failure if the data is ever read from disk again and the
checksum does not match that expected by the block pointer.
-Index: linux-2.6.27.21-0.1/block/blk-core.c
+Index: linux-3.0/block/blk-core.c
===================================================================
---- linux-2.6.27.21-0.1.orig/block/blk-core.c 2009-04-23 02:12:51.000000000 -0600
-+++ linux-2.6.27.21-0.1/block/blk-core.c 2009-05-22 08:38:02.000000000 -0600
-@@ -1335,6 +1335,8 @@
+--- linux-3.0.orig/block/blk-core.c 2013-01-25 11:25:32.000000000 -0500
++++ linux-3.0/block/blk-core.c 2013-01-25 11:31:53.000000000 -0500
+@@ -1390,6 +1390,8 @@
#endif /* CONFIG_FAIL_MAKE_REQUEST */
/*
* Check whether this bio extends beyond the end of the device.
*/
-@@ -1436,6 +1438,12 @@
-
+@@ -1491,6 +1493,12 @@
if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags)))
goto end_io;
-
-+ /* this is cfs's dev_rdonly check */
-+ if (bio_rw(bio) == WRITE && dev_check_rdonly(bio->bi_bdev)) {
-+ bio_endio(bio, bio->bi_size, 0);
-+ break;
-+ }
+
++ /* this is cfs's dev_rdonly check */
++ if (bio_rw(bio) == WRITE && dev_check_rdonly(bio->bi_bdev)) {
++ err = 0;
++ goto end_io;
++ }
+
if (should_fail_request(bio))
goto end_io;
-@@ -2189,6 +2197,91 @@
+
+@@ -2796,6 +2804,99 @@
}
- EXPORT_SYMBOL(kblockd_flush_work);
+ EXPORT_SYMBOL(blk_finish_plug);
-+ /*
++/*
+ * Debug code for turning block devices "read-only" (will discard writes
+ * silently). This is for filesystem crash/recovery testing.
+ */
+};
+
+static struct deventry *devlist = NULL;
-+static spinlock_t devlock = SPIN_LOCK_UNLOCKED;
++static spinlock_t devlock = __SPIN_LOCK_UNLOCKED(devlock);
+
-+int dev_check_rdonly(struct block_device *bdev)
++int dev_check_rdonly(struct block_device *bdev)
+{
+ struct deventry *cur;
-+ if (!bdev) return 0;
++
++ 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);
+{
+ struct deventry *newdev, *cur;
+
-+ if (!bdev)
++ if (!bdev)
+ return;
++
+ newdev = kmalloc(sizeof(struct deventry), GFP_KERNEL);
-+ if (!newdev)
++ if (!newdev)
+ return;
-+
++
+ spin_lock(&devlock);
+ cur = devlist;
+ while(cur) {
+ 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);
++ bdev->bd_disk ? bdev->bd_disk->disk_name : "", bdev->bd_dev);
+}
+
-+void dev_clear_rdonly(struct block_device *bdev)
++void dev_clear_rdonly(struct block_device *bdev)
+{
+ struct deventry *cur, *last = NULL;
-+ if (!bdev) return;
++
++ if (!bdev)
++ return;
++
+ spin_lock(&devlock);
+ cur = devlist;
+ while(cur) {
+ if (bdev->bd_dev == cur->dev) {
-+ if (last)
++ 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);
++ bdev->bd_disk ? bdev->bd_disk->disk_name :
++ "unknown block", bdev->bd_dev);
+ return;
+ }
+ last = cur;
+EXPORT_SYMBOL(dev_set_rdonly);
+EXPORT_SYMBOL(dev_clear_rdonly);
+EXPORT_SYMBOL(dev_check_rdonly);
++
int __init blk_dev_init(void)
{
- kblockd_workqueue = create_workqueue("kblockd");
-Index: linux-2.6.27.21-0.1/fs/block_dev.c
+ BUILD_BUG_ON(__REQ_NR_BITS > 8 *
+Index: linux-2.6.32-131.0.15.el6.x86_64/fs/block_dev.c
===================================================================
---- linux-2.6.27.21-0.1.orig/fs/block_dev.c 2009-04-23 02:12:56.000000000 -0600
-+++ linux-2.6.27.21-0.1/fs/block_dev.c 2009-05-22 08:38:02.000000000 -0600
-@@ -1208,6 +1208,7 @@
+--- linux-2.6.32-131.0.15.el6.x86_64.orig/fs/block_dev.c 2011-05-10 21:38:29.000000000 +0300
++++ linux-2.6.32-131.0.15.el6.x86_64/fs/block_dev.c 2011-05-19 21:01:04.000000000 +0300
+@@ -1389,6 +1389,7 @@ static int __blkdev_put(struct block_dev
if (bdev != bdev->bd_contains)
victim = bdev->bd_contains;
bdev->bd_contains = NULL;
+ dev_clear_rdonly(bdev);
- }
- unlock_kernel();
- mutex_unlock(&bdev->bd_mutex);
-Index: linux-2.6.27.21-0.1/include/linux/fs.h
+
+ put_disk(disk);
+ module_put(owner);
+Index: linux-2.6.32-131.0.15.el6.x86_64/include/linux/fs.h
===================================================================
---- linux-2.6.27.21-0.1.orig/include/linux/fs.h 2009-05-22 08:38:00.000000000 -0600
-+++ linux-2.6.27.21-0.1/include/linux/fs.h 2009-05-22 08:38:02.000000000 -0600
-@@ -1898,6 +1898,10 @@
+--- linux-2.6.32-131.0.15.el6.x86_64.orig/include/linux/fs.h 2011-05-10 21:38:29.000000000 +0300
++++ linux-2.6.32-131.0.15.el6.x86_64/include/linux/fs.h 2011-05-19 21:01:04.000000000 +0300
+@@ -2244,6 +2244,10 @@ struct bio;
extern void submit_bio(int, struct bio *);
extern int bdev_read_only(struct block_device *);
#endif