X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fkernel_patches%2Fpatches%2Fdev_read_only-2.6-suse.patch;fp=lustre%2Fkernel_patches%2Fpatches%2Fdev_read_only-2.6-suse.patch;h=9639f28126da5b5e2232ee364d4ceed953b12379;hb=3de901fceee79de12a31428bcc6ba3a00f10d1fe;hp=0000000000000000000000000000000000000000;hpb=94019f04d0103e90fd12f041763da20518308882;p=fs%2Flustre-release.git diff --git a/lustre/kernel_patches/patches/dev_read_only-2.6-suse.patch b/lustre/kernel_patches/patches/dev_read_only-2.6-suse.patch new file mode 100644 index 0000000..9639f28 --- /dev/null +++ b/lustre/kernel_patches/patches/dev_read_only-2.6-suse.patch @@ -0,0 +1,81 @@ + drivers/block/ll_rw_blk.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ + include/linux/blkdev.h | 1 + 2 files changed, 50 insertions(+) + +Index: linux-2.6.0/drivers/block/ll_rw_blk.c +=================================================================== +--- linux-2.6.0.orig/drivers/block/ll_rw_blk.c 2004-01-04 15:27:35.000000000 +0300 ++++ linux-2.6.0/drivers/block/ll_rw_blk.c 2004-01-07 17:35:57.000000000 +0300 +@@ -2298,6 +2298,13 @@ + if (test_bit(QUEUE_FLAG_DEAD, &q->queue_flags)) + goto end_io; + ++ /* this is cfs's dev_rdonly check */ ++ if (bio->bi_rw == WRITE && ++ dev_check_rdonly(bio->bi_bdev->bd_dev)) { ++ bio_endio(bio, bio->bi_size, 0); ++ break; ++ } ++ + /* + * If this device has partitions, remap block n + * of partition p to block n+start(p) of the disk. +@@ -2805,6 +2812,58 @@ + *ioc2 = temp; + } + ++#define MAX_RDONLY_DEVS 16 ++ ++static dev_t rdonly_devs[MAX_RDONLY_DEVS] = {0, }; ++ ++/* ++ * Debug code for turning block devices "read-only" (will discard writes ++ * silently). This is for filesystem crash/recovery testing. ++ */ ++void dev_set_rdonly(struct block_device *bdev, int no_write) ++{ ++ if (no_write >= MAX_RDONLY_DEVS) { ++ printk(KERN_ALERT "%s:%d illegal arg %d (max %d)\n", ++ __FILE__, __LINE__, no_write, MAX_RDONLY_DEVS); ++ return; ++ } ++ ++ if (bdev) { ++ printk(KERN_WARNING "Turning device %s read-only at %d\n", ++ bdev->bd_disk ? bdev->bd_disk->disk_name : "?", ++ no_write); ++ rdonly_devs[no_write] = bdev->bd_dev; ++ } ++} ++ ++void dev_clear_rdonly(int no_write) ++{ ++ if (no_write >= MAX_RDONLY_DEVS) { ++ printk(KERN_ALERT "%s:%d illegal arg %d (max %d)\n", ++ __FILE__, __LINE__, no_write, MAX_RDONLY_DEVS); ++ return; ++ } ++ ++ if (rdonly_devs[no_write] == 0) ++ return; ++ ++ printk(KERN_WARNING "Clearing read-only at %d\n", no_write); ++ rdonly_devs[no_write] = 0; ++} ++ ++int dev_check_rdonly(dev_t dev) ++{ ++ int i; ++ ++ for (i = 0; i < MAX_RDONLY_DEVS; i++) ++ if (rdonly_devs[i] == dev) ++ return 1; ++ return 0; ++} ++ ++EXPORT_SYMBOL(dev_set_rdonly); ++EXPORT_SYMBOL(dev_clear_rdonly); ++EXPORT_SYMBOL(dev_check_rdonly); + + /* + * sysfs parts below