1 --- linux-2.6.5.orig/drivers/block/ll_rw_blk.c 2005-03-16 11:08:47.404935605 -0800
2 +++ linux-2.6.5/drivers/block/ll_rw_blk.c 2005-03-16 10:57:38.197357003 -0800
3 @@ -2458,6 +2458,8 @@ static inline void blk_partition_remap(s
7 +int dev_check_rdonly(struct block_device *bdev);
10 * generic_make_request: hand a buffer to its device driver for I/O
11 * @bio: The bio describing the location in memory and on the device.
12 @@ -2546,6 +2548,13 @@ end_io:
13 if (test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))
16 + /* this is cfs's dev_rdonly check */
17 + if (bio->bi_rw == WRITE &&
18 + dev_check_rdonly(bio->bi_bdev)) {
19 + bio_endio(bio, bio->bi_size, 0);
24 * If this device has partitions, remap block n
25 * of partition p to block n+start(p) of the disk.
26 @@ -3078,6 +3087,91 @@ void swap_io_context(struct io_context *
30 + * Debug code for turning block devices "read-only" (will discard writes
31 + * silently). This is for filesystem crash/recovery testing.
35 + struct deventry *next;
38 +static struct deventry *devlist = NULL;
39 +static spinlock_t devlock = SPIN_LOCK_UNLOCKED;
41 +int dev_check_rdonly(struct block_device *bdev)
43 + struct deventry *cur;
44 + if (!bdev) return 0;
45 + spin_lock(&devlock);
48 + if (bdev->bd_dev == cur->dev) {
49 + spin_unlock(&devlock);
54 + spin_unlock(&devlock);
58 +void dev_set_rdonly(struct block_device *bdev)
60 + struct deventry *newdev, *cur;
64 + newdev = kmalloc(sizeof(struct deventry), GFP_KERNEL);
68 + spin_lock(&devlock);
71 + if (bdev->bd_dev == cur->dev) {
72 + spin_unlock(&devlock);
78 + newdev->dev = bdev->bd_dev;
79 + newdev->next = devlist;
81 + spin_unlock(&devlock);
82 + printk(KERN_WARNING "Turning device %s read-only\n",
83 + bdev->bd_disk ? bdev->bd_disk->disk_name : "?");
86 +void dev_clear_rdonly(struct block_device *bdev)
88 + struct deventry *cur, *last = NULL;
90 + spin_lock(&devlock);
93 + if (bdev->bd_dev == cur->dev) {
95 + last->next = cur->next;
97 + devlist = cur->next;
98 + spin_unlock(&devlock);
100 + printk(KERN_WARNING "Removing read-only on %s\n",
101 + bdev->bd_disk ? bdev->bd_disk->disk_name : "?");
107 + spin_unlock(&devlock);
110 +EXPORT_SYMBOL(dev_set_rdonly);
111 +EXPORT_SYMBOL(dev_clear_rdonly);
112 +EXPORT_SYMBOL(dev_check_rdonly);
117 struct queue_sysfs_entry {