Btrfs: use the device_list_mutex during write_dev_supers
authorChris Mason <chris.mason@oracle.com>
Fri, 27 May 2011 14:03:58 +0000 (10:03 -0400)
committerChris Mason <chris.mason@oracle.com>
Fri, 27 May 2011 14:03:58 +0000 (10:03 -0400)
write_dev_supers was changed to use RCU to protect the list of
devices, but it was then sleeping while it actually wrote the supers.
This fixes it to just use the mutex, since we really don't any
concurrency in write_dev_supers anyway.

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

index b2588a552658d28118fd8d885d8595d1ec1f4303..98b6a71decba105616ef5727b07b18c6d79dd8e0 100644 (file)
@@ -2310,7 +2310,7 @@ int write_all_supers(struct btrfs_root *root, int max_mirrors)
        sb = &root->fs_info->super_for_commit;
        dev_item = &sb->dev_item;
 
-       rcu_read_lock();
+       mutex_lock(&root->fs_info->fs_devices->device_list_mutex);
        head = &root->fs_info->fs_devices->devices;
        list_for_each_entry_rcu(dev, head, dev_list) {
                if (!dev->bdev) {
@@ -2355,7 +2355,7 @@ int write_all_supers(struct btrfs_root *root, int max_mirrors)
                if (ret)
                        total_errors++;
        }
-       rcu_read_unlock();
+       mutex_unlock(&root->fs_info->fs_devices->device_list_mutex);
        if (total_errors > max_errors) {
                printk(KERN_ERR "btrfs: %d errors while writing supers\n",
                       total_errors);