linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Weinberger <richard.weinberger@gmail.com>
To: Zhihao Cheng <chengzhihao1@huawei.com>
Cc: linux-mtd@lists.infradead.org,
	LKML <linux-kernel@vger.kernel.org>,
	Richard Weinberger <richard@nod.at>,
	"zhangyi (F)" <yi.zhang@huawei.com>
Subject: Re: [PATCH] ubifs: Fix wrong orphan node deletion in ubifs_jnl_update()
Date: Tue, 7 Jul 2020 13:52:53 +0200	[thread overview]
Message-ID: <CAFLxGvybobVbhS4zQSxSmq3xR40QP=pkyDG8j7jA8a6eOOKfHg@mail.gmail.com> (raw)
In-Reply-To: <20200702152048.1819867-1-chengzhihao1@huawei.com>

On Thu, Jul 2, 2020 at 5:21 PM Zhihao Cheng <chengzhihao1@huawei.com> wrote:
>
> There a wrong orphan node deleting in error handling path in
> ubifs_jnl_update(), which may cause following error msg:
>
>   UBIFS error (ubi0:0 pid 1522): ubifs_delete_orphan [ubifs]:
>   missing orphan ino 65
>
> Fix this by checking whether the node has been operated for
> adding to orphan list before being deleted,
>
> Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
> ---
>  fs/ubifs/journal.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
> index e5ec1afe1c66..db0a80dd9d52 100644
> --- a/fs/ubifs/journal.c
> +++ b/fs/ubifs/journal.c
> @@ -539,7 +539,7 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir,
>                      const struct fscrypt_name *nm, const struct inode *inode,
>                      int deletion, int xent)
>  {
> -       int err, dlen, ilen, len, lnum, ino_offs, dent_offs;
> +       int err, dlen, ilen, len, lnum, ino_offs, dent_offs, orphan_added = 0;
>         int aligned_dlen, aligned_ilen, sync = IS_DIRSYNC(dir);
>         int last_reference = !!(deletion && inode->i_nlink == 0);
>         struct ubifs_inode *ui = ubifs_inode(inode);
> @@ -630,6 +630,7 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir,
>                         goto out_finish;
>                 }
>                 ui->del_cmtno = c->cmt_no;
> +               orphan_added = 1;
>         }
>
>         err = write_head(c, BASEHD, dent, len, &lnum, &dent_offs, sync);
> @@ -702,7 +703,7 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir,
>         kfree(dent);
>  out_ro:
>         ubifs_ro_mode(c, err);
> -       if (last_reference)
> +       if (last_reference && orphan_added)

I think you can just check for orphan_added here.
Looks good otherwise, thanks for fixing! :-)

-- 
Thanks,
//richard

  reply	other threads:[~2020-07-07 11:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-02 15:20 [PATCH] ubifs: Fix wrong orphan node deletion in ubifs_jnl_update() Zhihao Cheng
2020-07-07 11:52 ` Richard Weinberger [this message]
2020-07-07 11:57   ` Zhihao Cheng

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='CAFLxGvybobVbhS4zQSxSmq3xR40QP=pkyDG8j7jA8a6eOOKfHg@mail.gmail.com' \
    --to=richard.weinberger@gmail.com \
    --cc=chengzhihao1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=yi.zhang@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;
as well as URLs for NNTP newsgroup(s).