diff options
author | David Sterba <dsterba@suse.cz> | 2015-01-02 13:12:57 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2015-01-14 13:23:48 -0500 |
commit | 9c4f61f01d269815bb7c37be3ede59c5587747c6 (patch) | |
tree | e0e02273a94ae41c71f58a4262ffd853780bc0a9 /fs/btrfs/tree-log.c | |
parent | c234a24de91837db6f00aeebe28e3daddc53c1b7 (diff) |
btrfs: simplify insert_orphan_item
We can search and add the orphan item in one go,
btrfs_insert_orphan_item will find out if the item already exists.
Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r-- | fs/btrfs/tree-log.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 5be45c12dd71..25a1c363a5f4 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
@@ -1254,21 +1254,13 @@ out: | |||
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | static int insert_orphan_item(struct btrfs_trans_handle *trans, | 1256 | static int insert_orphan_item(struct btrfs_trans_handle *trans, |
1257 | struct btrfs_root *root, u64 offset) | 1257 | struct btrfs_root *root, u64 ino) |
1258 | { | 1258 | { |
1259 | int ret; | 1259 | int ret; |
1260 | struct btrfs_path *path; | ||
1261 | |||
1262 | path = btrfs_alloc_path(); | ||
1263 | if (!path) | ||
1264 | return -ENOMEM; | ||
1265 | 1260 | ||
1266 | ret = btrfs_find_item(root, path, BTRFS_ORPHAN_OBJECTID, | 1261 | ret = btrfs_insert_orphan_item(trans, root, ino); |
1267 | offset, BTRFS_ORPHAN_ITEM_KEY, NULL); | 1262 | if (ret == -EEXIST) |
1268 | if (ret > 0) | 1263 | ret = 0; |
1269 | ret = btrfs_insert_orphan_item(trans, root, offset); | ||
1270 | |||
1271 | btrfs_free_path(path); | ||
1272 | 1264 | ||
1273 | return ret; | 1265 | return ret; |
1274 | } | 1266 | } |