Skip to content

Commit 35c8bb5

Browse files
Benny HalevyBoaz Harrosh
authored andcommitted
NFSv4.1: use layout driver in global device cache
pnfs deviceids are unique per server, per layout type. struct nfs_client is currently used to distinguish deviceids from different nfs servers, yet these may clash between different layout types on the same server. Therefore, use the layout driver associated with each deviceid at insertion time to look it up, unhash, or delete it. Signed-off-by: Benny Halevy <bhalevy@panasas.com>
1 parent 1be5683 commit 35c8bb5

4 files changed

Lines changed: 23 additions & 16 deletions

File tree

‎fs/nfs/callback_proc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ __be32 nfs4_callback_devicenotify(struct cb_devicenotifyargs *args,
278278
if (dev->cbd_notify_type == NOTIFY_DEVICEID4_CHANGE)
279279
dprintk("%s: NOTIFY_DEVICEID4_CHANGE not supported, "
280280
"deleting instead\n", __func__);
281-
nfs4_delete_deviceid(clp, &dev->cbd_dev_id);
281+
nfs4_delete_deviceid(server->pnfs_curr_ld, clp, &dev->cbd_dev_id);
282282
}
283283

284284
out:

‎fs/nfs/nfs4filelayout.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,8 @@ filelayout_check_layout(struct pnfs_layout_hdr *lo,
441441
}
442442

