All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhang Yi <yi.zhang@huawei.com>
To: Theodore Ts'o <tytso@mit.edu>
Cc: <linux-ext4@vger.kernel.org>, <adilger.kernel@dilger.ca>,
	<jack@suse.cz>, <yukuai3@huawei.com>
Subject: Re: [RFC PATCH 2/3] ext4: check for inconsistent extents between index and leaf block
Date: Fri, 8 Oct 2021 17:02:36 +0800	[thread overview]
Message-ID: <e3250b22-afda-04b9-76b3-ed50f2d52f1f@huawei.com> (raw)
In-Reply-To: <YV8iTPcMBUQN80Ob@mit.edu>

On 2021/10/8 0:37, Theodore Ts'o wrote:
> On Wed, Sep 08, 2021 at 08:08:49PM +0800, Zhang Yi wrote:
>> Now that we can check out overlapping extents in leaf block and
>> out-of-order index extents in index block. But the .ee_block in the
>> first extent of one leaf block should equal to the .ei_block in it's
>> parent index extent entry.
> 
> I don't believe this is always guaranteed.
> 
> The punch hole operation can remove some or part of the first entry in
> the leaf block, and it won't update the parent index.  So it's OK for
> the first entry of the leaf block to be greater than entry in the
> parent block.  However, if the first entry of the leaf block is less
> than the entry in the parent block, that's definitely going to be a
> problem.
> 

Hi, Ted.

ext4_punch_hole()->ext4_ext_remove_space()->ext4_ext_rm_leaf() call
ext4_ext_correct_indexes() or ext4_ext_rm_idx() to update the parent index
if the removing extent entry is the first entry of the leaf block.

static int
ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
                 struct ext4_ext_path *path,
                 struct partial_cluster *partial,
                 ext4_lblk_t start, ext4_lblk_t end)
{
...
                if (ex == EXT_FIRST_EXTENT(eh)) {
                        correct_index = 1;
...
        if (correct_index && eh->eh_entries)
                err = ext4_ext_correct_indexes(handle, inode, path);
...
}

static int ext4_ext_rm_idx(handle_t *handle, struct inode *inode,
                        struct ext4_ext_path *path, int depth)
{
...
        while (--depth >= 0) {
...
                path->p_idx->ei_block = (path+1)->p_idx->ei_block;
...
        }
...
}

And the fsck does also check the mismatch case in scan_extent_node(), am I
missing something?

Thanks,
Yi.

  reply	other threads:[~2021-10-08  9:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08 12:08 [RFC PATCH 0/3] ext4: enhance extent consistency check Zhang Yi
2021-09-08 12:08 ` [RFC PATCH 1/3] ext4: check for out-of-order index extents in ext4_valid_extent_entries() Zhang Yi
2021-10-07 16:44   ` Theodore Ts'o
2021-09-08 12:08 ` [RFC PATCH 2/3] ext4: check for inconsistent extents between index and leaf block Zhang Yi
2021-10-07 16:37   ` Theodore Ts'o
2021-10-08  9:02     ` Zhang Yi [this message]
2021-09-08 12:08 ` [RFC PATCH 3/3] ext4: prevent partial update of the extent blocks Zhang Yi
2021-10-07 16:45   ` Theodore Ts'o
2021-09-27 14:22 ` [RFC PATCH 0/3] ext4: enhance extent consistency check Zhang Yi
2021-10-14  2:32 ` Theodore Ts'o
2021-10-21 14:59 ` Theodore Ts'o

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=e3250b22-afda-04b9-76b3-ed50f2d52f1f@huawei.com \
    --to=yi.zhang@huawei.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=yukuai3@huawei.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.