]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
Btrfs: fix raid code for removing missing drives
authorChris Mason <chris.mason@oracle.com>
Thu, 28 Oct 2010 19:30:42 +0000 (15:30 -0400)
committerChris Mason <chris.mason@oracle.com>
Fri, 29 Oct 2010 15:25:46 +0000 (11:25 -0400)
When btrfs is mounted in degraded mode, it has some internal structures
to track the missing devices.  This missing device is setup as readonly,
but the mapping code can get upset when we try to write to it.

This changes the mapping code to return -EIO instead of oops when we try
to write to the readonly device.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/volumes.c

index dd318ff280b22a18167f65e538d5215b4b03e3c5..28681e729b1dda9f2fe4916473c0108290077844 100644 (file)
@@ -3034,8 +3034,7 @@ int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio,
                }
                bio->bi_sector = multi->stripes[dev_nr].physical >> 9;
                dev = multi->stripes[dev_nr].dev;
-               BUG_ON(rw == WRITE && !dev->writeable);
-               if (dev && dev->bdev) {
+               if (dev && dev->bdev && (rw != WRITE || dev->writeable)) {
                        bio->bi_bdev = dev->bdev;
                        if (async_submit)
                                schedule_bio(root, dev, rw, bio);