NFS: change stateid to be a union
authorAlexandros Batsakis <batsakis@netapp.com>
Wed, 20 Oct 2010 04:17:56 +0000 (00:17 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Sun, 24 Oct 2010 22:02:53 +0000 (18:02 -0400)
In NFSv4.1 the stateid consists of the other and seqid fields. For layout
processing we need to numerically compare the seqid value of layout stateids.
To do so, introduce a union to nfs4_stateid to switch between opaque(16 bytes)
and opaque(12 bytes) / __be32

Signed-off-by: Alexandros Batsakis <batsakis@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: Fred Isaman <iisaman@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/callback_proc.c
include/linux/nfs4.h

index 930d10fecdaff8632dc35869c3695fc8397e8d7a..2950fca0c61b22cd0997d7c136cde40b90a0ae71 100644 (file)
@@ -118,11 +118,11 @@ int nfs41_validate_delegation_stateid(struct nfs_delegation *delegation, const n
        if (delegation == NULL)
                return 0;
 
-       /* seqid is 4-bytes long */
-       if (((u32 *) &stateid->data)[0] != 0)
+       if (stateid->stateid.seqid != 0)
                return 0;
-       if (memcmp(&delegation->stateid.data[4], &stateid->data[4],
-                  sizeof(stateid->data)-4))
+       if (memcmp(&delegation->stateid.stateid.other,
+                  &stateid->stateid.other,
+                  NFS4_STATEID_OTHER_SIZE))
                return 0;
 
        return 1;
index 6c0406e87d5cd8793bd72986c32122b35c8d9156..34da32436ac03c09f2aebacbc7161d31edf6ae0c 100644 (file)
@@ -17,7 +17,9 @@
 
 #define NFS4_BITMAP_SIZE       2
 #define NFS4_VERIFIER_SIZE     8
-#define NFS4_STATEID_SIZE      16
+#define NFS4_STATEID_SEQID_SIZE 4
+#define NFS4_STATEID_OTHER_SIZE 12
+#define NFS4_STATEID_SIZE      (NFS4_STATEID_SEQID_SIZE + NFS4_STATEID_OTHER_SIZE)
 #define NFS4_FHSIZE            128
 #define NFS4_MAXPATHLEN                PATH_MAX
 #define NFS4_MAXNAMLEN         NAME_MAX
@@ -167,7 +169,16 @@ struct nfs4_acl {
 };
 
 typedef struct { char data[NFS4_VERIFIER_SIZE]; } nfs4_verifier;
-typedef struct { char data[NFS4_STATEID_SIZE]; } nfs4_stateid;
+
+struct nfs41_stateid {
+       __be32 seqid;
+       char other[NFS4_STATEID_OTHER_SIZE];
+} __attribute__ ((packed));
+
+typedef union {
+       char data[NFS4_STATEID_SIZE];
+       struct nfs41_stateid stateid;
+} nfs4_stateid;
 
 enum nfs_opnum4 {
        OP_ACCESS = 3,