[pnfs] [PATCH] move shared nfs41 types to include/linux/nfs4.h
William A. (Andy) Adamson
andros at citi.umich.edu
Thu Apr 19 13:54:00 EDT 2007
hi benny
this patch contains some changes for the 4.1-sessions branch (typing the
sessionid, etc)
and some changes for the master branch (pnfs use of new sessionid)
please separate the changes.
On 4/16/07, Benny Halevy <bhalevy at panasas.com> wrote:
>
> move shared nfs41 types to include/linux/nfs4.h
>
> sessionid_t and pnfs enums were defined both in
> include/linux/nfsd/state.h and in include/linux/nfs41_sessions.h
> This patch moves the enums and introduces a "generic" definition
> of nfs41_sessionid in nfs4.h as well as defining nfsd_sessionid_t
> in nfsd/state.h as the formatted version of the sessionid as
> used by the nfsd.
>
> diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
> index 37ca48d..b2d0d45 100644
> --- a/fs/nfs/pnfs.c
> +++ b/fs/nfs/pnfs.c
> @@ -42,6 +42,7 @@
> #include <linux/nfs_fs.h>
> #include <linux/nfs_mount.h>
> #include <linux/nfs_page.h>
> +#include <linux/nfs4.h>
> #include <linux/nfs4_pnfs.h>
>
> #include "nfs4_fs.h"
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index 283f97a..500446a 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -815,7 +815,8 @@ nfsd4_layoutget( struct svc_rqst *rqstp, struct
> current_session *cses, struct sv
>
> /* Set file handle and clientid*/
> memcpy(&lgp->lg_fh, ¤t_fh->fh_handle, sizeof(struct
> knfsd_fh));
> - memcpy(&lgp->lg_clientid, cses->cs_sid, sizeof(clientid_t));
> + memcpy(&lgp->lg_clientid, &cses->cs_sid.clientid,
> + sizeof(lgp->lg_clientid));
>
> status = nfs4_pnfs_get_layout(sb, current_fh, lgp);
> out:
> @@ -916,7 +917,8 @@ nfsd4_layoutreturn( struct svc_rqst *rqstp, struct
> current_session *cses, struct
> }
>
> /* Set clientid from sessionid */
> - memcpy(&lrp->lr_clientid, cses->cs_sid, sizeof(clientid_t));
> + memcpy(&lrp->lr_clientid, &cses->cs_sid.clientid,
> + sizeof(lrp->lr_clientid));
> status = nfs4_pnfs_return_layout(sb, current_fh, lrp);
> out:
> dprintk("pNFS %s: status %d layout_type %d\n",
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 5a41e70..93ad31a 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -354,19 +354,19 @@ nfs41_set_slot_state(struct nfs41_slot *slot, int
> state)
> atomic_set(&slot->sl_state, state);
> }
>
> -static int hash_sessionid(sessionid_t *sessionid)
> +static int hash_sessionid(nfs41_sessionid *sessionid)
> {
> u32 csum = 0;
> int idx;
>
> - csum = crc32(0, sessionid, sizeof(sessionid_t));
> + csum = crc32(0, sessionid, sizeof(nfs41_sessionid));
> idx = csum % SESSION_HASH_SIZE;
> dprintk("%s IDX: %u csum %u\n", __FUNCTION__, idx, csum);
> return idx;
> }
>
> void
> -dump_sessionid(const char *fn, sessionid_t *sessionid)
> +dump_sessionid(const char *fn, nfs41_sessionid *sessionid)
> {
> u32 *ptr;
>
> @@ -416,7 +416,7 @@ alloc_init_session(struct nfs4_client *clp, struct
> nfsd4_create_session *cses)
> new->se_client = clp;
> gen_sessionid(new);
> idx = hash_sessionid(&new->se_sessionid);
> - memcpy(&clp->cl_sessionid, &new->se_sessionid,
> sizeof(sessionid_t));
> + memcpy(&clp->cl_sessionid, &new->se_sessionid,
> sizeof(nfs41_sessionid));
>
> /* for now, accept the client values */
> new->se_fmaxreq_sz = cses->fore_channel.maxreq_sz;
> @@ -440,7 +440,7 @@ out_free:
> }
>
> struct nfs41_session*
> -find_in_sessionid_hashtbl(sessionid_t *sessionid)
> +find_in_sessionid_hashtbl(nfs41_sessionid *sessionid)
> {
> struct nfs41_session *elem;
> int idx;
> @@ -452,7 +452,8 @@ find_in_sessionid_hashtbl(sessionid_t *sessionid)
> /* Search in the appropriate list */
> list_for_each_entry(elem, &sessionid_hashtbl[idx], se_hash) {
> dump_sessionid("list traversal", &elem->se_sessionid);
> - if (!memcmp(elem->se_sessionid, sessionid,
> sizeof(sessionid_t))) {
> + if (!memcmp(elem->se_sessionid, sessionid,
> + sizeof(nfs41_sessionid))) {
> found = 1;
> break;
> }
> @@ -2333,7 +2334,8 @@ set_curr_ses:
> /* Set current_session. hold reference until done processing
> compound.
> * nfs41_put_session called only if cs_slot is set
> */
> - memcpy(c_ses->cs_sid, &seq->sessionid, sizeof(sessionid_t));
> + memcpy(&c_ses->cs_sid, &seq->sessionid, sizeof(c_ses->cs_sid));
> + COMPILE_BUG_ON(sizeof(c_ses->cs_sid) == sizeof(seq->sessionid));
> c_ses->cs_slot = slot;
> nfs41_get_session(slot->sl_session);
>
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index f5dc8cf..1c8f1f3 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -1,5 +1,5 @@
> /*
> - * fs/nfs/nfs4xdr.c
> + * fs/nfsd/nfs4xdr.c
> *
> * Server-side XDR for NFSv4
> *
> diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h
> index b03614a..d5cdd15 100644
> --- a/include/linux/nfs4.h
> +++ b/include/linux/nfs4.h
> @@ -13,6 +13,8 @@
> #ifndef _LINUX_NFS4_H
> #define _LINUX_NFS4_H
>
> +#define CONFIG_PNFS 1
> +
> #include <linux/types.h>
>
> #define NFS4_VERIFIER_SIZE 8
> @@ -449,6 +451,29 @@ enum {
> NFSPROC4_CLNT_GET_LEASE_TIME,
> };
>
> +typedef unsigned char nfs41_sessionid[16];
> +
> +#ifdef CONFIG_PNFS
> +enum pnfs_layouttype {
> + LAYOUT_NFSV4_FILES = 1,
> + LAYOUT_OSD2_OBJECTS = 2,
> + LAYOUT_BLOCK_VOLUME = 3,
> + LAYOUT_PVFS2 = 4
> +};
> +
> +enum pnfs_layoutreturn_type {
> + LAYOUTRETURN_FILE = 1,
> + LAYOUTRETURN_FSID = 2,
> + LAYOUTRETURN_ALL = 3,
> +};
> +
> +enum pnfs_iomode {
> + IOMODE_READ = 1,
> + IOMODE_RW = 2,
> + IOMODE_ANY = 3,
> +};
> +#endif /* CONFIG_PNFS */
> +
> #endif
> #endif
>
> diff --git a/include/linux/nfs41_sessions.h
> b/include/linux/nfs41_sessions.h
> index 352fae8..e0929b7 100644
> --- a/include/linux/nfs41_sessions.h
> +++ b/include/linux/nfs41_sessions.h
> @@ -1,12 +1,13 @@
> #ifndef __NFS4_1_SESSIONS_H__
> #define __NFS4_1_SESSIONS_H__
>
> +#include <linux/nfs4.h>
> +
> /* The flags for the nfs4_slot struct */
> #define NFS4_SLOT_BUSY 0X0 /* Slot in use */
> #define NFS4_SLOT_RECLAIMED 0x1 /* Slot has been reclaimed by
> the server */
>
> -typedef unsigned char sessionid_t[16];
> typedef u32 streamchannel_attrs;
> typedef u32 rdmachannel_attrs;
>
> @@ -41,7 +42,7 @@ struct nfs4_channel {
>
> struct nfs4_session {
> /* Session related params */
> - sessionid_t sess_id;
> + nfs41_sessionid sess_id;
> u32 seqid; /* The seqid returned by
> exchange_id */
> u32 persist;
> diff --git a/include/linux/nfs4_pnfs.h b/include/linux/nfs4_pnfs.h
> index 110e5a9..74d25fd 100644
> --- a/include/linux/nfs4_pnfs.h
> +++ b/include/linux/nfs4_pnfs.h
> @@ -170,13 +170,6 @@ void pnfs_unregister_layoutdriver(struct
> pnfs_layoutdriver_type *);
> #define NFS4_PNFS_MAX_LAYOUTS 4
> #define NFS4_PNFS_PRIVATE_LAYOUT 0x80000000
>
> -enum pnfs_layouttype4 {
> - LAYOUT_NFSV4_FILES = 1,
> - LAYOUT_OSD2_OBJECTS = 2,
> - LAYOUT_BLOCK_VOLUME = 3,
> - LAYOUT_PVFS2 = 4
> -};
> -
> enum file_layout_device_type {
> FILE_SIMPLE = 1,
> FILE_COMPLEX = 2
> diff --git a/include/linux/nfsd/state.h b/include/linux/nfsd/state.h
> index 52851e5..e095d1f 100644
> --- a/include/linux/nfsd/state.h
> +++ b/include/linux/nfsd/state.h
> @@ -40,15 +40,19 @@
> #include <linux/list.h>
> #include <linux/kref.h>
> #include <linux/sunrpc/clnt.h>
> -
> -#define CONFIG_PNFS 1
> +#include <linux/nfs4.h>
>
> typedef struct {
> u32 cl_boot;
> u32 cl_id;
> } clientid_t;
>
> -typedef unsigned char sessionid_t[16];
> +/* formatted contents of nfs41_sessionid */
> +typedef struct {
> + clientid_t clientid;
> + u32 boot_time;
> + u32 sequence;
> +} nfsd_sessionid_t;
>
> typedef struct {
> u32 so_boot;
> @@ -140,14 +144,14 @@ struct nfs41_slot {
> };
>
> /*
> - * nfs41_sessionid
> + * nfs41_session
> */
> struct nfs41_session {
> struct kref se_ref;
> struct list_head se_hash; /* hash by sessionid_t */
> struct list_head se_perclnt;
> struct nfs4_client *se_client; /* for expire_client */
> - sessionid_t se_sessionid;
> + nfs41_sessionid se_sessionid;
> struct nfs41_channel se_forward;
> struct nfs41_slot *se_slots; /* forward channel slots
> */
> };
> @@ -172,7 +176,7 @@ nfs41_get_session(struct nfs41_session *ses)
> }
>
> struct current_session {
> - sessionid_t cs_sid;
> + nfsd_sessionid_t cs_sid;
> struct nfs41_slot *cs_slot;
> };
>
> @@ -209,7 +213,7 @@ struct nfs4_client {
> u32 cl_firststate; /* recovery dir creation
> */
> /* NFSv4.1 create_session slot */
> u32 cl_seqid; /* seqid for
> create_session */
> - sessionid_t cl_sessionid; /* prev create_sessions id
> */
> + nfs41_sessionid cl_sessionid; /* prev create_sessions id
> */
> u32 cl_exchange_flags;
> u32 cl_session_flags;
> };
> @@ -356,19 +360,6 @@ struct nfs4_file {
>
> #ifdef CONFIG_PNFS
>
> -enum pnfs_layouttype4 {
> - LAYOUT_NFSV4_FILES = 1,
> - LAYOUT_OSD2_OBJECTS = 2,
> - LAYOUT_BLOCK_VOLUME = 3,
> - LAYOUT_PVFS2 = 4
> -};
> -
> -enum layoutreturn_type {
> - LAYOUTRETURN_FILE = 1,
> - LAYOUTRETURN_FSID = 2,
> - LAYOUTRETURN_ALL = 3,
> -};
> -
> /* pNFS Metadata server state */
>
> struct pnfs_ds_dev_entry {
> diff --git a/include/linux/nfsd/xdr4.h b/include/linux/nfsd/xdr4.h
> index b2a329c..20e5e38 100644
> --- a/include/linux/nfsd/xdr4.h
> +++ b/include/linux/nfsd/xdr4.h
> @@ -357,24 +357,24 @@ struct nfsd4_channel {
> };
>
> struct nfsd4_create_session {
> - clientid_t clientid;
> - sessionid_t sessionid;
> - u32 seqid;
> - u32 header_padding;
> - struct nfsd4_channel fore_channel;
> - struct nfsd4_channel back_channel;
> - u32 callback_prog;
> - u32 uid;
> - u32 gid;
> + clientid_t clientid;
> + nfs41_sessionid sessionid;
> + u32 seqid;
> + u32 header_padding;
> + struct nfsd4_channel fore_channel;
> + struct nfsd4_channel back_channel;
> + u32 callback_prog;
> + u32 uid;
> + u32 gid;
> };
>
> struct nfsd4_sequence {
> - sessionid_t sessionid;
> - u32 seqid;
> - u32 slotid;
> - u32 maxslots;
> - u32 target_maxslots;
> - u32 status_flags;
> + nfs41_sessionid sessionid;
> + u32 seqid;
> + u32 slotid;
> + u32 maxslots;
> + u32 target_maxslots;
> + u32 status_flags;
> };
>
> struct nfsd4_destroy_session {
> @@ -378,7 +394,7 @@ struct nfsd4_sequence {
> };
>
> struct nfsd4_destroy_session {
> - sessionid_t sessionid;
> + nfs41_sessionid sessionid;
> };
>
> struct nfsd4_op {
> diff --git a/include/linux/pnfs_xdr.h b/include/linux/pnfs_xdr.h
> index 5ae15e3..09aa69e 100644
> --- a/include/linux/pnfs_xdr.h
> +++ b/include/linux/pnfs_xdr.h
> @@ -17,23 +17,11 @@
> #define PNFS_LAYOUT_MAXSIZE 4096
> #define PNFS_MAX_NUM_LAYOUT_TYPES 2
>
> -enum layoutreturn_type {
> - LAYOUTRETURN_FILE = 1,
> - LAYOUTRETURN_FSID = 2,
> - LAYOUTRETURN_ALL = 3,
> -};
> -
> struct nfs4_pnfs_layout {
> __u32 len;
> void *buf;
> };
>
> -enum pnfs_iomode {
> - IOMODE_READ = 1,
> - IOMODE_RW = 2,
> - IOMODE_ANY = 3,
> -};
> -
> struct nfs4_pnfs_layoutget_arg {
> __u32 type;
> __u32 iomode;
> _______________________________________________
> pNFS mailing list
> pNFS at linux-nfs.org
> http://linux-nfs.org/cgi-bin/mailman/listinfo/pnfs
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://linux-nfs.org/pipermail/pnfs/attachments/20070419/af93c08c/attachment-0001.htm
More information about the pNFS
mailing list