aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode-map.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/inode-map.c')
-rw-r--r--fs/btrfs/inode-map.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
index a0925eabdaa2..298346ae1481 100644
--- a/fs/btrfs/inode-map.c
+++ b/fs/btrfs/inode-map.c
@@ -69,6 +69,12 @@ int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
69 struct btrfs_key search_key; 69 struct btrfs_key search_key;
70 u64 search_start = dirid; 70 u64 search_start = dirid;
71 71
72 mutex_lock(&root->objectid_mutex);
73 if (root->last_inode_alloc) {
74 *objectid = ++root->last_inode_alloc;
75 mutex_unlock(&root->objectid_mutex);
76 return 0;
77 }
72 path = btrfs_alloc_path(); 78 path = btrfs_alloc_path();
73 BUG_ON(!path); 79 BUG_ON(!path);
74 search_start = root->last_inode_alloc; 80 search_start = root->last_inode_alloc;
@@ -124,9 +130,11 @@ found:
124 btrfs_release_path(root, path); 130 btrfs_release_path(root, path);
125 btrfs_free_path(path); 131 btrfs_free_path(path);
126 BUG_ON(*objectid < search_start); 132 BUG_ON(*objectid < search_start);
133 mutex_unlock(&root->objectid_mutex);
127 return 0; 134 return 0;
128error: 135error:
129 btrfs_release_path(root, path); 136 btrfs_release_path(root, path);
130 btrfs_free_path(path); 137 btrfs_free_path(path);
138 mutex_unlock(&root->objectid_mutex);
131 return ret; 139 return ret;
132} 140}