diff options
-rw-r--r-- | fs/btrfs/tree-log.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 60e1d0083faa..533cdb02978a 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
@@ -1288,6 +1288,7 @@ static int count_inode_extrefs(struct btrfs_root *root, | |||
1288 | leaf = path->nodes[0]; | 1288 | leaf = path->nodes[0]; |
1289 | item_size = btrfs_item_size_nr(leaf, path->slots[0]); | 1289 | item_size = btrfs_item_size_nr(leaf, path->slots[0]); |
1290 | ptr = btrfs_item_ptr_offset(leaf, path->slots[0]); | 1290 | ptr = btrfs_item_ptr_offset(leaf, path->slots[0]); |
1291 | cur_offset = 0; | ||
1291 | 1292 | ||
1292 | while (cur_offset < item_size) { | 1293 | while (cur_offset < item_size) { |
1293 | extref = (struct btrfs_inode_extref *) (ptr + cur_offset); | 1294 | extref = (struct btrfs_inode_extref *) (ptr + cur_offset); |
@@ -1303,7 +1304,7 @@ static int count_inode_extrefs(struct btrfs_root *root, | |||
1303 | } | 1304 | } |
1304 | btrfs_release_path(path); | 1305 | btrfs_release_path(path); |
1305 | 1306 | ||
1306 | if (ret < 0) | 1307 | if (ret < 0 && ret != -ENOENT) |
1307 | return ret; | 1308 | return ret; |
1308 | return nlink; | 1309 | return nlink; |
1309 | } | 1310 | } |
@@ -1395,9 +1396,6 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans, | |||
1395 | nlink = ret; | 1396 | nlink = ret; |
1396 | 1397 | ||
1397 | ret = count_inode_extrefs(root, inode, path); | 1398 | ret = count_inode_extrefs(root, inode, path); |
1398 | if (ret == -ENOENT) | ||
1399 | ret = 0; | ||
1400 | |||
1401 | if (ret < 0) | 1399 | if (ret < 0) |
1402 | goto out; | 1400 | goto out; |
1403 | 1401 | ||
@@ -3966,15 +3964,22 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, | |||
3966 | max_key.type = (u8)-1; | 3964 | max_key.type = (u8)-1; |
3967 | max_key.offset = (u64)-1; | 3965 | max_key.offset = (u64)-1; |
3968 | 3966 | ||
3969 | /* Only run delayed items if we are a dir or a new file */ | 3967 | /* |
3968 | * Only run delayed items if we are a dir or a new file. | ||
3969 | * Otherwise commit the delayed inode only, which is needed in | ||
3970 | * order for the log replay code to mark inodes for link count | ||
3971 | * fixup (create temporary BTRFS_TREE_LOG_FIXUP_OBJECTID items). | ||
3972 | */ | ||
3970 | if (S_ISDIR(inode->i_mode) || | 3973 | if (S_ISDIR(inode->i_mode) || |
3971 | BTRFS_I(inode)->generation > root->fs_info->last_trans_committed) { | 3974 | BTRFS_I(inode)->generation > root->fs_info->last_trans_committed) |
3972 | ret = btrfs_commit_inode_delayed_items(trans, inode); | 3975 | ret = btrfs_commit_inode_delayed_items(trans, inode); |
3973 | if (ret) { | 3976 | else |
3974 | btrfs_free_path(path); | 3977 | ret = btrfs_commit_inode_delayed_inode(inode); |
3975 | btrfs_free_path(dst_path); | 3978 | |
3976 | return ret; | 3979 | if (ret) { |
3977 | } | 3980 | btrfs_free_path(path); |
3981 | btrfs_free_path(dst_path); | ||
3982 | return ret; | ||
3978 | } | 3983 | } |
3979 | 3984 | ||
3980 | mutex_lock(&BTRFS_I(inode)->log_mutex); | 3985 | mutex_lock(&BTRFS_I(inode)->log_mutex); |