Commit 7f08a335 authored by Trond Myklebust's avatar Trond Myklebust

NFSv4: Add support for the NFSv4.2 "change_attr_type" attribute

The change_attr_type allows the server to provide a description of how
the change attribute will behave. This again will allow the client to
optimise its behaviour w.r.t. attribute revalidation.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 993e2d4b
...@@ -792,6 +792,7 @@ static void nfs_server_set_fsinfo(struct nfs_server *server, ...@@ -792,6 +792,7 @@ static void nfs_server_set_fsinfo(struct nfs_server *server,
server->maxfilesize = fsinfo->maxfilesize; server->maxfilesize = fsinfo->maxfilesize;
server->time_delta = fsinfo->time_delta; server->time_delta = fsinfo->time_delta;
server->change_attr_type = fsinfo->change_attr_type;
server->clone_blksize = fsinfo->clone_blksize; server->clone_blksize = fsinfo->clone_blksize;
/* We're airborne Set socket buffersize */ /* We're airborne Set socket buffersize */
...@@ -933,6 +934,8 @@ struct nfs_server *nfs_alloc_server(void) ...@@ -933,6 +934,8 @@ struct nfs_server *nfs_alloc_server(void)
return NULL; return NULL;
} }
server->change_attr_type = NFS4_CHANGE_TYPE_IS_UNDEFINED;
ida_init(&server->openowner_id); ida_init(&server->openowner_id);
ida_init(&server->lockowner_id); ida_init(&server->lockowner_id);
pnfs_init_server(server); pnfs_init_server(server);
......
...@@ -2227,6 +2227,7 @@ static int decode_fsinfo3resok(struct xdr_stream *xdr, ...@@ -2227,6 +2227,7 @@ static int decode_fsinfo3resok(struct xdr_stream *xdr,
/* ignore properties */ /* ignore properties */
result->lease_time = 0; result->lease_time = 0;
result->change_attr_type = NFS4_CHANGE_TYPE_IS_TIME_METADATA;
return 0; return 0;
} }
......
...@@ -264,6 +264,7 @@ const u32 nfs4_fsinfo_bitmap[3] = { FATTR4_WORD0_MAXFILESIZE ...@@ -264,6 +264,7 @@ const u32 nfs4_fsinfo_bitmap[3] = { FATTR4_WORD0_MAXFILESIZE
| FATTR4_WORD1_FS_LAYOUT_TYPES, | FATTR4_WORD1_FS_LAYOUT_TYPES,
FATTR4_WORD2_LAYOUT_BLKSIZE FATTR4_WORD2_LAYOUT_BLKSIZE
| FATTR4_WORD2_CLONE_BLKSIZE | FATTR4_WORD2_CLONE_BLKSIZE
| FATTR4_WORD2_CHANGE_ATTR_TYPE
| FATTR4_WORD2_XATTR_SUPPORT | FATTR4_WORD2_XATTR_SUPPORT
}; };
......
...@@ -153,6 +153,7 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, ...@@ -153,6 +153,7 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
5 /* fs layout types */ + \ 5 /* fs layout types */ + \
1 /* layout blksize */ + \ 1 /* layout blksize */ + \
1 /* clone blksize */ + \ 1 /* clone blksize */ + \
1 /* change attr type */ + \
1 /* xattr support */) 1 /* xattr support */)
#define encode_renew_maxsz (op_encode_hdr_maxsz + 3) #define encode_renew_maxsz (op_encode_hdr_maxsz + 3)
#define decode_renew_maxsz (op_decode_hdr_maxsz) #define decode_renew_maxsz (op_decode_hdr_maxsz)
...@@ -4846,6 +4847,32 @@ static int decode_attr_clone_blksize(struct xdr_stream *xdr, uint32_t *bitmap, ...@@ -4846,6 +4847,32 @@ static int decode_attr_clone_blksize(struct xdr_stream *xdr, uint32_t *bitmap,
return 0; return 0;
} }
static int decode_attr_change_attr_type(struct xdr_stream *xdr,
uint32_t *bitmap,
enum nfs4_change_attr_type *res)
{
u32 tmp = NFS4_CHANGE_TYPE_IS_UNDEFINED;
dprintk("%s: bitmap is %x\n", __func__, bitmap[2]);
if (bitmap[2] & FATTR4_WORD2_CHANGE_ATTR_TYPE) {
if (xdr_stream_decode_u32(xdr, &tmp))
return -EIO;
bitmap[2] &= ~FATTR4_WORD2_CHANGE_ATTR_TYPE;
}
switch(tmp) {
case NFS4_CHANGE_TYPE_IS_MONOTONIC_INCR:
case NFS4_CHANGE_TYPE_IS_VERSION_COUNTER:
case NFS4_CHANGE_TYPE_IS_VERSION_COUNTER_NOPNFS:
case NFS4_CHANGE_TYPE_IS_TIME_METADATA:
*res = tmp;
break;
default:
*res = NFS4_CHANGE_TYPE_IS_UNDEFINED;
}
return 0;
}
static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo)
{ {
unsigned int savep; unsigned int savep;
...@@ -4894,6 +4921,11 @@ static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) ...@@ -4894,6 +4921,11 @@ static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo)
if (status) if (status)
goto xdr_error; goto xdr_error;
status = decode_attr_change_attr_type(xdr, bitmap,
&fsinfo->change_attr_type);
if (status)
goto xdr_error;
status = decode_attr_xattrsupport(xdr, bitmap, status = decode_attr_xattrsupport(xdr, bitmap,
&fsinfo->xattr_support); &fsinfo->xattr_support);
if (status) if (status)
......
...@@ -91,6 +91,7 @@ nfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle, ...@@ -91,6 +91,7 @@ nfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
info->dtpref = fsinfo.tsize; info->dtpref = fsinfo.tsize;
info->maxfilesize = 0x7FFFFFFF; info->maxfilesize = 0x7FFFFFFF;
info->lease_time = 0; info->lease_time = 0;
info->change_attr_type = NFS4_CHANGE_TYPE_IS_TIME_METADATA;
return 0; return 0;
} }
......
...@@ -452,6 +452,7 @@ enum lock_type4 { ...@@ -452,6 +452,7 @@ enum lock_type4 {
#define FATTR4_WORD2_LAYOUT_BLKSIZE (1UL << 1) #define FATTR4_WORD2_LAYOUT_BLKSIZE (1UL << 1)
#define FATTR4_WORD2_MDSTHRESHOLD (1UL << 4) #define FATTR4_WORD2_MDSTHRESHOLD (1UL << 4)
#define FATTR4_WORD2_CLONE_BLKSIZE (1UL << 13) #define FATTR4_WORD2_CLONE_BLKSIZE (1UL << 13)
#define FATTR4_WORD2_CHANGE_ATTR_TYPE (1UL << 15)
#define FATTR4_WORD2_SECURITY_LABEL (1UL << 16) #define FATTR4_WORD2_SECURITY_LABEL (1UL << 16)
#define FATTR4_WORD2_MODE_UMASK (1UL << 17) #define FATTR4_WORD2_MODE_UMASK (1UL << 17)
#define FATTR4_WORD2_XATTR_SUPPORT (1UL << 18) #define FATTR4_WORD2_XATTR_SUPPORT (1UL << 18)
...@@ -709,6 +710,14 @@ struct nl4_server { ...@@ -709,6 +710,14 @@ struct nl4_server {
} u; } u;
}; };
enum nfs4_change_attr_type {
NFS4_CHANGE_TYPE_IS_MONOTONIC_INCR = 0,
NFS4_CHANGE_TYPE_IS_VERSION_COUNTER = 1,
NFS4_CHANGE_TYPE_IS_VERSION_COUNTER_NOPNFS = 2,
NFS4_CHANGE_TYPE_IS_TIME_METADATA = 3,
NFS4_CHANGE_TYPE_IS_UNDEFINED = 4,
};
/* /*
* Options for setxattr. These match the flags for setxattr(2). * Options for setxattr. These match the flags for setxattr(2).
*/ */
......
...@@ -180,6 +180,9 @@ struct nfs_server { ...@@ -180,6 +180,9 @@ struct nfs_server {
#define NFS_OPTION_FSCACHE 0x00000001 /* - local caching enabled */ #define NFS_OPTION_FSCACHE 0x00000001 /* - local caching enabled */
#define NFS_OPTION_MIGRATION 0x00000002 /* - NFSv4 migration enabled */ #define NFS_OPTION_MIGRATION 0x00000002 /* - NFSv4 migration enabled */
enum nfs4_change_attr_type
change_attr_type;/* Description of change attribute */
struct nfs_fsid fsid; struct nfs_fsid fsid;
__u64 maxfilesize; /* maximum file size */ __u64 maxfilesize; /* maximum file size */
struct timespec64 time_delta; /* smallest time granularity */ struct timespec64 time_delta; /* smallest time granularity */
......
...@@ -152,6 +152,8 @@ struct nfs_fsinfo { ...@@ -152,6 +152,8 @@ struct nfs_fsinfo {
__u32 layouttype[NFS_MAX_LAYOUT_TYPES]; /* supported pnfs layout driver */ __u32 layouttype[NFS_MAX_LAYOUT_TYPES]; /* supported pnfs layout driver */
__u32 blksize; /* preferred pnfs io block size */ __u32 blksize; /* preferred pnfs io block size */
__u32 clone_blksize; /* granularity of a CLONE operation */ __u32 clone_blksize; /* granularity of a CLONE operation */
enum nfs4_change_attr_type
change_attr_type; /* Info about change attr */
__u32 xattr_support; /* User xattrs supported */ __u32 xattr_support; /* User xattrs supported */
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment