]> git.baikalelectronics.ru Git - kernel.git/commitdiff
nfs: fscache: use timespec64 in inode auxdata
authorArnd Bergmann <arnd@arndb.de>
Mon, 11 Nov 2019 20:16:25 +0000 (21:16 +0100)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Wed, 15 Jan 2020 15:54:30 +0000 (10:54 -0500)
nfs currently behaves differently on 32-bit and 64-bit kernels regarding
the on-disk format of nfs_fscache_inode_auxdata.

That format should really be the same on any kernel, and we should avoid
the 'timespec' type in order to remove that from the kernel later on.

Using plain 'timespec64' would not be good here, since that includes
implied padding and would possibly leak kernel stack data to the on-disk
format on 32-bit architectures.

struct __kernel_timespec would work as a replacement, but open-coding
the two struct members in nfs_fscache_inode_auxdata makes it more
obvious what's going on here, and keeps the current format for 64-bit
architectures.

Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
fs/nfs/fscache-index.c
fs/nfs/fscache.c
fs/nfs/fscache.h

index 15f271401dcca311aa83d98b90bc982cbe49a923..573b1da9342c124f213ebfb159fe7d37e0033e46 100644 (file)
@@ -84,8 +84,10 @@ enum fscache_checkaux nfs_fscache_inode_check_aux(void *cookie_netfs_data,
                return FSCACHE_CHECKAUX_OBSOLETE;
 
        memset(&auxdata, 0, sizeof(auxdata));
-       auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime);
-       auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime);
+       auxdata.mtime_sec  = nfsi->vfs_inode.i_mtime.tv_sec;
+       auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec;
+       auxdata.ctime_sec  = nfsi->vfs_inode.i_ctime.tv_sec;
+       auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec;
 
        if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4)
                auxdata.change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode);
index 4a8df8c30a03fed45a1cb6aedaadfbfcb4a895da..52270bfac120b99f3464af019c0ccc74078b8b92 100644 (file)
@@ -238,8 +238,10 @@ void nfs_fscache_init_inode(struct inode *inode)
                return;
 
        memset(&auxdata, 0, sizeof(auxdata));
-       auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime);
-       auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime);
+       auxdata.mtime_sec  = nfsi->vfs_inode.i_mtime.tv_sec;
+       auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec;
+       auxdata.ctime_sec  = nfsi->vfs_inode.i_ctime.tv_sec;
+       auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec;
 
        if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4)
                auxdata.change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode);
@@ -263,8 +265,10 @@ void nfs_fscache_clear_inode(struct inode *inode)
        dfprintk(FSCACHE, "NFS: clear cookie (0x%p/0x%p)\n", nfsi, cookie);
 
        memset(&auxdata, 0, sizeof(auxdata));
-       auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime);
-       auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime);
+       auxdata.mtime_sec  = nfsi->vfs_inode.i_mtime.tv_sec;
+       auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec;
+       auxdata.ctime_sec  = nfsi->vfs_inode.i_ctime.tv_sec;
+       auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec;
        fscache_relinquish_cookie(cookie, &auxdata, false);
        nfsi->fscache = NULL;
 }
@@ -305,8 +309,10 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp)
                return;
 
        memset(&auxdata, 0, sizeof(auxdata));
-       auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime);
-       auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime);
+       auxdata.mtime_sec  = nfsi->vfs_inode.i_mtime.tv_sec;
+       auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec;
+       auxdata.ctime_sec  = nfsi->vfs_inode.i_ctime.tv_sec;
+       auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec;
 
        if (inode_is_open_for_write(inode)) {
                dfprintk(FSCACHE, "NFS: nfsi 0x%p disabling cache\n", nfsi);
index ad041cfbf9ec0fe616441dc653225c30f0983ca8..6754c8607230ba60da15c2040c0fe53d9e6e06bd 100644 (file)
@@ -62,9 +62,11 @@ struct nfs_fscache_key {
  * cache object.
  */
 struct nfs_fscache_inode_auxdata {
-       struct timespec mtime;
-       struct timespec ctime;
-       u64             change_attr;
+       s64     mtime_sec;
+       s64     mtime_nsec;
+       s64     ctime_sec;
+       s64     ctime_nsec;
+       u64     change_attr;
 };
 
 /*