diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-04-14 09:48:18 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:01 -0400 |
commit | b248a4152956cbae1b23f4c70ef5b51d6ea2ecfb (patch) | |
tree | d42f7c6520b825e09e0c802d01e66a78297f6eb0 /fs/btrfs | |
parent | 98d20f67cf99ccda638dbcdf7b3a9ee0a428d932 (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')
-rw-r--r-- | fs/btrfs/disk-io.c | 12 | ||||
-rw-r--r-- | fs/btrfs/file.c | 8 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 15 |
3 files changed, 24 insertions, 11 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index aebe8c21ec80..9c94dddde704 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -850,7 +850,9 @@ void btrfs_unplug_io_fn(struct backing_dev_info *bdi, struct page *page) | |||
850 | 850 | ||
851 | static int setup_bdi(struct btrfs_fs_info *info, struct backing_dev_info *bdi) | 851 | static int setup_bdi(struct btrfs_fs_info *info, struct backing_dev_info *bdi) |
852 | { | 852 | { |
853 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23) | ||
853 | bdi_init(bdi); | 854 | bdi_init(bdi); |
855 | #endif | ||
854 | bdi->ra_pages = default_backing_dev_info.ra_pages * 4; | 856 | bdi->ra_pages = default_backing_dev_info.ra_pages * 4; |
855 | bdi->state = 0; | 857 | bdi->state = 0; |
856 | bdi->capabilities = default_backing_dev_info.capabilities; | 858 | bdi->capabilities = default_backing_dev_info.capabilities; |
@@ -950,7 +952,7 @@ void btrfs_end_io_csum(struct work_struct *work) | |||
950 | bio->bi_end_io = end_io_wq->end_io; | 952 | bio->bi_end_io = end_io_wq->end_io; |
951 | kfree(end_io_wq); | 953 | kfree(end_io_wq); |
952 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23) | 954 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23) |
953 | bio_endio(bio, bio->bi_size, err); | 955 | bio_endio(bio, bio->bi_size, error); |
954 | #else | 956 | #else |
955 | bio_endio(bio, error); | 957 | bio_endio(bio, error); |
956 | #endif | 958 | #endif |
@@ -1037,10 +1039,11 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1037 | fs_info->btree_inode->i_mapping, GFP_NOFS); | 1039 | fs_info->btree_inode->i_mapping, GFP_NOFS); |
1038 | fs_info->do_barriers = 1; | 1040 | fs_info->do_barriers = 1; |
1039 | 1041 | ||
1040 | INIT_WORK(&fs_info->end_io_work, btrfs_end_io_csum); | ||
1041 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18) | 1042 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18) |
1043 | INIT_WORK(&fs_info->end_io_work, btrfs_end_io_csum, fs_info); | ||
1042 | INIT_WORK(&fs_info->trans_work, btrfs_transaction_cleaner, fs_info); | 1044 | INIT_WORK(&fs_info->trans_work, btrfs_transaction_cleaner, fs_info); |
1043 | #else | 1045 | #else |
1046 | INIT_WORK(&fs_info->end_io_work, btrfs_end_io_csum); | ||
1044 | INIT_DELAYED_WORK(&fs_info->trans_work, btrfs_transaction_cleaner); | 1047 | INIT_DELAYED_WORK(&fs_info->trans_work, btrfs_transaction_cleaner); |
1045 | #endif | 1048 | #endif |
1046 | BTRFS_I(fs_info->btree_inode)->root = tree_root; | 1049 | BTRFS_I(fs_info->btree_inode)->root = tree_root; |
@@ -1173,7 +1176,9 @@ fail: | |||
1173 | close_all_devices(fs_info); | 1176 | close_all_devices(fs_info); |
1174 | kfree(extent_root); | 1177 | kfree(extent_root); |
1175 | kfree(tree_root); | 1178 | kfree(tree_root); |
1179 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23) | ||
1176 | bdi_destroy(&fs_info->bdi); | 1180 | bdi_destroy(&fs_info->bdi); |
1181 | #endif | ||
1177 | kfree(fs_info); | 1182 | kfree(fs_info); |
1178 | return ERR_PTR(err); | 1183 | return ERR_PTR(err); |
1179 | } | 1184 | } |
@@ -1407,7 +1412,10 @@ int close_ctree(struct btrfs_root *root) | |||
1407 | #endif | 1412 | #endif |
1408 | close_all_devices(fs_info); | 1413 | close_all_devices(fs_info); |
1409 | btrfs_mapping_tree_free(&fs_info->mapping_tree); | 1414 | btrfs_mapping_tree_free(&fs_info->mapping_tree); |
1415 | |||
1416 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23) | ||
1410 | bdi_destroy(&fs_info->bdi); | 1417 | bdi_destroy(&fs_info->bdi); |
1418 | #endif | ||
1411 | 1419 | ||
1412 | kfree(fs_info->extent_root); | 1420 | kfree(fs_info->extent_root); |
1413 | kfree(fs_info->tree_root); | 1421 | kfree(fs_info->tree_root); |
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 5b9386452218..9fbda6552069 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -908,11 +908,17 @@ out_nolock: | |||
908 | if (err < 0) | 908 | if (err < 0) |
909 | num_written = err; | 909 | num_written = err; |
910 | } else if (num_written > 0 && (file->f_flags & O_DIRECT)) { | 910 | } else if (num_written > 0 && (file->f_flags & O_DIRECT)) { |
911 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23) | ||
912 | do_sync_file_range(file, start_pos, | ||
913 | start_pos + num_written - 1, | ||
914 | SYNC_FILE_RANGE_WRITE | | ||
915 | SYNC_FILE_RANGE_WAIT_AFTER); | ||
916 | #else | ||
911 | do_sync_mapping_range(inode->i_mapping, start_pos, | 917 | do_sync_mapping_range(inode->i_mapping, start_pos, |
912 | start_pos + num_written - 1, | 918 | start_pos + num_written - 1, |
913 | SYNC_FILE_RANGE_WRITE | | 919 | SYNC_FILE_RANGE_WRITE | |
914 | SYNC_FILE_RANGE_WAIT_AFTER); | 920 | SYNC_FILE_RANGE_WAIT_AFTER); |
915 | 921 | #endif | |
916 | invalidate_mapping_pages(inode->i_mapping, | 922 | invalidate_mapping_pages(inode->i_mapping, |
917 | start_pos >> PAGE_CACHE_SHIFT, | 923 | start_pos >> PAGE_CACHE_SHIFT, |
918 | (start_pos + num_written - 1) >> PAGE_CACHE_SHIFT); | 924 | (start_pos + num_written - 1) >> PAGE_CACHE_SHIFT); |
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; |
933 | out: | 934 | out: |
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 | ||