mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Richard Weinberger <richard@nod.at>, <linux-mtd@lists.infradead.org>
Cc: <david@sigma-star.at>, <linux-kernel@vger.kernel.org>,
	<stable@vger.kernel.org>
Subject: Re: [PATCH 3/4] ubifs: Update directory size when creating whiteouts
Date: Sat, 23 Jan 2021 10:45:15 +0800	[thread overview]
Message-ID: <5b51ff9c-8f5e-c348-5195-c0a0bf60b746@huawei.com> (raw)
In-Reply-To: <20210122212229.17072-4-richard@nod.at>

在 2021/1/23 5:22, Richard Weinberger 写道:
> Although whiteouts are unlinked files they will get re-linked later,
I just want to make sure, is this where the count is increased?
do_rename -> inc_nlink(whiteout)
> therefore the size of the parent directory needs to be updated too.
> 
> Cc: stable@vger.kernel.org
> Fixes: 9e0a1fff8db5 ("ubifs: Implement RENAME_WHITEOUT")
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
>   fs/ubifs/dir.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index 8a34e0118ee9..b5d523e5854f 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -361,6 +361,7 @@ static int do_tmpfile(struct inode *dir, struct dentry *dentry,
>   	struct ubifs_budget_req ino_req = { .dirtied_ino = 1 };
>   	struct ubifs_inode *ui, *dir_ui = ubifs_inode(dir);
>   	int err, instantiated = 0;
> +	int sz_change = 0;
>   	struct fscrypt_name nm;
>   
>   	/*
> @@ -411,6 +412,8 @@ static int do_tmpfile(struct inode *dir, struct dentry *dentry,
>   		mark_inode_dirty(inode);
>   		drop_nlink(inode);
>   		*whiteout = inode;
> +		sz_change = CALC_DENT_SIZE(fname_len(&nm));
> +		dir->i_size += sz_change;
>   	} else {
>   		d_tmpfile(dentry, inode);
>   	}
> @@ -430,6 +433,7 @@ static int do_tmpfile(struct inode *dir, struct dentry *dentry,
>   	return 0;
>   
>   out_cancel:
Does this need a judgment? Like this,
if (whiteout)
     dir->i_size -= sz_change;
> +	dir->i_size -= sz_change;
>   	mutex_unlock(&dir_ui->ui_mutex);
>   out_inode:
>   	make_bad_inode(inode);
> 


  reply	other threads:[~2021-01-23  2:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-22 21:22 [PATCH 0/4] Assorted UBIFS fixes Richard Weinberger
2021-01-22 21:22 ` [PATCH 1/4] ubifs: Correctly set inode size in ubifs_link() Richard Weinberger
2021-01-23  2:35   ` Zhihao Cheng
2021-01-22 21:22 ` [PATCH 2/4] ubifs: Don't add fscrypt context to xattrs Richard Weinberger
2021-01-22 21:22 ` [PATCH 3/4] ubifs: Update directory size when creating whiteouts Richard Weinberger
2021-01-23  2:45   ` Zhihao Cheng [this message]
2021-01-23 10:05     ` Richard Weinberger
2021-01-25  1:05     ` Zhihao Cheng
2021-01-25  7:55       ` Richard Weinberger
2021-01-25  9:31         ` Zhihao Cheng
2021-01-22 21:22 ` [PATCH 4/4] ubifs: Harden ubifs_jnl_write_inode() Richard Weinberger

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=5b51ff9c-8f5e-c348-5195-c0a0bf60b746@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=david@sigma-star.at \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=stable@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®