From: Filipe Manana <fdman...@suse.com>

We log holes explicitly by using file extent items, however when replaying
a log tree, if a logged file extent item corresponds to a hole and the
NO_HOLES feature is enabled we do not need to copy the file extent item
into the fs/subvolume tree, as the absence of such file extent items is
the purpose of the NO_HOLES feature. So skip the copying of file extent
items representing holes when the NO_HOLES feature is enabled.

Signed-off-by: Filipe Manana <fdman...@suse.com>
---
 fs/btrfs/tree-log.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index eeffff8..44aca7f 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -667,6 +667,10 @@ static noinline int replay_one_extent(struct 
btrfs_trans_handle *trans,
        if (ret)
                goto out;
 
+       if (btrfs_file_extent_disk_bytenr(eb, item) == 0 &&
+           btrfs_fs_incompat(fs_info, NO_HOLES))
+               goto update_inode;
+
        if (found_type == BTRFS_FILE_EXTENT_REG ||
            found_type == BTRFS_FILE_EXTENT_PREALLOC) {
                u64 offset;
@@ -825,6 +829,7 @@ static noinline int replay_one_extent(struct 
btrfs_trans_handle *trans,
        }
 
        inode_add_bytes(inode, nbytes);
+update_inode:
        ret = btrfs_update_inode(trans, root, inode);
 out:
        if (inode)
-- 
2.7.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to