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-08 12:35:49.785573840 +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,79 @@
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 list_head dev_list;
39 +static struct list_head devlist = LIST_HEAD_INIT(devlist);
40 +static spinlock_t devlock = SPIN_LOCK_UNLOCKED;
42 +int dev_check_rdonly(struct block_device *bdev)
44 + struct deventry *cur;
45 + if (!bdev) return 0;
46 + spin_lock(&devlock);
47 + list_for_each_entry(cur, &devlist, dev_list) {
48 + if (bdev->bd_dev == cur->dev) {
49 + spin_unlock(&devlock);
53 + spin_unlock(&devlock);
57 +void dev_set_rdonly(struct block_device *bdev)
59 + struct deventry *newdev, *cur;
63 + newdev = kmalloc(sizeof(struct deventry), GFP_KERNEL);
67 + spin_lock(&devlock);
68 + list_for_each_entry(cur, &devlist, dev_list) {
69 + if (bdev->bd_dev == cur->dev) {
70 + spin_unlock(&devlock);
75 + newdev->dev = bdev->bd_dev;
76 + list_add(&newdev->dev_list, &devlist);
77 + spin_unlock(&devlock);
78 + printk(KERN_WARNING "Turning device %s read-only\n",
79 + bdev->bd_disk ? bdev->bd_disk->disk_name : "?");
82 +void dev_clear_rdonly(struct block_device *bdev)
84 + struct deventry *cur, *tmp;
86 + spin_lock(&devlock);
87 + list_for_each_entry_safe(cur, tmp, &devlist, dev_list) {
88 + if (bdev->bd_dev == cur->dev) {
89 + list_del_init(&cur->dev_list);
91 + spin_unlock(&devlock);
92 + printk(KERN_WARNING "Removing read-only on %s\n",
93 + bdev->bd_disk ? bdev->bd_disk->disk_name : "?");
97 + spin_unlock(&devlock);
100 +EXPORT_SYMBOL(dev_set_rdonly);
101 +EXPORT_SYMBOL(dev_clear_rdonly);
102 +EXPORT_SYMBOL(dev_check_rdonly);
107 struct queue_sysfs_entry {