aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/pnfs.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2011-02-28 20:34:21 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2011-03-11 15:38:43 -0500
commitea8eecdd11ee6becd09c095c8efa88aa7df95961 (patch)
tree4db9c584989d006790637e255657a010c8243cb9 /fs/nfs/pnfs.h
parentcbdabc7f8bf14ca1d40ab1cb86f64b3bc09716e8 (diff)
NFSv4.1 move deviceid cache to filelayout driver
No need for generic cache with only one user. Keep a simple hash of deviceids in the filelayout driver. Signed-off-by: Christoph Hellwig <hch@infradead.org> Acked-by: Andy Adamson <andros@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/pnfs.h')
-rw-r--r--fs/nfs/pnfs.h48
1 files changed, 0 insertions, 48 deletions
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 585023fabb55..acbb77802075 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -68,8 +68,6 @@ struct pnfs_layoutdriver_type {
68 const u32 id; 68 const u32 id;
69 const char *name; 69 const char *name;
70 struct module *owner; 70 struct module *owner;
71 int (*set_layoutdriver) (struct nfs_server *);
72 int (*clear_layoutdriver) (struct nfs_server *);
73 struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_hdr *layoutid, struct nfs4_layoutget_res *lgr); 71 struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_hdr *layoutid, struct nfs4_layoutget_res *lgr);
74 void (*free_lseg) (struct pnfs_layout_segment *lseg); 72 void (*free_lseg) (struct pnfs_layout_segment *lseg);
75 73
@@ -106,52 +104,6 @@ struct pnfs_device {
106 unsigned int pglen; 104 unsigned int pglen;
107}; 105};
108 106
109/*
110 * Device ID RCU cache. A device ID is unique per client ID and layout type.
111 */
112#define NFS4_DEVICE_ID_HASH_BITS 5
113#define NFS4_DEVICE_ID_HASH_SIZE (1 << NFS4_DEVICE_ID_HASH_BITS)
114#define NFS4_DEVICE_ID_HASH_MASK (NFS4_DEVICE_ID_HASH_SIZE - 1)
115
116static inline u32
117nfs4_deviceid_hash(struct nfs4_deviceid *id)
118{
119 unsigned char *cptr = (unsigned char *)id->data;
120 unsigned int nbytes = NFS4_DEVICEID4_SIZE;
121 u32 x = 0;
122
123 while (nbytes--) {
124 x *= 37;
125 x += *cptr++;
126 }
127 return x & NFS4_DEVICE_ID_HASH_MASK;
128}
129
130struct pnfs_deviceid_node {
131 struct hlist_node de_node;
132 struct nfs4_deviceid de_id;
133 atomic_t de_ref;
134};
135
136struct pnfs_deviceid_cache {
137 spinlock_t dc_lock;
138 atomic_t dc_ref;
139 void (*dc_free_callback)(struct pnfs_deviceid_node *);
140 struct hlist_head dc_deviceids[NFS4_DEVICE_ID_HASH_SIZE];
141};
142
143extern int pnfs_alloc_init_deviceid_cache(struct nfs_client *,
144 void (*free_callback)(struct pnfs_deviceid_node *));
145extern void pnfs_put_deviceid_cache(struct nfs_client *);
146extern struct pnfs_deviceid_node *pnfs_find_get_deviceid(
147 struct pnfs_deviceid_cache *,
148 struct nfs4_deviceid *);
149extern struct pnfs_deviceid_node *pnfs_add_deviceid(
150 struct pnfs_deviceid_cache *,
151 struct pnfs_deviceid_node *);
152extern void pnfs_put_deviceid(struct pnfs_deviceid_cache *c,
153 struct pnfs_deviceid_node *devid);
154
155extern int pnfs_register_layoutdriver(struct pnfs_layoutdriver_type *); 107extern int pnfs_register_layoutdriver(struct pnfs_layoutdriver_type *);
156extern void pnfs_unregister_layoutdriver(struct pnfs_layoutdriver_type *); 108extern void pnfs_unregister_layoutdriver(struct pnfs_layoutdriver_type *);
157 109