Skip to contentSkip to conversation

Btrfs: do not create explicit holes when replaying log tree if NO_HOLES enabled

PATCH Superseded [email protected] 1 participant 2 messages Feb 1, 2017 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs: do not create explicit holes when replaying log tree if NO_HOLES enabled

From: Filipe Manana <[email protected]>

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.

---
 fs/btrfs/tree-log.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/btrfs/tree-log.c +5 -0
index eeffff8..44aca7f 100644
@@ -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)
Signature · 1 line
2.7.0.rc3
#1 lore raw

PATCH v2 1/1 Btrfs: do not create explicit holes when replaying log tree if NO_HOLES enabled

From: Filipe Manana <[email protected]>

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.

---

v2: Make the check only if the extent type is regular or prealloc,
since for inline extents disk_bytenr has no meaning.

 fs/btrfs/tree-log.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/btrfs/tree-log.c +5 -0
index eeffff8..30423ce 100644
@@ -673,6 +673,10 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
 		unsigned long dest_offset;
 		struct btrfs_key ins;
 
+		if (btrfs_file_extent_disk_bytenr(eb, item) == 0 &&
+		    btrfs_fs_incompat(fs_info, NO_HOLES))
+			goto update_inode;
+
 		ret = btrfs_insert_empty_item(trans, root, path, key,
 					      sizeof(*item));
 		if (ret)
@@ -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)
Signature · 1 line
2.7.0.rc3