Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 294450
b: refs/heads/master
c: 2d3fe01
h: refs/heads/master
v: v3
  • Loading branch information
Weston Andros Adamson authored and Trond Myklebust committed Feb 6, 2012
1 parent 2615787 commit b47e219
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 48 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a030889a01d1bea921e1a7501010b7b891d2abd2
refs/heads/master: 2d3fe01c36a9b881fae89c5bdf4085a4d7d53ae1
71 changes: 24 additions & 47 deletions trunk/fs/nfs/nfs4filelayoutdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,58 +108,40 @@ same_sockaddr(struct sockaddr *addr1, struct sockaddr *addr2)
return false;
}

/*
* Lookup DS by addresses. The first matching address returns true.
* nfs4_ds_cache_lock is held
*/
static struct nfs4_pnfs_ds *
_data_server_lookup_locked(struct list_head *dsaddrs)
bool
_same_data_server_addrs_locked(const struct list_head *dsaddrs1,
const struct list_head *dsaddrs2)
{
struct nfs4_pnfs_ds *ds;
struct nfs4_pnfs_ds_addr *da1, *da2;

list_for_each_entry(da1, dsaddrs, da_node) {
list_for_each_entry(ds, &nfs4_data_server_cache, ds_node) {
list_for_each_entry(da2, &ds->ds_addrs, da_node) {
if (same_sockaddr(
(struct sockaddr *)&da1->da_addr,
(struct sockaddr *)&da2->da_addr))
return ds;
}
}
/* step through both lists, comparing as we go */
for (da1 = list_first_entry(dsaddrs1, typeof(*da1), da_node),
da2 = list_first_entry(dsaddrs2, typeof(*da2), da_node);
da1 != NULL && da2 != NULL;
da1 = list_entry(da1->da_node.next, typeof(*da1), da_node),
da2 = list_entry(da2->da_node.next, typeof(*da2), da_node)) {
if (!same_sockaddr((struct sockaddr *)&da1->da_addr,
(struct sockaddr *)&da2->da_addr))
return false;
}
return NULL;
if (da1 == NULL && da2 == NULL)
return true;

return false;
}

/*
* Compare two lists of addresses.
* Lookup DS by addresses. nfs4_ds_cache_lock is held
*/
static bool
_data_server_match_all_addrs_locked(struct list_head *dsaddrs1,
struct list_head *dsaddrs2)
static struct nfs4_pnfs_ds *
_data_server_lookup_locked(const struct list_head *dsaddrs)
{
struct nfs4_pnfs_ds_addr *da1, *da2;
size_t count1 = 0,
count2 = 0;

list_for_each_entry(da1, dsaddrs1, da_node)
count1++;

list_for_each_entry(da2, dsaddrs2, da_node) {
bool found = false;
count2++;
list_for_each_entry(da1, dsaddrs1, da_node) {
if (same_sockaddr((struct sockaddr *)&da1->da_addr,
(struct sockaddr *)&da2->da_addr)) {
found = true;
break;
}
}
if (!found)
return false;
}
struct nfs4_pnfs_ds *ds;

return (count1 == count2);
list_for_each_entry(ds, &nfs4_data_server_cache, ds_node)
if (_same_data_server_addrs_locked(&ds->ds_addrs, dsaddrs))
return ds;
return NULL;
}

/*
Expand Down Expand Up @@ -356,11 +338,6 @@ nfs4_pnfs_ds_add(struct list_head *dsaddrs, gfp_t gfp_flags)
dprintk("%s add new data server %s\n", __func__,
ds->ds_remotestr);
} else {
if (!_data_server_match_all_addrs_locked(&tmp_ds->ds_addrs,
dsaddrs)) {
dprintk("%s: multipath address mismatch: %s != %s",
__func__, tmp_ds->ds_remotestr, remotestr);
}
kfree(remotestr);
kfree(ds);
atomic_inc(&tmp_ds->ds_count);
Expand Down

0 comments on commit b47e219

Please sign in to comment.