Commit 0bdce6a8 authored by Trond Myklebust's avatar Trond Myklebust Committed by Greg Kroah-Hartman

NFSv4.1/pNFS: Fix borken function _same_data_server_addrs_locked()

commit 6f536936 upstream.

- Switch back to using list_for_each_entry(). Fixes an incorrect test
  for list NULL termination.
- Do not assume that lists are sorted.
- Finally, consider an existing entry to match if it consists of a subset
  of the addresses in the new entry.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e204275a
...@@ -359,26 +359,31 @@ same_sockaddr(struct sockaddr *addr1, struct sockaddr *addr2) ...@@ -359,26 +359,31 @@ same_sockaddr(struct sockaddr *addr1, struct sockaddr *addr2)
return false; return false;
} }
/*
* Checks if 'dsaddrs1' contains a subset of 'dsaddrs2'. If it does,
* declare a match.
*/
static bool static bool
_same_data_server_addrs_locked(const struct list_head *dsaddrs1, _same_data_server_addrs_locked(const struct list_head *dsaddrs1,
const struct list_head *dsaddrs2) const struct list_head *dsaddrs2)
{ {
struct nfs4_pnfs_ds_addr *da1, *da2; struct nfs4_pnfs_ds_addr *da1, *da2;
struct sockaddr *sa1, *sa2;
/* step through both lists, comparing as we go */ bool match = false;
for (da1 = list_first_entry(dsaddrs1, typeof(*da1), da_node),
da2 = list_first_entry(dsaddrs2, typeof(*da2), da_node); list_for_each_entry(da1, dsaddrs1, da_node) {
da1 != NULL && da2 != NULL; sa1 = (struct sockaddr *)&da1->da_addr;
da1 = list_entry(da1->da_node.next, typeof(*da1), da_node), match = false;
da2 = list_entry(da2->da_node.next, typeof(*da2), da_node)) { list_for_each_entry(da2, dsaddrs2, da_node) {
if (!same_sockaddr((struct sockaddr *)&da1->da_addr, sa2 = (struct sockaddr *)&da2->da_addr;
(struct sockaddr *)&da2->da_addr)) match = same_sockaddr(sa1, sa2);
return false; if (match)
break;
}
if (!match)
break;
} }
if (da1 == NULL && da2 == NULL) return match;
return true;
return false;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment