[pnfs] [PATCH] update exchange id reply to draft 9

Marc Eshel eshel at almaden.ibm.com
Thu Mar 8 02:33:50 EST 2007


This is a replacement to the last patch based on the discussion we had in 
the last meeting.
Marc.

pnfs-bounces at linux-nfs.org wrote on 03/07/2007 11:18:39 PM:

> From: Marc Eshel <eshel at almaden.ibm.com>
> 
> Leave NFS4_OPAQUE_LIMIT unchanged use NFS4_NAME_LIMIT 256 to limit some
> names that the client will produce or accept.
> ---
> 
>  fs/nfs/nfs4xdr.c           |   42 
+++++++++++++++++++++++++++++++++++++-----
>  fs/nfsd/nfs4state.c        |    3 ++-
>  fs/nfsd/nfs4xdr.c          |   21 ++++++++++++++++++++-
>  include/linux/nfs4.h       |    3 ++-
>  include/linux/nfs_xdr.h    |   12 +++++++-----
>  include/linux/nfsd/state.h |    1 -
>  include/linux/nfsd/xdr4.h  |    6 ------
>  7 files changed, 68 insertions(+), 20 deletions(-)
> 
> diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
> index 5c4363f..8c35829 100644
> --- a/fs/nfs/nfs4xdr.c
> +++ b/fs/nfs/nfs4xdr.c
> @@ -144,11 +144,10 @@ #define decode_delegreturn_maxsz (op_dec
>  #define encode_sequence_maxsz    (op_encode_hdr_maxsz + 4 + 1 + 1 + 1)
>  #define decode_sequence_maxsz    (op_decode_hdr_maxsz + 4 + 1 + 1 +1 + 
1 + 1)
>  #define encode_exchange_id_maxsz   (op_encode_hdr_maxsz + 4 + 1 + 6 + 6 
+ \
> -               (NFS4_VERIFIER_SIZE >> 2)) + 10 + \
> -               ((3 * NFS4_OPAQUE_LIMIT) >> 2)
> +               (NFS4_VERIFIER_SIZE >> 2) + 10 + \
> +               ((3 * NFS4_OPAQUE_LIMIT) >> 2))
>  #define decode_exchange_id_maxsz   (op_decode_hdr_maxsz + 2 + 1 + 2 + 1 
+ \
> -                  (NFS4_OPAQUE_LIMIT >> 2) + 1 + \
> -                  (NFS4_OPAQUE_LIMIT >> 2))
> +               ((4 * NFS4_OPAQUE_LIMIT) >> 2) + 7)
>  #define encode_create_session_maxsz   (op_encode_hdr_maxsz + 2 + 1 
> + 1 + 1 + \
>                       1 + 1 + 1 + 1 + \
>                    (NFS4_VERIFIER_SIZE >> 2) + \
> @@ -5028,6 +5027,9 @@ static int decode_exchange_id(struct xdr
>     READ_BUF(4);
>     READ32(clp->cl_session->seqid);
> 
> +   READ_BUF(4);
> +   READ32(res->flags);
> + 
>     /* server_owner */
>     /* minor_id */
>     READ_BUF(8);
> @@ -5037,13 +5039,43 @@ static int decode_exchange_id(struct xdr
>     READ_BUF(4);
>     READ32(res->server_owner.major_id_sz);
>     READ_BUF(res->server_owner.major_id_sz);
> -   COPYMEM(res->server_owner.major_id, res->server_owner.major_id_sz);
> +   if (res->server_owner.major_id_sz < NFS4_NAME_LIMIT)
> +      COPYMEM(res->server_owner.major_id, 
res->server_owner.major_id_sz);
> +   else {
> +      COPYMEM(res->server_owner.major_id, NFS4_NAME_LIMIT);
> +      p += XDR_QUADLEN(res->server_owner.major_id_sz - 
NFS4_NAME_LIMIT);
> +      res->server_owner.major_id_sz = NFS4_NAME_LIMIT;
> +   }
> 
>     /* server_scope */
>     READ_BUF(4);
>     READ32(res->server_scope.server_scope_sz);
>     READ_BUF(res->server_scope.server_scope_sz);
>     COPYMEM(res->server_scope.server_scope, res->server_scope.
> server_scope_sz);
> +   /* implementation id */
> +   READ_BUF(4);
> +   READ32(res->impl_id.domain_len);
> +   READ_BUF(res->impl_id.domain_len);
> +   if (res->impl_id.domain_len < NFS4_NAME_LIMIT)
> +      COPYMEM(res->impl_id.domain, res->impl_id.domain_len);
> +   else {
> +      COPYMEM(res->impl_id.domain, NFS4_NAME_LIMIT);
> +      p += XDR_QUADLEN(res->impl_id.domain_len - NFS4_NAME_LIMIT);
> +      res->impl_id.domain_len = NFS4_NAME_LIMIT;
> +   }
> +   READ_BUF(4);
> +   READ32(res->impl_id.name_len);
> +   READ_BUF(res->impl_id.name_len);
> +   if (res->impl_id.name_len < NFS4_NAME_LIMIT)
> +      COPYMEM(res->impl_id.name, res->impl_id.name_len);
> +   else {
> +      COPYMEM(res->impl_id.name, NFS4_NAME_LIMIT);
> +      p += XDR_QUADLEN(res->impl_id.name_len - NFS4_NAME_LIMIT);
> +      res->impl_id.name_len = NFS4_NAME_LIMIT;
> +   }
> +   READ_BUF(12);
> +   READ64(res->impl_id.date.seconds);
> +   READ32(res->impl_id.date.nseconds);
> 
>     return 0;
>  }
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 6e3c73a..4261b8c 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -665,7 +665,7 @@ check_name(struct xdr_netobj name) {
> 
>     if (name.len == 0) 
>        return 0;
> -   if (name.len > NFS4_OPAQUE_LIMIT) {
> +   if (name.len > NFS4_NAME_LIMIT) {
>        printk("NFSD: check_name: name too long(%d)!\n", name.len);
>        return 0;
>     }
> @@ -1122,6 +1122,7 @@ out_copy:
> 
>          new->cl_seqid = clid->seqid = 1;
>          new->cl_exchange_flags = clid->flags;
> +        clid->flags = EXCHGID4_FLAG_USE_PNFS_MDS;
> 
>     dprintk("nfsd4_exchange_id seqid %d flags %x\n",
>              new->cl_seqid, new->cl_exchange_flags);
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index b2b3ad6..6c3025e 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -2711,8 +2711,12 @@ nfsd4_encode_exchange_id(struct nfsd4_co
>          ENCODE_HEAD;
>          char major_id[] = "fixme_please!";
>          char server_scope[] = "fixme_please!";
> +        char domain[] = "fixme_please!";
> +        char name[] = "fixme_please!";
>          int major_id_sz;
>          int server_scope_sz;
> +        int domain_sz;
> +        int name_sz;
>          uint64_t minor_id = 0;
> 
>          /* XXX FIXME We currently use ia dummy  as the major id. 
> Need to change
> @@ -2721,11 +2725,15 @@ nfsd4_encode_exchange_id(struct nfsd4_co
>          if (!nfserr) {
>                  major_id_sz = strlen(major_id);
>                  server_scope_sz = strlen(server_scope);
> +                domain_sz = strlen(domain);
> +                name_sz = strlen(name);
> 
> -                RESERVE_SPACE(8 + 4 + 8 + 4 + major_id_sz + 4 + 
> server_scope_sz);
> +      RESERVE_SPACE(8+4+4+8+4+major_id_sz+4+server_scope_sz);
>                  WRITEMEM(&clid->clientid, 8);
>                  WRITE32(clid->seqid);
> 
> +      WRITE32(clid->flags);
> +
>                  /* The server_owner struct */
>                  WRITE64(minor_id);      /* Minor id */
>                  /* major id */
> @@ -2736,6 +2744,17 @@ nfsd4_encode_exchange_id(struct nfsd4_co
>                  WRITE32(server_scope_sz);
>                  WRITEMEM(server_scope, server_scope_sz);
>                  ADJUST_ARGS();
> +
> +      /* Implementation id */
> +      RESERVE_SPACE(4+domain_sz+4+name_sz+8+4);
> +      WRITE32(domain_sz);
> +      WRITEMEM(domain, domain_sz);
> +      WRITE32(name_sz);
> +      WRITEMEM(name, name_sz);
> +      WRITE64(clid->impl_id.date.seconds);
> +      WRITE32(clid->impl_id.date.nseconds);
> +
> +                ADJUST_ARGS();
>          }
> 
>  }
> diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h
> index 6be5ab7..f709518 100644
> --- a/include/linux/nfs4.h
> +++ b/include/linux/nfs4.h
> @@ -19,7 +19,8 @@ #define NFS4_VERIFIER_SIZE   8
>  #define NFS4_FHSIZE      128
>  #define NFS4_MAXPATHLEN      PATH_MAX
>  #define NFS4_MAXNAMLEN      NAME_MAX
> -#define NFS4_OPAQUE_LIMIT       1024
> +#define NFS4_OPAQUE_LIMIT   1024
> +#define NFS4_NAME_LIMIT      256
>  #define NFS4_MAX_SESSIONID_LEN  16
> 
>  #define NFS4_ACCESS_READ        0x0001
> diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
> index 9310e9f..db3984b 100644
> --- a/include/linux/nfs_xdr.h
> +++ b/include/linux/nfs_xdr.h
> @@ -758,9 +758,9 @@ struct nfstime4 {
> 
>  struct nfs_impl_id4 {
>     u32      domain_len;
> -   char       domain[NFS4_OPAQUE_LIMIT];
> +   char       domain[NFS4_NAME_LIMIT];
>     u32      name_len;
> -   char       name[NFS4_OPAQUE_LIMIT];
> +   char       name[NFS4_NAME_LIMIT];
>     struct nfstime4   date;
>  };
> 
> @@ -773,7 +773,7 @@ #define EXCHGID4_FLAG_USE_PNFS_DS   0x0004
>  struct nfs41_exchange_id_args {
>     nfs4_verifier *         verifier;
>     unsigned int          id_len;
> -   char             id[NFS4_OPAQUE_LIMIT];
> +   char             id[NFS4_NAME_LIMIT];
>     u32            flags;
>     struct nfs_impl_id4      impl_id;
>     clientid4         clientid;
> @@ -783,18 +783,20 @@ struct nfs41_exchange_id_args {
>  struct server_owner {
>     uint64_t         minor_id;
>     uint32_t         major_id_sz;
> -   char            major_id[NFS4_OPAQUE_LIMIT];
> +   char            major_id[NFS4_NAME_LIMIT];
>  };
> 
>  struct server_scope {
>     uint32_t         server_scope_sz;
> -   char             server_scope[NFS4_OPAQUE_LIMIT];
> +   char             server_scope[NFS4_NAME_LIMIT];
>  };
> 
>  struct nfs41_exchange_id_res {
>     struct nfs4_client *      client;
> +   u32            flags;
>     struct server_owner      server_owner;
>     struct server_scope      server_scope;
> +   struct nfs_impl_id4      impl_id;
>  };
> 
>  struct nfs41_create_session_args {
> diff --git a/include/linux/nfsd/state.h b/include/linux/nfsd/state.h
> index 95cd3fd..9b5c094 100644
> --- a/include/linux/nfsd/state.h
> +++ b/include/linux/nfsd/state.h
> @@ -44,7 +44,6 @@ #include <linux/sunrpc/clnt.h>
> 
>  #define CONFIG_PNFS   1
> 
> -#define NFS4_OPAQUE_LIMIT 1024
>  typedef struct {
>     u32             cl_boot;
>     u32             cl_id;
> diff --git a/include/linux/nfsd/xdr4.h b/include/linux/nfsd/xdr4.h
> index ee72699..d937b9f 100644
> --- a/include/linux/nfsd/xdr4.h
> +++ b/include/linux/nfsd/xdr4.h
> @@ -343,12 +343,6 @@ struct impl_id4 {
>     struct nfstime4   date;
>  };
> 
> -#define EXCHGID4_FLAG_SUPP_MOVED_REFER   0x00000001
> -#define EXCHGID4_FLAG_SUPP_MOVED_MIGR   0x00000002
> -#define EXCHGID4_FLAG_USE_NON_PNFS   0x00010000
> -#define EXCHGID4_FLAG_USE_PNFS_MDS   0x00020000
> -#define EXCHGID4_FLAG_USE_PNFS_DS   0x00040000
> -
>  struct nfsd4_exchange_id {
>     nfs4_verifier      verifier;
>     u32         id_len;
> _______________________________________________
> pNFS mailing list
> pNFS at linux-nfs.org
> http://linux-nfs.org/cgi-bin/mailman/listinfo/pnfs



More information about the pNFS mailing list