Backport of 19b7ccf8651d
Hi Greg,
Please apply the following backport of 19b7ccf8651d ("block: get rid of blk_integrity_revalidate()") to 4.4, 4.9 and 4.10.
The original commit also needs to go into 4.11, as noted in the commit message.
Thanks,
Ilya
PATCH 1/1 block: get rid of blk_integrity_revalidate()
Commit 25520d55cdb6 ("block: Inline blk_integrity in struct gendisk") introduced blk_integrity_revalidate(), which seems to assume ownership of the stable pages flag and unilaterally clears it if no blk_integrity profile is registered:
if (bi->profile)
disk->queue->backing_dev_info->capabilities |=
BDI_CAP_STABLE_WRITES;
else
disk->queue->backing_dev_info->capabilities &=
~BDI_CAP_STABLE_WRITES;It's called from revalidate_disk() and rescan_partitions(), making it impossible to enable stable pages for drivers that support partitions and don't use blk_integrity: while the call in revalidate_disk() can be trivially worked around (see zram, which doesn't support partitions and hence gets away with zram_revalidate_disk()), rescan_partitions() can be triggered from userspace at any time. This breaks rbd, where the ceph messenger is responsible for generating/verifying CRCs.
Since blk_integrity_{un,}register() "must" be used for (un)registering the integrity profile with the block layer, move BDI_CAP_STABLE_WRITES setting there. This way drivers that call blk_integrity_register() and use integrity infrastructure won't interfere with drivers that don't but still want stable pages.
--- block/blk-integrity.c | 19 ++----------------- block/partition-generic.c | 1 - fs/block_dev.c | 1 - include/linux/genhd.h | 2 -- 4 files changed, 2 insertions(+), 21 deletions(-)
block/blk-integrity.c +2 -17
@@ -417,7 +417,7 @@ void blk_integrity_register(struct gendisk *disk, struct blk_integrity *template bi->tuple_size = template->tuple_size; bi->tag_size = template->tag_size; -blk_integrity_revalidate (disk); + disk->queue->backing_dev_info.capabilities |=BDI_CAP_STABLE_WRITES ; }EXPORT_SYMBOL (blk_integrity_register);
@@ -430,26 +430,11 @@ EXPORT_SYMBOL(blk_integrity_register);*/ void blk_integrity_unregister (struct gendisk *disk) { -blk_integrity_revalidate (disk); + disk->queue->backing_dev_info.capabilities &= ~BDI_CAP_STABLE_WRITES ;memset (&disk->queue->integrity,0 ,sizeof (struct blk_integrity )); }EXPORT_SYMBOL (blk_integrity_unregister); -void blk_integrity_revalidate (struct gendisk *disk) -{ -struct blk_integrity *bi = &disk->queue->integrity; - -if (!(disk->flags &GENHD_FL_UP )) -return ; - -if (bi->profile) - disk->queue->backing_dev_info.capabilities |= -BDI_CAP_STABLE_WRITES ; -else - disk->queue->backing_dev_info.capabilities &= - ~BDI_CAP_STABLE_WRITES ; -} -void blk_integrity_add (struct gendisk *disk) { if (kobject_init_and_add(&disk->integrity_kobj, &integrity_ktype,
block/partition-generic.c +0 -1
@@ -497,7 +497,6 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)if (disk->fops->revalidate_disk) disk->fops->revalidate_disk (disk); -blk_integrity_revalidate (disk);check_disk_size_change (disk, bdev); bdev->bd_invalidated =0 ;if (!get_capacity (disk) || !(state =check_partition (disk, bdev)))
fs/block_dev.c +0 -1
@@ -1422,7 +1422,6 @@ int revalidate_disk(struct gendisk *disk)if (disk->fops->revalidate_disk) ret = disk->fops->revalidate_disk (disk); -blk_integrity_revalidate (disk); bdev =bdget_disk (disk,0 );if (!bdev)return ret;
include/linux/genhd.h +0 -2
@@ -722,11 +722,9 @@ static inline void part_nr_sects_write(struct hd_struct *part, sector_t size)#if defined(CONFIG_BLK_DEV_INTEGRITY )extern void blk_integrity_add (struct gendisk *);extern void blk_integrity_del (struct gendisk *); -extern void blk_integrity_revalidate (struct gendisk *);#else /* CONFIG_BLK_DEV_INTEGRITY */ static inline void blk_integrity_add (struct gendisk *disk) { }static inline void blk_integrity_del (struct gendisk *disk) { } -static inline void blk_integrity_revalidate (struct gendisk *disk) { }#endif /* CONFIG_BLK_DEV_INTEGRITY */ #else /* CONFIG_BLOCK */
Signature · 1 line
2.4.3
Greg KH
maintainerRe: [PATCH for 4.4-4.10] block: get rid of blk_integrity_revalidate()
Quoted 35 lines · Ilya Dryomov
Commit
25520d55cdb6("block: Inlineblk_integrityin struct gendisk") introducedblk_integrity_revalidate(), which seems to assume ownership of the stable pages flag and unilaterally clears it if noblk_integrityprofile is registered:if (bi->profile) disk->queue->backing_dev_info->capabilities |= BDI_CAP_STABLE_WRITES; else disk->queue->backing_dev_info->capabilities &= ~BDI_CAP_STABLE_WRITES;It's called from
revalidate_disk()andrescan_partitions(), making it impossible to enable stable pages for drivers that support partitions and don't useblk_integrity: while the call inrevalidate_disk()can be trivially worked around (see zram, which doesn't support partitions and hence gets away withzram_revalidate_disk()),rescan_partitions()can be triggered from userspace at any time. This breaks rbd, where the ceph messenger is responsible for generating/verifying CRCs.Since blk_integrity_{un,}register() "must" be used for (un)registering the integrity profile with the block layer, move
BDI_CAP_STABLE_WRITESsetting there. This way drivers that callblk_integrity_register()and use integrity infrastructure won't interfere with drivers that don't but still want stable pages.Fixes 25520d55cdb6 ("block: Inline blk_integrity in struct gendisk")Cc "Martin K. Petersen" <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Mike Snitzer <[email protected]>Cc [email protected] # 4.4+, needs backportingTested-by Dan Williams <[email protected]>Signed-off-by Ilya Dryomov <[email protected]>Signed-off-by Jens Axboe <[email protected]>[[email protected]: backport to < 4.11: bdi is embedded in queue]
Quoted 6 lines
--- block/blk-integrity.c | 19 ++----------------- block/partition-generic.c | 1 - fs/block_dev.c | 1 - include/linux/genhd.h | 2 -- 4 files changed, 2 insertions(+), 21 deletions(-)
Now queued up, thanks for the backport!
greg k-h