All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Subject: [PATCH v1.1 01/14] btrfs-progs: lowmem: fix false alert about the existence of gaps in the check_file_extent
Date: Wed, 27 Feb 2019 14:05:39 +0800	[thread overview]
Message-ID: <20190227060552.3841-2-wqu@suse.com> (raw)
In-Reply-To: <20190227060552.3841-1-wqu@suse.com>

From: Lu Fengqi <lufq.fnst@cn.fujitsu.com>

The 'end' parameter of check_file_extent tracks the ending offset of the
last checked extent. This is used to detect gaps between adjacent extents.

Currently such gaps are wrongly detected since for regular extents only
the size of the extent is added to the 'end' parameter. This results in
wrongly considering all extents of a file as having gaps between them
when only 2 of them really have a gap as seen in the example below.

Solution:
The extent_end variable should set to the sum of the offset and the
extent_num_bytes of the file extent.

Example:
Suppose that lowmem check the following file extent of inode 257.

        item 6 key (257 EXTENT_DATA 0) itemoff 15813 itemsize 53
                generation 6 type 1 (regular)
                extent data disk byte 13631488 nr 4096
                extent data offset 0 nr 4096 ram 4096
                extent compression 0 (none)
        item 7 key (257 EXTENT_DATA 8192) itemoff 15760 itemsize 53
                generation 6 type 1 (regular)
                extent data disk byte 13631488 nr 4096
                extent data offset 0 nr 4096 ram 4096
                extent compression 0 (none)
        item 8 key (257 EXTENT_DATA 12288) itemoff 15707 itemsize 53
                generation 6 type 1 (regular)
                extent data disk byte 13631488 nr 4096
                extent data offset 0 nr 4096 ram 4096
                extent compression 0 (none)

For inode 257, check_inode_item set extent_end to 0, then call
check_file_extent to check item {6,7,8}.
item 6)
	offset(0) == extent_end(0)
	extent_end = extent_end(0) + extent_num_bytes(4096)
item 7)
	offset(8192) != extent_end(4096)
	extent_end = extent_end(4096) + extent_num_bytes(4096)
			^^^
	The old extent_end should replace by offset(8192).
item 8)
	offset(12288) != extent_end(8192)
		^^^
	But there is no gap between item {7,8}.

Fixes: d88da10ddd42 ("btrfs-progs: check: introduce function to check file extent")
Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
[Move this patch as the 1st patch, since it's an independent fix]
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 check/mode-lowmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index fc6228a05a1b..bbda2bb23c65 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -2039,7 +2039,7 @@ static int check_file_extent(struct btrfs_root *root, struct btrfs_path *path,
 		}
 	}
 
-	*end += extent_num_bytes;
+	*end = fkey.offset + extent_num_bytes;
 	if (!is_hole)
 		*size += extent_num_bytes;
 
-- 
2.21.0


  reply	other threads:[~2019-02-27  6:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-27  6:05 [PATCH v1.1 00/14] btrfs-progs: check: Use fs/subvol trees to fix extent tree, not vice versa Qu Wenruo
2019-02-27  6:05 ` Qu Wenruo [this message]
2019-02-27  6:05 ` [PATCH v1.1 02/14] btrfs-progs: lowmem: add argument path to punch_extent_hole() Qu Wenruo
2019-02-27  6:05 ` [PATCH v1.1 03/14] btrfs-progs: lowmem: move nbytes check before isize check Qu Wenruo
2019-02-27  6:05 ` [PATCH v1.1 04/14] btrfs-progs: lowmem: fix false alert if extent item has been repaired Qu Wenruo
2019-02-27  6:05 ` [PATCH v1.1 05/14] btrfs-progs: lowmem: check unaligned disk_bytenr for extent_data Qu Wenruo
2019-02-27  6:05 ` [PATCH v1.1 06/14] btrfs-progs: lowmem: rename delete_extent_tree_item() to delete_item() Qu Wenruo
2019-02-27  6:05 ` [PATCH v1.1 07/14] btrfs-progs: lowmem: delete unaligned bytes extent data under repair Qu Wenruo
2019-02-27  6:05 ` [PATCH v1.1 08/14] btrfs-progs: Revert "btrfs-progs: Add repair and report function for orphan file extent." Qu Wenruo
2019-02-27  6:05 ` [PATCH v1.1 09/14] btrfs-progs: Revert "btrfs-progs: Record orphan data extent ref to corresponding root." Qu Wenruo
2019-02-27  6:05 ` [PATCH v1.1 10/14] btrfs-progs: check: fix wrong @offset used in find_possible_backrefs() Qu Wenruo
2019-02-27  6:05 ` [PATCH v1.1 11/14] btrfs-progs: check: Delete file extent item with unaligned disk bytenr Qu Wenruo
2019-02-27  6:05 ` [PATCH v1.1 12/14] btrfs-progs: tests: add case for inode lose one file extent Qu Wenruo
2019-02-27  6:05 ` [PATCH v1.1 13/14] btrfs-progs: fsck-test: enable lowmem repair for case 001 Qu Wenruo
2019-02-27  6:05 ` [PATCH v1.1 14/14] btrfs-progs: Update backup roots when writing super blocks Qu Wenruo
2019-03-28  5:51 ` [PATCH v1.1 00/14] btrfs-progs: check: Use fs/subvol trees to fix extent tree, not vice versa Qu Wenruo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190227060552.3841-2-wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=lufq.fnst@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.