Message ID | 20240704061515.282343-1-joshi.k@samsung.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | block: t10-pi: Return correct ref tag when queue has no integrity profile | expand |
On Thu, Jul 04, 2024 at 11:45:15AM +0530, Kanchan Joshi wrote: > From: Anuj Gupta <anuj20.g@samsung.com> > > Commit <c6e56cf6b2e7> (block: move integrity information into > queue_limits) changed the ref tag calculation logic. It would break if > there is no integrity profile. This in turn causes read/write failures > for such cases. Can you explain the scenario a bit better? I guess this is for when the drivers use PRACT to insert/strip PI because BLK_DEV_INTEGRITY is disabled? > > Fixes: <c6e56cf6b2e7> (block: move integrity information into queue_limits) This is not the standard formatting for fixes tags. > > static inline u32 t10_pi_ref_tag(struct request *rq) > { > - unsigned int shift = rq->q->limits.integrity.interval_exp; > + unsigned int shift = ilog2(queue_logical_block_size(rq->q)); > > + if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) && > + rq->q->limits.integrity.interval_exp) > + shift = rq->q->limits.integrity.interval_exp; > return blk_rq_pos(rq) >> (shift - SECTOR_SHIFT) & 0xffffffff; But this only works when the interval_exp equals the block size. So I think the proper fix that not only addresses the regression, but also the long standing buf for larger interval_exp is to make sure interval_exp is always initialized, including for !CONFIG_BLK_DEV_INTEGRITY.
Looking a bit more it seems like never actually merged the SCSI support for an interval_exp smaller than the block size, although I'm pretty sure I've seen Martins patches for it. So i guess we should just go with this patch (preferably with the fixed Fixes tag and a more detailed commit log) and then sort this out later.
On Thu, 04 Jul 2024 11:45:15 +0530, Kanchan Joshi wrote: > Commit <c6e56cf6b2e7> (block: move integrity information into > queue_limits) changed the ref tag calculation logic. It would break if > there is no integrity profile. This in turn causes read/write failures > for such cases. > > Applied, thanks! [1/1] block: t10-pi: Return correct ref tag when queue has no integrity profile commit: 162e06871e6dcde861ef608e0c00a8b6a2d35d43 Best regards,
Christoph, > Looking a bit more it seems like never actually merged the SCSI > support for an interval_exp smaller than the block size, although I'm > pretty sure I've seen Martins patches for it. So i guess we should > just go with this patch (preferably with the fixed Fixes tag and a > more detailed commit log) and then sort this out later. The driver for this feature was being able to use disks with 4Kn sectors and yet provide 8 bytes of PI for every 512 bytes of data for backwards compatibility reasons. I had a couple of drives which supported the feature and several OEMs were requesting it. However, it turned out that using 512e drives was a much more elegant solution to this particular problem.
On Thu, Jul 04, 2024 at 11:49:56PM -0400, Martin K. Petersen wrote: > I had a couple of drives which supported the feature and several OEMs > were requesting it. However, it turned out that using 512e drives was a > much more elegant solution to this particular problem. So should we just drop the internval_exp member for now? It would simplify things a bit, but more importantly we wouldn't have to fix the !BLK_DEV_INTEGRITY case for strip/insert.
Christoph, > So should we just drop the internval_exp member for now? It would > simplify things a bit, but more importantly we wouldn't have to fix > the !BLK_DEV_INTEGRITY case for strip/insert. Yeah, I think that's fine. 512e won.
diff --git a/include/linux/t10-pi.h b/include/linux/t10-pi.h index 1773610010eb..2c59fe3efcd4 100644 --- a/include/linux/t10-pi.h +++ b/include/linux/t10-pi.h @@ -39,8 +39,11 @@ struct t10_pi_tuple { static inline u32 t10_pi_ref_tag(struct request *rq) { - unsigned int shift = rq->q->limits.integrity.interval_exp; + unsigned int shift = ilog2(queue_logical_block_size(rq->q)); + if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) && + rq->q->limits.integrity.interval_exp) + shift = rq->q->limits.integrity.interval_exp; return blk_rq_pos(rq) >> (shift - SECTOR_SHIFT) & 0xffffffff; } @@ -61,8 +64,11 @@ static inline u64 lower_48_bits(u64 n) static inline u64 ext_pi_ref_tag(struct request *rq) { - unsigned int shift = rq->q->limits.integrity.interval_exp; + unsigned int shift = ilog2(queue_logical_block_size(rq->q)); + if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) && + rq->q->limits.integrity.interval_exp) + shift = rq->q->limits.integrity.interval_exp; return lower_48_bits(blk_rq_pos(rq) >> (shift - SECTOR_SHIFT)); }