linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Deepa Dinamani <deepa.kernel@gmail.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Amir Goldstein <amir73il@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>, Jeff Layton <jlayton@kernel.org>,
	"J . Bruce Fields" <bfields@fieldses.org>,
	Miklos Szeredi <miklos@szeredi.hu>,
	Linux FS-devel Mailing List <linux-fsdevel@vger.kernel.org>,
	overlayfs <linux-unionfs@vger.kernel.org>,
	Linux NFS Mailing List <linux-nfs@vger.kernel.org>,
	y2038 Mailman List <y2038@lists.linaro.org>
Subject: Re: [PATCH] utimes: Clamp the timestamps in notify_change()
Date: Sun, 24 Nov 2019 13:13:50 -0800	[thread overview]
Message-ID: <CABeXuvqZUK4UMLA=hU5i9r0k6G7E+RCi58Om-KVeZuA3OjL4fA@mail.gmail.com> (raw)
In-Reply-To: <20191124194934.GB4203@ZenIV.linux.org.uk>

On Sun, Nov 24, 2019 at 11:49 AM Al Viro <viro@zeniv.linux.org.uk> wrote:
>
> On Sun, Nov 24, 2019 at 09:31:45PM +0200, Amir Goldstein wrote:
> > Push clamping timestamps down the call stack into notify_change(), so
> > in-kernel callers like nfsd and overlayfs will get similar timestamp
> > set behavior as utimes.
>
> Makes sense; said that, shouldn't we go through ->setattr() instances and
> get rid of that there, now that notify_change() is made to do it?
>
> I mean,
>         if (ia_valid & ATTR_ATIME)
>                 sd_iattr->ia_atime = timestamp_truncate(iattr->ia_atime,
>                                                       inode);
> in configfs_setattr() looks like it should be reverted to
>         if (ia_valid & ATTR_ATIME)
>                 sd_iattr->ia_atime = iattr->ia_atime;
> with that, etc.
>
> Moreover, does that leave any valid callers of timestamp_truncate()
> outside of notify_change() and current_time()?  IOW, is there any
> point having it exported?  Look:
> fs/attr.c:187:          inode->i_atime = timestamp_truncate(attr->ia_atime,
> fs/attr.c:191:          inode->i_mtime = timestamp_truncate(attr->ia_mtime,
> fs/attr.c:195:          inode->i_ctime = timestamp_truncate(attr->ia_ctime,
>         setattr_copy(), called downstream of your changes.
> fs/configfs/inode.c:79:         sd_iattr->ia_atime = timestamp_truncate(iattr->ia_atime,
> fs/configfs/inode.c:82:         sd_iattr->ia_mtime = timestamp_truncate(iattr->ia_mtime,
> fs/configfs/inode.c:85:         sd_iattr->ia_ctime = timestamp_truncate(iattr->ia_ctime,
>         configfs_setattr(); ditto.
> fs/f2fs/file.c:755:             inode->i_atime = timestamp_truncate(attr->ia_atime,
> fs/f2fs/file.c:759:             inode->i_mtime = timestamp_truncate(attr->ia_mtime,
> fs/f2fs/file.c:763:             inode->i_ctime = timestamp_truncate(attr->ia_ctime,
>         __setattr_copy() from f2fs_setattr(); ditto.
> fs/inode.c:2224:        return timestamp_truncate(now, inode);
>         current_time()
> fs/kernfs/inode.c:163:  inode->i_atime = timestamp_truncate(attrs->ia_atime, inode);
> fs/kernfs/inode.c:164:  inode->i_mtime = timestamp_truncate(attrs->ia_mtime, inode);
> fs/kernfs/inode.c:165:  inode->i_ctime = timestamp_truncate(attrs->ia_ctime, inode);
>         ->s_time_max and ->s_time_min are left TIME64_MAX and TIME64_MIN resp., so
> timestamp_truncate() should be a no-op there.
> fs/ntfs/inode.c:2903:           vi->i_atime = timestamp_truncate(attr->ia_atime,
> fs/ntfs/inode.c:2907:           vi->i_mtime = timestamp_truncate(attr->ia_mtime,
> fs/ntfs/inode.c:2911:           vi->i_ctime = timestamp_truncate(attr->ia_ctime,
>         ntfs_setattr(); downstream from your changes
> fs/ubifs/file.c:1082:           inode->i_atime = timestamp_truncate(attr->ia_atime,
> fs/ubifs/file.c:1086:           inode->i_mtime = timestamp_truncate(attr->ia_mtime,
> fs/ubifs/file.c:1090:           inode->i_ctime = timestamp_truncate(attr->ia_ctime,
>         do_attr_changes(), from do_truncation() or do_setattr(), both from ubifs_setattr();
> ditto.
> fs/utimes.c:39:                 newattrs.ia_atime = timestamp_truncate(times[0], inode);
> fs/utimes.c:46:                 newattrs.ia_mtime = timestamp_truncate(times[1], inode);
>         disappears in your patch.

We also want to replace all uses of timespec64_trunc() with
timestamp_truncate() for all fs cases.

In that case we have a few more:

fs/ceph/mds_client.c:   req->r_stamp = timespec64_trunc(ts,
mdsc->fsc->sb->s_time_gran);
fs/cifs/inode.c:        fattr->cf_mtime =
timespec64_trunc(fattr->cf_mtime, sb->s_time_gran);
fs/cifs/inode.c:                fattr->cf_atime =
timespec64_trunc(fattr->cf_atime, sb->s_time_gran);
fs/fat/misc.c:static inline struct timespec64
fat_timespec64_trunc_2secs(struct timespec64 ts)
fs/fat/misc.c:                  inode->i_ctime =
timespec64_trunc(*now, 10000000);
fs/fat/misc.c:                  inode->i_ctime =
fat_timespec64_trunc_2secs(*now);
fs/fat/misc.c:          inode->i_mtime = fat_timespec64_trunc_2secs(*now);
fs/ubifs/sb.c:  ts = timespec64_trunc(ts, DEFAULT_TIME_GRAN);

These do not follow from notify_change(), so these might still need
timestamp_truncate() exported.
I will post a cleanup series for timespec64_trunc() also, then we can decide.

-Deepa

  parent reply	other threads:[~2019-11-24 21:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-24 19:31 [PATCH] utimes: Clamp the timestamps in notify_change() Amir Goldstein
2019-11-24 19:49 ` Al Viro
2019-11-24 20:50   ` Amir Goldstein
2019-11-24 21:14     ` Deepa Dinamani
2019-11-24 21:13   ` Deepa Dinamani [this message]
2019-11-24 21:34     ` Al Viro
2019-11-30  5:34       ` Deepa Dinamani
2019-11-25 16:46 ` J . Bruce Fields
2019-11-25 17:35   ` Amir Goldstein
2019-11-25 18:16   ` Deepa Dinamani

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='CABeXuvqZUK4UMLA=hU5i9r0k6G7E+RCi58Om-KVeZuA3OjL4fA@mail.gmail.com' \
    --to=deepa.kernel@gmail.com \
    --cc=amir73il@gmail.com \
    --cc=arnd@arndb.de \
    --cc=bfields@fieldses.org \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=viro@zeniv.linux.org.uk \
    --cc=y2038@lists.linaro.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;
as well as URLs for NNTP newsgroup(s).