2019-07-30 04:17:26

by Deepa Dinamani

[permalink] [raw]
Subject: [PATCH 00/20] vfs: Add support for timestamp limits

The series is an update and a more complete version of the
previously posted series at
https://lore.kernel.org/linux-fsdevel/[email protected]/

Thanks to Arnd Bergmann for doing a few preliminary reviews.
They helped me fix a few issues I had overlooked.

The limits (sometimes granularity also) for the filesystems updated here are according to the
following table:

File system Time type Start year Expiration year Granularity
cramfs fixed 0 0
romfs fixed 0 0
pstore ascii seconds (27 digit ascii) S64_MIN S64_MAX NSEC_PER_USEC
coda INT64 S64_MIN S64_MAX 1
omfs 64-bit milliseconds 0 U64_MAX/ 1000 NSEC_PER_MSEC
befs unsigned 48-bit seconds 0 0xffffffffffff alloc_super
bfs unsigned 32-bit seconds 0 U32_MAX alloc_super
efs unsigned 32-bit seconds 0 U32_MAX alloc_super
ext2 signed 32-bit seconds S32_MIN S32_MAX alloc_super
ext3 signed 32-bit seconds S32_MIN S32_MAX alloc_super
ext4 (old) signed 32-bit seconds S32_MIN S32_MAX alloc_super
ext4 (extra) 34-bit seconds, 30-bit ns S32_MIN 0x37fffffff 1
freevxfs u32 secs/usecs 0 U32_MAX alloc_super
jffs2 unsigned 32-bit seconds 0 U32_MAX alloc_super
jfs unsigned 32-bit seconds/ns 0 U32_MAX 1
minix unsigned 32-bit seconds 0 U32_MAX alloc_super
orangefs u64 seconds 0 U64_MAX alloc_super
qnx4 unsigned 32-bit seconds 0 U32_MAX alloc_super
qnx6 unsigned 32-bit seconds 0 U32_MAX alloc_super
reiserfs unsigned 32-bit seconds 0 U32_MAX alloc_super
squashfs unsigned 32-bit seconds 0 U32_MAX alloc_super
ufs1 signed 32-bit seconds S32_MIN S32_MAX NSEC_PER_SEC
ufs2 signed 64-bit seconds/u32 ns S64_MIN S64_MAX 1
xfs signed 32-bit seconds/ns S32_MIN S32_MAX 1
ceph unsigned 32-bit second/ns 0 U32_MAX 1000
sysv unsigned 32-bit seconds 0 U32_MAX alloc_super
affs u32 day, min, ticks 1978 u32_max days NSEC_PER_SEC
nfsv2 unsigned 32-bit seconds/ns 0 U32_MAX 1
nfsv3 unsigned 32-bit seconds/ns 0 U32_MAX 1000
nfsv4 u64 seconds/u32 ns S64_MIN S64_MAX 1000
isofs u8 year since 1900 (fixable) 1900 2155 alloc_super
hpfs unsigned 32-bit seconds 1970 2106 alloc_super
fat 7-bit years, 2s resolution 1980 2107
cifs (smb) 7-bit years 1980 2107
cifs (modern) 64-bit 100ns since 1601 1601 30828
adfs 40-bit cs since 1900 1900 2248
9p (9P2000) unsigned 32-bit seconds 1970 2106
9p (9P2000.L) signed 64-bit seconds, ns 1970 S64_MAX

Granularity column filled in by the alloc_super() in the above table indicates that
the granularity is NSEC_PER_SEC.
Note that anything not mentioned above still has the default limits
S64_MIN..S64_MAX.

The patches in the series are as structured below:
1. Add vfs support to maintain the limits per filesystem.
2. Add a new timestamp_truncate() api for clamping timestamps
according to the filesystem limits.
3. Add a warning for mount syscall to indicate the impending
expiry of timestamps.
4. Modify utimes to clamp the timestamps.
5. Fill in limits for filesystems.

An updated version of the test for checking file system timestamp limits has been posted
at https://www.spinics.net/lists/fstests/msg12262.html

Changes from previous version:
* No change in mount behavior because of expiry of timestamps.
* Included limits for more filesystems.

Deepa Dinamani (20):
vfs: Add file timestamp range support
vfs: Add timestamp_truncate() api
timestamp_truncate: Replace users of timespec64_trunc
mount: Add mount warning for impending timestamp expiry
utimes: Clamp the timestamps before update
fs: Fill in max and min timestamps in superblock
9p: Fill min and max timestamps in sb
adfs: Fill in max and min timestamps in sb
ext4: Initialize timestamps limits
fs: nfs: Initialize filesystem timestamp ranges
fs: cifs: Initialize filesystem timestamp ranges
fs: fat: Initialize filesystem timestamp ranges
fs: affs: Initialize filesystem timestamp ranges
fs: sysv: Initialize filesystem timestamp ranges
fs: ceph: Initialize filesystem timestamp ranges
fs: orangefs: Initialize filesystem timestamp ranges
fs: hpfs: Initialize filesystem timestamp ranges
fs: omfs: Initialize filesystem timestamp ranges
pstore: fs superblock limits
isofs: Initialize filesystem timestamp ranges

