]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.9-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2017 13:02:43 +0000 (15:02 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2017 13:02:43 +0000 (15:02 +0200)
added patches:
block-get-rid-of-blk_integrity_revalidate.patch

queue-4.9/block-get-rid-of-blk_integrity_revalidate.patch [new file with mode: 0644]
queue-4.9/series

diff --git a/queue-4.9/block-get-rid-of-blk_integrity_revalidate.patch b/queue-4.9/block-get-rid-of-blk_integrity_revalidate.patch
new file mode 100644 (file)
index 0000000..570993c
--- /dev/null
@@ -0,0 +1,125 @@
+From 19b7ccf8651df09d274671b53039c672a52ad84d Mon Sep 17 00:00:00 2001
+From: Ilya Dryomov <idryomov@gmail.com>
+Date: Tue, 18 Apr 2017 18:43:20 +0200
+Subject: block: get rid of blk_integrity_revalidate()
+
+From: Ilya Dryomov <idryomov@gmail.com>
+
+commit 19b7ccf8651df09d274671b53039c672a52ad84d upstream.
+
+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.
+
+Fixes: 25520d55cdb6 ("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>
+
+---
+ 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(-)
+
+--- a/block/blk-integrity.c
++++ b/block/blk-integrity.c
+@@ -417,7 +417,7 @@ void blk_integrity_register(struct gendi
+       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,
+--- a/block/partition-generic.c
++++ b/block/partition-generic.c
+@@ -447,7 +447,6 @@ rescan:
+       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)))
+--- a/fs/block_dev.c
++++ b/fs/block_dev.c
+@@ -1165,7 +1165,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;
+--- a/include/linux/genhd.h
++++ b/include/linux/genhd.h
+@@ -731,11 +731,9 @@ static inline void part_nr_sects_write(s
+ #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 */
index f15b7aebb045ce75967ffc2feb63ca9d7ab73a2c..306f7bb46c336e2d80cc2ed9f326a992c229055d 100644 (file)
@@ -100,3 +100,4 @@ xen-revert-commits-da72ff5bfcb0-and-72a9b186292d.patch
 wlcore-pass-win_size-taken-from-ieee80211_sta-to-fw.patch
 wlcore-add-rx_ba_win_size_change_event-event.patch
 drm-ttm-fix-use-after-free-races-in-vm-fault-handling.patch
+block-get-rid-of-blk_integrity_revalidate.patch