nfsd4: support change_attr_type attribute
authorJ. Bruce Fields <bfields@redhat.com>
Wed, 25 Apr 2018 17:26:23 +0000 (13:26 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Sun, 17 Jun 2018 14:41:31 +0000 (10:41 -0400)
The change attribute is what is used by clients to revalidate their
caches.  Our server may use i_version or ctime for that purpose.  Those
choices behave slightly differently, and it may be useful to the client
to know which we're using.  This attribute tells the client that.  The
Linux client doesn't yet use this attribute yet, though.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4xdr.c
fs/nfsd/nfsd.h
include/linux/nfs4.h

index 4161031ae14e3462a571ed61f2445b8a3452fa9b..fb4991889f8940c5663ffe9a03caff40116d5958 100644 (file)
@@ -2891,6 +2891,16 @@ out_acl:
                        goto out;
        }
 
+       if (bmval2 & FATTR4_WORD2_CHANGE_ATTR_TYPE) {
+               p = xdr_reserve_space(xdr, 4);
+               if (!p)
+                       goto out_resource;
+               if (IS_I_VERSION(d_inode(dentry)))
+                       *p++ = cpu_to_be32(NFS4_CHANGE_TYPE_IS_MONOTONIC_INCR);
+               else
+                       *p++ = cpu_to_be32(NFS4_CHANGE_TYPE_IS_TIME_METADATA);
+       }
+
        if (bmval2 & FATTR4_WORD2_SECURITY_LABEL) {
                status = nfsd4_encode_security_label(xdr, rqstp, context,
                                                                contextlen);
index 3fce905d036502987d4ebb9560800a28fd37ad98..066899929863c020f8a87a94f0399b770c46eb78 100644 (file)
@@ -360,6 +360,7 @@ void                nfsd_lockd_shutdown(void);
 
 #define NFSD4_2_SUPPORTED_ATTRS_WORD2 \
        (NFSD4_1_SUPPORTED_ATTRS_WORD2 | \
+       FATTR4_WORD2_CHANGE_ATTR_TYPE | \
        FATTR4_WORD2_MODE_UMASK | \
        NFSD4_2_SECURITY_ATTRS)
 
index 57ffaa20d5649f5cdc77e4a1fd088201e66286ed..0877ed33373361f5d0c1141d5bbbf1f1e25794a8 100644 (file)
@@ -374,6 +374,13 @@ enum lock_type4 {
        NFS4_WRITEW_LT = 4
 };
 
+enum change_attr_type4 {
+       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
+};
 
 /* Mandatory Attributes */
 #define FATTR4_WORD0_SUPPORTED_ATTRS    (1UL << 0)
@@ -441,6 +448,7 @@ enum lock_type4 {
 #define FATTR4_WORD2_LAYOUT_BLKSIZE     (1UL << 1)
 #define FATTR4_WORD2_MDSTHRESHOLD       (1UL << 4)
 #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_MODE_UMASK                (1UL << 17)