diff options
author | David Howells <dhowells@redhat.com> | 2017-11-02 16:27:50 +0100 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2017-11-13 16:38:18 +0100 |
commit | 8b2a464ced77fe35be72ab7d38152a9439daf8d3 (patch) | |
tree | ec478c8adebb6344513581b60935c0cf2b0ff937 /fs/afs/vlocation.c | |
parent | afs: Overhaul cell database management (diff) | |
download | linux-8b2a464ced77fe35be72ab7d38152a9439daf8d3.tar.xz linux-8b2a464ced77fe35be72ab7d38152a9439daf8d3.zip |
afs: Add an address list concept
Add an RCU replaceable address list structure to hold a list of server
addresses. The list also holds the
To this end:
(1) A cell's VL server address list can be loaded directly via insmod or
echo to /proc/fs/afs/cells or dynamically from a DNS query for AFSDB
or SRV records.
(2) Anyone wanting to use a cell's VL server address must wait until the
cell record comes online and has tried to obtain some addresses.
(3) An FS server's address list, for the moment, has a single entry that
is the key to the server list. This will change in the future when a
server is instead keyed on its UUID and the VL.GetAddrsU operation is
used.
(4) An 'address cursor' concept is introduced to handle iteration through
the address list. This is passed to the afs_make_call() as, in the
future, stuff (such as abort code) that doesn't outlast the call will
be returned in it.
In the future, we might want to annotate the list with information about
how each address fares. We might then want to propagate such annotations
over address list replacement.
Whilst we're at it, we allow IPv6 addresses to be specified in
colon-delimited lists by enclosing them in square brackets.
Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs/afs/vlocation.c')
-rw-r--r-- | fs/afs/vlocation.c | 75 |
1 files changed, 40 insertions, 35 deletions
diff --git a/fs/afs/vlocation.c b/fs/afs/vlocation.c index ec5ab8dc9bc8..52c31ad0ef60 100644 --- a/fs/afs/vlocation.c +++ b/fs/afs/vlocation.c @@ -29,22 +29,25 @@ static int afs_vlocation_access_vl_by_name(struct afs_vlocation *vl, struct key *key, struct afs_cache_vlocation *vldb) { - struct afs_cell *cell = vl->cell; - int count, ret; + struct afs_addr_cursor ac; + int ret; - _enter("%s,%s", cell->name, vl->vldb.name); + _enter("%s,%s", vl->cell->name, vl->vldb.name); + + ret = afs_set_vl_cursor(&ac, vl->cell); + if (ret < 0) + return ret; down_write(&vl->cell->vl_sem); + ret = -ENOMEDIUM; - for (count = cell->vl_naddrs; count > 0; count--) { - struct sockaddr_rxrpc *addr = &cell->vl_addrs[cell->vl_curr_svix]; - - _debug("CellServ[%hu]: %pIS", cell->vl_curr_svix, &addr->transport); + while (afs_iterate_addresses(&ac)) { + _debug("CellServ[%hu]: %pIS", ac.index, &ac.addr->transport); /* attempt to access the VL server */ - ret = afs_vl_get_entry_by_name(cell->net, addr, key, - vl->vldb.name, vldb, false); - switch (ret) { + ac.error = afs_vl_get_entry_by_name(vl->cell->net, &ac, key, + vl->vldb.name, vldb, false); + switch (ac.error) { case 0: goto out; case -ENOMEM: @@ -52,26 +55,24 @@ static int afs_vlocation_access_vl_by_name(struct afs_vlocation *vl, case -ENETUNREACH: case -EHOSTUNREACH: case -ECONNREFUSED: - if (ret == -ENOMEM || ret == -ENONET) + if (ac.error == -ENOMEM || ac.error == -ENONET) goto out; - goto rotate; + break; case -ENOMEDIUM: case -EKEYREJECTED: case -EKEYEXPIRED: + ac.responded = true; goto out; default: - ret = -EIO; - goto rotate; + ac.responded = true; + ac.error = -EIO; + break; } - - /* rotate the server records upon lookup failure */ - rotate: - cell->vl_curr_svix++; - cell->vl_curr_svix %= cell->vl_naddrs; } out: up_write(&vl->cell->vl_sem); + ret = afs_end_cursor(&ac); _leave(" = %d", ret); return ret; } @@ -86,22 +87,24 @@ static int afs_vlocation_access_vl_by_id(struct afs_vlocation *vl, afs_voltype_t voltype, struct afs_cache_vlocation *vldb) { - struct afs_cell *cell = vl->cell; - int count, ret; + struct afs_addr_cursor ac; + int ret; - _enter("%s,%x,%d,", cell->name, volid, voltype); + _enter("%s,%x,%d,", vl->cell->name, volid, voltype); + + ret = afs_set_vl_cursor(&ac, vl->cell); + if (ret < 0) + return ret; down_write(&vl->cell->vl_sem); ret = -ENOMEDIUM; - for (count = cell->vl_naddrs; count > 0; count--) { - struct sockaddr_rxrpc *addr = &cell->vl_addrs[cell->vl_curr_svix]; - - _debug("CellServ[%hu]: %pIS", cell->vl_curr_svix, &addr->transport); + while (afs_iterate_addresses(&ac)) { + _debug("CellServ[%hu]: %pIS", ac.index, &ac.addr->transport); /* attempt to access the VL server */ - ret = afs_vl_get_entry_by_id(cell->net, addr, key, volid, - voltype, vldb, false); - switch (ret) { + ac.error = afs_vl_get_entry_by_id(vl->cell->net, &ac, key, volid, + voltype, vldb, false); + switch (ac.error) { case 0: goto out; case -ENOMEM: @@ -109,10 +112,11 @@ static int afs_vlocation_access_vl_by_id(struct afs_vlocation *vl, case -ENETUNREACH: case -EHOSTUNREACH: case -ECONNREFUSED: - if (ret == -ENOMEM || ret == -ENONET) + if (ac.error == -ENOMEM || ac.error == -ENONET) goto out; goto rotate; case -EBUSY: + ac.responded = true; vl->upd_busy_cnt++; if (vl->upd_busy_cnt <= 3) { if (vl->upd_busy_cnt > 1) { @@ -124,30 +128,31 @@ static int afs_vlocation_access_vl_by_id(struct afs_vlocation *vl, } break; case -ENOMEDIUM: + ac.responded = true; vl->upd_rej_cnt++; goto rotate; default: - ret = -EIO; + ac.responded = true; + ac.error = -EIO; goto rotate; } /* rotate the server records upon lookup failure */ rotate: - cell->vl_curr_svix++; - cell->vl_curr_svix %= cell->vl_naddrs; vl->upd_busy_cnt = 0; } out: - if (ret < 0 && vl->upd_rej_cnt > 0) { + if (ac.error < 0 && vl->upd_rej_cnt > 0) { printk(KERN_NOTICE "kAFS:" " Active volume no longer valid '%s'\n", vl->vldb.name); vl->valid = 0; - ret = -ENOMEDIUM; + ac.error = -ENOMEDIUM; } up_write(&vl->cell->vl_sem); + ret = afs_end_cursor(&ac); _leave(" = %d", ret); return ret; } |