Support btime and other NFSv4 specific attributes
Subsystems (2)
[email protected]
maintainerv2 cover Support btime and other NFSv4 specific attributes
From: Trond Myklebust <[email protected]>
NFSv4 has support for a number of extra attributes that are of interest to Samba when it is used to re-export a filesystem to Windows clients. Aside from the btime, which is of interest in statx(), Windows clients have an interest in determining the status of the 'hidden', and 'system' flags.
Backup programs want to read the 'archive' flags and the 'time backup' attribute.
Finally, the 'offline' flag can tell whether or not a file needs to be staged by an HSM system before it can be read or written to.
The patch series also adds an ioctl() to allow userspace retrieval and setting of these attributes where appropriate. It also adds an ioctl() to allow retrieval of the raw NFSv4 ACCESS information, to allow more fine grained determination of the user's access rights to a file or directory. All of this information is of use for Samba.
- v2: Rebase on top of Anna's linux-next
Anne Marie Merritt (3):
nfs: Add timecreate to nfs inode
nfs: Add 'archive', 'hidden' and 'system' fields to nfs inode
nfs: Add 'time backup' to nfs inode
Richard Sharpe (1):
NFS: Support statx_get and statx_set ioctls
Trond Myklebust (4):
NFS: Expand the type of nfs_fattr->valid
NFS: Return the file btime in the statx results when appropriate
NFSv4: Support the offline bit
NFSv4: Add an ioctl to allow retrieval of the NFS raw ACCESS mask
fs/nfs/dir.c | 71 ++--- fs/nfs/getroot.c | 3 +- fs/nfs/inode.c | 147 +++++++++- fs/nfs/internal.h | 10 + fs/nfs/nfs3proc.c | 1 + fs/nfs/nfs4_fs.h | 31 +++ fs/nfs/nfs4file.c | 550 ++++++++++++++++++++++++++++++++++++++ fs/nfs/nfs4proc.c | 175 +++++++++++- fs/nfs/nfs4trace.h | 8 +- fs/nfs/nfs4xdr.c | 240 +++++++++++++++-- fs/nfs/nfstrace.c | 5 + fs/nfs/nfstrace.h | 9 +- fs/nfs/proc.c | 1 + include/linux/nfs4.h | 1 + include/linux/nfs_fs.h | 15 ++ include/linux/nfs_fs_sb.h | 2 +- include/linux/nfs_xdr.h | 80 ++++-- include/uapi/linux/nfs.h | 101 +++++++ 18 files changed, 1355 insertions(+), 95 deletions(-)
Signature · 1 line
2.33.1
[email protected]
maintainerPATCH v2 1/8 NFS: Expand the type of nfs_fattr->valid
From: Trond Myklebust <[email protected]>
We need to be able to track more than 32 attributes per inode.
--- fs/nfs/inode.c | 5 ++-- include/linux/nfs_fs_sb.h | 2 +- include/linux/nfs_xdr.h | 54 +++++++++++++++++++-------------------- 3 files changed, 31 insertions(+), 30 deletions(-)
fs/nfs/inode.c +3 -2
@@ -2001,10 +2001,11 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)bool attr_changed = false;bool have_delegation; -dfprintk (VFS ,"NFS: %s(%s/%lu fh_crc=0x%08x ct=%d info=0x%x)\n" , +dfprintk (VFS ,"NFS: %s(%s/%lu fh_crc=0x%08x ct=%d info=0x%lx)\n" , __func__, inode->i_sb->s_id, inode->i_ino,nfs_display_fhandle_hash (NFS_FH (inode)), -atomic_read (&inode->i_count), fattr->valid); +atomic_read (&inode->i_count), + (unsigned long )fattr->valid);if (!(fattr->valid &NFS_ATTR_FATTR_FILEID )) {/* Only a mounted-on-fileid? Just exit */
include/linux/nfs_fs_sb.h +1 -1
@@ -157,8 +157,8 @@ struct nfs_server {#define NFS_MOUNT_WRITE_EAGER 0x01000000#define NFS_MOUNT_WRITE_WAIT 0x02000000 -unsigned int fattr_valid;/* Valid attributes */ unsigned int caps;/* server capabilities */ +__u64 fattr_valid;/* Valid attributes */ unsigned int rsize;/* read size */ unsigned int rpages;/* read size (in pages) */ unsigned int wsize;/* write size */
include/linux/nfs_xdr.h +27 -27
66 lines not on this page · raw message
Signature · 1 line
2.33.1
[email protected]
maintainerPATCH v2 2/8 nfs: Add timecreate to nfs inode
From: Anne Marie Merritt <[email protected]>
Add tracking of the create time (a.k.a. btime) along with corresponding bitfields, request, and decode xdr routines.
--- fs/nfs/inode.c | 28 ++++++++++++++++++++++------ fs/nfs/nfs4proc.c | 15 +++++++++++++-- fs/nfs/nfs4xdr.c | 24 ++++++++++++++++++++++++ fs/nfs/nfstrace.h | 3 ++- include/linux/nfs_fs.h | 7 +++++++ include/linux/nfs_xdr.h | 3 +++ 6 files changed, 71 insertions(+), 9 deletions(-)
fs/nfs/inode.c +22 -6
@@ -201,6 +201,7 @@ void nfs_set_cache_invalid(struct inode *inode, unsigned long flags)if (!(flags &NFS_INO_REVAL_FORCED )) flags &= ~(NFS_INO_INVALID_MODE |NFS_INO_INVALID_OTHER | +NFS_INO_INVALID_BTIME |NFS_INO_INVALID_XATTR ); flags &= ~(NFS_INO_INVALID_CHANGE |NFS_INO_INVALID_SIZE ); }else if (flags &NFS_INO_REVAL_PAGECACHE )
@@ -521,6 +522,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)memset (&inode->i_atime,0 ,sizeof (inode->i_atime));memset (&inode->i_mtime,0 ,sizeof (inode->i_mtime));memset (&inode->i_ctime,0 ,sizeof (inode->i_ctime)); +memset (&nfsi->btime,0 ,sizeof (nfsi->btime));inode_set_iversion_raw (inode,0 ); inode->i_size =0 ;clear_nlink (inode);
@@ -544,6 +546,10 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) inode->i_ctime = fattr->ctime; else if (fattr_supported & NFS_ATTR_FATTR_CTIME) nfs_set_cache_invalid(inode, NFS_INO_INVALID_CTIME); +if (fattr->valid &NFS_ATTR_FATTR_BTIME ) + nfsi->btime = fattr->btime; +else if (fattr_supported &NFS_ATTR_FATTR_BTIME ) +nfs_set_cache_invalid (inode,NFS_INO_INVALID_BTIME );if (fattr->valid &NFS_ATTR_FATTR_CHANGE )inode_set_iversion_raw (inode, fattr->change_attr);else
@@ -1801,7 +1807,7 @@ static int nfs_inode_finish_partial_attr_update(const struct nfs_fattr *fattr,NFS_INO_INVALID_ATIME |NFS_INO_INVALID_CTIME |NFS_INO_INVALID_MTIME |NFS_INO_INVALID_SIZE |NFS_INO_INVALID_BLOCKS |NFS_INO_INVALID_OTHER | -NFS_INO_INVALID_NLINK ; +NFS_INO_INVALID_NLINK |NFS_INO_INVALID_BTIME ;unsigned long cache_validity =NFS_I (inode)->cache_validity;enum nfs4_change_attr_type ctype =NFS_SERVER (inode)->change_attr_type;
@@ -2052,10 +2058,13 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) nfsi->read_cache_jiffies = fattr->time_start; save_cache_validity = nfsi->cache_validity; - nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR - |NFS_INO_INVALID_ATIME - |NFS_INO_REVAL_FORCED - |NFS_INO_INVALID_BLOCKS ); + nfsi->cache_validity &= + ~(NFS_INO_INVALID_ATIME |NFS_INO_REVAL_FORCED | +NFS_INO_INVALID_CHANGE |NFS_INO_INVALID_CTIME | +NFS_INO_INVALID_MTIME |NFS_INO_INVALID_SIZE | +NFS_INO_INVALID_OTHER |NFS_INO_INVALID_BLOCKS | +NFS_INO_INVALID_NLINK |NFS_INO_INVALID_MODE | +NFS_INO_INVALID_BTIME );/* Do atomic weak cache consistency updates */ nfs_wcc_update_inode (inode, fattr);
@@ -2085,7 +2094,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | NFS_INO_INVALID_BLOCKS |NFS_INO_INVALID_NLINK |NFS_INO_INVALID_MODE - |NFS_INO_INVALID_OTHER ; + |NFS_INO_INVALID_OTHER + |NFS_INO_INVALID_BTIME ;if (S_ISDIR (inode->i_mode))nfs_force_lookup_revalidate (inode); attr_changed = true;
@@ -2116,6 +2126,12 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) nfsi->cache_validity |= save_cache_validity &NFS_INO_INVALID_CTIME ; +if (fattr->valid &NFS_ATTR_FATTR_BTIME ) + nfsi->btime = fattr->btime; +else if (fattr_supported &NFS_ATTR_FATTR_BTIME ) + nfsi->cache_validity |= + save_cache_validity &NFS_INO_INVALID_BTIME ; +/* Check if our cached file size is stale */ if (fattr->valid &NFS_ATTR_FATTR_SIZE ) { new_isize =nfs_size_to_loff_t (fattr->size);
fs/nfs/nfs4proc.c +13 -2
@@ -208,6 +208,7 @@ const u32 nfs4_fattr_bitmap[3] = { | FATTR4_WORD1_RAWDEV |FATTR4_WORD1_SPACE_USED |FATTR4_WORD1_TIME_ACCESS + |FATTR4_WORD1_TIME_CREATE |FATTR4_WORD1_TIME_METADATA |FATTR4_WORD1_TIME_MODIFY | FATTR4_WORD1_MOUNTED_ON_FILEID,
@@ -229,6 +230,7 @@ static const u32 nfs4_pnfs_open_bitmap[3] = { | FATTR4_WORD1_RAWDEV |FATTR4_WORD1_SPACE_USED |FATTR4_WORD1_TIME_ACCESS + |FATTR4_WORD1_TIME_CREATE |FATTR4_WORD1_TIME_METADATA |FATTR4_WORD1_TIME_MODIFY ,FATTR4_WORD2_MDSTHRESHOLD
@@ -308,6 +310,9 @@ static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src, dst[1 ] &= ~FATTR4_WORD1_MODE ;if (!(cache_validity &NFS_INO_INVALID_OTHER )) dst[1 ] &= ~(FATTR4_WORD1_OWNER |FATTR4_WORD1_OWNER_GROUP ); + +if (!(cache_validity &NFS_INO_INVALID_BTIME )) + dst[1 ] &= ~FATTR4_WORD1_TIME_CREATE ; } static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dentry,
@@ -1233,8 +1238,8 @@ nfs4_update_changeattr_locked(struct inode *inode,NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL |NFS_INO_INVALID_SIZE |NFS_INO_INVALID_OTHER |NFS_INO_INVALID_BLOCKS |NFS_INO_INVALID_NLINK | -NFS_INO_INVALID_MODE |NFS_INO_INVALID_XATTR | -NFS_INO_REVAL_PAGECACHE ; +NFS_INO_INVALID_MODE |NFS_INO_INVALID_BTIME | +NFS_INO_INVALID_XATTR |NFS_INO_REVAL_PAGECACHE ; nfsi->attrtimeo =NFS_MINATTRTIMEO (inode); } nfsi->attrtimeo_timestamp = jiffies;
@@ -3893,6 +3898,10 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *f server->fattr_valid &= ~NFS_ATTR_FATTR_CTIME ;if (!(res.attr_bitmask[1 ] &FATTR4_WORD1_TIME_MODIFY )) server->fattr_valid &= ~NFS_ATTR_FATTR_MTIME ; +if (!(res.attr_bitmask[1 ] &FATTR4_WORD1_TIME_MODIFY )) + server->fattr_valid &= ~NFS_ATTR_FATTR_MTIME ; +if (!(res.attr_bitmask[1 ] &FATTR4_WORD1_TIME_CREATE )) + server->fattr_valid &= ~NFS_ATTR_FATTR_BTIME ;memcpy (server->attr_bitmask_nl, res.attr_bitmask,sizeof (server->attr_bitmask)); server->attr_bitmask_nl[2 ] &= ~FATTR4_WORD2_SECURITY_LABEL ;
@@ -5450,6 +5459,8 @@ static void nfs4_bitmask_set(__u32 bitmask[NFS4_BITMASK_SZ], const __u32 *src, bitmask[1 ] |=FATTR4_WORD1_TIME_MODIFY ;if (cache_validity &NFS_INO_INVALID_BLOCKS ) bitmask[1 ] |=FATTR4_WORD1_SPACE_USED ; +if (cache_validity &NFS_INO_INVALID_BTIME ) + bitmask[1 ] |=FATTR4_WORD1_TIME_CREATE ;if (cache_validity &NFS_INO_INVALID_SIZE ) bitmask[0 ] |=FATTR4_WORD0_SIZE ;
fs/nfs/nfs4xdr.c +24 -0
@@ -1616,6 +1616,7 @@ static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg attrs[1 ] |=FATTR4_WORD1_MODE |FATTR4_WORD1_NUMLINKS |FATTR4_WORD1_OWNER |FATTR4_WORD1_OWNER_GROUP |FATTR4_WORD1_RAWDEV |FATTR4_WORD1_SPACE_USED |FATTR4_WORD1_TIME_ACCESS | +FATTR4_WORD1_TIME_CREATE |FATTR4_WORD1_TIME_METADATA |FATTR4_WORD1_TIME_MODIFY ; attrs[2 ] |=FATTR4_WORD2_SECURITY_LABEL ; dircount >>=1 ;
@@ -4121,6 +4122,24 @@ static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, strreturn status; } +static int decode_attr_time_create (struct xdr_stream *xdr,uint32_t *bitmap,struct timespec64 *time) +{ +int status =0 ; + + time->tv_sec =0 ; + time->tv_nsec =0 ; +if (unlikely (bitmap[1 ] & (FATTR4_WORD1_TIME_CREATE -1U ))) +return -EIO ; +if (likely (bitmap[1 ] &FATTR4_WORD1_TIME_CREATE )) { + status =decode_attr_time (xdr, time); +if (status ==0 ) + status =NFS_ATTR_FATTR_BTIME ; + bitmap[1 ] &= ~FATTR4_WORD1_TIME_CREATE ; + } +dprintk ("%s: btime=%lld\n" , __func__, time->tv_sec); +return status; +} +static int decode_attr_time_metadata (struct xdr_stream *xdr,uint32_t *bitmap,struct timespec64 *time) {int status =0 ;
@@ -4678,6 +4697,11 @@ static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, goto xdr_error; fattr->valid |= status; + status =decode_attr_time_create (xdr, bitmap, &fattr->btime); +if (status <0 ) + goto xdr_error; + fattr->valid |= status; + status =decode_attr_time_metadata (xdr, bitmap, &fattr->ctime);if (status <0 ) goto xdr_error;
fs/nfs/nfstrace.h +2 -1
@@ -33,7 +33,8 @@ { NFS_INO_INVALID_BLOCKS, "INVALID_BLOCKS" }, \ { NFS_INO_INVALID_XATTR, "INVALID_XATTR" }, \ { NFS_INO_INVALID_NLINK, "INVALID_NLINK" }, \ - { NFS_INO_INVALID_MODE, "INVALID_MODE" }) + { NFS_INO_INVALID_MODE, "INVALID_MODE" }, \ + { NFS_INO_INVALID_BTIME, "INVALID_BTIME" }) #define nfs_show_nfsi_flags(v) \ __print_flags(v, "|", \
include/linux/nfs_fs.h +7 -0
@@ -138,6 +138,12 @@ struct nfs_inode {unsigned long flags;/* atomic bit ops */ unsigned long cache_validity;/* bit mask */ +/* +* NFS Attributes not included in struct inode +*/ + +struct timespec64 btime; +/* * read_cache_jiffies is when we started read-caching this inode. * attrtimeo is for how long the cached information is assumed
@@ -260,6 +266,7 @@ struct nfs4_copy_state {#define NFS_INO_INVALID_XATTR BIT(15)/* xattrs are invalid */ #define NFS_INO_INVALID_NLINK BIT(16)/* cached nlinks is invalid */ #define NFS_INO_INVALID_MODE BIT(17)/* cached mode is invalid */ +#define NFS_INO_INVALID_BTIME BIT(18)/* cached btime is invalid */ #define NFS_INO_INVALID_ATTR (NFS_INO_INVALID_CHANGE \ | NFS_INO_INVALID_CTIME \
include/linux/nfs_xdr.h +3 -0
@@ -67,6 +67,7 @@ struct nfs_fattr {struct timespec64 atime;struct timespec64 mtime;struct timespec64 ctime; +struct timespec64 btime;__u64 change_attr;/* NFSv4 change attribute */ __u64 pre_change_attr;/* pre-op NFSv4 change attribute */ __u64 pre_size;/* pre_op_attr.size */
@@ -106,6 +107,7 @@ struct nfs_fattr {#define NFS_ATTR_FATTR_OWNER_NAME BIT_ULL(23)#define NFS_ATTR_FATTR_GROUP_NAME BIT_ULL(24)#define NFS_ATTR_FATTR_V4_SECURITY_LABEL BIT_ULL(25) +#define NFS_ATTR_FATTR_BTIME BIT_ULL(26)#define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \ | NFS_ATTR_FATTR_MODE \
@@ -126,6 +128,7 @@ struct nfs_fattr { | NFS_ATTR_FATTR_SPACE_USED)#define NFS_ATTR_FATTR_V4 (NFS_ATTR_FATTR \ | NFS_ATTR_FATTR_SPACE_USED \ + | NFS_ATTR_FATTR_BTIME \ | NFS_ATTR_FATTR_V4_SECURITY_LABEL)/*
Signature · 1 line
2.33.1
[email protected]
maintainerPATCH v2 3/8 NFS: Return the file btime in the statx results when appropriate
From: Trond Myklebust <[email protected]>
If the server supports the NFSv4.x "create_time" attribute, then return it as part of the statx results.
--- fs/nfs/inode.c | 15 +++++++++++++-- fs/nfs/nfs4trace.h | 3 ++- 2 files changed, 15 insertions(+), 3 deletions(-)
fs/nfs/inode.c +13 -2
@@ -815,6 +815,7 @@ static void nfs_readdirplus_parent_cache_hit(struct dentry *dentry)static u32 nfs_get_valid_attrmask (struct inode *inode) { +u64 fattr_valid =NFS_SERVER (inode)->fattr_valid;unsigned long cache_validity =READ_ONCE (NFS_I (inode)->cache_validity);u32 reply_mask =STATX_INO |STATX_TYPE ;
@@ -834,6 +835,9 @@ static u32 nfs_get_valid_attrmask(struct inode *inode) reply_mask |=STATX_UID |STATX_GID ;if (!(cache_validity &NFS_INO_INVALID_BLOCKS )) reply_mask |=STATX_BLOCKS ; +if (!(cache_validity &NFS_INO_INVALID_BTIME ) && + (fattr_valid &NFS_ATTR_FATTR_BTIME )) + reply_mask |=STATX_BTIME ;return reply_mask; }
@@ -842,6 +846,7 @@ int nfs_getattr(struct user_namespace *mnt_userns, const struct path *path, {struct inode *inode =d_inode (path->dentry);struct nfs_server *server =NFS_SERVER (inode); +u64 fattr_valid = server->fattr_valid;unsigned long cache_validity;int err =0 ;bool force_sync = query_flags &AT_STATX_FORCE_SYNC ;
@@ -851,7 +856,10 @@ int nfs_getattr(struct user_namespace *mnt_userns, const struct path *path, request_mask &=STATX_TYPE |STATX_MODE |STATX_NLINK |STATX_UID |STATX_GID |STATX_ATIME |STATX_MTIME |STATX_CTIME | -STATX_INO |STATX_SIZE |STATX_BLOCKS ; +STATX_INO |STATX_SIZE |STATX_BLOCKS |STATX_BTIME ; + +if (!(fattr_valid &NFS_ATTR_FATTR_BTIME )) + request_mask &= ~STATX_BTIME ;if ((query_flags &AT_STATX_DONT_SYNC ) && !force_sync) {nfs_readdirplus_parent_cache_hit (path->dentry);
@@ -882,7 +890,7 @@ int nfs_getattr(struct user_namespace *mnt_userns, const struct path *path,/* Is the user requesting attributes that might need revalidation? */ if (!(request_mask & (STATX_MODE |STATX_NLINK |STATX_ATIME |STATX_CTIME |STATX_MTIME |STATX_UID |STATX_GID | -STATX_SIZE |STATX_BLOCKS ))) +STATX_SIZE |STATX_BLOCKS |STATX_BTIME ))) goto out_no_revalidate;/* Check whether the cached attributes are stale */
@@ -905,6 +913,8 @@ int nfs_getattr(struct user_namespace *mnt_userns, const struct path *path, do_update |= cache_validity &NFS_INO_INVALID_OTHER ;if (request_mask &STATX_BLOCKS ) do_update |= cache_validity &NFS_INO_INVALID_BLOCKS ; +if (request_mask &STATX_BTIME ) + do_update |= cache_validity &NFS_INO_INVALID_BTIME ;if (do_update) {/* Update the attribute cache */
@@ -925,6 +935,7 @@ int nfs_getattr(struct user_namespace *mnt_userns, const struct path *path, stat->ino =nfs_compat_user_ino64 (NFS_FILEID (inode));if (S_ISDIR (inode->i_mode)) stat->blksize =NFS_SERVER (inode)->dtsize; + stat->btime =NFS_I (inode)->btime; out:trace_nfs_getattr_exit (inode, err);return err;
fs/nfs/nfs4trace.h +2 -1
@@ -30,7 +30,8 @@ { NFS_ATTR_FATTR_CTIME, "CTIME" }, \ { NFS_ATTR_FATTR_CHANGE, "CHANGE" }, \ { NFS_ATTR_FATTR_OWNER_NAME, "OWNER_NAME" }, \ - { NFS_ATTR_FATTR_GROUP_NAME, "GROUP_NAME" }) + { NFS_ATTR_FATTR_GROUP_NAME, "GROUP_NAME" }, \ + { NFS_ATTR_FATTR_BTIME, "BTIME" }) DECLARE_EVENT_CLASS(nfs4_clientid_event, TP_PROTO(
Signature · 1 line
2.33.1
[email protected]
maintainerPATCH v2 4/8 nfs: Add 'archive', 'hidden' and 'system' fields to nfs inode
From: Anne Marie Merritt <[email protected]>
Add tracking of the Windows 'archive', 'hidden' and 'system' attributes, along with corresponding bitfields, request, and decode xdr routines.
--- fs/nfs/inode.c | 42 +++++++++++++++-- fs/nfs/nfs4proc.c | 26 ++++++++++- fs/nfs/nfs4trace.h | 5 +- fs/nfs/nfs4xdr.c | 100 +++++++++++++++++++++++++++++++++++++--- fs/nfs/nfstrace.h | 3 +- include/linux/nfs_fs.h | 5 ++ include/linux/nfs_xdr.h | 12 +++++ 7 files changed, 179 insertions(+), 14 deletions(-)
fs/nfs/inode.c +39 -3
@@ -202,6 +202,7 @@ void nfs_set_cache_invalid(struct inode *inode, unsigned long flags) flags &= ~(NFS_INO_INVALID_MODE |NFS_INO_INVALID_OTHER |NFS_INO_INVALID_BTIME | +NFS_INO_INVALID_WINATTR |NFS_INO_INVALID_XATTR ); flags &= ~(NFS_INO_INVALID_CHANGE |NFS_INO_INVALID_SIZE ); }else if (flags &NFS_INO_REVAL_PAGECACHE )
@@ -523,6 +524,9 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)memset (&inode->i_mtime,0 ,sizeof (inode->i_mtime));memset (&inode->i_ctime,0 ,sizeof (inode->i_ctime));memset (&nfsi->btime,0 ,sizeof (nfsi->btime)); + nfsi->archive =0 ; + nfsi->hidden =0 ; + nfsi->system =0 ;inode_set_iversion_raw (inode,0 ); inode->i_size =0 ;clear_nlink (inode);
@@ -550,6 +554,18 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) nfsi->btime = fattr->btime; else if (fattr_supported & NFS_ATTR_FATTR_BTIME) nfs_set_cache_invalid(inode, NFS_INO_INVALID_BTIME); +if (fattr->valid &NFS_ATTR_FATTR_ARCHIVE ) + nfsi->archive = (fattr->hsa_flags &NFS_HSA_ARCHIVE ) ?1 :0 ; +else if (fattr_supported &NFS_ATTR_FATTR_ARCHIVE ) +nfs_set_cache_invalid (inode,NFS_INO_INVALID_WINATTR ); +if (fattr->valid &NFS_ATTR_FATTR_HIDDEN ) + nfsi->hidden = (fattr->hsa_flags &NFS_HSA_HIDDEN ) ?1 :0 ; +else if (fattr_supported &NFS_ATTR_FATTR_HIDDEN ) +nfs_set_cache_invalid (inode,NFS_INO_INVALID_WINATTR ); +if (fattr->valid &NFS_ATTR_FATTR_SYSTEM ) + nfsi->system = (fattr->hsa_flags &NFS_HSA_SYSTEM ) ?1 :0 ; +else if (fattr_supported &NFS_ATTR_FATTR_SYSTEM ) +nfs_set_cache_invalid (inode,NFS_INO_INVALID_WINATTR );if (fattr->valid &NFS_ATTR_FATTR_CHANGE )inode_set_iversion_raw (inode, fattr->change_attr);else
@@ -1818,7 +1834,8 @@ static int nfs_inode_finish_partial_attr_update(const struct nfs_fattr *fattr,NFS_INO_INVALID_ATIME |NFS_INO_INVALID_CTIME |NFS_INO_INVALID_MTIME |NFS_INO_INVALID_SIZE |NFS_INO_INVALID_BLOCKS |NFS_INO_INVALID_OTHER | -NFS_INO_INVALID_NLINK |NFS_INO_INVALID_BTIME ; +NFS_INO_INVALID_NLINK |NFS_INO_INVALID_BTIME | +NFS_INO_INVALID_WINATTR ;unsigned long cache_validity =NFS_I (inode)->cache_validity;enum nfs4_change_attr_type ctype =NFS_SERVER (inode)->change_attr_type;
@@ -2075,7 +2092,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)NFS_INO_INVALID_MTIME |NFS_INO_INVALID_SIZE |NFS_INO_INVALID_OTHER |NFS_INO_INVALID_BLOCKS |NFS_INO_INVALID_NLINK |NFS_INO_INVALID_MODE | - NFS_INO_INVALID_BTIME); + NFS_INO_INVALID_BTIME | NFS_INO_INVALID_WINATTR);/* Do atomic weak cache consistency updates */ nfs_wcc_update_inode (inode, fattr);
@@ -2106,7 +2123,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | NFS_INO_INVALID_NLINK |NFS_INO_INVALID_MODE |NFS_INO_INVALID_OTHER - |NFS_INO_INVALID_BTIME ; + |NFS_INO_INVALID_BTIME + |NFS_INO_INVALID_WINATTR ;if (S_ISDIR (inode->i_mode))nfs_force_lookup_revalidate (inode); attr_changed = true;
@@ -2143,6 +2161,24 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) nfsi->cache_validity |= save_cache_validity &NFS_INO_INVALID_BTIME ; +if (fattr->valid &NFS_ATTR_FATTR_ARCHIVE ) + nfsi->archive = (fattr->hsa_flags &NFS_HSA_ARCHIVE ) ?1 :0 ; +else if (fattr_supported &NFS_ATTR_FATTR_ARCHIVE ) + nfsi->cache_validity |= + save_cache_validity &NFS_INO_INVALID_WINATTR ; + +if (fattr->valid &NFS_ATTR_FATTR_HIDDEN ) + nfsi->hidden = (fattr->hsa_flags &NFS_HSA_HIDDEN ) ?1 :0 ; +else if (fattr_supported &NFS_ATTR_FATTR_HIDDEN ) + nfsi->cache_validity |= + save_cache_validity &NFS_INO_INVALID_WINATTR ; + +if (fattr->valid &NFS_ATTR_FATTR_SYSTEM ) + nfsi->system = (fattr->hsa_flags &NFS_HSA_SYSTEM ) ?1 :0 ; +else if (fattr_supported &NFS_ATTR_FATTR_SYSTEM ) + nfsi->cache_validity |= + save_cache_validity &NFS_INO_INVALID_WINATTR ; +/* Check if our cached file size is stale */ if (fattr->valid &NFS_ATTR_FATTR_SIZE ) { new_isize =nfs_size_to_loff_t (fattr->size);
fs/nfs/nfs4proc.c +24 -2
@@ -200,13 +200,16 @@ const u32 nfs4_fattr_bitmap[3] = { | FATTR4_WORD0_CHANGE |FATTR4_WORD0_SIZE |FATTR4_WORD0_FSID - |FATTR4_WORD0_FILEID , + |FATTR4_WORD0_ARCHIVE + |FATTR4_WORD0_FILEID + |FATTR4_WORD0_HIDDEN ,FATTR4_WORD1_MODE |FATTR4_WORD1_NUMLINKS |FATTR4_WORD1_OWNER |FATTR4_WORD1_OWNER_GROUP |FATTR4_WORD1_RAWDEV |FATTR4_WORD1_SPACE_USED + |FATTR4_WORD1_SYSTEM |FATTR4_WORD1_TIME_ACCESS |FATTR4_WORD1_TIME_CREATE |FATTR4_WORD1_TIME_METADATA
@@ -222,13 +225,16 @@ static const u32 nfs4_pnfs_open_bitmap[3] = { | FATTR4_WORD0_CHANGE |FATTR4_WORD0_SIZE |FATTR4_WORD0_FSID - |FATTR4_WORD0_FILEID , + |FATTR4_WORD0_ARCHIVE + |FATTR4_WORD0_FILEID + |FATTR4_WORD0_HIDDEN ,FATTR4_WORD1_MODE |FATTR4_WORD1_NUMLINKS |FATTR4_WORD1_OWNER |FATTR4_WORD1_OWNER_GROUP |FATTR4_WORD1_RAWDEV |FATTR4_WORD1_SPACE_USED + |FATTR4_WORD1_SYSTEM |FATTR4_WORD1_TIME_ACCESS |FATTR4_WORD1_TIME_CREATE |FATTR4_WORD1_TIME_METADATA
@@ -313,6 +319,11 @@ static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src,if (!(cache_validity &NFS_INO_INVALID_BTIME )) dst[1 ] &= ~FATTR4_WORD1_TIME_CREATE ; + +if (!(cache_validity &NFS_INO_INVALID_WINATTR )) { + dst[0 ] &= ~(FATTR4_WORD0_ARCHIVE |FATTR4_WORD0_HIDDEN ); + dst[1 ] &= ~FATTR4_WORD1_SYSTEM ; + } } static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dentry,
@@ -1239,6 +1250,7 @@ nfs4_update_changeattr_locked(struct inode *inode,NFS_INO_INVALID_SIZE |NFS_INO_INVALID_OTHER |NFS_INO_INVALID_BLOCKS |NFS_INO_INVALID_NLINK |NFS_INO_INVALID_MODE |NFS_INO_INVALID_BTIME | +NFS_INO_INVALID_WINATTR |NFS_INO_INVALID_XATTR |NFS_INO_REVAL_PAGECACHE ; nfsi->attrtimeo =NFS_MINATTRTIMEO (inode); }
@@ -3878,8 +3890,12 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fif (res.attr_bitmask[2 ] &FATTR4_WORD2_SECURITY_LABEL ) server->caps |=NFS_CAP_SECURITY_LABEL ;#endif +if (!(res.attr_bitmask[0 ] &FATTR4_WORD0_ARCHIVE )) + server->fattr_valid &= ~NFS_ATTR_FATTR_ARCHIVE ;if (!(res.attr_bitmask[0 ] &FATTR4_WORD0_FILEID )) server->fattr_valid &= ~NFS_ATTR_FATTR_FILEID ; +if (!(res.attr_bitmask[0 ] &FATTR4_WORD0_HIDDEN )) + server->fattr_valid &= ~NFS_ATTR_FATTR_HIDDEN ;if (!(res.attr_bitmask[1 ] &FATTR4_WORD1_MODE )) server->fattr_valid &= ~NFS_ATTR_FATTR_MODE ;if (!(res.attr_bitmask[1 ] &FATTR4_WORD1_NUMLINKS ))
@@ -3902,6 +3918,8 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *f server->fattr_valid &= ~NFS_ATTR_FATTR_MTIME ;if (!(res.attr_bitmask[1 ] &FATTR4_WORD1_TIME_CREATE )) server->fattr_valid &= ~NFS_ATTR_FATTR_BTIME ; +if (!(res.attr_bitmask[1 ] &FATTR4_WORD1_SYSTEM )) + server->fattr_valid &= ~NFS_ATTR_FATTR_SYSTEM ;memcpy (server->attr_bitmask_nl, res.attr_bitmask,sizeof (server->attr_bitmask)); server->attr_bitmask_nl[2 ] &= ~FATTR4_WORD2_SECURITY_LABEL ;
@@ -5461,6 +5479,10 @@ static void nfs4_bitmask_set(__u32 bitmask[NFS4_BITMASK_SZ], const __u32 *src, bitmask[1 ] |=FATTR4_WORD1_SPACE_USED ;if (cache_validity &NFS_INO_INVALID_BTIME ) bitmask[1 ] |=FATTR4_WORD1_TIME_CREATE ; +if (cache_validity &NFS_INO_INVALID_WINATTR ) { + bitmask[0 ] |=FATTR4_WORD0_ARCHIVE |FATTR4_WORD0_HIDDEN ; + bitmask[1 ] |=FATTR4_WORD1_SYSTEM ; + }if (cache_validity &NFS_INO_INVALID_SIZE ) bitmask[0 ] |=FATTR4_WORD0_SIZE ;
fs/nfs/nfs4trace.h +4 -1
@@ -31,7 +31,10 @@ { NFS_ATTR_FATTR_CHANGE, "CHANGE" }, \ { NFS_ATTR_FATTR_OWNER_NAME, "OWNER_NAME" }, \ { NFS_ATTR_FATTR_GROUP_NAME, "GROUP_NAME" }, \ - { NFS_ATTR_FATTR_BTIME, "BTIME" }) + { NFS_ATTR_FATTR_BTIME, "BTIME" }, \ + { NFS_ATTR_FATTR_HIDDEN, "HIDDEN" }, \ + { NFS_ATTR_FATTR_SYSTEM, "SYSTEM" }, \ + { NFS_ATTR_FATTR_ARCHIVE, "ARCHIVE" }) DECLARE_EVENT_CLASS(nfs4_clientid_event, TP_PROTO(
fs/nfs/nfs4xdr.c +93 -7
142 lines not on this page · raw message
fs/nfs/nfstrace.h +2 -1
@@ -34,7 +34,8 @@ { NFS_INO_INVALID_XATTR, "INVALID_XATTR" }, \ { NFS_INO_INVALID_NLINK, "INVALID_NLINK" }, \ { NFS_INO_INVALID_MODE, "INVALID_MODE" }, \ - { NFS_INO_INVALID_BTIME, "INVALID_BTIME" }) + { NFS_INO_INVALID_BTIME, "INVALID_BTIME" }, \ + { NFS_INO_INVALID_WINATTR, "INVALID_WINATTR" }) #define nfs_show_nfsi_flags(v) \ __print_flags(v, "|", \
include/linux/nfs_fs.h +5 -0
@@ -144,6 +144,10 @@ struct nfs_inode {struct timespec64 btime; + unsigned char archive : 1; + unsigned char hidden : 1; + unsigned char system : 1; +/* * read_cache_jiffies is when we started read-caching this inode. * attrtimeo is for how long the cached information is assumed
@@ -267,6 +271,7 @@ struct nfs4_copy_state {#define NFS_INO_INVALID_NLINK BIT(16)/* cached nlinks is invalid */ #define NFS_INO_INVALID_MODE BIT(17)/* cached mode is invalid */ #define NFS_INO_INVALID_BTIME BIT(18)/* cached btime is invalid */ +#define NFS_INO_INVALID_WINATTR BIT(19)/* cached windows attr is invalid */ #define NFS_INO_INVALID_ATTR (NFS_INO_INVALID_CHANGE \ | NFS_INO_INVALID_CTIME \
include/linux/nfs_xdr.h +12 -0
@@ -17,6 +17,11 @@#define NFS_BITMASK_SZ 3 +/* HIDDEN, SYSTEM bitfields in hsa_flags in nfs_fattr */ +#define NFS_HSA_HIDDEN BIT(0) +#define NFS_HSA_SYSTEM BIT(1) +#define NFS_HSA_ARCHIVE BIT(2) +struct nfs4_string {unsigned int len;char *data;
@@ -68,6 +73,7 @@ struct nfs_fattr {struct timespec64 mtime;struct timespec64 ctime;struct timespec64 btime; +__u32 hsa_flags;/* hidden, system, archive flags bitfield */ __u64 change_attr;/* NFSv4 change attribute */ __u64 pre_change_attr;/* pre-op NFSv4 change attribute */ __u64 pre_size;/* pre_op_attr.size */
@@ -108,6 +114,9 @@ struct nfs_fattr {#define NFS_ATTR_FATTR_GROUP_NAME BIT_ULL(24)#define NFS_ATTR_FATTR_V4_SECURITY_LABEL BIT_ULL(25)#define NFS_ATTR_FATTR_BTIME BIT_ULL(26) +#define NFS_ATTR_FATTR_HIDDEN BIT_ULL(27) +#define NFS_ATTR_FATTR_SYSTEM BIT_ULL(28) +#define NFS_ATTR_FATTR_ARCHIVE BIT_ULL(29)#define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \ | NFS_ATTR_FATTR_MODE \
@@ -129,6 +138,9 @@ struct nfs_fattr {#define NFS_ATTR_FATTR_V4 (NFS_ATTR_FATTR \ | NFS_ATTR_FATTR_SPACE_USED \ | NFS_ATTR_FATTR_BTIME \ + | NFS_ATTR_FATTR_HIDDEN \ + | NFS_ATTR_FATTR_SYSTEM \ + | NFS_ATTR_FATTR_ARCHIVE \ | NFS_ATTR_FATTR_V4_SECURITY_LABEL)/*
Signature · 1 line
2.33.1
[email protected]
maintainerPATCH v2 5/8 nfs: Add 'time backup' to nfs inode
From: Anne Marie Merritt <[email protected]>
Add tracking of the NFSv4 'time backup' attribute, along with corresponding bitfields, request, and decode xdr routines.
--- fs/nfs/inode.c | 11 +++++++++++ fs/nfs/nfs4proc.c | 8 ++++++-- fs/nfs/nfs4trace.h | 3 ++- fs/nfs/nfs4xdr.c | 24 ++++++++++++++++++++++++ include/linux/nfs_fs.h | 1 + include/linux/nfs_xdr.h | 3 +++ 6 files changed, 47 insertions(+), 3 deletions(-)
fs/nfs/inode.c +11 -0
@@ -524,6 +524,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)memset (&inode->i_mtime,0 ,sizeof (inode->i_mtime));memset (&inode->i_ctime,0 ,sizeof (inode->i_ctime));memset (&nfsi->btime,0 ,sizeof (nfsi->btime)); +memset (&nfsi->timebackup,0 ,sizeof (nfsi->timebackup)); nfsi->archive =0 ; nfsi->hidden =0 ; nfsi->system =0 ;
@@ -554,6 +555,10 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) nfsi->btime = fattr->btime; else if (fattr_supported & NFS_ATTR_FATTR_BTIME) nfs_set_cache_invalid(inode, NFS_INO_INVALID_BTIME); +if (fattr->valid &NFS_ATTR_FATTR_TIME_BACKUP ) + nfsi->timebackup = fattr->time_backup; +else if (fattr_supported &NFS_ATTR_FATTR_TIME_BACKUP ) +nfs_set_cache_invalid (inode,NFS_INO_INVALID_WINATTR );if (fattr->valid &NFS_ATTR_FATTR_ARCHIVE ) nfsi->archive = (fattr->hsa_flags &NFS_HSA_ARCHIVE ) ?1 :0 ;else if (fattr_supported &NFS_ATTR_FATTR_ARCHIVE )
@@ -2161,6 +2166,12 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) nfsi->cache_validity |= save_cache_validity &NFS_INO_INVALID_BTIME ; +if (fattr->valid &NFS_ATTR_FATTR_TIME_BACKUP ) + nfsi->timebackup = fattr->time_backup; +else if (fattr_supported &NFS_ATTR_FATTR_TIME_BACKUP ) + nfsi->cache_validity |= + save_cache_validity &NFS_INO_INVALID_WINATTR ; +if (fattr->valid &NFS_ATTR_FATTR_ARCHIVE ) nfsi->archive = (fattr->hsa_flags &NFS_HSA_ARCHIVE ) ?1 :0 ;else if (fattr_supported &NFS_ATTR_FATTR_ARCHIVE )
fs/nfs/nfs4proc.c +6 -2
@@ -211,6 +211,7 @@ const u32 nfs4_fattr_bitmap[3] = { | FATTR4_WORD1_SPACE_USED |FATTR4_WORD1_SYSTEM |FATTR4_WORD1_TIME_ACCESS + |FATTR4_WORD1_TIME_BACKUP |FATTR4_WORD1_TIME_CREATE |FATTR4_WORD1_TIME_METADATA |FATTR4_WORD1_TIME_MODIFY
@@ -236,6 +237,7 @@ static const u32 nfs4_pnfs_open_bitmap[3] = { | FATTR4_WORD1_SPACE_USED |FATTR4_WORD1_SYSTEM |FATTR4_WORD1_TIME_ACCESS + |FATTR4_WORD1_TIME_BACKUP |FATTR4_WORD1_TIME_CREATE |FATTR4_WORD1_TIME_METADATA | FATTR4_WORD1_TIME_MODIFY,
@@ -322,7 +324,7 @@ static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src,if (!(cache_validity &NFS_INO_INVALID_WINATTR )) { dst[0 ] &= ~(FATTR4_WORD0_ARCHIVE |FATTR4_WORD0_HIDDEN ); - dst[1 ] &= ~FATTR4_WORD1_SYSTEM ; + dst[1 ] &= ~(FATTR4_WORD1_SYSTEM |FATTR4_WORD1_TIME_BACKUP ); } }
@@ -3916,6 +3918,8 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *f server->fattr_valid &= ~NFS_ATTR_FATTR_MTIME ;if (!(res.attr_bitmask[1 ] &FATTR4_WORD1_TIME_MODIFY )) server->fattr_valid &= ~NFS_ATTR_FATTR_MTIME ; +if (!(res.attr_bitmask[1 ] &FATTR4_WORD1_TIME_BACKUP )) + server->fattr_valid &= ~NFS_ATTR_FATTR_TIME_BACKUP ;if (!(res.attr_bitmask[1 ] &FATTR4_WORD1_TIME_CREATE )) server->fattr_valid &= ~NFS_ATTR_FATTR_BTIME ;if (!(res.attr_bitmask[1 ] &FATTR4_WORD1_SYSTEM ))
@@ -5481,7 +5485,7 @@ static void nfs4_bitmask_set(__u32 bitmask[NFS4_BITMASK_SZ], const __u32 *src, bitmask[1 ] |=FATTR4_WORD1_TIME_CREATE ;if (cache_validity &NFS_INO_INVALID_WINATTR ) { bitmask[0 ] |=FATTR4_WORD0_ARCHIVE |FATTR4_WORD0_HIDDEN ; - bitmask[1 ] |=FATTR4_WORD1_SYSTEM ; + bitmask[1 ] |=FATTR4_WORD1_SYSTEM |FATTR4_WORD1_TIME_BACKUP ; }if (cache_validity &NFS_INO_INVALID_SIZE )
fs/nfs/nfs4trace.h +2 -1
@@ -34,7 +34,8 @@ { NFS_ATTR_FATTR_BTIME, "BTIME" }, \ { NFS_ATTR_FATTR_HIDDEN, "HIDDEN" }, \ { NFS_ATTR_FATTR_SYSTEM, "SYSTEM" }, \ - { NFS_ATTR_FATTR_ARCHIVE, "ARCHIVE" }) + { NFS_ATTR_FATTR_ARCHIVE, "ARCHIVE" }, \ + { NFS_ATTR_FATTR_TIME_BACKUP, "TIME_BACKUP" }) DECLARE_EVENT_CLASS(nfs4_clientid_event, TP_PROTO(
fs/nfs/nfs4xdr.c +24 -0
@@ -1619,6 +1619,7 @@ static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_argFATTR4_WORD1_OWNER |FATTR4_WORD1_OWNER_GROUP |FATTR4_WORD1_RAWDEV |FATTR4_WORD1_SPACE_USED |FATTR4_WORD1_SYSTEM |FATTR4_WORD1_TIME_ACCESS | +FATTR4_WORD1_TIME_BACKUP |FATTR4_WORD1_TIME_CREATE |FATTR4_WORD1_TIME_METADATA |FATTR4_WORD1_TIME_MODIFY ;
@@ -4192,6 +4193,24 @@ static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, strreturn status; } +static int decode_attr_time_backup (struct xdr_stream *xdr,uint32_t *bitmap,struct timespec64 *time) +{ +int status =0 ; + + time->tv_sec =0 ; + time->tv_nsec =0 ; +if (unlikely (bitmap[1 ] & (FATTR4_WORD1_TIME_BACKUP -1U ))) +return -EIO ; +if (likely (bitmap[1 ] &FATTR4_WORD1_TIME_BACKUP )) { + status =decode_attr_time (xdr, time); +if (status ==0 ) + status =NFS_ATTR_FATTR_TIME_BACKUP ; + bitmap[1 ] &= ~FATTR4_WORD1_TIME_BACKUP ; + } +dprintk ("%s: time_backup=%ld\n" , __func__, (long )time->tv_sec); +return status; +} +static int decode_attr_time_create (struct xdr_stream *xdr,uint32_t *bitmap,struct timespec64 *time) {int status =0 ;
@@ -4783,6 +4802,11 @@ static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, goto xdr_error; fattr->valid |= status; + status =decode_attr_time_backup (xdr, bitmap, &fattr->time_backup); +if (status <0 ) + goto xdr_error; + fattr->valid |= status; + status =decode_attr_time_create (xdr, bitmap, &fattr->btime);if (status <0 ) goto xdr_error;
include/linux/nfs_fs.h +1 -0
@@ -143,6 +143,7 @@ struct nfs_inode {*/ struct timespec64 btime; +struct timespec64 timebackup; unsigned char archive : 1; unsigned char hidden : 1;
include/linux/nfs_xdr.h +3 -0
@@ -73,6 +73,7 @@ struct nfs_fattr {struct timespec64 mtime;struct timespec64 ctime;struct timespec64 btime; +struct timespec64 time_backup;__u32 hsa_flags;/* hidden, system, archive flags bitfield */ __u64 change_attr;/* NFSv4 change attribute */ __u64 pre_change_attr;/* pre-op NFSv4 change attribute */
@@ -117,6 +118,7 @@ struct nfs_fattr {#define NFS_ATTR_FATTR_HIDDEN BIT_ULL(27)#define NFS_ATTR_FATTR_SYSTEM BIT_ULL(28)#define NFS_ATTR_FATTR_ARCHIVE BIT_ULL(29) +#define NFS_ATTR_FATTR_TIME_BACKUP BIT_ULL(30)#define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \ | NFS_ATTR_FATTR_MODE \
@@ -141,6 +143,7 @@ struct nfs_fattr { | NFS_ATTR_FATTR_HIDDEN \ |NFS_ATTR_FATTR_SYSTEM \ |NFS_ATTR_FATTR_ARCHIVE \ + |NFS_ATTR_FATTR_TIME_BACKUP \ | NFS_ATTR_FATTR_V4_SECURITY_LABEL)/*
Signature · 1 line
2.33.1
[email protected]
maintainerPATCH v2 6/8 NFSv4: Support the offline bit
From: Trond Myklebust <[email protected]>
Add tracking of the NFSv4 'offline' attribute.
--- fs/nfs/inode.c | 11 +++++++++++ fs/nfs/nfs4proc.c | 6 ++++++ fs/nfs/nfs4trace.h | 3 ++- fs/nfs/nfs4xdr.c | 31 ++++++++++++++++++++++++++++++- include/linux/nfs4.h | 1 + include/linux/nfs_fs.h | 1 + include/linux/nfs_xdr.h | 5 ++++- 7 files changed, 55 insertions(+), 3 deletions(-)
fs/nfs/inode.c +11 -0
@@ -528,6 +528,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) nfsi->archive =0 ; nfsi->hidden =0 ; nfsi->system =0 ; + nfsi->offline =0 ;inode_set_iversion_raw (inode,0 ); inode->i_size =0 ;clear_nlink (inode);
@@ -606,6 +607,10 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) }else if (fattr_supported &NFS_ATTR_FATTR_SPACE_USED && fattr->size !=0 )nfs_set_cache_invalid (inode,NFS_INO_INVALID_BLOCKS ); +if (fattr->valid &NFS_ATTR_FATTR_OFFLINE ) + nfsi->offline = (fattr->hsa_flags &NFS_HSA_OFFLINE ) ?1 :0 ; +else if (fattr_supported &NFS_ATTR_FATTR_OFFLINE ) +nfs_set_cache_invalid (inode,NFS_INO_INVALID_WINATTR );nfs_setsecurity (inode, fattr);
@@ -2274,6 +2279,12 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) nfsi->cache_validity |= save_cache_validity &NFS_INO_INVALID_BLOCKS ; +if (fattr->valid &NFS_ATTR_FATTR_OFFLINE ) + nfsi->offline = (fattr->hsa_flags &NFS_HSA_OFFLINE ) ?1 :0 ; +else if (fattr_supported &NFS_ATTR_FATTR_OFFLINE ) + nfsi->cache_validity |= + save_cache_validity &NFS_INO_INVALID_WINATTR ; +/* Update attrtimeo value if we're out of the unstable period */ if (attr_changed) {nfs_inc_stats (inode,NFSIOS_ATTRINVALIDATE );
fs/nfs/nfs4proc.c +6 -0
@@ -219,6 +219,7 @@ const u32 nfs4_fattr_bitmap[3] = { #ifdef CONFIG_NFS_V4_SECURITY_LABEL FATTR4_WORD2_SECURITY_LABEL #endif + | FATTR4_WORD2_OFFLINE }; static const u32 nfs4_pnfs_open_bitmap[3] = {
@@ -245,6 +246,7 @@ static const u32 nfs4_pnfs_open_bitmap[3] = { #ifdef CONFIG_NFS_V4_SECURITY_LABEL | FATTR4_WORD2_SECURITY_LABEL #endif + | FATTR4_WORD2_OFFLINE }; static const u32 nfs4_open_noattr_bitmap[3] = {
@@ -325,6 +327,7 @@ static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src,if (!(cache_validity &NFS_INO_INVALID_WINATTR )) { dst[0 ] &= ~(FATTR4_WORD0_ARCHIVE |FATTR4_WORD0_HIDDEN ); dst[1 ] &= ~(FATTR4_WORD1_SYSTEM |FATTR4_WORD1_TIME_BACKUP ); + dst[2 ] &= ~FATTR4_WORD2_OFFLINE ; } }
@@ -3927,6 +3930,8 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fmemcpy (server->attr_bitmask_nl, res.attr_bitmask,sizeof (server->attr_bitmask)); server->attr_bitmask_nl[2 ] &= ~FATTR4_WORD2_SECURITY_LABEL ; +if (!(res.attr_bitmask[2 ] &FATTR4_WORD2_OFFLINE )) + server->fattr_valid &= ~NFS_ATTR_FATTR_OFFLINE ;memcpy (server->cache_consistency_bitmask, res.attr_bitmask,sizeof (server->cache_consistency_bitmask)); server->cache_consistency_bitmask[0 ] &=FATTR4_WORD0_CHANGE |FATTR4_WORD0_SIZE ;
@@ -5486,6 +5491,7 @@ static void nfs4_bitmask_set(__u32 bitmask[NFS4_BITMASK_SZ], const __u32 *src,if (cache_validity &NFS_INO_INVALID_WINATTR ) { bitmask[0 ] |=FATTR4_WORD0_ARCHIVE |FATTR4_WORD0_HIDDEN ; bitmask[1 ] |=FATTR4_WORD1_SYSTEM |FATTR4_WORD1_TIME_BACKUP ; + bitmask[2 ] |=FATTR4_WORD2_OFFLINE ; }if (cache_validity &NFS_INO_INVALID_SIZE )
fs/nfs/nfs4trace.h +2 -1
@@ -35,7 +35,8 @@ { NFS_ATTR_FATTR_HIDDEN, "HIDDEN" }, \ { NFS_ATTR_FATTR_SYSTEM, "SYSTEM" }, \ { NFS_ATTR_FATTR_ARCHIVE, "ARCHIVE" }, \ - { NFS_ATTR_FATTR_TIME_BACKUP, "TIME_BACKUP" }) + { NFS_ATTR_FATTR_TIME_BACKUP, "TIME_BACKUP" }, \ + { NFS_ATTR_FATTR_OFFLINE, "OFFLINE" }) DECLARE_EVENT_CLASS(nfs4_clientid_event, TP_PROTO(
fs/nfs/nfs4xdr.c +30 -1
@@ -1623,7 +1623,7 @@ static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_argFATTR4_WORD1_TIME_CREATE |FATTR4_WORD1_TIME_METADATA |FATTR4_WORD1_TIME_MODIFY ; - attrs[2 ] |=FATTR4_WORD2_SECURITY_LABEL ; + attrs[2 ] |=FATTR4_WORD2_SECURITY_LABEL |FATTR4_WORD2_OFFLINE ; dircount >>=1 ; }/* Use mounted_on_fileid only if the server supports it */
@@ -4354,6 +4354,29 @@ static int decode_attr_xattrsupport(struct xdr_stream *xdr, uint32_t *bitmap,return 0 ; } +static int decode_attr_offline (struct xdr_stream *xdr,uint32_t *bitmap, +uint32_t *res,uint64_t *flags) +{ +int status =0 ; +__be32 *p; + +if (unlikely (bitmap[2 ] & (FATTR4_WORD2_OFFLINE -1U ))) +return -EIO ; +if (likely (bitmap[2 ] &FATTR4_WORD2_OFFLINE )) { + p =xdr_inline_decode (xdr,4 ); +if (unlikely (!p)) +return -EIO ; +if (be32_to_cpup (p)) + *res |=NFS_HSA_OFFLINE ; +else + *res &= ~NFS_HSA_OFFLINE ; + bitmap[2 ] &= ~FATTR4_WORD2_OFFLINE ; + *flags |=NFS_ATTR_FATTR_OFFLINE ; + } +dprintk ("%s: system file: =%s\n" , __func__, (*res &NFS_HSA_OFFLINE ) ==0 ?"false" :"true" ); +return status; +} +static int verify_attr_len (struct xdr_stream *xdr,unsigned int savep,uint32_t attrlen) {unsigned int attrwords =XDR_QUADLEN (attrlen);
@@ -4842,6 +4865,12 @@ static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, fattr->valid |= status; } + status =decode_attr_offline (xdr, bitmap, &fattr->hsa_flags, + &fattr->valid); +if (status <0 ) + goto xdr_error; + + status =0 ; xdr_error:dprintk ("%s: xdr returned %d\n" , __func__, -status);return status;
include/linux/nfs4.h +1 -0
@@ -460,6 +460,7 @@ enum lock_type4 {#define FATTR4_WORD2_SECURITY_LABEL (1UL << 16)#define FATTR4_WORD2_MODE_UMASK (1UL << 17)#define FATTR4_WORD2_XATTR_SUPPORT (1UL << 18) +#define FATTR4_WORD2_OFFLINE (1UL << 19)/* MDS threshold bitmap bits */ #define THRESHOLD_RD (1UL << 0)
include/linux/nfs_fs.h +1 -0
@@ -148,6 +148,7 @@ struct nfs_inode { unsigned char archive : 1; unsigned char hidden : 1; unsigned char system : 1; + unsigned char offline : 1;/* * read_cache_jiffies is when we started read-caching this inode.
include/linux/nfs_xdr.h +4 -1
@@ -21,6 +21,7 @@#define NFS_HSA_HIDDEN BIT(0)#define NFS_HSA_SYSTEM BIT(1)#define NFS_HSA_ARCHIVE BIT(2) +#define NFS_HSA_OFFLINE BIT(3)struct nfs4_string {unsigned int len;
@@ -119,6 +120,7 @@ struct nfs_fattr {#define NFS_ATTR_FATTR_SYSTEM BIT_ULL(28)#define NFS_ATTR_FATTR_ARCHIVE BIT_ULL(29)#define NFS_ATTR_FATTR_TIME_BACKUP BIT_ULL(30) +#define NFS_ATTR_FATTR_OFFLINE BIT_ULL(31)#define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \ | NFS_ATTR_FATTR_MODE \
@@ -144,7 +146,8 @@ struct nfs_fattr { | NFS_ATTR_FATTR_SYSTEM \ |NFS_ATTR_FATTR_ARCHIVE \ |NFS_ATTR_FATTR_TIME_BACKUP \ - | NFS_ATTR_FATTR_V4_SECURITY_LABEL) + |NFS_ATTR_FATTR_V4_SECURITY_LABEL \ + | NFS_ATTR_FATTR_OFFLINE)/* * Maximal number of supported layout drivers.
Signature · 1 line
2.33.1
[email protected]
maintainerPATCH v2 7/8 NFS: Support statx_get and statx_set ioctls
From: Richard Sharpe <[email protected]>
Add support for returning all of the Windows attributes with a statx ioctl.
Add support for setting all of the Windows attributes using an ioctl.
--- fs/nfs/dir.c | 24 +- fs/nfs/getroot.c | 3 +- fs/nfs/inode.c | 41 +++- fs/nfs/internal.h | 8 + fs/nfs/nfs3proc.c | 1 + fs/nfs/nfs4_fs.h | 31 +++ fs/nfs/nfs4file.c | 511 +++++++++++++++++++++++++++++++++++++++ fs/nfs/nfs4proc.c | 124 ++++++++++ fs/nfs/nfs4xdr.c | 63 ++++- fs/nfs/nfstrace.c | 5 + fs/nfs/nfstrace.h | 5 + fs/nfs/proc.c | 1 + include/linux/nfs_fs.h | 1 + include/linux/nfs_xdr.h | 3 + include/uapi/linux/nfs.h | 90 +++++++ 15 files changed, 887 insertions(+), 24 deletions(-)
fs/nfs/dir.c +11 -13
@@ -48,11 +48,6 @@/* #define NFS_DEBUG_VERBOSE 1 */ -static int nfs_opendir (struct inode *,struct file *); -static int nfs_closedir (struct inode *,struct file *); -static int nfs_readdir (struct file *,struct dir_context *); -static int nfs_fsync_dir (struct file *,loff_t ,loff_t ,int ); -static loff_t nfs_llseek_dir (struct file *,loff_t ,int );static void nfs_readdir_clear_array (struct page *);const struct file_operations nfs_dir_operations = {
@@ -63,6 +58,7 @@ const struct file_operations nfs_dir_operations = { .release = nfs_closedir, .fsync = nfs_fsync_dir, }; +EXPORT_SYMBOL_GPL (nfs_dir_operations);const struct address_space_operations nfs_dir_aops = { .freepage = nfs_readdir_clear_array,
@@ -104,8 +100,7 @@ static void put_nfs_open_dir_context(struct inode *dir, struct nfs_open_dir_cont/* * Open file */ -static int -nfs_opendir (struct inode *inode,struct file *filp) +int nfs_opendir (struct inode *inode,struct file *filp) {int res =0 ;struct nfs_open_dir_context *ctx;
@@ -123,13 +118,14 @@ nfs_opendir(struct inode *inode, struct file *filp) out:return res; } +EXPORT_SYMBOL_GPL (nfs_opendir); -static int -nfs_closedir (struct inode *inode,struct file *filp) +int nfs_closedir (struct inode *inode,struct file *filp) {put_nfs_open_dir_context (file_inode (filp), filp->private_data);return 0 ; } +EXPORT_SYMBOL_GPL (nfs_closedir);struct nfs_cache_array_entry {u64 cookie;
@@ -1064,7 +1060,7 @@ static int uncached_readdir(struct nfs_readdir_descriptor *desc)last cookie cache takes care of the common case of reading the whole directory. */ -static int nfs_readdir (struct file *file,struct dir_context *ctx) +int nfs_readdir (struct file *file,struct dir_context *ctx) {struct dentry *dentry =file_dentry (file);struct inode *inode =d_inode (dentry);
@@ -1157,8 +1153,9 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx)dfprintk (FILE ,"NFS: readdir(%pD2) returns %d\n" , file, res);return res; } +EXPORT_SYMBOL_GPL (nfs_readdir); -static loff_t nfs_llseek_dir (struct file *filp,loff_t offset,int whence) +loff_t nfs_llseek_dir (struct file *filp,loff_t offset,int whence) {struct nfs_open_dir_context *dir_ctx = filp->private_data;
@@ -1196,19 +1193,20 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence)spin_unlock (&filp->f_lock);return offset; } +EXPORT_SYMBOL_GPL (nfs_llseek_dir);/* * All directory operations under NFS are synchronous, so fsync() * is a dummy operation. */ -static int nfs_fsync_dir (struct file *filp,loff_t start,loff_t end, -int datasync) +int nfs_fsync_dir (struct file *filp,loff_t start,loff_t end,int datasync) {dfprintk (FILE ,"NFS: fsync dir(%pD2) datasync %d\n" , filp, datasync);nfs_inc_stats (file_inode (filp),NFSIOS_VFSFSYNC );return 0 ; } +EXPORT_SYMBOL_GPL (nfs_fsync_dir);/** * nfs_force_lookup_revalidate - Mark the directory as having changed
fs/nfs/getroot.c +2 -1
@@ -127,7 +127,8 @@ int nfs_get_root(struct super_block *s, struct fs_context *fc)if (server->caps &NFS_CAP_SECURITY_LABEL ) kflags |=SECURITY_LSM_NATIVE_LABELS ;if (ctx->clone_data.sb) { -if (d_inode (fc->root)->i_fop != &nfs_dir_operations) { +if (d_inode (fc->root)->i_fop != + server->nfs_client->rpc_ops->dir_ops) { error = -ESTALE ; goto error_splat_root; }
fs/nfs/inode.c +40 -1
59 lines not on this page · raw message
fs/nfs/internal.h +8 -0
@@ -366,6 +366,12 @@ extern struct nfs_client *nfs_init_client(struct nfs_client *clp, const struct nfs_client_initdata *); /* dir.c */ +int nfs_opendir(struct inode *, struct file *); +int nfs_closedir (struct inode *,struct file *); +int nfs_readdir (struct file *file,struct dir_context *ctx); +int nfs_fsync_dir (struct file *,loff_t ,loff_t ,int ); +loff_t nfs_llseek_dir (struct file *filp,loff_t offset,int whence); +extern void nfs_advise_use_readdirplus (struct inode *dir);extern void nfs_force_use_readdirplus (struct inode *dir); extern unsigned long nfs_access_cache_count(struct shrinker *shrink,
@@ -411,6 +417,8 @@ extern void nfs_set_cache_invalid(struct inode *inode, unsigned long flags);extern bool nfs_check_cache_invalid (struct inode *,unsigned long );extern int nfs_wait_bit_killable (struct wait_bit_key *key,int mode);extern int nfs_wait_atomic_killable (atomic_t *p,unsigned int mode); +extern int nfs_getattr_revalidate (const struct path *path,unsigned long flags, +unsigned int query_flags);/* super.c */ extern const struct super_operations nfs_sops;
fs/nfs/nfs3proc.c +1 -0
@@ -1019,6 +1019,7 @@ const struct nfs_rpc_ops nfs_v3_clientops = { .dir_inode_ops = &nfs3_dir_inode_operations, .file_inode_ops = &nfs3_file_inode_operations, .file_ops = &nfs_file_operations, + .dir_ops = &nfs_dir_operations, .nlmclnt_ops = &nlmclnt_fl_close_lock_ops, .getroot = nfs3_proc_get_root, .submount = nfs_submount,
fs/nfs/nfs4_fs.h +31 -0
@@ -248,6 +248,34 @@ struct nfs4_opendata {int rpc_status; }; +struct nfs4_statx { +int real_fd;/* real FD to use, +-1 means use current file */ +__u32 fa_options;/* statx flags */ +__u64 fa_request[2 ];/* Attributes requested */ +__u64 fa_valid[2 ];/* Attributes set */ + +struct timespec64 fa_time_backup;/* Backup time */ +struct timespec64 fa_btime;/* Birth time */ +/* Flag attributes */ +__u64 fa_flags; +struct timespec64 fa_atime;/* Access time */ +struct timespec64 fa_mtime;/* Modify time */ +struct timespec64 fa_ctime;/* Change time */ +kuid_t fa_owner_uid;/* Owner User ID */ +kgid_t fa_group_gid;/* Primary Group ID */ +/* Normal stat fields after this */ +__u32 fa_mode;/* Mode */ +unsigned int fa_nlink; +__u32 fa_blksize; +__u32 fa_spare;/* Alignment */ +__u64 fa_ino; +dev_t fa_dev; +dev_t fa_rdev; +loff_t fa_size; +__u64 fa_blocks; +}; +struct nfs4_add_xprt_data {struct nfs_client *clp;const struct cred *cred;
@@ -315,6 +343,9 @@ extern int nfs4_set_rw_stateid(nfs4_stateid *stateid,const struct nfs_open_context *ctx, const struct nfs_lock_context *l_ctx, fmode_t fmode); +int nfs4_set_nfs4_statx (struct inode *inode, +struct nfs4_statx *statx, +struct nfs_fattr *fattr);extern int nfs4_proc_getattr (struct nfs_server *server,struct nfs_fh *fhandle,struct nfs_fattr *fattr,struct inode *inode); extern int update_open_stateid(struct nfs4_state *state,
fs/nfs/nfs4file.c +511 -0
533 lines not on this page · raw message
fs/nfs/nfs4proc.c +124 -0
136 lines not on this page · raw message
fs/nfs/nfs4xdr.c +54 -9
130 lines not on this page · raw message
fs/nfs/nfstrace.c +5 -0
@@ -9,6 +9,11 @@#define CREATE_TRACE_POINTS #include "nfstrace.h" +EXPORT_TRACEPOINT_SYMBOL_GPL (nfs_ioctl_file_statx_get_enter); +EXPORT_TRACEPOINT_SYMBOL_GPL (nfs_ioctl_file_statx_get_exit); +EXPORT_TRACEPOINT_SYMBOL_GPL (nfs_ioctl_file_statx_set_enter); +EXPORT_TRACEPOINT_SYMBOL_GPL (nfs_ioctl_file_statx_set_exit); +EXPORT_TRACEPOINT_SYMBOL_GPL (nfs_fsync_enter);EXPORT_TRACEPOINT_SYMBOL_GPL (nfs_fsync_exit);EXPORT_TRACEPOINT_SYMBOL_GPL (nfs_xdr_status);
fs/nfs/nfstrace.h +5 -0
@@ -166,6 +166,11 @@ DEFINE_NFS_INODE_EVENT_DONE(nfs_fsync_exit);DEFINE_NFS_INODE_EVENT (nfs_access_enter);DEFINE_NFS_INODE_EVENT_DONE (nfs_set_cache_invalid); +DEFINE_NFS_INODE_EVENT (nfs_ioctl_file_statx_get_enter); +DEFINE_NFS_INODE_EVENT_DONE (nfs_ioctl_file_statx_get_exit); +DEFINE_NFS_INODE_EVENT (nfs_ioctl_file_statx_set_enter); +DEFINE_NFS_INODE_EVENT_DONE (nfs_ioctl_file_statx_set_exit); + TRACE_EVENT(nfs_access_exit, TP_PROTO( const struct inode *inode,
fs/nfs/proc.c +1 -0
@@ -717,6 +717,7 @@ const struct nfs_rpc_ops nfs_v2_clientops = { .dir_inode_ops = &nfs_dir_inode_operations, .file_inode_ops = &nfs_file_inode_operations, .file_ops = &nfs_file_operations, + .dir_ops = &nfs_dir_operations, .getroot = nfs_proc_get_root, .submount = nfs_submount, .try_get_tree = nfs_try_get_tree,
include/linux/nfs_fs.h +1 -0
@@ -503,6 +503,7 @@ extern __be32 root_nfs_parse_addr(char *name); /*__init*/extern const struct file_operations nfs_file_operations;#if IS_ENABLED (CONFIG_NFS_V4 )extern const struct file_operations nfs4_file_operations; +extern const struct file_operations nfs4_dir_operations;#endif /* CONFIG_NFS_V4 */ extern const struct address_space_operations nfs_file_aops;extern const struct address_space_operations nfs_dir_aops;
include/linux/nfs_xdr.h +3 -0
@@ -812,6 +812,7 @@ struct nfs_createargs {struct iattr * sattr; }; +struct nfs4_statx ;struct nfs_setattrargs {struct nfs4_sequence_args seq_args;struct nfs_fh * fh;
@@ -820,6 +821,7 @@ struct nfs_setattrargs {const struct nfs_server * server;/* Needed for name mapping */ const u32 * bitmask;const struct nfs4_label *label; +const struct nfs4_statx *statx; };struct nfs_setaclargs {
@@ -1744,6 +1746,7 @@ struct nfs_rpc_ops {const struct inode_operations *dir_inode_ops;const struct inode_operations *file_inode_ops;const struct file_operations *file_ops; +const struct file_operations *dir_ops;const struct nlmclnt_operations *nlmclnt_ops; int (*getroot) (struct nfs_server *, struct nfs_fh *,
include/uapi/linux/nfs.h +90 -0
102 lines not on this page · raw message
Signature · 1 line
2.33.1
[email protected]
maintainerPATCH v2 8/8 NFSv4: Add an ioctl to allow retrieval of the NFS raw ACCESS mask
From: Trond Myklebust <[email protected]>
--- fs/nfs/dir.c | 47 ++++++++++++++++++++++++---------------- fs/nfs/internal.h | 2 ++ fs/nfs/nfs4file.c | 39 +++++++++++++++++++++++++++++++++ include/uapi/linux/nfs.h | 11 ++++++++++ 4 files changed, 80 insertions(+), 19 deletions(-)
fs/nfs/dir.c +28 -19
@@ -2907,36 +2907,30 @@ void nfs_access_set_mask(struct nfs_access_entry *entry, u32 access_result) }EXPORT_SYMBOL_GPL (nfs_access_set_mask); -static int nfs_do_access (struct inode *inode,const struct cred *cred,int mask) +int nfs_get_access (struct inode *inode,const struct cred *cred, +struct nfs_access_entry *cache,bool may_block) { -struct nfs_access_entry cache; -bool may_block = (mask &MAY_NOT_BLOCK ) ==0 ; -int cache_mask =-1 ;int status; -trace_nfs_access_enter (inode); - - status =nfs_access_get_cached (inode, cred, &cache.mask, may_block); + status =nfs_access_get_cached (inode, cred, &cache->mask, may_block);if (status ==0 ) - goto out_cached; +return 0 ; - status = -ECHILD ;if (!may_block) - goto out; - +return -ECHILD ;/* * Determine which access bits we want to ask for... */ - cache.mask =NFS_ACCESS_READ |NFS_ACCESS_MODIFY |NFS_ACCESS_EXTEND ; + cache->mask =NFS_ACCESS_READ |NFS_ACCESS_MODIFY |NFS_ACCESS_EXTEND ;if (nfs_server_capable (inode,NFS_CAP_XATTR )) { - cache.mask |=NFS_ACCESS_XAREAD |NFS_ACCESS_XAWRITE | + cache->mask |=NFS_ACCESS_XAREAD |NFS_ACCESS_XAWRITE |NFS_ACCESS_XALIST ; }if (S_ISDIR (inode->i_mode)) - cache.mask |=NFS_ACCESS_DELETE |NFS_ACCESS_LOOKUP ; + cache->mask |=NFS_ACCESS_DELETE |NFS_ACCESS_LOOKUP ;else - cache.mask |=NFS_ACCESS_EXECUTE ; - status =NFS_PROTO (inode)->access (inode, &cache, cred); + cache->mask |=NFS_ACCESS_EXECUTE ; + status =NFS_PROTO (inode)->access (inode, cache, cred);if (status !=0 ) {if (status == -ESTALE ) {if (!S_ISDIR (inode->i_mode))
@@ -2944,10 +2938,25 @@ static int nfs_do_access(struct inode *inode, const struct cred *cred, int mask)else nfs_zap_caches (inode); } - goto out; +return status; } -nfs_access_add_cache (inode, &cache, cred); -out_cached: +nfs_access_add_cache (inode, cache, cred); +return 0 ; +} +EXPORT_SYMBOL_GPL (nfs_get_access); + +static int nfs_do_access (struct inode *inode,const struct cred *cred,int mask) +{ +struct nfs_access_entry cache; +bool may_block = (mask &MAY_NOT_BLOCK ) ==0 ; +int cache_mask =-1 ; +int status; + +trace_nfs_access_enter (inode); + + status =nfs_get_access (inode, cred, &cache, may_block); +if (status <0 ) + goto out; cache_mask =nfs_access_calc_mask (cache.mask, inode->i_mode);if ((mask & ~cache_mask & (MAY_READ |MAY_WRITE |MAY_EXEC )) !=0 ) status = -EACCES ;
fs/nfs/internal.h +2 -0
@@ -392,6 +392,8 @@ int nfs_mknod(struct user_namespace *, struct inode *, struct dentry *, umode_t, dev_t);int nfs_rename (struct user_namespace *,struct inode *,struct dentry *,struct inode *,struct dentry *,unsigned int ); +int nfs_get_access (struct inode *inode,const struct cred *cred, +struct nfs_access_entry *cache,bool may_block);/* file.c */ int nfs_file_fsync (struct file *file,loff_t start,loff_t end,int datasync);
fs/nfs/nfs4file.c +39 -0
@@ -611,6 +611,42 @@ static long nfs4_ioctl_file_statx_set(struct file *dst_file,return ret; } +static long +nfs4_ioctl_file_access_get (struct file *file, +struct nfs_ioctl_nfs4_access __user *uarg) +{ +struct inode *inode =file_inode (file); +struct nfs_access_entry cache; +__u64 ac_flags; +const struct cred *old_cred; +struct cred *override_cred; +long ret; + +if (!NFS_PROTO (inode)->access) +return -ENOTSUPP ; + +if (get_user (ac_flags, &uarg->ac_flags)) +return -EFAULT ; + + override_cred =prepare_creds (); +if (!override_cred) +return -ENOMEM ; + +if (!(ac_flags &NFS_AC_FLAG_EACCESS )) { + override_cred->fsuid = override_cred->uid; + override_cred->fsgid = override_cred->gid; + } + old_cred =override_creds (override_cred); + + ret =nfs_get_access (inode, override_cred, &cache, true); +if (!ret &&unlikely (put_user (cache.mask, &uarg->ac_mask) !=0 )) + ret = -EFAULT ; + +revert_creds (old_cred); +put_cred (override_cred); +return ret; +} +static long nfs4_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {void __user *argp = (void __user *)arg;
@@ -623,6 +659,9 @@ static long nfs4_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case NFS_IOC_FILE_STATX_SET : ret =nfs4_ioctl_file_statx_set (file, argp);break ; +case NFS_IOC_FILE_ACCESS_GET : + ret =nfs4_ioctl_file_access_get (file, argp); +break ;default : ret = -ENOIOCTLCMD ; }
include/uapi/linux/nfs.h +11 -0
@@ -41,6 +41,8 @@#define NFS_IOC_FILE_STATX_GET _IOR('N', 2, struct nfs_ioctl_nfs4_statx)#define NFS_IOC_FILE_STATX_SET _IOW('N', 3, struct nfs_ioctl_nfs4_statx) +#define NFS_IOC_FILE_ACCESS_GET _IOR('N', 4, struct nfs_ioctl_nfs4_access) +/* Options for struct nfs_ioctl_nfs4_statx */ #define NFS_FA_OPTIONS_SYNC_AS_STAT 0x0000#define NFS_FA_OPTIONS_FORCE_SYNC 0x2000/* See statx */
@@ -125,6 +127,15 @@ struct nfs_ioctl_nfs4_statx {__u64 fa_padding[4 ]; }; +struct nfs_ioctl_nfs4_access { +/* input */ +__u64 ac_flags;/* operation flags */ +/* output */ +__u64 ac_mask;/* NFS raw ACCESS reply mask */ +}; + +#define NFS_AC_FLAG_EACCESS (1UL << 0) +/* * NFS stats. The good thing with these values is that NFSv3 errors are * a superset of NFSv2 errors (with the exception of NFSERR_WFLUSH which
Signature · 1 line
2.33.1
Re: [PATCH v2 6/8] NFSv4: Support the offline bit
In reply to [email protected]Hi Trond,
Quoted 59 lines · On Tue, Dec 28, 2021 at 3:03 AM <[email protected]> wrote:
From: Trond Myklebust <[email protected]>
Add tracking of the NFSv4 'offline' attribute.
Signed-off-by Trond Myklebust <[email protected]>Signed-off-by Lance Shelton <[email protected]>Signed-off-by Trond Myklebust <[email protected]>--- fs/nfs/inode.c | 11 +++++++++++ fs/nfs/nfs4proc.c | 6 ++++++ fs/nfs/nfs4trace.h | 3 ++- fs/nfs/nfs4xdr.c | 31 ++++++++++++++++++++++++++++++- include/linux/nfs4.h | 1 + include/linux/nfs_fs.h | 1 + include/linux/nfs_xdr.h | 5 ++++- 7 files changed, 55 insertions(+), 3 deletions(-)fs/nfs/inode.c +11
-0@@ -528,6 +528,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) nfsi->archive =0 ; nfsi->hidden =0 ; nfsi->system =0 ; + nfsi->offline =0 ;inode_set_iversion_raw (inode,0 ); inode->i_size =0 ;clear_nlink (inode);@@ -606,6 +607,10 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) }else if (fattr_supported &NFS_ATTR_FATTR_SPACE_USED && fattr->size !=0 )nfs_set_cache_invalid (inode,NFS_INO_INVALID_BLOCKS ); +if (fattr->valid &NFS_ATTR_FATTR_OFFLINE ) + nfsi->offline = (fattr->hsa_flags &NFS_HSA_OFFLINE ) ?1 :0 ; +else if (fattr_supported &NFS_ATTR_FATTR_OFFLINE ) +nfs_set_cache_invalid (inode,NFS_INO_INVALID_WINATTR );nfs_setsecurity (inode, fattr);@@ -2274,6 +2279,12 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) nfsi->cache_validity |= save_cache_validity &NFS_INO_INVALID_BLOCKS ; +if (fattr->valid &NFS_ATTR_FATTR_OFFLINE ) + nfsi->offline = (fattr->hsa_flags &NFS_HSA_OFFLINE ) ?1 :0 ; +else if (fattr_supported &NFS_ATTR_FATTR_OFFLINE ) + nfsi->cache_validity |= + save_cache_validity &NFS_INO_INVALID_WINATTR ; +/* Update attrtimeo value if we're out of the unstable period */ if (attr_changed) {nfs_inc_stats (inode,NFSIOS_ATTRINVALIDATE );fs/nfs/nfs4proc.c +0
-0
fs/nfs/nfs4proc.c const u32 nfs4_fattr_bitmap[3] = { · line 223
Quoted 5 lines
fs/nfs/nfs4proc.c +1
-0@@ -219,6 +219,7 @@ const u32 nfs4_fattr_bitmap[3] = {#ifdef CONFIG_NFS_V4_SECURITY_LABEL FATTR4_WORD2_SECURITY_LABEL #endif + |FATTR4_WORD2_OFFLINE };
This won't compile if CONFIG_NFS_V4_SECURITY_LABEL=n:
fs/nfs/nfs4proc.c:218:9: error: expected expression before ‘|’ token
218 | | FATTR4_WORD2_OFFLINE
| ^make[2]: *** [scripts/Makefile.build:287: fs/nfs/nfs4proc.o] Error 1 make[1]: *** [scripts/Makefile.build:549: fs/nfs] Error 2
make: *** [Makefile:1846: fs] Error 2
make: *** Waiting for unfinished jobs....
Anna
Quoted 162 lines
fs/nfs/nfs4proc.c +5
-0static const u32 nfs4_pnfs_open_bitmap[3 ] = {@@ -245,6 +246,7 @@ static const u32 nfs4_pnfs_open_bitmap[3] = { #ifdef CONFIG_NFS_V4_SECURITY_LABEL | FATTR4_WORD2_SECURITY_LABEL #endif + | FATTR4_WORD2_OFFLINE }; static const u32 nfs4_open_noattr_bitmap[3] = {@@ -325,6 +327,7 @@ static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src,if (!(cache_validity &NFS_INO_INVALID_WINATTR )) { dst[0 ] &= ~(FATTR4_WORD0_ARCHIVE |FATTR4_WORD0_HIDDEN ); dst[1 ] &= ~(FATTR4_WORD1_SYSTEM |FATTR4_WORD1_TIME_BACKUP ); + dst[2 ] &= ~FATTR4_WORD2_OFFLINE ; } }@@ -3927,6 +3930,8 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fmemcpy (server->attr_bitmask_nl, res.attr_bitmask,sizeof (server->attr_bitmask)); server->attr_bitmask_nl[2 ] &= ~FATTR4_WORD2_SECURITY_LABEL ; +if (!(res.attr_bitmask[2 ] &FATTR4_WORD2_OFFLINE )) + server->fattr_valid &= ~NFS_ATTR_FATTR_OFFLINE ;memcpy (server->cache_consistency_bitmask, res.attr_bitmask,sizeof (server->cache_consistency_bitmask)); server->cache_consistency_bitmask[0 ] &=FATTR4_WORD0_CHANGE |FATTR4_WORD0_SIZE ;@@ -5486,6 +5491,7 @@ static void nfs4_bitmask_set(__u32 bitmask[NFS4_BITMASK_SZ], const __u32 *src,if (cache_validity &NFS_INO_INVALID_WINATTR ) { bitmask[0 ] |=FATTR4_WORD0_ARCHIVE |FATTR4_WORD0_HIDDEN ; bitmask[1 ] |=FATTR4_WORD1_SYSTEM |FATTR4_WORD1_TIME_BACKUP ; + bitmask[2 ] |=FATTR4_WORD2_OFFLINE ; }if (cache_validity &NFS_INO_INVALID_SIZE )fs/nfs/nfs4trace.h +2
-1@@ -35,7 +35,8 @@ { NFS_ATTR_FATTR_HIDDEN, "HIDDEN" }, \ { NFS_ATTR_FATTR_SYSTEM, "SYSTEM" }, \ { NFS_ATTR_FATTR_ARCHIVE, "ARCHIVE" }, \ - { NFS_ATTR_FATTR_TIME_BACKUP, "TIME_BACKUP" }) + { NFS_ATTR_FATTR_TIME_BACKUP, "TIME_BACKUP" }, \ + { NFS_ATTR_FATTR_OFFLINE, "OFFLINE" }) DECLARE_EVENT_CLASS(nfs4_clientid_event, TP_PROTO(fs/nfs/nfs4xdr.c +30
-1@@ -1623,7 +1623,7 @@ static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_argFATTR4_WORD1_TIME_CREATE |FATTR4_WORD1_TIME_METADATA |FATTR4_WORD1_TIME_MODIFY ; - attrs[2 ] |=FATTR4_WORD2_SECURITY_LABEL ; + attrs[2 ] |=FATTR4_WORD2_SECURITY_LABEL |FATTR4_WORD2_OFFLINE ; dircount >>=1 ; }/* Use mounted_on_fileid only if the server supports it */ @@ -4354,6 +4354,29 @@ static int decode_attr_xattrsupport(struct xdr_stream *xdr, uint32_t *bitmap,return 0 ; } +static int decode_attr_offline (struct xdr_stream *xdr,uint32_t *bitmap, +uint32_t *res,uint64_t *flags) +{ +int status =0 ; +__be32 *p; + +if (unlikely (bitmap[2 ] & (FATTR4_WORD2_OFFLINE -1U ))) +return -EIO ; +if (likely (bitmap[2 ] &FATTR4_WORD2_OFFLINE )) { + p =xdr_inline_decode (xdr,4 ); +if (unlikely (!p)) +return -EIO ; +if (be32_to_cpup (p)) + *res |=NFS_HSA_OFFLINE ; +else + *res &= ~NFS_HSA_OFFLINE ; + bitmap[2 ] &= ~FATTR4_WORD2_OFFLINE ; + *flags |=NFS_ATTR_FATTR_OFFLINE ; + } +dprintk ("%s: system file: =%s\n" , __func__, (*res &NFS_HSA_OFFLINE ) ==0 ?"false" :"true" ); +return status; +} +static int verify_attr_len (struct xdr_stream *xdr,unsigned int savep,uint32_t attrlen) {unsigned int attrwords =XDR_QUADLEN (attrlen);@@ -4842,6 +4865,12 @@ static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, fattr->valid |= status; } + status =decode_attr_offline (xdr, bitmap, &fattr->hsa_flags, + &fattr->valid); +if (status <0 ) + goto xdr_error; + + status =0 ; xdr_error:dprintk ("%s: xdr returned %d\n" , __func__, -status);return status;include/linux/nfs4.h +1
-0@@ -460,6 +460,7 @@ enum lock_type4 {#define FATTR4_WORD2_SECURITY_LABEL (1UL << 16)#define FATTR4_WORD2_MODE_UMASK (1UL << 17)#define FATTR4_WORD2_XATTR_SUPPORT (1UL << 18) +#define FATTR4_WORD2_OFFLINE (1UL << 19)/* MDS threshold bitmap bits */ #define THRESHOLD_RD (1UL << 0)include/linux/nfs_fs.h +1
-0@@ -148,6 +148,7 @@ struct nfs_inode { unsigned char archive : 1; unsigned char hidden : 1; unsigned char system : 1; + unsigned char offline : 1;/* * read_cache_jiffies is when we started read-caching this inode. include/linux/nfs_xdr.h +4
-2@@ -21,6 +21,7 @@#define NFS_HSA_HIDDEN BIT(0)#define NFS_HSA_SYSTEM BIT(1)#define NFS_HSA_ARCHIVE BIT(2) +#define NFS_HSA_OFFLINE BIT(3)struct nfs4_string {unsigned int len;@@ -119,6 +120,7 @@ struct nfs_fattr {#define NFS_ATTR_FATTR_SYSTEM BIT_ULL(28)#define NFS_ATTR_FATTR_ARCHIVE BIT_ULL(29)#define NFS_ATTR_FATTR_TIME_BACKUP BIT_ULL(30) +#define NFS_ATTR_FATTR_OFFLINE BIT_ULL(31)#define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \ | NFS_ATTR_FATTR_MODE \@@ -144,7 +146,8 @@ struct nfs_fattr { | NFS_ATTR_FATTR_SYSTEM \ |NFS_ATTR_FATTR_ARCHIVE \ |NFS_ATTR_FATTR_TIME_BACKUP \ - | NFS_ATTR_FATTR_V4_SECURITY_LABEL) + |NFS_ATTR_FATTR_V4_SECURITY_LABEL \ + | NFS_ATTR_FATTR_OFFLINE)/* * Maximal number of supported layout drivers. -- 2.33.1
Re: [PATCH v2 6/8] NFSv4: Support the offline bit
Quoted 81 lines · Anna Schumaker
Hi Trond,
Quoted 71 lines · On Tue, Dec 28, 2021 at 3:03 AM <[email protected]> wrote:
From: Trond Myklebust <[email protected]>
Add tracking of the NFSv4 'offline' attribute.
Signed-off-by Trond Myklebust <[email protected]>Signed-off-by Lance Shelton <[email protected]>Signed-off-by Trond Myklebust <[email protected]>---
fs/nfs/inode.c | 11 +++++++++++ fs/nfs/nfs4proc.c | 6 ++++++ fs/nfs/nfs4trace.h | 3 ++-
fs/nfs/nfs4xdr.c | 31 ++++++++++++++++++++++++++++++- include/linux/nfs4.h | 1 + include/linux/nfs_fs.h | 1 +include/linux/nfs_xdr.h| 5 ++++-7 files changed, 55 insertions(+), 3 deletions(-)fs/nfs/inode.c +1
-0@@ -528,6 +528,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) nfsi->archive = 0; nfsi->hidden = 0; nfsi->system = 0; + nfsi->offline = 0; inode_set_iversion_raw(inode, 0); inode->i_size = 0;
clear_nlink(inode);fs/nfs/inode.c +0
-0@@ -606,6 +607,10 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) } else if (fattr_supported &
NFS_ATTR_FATTR_SPACE_USED&&
fattr->size!= 0)nfs_set_cache_invalid(inode, NFS_INO_INVALID_BLOCKS);
+ if (fattr->valid&NFS_ATTR_FATTR_OFFLINE) +nfsi->offline= (fattr->hsa_flags&NFS_HSA_OFFLINE) ? 1 : 0;
+ else if (fattr_supported&NFS_ATTR_FATTR_OFFLINE) +nfs_set_cache_invalid(inode, NFS_INO_INVALID_WINATTR);
nfs_setsecurity(inode, fattr);fs/nfs/inode.c +0
-0@@ -2274,6 +2279,12 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
nfsi->cache_validity|=
save_cache_validity&NFS_INO_INVALID_BLOCKS;+ if (
fattr->valid&NFS_ATTR_FATTR_OFFLINE)
+nfsi->offline= (fattr->hsa_flags&NFS_HSA_OFFLINE) ? 1 : 0;
+ else if (fattr_supported&NFS_ATTR_FATTR_OFFLINE) +nfsi->cache_validity|=
+save_cache_validity&NFS_INO_INVALID_WINATTR;
+
/* Update attrtimeo value if we're out of the unstable period */
if (attr_changed) {
nfs_inc_stats(inode, NFSIOS_ATTRINVALIDATE);fs/nfs/nfs4proc.c +0
-0@@ -219,6 +219,7 @@ const u32 nfs4_fattr_bitmap[3] = { #ifdef CONFIG_NFS_V4_SECURITY_LABELQuoted 4 lines
FATTR4_WORD2_SECURITY_LABEL
#endif
+ |FATTR4_WORD2_OFFLINE
};This won't compile if
CONFIG_NFS_V4_SECURITY_LABEL=n:
Quoted 2 lines
fs/nfs/nfs4proc.c:218:9: error: expected expression before ‘|’ token 218 | |FATTR4_WORD2_OFFLINE
Oh... Can you fix it up by just moving that '|' inside the #ifdef?
Signature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]
Re: [PATCH v2 6/8] NFSv4: Support the offline bit
In reply to Anna SchumakerQuoted 71 lines · Anna Schumaker
Hi Trond,
Quoted 59 lines · On Tue, Dec 28, 2021 at 3:03 AM <[email protected]> wrote:
From: Trond Myklebust <[email protected]>
Add tracking of the NFSv4 'offline' attribute.
Signed-off-by Trond Myklebust <[email protected]>Signed-off-by Lance Shelton <[email protected]>Signed-off-by Trond Myklebust <[email protected]>--- fs/nfs/inode.c | 11 +++++++++++ fs/nfs/nfs4proc.c | 6 ++++++ fs/nfs/nfs4trace.h | 3 ++- fs/nfs/nfs4xdr.c | 31 ++++++++++++++++++++++++++++++- include/linux/nfs4.h | 1 + include/linux/nfs_fs.h | 1 + include/linux/nfs_xdr.h | 5 ++++- 7 files changed, 55 insertions(+), 3 deletions(-)fs/nfs/inode.c +11
-0@@ -528,6 +528,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) nfsi->archive =0 ; nfsi->hidden =0 ; nfsi->system =0 ; + nfsi->offline =0 ;inode_set_iversion_raw (inode,0 ); inode->i_size =0 ;clear_nlink (inode);@@ -606,6 +607,10 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) }else if (fattr_supported &NFS_ATTR_FATTR_SPACE_USED && fattr->size !=0 )nfs_set_cache_invalid (inode,NFS_INO_INVALID_BLOCKS ); +if (fattr->valid &NFS_ATTR_FATTR_OFFLINE ) + nfsi->offline = (fattr->hsa_flags &NFS_HSA_OFFLINE ) ?1 :0 ; +else if (fattr_supported &NFS_ATTR_FATTR_OFFLINE ) +nfs_set_cache_invalid (inode,NFS_INO_INVALID_WINATTR );nfs_setsecurity (inode, fattr);@@ -2274,6 +2279,12 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) nfsi->cache_validity |= save_cache_validity &NFS_INO_INVALID_BLOCKS ; +if (fattr->valid &NFS_ATTR_FATTR_OFFLINE ) + nfsi->offline = (fattr->hsa_flags &NFS_HSA_OFFLINE ) ?1 :0 ; +else if (fattr_supported &NFS_ATTR_FATTR_OFFLINE ) + nfsi->cache_validity |= + save_cache_validity &NFS_INO_INVALID_WINATTR ; +/* Update attrtimeo value if we're out of the unstable period */ if (attr_changed) {nfs_inc_stats (inode,NFSIOS_ATTRINVALIDATE );fs/nfs/nfs4proc.c +0
-0fs/nfs/nfs4proc.c const u32 nfs4_fattr_bitmap[3] = { · line 223
Quoted 5 lines
fs/nfs/nfs4proc.c +1
-0@@ -219,6 +219,7 @@ const u32 nfs4_fattr_bitmap[3] = {#ifdef CONFIG_NFS_V4_SECURITY_LABEL FATTR4_WORD2_SECURITY_LABEL #endif + |FATTR4_WORD2_OFFLINE };This won't compile if
CONFIG_NFS_V4_SECURITY_LABEL=n:
Quoted 7 lines
fs/nfs/nfs4proc.c:218:9: error: expected expression before ‘|’ token218 | | FATTR4_WORD2_OFFLINE | ^make[2]: *** [
scripts/Makefile.build:287:fs/nfs/nfs4proc.o] Error 1 make[1]: *** [scripts/Makefile.build:549: fs/nfs] Error 2
make: *** [Makefile:1846: fs] Error 2
make: *** Waiting for unfinished jobs....
I can fix it up by doing:
fs/nfs/nfs4proc.c +2 -2
@@ -212,10 +212,10 @@ const u32 nfs4_fattr_bitmap[3] = { | FATTR4_WORD1_TIME_METADATA |FATTR4_WORD1_TIME_MODIFY |FATTR4_WORD1_MOUNTED_ON_FILEID , + FATTR4_WORD2_OFFLINE #ifdef CONFIG_NFS_V4_SECURITY_LABEL - FATTR4_WORD2_SECURITY_LABEL + |FATTR4_WORD2_SECURITY_LABEL #endif - | FATTR4_WORD2_OFFLINE }; static const u32 nfs4_pnfs_open_bitmap[3] = {
If that works for you I can squash it into your patch in my tree
Anna
Quoted 165 lines
Anna
Quoted 162 lines
fs/nfs/nfs4proc.c +5
-0static const u32 nfs4_pnfs_open_bitmap[3 ] = {@@ -245,6 +246,7 @@ static const u32 nfs4_pnfs_open_bitmap[3] = { #ifdef CONFIG_NFS_V4_SECURITY_LABEL | FATTR4_WORD2_SECURITY_LABEL #endif + | FATTR4_WORD2_OFFLINE }; static const u32 nfs4_open_noattr_bitmap[3] = {@@ -325,6 +327,7 @@ static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src,if (!(cache_validity &NFS_INO_INVALID_WINATTR )) { dst[0 ] &= ~(FATTR4_WORD0_ARCHIVE |FATTR4_WORD0_HIDDEN ); dst[1 ] &= ~(FATTR4_WORD1_SYSTEM |FATTR4_WORD1_TIME_BACKUP ); + dst[2 ] &= ~FATTR4_WORD2_OFFLINE ; } }@@ -3927,6 +3930,8 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fmemcpy (server->attr_bitmask_nl, res.attr_bitmask,sizeof (server->attr_bitmask)); server->attr_bitmask_nl[2 ] &= ~FATTR4_WORD2_SECURITY_LABEL ; +if (!(res.attr_bitmask[2 ] &FATTR4_WORD2_OFFLINE )) + server->fattr_valid &= ~NFS_ATTR_FATTR_OFFLINE ;memcpy (server->cache_consistency_bitmask, res.attr_bitmask,sizeof (server->cache_consistency_bitmask)); server->cache_consistency_bitmask[0 ] &=FATTR4_WORD0_CHANGE |FATTR4_WORD0_SIZE ;@@ -5486,6 +5491,7 @@ static void nfs4_bitmask_set(__u32 bitmask[NFS4_BITMASK_SZ], const __u32 *src,if (cache_validity &NFS_INO_INVALID_WINATTR ) { bitmask[0 ] |=FATTR4_WORD0_ARCHIVE |FATTR4_WORD0_HIDDEN ; bitmask[1 ] |=FATTR4_WORD1_SYSTEM |FATTR4_WORD1_TIME_BACKUP ; + bitmask[2 ] |=FATTR4_WORD2_OFFLINE ; }if (cache_validity &NFS_INO_INVALID_SIZE )fs/nfs/nfs4trace.h +2
-1@@ -35,7 +35,8 @@ { NFS_ATTR_FATTR_HIDDEN, "HIDDEN" }, \ { NFS_ATTR_FATTR_SYSTEM, "SYSTEM" }, \ { NFS_ATTR_FATTR_ARCHIVE, "ARCHIVE" }, \ - { NFS_ATTR_FATTR_TIME_BACKUP, "TIME_BACKUP" }) + { NFS_ATTR_FATTR_TIME_BACKUP, "TIME_BACKUP" }, \ + { NFS_ATTR_FATTR_OFFLINE, "OFFLINE" }) DECLARE_EVENT_CLASS(nfs4_clientid_event, TP_PROTO(fs/nfs/nfs4xdr.c +30
-1@@ -1623,7 +1623,7 @@ static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_argFATTR4_WORD1_TIME_CREATE |FATTR4_WORD1_TIME_METADATA |FATTR4_WORD1_TIME_MODIFY ; - attrs[2 ] |=FATTR4_WORD2_SECURITY_LABEL ; + attrs[2 ] |=FATTR4_WORD2_SECURITY_LABEL |FATTR4_WORD2_OFFLINE ; dircount >>=1 ; }/* Use mounted_on_fileid only if the server supports it */ @@ -4354,6 +4354,29 @@ static int decode_attr_xattrsupport(struct xdr_stream *xdr, uint32_t *bitmap,return 0 ; } +static int decode_attr_offline (struct xdr_stream *xdr,uint32_t *bitmap, +uint32_t *res,uint64_t *flags) +{ +int status =0 ; +__be32 *p; + +if (unlikely (bitmap[2 ] & (FATTR4_WORD2_OFFLINE -1U ))) +return -EIO ; +if (likely (bitmap[2 ] &FATTR4_WORD2_OFFLINE )) { + p =xdr_inline_decode (xdr,4 ); +if (unlikely (!p)) +return -EIO ; +if (be32_to_cpup (p)) + *res |=NFS_HSA_OFFLINE ; +else + *res &= ~NFS_HSA_OFFLINE ; + bitmap[2 ] &= ~FATTR4_WORD2_OFFLINE ; + *flags |=NFS_ATTR_FATTR_OFFLINE ; + } +dprintk ("%s: system file: =%s\n" , __func__, (*res &NFS_HSA_OFFLINE ) ==0 ?"false" :"true" ); +return status; +} +static int verify_attr_len (struct xdr_stream *xdr,unsigned int savep,uint32_t attrlen) {unsigned int attrwords =XDR_QUADLEN (attrlen);@@ -4842,6 +4865,12 @@ static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, fattr->valid |= status; } + status =decode_attr_offline (xdr, bitmap, &fattr->hsa_flags, + &fattr->valid); +if (status <0 ) + goto xdr_error; + + status =0 ; xdr_error:dprintk ("%s: xdr returned %d\n" , __func__, -status);return status;include/linux/nfs4.h +1
-0@@ -460,6 +460,7 @@ enum lock_type4 {#define FATTR4_WORD2_SECURITY_LABEL (1UL << 16)#define FATTR4_WORD2_MODE_UMASK (1UL << 17)#define FATTR4_WORD2_XATTR_SUPPORT (1UL << 18) +#define FATTR4_WORD2_OFFLINE (1UL << 19)/* MDS threshold bitmap bits */ #define THRESHOLD_RD (1UL << 0)include/linux/nfs_fs.h +1
-0@@ -148,6 +148,7 @@ struct nfs_inode { unsigned char archive : 1; unsigned char hidden : 1; unsigned char system : 1; + unsigned char offline : 1;/* * read_cache_jiffies is when we started read-caching this inode. include/linux/nfs_xdr.h +4
-2@@ -21,6 +21,7 @@#define NFS_HSA_HIDDEN BIT(0)#define NFS_HSA_SYSTEM BIT(1)#define NFS_HSA_ARCHIVE BIT(2) +#define NFS_HSA_OFFLINE BIT(3)struct nfs4_string {unsigned int len;@@ -119,6 +120,7 @@ struct nfs_fattr {#define NFS_ATTR_FATTR_SYSTEM BIT_ULL(28)#define NFS_ATTR_FATTR_ARCHIVE BIT_ULL(29)#define NFS_ATTR_FATTR_TIME_BACKUP BIT_ULL(30) +#define NFS_ATTR_FATTR_OFFLINE BIT_ULL(31)#define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \ | NFS_ATTR_FATTR_MODE \@@ -144,7 +146,8 @@ struct nfs_fattr { | NFS_ATTR_FATTR_SYSTEM \ |NFS_ATTR_FATTR_ARCHIVE \ |NFS_ATTR_FATTR_TIME_BACKUP \ - | NFS_ATTR_FATTR_V4_SECURITY_LABEL) + |NFS_ATTR_FATTR_V4_SECURITY_LABEL \ + | NFS_ATTR_FATTR_OFFLINE)/* * Maximal number of supported layout drivers. -- 2.33.1
Re: [PATCH v2 6/8] NFSv4: Support the offline bit
Quoted 113 lines · Anna Schumaker
Quoted 83 lines · Anna Schumaker
Hi Trond,
Quoted 72 lines · On Tue, Dec 28, 2021 at 3:03 AM <[email protected]> wrote:
From: Trond Myklebust <[email protected]>
Add tracking of the NFSv4 'offline' attribute.
Signed-off-by Trond Myklebust <[email protected]>Signed-off-by Lance Shelton <[email protected]>Signed-off-by Trond Myklebust <[email protected]>---
fs/nfs/inode.c | 11 +++++++++++ fs/nfs/nfs4proc.c | 6 ++++++ fs/nfs/nfs4trace.h | 3 ++-
fs/nfs/nfs4xdr.c | 31 ++++++++++++++++++++++++++++++- include/linux/nfs4.h | 1 + include/linux/nfs_fs.h | 1 +include/linux/nfs_xdr.h| 5 ++++-7 files changed, 55 insertions(+), 3 deletions(-)fs/nfs/inode.c +1
-0@@ -528,6 +528,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) nfsi->archive = 0; nfsi->hidden = 0; nfsi->system = 0; + nfsi->offline = 0; inode_set_iversion_raw(inode, 0); inode->i_size = 0;
clear_nlink(inode);fs/nfs/inode.c +0
-0@@ -606,6 +607,10 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) } else if (fattr_supported &
NFS_ATTR_FATTR_SPACE_USED&&
fattr->size!= 0)nfs_set_cache_invalid(inode, NFS_INO_INVALID_BLOCKS);
+ if (fattr->valid&NFS_ATTR_FATTR_OFFLINE) +nfsi->offline= (fattr->hsa_flags&NFS_HSA_OFFLINE) ? 1 : 0;
+ else if (fattr_supported&NFS_ATTR_FATTR_OFFLINE)
+nfs_set_cache_invalid(inode, NFS_INO_INVALID_WINATTR);
nfs_setsecurity(inode, fattr);fs/nfs/inode.c +0
-0@@ -2274,6 +2279,12 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
nfsi->cache_validity|=
save_cache_validity&NFS_INO_INVALID_BLOCKS;+ if (
fattr->valid&NFS_ATTR_FATTR_OFFLINE)
+nfsi->offline= (fattr->hsa_flags&NFS_HSA_OFFLINE) ? 1 : 0;
+ else if (fattr_supported&NFS_ATTR_FATTR_OFFLINE) +nfsi->cache_validity|=
+save_cache_validity&NFS_INO_INVALID_WINATTR;
+
/* Update attrtimeo value if we're out of the unstable period */
if (attr_changed) {
nfs_inc_stats(inode, NFSIOS_ATTRINVALIDATE);fs/nfs/nfs4proc.c +0
-0@@ -219,6 +219,7 @@ const u32 nfs4_fattr_bitmap[3] = { #ifdef CONFIG_NFS_V4_SECURITY_LABELQuoted 4 lines
FATTR4_WORD2_SECURITY_LABEL
#endif
+ |FATTR4_WORD2_OFFLINE
};This won't compile if
CONFIG_NFS_V4_SECURITY_LABEL=n:Quoted 9 lines
fs/nfs/nfs4proc.c:218:9: error: expected expression before ‘|’ token
218 | |FATTR4_WORD2_OFFLINE
| ^
make[2]: *** [scripts/Makefile.build:287:fs/nfs/nfs4proc.o] Error 1
make[1]: *** [scripts/Makefile.build:549: fs/nfs] Error 2
make: *** [Makefile:1846: fs] Error 2
make: *** Waiting for unfinished jobs....I can fix it up by doing:
fs/nfs/nfs4proc.c +0
-0@@ -212,10 +212,10 @@ const u32 nfs4_fattr_bitmap[3] = {| FATTR4_WORD1_TIME_METADATA | FATTR4_WORD1_TIME_MODIFY | FATTR4_WORD1_MOUNTED_ON_FILEID,+
FATTR4_WORD2_OFFLINE
#ifdefCONFIG_NFS_V4_SECURITY_LABEL
-FATTR4_WORD2_SECURITY_LABEL
+ |FATTR4_WORD2_SECURITY_LABEL
#endif
- |FATTR4_WORD2_OFFLINE
};
Quoted 3 lines
static const u32 nfs4_pnfs_open_bitmap[3] = {
If that works for you I can squash it into your patch in my tree
Sure. I was thinking the opposite, but this works too.
i.e. my suggestion was just
#ifdef CONFIG_NFS_V4_SECURITY_LABEL
FATTR4_WORD2_SECURITY_LABEL |
#endif
FATTR4_WORD2_OFFLINE
However there is no functional difference between the two, so let's go with yours.
Quoted 190 lines
Anna
Quoted 187 lines
Anna
Quoted 184 lines
static const u32 nfs4_pnfs_open_bitmap[3] = {
fs/nfs/nfs4proc.c +0
-0@@ -245,6 +246,7 @@ static const u32 nfs4_pnfs_open_bitmap[3] = { #ifdef CONFIG_NFS_V4_SECURITY_LABEL|
FATTR4_WORD2_SECURITY_LABEL
#endif
+ |FATTR4_WORD2_OFFLINE
};static const u32 nfs4_open_noattr_bitmap[3] = {
fs/nfs/nfs4proc.c +0
-0@@ -325,6 +327,7 @@ static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src, if (!(cache_validity & NFS_INO_INVALID_WINATTR)) {dst[0] &= ~(FATTR4_WORD0_ARCHIVE |
FATTR4_WORD0_HIDDEN);
dst[1] &= ~(FATTR4_WORD1_SYSTEM |FATTR4_WORD1_TIME_BACKUP);
+ dst[2] &= ~FATTR4_WORD2_OFFLINE; }
}fs/nfs/nfs4proc.c +0
-0@@ -3927,6 +3930,8 @@ static int _nfs4_server_capabilities(struct
nfs_server*server, structnfs_fh*fmemcpy(server->attr_bitmask_nl, res.attr_bitmask, sizeof(server->attr_bitmask)); server->attr_bitmask_nl[2] &= ~FATTR4_WORD2_SECURITY_LABEL;
+ if (!(res.attr_bitmask[2] &FATTR4_WORD2_OFFLINE))
+server->fattr_valid&= ~NFS_ATTR_FATTR_OFFLINE;
memcpy(server->cache_consistency_bitmask, res.attr_bitmask, sizeof(server->cache_consistency_bitmask)); server->cache_consistency_bitmask[0] &= FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE;fs/nfs/nfs4proc.c +0
-0@@ -5486,6 +5491,7 @@ static void nfs4_bitmask_set(__u32 bitmask[NFS4_BITMASK_SZ], const __u32 *src, if (cache_validity & NFS_INO_INVALID_WINATTR) {bitmask[0] |=
FATTR4_WORD0_ARCHIVE|FATTR4_WORD0_HIDDEN;
bitmask[1] |=FATTR4_WORD1_SYSTEM|FATTR4_WORD1_TIME_BACKUP;
+ bitmask[2] |=FATTR4_WORD2_OFFLINE; }if (
cache_validity&NFS_INO_INVALID_SIZE)fs/nfs/nfs4trace.h +2
-1@@ -35,7 +35,8 @@ { NFS_ATTR_FATTR_HIDDEN, "HIDDEN" }, \ { NFS_ATTR_FATTR_SYSTEM, "SYSTEM" }, \ { NFS_ATTR_FATTR_ARCHIVE, "ARCHIVE" }, \ - { NFS_ATTR_FATTR_TIME_BACKUP, "TIME_BACKUP" }) + { NFS_ATTR_FATTR_TIME_BACKUP, "TIME_BACKUP" }, \ + { NFS_ATTR_FATTR_OFFLINE, "OFFLINE" }) DECLARE_EVENT_CLASS(nfs4_clientid_event,TP_PROTO(
fs/nfs/nfs4xdr.c +0
-0@@ -1623,7 +1623,7 @@ static void encode_readdir(struct
xdr_stream*xdr, const structnfs4_readdir_argFATTR4_WORD1_TIME_CREATE|FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY; - attrs[2] |=FATTR4_WORD2_SECURITY_LABEL; + attrs[2] |=FATTR4_WORD2_SECURITY_LABEL|FATTR4_WORD2_OFFLINE;
dircount >>= 1;
}
/* Usemounted_on_fileidonly if the server supports it */fs/nfs/nfs4xdr.c +23
-0@@ -4354,6 +4354,29 @@ static int decode_attr_xattrsupport(struct xdr_stream *xdr, uint32_t *bitmap, return 0; } +static int decode_attr_offline (struct xdr_stream *xdr,uint32_t *bitmap, + uint32_t *res, uint64_t *flags) +{ + int status = 0; + __be32 *p; + + if (unlikely(bitmap[2] & (FATTR4_WORD2_OFFLINE - 1U))) + return -EIO; + if (likely(bitmap[2] & FATTR4_WORD2_OFFLINE)) { + p = xdr_inline_decode(xdr, 4); + if (unlikely(!p)) + return -EIO; + if (be32_to_cpup(p)) + *res |= NFS_HSA_OFFLINE; + else + *res &= ~NFS_HSA_OFFLINE; + bitmap[2] &= ~FATTR4_WORD2_OFFLINE; + *flags |= NFS_ATTR_FATTR_OFFLINE; + } + dprintk("%s: system file: =%s\n", __func__, (*res &NFS_HSA_OFFLINE ) ==0 ?"false" :"true" ); + return status; +} +static int
verify_attr_len(struct xdr_stream *xdr, unsigned int savep, uint32_t attrlen)
{
unsigned int attrwords =XDR_QUADLEN(attrlen);fs/nfs/nfs4xdr.c +6
-0@@ -4842,6 +4865,12 @@ static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, fattr->valid |= status; } + status = decode_attr_offline(xdr, bitmap, &fattr- >hsa_flags, + &fattr->valid); + if (status < 0) + goto xdr_error; + + status = 0;xdr_error:
dprintk("%s: xdr returned %d\n", __func__, -status); return status;include/linux/nfs4.h +1
-0@@ -460,6 +460,7 @@ enum lock_type4 { #define FATTR4_WORD2_SECURITY_LABEL (1UL << 16) #define FATTR4_WORD2_MODE_UMASK (1UL << 17) #define FATTR4_WORD2_XATTR_SUPPORT (1UL << 18) +#define FATTR4_WORD2_OFFLINE (1UL << 19) /* MDS threshold bitmap bits */ #define THRESHOLD_RD (1UL << 0)include/linux/nfs_fs.h +1
-0@@ -148,6 +148,7 @@ struct nfs_inode { unsigned char archive : 1; unsigned char hidden : 1; unsigned char system : 1; + unsigned char offline : 1; /** read_cache_jiffies is when we started read-caching this inode.
include/linux/nfs_xdr.h +4
-2@@ -21,6 +21,7 @@ #define NFS_HSA_HIDDEN BIT(0) #define NFS_HSA_SYSTEM BIT(1) #define NFS_HSA_ARCHIVE BIT(2) +#define NFS_HSA_OFFLINE BIT(3) struct nfs4_string { unsigned int len;@@ -119,6 +120,7 @@ struct nfs_fattr { #define NFS_ATTR_FATTR_SYSTEM BIT_ULL(28) #define NFS_ATTR_FATTR_ARCHIVE BIT_ULL(29) #define NFS_ATTR_FATTR_TIME_BACKUP BIT_ULL(30) +#define NFS_ATTR_FATTR_OFFLINE BIT_ULL(31) #define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \ | NFS_ATTR_FATTR_MODE \@@ -144,7 +146,8 @@ struct nfs_fattr { | NFS_ATTR_FATTR_SYSTEM \ | NFS_ATTR_FATTR_ARCHIVE \ | NFS_ATTR_FATTR_TIME_BACKUP \ - | NFS_ATTR_FATTR_V4_SECURITY_LABEL) + | NFS_ATTR_FATTR_V4_SECURITY_LABEL \ + | NFS_ATTR_FATTR_OFFLINE) /** Maximal number of supported layout drivers. -- 2.33.1
Signature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]
Re: [PATCH v2 6/8] NFSv4: Support the offline bit
Quoted 123 lines · Trond Myklebust
Quoted 115 lines · Anna Schumaker
Quoted 85 lines · Anna Schumaker
Hi Trond,
Quoted 71 lines · On Tue, Dec 28, 2021 at 3:03 AM <[email protected]> wrote:
From: Trond Myklebust <[email protected]>
Add tracking of the NFSv4 'offline' attribute.
Signed-off-by Trond Myklebust <[email protected]>Signed-off-by Lance Shelton <[email protected]>Signed-off-by Trond Myklebust <[email protected]>--- fs/nfs/inode.c | 11 +++++++++++ fs/nfs/nfs4proc.c | 6 ++++++ fs/nfs/nfs4trace.h | 3 ++- fs/nfs/nfs4xdr.c | 31 ++++++++++++++++++++++++++++++- include/linux/nfs4.h | 1 + include/linux/nfs_fs.h | 1 + include/linux/nfs_xdr.h | 5 ++++- 7 files changed, 55 insertions(+), 3 deletions(-)fs/nfs/inode.c +1
-0@@ -528,6 +528,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) nfsi->archive = 0; nfsi->hidden =0 ; nfsi->system =0 ; + nfsi->offline =0 ;inode_set_iversion_raw (inode,0 ); inode->i_size =0 ;clear_nlink(inode);fs/nfs/inode.c +0
-0@@ -606,6 +607,10 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) } else if (fattr_supported &
NFS_ATTR_FATTR_SPACE_USED&&fattr->size != 0) nfs_set_cache_invalid(inode,
NFS_INO_INVALID_BLOCKS);fs/nfs/inode.c +2
-0+if (fattr->valid &NFS_ATTR_FATTR_OFFLINE ) + nfsi->offline = (fattr->hsa_flags &
NFS_HSA_OFFLINE) ? 1 : 0;
+ else if (fattr_supported&NFS_ATTR_FATTR_OFFLINE)
+ nfs_set_cache_invalid(inode,NFS_INO_INVALID_WINATTR);nfs_setsecurity(inode, fattr);fs/nfs/inode.c +5
-0@@ -2274,6 +2279,12 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) nfsi->cache_validity |= save_cache_validity &NFS_INO_INVALID_BLOCKS ; +if (fattr->valid &NFS_ATTR_FATTR_OFFLINE ) + nfsi->offline = (fattr->hsa_flags &NFS_HSA_OFFLINE ) ?1 :0 ; +else if (fattr_supported &NFS_ATTR_FATTR_OFFLINE ) + nfsi->cache_validity |= + save_cache_validity &
NFS_INO_INVALID_WINATTR;
+/* Update attrtimeo value if we're out of the unstable period */ if (attr_changed) { nfs_inc_stats(inode, NFSIOS_ATTRINVALIDATE);fs/nfs/nfs4proc.c +0
-0fs/nfs/nfs4proc.c const u32 nfs4_fattr_bitmap[3] = { · line 223
Quoted 5 lines
fs/nfs/nfs4proc.c +1
-0@@ -219,6 +219,7 @@ const u32 nfs4_fattr_bitmap[3] = {#ifdef CONFIG_NFS_V4_SECURITY_LABEL FATTR4_WORD2_SECURITY_LABEL #endif + |FATTR4_WORD2_OFFLINE };This won't compile if
CONFIG_NFS_V4_SECURITY_LABEL=n:
fs/nfs/nfs4proc.c:218:9: error: expected expression before ‘|’ tokenQuoted 7 lines
218 | | FATTR4_WORD2_OFFLINE | ^make[2]: *** [
scripts/Makefile.build:287:fs/nfs/nfs4proc.o] Error 1
make[1]: *** [scripts/Makefile.build:549: fs/nfs] Error 2
make: *** [Makefile:1846: fs] Error 2
make: *** Waiting for unfinished jobs....I can fix it up by doing:
fs/nfs/nfs4proc.c +2
-2@@ -212,10 +212,10 @@ const u32 nfs4_fattr_bitmap[3] = { | FATTR4_WORD1_TIME_METADATA |FATTR4_WORD1_TIME_MODIFY |FATTR4_WORD1_MOUNTED_ON_FILEID , + FATTR4_WORD2_OFFLINE #ifdef CONFIG_NFS_V4_SECURITY_LABEL - FATTR4_WORD2_SECURITY_LABEL + |FATTR4_WORD2_SECURITY_LABEL #endif - | FATTR4_WORD2_OFFLINE }; static const u32 nfs4_pnfs_open_bitmap[3] = {Quoted 1 line
If that works for you I can squash it into your patch in my tree
Sure. I was thinking the opposite, but this works too.
i.e. my suggestion was just
Quoted 7 lines
#ifdef
CONFIG_NFS_V4_SECURITY_LABEL
FATTR4_WORD2_SECURITY_LABEL|
#endif
FATTR4_WORD2_OFFLINEHowever there is no functional difference between the two, so let's go with yours.
Thanks for taking a quick look!
Anna
Quoted 198 lines
Quoted 186 lines
Anna
Quoted 182 lines
Anna
Quoted 179 lines
fs/nfs/nfs4proc.c +2
-0static const u32 nfs4_pnfs_open_bitmap[3 ] = {@@ -245,6 +246,7 @@ static const u32 nfs4_pnfs_open_bitmap[3] = { #ifdef CONFIG_NFS_V4_SECURITY_LABEL | FATTR4_WORD2_SECURITY_LABEL #endif + | FATTR4_WORD2_OFFLINE }; static const u32 nfs4_open_noattr_bitmap[3] = {@@ -325,6 +327,7 @@ static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src, if (!(cache_validity & NFS_INO_INVALID_WINATTR)) { dst[0 ] &= ~(FATTR4_WORD0_ARCHIVE |FATTR4_WORD0_HIDDEN ); dst[1 ] &= ~(FATTR4_WORD1_SYSTEM |FATTR4_WORD1_TIME_BACKUP ); + dst[2 ] &= ~FATTR4_WORD2_OFFLINE ;}}
fs/nfs/nfs4proc.c +0
-0@@ -3927,6 +3930,8 @@ static int _nfs4_server_capabilities(struct
nfs_server*server, structnfs_fh*fmemcpy(server->attr_bitmask_nl, res.attr_bitmask, sizeof(server->attr_bitmask)); server->attr_bitmask_nl[2] &=~FATTR4_WORD2_SECURITY_LABEL;
+ if (!(res.attr_bitmask[2] &FATTR4_WORD2_OFFLINE))
+server->fattr_valid&=
~NFS_ATTR_FATTR_OFFLINE;memcpy(server->cache_consistency_bitmask, res.attr_bitmask, sizeof(server->cache_consistency_bitmask)); server->cache_consistency_bitmask[0] &=FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE;
fs/nfs/nfs4proc.c +1
-0@@ -5486,6 +5491,7 @@ static void nfs4_bitmask_set(__u32 bitmask[NFS4_BITMASK_SZ], const __u32 *src, if (cache_validity & NFS_INO_INVALID_WINATTR) { bitmask[0 ] |=FATTR4_WORD0_ARCHIVE |FATTR4_WORD0_HIDDEN ; bitmask[1 ] |=FATTR4_WORD1_SYSTEM |FATTR4_WORD1_TIME_BACKUP ; + bitmask[2 ] |=FATTR4_WORD2_OFFLINE ;}
if (
cache_validity&NFS_INO_INVALID_SIZE)fs/nfs/nfs4trace.h +2
-1@@ -35,7 +35,8 @@ { NFS_ATTR_FATTR_HIDDEN, "HIDDEN" }, \ { NFS_ATTR_FATTR_SYSTEM, "SYSTEM" }, \ { NFS_ATTR_FATTR_ARCHIVE, "ARCHIVE" }, \ - { NFS_ATTR_FATTR_TIME_BACKUP, "TIME_BACKUP" }) + { NFS_ATTR_FATTR_TIME_BACKUP, "TIME_BACKUP" }, \ + { NFS_ATTR_FATTR_OFFLINE, "OFFLINE" }) DECLARE_EVENT_CLASS(nfs4_clientid_event, TP_PROTO(fs/nfs/nfs4xdr.c +0
-0@@ -1623,7 +1623,7 @@ static void encode_readdir(struct
xdr_stream*xdr, const structnfs4_readdir_argFATTR4_WORD1_TIME_CREATE | FATTR4_WORD1_TIME_METADATA | FATTR4_WORD1_TIME_MODIFY;fs/nfs/nfs4xdr.c +1
-1- attrs[2 ] |=FATTR4_WORD2_SECURITY_LABEL ; + attrs[2] |= FATTR4_WORD2_SECURITY_LABEL |FATTR4_WORD2_OFFLINE; dircount >>= 1; } /* Use mounted_on_fileid only if the server supports it*/
fs/nfs/nfs4xdr.c +23
-0@@ -4354,6 +4354,29 @@ static int decode_attr_xattrsupport(struct xdr_stream *xdr, uint32_t *bitmap, return 0; } +static int decode_attr_offline (struct xdr_stream *xdr,uint32_t *bitmap, +uint32_t *res,uint64_t *flags) +{ +int status =0 ; +__be32 *p; + +if (unlikely (bitmap[2 ] & (FATTR4_WORD2_OFFLINE -1U ))) +return -EIO ; +if (likely (bitmap[2 ] &FATTR4_WORD2_OFFLINE )) { + p =xdr_inline_decode (xdr,4 ); +if (unlikely (!p)) +return -EIO ; +if (be32_to_cpup (p)) + *res |=NFS_HSA_OFFLINE ; +else + *res &= ~NFS_HSA_OFFLINE ; + bitmap[2 ] &= ~FATTR4_WORD2_OFFLINE ; + *flags |=NFS_ATTR_FATTR_OFFLINE ; + } +dprintk ("%s: system file: =%s\n" , __func__, (*res &NFS_HSA_OFFLINE ) ==0 ?"false" :"true" ); +return status; +} +static int verify_attr_len(struct
xdr_stream*xdr, unsigned int
savep,uint32_tattrlen){ unsigned int attrwords = XDR_QUADLEN(attrlen);fs/nfs/nfs4xdr.c +6
-0@@ -4842,6 +4865,12 @@ static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, fattr->valid |= status; } + status =decode_attr_offline (xdr, bitmap, &fattr- >hsa_flags, + &fattr->valid); +if (status <0 ) + goto xdr_error; + + status =0 ; xdr_error:dprintk("%s: xdr returned %d\n", __func__, -status); return status;include/linux/nfs4.h +1
-0@@ -460,6 +460,7 @@ enum lock_type4 {#define FATTR4_WORD2_SECURITY_LABEL (1UL << 16)#define FATTR4_WORD2_MODE_UMASK (1UL << 17)#define FATTR4_WORD2_XATTR_SUPPORT (1UL << 18) +#define FATTR4_WORD2_OFFLINE (1UL << 19)/* MDS threshold bitmap bits */ #define THRESHOLD_RD (1UL << 0)include/linux/nfs_fs.h +1
-0@@ -148,6 +148,7 @@ struct nfs_inode { unsigned char archive : 1; unsigned char hidden : 1; unsigned char system : 1; + unsigned char offline : 1;/* * read_cache_jiffies is when we started read-caching this inode.
include/linux/nfs_xdr.h +4
-1@@ -21,6 +21,7 @@#define NFS_HSA_HIDDEN BIT(0)#define NFS_HSA_SYSTEM BIT(1)#define NFS_HSA_ARCHIVE BIT(2) +#define NFS_HSA_OFFLINE BIT(3)struct nfs4_string {unsigned int len;@@ -119,6 +120,7 @@ struct nfs_fattr {#define NFS_ATTR_FATTR_SYSTEM BIT_ULL(28)#define NFS_ATTR_FATTR_ARCHIVE BIT_ULL(29)#define NFS_ATTR_FATTR_TIME_BACKUP BIT_ULL(30) +#define NFS_ATTR_FATTR_OFFLINE BIT_ULL(31)#define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \ | NFS_ATTR_FATTR_MODE \@@ -144,7 +146,8 @@ struct nfs_fattr { | NFS_ATTR_FATTR_SYSTEM \ |NFS_ATTR_FATTR_ARCHIVE \ |NFS_ATTR_FATTR_TIME_BACKUP \ - | NFS_ATTR_FATTR_V4_SECURITY_LABEL) + |NFS_ATTR_FATTR_V4_SECURITY_LABEL \ + | NFS_ATTR_FATTR_OFFLINE)Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
include/linux/nfs_xdr.h +0
-1/* * Maximal number of supported layout drivers. -- 2.33.1
--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]
Hey Trond and Anna - this series looked ready to go, but seems to have never gotten upstream. Was there a problem that needed work?
I'd like to rebase these and submit them, but will hold off if its a non-starter..
Ben
Quoted 57 lines · On 27 Dec 2021, at 14:04, [email protected] wrote:
From: Trond Myklebust <[email protected]>
NFSv4 has support for a number of extra attributes that are of interest to Samba when it is used to re-export a filesystem to Windows clients. Aside from the btime, which is of interest in
statx(), Windows clients have an interest in determining the status of the 'hidden', and 'system' flags.
Backup programs want to read the 'archive' flags and the 'time backup' attribute.
Finally, the 'offline' flag can tell whether or not a file needs to be staged by an HSM system before it can be read or written to.The patch series also adds an
ioctl()to allow userspace retrieval and setting of these attributes where appropriate. It also adds anioctl()to allow retrieval of the raw NFSv4 ACCESS information, to allow more fine grained determination of the user's access rights to a file or directory. All of this information is of use for Samba.- v2: Rebase on top of Anna's linux-next
Anne Marie Merritt (3):
nfs: Add timecreate to nfs inode
nfs: Add 'archive', 'hidden' and 'system' fields to nfs inode
nfs: Add 'time backup' to nfs inodeRichard Sharpe (1):
NFS: Supportstatx_getandstatx_setioctlsTrond Myklebust (4):
NFS: Expand the type ofnfs_fattr->valid
NFS: Return the file btime in the statx results when appropriate
NFSv4: Support the offline bit
NFSv4: Add an ioctl to allow retrieval of the NFS raw ACCESS maskfs/nfs/dir.c | 71 ++--- fs/nfs/getroot.c | 3 +- fs/nfs/inode.c | 147 +++++++++- fs/nfs/internal.h | 10 + fs/nfs/nfs3proc.c | 1 + fs/nfs/nfs4_fs.h | 31 +++ fs/nfs/nfs4file.c | 550 ++++++++++++++++++++++++++++++++++++++ fs/nfs/nfs4proc.c | 175 +++++++++++- fs/nfs/nfs4trace.h | 8 +- fs/nfs/nfs4xdr.c | 240 +++++++++++++++-- fs/nfs/nfstrace.c | 5 + fs/nfs/nfstrace.h | 9 +- fs/nfs/proc.c | 1 + include/linux/nfs4.h | 1 + include/linux/nfs_fs.h | 15 ++ include/linux/nfs_fs_sb.h | 2 +- include/linux/nfs_xdr.h | 80 ++++-- include/uapi/linux/nfs.h | 101 +++++++ 18 files changed, 1355 insertions(+), 95 deletions(-)Signature · 1 line
2.33.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 16 lines · Trond Myklebust
Quoted 6 lines · Benjamin Coddington
Hey Trond and Anna - this series looked ready to go, but seems to have never gotten upstream. Was there a problem that needed work?
I'd like to rebase these and submit them, but will hold off if its a non-starter..
I believe the main issue raised at the time when we submitted all these attributes was that we had the
ioctl()to retrieve and set them. The request from the community was that we usestatx()to retrieve, and then add a new system call to set them.btime already has support in
statx(), so there was relatively little work needed to convert these patches to use it.
Quoted 8 lines
However for the other attributes (Windows Hidden, System, Archive attributes and the backup time) the main issue was adding the new system call to set them all. That work is yet to be done due to lack of developer time.
If you have time to revive these patches and push the btime changes upstream, then that would be very welcome from our perspective. I'm happy to help in any capacity that I can.
Great news! I did rebase and post just the btime portion, it needs a v2 so I'll work on moving it along.
Ben