Re: [PATCH] utimes: Clamp the timestamps in notify_change()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Nov 24, 2019 at 11:49 AM Al Viro <viro@xxxxxxxxxxxxxxxxxx> 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



[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux