Whamcloud - gitweb
LU-12477 kernel: remove dev_read_only handling
[fs/lustre-release.git] / lustre / kernel_patches / patches / dev_read_only-3.9.patch
diff --git a/lustre/kernel_patches/patches/dev_read_only-3.9.patch b/lustre/kernel_patches/patches/dev_read_only-3.9.patch
deleted file mode 100644 (file)
index 9e88df6..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-This patch is no longer needed for Lustre.  It is only included
-for testing and ease of using the same kernel with older Lustre
-versions.  This testing functionality was replaced in Linux 3.0
-by the dm-flakey driver.
-
-This functionality is mainly used during testing, in order to
-simulate a server crash for ldiskfs by discarding all of the
-writes to the filesystem.  For recovery testing we could simulate
-this by using a special loopback or DM device that also discards
-writes to the device.
-
-This functionality is also used by target "failback" in order
-to speed up service shutdown and takeover by the other node
-during controlled operation.  However, it would also be possible
-to do this by simply allowing all of the in-flight requests to
-complete and then waiting for the service to stop.  This will
-also be needed by the DMU-OSD, because discarding of writes on
-a DMU-based target is not safe as it could trigger a storage
-failure if the data is ever read from disk again and the
-checksum does not match that expected by the block pointer.
-
-Index: linux-4.4.59-1/block/blk-core.c
-===================================================================
---- linux-4.4.59-1.orig/block/blk-core.c
-+++ linux-4.4.59-1/block/blk-core.c
-@@ -1804,6 +1804,8 @@ static inline bool should_fail_request(s
- #endif /* CONFIG_FAIL_MAKE_REQUEST */
-+int dev_check_rdonly(struct block_device *bdev);
-+
- /*
-  * Check whether this bio extends beyond the end of the device.
-  */
-@@ -1857,6 +1859,12 @@ generic_make_request_checks(struct bio *
-               goto end_io;
-       }
-+      /* this is cfs's dev_rdonly check */
-+      if (bio_data_dir(bio) && dev_check_rdonly(bio->bi_bdev)) {
-+              err = 0;
-+              goto end_io;
-+      }
-+
-       part = bio->bi_bdev->bd_part;
-       if (should_fail_request(part, bio->bi_iter.bi_size) ||
-           should_fail_request(&part_to_disk(part)->part0,
-@@ -3454,6 +3462,99 @@ void blk_set_runtime_active(struct reque
- EXPORT_SYMBOL(blk_set_runtime_active);
- #endif
-+/*
-+ * Debug code for turning block devices "read-only" (will discard writes
-+ * silently).  This is for filesystem crash/recovery testing.
-+ */
-+struct deventry {
-+      dev_t dev;
-+      struct deventry *next;
-+};
-+
-+static struct deventry *devlist = NULL;
-+static spinlock_t devlock = __SPIN_LOCK_UNLOCKED(devlock);
-+
-+int dev_check_rdonly(struct block_device *bdev)
-+{
-+      struct deventry *cur;
-+
-+      if (!bdev)
-+              return 0;
-+
-+      spin_lock(&devlock);
-+      cur = devlist;
-+      while(cur) {
-+              if (bdev->bd_dev == cur->dev) {
-+                      spin_unlock(&devlock);
-+                      return 1;
-+              }
-+              cur = cur->next;
-+      }
-+      spin_unlock(&devlock);
-+      return 0;
-+}
-+
-+void dev_set_rdonly(struct block_device *bdev)
-+{
-+      struct deventry *newdev, *cur;
-+
-+      if (!bdev)
-+              return;
-+
-+      newdev = kmalloc(sizeof(struct deventry), GFP_KERNEL);
-+      if (!newdev)
-+              return;
-+
-+      spin_lock(&devlock);
-+      cur = devlist;
-+      while(cur) {
-+              if (bdev->bd_dev == cur->dev) {
-+                      spin_unlock(&devlock);
-+                      kfree(newdev);
-+                      return;
-+              }
-+              cur = cur->next;
-+      }
-+      newdev->dev = bdev->bd_dev;
-+      newdev->next = devlist;
-+      devlist = newdev;
-+      spin_unlock(&devlock);
-+      printk(KERN_WARNING "Turning device %s (%#x) read-only\n",
-+              bdev->bd_disk ? bdev->bd_disk->disk_name : "", bdev->bd_dev);
-+}
-+
-+void dev_clear_rdonly(struct block_device *bdev)
-+{
-+      struct deventry *cur, *last = NULL;
-+
-+      if (!bdev)
-+              return;
-+
-+      spin_lock(&devlock);
-+      cur = devlist;
-+      while(cur) {
-+              if (bdev->bd_dev == cur->dev) {
-+                      if (last)
-+                              last->next = cur->next;
-+                      else
-+                              devlist = cur->next;
-+                      spin_unlock(&devlock);
-+                      kfree(cur);
-+                      printk(KERN_WARNING "Removing read-only on %s (%#x)\n",
-+                              bdev->bd_disk ? bdev->bd_disk->disk_name :
-+                              "unknown block", bdev->bd_dev);
-+                      return;
-+              }
-+              last = cur;
-+              cur = cur->next;
-+      }
-+      spin_unlock(&devlock);
-+}
-+
-+EXPORT_SYMBOL(dev_set_rdonly);
-+EXPORT_SYMBOL(dev_clear_rdonly);
-+EXPORT_SYMBOL(dev_check_rdonly);
-+
- int __init blk_dev_init(void)
- {
-       BUILD_BUG_ON(REQ_OP_LAST >= (1 << REQ_OP_BITS));
-Index: linux-4.4.59-1/fs/block_dev.c
-===================================================================
---- linux-4.4.59-1.orig/fs/block_dev.c
-+++ linux-4.4.59-1/fs/block_dev.c
-@@ -1914,6 +1914,7 @@ static void __blkdev_put(struct block_de
-               if (bdev != bdev->bd_contains)
-                       victim = bdev->bd_contains;
-               bdev->bd_contains = NULL;
-+              dev_clear_rdonly(bdev);
-               put_disk(disk);
-               module_put(owner);
-Index: linux-4.4.59-1/include/linux/fs.h
-===================================================================
---- linux-4.4.59-1.orig/include/linux/fs.h
-+++ linux-4.4.59-1/include/linux/fs.h
-@@ -2624,6 +2624,10 @@ extern void inode_sb_list_add(struct ino
- #ifdef CONFIG_BLOCK
- extern int bdev_read_only(struct block_device *);
- #endif
-+#define HAVE_CLEAR_RDONLY_ON_PUT
-+extern void dev_set_rdonly(struct block_device *bdev);
-+extern int dev_check_rdonly(struct block_device *bdev);
-+extern void dev_clear_rdonly(struct block_device *bdev);
- extern int set_blocksize(struct block_device *, int);
- extern int sb_set_blocksize(struct super_block *, int);
- extern int sb_min_blocksize(struct super_block *, int);