Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP4:GA
btrfsprogs
btrfs-progs-file-item-fix-wrong-file-extents-in...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File btrfs-progs-file-item-fix-wrong-file-extents-inserted.patch of Package btrfsprogs
From: Qu Wenruo <quwenruo@cn.fujitsu.com> Subject: btrfs-progs: file-item: Fix wrong file extents inserted Git-commit: 95ecaf0d61ae0bd5f70d6ddf79de3a36a24f816d Patch-mainline: v4.9-rc2 References: bsc#1042369 If we specify NO_HOLES incompat feature when converting, the result image still uses hole file extents. And further more, the hole is incorrect as its disk_num_bytes is not zero. The problem is at btrfs_insert_file_extent() which doesn't check if we are going to insert hole file extent. Modify it to skip hole file extents to allow it follow restrict NO_HOLES flag. And since no_holes flag can be triggered on half-way, so current fsck won't report such error, as it consider it as old file holes. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com> Acked-by: Jeff Mahoney <jeffm@suse.com> --- btrfs-convert.c | 2 +- file-item.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/btrfs-convert.c b/convert/main.c index fd6f77b2..15f14af2 100644 --- a/btrfs-convert.c +++ b/btrfs-convert.c @@ -336,7 +336,7 @@ static int record_file_blocks(struct blk_iterate_data *data, key.offset > cur_off); fi = btrfs_item_ptr(node, slot, struct btrfs_file_extent_item); extent_disk_bytenr = btrfs_file_extent_disk_bytenr(node, fi); - extent_num_bytes = btrfs_file_extent_disk_num_bytes(node, fi); + extent_num_bytes = btrfs_file_extent_num_bytes(node, fi); BUG_ON(cur_off - key.offset >= extent_num_bytes); btrfs_release_path(path); diff --git a/file-item.c b/file-item.c index 67c0b4f2..e462b4bb 100644 --- a/file-item.c +++ b/file-item.c @@ -36,11 +36,23 @@ int btrfs_insert_file_extent(struct btrfs_trans_handle *trans, u64 disk_num_bytes, u64 num_bytes) { int ret = 0; + int is_hole = 0; struct btrfs_file_extent_item *item; struct btrfs_key file_key; struct btrfs_path *path; struct extent_buffer *leaf; + if (offset == 0) + is_hole = 1; + /* For NO_HOLES, we don't insert hole file extent */ + if (btrfs_fs_incompat(root->fs_info, BTRFS_FEATURE_INCOMPAT_NO_HOLES) && + is_hole) + return 0; + + /* For hole, its disk_bytenr and disk_num_bytes must be 0 */ + if (is_hole) + disk_num_bytes = 0; + path = btrfs_alloc_path(); BUG_ON(!path); file_key.objectid = objectid;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor