diff options
author | Jeff Mahoney <jeffm@suse.com> | 2012-03-01 08:57:19 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2012-03-21 20:45:35 -0400 |
commit | 3fbe5c02ae5a59053d779392b9a12aa8f6d6198e (patch) | |
tree | 39b3383401c031d61b6d4cf625730511a5fe7dae /fs/btrfs | |
parent | d0082371cf086e0ba2bbd0367b2c9920532df24f (diff) |
btrfs: split extent_state ops
set_extent_bit can do exclusive locking but only when called by lock_extent*,
Drop the exclusive bits argument except when called by lock_extent.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/extent_io.c | 36 | ||||
-rw-r--r-- | fs/btrfs/extent_io.h | 2 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 2 |
3 files changed, 25 insertions, 15 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 0112c02742f4..ffa7cc3370c7 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -721,9 +721,10 @@ static void uncache_state(struct extent_state **cached_ptr) | |||
721 | * [start, end] is inclusive This takes the tree lock. | 721 | * [start, end] is inclusive This takes the tree lock. |
722 | */ | 722 | */ |
723 | 723 | ||
724 | int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, | 724 | static int __must_check |
725 | int bits, int exclusive_bits, u64 *failed_start, | 725 | __set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, |
726 | struct extent_state **cached_state, gfp_t mask) | 726 | int bits, int exclusive_bits, u64 *failed_start, |
727 | struct extent_state **cached_state, gfp_t mask) | ||
727 | { | 728 | { |
728 | struct extent_state *state; | 729 | struct extent_state *state; |
729 | struct extent_state *prealloc = NULL; | 730 | struct extent_state *prealloc = NULL; |
@@ -917,6 +918,15 @@ search_again: | |||
917 | goto again; | 918 | goto again; |
918 | } | 919 | } |
919 | 920 | ||
921 | int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits, | ||
922 | u64 *failed_start, struct extent_state **cached_state, | ||
923 | gfp_t mask) | ||
924 | { | ||
925 | return __set_extent_bit(tree, start, end, bits, 0, failed_start, | ||
926 | cached_state, mask); | ||
927 | } | ||
928 | |||
929 | |||
920 | /** | 930 | /** |
921 | * convert_extent - convert all bits in a given range from one bit to another | 931 | * convert_extent - convert all bits in a given range from one bit to another |
922 | * @tree: the io tree to search | 932 | * @tree: the io tree to search |
@@ -1111,14 +1121,14 @@ search_again: | |||
1111 | int set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, | 1121 | int set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, |
1112 | gfp_t mask) | 1122 | gfp_t mask) |
1113 | { | 1123 | { |
1114 | return set_extent_bit(tree, start, end, EXTENT_DIRTY, 0, NULL, | 1124 | return set_extent_bit(tree, start, end, EXTENT_DIRTY, NULL, |
1115 | NULL, mask); | 1125 | NULL, mask); |
1116 | } | 1126 | } |
1117 | 1127 | ||
1118 | int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, | 1128 | int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, |
1119 | int bits, gfp_t mask) | 1129 | int bits, gfp_t mask) |
1120 | { | 1130 | { |
1121 | return set_extent_bit(tree, start, end, bits, 0, NULL, | 1131 | return set_extent_bit(tree, start, end, bits, NULL, |
1122 | NULL, mask); | 1132 | NULL, mask); |
1123 | } | 1133 | } |
1124 | 1134 | ||
@@ -1133,7 +1143,7 @@ int set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end, | |||
1133 | { | 1143 | { |
1134 | return set_extent_bit(tree, start, end, | 1144 | return set_extent_bit(tree, start, end, |
1135 | EXTENT_DELALLOC | EXTENT_UPTODATE, | 1145 | EXTENT_DELALLOC | EXTENT_UPTODATE, |
1136 | 0, NULL, cached_state, mask); | 1146 | NULL, cached_state, mask); |
1137 | } | 1147 | } |
1138 | 1148 | ||
1139 | int clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, | 1149 | int clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, |
@@ -1147,7 +1157,7 @@ int clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, | |||
1147 | int set_extent_new(struct extent_io_tree *tree, u64 start, u64 end, | 1157 | int set_extent_new(struct extent_io_tree *tree, u64 start, u64 end, |
1148 | gfp_t mask) | 1158 | gfp_t mask) |
1149 | { | 1159 | { |
1150 | return set_extent_bit(tree, start, end, EXTENT_NEW, 0, NULL, | 1160 | return set_extent_bit(tree, start, end, EXTENT_NEW, NULL, |
1151 | NULL, mask); | 1161 | NULL, mask); |
1152 | } | 1162 | } |
1153 | 1163 | ||
@@ -1155,7 +1165,7 @@ int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, | |||
1155 | struct extent_state **cached_state, gfp_t mask) | 1165 | struct extent_state **cached_state, gfp_t mask) |
1156 | { | 1166 | { |
1157 | return set_extent_bit(tree, start, end, EXTENT_UPTODATE, 0, | 1167 | return set_extent_bit(tree, start, end, EXTENT_UPTODATE, 0, |
1158 | NULL, cached_state, mask); | 1168 | cached_state, mask); |
1159 | } | 1169 | } |
1160 | 1170 | ||
1161 | static int clear_extent_uptodate(struct extent_io_tree *tree, u64 start, | 1171 | static int clear_extent_uptodate(struct extent_io_tree *tree, u64 start, |
@@ -1176,9 +1186,9 @@ int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, | |||
1176 | int err; | 1186 | int err; |
1177 | u64 failed_start; | 1187 | u64 failed_start; |
1178 | while (1) { | 1188 | while (1) { |
1179 | err = set_extent_bit(tree, start, end, EXTENT_LOCKED | bits, | 1189 | err = __set_extent_bit(tree, start, end, EXTENT_LOCKED | bits, |
1180 | EXTENT_LOCKED, &failed_start, | 1190 | EXTENT_LOCKED, &failed_start, |
1181 | cached_state, GFP_NOFS); | 1191 | cached_state, GFP_NOFS); |
1182 | if (err == -EEXIST) { | 1192 | if (err == -EEXIST) { |
1183 | wait_extent_bit(tree, failed_start, end, EXTENT_LOCKED); | 1193 | wait_extent_bit(tree, failed_start, end, EXTENT_LOCKED); |
1184 | start = failed_start; | 1194 | start = failed_start; |
@@ -1199,8 +1209,8 @@ int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end) | |||
1199 | int err; | 1209 | int err; |
1200 | u64 failed_start; | 1210 | u64 failed_start; |
1201 | 1211 | ||
1202 | err = set_extent_bit(tree, start, end, EXTENT_LOCKED, EXTENT_LOCKED, | 1212 | err = __set_extent_bit(tree, start, end, EXTENT_LOCKED, EXTENT_LOCKED, |
1203 | &failed_start, NULL, GFP_NOFS); | 1213 | &failed_start, NULL, GFP_NOFS); |
1204 | if (err == -EEXIST) { | 1214 | if (err == -EEXIST) { |
1205 | if (failed_start > start) | 1215 | if (failed_start > start) |
1206 | clear_extent_bit(tree, start, failed_start - 1, | 1216 | clear_extent_bit(tree, start, failed_start - 1, |
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index 439e183d45bb..3a171c259276 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h | |||
@@ -209,7 +209,7 @@ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, | |||
209 | int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, | 209 | int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, |
210 | int bits, gfp_t mask); | 210 | int bits, gfp_t mask); |
211 | int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, | 211 | int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, |
212 | int bits, int exclusive_bits, u64 *failed_start, | 212 | int bits, u64 *failed_start, |
213 | struct extent_state **cached_state, gfp_t mask); | 213 | struct extent_state **cached_state, gfp_t mask); |
214 | int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, | 214 | int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, |
215 | struct extent_state **cached_state, gfp_t mask); | 215 | struct extent_state **cached_state, gfp_t mask); |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index d16bf3f5da0e..593a2c3a27ab 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -6233,7 +6233,7 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb, | |||
6233 | if (writing) { | 6233 | if (writing) { |
6234 | write_bits = EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING; | 6234 | write_bits = EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING; |
6235 | ret = set_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, lockend, | 6235 | ret = set_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, lockend, |
6236 | EXTENT_DELALLOC, 0, NULL, &cached_state, | 6236 | EXTENT_DELALLOC, NULL, &cached_state, |
6237 | GFP_NOFS); | 6237 | GFP_NOFS); |
6238 | if (ret) { | 6238 | if (ret) { |
6239 | clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, | 6239 | clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, |