fs/9p/vfs_super.c | 6 +++++-
fs/adfs/adfs.h | 13 +++++++++++++
fs/adfs/inode.c | 8 ++------
fs/adfs/super.c | 2 ++
fs/affs/amigaffs.c | 2 +-
fs/affs/amigaffs.h | 3 +++
fs/affs/inode.c | 4 ++--
fs/affs/super.c | 4 ++++
fs/attr.c | 21 ++++++++++++---------
fs/befs/linuxvfs.c | 2 ++
fs/bfs/inode.c | 2 ++
fs/ceph/super.c | 2 ++
fs/cifs/cifsfs.c | 22 ++++++++++++++++++++++
fs/cifs/netmisc.c | 14 +++++++-------
fs/coda/inode.c | 3 +++
fs/configfs/inode.c | 12 ++++++------
fs/cramfs/inode.c | 2 ++
fs/efs/super.c | 2 ++
fs/ext2/super.c | 2 ++
fs/ext4/ext4.h | 4 ++++
fs/ext4/super.c | 17 +++++++++++++++--
fs/f2fs/file.c | 21 ++++++++++++---------
fs/fat/inode.c | 12 ++++++++++++
fs/fat/misc.c | 5 +++--
fs/freevxfs/vxfs_super.c | 2 ++
fs/hpfs/hpfs_fn.h | 6 ++----
fs/hpfs/super.c | 2 ++
fs/inode.c | 33 ++++++++++++++++++++++++++++++++-
fs/isofs/inode.c | 7 +++++++
fs/jffs2/fs.c | 3 +++
fs/jfs/super.c | 2 ++
fs/kernfs/inode.c | 6 +++---
fs/minix/inode.c | 2 ++
fs/namespace.c | 11 +++++++++++
fs/nfs/super.c | 20 +++++++++++++++++++-
fs/ntfs/inode.c | 21 ++++++++++++---------
fs/omfs/inode.c | 4 ++++
fs/orangefs/super.c | 2 ++
fs/pstore/inode.c | 4 +++-
fs/qnx4/inode.c | 2 ++
fs/qnx6/inode.c | 2 ++
fs/reiserfs/super.c | 3 +++
fs/romfs/super.c | 2 ++
fs/squashfs/super.c | 2 ++
fs/super.c | 2 ++
fs/sysv/super.c | 5 ++++-
fs/ubifs/file.c | 21 ++++++++++++---------
fs/ufs/super.c | 7 +++++++
fs/utimes.c | 17 +++++++++++++----
fs/xfs/xfs_super.c | 2 ++
include/linux/fs.h | 5 +++++
include/linux/time64.h | 2 ++
52 files changed, 304 insertions(+), 78 deletions(-)

--
2.17.1

Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]


2019-07-30 04:26:38

by Deepa Dinamani

[permalink] [raw]
Subject: [PATCH 10/20] fs: nfs: Initialize filesystem timestamp ranges

Fill in the appropriate limits to avoid inconsistencies
in the vfs cached inode times when timestamps are
outside the permitted range.

The time formats for various verious is detailed in the
RFCs as below:

https://tools.ietf.org/html/rfc7862(time metadata)
https://tools.ietf.org/html/rfc7530:

nfstime4

struct nfstime4 {
int64_t seconds;
uint32_t nseconds;
};

https://tools.ietf.org/html/rfc1094

struct timeval {
unsigned int seconds;
unsigned int useconds;
};

https://tools.ietf.org/html/rfc1813

struct nfstime3 {
uint32 seconds;
uint32 nseconds;
};

Use the limits as per the RFC.

Signed-off-by: Deepa Dinamani <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
fs/nfs/super.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index f88ddac2dcdf..54eb5a47f180 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2360,6 +2360,15 @@ void nfs_fill_super(struct super_block *sb, struct nfs_mount_info *mount_info)
sb->s_flags |= SB_POSIXACL;
sb->s_time_gran = 1;
sb->s_export_op = &nfs_export_ops;
+ } else
+ sb->s_time_gran = 1000;
+
+ if (server->nfs_client->rpc_ops->version != 4) {
+ sb->s_time_min = 0;
+ sb->s_time_max = U32_MAX;
+ } else {
+ sb->s_time_min = S64_MIN;
+ sb->s_time_max = S64_MAX;
}

nfs_initialise_sb(sb);
@@ -2380,7 +2389,6 @@ static void nfs_clone_super(struct super_block *sb,
sb->s_maxbytes = old_sb->s_maxbytes;
sb->s_xattr = old_sb->s_xattr;
sb->s_op = old_sb->s_op;
- sb->s_time_gran = 1;
sb->s_export_op = old_sb->s_export_op;

if (server->nfs_client->rpc_ops->version != 2) {
@@ -2388,6 +2396,16 @@ static void nfs_clone_super(struct super_block *sb,
* so ourselves when necessary.
*/
sb->s_flags |= SB_POSIXACL;
+ sb->s_time_gran = 1;
+ } else
+ sb->s_time_gran = 1000;
+
+ if (server->nfs_client->rpc_ops->version != 4) {
+ sb->s_time_min = 0;
+ sb->s_time_max = U32_MAX;
+ } else {
+ sb->s_time_min = S64_MIN;
+ sb->s_time_max = S64_MAX;
}

nfs_initialise_sb(sb);
--
2.17.1