linux-unionfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Chengguang Xu <cgxu519@mykernel.net>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
	overlayfs <linux-unionfs@vger.kernel.org>
Subject: Re: [PATCH v2 1/3] ovl: do not restore mtime on copy-up for regular file
Date: Wed, 7 Apr 2021 09:55:22 +0300	[thread overview]
Message-ID: <CAOQ4uxjVUt1a91bn7=QCdcXiuC+obyHAHxfChM6CcuaBUBtt_A@mail.gmail.com> (raw)
In-Reply-To: <20210406120245.1338326-1-cgxu519@mykernel.net>

On Wed, Apr 7, 2021 at 12:04 AM Chengguang Xu <cgxu519@mykernel.net> wrote:
>
> In order to simplify truncate operation on the file which
> only has lower, we skip restoring mtime on copy-up for
> regular file.
>
> Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
> ---
>  fs/overlayfs/copy_up.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
> index 0fed532efa68..8b92b3ba3c46 100644
> --- a/fs/overlayfs/copy_up.c
> +++ b/fs/overlayfs/copy_up.c
> @@ -241,12 +241,17 @@ static int ovl_set_size(struct dentry *upperdentry, struct kstat *stat)
>
>  static int ovl_set_timestamps(struct dentry *upperdentry, struct kstat *stat)
>  {
> -       struct iattr attr = {
> -               .ia_valid =
> -                    ATTR_ATIME | ATTR_MTIME | ATTR_ATIME_SET | ATTR_MTIME_SET,
> -               .ia_atime = stat->atime,
> -               .ia_mtime = stat->mtime,
> -       };
> +       struct iattr attr;
> +
> +       if (S_ISREG(upperdentry->d_inode->i_mode)) {
> +               attr.ia_valid = ATTR_ATIME | ATTR_ATIME_SET;
> +               attr.ia_atime = stat->atime;
> +       } else {
> +               attr.ia_valid = ATTR_ATIME | ATTR_MTIME |
> +                               ATTR_ATIME_SET | ATTR_MTIME_SET;
> +               attr.ia_atime = stat->atime;
> +               attr.ia_mtime = stat->mtime;
> +       }

Nit: IMO it would look nicer with:
if (!S_ISREG(stat->mode)) {
               attr.ia_valid |= ATTR_MTIME | ATTR_MTIME_SET;
               attr.ia_mtime = stat->mtime;
}

But generally, this logic looks a bit weird in a function named
ovl_set_timestamps().

When you look at the 3 callers of ovl_set_timestamps(), two of
them do it for a directory and one is in ovl_set_attr() where there
are several other open coded calls to notify_change(), so I
wonder if this logic shouldn't be open coded in ovl_set_attr()
as well?

Thanks,
Amir.

      parent reply	other threads:[~2021-04-07  6:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-06 12:02 [PATCH v2 1/3] ovl: do not restore mtime on copy-up for regular file Chengguang Xu
2021-04-06 12:02 ` [PATCH v2 2/3] ovl: check actual copy-up size Chengguang Xu
2021-04-07  6:56   ` Amir Goldstein
2021-04-06 12:02 ` [PATCH v2 3/3] ovl: copy-up optimization for truncate Chengguang Xu
2021-04-07  7:52   ` Amir Goldstein
2021-04-08 13:23     ` Chengguang Xu
2021-04-08 14:40       ` Amir Goldstein
2021-04-09  3:00         ` Chengguang Xu
2021-04-09  5:50           ` Amir Goldstein
2021-04-09  8:02             ` Miklos Szeredi
2021-04-07  6:55 ` Amir Goldstein [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='CAOQ4uxjVUt1a91bn7=QCdcXiuC+obyHAHxfChM6CcuaBUBtt_A@mail.gmail.com' \
    --to=amir73il@gmail.com \
    --cc=cgxu519@mykernel.net \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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).