443443
/* find and reference the deviceid */
444-
d = nfs4_find_get_deviceid(NFS_SERVER(lo->plh_inode)->nfs_client, id);
444+
d = nfs4_find_get_deviceid(NFS_SERVER(lo->plh_inode)->pnfs_curr_ld,
445+
NFS_SERVER(lo->plh_inode)->nfs_client, id);
445446
if (d == NULL) {
446447
dsaddr = get_device_info(lo->plh_inode, id, gfp_flags);
447448
if (dsaddr == NULL)

‎fs/nfs/pnfs.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ struct nfs4_deviceid_node {
171171
};
172172

173173
void nfs4_print_deviceid(const struct nfs4_deviceid *dev_id);
174-
struct nfs4_deviceid_node *nfs4_find_get_deviceid(const struct nfs_client *, const struct nfs4_deviceid *);
175-
struct nfs4_deviceid_node *nfs4_unhash_put_deviceid(const struct nfs_client *, const struct nfs4_deviceid *);
176-
void nfs4_delete_deviceid(const struct nfs_client *, const struct nfs4_deviceid *);
174+
struct nfs4_deviceid_node *nfs4_find_get_deviceid(const struct pnfs_layoutdriver_type *, const struct nfs_client *, const struct nfs4_deviceid *);
175+
struct nfs4_deviceid_node *nfs4_unhash_put_deviceid(const struct pnfs_layoutdriver_type *, const struct nfs_client *, const struct nfs4_deviceid *);
176+
void nfs4_delete_deviceid(const struct pnfs_layoutdriver_type *, const struct nfs_client *, const struct nfs4_deviceid *);
177177
void nfs4_init_deviceid_node(struct nfs4_deviceid_node *,
178178
const struct pnfs_layoutdriver_type *,
179179
const struct nfs_client *,

‎fs/nfs/pnfs_dev.c‎

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,16 @@ nfs4_deviceid_hash(const struct nfs4_deviceid *id)
6767
}
6868

6969
static struct nfs4_deviceid_node *
70-
_lookup_deviceid(const struct nfs_client *clp, const struct nfs4_deviceid *id,
70+
_lookup_deviceid(const struct pnfs_layoutdriver_type *ld,
71+
const struct nfs_client *clp, const struct nfs4_deviceid *id,
7172
long hash)
7273
{
7374
struct nfs4_deviceid_node *d;
7475
struct hlist_node *n;
7576

7677
hlist_for_each_entry_rcu(d, n, &nfs4_deviceid_cache[hash], node)
77-
if (d->nfs_client == clp && !memcmp(&d->deviceid, id, sizeof(*id))) {
78+
if (d->ld == ld && d->nfs_client == clp &&
79+
!memcmp(&d->deviceid, id, sizeof(*id))) {
7880
if (atomic_read(&d->ref))
7981
return d;
8082
else
@@ -90,23 +92,25 @@ _lookup_deviceid(const struct nfs_client *clp, const struct nfs4_deviceid *id,
9092
* @id deviceid to look up
9193
*/
9294
struct nfs4_deviceid_node *
93-
_find_get_deviceid(const struct nfs_client *clp, const struct nfs4_deviceid *id,
95+
_find_get_deviceid(const struct pnfs_layoutdriver_type *ld,
96+
const struct nfs_client *clp, const struct nfs4_deviceid *id,
9497
long hash)
9598
{
9699
struct nfs4_deviceid_node *d;
97100

98101
rcu_read_lock();
99-
d = _lookup_deviceid(clp, id, hash);
102+
d = _lookup_deviceid(ld, clp, id, hash);
100103
if (d && !atomic_inc_not_zero(&d->ref))
101104
d = NULL;
102105
rcu_read_unlock();
103106
return d;
104107
}
105108

106109
struct nfs4_deviceid_node *
107-
nfs4_find_get_deviceid(const struct nfs_client *clp, const struct nfs4_deviceid *id)
110+
nfs4_find_get_deviceid(const struct pnfs_layoutdriver_type *ld,
111+
const struct nfs_client *clp, const struct nfs4_deviceid *id)
108112
{
109-
return _find_get_deviceid(clp, id, nfs4_deviceid_hash(id));
113+
return _find_get_deviceid(ld, clp, id, nfs4_deviceid_hash(id));
110114
}
111115
EXPORT_SYMBOL_GPL(nfs4_find_get_deviceid);
112116

@@ -119,13 +123,14 @@ EXPORT_SYMBOL_GPL(nfs4_find_get_deviceid);
119123
* @ret the unhashed node, if found and dereferenced to zero, NULL otherwise.
120124
*/
121125
struct nfs4_deviceid_node *
122-
nfs4_unhash_put_deviceid(const struct nfs_client *clp, const struct nfs4_deviceid *id)
126+
nfs4_unhash_put_deviceid(const struct pnfs_layoutdriver_type *ld,
127+
const struct nfs_client *clp, const struct nfs4_deviceid *id)
123128
{
124129
struct nfs4_deviceid_node *d;
125130

126131
spin_lock(&nfs4_deviceid_lock);
127132
rcu_read_lock();
128-
d = _lookup_deviceid(clp, id, nfs4_deviceid_hash(id));
133+
d = _lookup_deviceid(ld, clp, id, nfs4_deviceid_hash(id));
129134
rcu_read_unlock();
130135
if (!d) {
131136
spin_unlock(&nfs4_deviceid_lock);
@@ -150,11 +155,12 @@ EXPORT_SYMBOL_GPL(nfs4_unhash_put_deviceid);
150155
* @id deviceid to delete
151156
*/
152157
void
153-
nfs4_delete_deviceid(const struct nfs_client *clp, const struct nfs4_deviceid *id)
158+
nfs4_delete_deviceid(const struct pnfs_layoutdriver_type *ld,
159+
const struct nfs_client *clp, const struct nfs4_deviceid *id)
154160
{
155161
struct nfs4_deviceid_node *d;
156162

157-
d = nfs4_unhash_put_deviceid(clp, id);
163+
d = nfs4_unhash_put_deviceid(ld, clp, id);
158164
if (!d)
159165
return;
160166
d->ld->free_deviceid_node(d);
@@ -194,7 +200,7 @@ nfs4_insert_deviceid_node(struct nfs4_deviceid_node *new)
194200

195201
spin_lock(&nfs4_deviceid_lock);
196202
hash = nfs4_deviceid_hash(&new->deviceid);
197-
d = _find_get_deviceid(new->nfs_client, &new->deviceid, hash);
203+
d = _find_get_deviceid(new->ld, new->nfs_client, &new->deviceid, hash);
198204
if (d) {
199205
spin_unlock(&nfs4_deviceid_lock);
200206
return d;

0 commit comments

Comments
 (0)