diff options
author | Liu Bo <liub.liubo@gmail.com> | 2012-09-07 22:01:28 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2012-10-01 15:19:18 -0400 |
commit | 69917e431210f8712fe050f47b7561e7dae89521 (patch) | |
tree | 52a81d3c70d3a768d2d7756984dd16898ce12e50 /fs/btrfs/backref.c | |
parent | dea7d76ecbfb53cda6aadd9bed33e87d255c5b02 (diff) |
Btrfs: fix a bug in parsing return value in logical resolve
In logical resolve, we parse extent_from_logical()'s 'ret' as a kind of flag.
It is possible to lose our errors because
(-EXXXX & BTRFS_EXTENT_FLAG_TREE_BLOCK) is true.
I'm not sure if it is on purpose, it just looks too hacky if it is.
I'd rather use a real flag and a 'ret' to catch errors.
Acked-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: Liu Bo <liub.liubo@gmail.com>
Diffstat (limited to 'fs/btrfs/backref.c')
-rw-r--r-- | fs/btrfs/backref.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index e600857d3ca4..ab286e5bfe33 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c | |||
@@ -1193,7 +1193,8 @@ char *btrfs_iref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path, | |||
1193 | * tree blocks and <0 on error. | 1193 | * tree blocks and <0 on error. |
1194 | */ | 1194 | */ |
1195 | int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical, | 1195 | int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical, |
1196 | struct btrfs_path *path, struct btrfs_key *found_key) | 1196 | struct btrfs_path *path, struct btrfs_key *found_key, |
1197 | u64 *flags_ret) | ||
1197 | { | 1198 | { |
1198 | int ret; | 1199 | int ret; |
1199 | u64 flags; | 1200 | u64 flags; |
@@ -1237,10 +1238,17 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical, | |||
1237 | (unsigned long long)found_key->objectid, | 1238 | (unsigned long long)found_key->objectid, |
1238 | (unsigned long long)found_key->offset, | 1239 | (unsigned long long)found_key->offset, |
1239 | (unsigned long long)flags, item_size); | 1240 | (unsigned long long)flags, item_size); |
1240 | if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) | 1241 | |
1241 | return BTRFS_EXTENT_FLAG_TREE_BLOCK; | 1242 | WARN_ON(!flags_ret); |
1242 | if (flags & BTRFS_EXTENT_FLAG_DATA) | 1243 | if (flags_ret) { |
1243 | return BTRFS_EXTENT_FLAG_DATA; | 1244 | if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) |
1245 | *flags_ret = BTRFS_EXTENT_FLAG_TREE_BLOCK; | ||
1246 | else if (flags & BTRFS_EXTENT_FLAG_DATA) | ||
1247 | *flags_ret = BTRFS_EXTENT_FLAG_DATA; | ||
1248 | else | ||
1249 | BUG_ON(1); | ||
1250 | return 0; | ||
1251 | } | ||
1244 | 1252 | ||
1245 | return -EIO; | 1253 | return -EIO; |
1246 | } | 1254 | } |
@@ -1433,15 +1441,15 @@ int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info, | |||
1433 | { | 1441 | { |
1434 | int ret; | 1442 | int ret; |
1435 | u64 extent_item_pos; | 1443 | u64 extent_item_pos; |
1444 | u64 flags = 0; | ||
1436 | struct btrfs_key found_key; | 1445 | struct btrfs_key found_key; |
1437 | int search_commit_root = path->search_commit_root; | 1446 | int search_commit_root = path->search_commit_root; |
1438 | 1447 | ||
1439 | ret = extent_from_logical(fs_info, logical, path, | 1448 | ret = extent_from_logical(fs_info, logical, path, &found_key, &flags); |
1440 | &found_key); | ||
1441 | btrfs_release_path(path); | 1449 | btrfs_release_path(path); |
1442 | if (ret < 0) | 1450 | if (ret < 0) |
1443 | return ret; | 1451 | return ret; |
1444 | if (ret & BTRFS_EXTENT_FLAG_TREE_BLOCK) | 1452 | if (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK) |
1445 | return -EINVAL; | 1453 | return -EINVAL; |
1446 | 1454 | ||
1447 | extent_item_pos = logical - found_key.objectid; | 1455 | extent_item_pos = logical - found_key.objectid; |