@@ -120,76 +120,22 @@ static blk_status_t t10_pi_type1_verify_ip(struct blk_integrity_iter *iter)
120120 return t10_pi_verify (iter , t10_pi_ip_fn , T10_PI_TYPE1_PROTECTION );
121121}
122122
123- static blk_status_t t10_pi_type3_generate_crc (struct blk_integrity_iter * iter )
124- {
125- return t10_pi_generate (iter , t10_pi_crc_fn , T10_PI_TYPE3_PROTECTION );
126- }
127-
128- static blk_status_t t10_pi_type3_generate_ip (struct blk_integrity_iter * iter )
129- {
130- return t10_pi_generate (iter , t10_pi_ip_fn , T10_PI_TYPE3_PROTECTION );
131- }
132-
133- static blk_status_t t10_pi_type3_verify_crc (struct blk_integrity_iter * iter )
134- {
135- return t10_pi_verify (iter , t10_pi_crc_fn , T10_PI_TYPE3_PROTECTION );
136- }
137-
138- static blk_status_t t10_pi_type3_verify_ip (struct blk_integrity_iter * iter )
139- {
140- return t10_pi_verify (iter , t10_pi_ip_fn , T10_PI_TYPE3_PROTECTION );
141- }
142-
143- const struct blk_integrity_profile t10_pi_type1_crc = {
144- .name = "T10-DIF-TYPE1-CRC" ,
145- .generate_fn = t10_pi_type1_generate_crc ,
146- .verify_fn = t10_pi_type1_verify_crc ,
147- };
148- EXPORT_SYMBOL (t10_pi_type1_crc );
149-
150- const struct blk_integrity_profile t10_pi_type1_ip = {
151- .name = "T10-DIF-TYPE1-IP" ,
152- .generate_fn = t10_pi_type1_generate_ip ,
153- .verify_fn = t10_pi_type1_verify_ip ,
154- };
155- EXPORT_SYMBOL (t10_pi_type1_ip );
156-
157- const struct blk_integrity_profile t10_pi_type3_crc = {
158- .name = "T10-DIF-TYPE3-CRC" ,
159- .generate_fn = t10_pi_type3_generate_crc ,
160- .verify_fn = t10_pi_type3_verify_crc ,
161- };
162- EXPORT_SYMBOL (t10_pi_type3_crc );
163-
164- const struct blk_integrity_profile t10_pi_type3_ip = {
165- .name = "T10-DIF-TYPE3-IP" ,
166- .generate_fn = t10_pi_type3_generate_ip ,
167- .verify_fn = t10_pi_type3_verify_ip ,
168- };
169- EXPORT_SYMBOL (t10_pi_type3_ip );
170-
171123/**
172- * t10_pi_prepare - prepare PI prior submitting request to device
124+ * t10_pi_type1_prepare - prepare PI prior submitting request to device
173125 * @rq: request with PI that should be prepared
174- * @protection_type: PI type (Type 1/Type 2/Type 3)
175126 *
176127 * For Type 1/Type 2, the virtual start sector is the one that was
177128 * originally submitted by the block layer for the ref_tag usage. Due to
178129 * partitioning, MD/DM cloning, etc. the actual physical start sector is
179130 * likely to be different. Remap protection information to match the
180131 * physical LBA.
181- *
182- * Type 3 does not have a reference tag so no remapping is required.
183132 */
184- void t10_pi_prepare (struct request * rq , u8 protection_type )
133+ static void t10_pi_type1_prepare (struct request * rq )
185134{
186135 const int tuple_sz = rq -> q -> integrity .tuple_size ;
187136 u32 ref_tag = t10_pi_ref_tag (rq );
188137 struct bio * bio ;
189138
190- if (protection_type == T10_PI_TYPE3_PROTECTION )
191- return ;
192-
193139 __rq_for_each_bio (bio , rq ) {
194140 struct bio_integrity_payload * bip = bio_integrity (bio );
195141 u32 virt = bip_get_seed (bip ) & 0xffffffff ;
@@ -222,33 +168,26 @@ void t10_pi_prepare(struct request *rq, u8 protection_type)
222168 bip -> bip_flags |= BIP_MAPPED_INTEGRITY ;
223169 }
224170}
225- EXPORT_SYMBOL (t10_pi_prepare );
226171
227172/**
228- * t10_pi_complete - prepare PI prior returning request to the block layer
173+ * t10_pi_type1_complete - prepare PI prior returning request to the blk layer
229174 * @rq: request with PI that should be prepared
230- * @protection_type: PI type (Type 1/Type 2/Type 3)
231- * @intervals: total elements to prepare
175+ * @nr_bytes: total bytes to prepare
232176 *
233177 * For Type 1/Type 2, the virtual start sector is the one that was
234178 * originally submitted by the block layer for the ref_tag usage. Due to
235179 * partitioning, MD/DM cloning, etc. the actual physical start sector is
236180 * likely to be different. Since the physical start sector was submitted
237181 * to the device, we should remap it back to virtual values expected by the
238182 * block layer.
239- *
240- * Type 3 does not have a reference tag so no remapping is required.
241183 */
242- void t10_pi_complete (struct request * rq , u8 protection_type ,
243- unsigned int intervals )
184+ static void t10_pi_type1_complete (struct request * rq , unsigned int nr_bytes )
244185{
186+ unsigned intervals = nr_bytes >> rq -> q -> integrity .interval_exp ;
245187 const int tuple_sz = rq -> q -> integrity .tuple_size ;
246188 u32 ref_tag = t10_pi_ref_tag (rq );
247189 struct bio * bio ;
248190
249- if (protection_type == T10_PI_TYPE3_PROTECTION )
250- return ;
251-
252191 __rq_for_each_bio (bio , rq ) {
253192 struct bio_integrity_payload * bip = bio_integrity (bio );
254193 u32 virt = bip_get_seed (bip ) & 0xffffffff ;
@@ -276,4 +215,73 @@ void t10_pi_complete(struct request *rq, u8 protection_type,
276215 }
277216 }
278217}
279- EXPORT_SYMBOL (t10_pi_complete );
218+
219+ static blk_status_t t10_pi_type3_generate_crc (struct blk_integrity_iter * iter )
220+ {
221+ return t10_pi_generate (iter , t10_pi_crc_fn , T10_PI_TYPE3_PROTECTION );
222+ }
223+
224+ static blk_status_t t10_pi_type3_generate_ip (struct blk_integrity_iter * iter )
225+ {
226+ return t10_pi_generate (iter , t10_pi_ip_fn , T10_PI_TYPE3_PROTECTION );
227+ }
228+
229+ static blk_status_t t10_pi_type3_verify_crc (struct blk_integrity_iter * iter )
230+ {
231+ return t10_pi_verify (iter , t10_pi_crc_fn , T10_PI_TYPE3_PROTECTION );
232+ }
233+
234+ static blk_status_t t10_pi_type3_verify_ip (struct blk_integrity_iter * iter )
235+ {
236+ return t10_pi_verify (iter , t10_pi_ip_fn , T10_PI_TYPE3_PROTECTION );
237+ }
238+
239+ /**
240+ * Type 3 does not have a reference tag so no remapping is required.
241+ */
242+ static void t10_pi_type3_prepare (struct request * rq )
243+ {
244+ }
245+
246+ /**
247+ * Type 3 does not have a reference tag so no remapping is required.
248+ */
249+ static void t10_pi_type3_complete (struct request * rq , unsigned int nr_bytes )
250+ {
251+ }
252+
253+ const struct blk_integrity_profile t10_pi_type1_crc = {
254+ .name = "T10-DIF-TYPE1-CRC" ,
255+ .generate_fn = t10_pi_type1_generate_crc ,
256+ .verify_fn = t10_pi_type1_verify_crc ,
257+ .prepare_fn = t10_pi_type1_prepare ,
258+ .complete_fn = t10_pi_type1_complete ,
259+ };
260+ EXPORT_SYMBOL (t10_pi_type1_crc );
261+
262+ const struct blk_integrity_profile t10_pi_type1_ip = {
263+ .name = "T10-DIF-TYPE1-IP" ,
264+ .generate_fn = t10_pi_type1_generate_ip ,
265+ .verify_fn = t10_pi_type1_verify_ip ,
266+ .prepare_fn = t10_pi_type1_prepare ,
267+ .complete_fn = t10_pi_type1_complete ,
268+ };
269+ EXPORT_SYMBOL (t10_pi_type1_ip );
270+
271+ const struct blk_integrity_profile t10_pi_type3_crc = {
272+ .name = "T10-DIF-TYPE3-CRC" ,
273+ .generate_fn = t10_pi_type3_generate_crc ,
274+ .verify_fn = t10_pi_type3_verify_crc ,
275+ .prepare_fn = t10_pi_type3_prepare ,
276+ .complete_fn = t10_pi_type3_complete ,
277+ };
278+ EXPORT_SYMBOL (t10_pi_type3_crc );
279+
280+ const struct blk_integrity_profile t10_pi_type3_ip = {
281+ .name = "T10-DIF-TYPE3-IP" ,
282+ .generate_fn = t10_pi_type3_generate_ip ,
283+ .verify_fn = t10_pi_type3_verify_ip ,
284+ .prepare_fn = t10_pi_type3_prepare ,
285+ .complete_fn = t10_pi_type3_complete ,
286+ };
287+ EXPORT_SYMBOL (t10_pi_type3_ip );
0 commit comments