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

在 2020/7/7 19:52, Richard Weinberger 写道:
> 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! :-)
Sounds reasonable. I will send v2.


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

      reply	other threads:[~2020-07-07 11:58 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
2020-07-07 11:57   ` Zhihao Cheng [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=37d3628a-1904-bb94-e225-348dfeafe6b1@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard.weinberger@gmail.com \
    --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).