Whamcloud - gitweb
Branch: HEAD
[fs/lustre-release.git] / lustre / kernel_patches / patches / dev_read_only-2.6.10-fc3.patch
1  drivers/block/ll_rw_blk.c |   49 ++++++++++++++++++++++++++++++++++++++++++++++
2  include/linux/blkdev.h    |    1 
3  2 files changed, 50 insertions(+)
4
5 Index: linux-2.6.10/drivers/block/ll_rw_blk.c
6 ===================================================================
7 --- linux-2.6.10.orig/drivers/block/ll_rw_blk.c 2004-12-25 05:33:59.000000000 +0800
8 +++ linux-2.6.10/drivers/block/ll_rw_blk.c      2005-04-05 15:42:58.075467024 +0800
9 @@ -2679,6 +2679,13 @@
10                 if (test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))
11                         goto end_io;
12  
13 +                /* this is cfs's dev_rdonly check */
14 +                if (bio->bi_rw == WRITE &&
15 +                                dev_check_rdonly(bio->bi_bdev->bd_dev)) {
16 +                        bio_endio(bio, bio->bi_size, 0);
17 +                        break;
18 +                }
19 +
20                 block_wait_queue_running(q);
21  
22                 /*
23 @@ -3287,6 +3294,58 @@
24         return queue_var_show(max_hw_sectors_kb, (page));
25  }
26  
27 +#define MAX_RDONLY_DEVS                16
28 +
29 +static dev_t rdonly_devs[MAX_RDONLY_DEVS] = {0, };
30 +
31 +/*
32 + * Debug code for turning block devices "read-only" (will discard writes
33 + * silently).  This is for filesystem crash/recovery testing.
34 + */
35 +void dev_set_rdonly(struct block_device *bdev, int no_write)
36 +{
37 +       if (no_write >= MAX_RDONLY_DEVS) {
38 +               printk(KERN_ALERT "%s:%d illegal arg %d (max %d)\n",
39 +                               __FILE__, __LINE__, no_write, MAX_RDONLY_DEVS);
40 +               return;
41 +       }
42 +
43 +       if (bdev) {
44 +               printk(KERN_WARNING "Turning device %s read-only at %d\n",
45 +                               bdev->bd_disk ? bdev->bd_disk->disk_name : "?",
46 +                               no_write);
47 +               rdonly_devs[no_write] = bdev->bd_dev;
48 +       }
49 +}
50 +
51 +void dev_clear_rdonly(int no_write)
52 +{
53 +       if (no_write >= MAX_RDONLY_DEVS) {
54 +               printk(KERN_ALERT "%s:%d illegal arg %d (max %d)\n",
55 +                               __FILE__, __LINE__, no_write, MAX_RDONLY_DEVS);
56 +               return;
57 +       }
58 +
59 +       if (rdonly_devs[no_write] == 0)
60 +               return;
61 +       
62 +       printk(KERN_WARNING "Clearing read-only at %d\n", no_write);
63 +       rdonly_devs[no_write] = 0;
64 +}
65 +
66 +int dev_check_rdonly(dev_t dev)
67 +{
68 +       int i;
69 +
70 +       for (i = 0; i < MAX_RDONLY_DEVS; i++)
71 +               if (rdonly_devs[i] == dev)
72 +                       return 1;
73 +       return 0;
74 +}
75 +
76 +EXPORT_SYMBOL(dev_set_rdonly);
77 +EXPORT_SYMBOL(dev_clear_rdonly);
78 +EXPORT_SYMBOL(dev_check_rdonly);
79  
80  static struct queue_sysfs_entry queue_requests_entry = {
81         .attr = {.name = "nr_requests", .mode = S_IRUGO | S_IWUSR },