public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: yebin <yebin10@huawei.com>
Cc: Jan Kara <jack@suse.cz>,
	tytso@mit.edu, adilger.kernel@dilger.ca,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] ext4: Fix bug on in ext4_es_cache_extent as ext4_split_extent_at failed
Date: Thu, 6 May 2021 14:15:29 +0200	[thread overview]
Message-ID: <20210506121529.GC22189@quack2.suse.cz> (raw)
In-Reply-To: <6093D73F.70909@huawei.com>

On Thu 06-05-21 19:47:11, yebin wrote:
> 
> 
> On 2021/5/6 18:19, Jan Kara wrote:
> > On Thu 06-05-21 16:26:24, yebin wrote:
> > > Thanks for your suggesttion. If you have no objection to following
> > > modification, i will send it as V4.
> > > 
> > > diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> > > index 77c84d6f1af6..f9cbd11e1eae 100644
> > > --- a/fs/ext4/extents.c
> > > +++ b/fs/ext4/extents.c
> > > @@ -3206,7 +3206,10 @@ static int ext4_split_extent_at(handle_t *handle,
> > >                  ext4_ext_mark_unwritten(ex2);
> > > 
> > >          err = ext4_ext_insert_extent(handle, inode, ppath, &newex, flags);
> > > -       if (err == -ENOSPC && (EXT4_EXT_MAY_ZEROOUT & split_flag)) {
> > > +       if (err != -ENOSPC && err != -EDQUOT)
> > > +                goto out;
> > > +
> > > +       if (EXT4_EXT_MAY_ZEROOUT & split_flag) {
> > You need:
> > 
> > if (err && (EXT4_EXT_MAY_ZEROOUT & split_flag))
> > 
> > there, don't you? You don't want to zero-out if there's no error.
> 
> If (err != -ENOSPC && err != -EDQUOT) already goto out, so there is needn't
> judge "err" again.

Right, my fault. I was confused.

> > > @@ -3232,22 +3235,23 @@ static int ext4_split_extent_at(handle_t *handle,
> > > ext4_ext_pblock(&orig_ex));
> > >                  }
> > > 
> > > -               if (err)
> > > -                       goto fix_extent_len;
> > > -               /* update the extent length and mark as initialized */
> > > -               ex->ee_len = cpu_to_le16(ee_len);
> > > -               ext4_ext_try_to_merge(handle, inode, path, ex);
> > > -               err = ext4_ext_dirty(handle, inode, path + path->p_depth);
> > > -               if (err)
> > > -                       goto fix_extent_len;
> > > -
> > > -               /* update extent status tree */
> > > -               err = ext4_zeroout_es(inode, &zero_ex);
> > > -
> > > -               goto out;
> > > -       } else if (err)
> > > -               goto fix_extent_len;
> > > -
> > > +               if (!err) {
> > > +                       /* update the extent length and mark as initialized
> > > */
> > > +                        ex->ee_len = cpu_to_le16(ee_len);
> > > +                        ext4_ext_try_to_merge(handle, inode, path, ex);
> > > +                        err = ext4_ext_dirty(handle, inode, path +
> > > path->p_depth);
> > > +                        if (!err)
> > > +                               /* update extent status tree */
> > > +                                err = ext4_zeroout_es(inode, &zero_ex);
> > > +                        /* At here, ext4_ext_try_to_merge maybe already
> > > merge
> > > +                         * extent, if fix origin extent length may lead to
> > > +                         * overwritten.
> > > +                         */
> > I'd rephrase the comment as:
> > 
> > /*
> >   * If we failed at this point, we don't know in which state the extent tree
> >   * exactly is so don't try to fix length of the original extent as it may do
> >   * even more damage.
> >   */
> I will replace it with your comment.
> > 
> > > +                        goto out;
> > > +                }
> > > +       }
> > > +        if (err)
> > > +                goto fix_extent_len;
> > And you can move this if (err) before if (!err) above to make code easier
> > to read and save one indentation level.
> if (EXT4_EXT_MAY_ZEROOUT & split_flag) do zero-out,  if  failed, we don't
> need fix extent length.
> But if (!EXT4_EXT_MAY_ZEROOUT & split_flag) we need to fix extent length.
> Maybe i can move
> label "out"  behind  label "fix_extent_len", then this judement can be
> removed.
> Did i misunderstand what you meant earlier?

Thanks for the update! The diff now looks good to me so feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

for your next posting.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

      reply	other threads:[~2021-05-06 12:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-28  8:51 [PATCH v3] ext4: Fix bug on in ext4_es_cache_extent as ext4_split_extent_at failed Ye Bin
2021-04-30 12:58 ` Jan Kara
2021-05-05  3:29   ` yebin
2021-05-05 10:41     ` Jan Kara
2021-05-06  8:26       ` yebin
2021-05-06 10:19         ` Jan Kara
2021-05-06 11:47           ` yebin
2021-05-06 12:15             ` Jan Kara [this message]

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=20210506121529.GC22189@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=yebin10@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox