summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYan <yanzheng@21cn.com>2008-01-22 11:32:05 -0500
committerDavid Woodhouse <dwmw2@hera.kernel.org>2008-01-22 11:32:05 -0500
commit7c2844538143aebb26f0436c2760172017901536 (patch)
tree84e64fedf666a1517b518b96acdfaf45c77f5bb1
parent033cd664516345101a012141f74c141b571e7899 (diff)
Fix for btrfs_find_free_objectid
btrfs_find_free_objectid may return a used objectid due to arithmetic underflow. This bug may happen when parameter 'root' is tree root, so it may cause serious problems when creating snapshot or sub-volume.
-rw-r--r--inode-map.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/inode-map.c b/inode-map.c
index ab74977a..a0925eab 100644
--- a/inode-map.c
+++ b/inode-map.c
@@ -62,7 +62,6 @@ int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
struct btrfs_path *path;
struct btrfs_key key;
int ret;
- u64 hole_size = 0;
int slot = 0;
u64 last_ino = 0;
int start_found;
@@ -109,8 +108,7 @@ int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
if (start_found) {
if (last_ino < search_start)
last_ino = search_start;
- hole_size = key.objectid - last_ino;
- if (hole_size > 0) {
+ if (key.objectid > last_ino) {
*objectid = last_ino;
goto found;
}