aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-04-14 09:48:18 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:01 -0400
commitb248a4152956cbae1b23f4c70ef5b51d6ea2ecfb (patch)
treed42f7c6520b825e09e0c802d01e66a78297f6eb0 /fs/btrfs/volumes.c
parent98d20f67cf99ccda638dbcdf7b3a9ee0a428d932 (diff)
Btrfs: A few updates for 2.6.18 and versions older than 2.6.25
This includes fixing a missing spinlock init call that caused oops on mount for most kernels other than 2.6.25. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 82bc6cfc110f..f81519f0e4a7 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -126,6 +126,7 @@ static int device_list_add(const char *path,
126 } 126 }
127 device->devid = devid; 127 device->devid = devid;
128 device->barriers = 1; 128 device->barriers = 1;
129 spin_lock_init(&device->io_lock);
129 device->name = kstrdup(path, GFP_NOFS); 130 device->name = kstrdup(path, GFP_NOFS);
130 if (!device->name) { 131 if (!device->name) {
131 kfree(device); 132 kfree(device);
@@ -759,8 +760,8 @@ printk("alloc chunk start %Lu size %Lu from dev %Lu type %Lu\n", key.objectid, c
759 em_tree = &extent_root->fs_info->mapping_tree.map_tree; 760 em_tree = &extent_root->fs_info->mapping_tree.map_tree;
760 spin_lock(&em_tree->lock); 761 spin_lock(&em_tree->lock);
761 ret = add_extent_mapping(em_tree, em); 762 ret = add_extent_mapping(em_tree, em);
762 BUG_ON(ret);
763 spin_unlock(&em_tree->lock); 763 spin_unlock(&em_tree->lock);
764 BUG_ON(ret);
764 free_extent_map(em); 765 free_extent_map(em);
765 return ret; 766 return ret;
766} 767}
@@ -799,6 +800,7 @@ int btrfs_num_copies(struct btrfs_mapping_tree *map_tree, u64 logical, u64 len)
799 800
800 spin_lock(&em_tree->lock); 801 spin_lock(&em_tree->lock);
801 em = lookup_extent_mapping(em_tree, logical, len); 802 em = lookup_extent_mapping(em_tree, logical, len);
803 spin_unlock(&em_tree->lock);
802 BUG_ON(!em); 804 BUG_ON(!em);
803 805
804 BUG_ON(em->start > logical || em->start + em->len < logical); 806 BUG_ON(em->start > logical || em->start + em->len < logical);
@@ -808,7 +810,6 @@ int btrfs_num_copies(struct btrfs_mapping_tree *map_tree, u64 logical, u64 len)
808 else 810 else
809 ret = 1; 811 ret = 1;
810 free_extent_map(em); 812 free_extent_map(em);
811 spin_unlock(&em_tree->lock);
812 return ret; 813 return ret;
813} 814}
814 815
@@ -840,6 +841,7 @@ again:
840 841
841 spin_lock(&em_tree->lock); 842 spin_lock(&em_tree->lock);
842 em = lookup_extent_mapping(em_tree, logical, *length); 843 em = lookup_extent_mapping(em_tree, logical, *length);
844 spin_unlock(&em_tree->lock);
843 BUG_ON(!em); 845 BUG_ON(!em);
844 846
845 BUG_ON(em->start > logical || em->start + em->len < logical); 847 BUG_ON(em->start > logical || em->start + em->len < logical);
@@ -855,7 +857,6 @@ again:
855 ((map->type & BTRFS_BLOCK_GROUP_RAID1) || 857 ((map->type & BTRFS_BLOCK_GROUP_RAID1) ||
856 (map->type & BTRFS_BLOCK_GROUP_DUP))) { 858 (map->type & BTRFS_BLOCK_GROUP_DUP))) {
857 stripes_allocated = map->num_stripes; 859 stripes_allocated = map->num_stripes;
858 spin_unlock(&em_tree->lock);
859 free_extent_map(em); 860 free_extent_map(em);
860 kfree(multi); 861 kfree(multi);
861 goto again; 862 goto again;
@@ -932,7 +933,6 @@ again:
932 *multi_ret = multi; 933 *multi_ret = multi;
933out: 934out:
934 free_extent_map(em); 935 free_extent_map(em);
935 spin_unlock(&em_tree->lock);
936 return 0; 936 return 0;
937} 937}
938 938
@@ -1060,16 +1060,15 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
1060 length = key->offset; 1060 length = key->offset;
1061 spin_lock(&map_tree->map_tree.lock); 1061 spin_lock(&map_tree->map_tree.lock);
1062 em = lookup_extent_mapping(&map_tree->map_tree, logical, 1); 1062 em = lookup_extent_mapping(&map_tree->map_tree, logical, 1);
1063 spin_unlock(&map_tree->map_tree.lock);
1063 1064
1064 /* already mapped? */ 1065 /* already mapped? */
1065 if (em && em->start <= logical && em->start + em->len > logical) { 1066 if (em && em->start <= logical && em->start + em->len > logical) {
1066 free_extent_map(em); 1067 free_extent_map(em);
1067 spin_unlock(&map_tree->map_tree.lock);
1068 return 0; 1068 return 0;
1069 } else if (em) { 1069 } else if (em) {
1070 free_extent_map(em); 1070 free_extent_map(em);
1071 } 1071 }
1072 spin_unlock(&map_tree->map_tree.lock);
1073 1072
1074 map = kzalloc(sizeof(*map), GFP_NOFS); 1073 map = kzalloc(sizeof(*map), GFP_NOFS);
1075 if (!map) 1074 if (!map)
@@ -1110,8 +1109,8 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
1110 1109
1111 spin_lock(&map_tree->map_tree.lock); 1110 spin_lock(&map_tree->map_tree.lock);
1112 ret = add_extent_mapping(&map_tree->map_tree, em); 1111 ret = add_extent_mapping(&map_tree->map_tree, em);
1113 BUG_ON(ret);
1114 spin_unlock(&map_tree->map_tree.lock); 1112 spin_unlock(&map_tree->map_tree.lock);
1113 BUG_ON(ret);
1115 free_extent_map(em); 1114 free_extent_map(em);
1116 1115
1117 return 0; 1116 return 0;
@@ -1154,7 +1153,7 @@ static int read_one_dev(struct btrfs_root *root,
1154 return -ENOMEM; 1153 return -ENOMEM;
1155 list_add(&device->dev_list, 1154 list_add(&device->dev_list,
1156 &root->fs_info->fs_devices->devices); 1155 &root->fs_info->fs_devices->devices);
1157 device->total_ios = 0; 1156 device->barriers = 1;
1158 spin_lock_init(&device->io_lock); 1157 spin_lock_init(&device->io_lock);
1159 } 1158 }
1160 1159