1 Index: linux-2.6.10/drivers/block/ll_rw_blk.c
2 ===================================================================
3 --- linux-2.6.10.orig/drivers/block/ll_rw_blk.c 2004-12-25 05:33:59.000000000 +0800
4 +++ linux-2.6.10/drivers/block/ll_rw_blk.c 2005-04-07 00:37:34.299974720 +0800
6 set_bit(BIO_EOF, &bio->bi_flags);
9 +int dev_check_rdonly(struct block_device *bdev);
12 * generic_make_request: hand a buffer to its device driver for I/O
13 * @bio: The bio describing the location in memory and on the device.
14 @@ -2681,6 +2683,13 @@
16 block_wait_queue_running(q);
18 + /* this is cfs's dev_rdonly check */
19 + if (bio->bi_rw == WRITE &&
20 + dev_check_rdonly(bio->bi_bdev)) {
21 + bio_endio(bio, bio->bi_size, 0);
26 * If this device has partitions, remap block n
27 * of partition p to block n+start(p) of the disk.
28 @@ -3156,6 +3165,91 @@
29 EXPORT_SYMBOL(swap_io_context);
32 + * Debug code for turning block devices "read-only" (will discard writes
33 + * silently). This is for filesystem crash/recovery testing.
37 + struct deventry *next;
40 +static struct deventry *devlist = NULL;
41 +static spinlock_t devlock = SPIN_LOCK_UNLOCKED;
43 +int dev_check_rdonly(struct block_device *bdev)
45 + struct deventry *cur;
46 + if (!bdev) return 0;
47 + spin_lock(&devlock);
50 + if (bdev->bd_dev == cur->dev) {
51 + spin_unlock(&devlock);
56 + spin_unlock(&devlock);
60 +void dev_set_rdonly(struct block_device *bdev)
62 + struct deventry *newdev, *cur;
66 + newdev = kmalloc(sizeof(struct deventry), GFP_KERNEL);
70 + spin_lock(&devlock);
73 + if (bdev->bd_dev == cur->dev) {
74 + spin_unlock(&devlock);
80 + newdev->dev = bdev->bd_dev;
81 + newdev->next = devlist;
83 + spin_unlock(&devlock);
84 + printk(KERN_WARNING "Turning device %s read-only\n",
85 + bdev->bd_disk ? bdev->bd_disk->disk_name : "?");
88 +void dev_clear_rdonly(struct block_device *bdev)
90 + struct deventry *cur, *last = NULL;
92 + spin_lock(&devlock);
95 + if (bdev->bd_dev == cur->dev) {
97 + last->next = cur->next;
99 + devlist = cur->next;
100 + spin_unlock(&devlock);
102 + printk(KERN_WARNING "Removing read-only on %s\n",
103 + bdev->bd_disk ? bdev->bd_disk->disk_name : "?");
109 + spin_unlock(&devlock);
112 +EXPORT_SYMBOL(dev_set_rdonly);
113 +EXPORT_SYMBOL(dev_clear_rdonly);
114 +EXPORT_SYMBOL(dev_check_rdonly);
119 struct queue_sysfs_entry {