Skip to content

Commit 4a4c6a0

Browse files
idryomovgregkh
authored andcommitted
block: get rid of blk_integrity_revalidate()
commit 19b7ccf8651df09d274671b53039c672a52ad84d upstream. Commit 25520d5 ("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. Fixes: 25520d5 ("block: Inline blk_integrity in struct gendisk") Cc: "Martin K. Petersen" <martin.petersen@oracle.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Mike Snitzer <snitzer@redhat.com> Tested-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com> [idryomov@gmail.com: backport to < 4.11: bdi is embedded in queue] Signed-off-by: Jens Axboe <axboe@fb.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 60e3f5a commit 4a4c6a0

4 files changed

Lines changed: 2 additions & 21 deletions

File tree

block/blk-integrity.c

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ void blk_integrity_register(struct gendisk *disk, struct blk_integrity *template
417417
bi->tuple_size = template->tuple_size;
418418
bi->tag_size = template->tag_size;
419419

420-
blk_integrity_revalidate(disk);
420+
disk->queue->backing_dev_info.capabilities |= BDI_CAP_STABLE_WRITES;
421421
}
422422
EXPORT_SYMBOL(blk_integrity_register);
423423

@@ -430,26 +430,11 @@ EXPORT_SYMBOL(blk_integrity_register);
430430
*/
431431
void blk_integrity_unregister(struct gendisk *disk)
432432
{
433-
blk_integrity_revalidate(disk);
433+
disk->queue->backing_dev_info.capabilities &= ~BDI_CAP_STABLE_WRITES;
434434
memset(&disk->queue->integrity, 0, sizeof(struct blk_integrity));
435435
}
436436
EXPORT_SYMBOL(blk_integrity_unregister);
437437

438-
void blk_integrity_revalidate(struct gendisk *disk)
439-
{
440-
struct blk_integrity *bi = &disk->queue->integrity;
441-
442-
if (!(disk->flags & GENHD_FL_UP))
443-
return;
444-
445-
if (bi->profile)
446-
disk->queue->backing_dev_info.capabilities |=
447-
BDI_CAP_STABLE_WRITES;
448-
else
449-
disk->queue->backing_dev_info.capabilities &=
450-
~BDI_CAP_STABLE_WRITES;
451-
}
452-
453438
void blk_integrity_add(struct gendisk *disk)
454439
{
455440
if (kobject_init_and_add(&disk->integrity_kobj, &integrity_ktype,

block/partition-generic.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,6 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
435435

436436
if (disk->fops->revalidate_disk)
437437
disk->fops->revalidate_disk(disk);
438-
blk_integrity_revalidate(disk);
439438
check_disk_size_change(disk, bdev);
440439
bdev->bd_invalidated = 0;
441440
if (!get_capacity(disk) || !(state = check_partition(disk, bdev)))

fs/block_dev.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,6 @@ int revalidate_disk(struct gendisk *disk)
10981098

10991099
if (disk->fops->revalidate_disk)
11001100
ret = disk->fops->revalidate_disk(disk);
1101-
blk_integrity_revalidate(disk);
11021101
bdev = bdget_disk(disk, 0);
11031102
if (!bdev)
11041103
return ret;

include/linux/genhd.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,11 +742,9 @@ static inline void part_nr_sects_write(struct hd_struct *part, sector_t size)
742742
#if defined(CONFIG_BLK_DEV_INTEGRITY)
743743
extern void blk_integrity_add(struct gendisk *);
744744
extern void blk_integrity_del(struct gendisk *);
745-
extern void blk_integrity_revalidate(struct gendisk *);
746745
#else /* CONFIG_BLK_DEV_INTEGRITY */
747746
static inline void blk_integrity_add(struct gendisk *disk) { }
748747
static inline void blk_integrity_del(struct gendisk *disk) { }
749-
static inline void blk_integrity_revalidate(struct gendisk *disk) { }
750748
#endif /* CONFIG_BLK_DEV_INTEGRITY */
751749

752750
#else /* CONFIG_BLOCK */

0 commit comments

Comments
 (0)