2019-05-21 00:08:01 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-11-02 22:27:50 +07:00
|
|
|
/* Server address list management
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 Red Hat, Inc. All Rights Reserved.
|
|
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/ctype.h>
|
|
|
|
#include <linux/dns_resolver.h>
|
|
|
|
#include <linux/inet.h>
|
|
|
|
#include <keys/rxrpc-type.h>
|
|
|
|
#include "internal.h"
|
|
|
|
#include "afs_fs.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release an address list.
|
|
|
|
*/
|
|
|
|
void afs_put_addrlist(struct afs_addr_list *alist)
|
|
|
|
{
|
|
|
|
if (alist && refcount_dec_and_test(&alist->usage))
|
2020-03-13 04:36:53 +07:00
|
|
|
kfree_rcu(alist, rcu);
|
2017-11-02 22:27:50 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate an address list.
|
|
|
|
*/
|
|
|
|
struct afs_addr_list *afs_alloc_addrlist(unsigned int nr,
|
|
|
|
unsigned short service,
|
|
|
|
unsigned short port)
|
|
|
|
{
|
|
|
|
struct afs_addr_list *alist;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
_enter("%u,%u,%u", nr, service, port);
|
|
|
|
|
2018-10-04 15:32:27 +07:00
|
|
|
if (nr > AFS_MAX_ADDRESSES)
|
|
|
|
nr = AFS_MAX_ADDRESSES;
|
|
|
|
|
treewide: Use struct_size() for kmalloc()-family
One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:
struct foo {
int stuff;
void *entry[];
};
instance = kmalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:
instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL);
This patch makes the changes for kmalloc()-family (and kvmalloc()-family)
uses. It was done via automatic conversion with manual review for the
"CHECKME" non-standard cases noted below, using the following Coccinelle
script:
// pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len *
// sizeof *pkey_cache->table, GFP_KERNEL);
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@
- alloc(sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP)
+ alloc(struct_size(VAR, ELEMENT, COUNT), GFP)
// mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL);
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@
- alloc(sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP)
+ alloc(struct_size(VAR, ELEMENT, COUNT), GFP)
// Same pattern, but can't trivially locate the trailing element name,
// or variable name.
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
expression SOMETHING, COUNT, ELEMENT;
@@
- alloc(sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP)
+ alloc(CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-05-09 03:45:50 +07:00
|
|
|
alist = kzalloc(struct_size(alist, addrs, nr), GFP_KERNEL);
|
2017-11-02 22:27:50 +07:00
|
|
|
if (!alist)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
refcount_set(&alist->usage, 1);
|
2018-10-04 15:32:27 +07:00
|
|
|
alist->max_addrs = nr;
|
2017-11-02 22:27:50 +07:00
|
|
|
|
|
|
|
for (i = 0; i < nr; i++) {
|
|
|
|
struct sockaddr_rxrpc *srx = &alist->addrs[i];
|
|
|
|
srx->srx_family = AF_RXRPC;
|
|
|
|
srx->srx_service = service;
|
|
|
|
srx->transport_type = SOCK_DGRAM;
|
|
|
|
srx->transport_len = sizeof(srx->transport.sin6);
|
|
|
|
srx->transport.sin6.sin6_family = AF_INET6;
|
|
|
|
srx->transport.sin6.sin6_port = htons(port);
|
|
|
|
}
|
|
|
|
|
|
|
|
return alist;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse a text string consisting of delimited addresses.
|
|
|
|
*/
|
2018-10-20 06:57:57 +07:00
|
|
|
struct afs_vlserver_list *afs_parse_text_addrs(struct afs_net *net,
|
|
|
|
const char *text, size_t len,
|
|
|
|
char delim,
|
|
|
|
unsigned short service,
|
|
|
|
unsigned short port)
|
2017-11-02 22:27:50 +07:00
|
|
|
{
|
2018-10-20 06:57:57 +07:00
|
|
|
struct afs_vlserver_list *vllist;
|
2017-11-02 22:27:50 +07:00
|
|
|
struct afs_addr_list *alist;
|
|
|
|
const char *p, *end = text + len;
|
2018-10-20 06:57:57 +07:00
|
|
|
const char *problem;
|
2017-11-02 22:27:50 +07:00
|
|
|
unsigned int nr = 0;
|
2018-10-20 06:57:57 +07:00
|
|
|
int ret = -ENOMEM;
|
2017-11-02 22:27:50 +07:00
|
|
|
|
|
|
|
_enter("%*.*s,%c", (int)len, (int)len, text, delim);
|
|
|
|
|
2018-10-20 06:57:57 +07:00
|
|
|
if (!len) {
|
|
|
|
_leave(" = -EDESTADDRREQ [empty]");
|
2017-11-02 22:27:50 +07:00
|
|
|
return ERR_PTR(-EDESTADDRREQ);
|
2018-10-20 06:57:57 +07:00
|
|
|
}
|
2017-11-02 22:27:50 +07:00
|
|
|
|
|
|
|
if (delim == ':' && (memchr(text, ',', len) || !memchr(text, '.', len)))
|
|
|
|
delim = ',';
|
|
|
|
|
|
|
|
/* Count the addresses */
|
|
|
|
p = text;
|
|
|
|
do {
|
2018-10-20 06:57:57 +07:00
|
|
|
if (!*p) {
|
|
|
|
problem = "nul";
|
|
|
|
goto inval;
|
|
|
|
}
|
2017-11-02 22:27:50 +07:00
|
|
|
if (*p == delim)
|
|
|
|
continue;
|
|
|
|
nr++;
|
|
|
|
if (*p == '[') {
|
|
|
|
p++;
|
2018-10-20 06:57:57 +07:00
|
|
|
if (p == end) {
|
|
|
|
problem = "brace1";
|
|
|
|
goto inval;
|
|
|
|
}
|
2017-11-02 22:27:50 +07:00
|
|
|
p = memchr(p, ']', end - p);
|
2018-10-20 06:57:57 +07:00
|
|
|
if (!p) {
|
|
|
|
problem = "brace2";
|
|
|
|
goto inval;
|
|
|
|
}
|
2017-11-02 22:27:50 +07:00
|
|
|
p++;
|
|
|
|
if (p >= end)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = memchr(p, delim, end - p);
|
|
|
|
if (!p)
|
|
|
|
break;
|
|
|
|
p++;
|
|
|
|
} while (p < end);
|
|
|
|
|
|
|
|
_debug("%u/%u addresses", nr, AFS_MAX_ADDRESSES);
|
|
|
|
|
2018-10-20 06:57:57 +07:00
|
|
|
vllist = afs_alloc_vlserver_list(1);
|
|
|
|
if (!vllist)
|
2017-11-02 22:27:50 +07:00
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
2018-10-20 06:57:57 +07:00
|
|
|
vllist->nr_servers = 1;
|
|
|
|
vllist->servers[0].server = afs_alloc_vlserver("<dummy>", 7, AFS_VL_PORT);
|
|
|
|
if (!vllist->servers[0].server)
|
|
|
|
goto error_vl;
|
|
|
|
|
|
|
|
alist = afs_alloc_addrlist(nr, service, AFS_VL_PORT);
|
|
|
|
if (!alist)
|
|
|
|
goto error;
|
|
|
|
|
2017-11-02 22:27:50 +07:00
|
|
|
/* Extract the addresses */
|
|
|
|
p = text;
|
|
|
|
do {
|
2018-05-10 04:03:18 +07:00
|
|
|
const char *q, *stop;
|
2018-10-04 15:32:27 +07:00
|
|
|
unsigned int xport = port;
|
|
|
|
__be32 x[4];
|
|
|
|
int family;
|
2017-11-02 22:27:50 +07:00
|
|
|
|
|
|
|
if (*p == delim) {
|
|
|
|
p++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*p == '[') {
|
|
|
|
p++;
|
2018-05-10 04:03:18 +07:00
|
|
|
q = memchr(p, ']', end - p);
|
|
|
|
} else {
|
|
|
|
for (q = p; q < end; q++)
|
|
|
|
if (*q == '+' || *q == delim)
|
|
|
|
break;
|
2017-11-02 22:27:50 +07:00
|
|
|
}
|
|
|
|
|
2018-10-20 06:57:57 +07:00
|
|
|
if (in4_pton(p, q - p, (u8 *)&x[0], -1, &stop)) {
|
2018-10-04 15:32:27 +07:00
|
|
|
family = AF_INET;
|
2018-10-20 06:57:57 +07:00
|
|
|
} else if (in6_pton(p, q - p, (u8 *)x, -1, &stop)) {
|
2018-10-04 15:32:27 +07:00
|
|
|
family = AF_INET6;
|
2018-10-20 06:57:57 +07:00
|
|
|
} else {
|
|
|
|
problem = "family";
|
2017-11-02 22:27:50 +07:00
|
|
|
goto bad_address;
|
2018-10-20 06:57:57 +07:00
|
|
|
}
|
2017-11-02 22:27:50 +07:00
|
|
|
|
2018-10-20 06:57:57 +07:00
|
|
|
p = q;
|
|
|
|
if (stop != p) {
|
|
|
|
problem = "nostop";
|
2018-05-10 04:03:18 +07:00
|
|
|
goto bad_address;
|
2018-10-20 06:57:57 +07:00
|
|
|
}
|
2018-05-10 04:03:18 +07:00
|
|
|
|
|
|
|
if (q < end && *q == ']')
|
2017-11-02 22:27:50 +07:00
|
|
|
p++;
|
|
|
|
|
|
|
|
if (p < end) {
|
|
|
|
if (*p == '+') {
|
|
|
|
/* Port number specification "+1234" */
|
2018-10-04 15:32:27 +07:00
|
|
|
xport = 0;
|
2017-11-02 22:27:50 +07:00
|
|
|
p++;
|
2018-10-20 06:57:57 +07:00
|
|
|
if (p >= end || !isdigit(*p)) {
|
|
|
|
problem = "port";
|
2017-11-02 22:27:50 +07:00
|
|
|
goto bad_address;
|
2018-10-20 06:57:57 +07:00
|
|
|
}
|
2017-11-02 22:27:50 +07:00
|
|
|
do {
|
|
|
|
xport *= 10;
|
|
|
|
xport += *p - '0';
|
2018-10-20 06:57:57 +07:00
|
|
|
if (xport > 65535) {
|
|
|
|
problem = "pval";
|
2017-11-02 22:27:50 +07:00
|
|
|
goto bad_address;
|
2018-10-20 06:57:57 +07:00
|
|
|
}
|
2017-11-02 22:27:50 +07:00
|
|
|
p++;
|
|
|
|
} while (p < end && isdigit(*p));
|
|
|
|
} else if (*p == delim) {
|
|
|
|
p++;
|
|
|
|
} else {
|
2018-10-20 06:57:57 +07:00
|
|
|
problem = "weird";
|
2017-11-02 22:27:50 +07:00
|
|
|
goto bad_address;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-04 15:32:27 +07:00
|
|
|
if (family == AF_INET)
|
|
|
|
afs_merge_fs_addr4(alist, x[0], xport);
|
|
|
|
else
|
|
|
|
afs_merge_fs_addr6(alist, x, xport);
|
|
|
|
|
|
|
|
} while (p < end);
|
2017-11-02 22:27:50 +07:00
|
|
|
|
2018-10-20 06:57:57 +07:00
|
|
|
rcu_assign_pointer(vllist->servers[0].server->addresses, alist);
|
2017-11-02 22:27:50 +07:00
|
|
|
_leave(" = [nr %u]", alist->nr_addrs);
|
2018-10-20 06:57:57 +07:00
|
|
|
return vllist;
|
2017-11-02 22:27:50 +07:00
|
|
|
|
2018-10-20 06:57:57 +07:00
|
|
|
inval:
|
|
|
|
_leave(" = -EINVAL [%s %zu %*.*s]",
|
|
|
|
problem, p - text, (int)len, (int)len, text);
|
2017-11-02 22:27:50 +07:00
|
|
|
return ERR_PTR(-EINVAL);
|
2018-10-20 06:57:57 +07:00
|
|
|
bad_address:
|
|
|
|
_leave(" = -EINVAL [%s %zu %*.*s]",
|
|
|
|
problem, p - text, (int)len, (int)len, text);
|
|
|
|
ret = -EINVAL;
|
|
|
|
error:
|
|
|
|
afs_put_addrlist(alist);
|
|
|
|
error_vl:
|
|
|
|
afs_put_vlserverlist(net, vllist);
|
|
|
|
return ERR_PTR(ret);
|
2017-11-02 22:27:50 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compare old and new address lists to see if there's been any change.
|
|
|
|
* - How to do this in better than O(Nlog(N)) time?
|
|
|
|
* - We don't really want to sort the address list, but would rather take the
|
|
|
|
* list as we got it so as not to undo record rotation by the DNS server.
|
|
|
|
*/
|
|
|
|
#if 0
|
|
|
|
static int afs_cmp_addr_list(const struct afs_addr_list *a1,
|
|
|
|
const struct afs_addr_list *a2)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform a DNS query for VL servers and build a up an address list.
|
|
|
|
*/
|
2018-10-20 06:57:57 +07:00
|
|
|
struct afs_vlserver_list *afs_dns_query(struct afs_cell *cell, time64_t *_expiry)
|
2017-11-02 22:27:50 +07:00
|
|
|
{
|
2018-10-20 06:57:57 +07:00
|
|
|
struct afs_vlserver_list *vllist;
|
|
|
|
char *result = NULL;
|
2017-11-02 22:27:50 +07:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
_enter("%s", cell->name);
|
|
|
|
|
2019-06-27 03:02:33 +07:00
|
|
|
ret = dns_query(cell->net->net, "afsdb", cell->name, cell->name_len,
|
|
|
|
"srv=1", &result, _expiry, true);
|
2018-10-20 06:57:57 +07:00
|
|
|
if (ret < 0) {
|
|
|
|
_leave(" = %d [dns]", ret);
|
2017-11-02 22:27:50 +07:00
|
|
|
return ERR_PTR(ret);
|
|
|
|
}
|
|
|
|
|
2018-10-20 06:57:57 +07:00
|
|
|
if (*_expiry == 0)
|
|
|
|
*_expiry = ktime_get_real_seconds() + 60;
|
|
|
|
|
|
|
|
if (ret > 1 && result[0] == 0)
|
|
|
|
vllist = afs_extract_vlserver_list(cell, result, ret);
|
|
|
|
else
|
|
|
|
vllist = afs_parse_text_addrs(cell->net, result, ret, ',',
|
|
|
|
VL_SERVICE, AFS_VL_PORT);
|
|
|
|
kfree(result);
|
|
|
|
if (IS_ERR(vllist) && vllist != ERR_PTR(-ENOMEM))
|
|
|
|
pr_err("Failed to parse DNS data %ld\n", PTR_ERR(vllist));
|
|
|
|
|
|
|
|
return vllist;
|
2017-11-02 22:27:50 +07:00
|
|
|
}
|
|
|
|
|
afs: Overhaul volume and server record caching and fileserver rotation
The current code assumes that volumes and servers are per-cell and are
never shared, but this is not enforced, and, indeed, public cells do exist
that are aliases of each other. Further, an organisation can, say, set up
a public cell and a private cell with overlapping, but not identical, sets
of servers. The difference is purely in the database attached to the VL
servers.
The current code will malfunction if it sees a server in two cells as it
assumes global address -> server record mappings and that each server is in
just one cell.
Further, each server may have multiple addresses - and may have addresses
of different families (IPv4 and IPv6, say).
To this end, the following structural changes are made:
(1) Server record management is overhauled:
(a) Server records are made independent of cell. The namespace keeps
track of them, volume records have lists of them and each vnode
has a server on which its callback interest currently resides.
(b) The cell record no longer keeps a list of servers known to be in
that cell.
(c) The server records are now kept in a flat list because there's no
single address to sort on.
(d) Server records are now keyed by their UUID within the namespace.
(e) The addresses for a server are obtained with the VL.GetAddrsU
rather than with VL.GetEntryByName, using the server's UUID as a
parameter.
(f) Cached server records are garbage collected after a period of
non-use and are counted out of existence before purging is allowed
to complete. This protects the work functions against rmmod.
(g) The servers list is now in /proc/fs/afs/servers.
(2) Volume record management is overhauled:
(a) An RCU-replaceable server list is introduced. This tracks both
servers and their coresponding callback interests.
(b) The superblock is now keyed on cell record and numeric volume ID.
(c) The volume record is now tied to the superblock which mounts it,
and is activated when mounted and deactivated when unmounted.
This makes it easier to handle the cache cookie without causing a
double-use in fscache.
(d) The volume record is loaded from the VLDB using VL.GetEntryByNameU
to get the server UUID list.
(e) The volume name is updated if it is seen to have changed when the
volume is updated (the update is keyed on the volume ID).
(3) The vlocation record is got rid of and VLDB records are no longer
cached. Sufficient information is stored in the volume record, though
an update to a volume record is now no longer shared between related
volumes (volumes come in bundles of three: R/W, R/O and backup).
and the following procedural changes are made:
(1) The fileserver cursor introduced previously is now fleshed out and
used to iterate over fileservers and their addresses.
(2) Volume status is checked during iteration, and the server list is
replaced if a change is detected.
(3) Server status is checked during iteration, and the address list is
replaced if a change is detected.
(4) The abort code is saved into the address list cursor and -ECONNABORTED
returned in afs_make_call() if a remote abort happened rather than
translating the abort into an error message. This allows actions to
be taken depending on the abort code more easily.
(a) If a VMOVED abort is seen then this is handled by rechecking the
volume and restarting the iteration.
(b) If a VBUSY, VRESTARTING or VSALVAGING abort is seen then this is
handled by sleeping for a short period and retrying and/or trying
other servers that might serve that volume. A message is also
displayed once until the condition has cleared.
(c) If a VOFFLINE abort is seen, then this is handled as VBUSY for the
moment.
(d) If a VNOVOL abort is seen, the volume is rechecked in the VLDB to
see if it has been deleted; if not, the fileserver is probably
indicating that the volume couldn't be attached and needs
salvaging.
(e) If statfs() sees one of these aborts, it does not sleep, but
rather returns an error, so as not to block the umount program.
(5) The fileserver iteration functions in vnode.c are now merged into
their callers and more heavily macroised around the cursor. vnode.c
is removed.
(6) Operations on a particular vnode are serialised on that vnode because
the server will lock that vnode whilst it operates on it, so a second
op sent will just have to wait.
(7) Fileservers are probed with FS.GetCapabilities before being used.
This is where service upgrade will be done.
(8) A callback interest on a fileserver is set up before an FS operation
is performed and passed through to afs_make_call() so that it can be
set on the vnode if the operation returns a callback. The callback
interest is passed through to afs_iget() also so that it can be set
there too.
In general, record updating is done on an as-needed basis when we try to
access servers, volumes or vnodes rather than offloading it to work items
and special threads.
Notes:
(1) Pre AFS-3.4 servers are no longer supported, though this can be added
back if necessary (AFS-3.4 was released in 1998).
(2) VBUSY is retried forever for the moment at intervals of 1s.
(3) /proc/fs/afs/<cell>/servers no longer exists.
Signed-off-by: David Howells <dhowells@redhat.com>
2017-11-02 22:27:50 +07:00
|
|
|
/*
|
|
|
|
* Merge an IPv4 entry into a fileserver address list.
|
|
|
|
*/
|
2017-11-02 22:27:51 +07:00
|
|
|
void afs_merge_fs_addr4(struct afs_addr_list *alist, __be32 xdr, u16 port)
|
afs: Overhaul volume and server record caching and fileserver rotation
The current code assumes that volumes and servers are per-cell and are
never shared, but this is not enforced, and, indeed, public cells do exist
that are aliases of each other. Further, an organisation can, say, set up
a public cell and a private cell with overlapping, but not identical, sets
of servers. The difference is purely in the database attached to the VL
servers.
The current code will malfunction if it sees a server in two cells as it
assumes global address -> server record mappings and that each server is in
just one cell.
Further, each server may have multiple addresses - and may have addresses
of different families (IPv4 and IPv6, say).
To this end, the following structural changes are made:
(1) Server record management is overhauled:
(a) Server records are made independent of cell. The namespace keeps
track of them, volume records have lists of them and each vnode
has a server on which its callback interest currently resides.
(b) The cell record no longer keeps a list of servers known to be in
that cell.
(c) The server records are now kept in a flat list because there's no
single address to sort on.
(d) Server records are now keyed by their UUID within the namespace.
(e) The addresses for a server are obtained with the VL.GetAddrsU
rather than with VL.GetEntryByName, using the server's UUID as a
parameter.
(f) Cached server records are garbage collected after a period of
non-use and are counted out of existence before purging is allowed
to complete. This protects the work functions against rmmod.
(g) The servers list is now in /proc/fs/afs/servers.
(2) Volume record management is overhauled:
(a) An RCU-replaceable server list is introduced. This tracks both
servers and their coresponding callback interests.
(b) The superblock is now keyed on cell record and numeric volume ID.
(c) The volume record is now tied to the superblock which mounts it,
and is activated when mounted and deactivated when unmounted.
This makes it easier to handle the cache cookie without causing a
double-use in fscache.
(d) The volume record is loaded from the VLDB using VL.GetEntryByNameU
to get the server UUID list.
(e) The volume name is updated if it is seen to have changed when the
volume is updated (the update is keyed on the volume ID).
(3) The vlocation record is got rid of and VLDB records are no longer
cached. Sufficient information is stored in the volume record, though
an update to a volume record is now no longer shared between related
volumes (volumes come in bundles of three: R/W, R/O and backup).
and the following procedural changes are made:
(1) The fileserver cursor introduced previously is now fleshed out and
used to iterate over fileservers and their addresses.
(2) Volume status is checked during iteration, and the server list is
replaced if a change is detected.
(3) Server status is checked during iteration, and the address list is
replaced if a change is detected.
(4) The abort code is saved into the address list cursor and -ECONNABORTED
returned in afs_make_call() if a remote abort happened rather than
translating the abort into an error message. This allows actions to
be taken depending on the abort code more easily.
(a) If a VMOVED abort is seen then this is handled by rechecking the
volume and restarting the iteration.
(b) If a VBUSY, VRESTARTING or VSALVAGING abort is seen then this is
handled by sleeping for a short period and retrying and/or trying
other servers that might serve that volume. A message is also
displayed once until the condition has cleared.
(c) If a VOFFLINE abort is seen, then this is handled as VBUSY for the
moment.
(d) If a VNOVOL abort is seen, the volume is rechecked in the VLDB to
see if it has been deleted; if not, the fileserver is probably
indicating that the volume couldn't be attached and needs
salvaging.
(e) If statfs() sees one of these aborts, it does not sleep, but
rather returns an error, so as not to block the umount program.
(5) The fileserver iteration functions in vnode.c are now merged into
their callers and more heavily macroised around the cursor. vnode.c
is removed.
(6) Operations on a particular vnode are serialised on that vnode because
the server will lock that vnode whilst it operates on it, so a second
op sent will just have to wait.
(7) Fileservers are probed with FS.GetCapabilities before being used.
This is where service upgrade will be done.
(8) A callback interest on a fileserver is set up before an FS operation
is performed and passed through to afs_make_call() so that it can be
set on the vnode if the operation returns a callback. The callback
interest is passed through to afs_iget() also so that it can be set
there too.
In general, record updating is done on an as-needed basis when we try to
access servers, volumes or vnodes rather than offloading it to work items
and special threads.
Notes:
(1) Pre AFS-3.4 servers are no longer supported, though this can be added
back if necessary (AFS-3.4 was released in 1998).
(2) VBUSY is retried forever for the moment at intervals of 1s.
(3) /proc/fs/afs/<cell>/servers no longer exists.
Signed-off-by: David Howells <dhowells@redhat.com>
2017-11-02 22:27:50 +07:00
|
|
|
{
|
2018-10-04 15:32:28 +07:00
|
|
|
struct sockaddr_rxrpc *srx;
|
2018-10-04 15:32:28 +07:00
|
|
|
u32 addr = ntohl(xdr);
|
afs: Overhaul volume and server record caching and fileserver rotation
The current code assumes that volumes and servers are per-cell and are
never shared, but this is not enforced, and, indeed, public cells do exist
that are aliases of each other. Further, an organisation can, say, set up
a public cell and a private cell with overlapping, but not identical, sets
of servers. The difference is purely in the database attached to the VL
servers.
The current code will malfunction if it sees a server in two cells as it
assumes global address -> server record mappings and that each server is in
just one cell.
Further, each server may have multiple addresses - and may have addresses
of different families (IPv4 and IPv6, say).
To this end, the following structural changes are made:
(1) Server record management is overhauled:
(a) Server records are made independent of cell. The namespace keeps
track of them, volume records have lists of them and each vnode
has a server on which its callback interest currently resides.
(b) The cell record no longer keeps a list of servers known to be in
that cell.
(c) The server records are now kept in a flat list because there's no
single address to sort on.
(d) Server records are now keyed by their UUID within the namespace.
(e) The addresses for a server are obtained with the VL.GetAddrsU
rather than with VL.GetEntryByName, using the server's UUID as a
parameter.
(f) Cached server records are garbage collected after a period of
non-use and are counted out of existence before purging is allowed
to complete. This protects the work functions against rmmod.
(g) The servers list is now in /proc/fs/afs/servers.
(2) Volume record management is overhauled:
(a) An RCU-replaceable server list is introduced. This tracks both
servers and their coresponding callback interests.
(b) The superblock is now keyed on cell record and numeric volume ID.
(c) The volume record is now tied to the superblock which mounts it,
and is activated when mounted and deactivated when unmounted.
This makes it easier to handle the cache cookie without causing a
double-use in fscache.
(d) The volume record is loaded from the VLDB using VL.GetEntryByNameU
to get the server UUID list.
(e) The volume name is updated if it is seen to have changed when the
volume is updated (the update is keyed on the volume ID).
(3) The vlocation record is got rid of and VLDB records are no longer
cached. Sufficient information is stored in the volume record, though
an update to a volume record is now no longer shared between related
volumes (volumes come in bundles of three: R/W, R/O and backup).
and the following procedural changes are made:
(1) The fileserver cursor introduced previously is now fleshed out and
used to iterate over fileservers and their addresses.
(2) Volume status is checked during iteration, and the server list is
replaced if a change is detected.
(3) Server status is checked during iteration, and the address list is
replaced if a change is detected.
(4) The abort code is saved into the address list cursor and -ECONNABORTED
returned in afs_make_call() if a remote abort happened rather than
translating the abort into an error message. This allows actions to
be taken depending on the abort code more easily.
(a) If a VMOVED abort is seen then this is handled by rechecking the
volume and restarting the iteration.
(b) If a VBUSY, VRESTARTING or VSALVAGING abort is seen then this is
handled by sleeping for a short period and retrying and/or trying
other servers that might serve that volume. A message is also
displayed once until the condition has cleared.
(c) If a VOFFLINE abort is seen, then this is handled as VBUSY for the
moment.
(d) If a VNOVOL abort is seen, the volume is rechecked in the VLDB to
see if it has been deleted; if not, the fileserver is probably
indicating that the volume couldn't be attached and needs
salvaging.
(e) If statfs() sees one of these aborts, it does not sleep, but
rather returns an error, so as not to block the umount program.
(5) The fileserver iteration functions in vnode.c are now merged into
their callers and more heavily macroised around the cursor. vnode.c
is removed.
(6) Operations on a particular vnode are serialised on that vnode because
the server will lock that vnode whilst it operates on it, so a second
op sent will just have to wait.
(7) Fileservers are probed with FS.GetCapabilities before being used.
This is where service upgrade will be done.
(8) A callback interest on a fileserver is set up before an FS operation
is performed and passed through to afs_make_call() so that it can be
set on the vnode if the operation returns a callback. The callback
interest is passed through to afs_iget() also so that it can be set
there too.
In general, record updating is done on an as-needed basis when we try to
access servers, volumes or vnodes rather than offloading it to work items
and special threads.
Notes:
(1) Pre AFS-3.4 servers are no longer supported, though this can be added
back if necessary (AFS-3.4 was released in 1998).
(2) VBUSY is retried forever for the moment at intervals of 1s.
(3) /proc/fs/afs/<cell>/servers no longer exists.
Signed-off-by: David Howells <dhowells@redhat.com>
2017-11-02 22:27:50 +07:00
|
|
|
int i;
|
|
|
|
|
2018-10-04 15:32:27 +07:00
|
|
|
if (alist->nr_addrs >= alist->max_addrs)
|
|
|
|
return;
|
|
|
|
|
afs: Overhaul volume and server record caching and fileserver rotation
The current code assumes that volumes and servers are per-cell and are
never shared, but this is not enforced, and, indeed, public cells do exist
that are aliases of each other. Further, an organisation can, say, set up
a public cell and a private cell with overlapping, but not identical, sets
of servers. The difference is purely in the database attached to the VL
servers.
The current code will malfunction if it sees a server in two cells as it
assumes global address -> server record mappings and that each server is in
just one cell.
Further, each server may have multiple addresses - and may have addresses
of different families (IPv4 and IPv6, say).
To this end, the following structural changes are made:
(1) Server record management is overhauled:
(a) Server records are made independent of cell. The namespace keeps
track of them, volume records have lists of them and each vnode
has a server on which its callback interest currently resides.
(b) The cell record no longer keeps a list of servers known to be in
that cell.
(c) The server records are now kept in a flat list because there's no
single address to sort on.
(d) Server records are now keyed by their UUID within the namespace.
(e) The addresses for a server are obtained with the VL.GetAddrsU
rather than with VL.GetEntryByName, using the server's UUID as a
parameter.
(f) Cached server records are garbage collected after a period of
non-use and are counted out of existence before purging is allowed
to complete. This protects the work functions against rmmod.
(g) The servers list is now in /proc/fs/afs/servers.
(2) Volume record management is overhauled:
(a) An RCU-replaceable server list is introduced. This tracks both
servers and their coresponding callback interests.
(b) The superblock is now keyed on cell record and numeric volume ID.
(c) The volume record is now tied to the superblock which mounts it,
and is activated when mounted and deactivated when unmounted.
This makes it easier to handle the cache cookie without causing a
double-use in fscache.
(d) The volume record is loaded from the VLDB using VL.GetEntryByNameU
to get the server UUID list.
(e) The volume name is updated if it is seen to have changed when the
volume is updated (the update is keyed on the volume ID).
(3) The vlocation record is got rid of and VLDB records are no longer
cached. Sufficient information is stored in the volume record, though
an update to a volume record is now no longer shared between related
volumes (volumes come in bundles of three: R/W, R/O and backup).
and the following procedural changes are made:
(1) The fileserver cursor introduced previously is now fleshed out and
used to iterate over fileservers and their addresses.
(2) Volume status is checked during iteration, and the server list is
replaced if a change is detected.
(3) Server status is checked during iteration, and the address list is
replaced if a change is detected.
(4) The abort code is saved into the address list cursor and -ECONNABORTED
returned in afs_make_call() if a remote abort happened rather than
translating the abort into an error message. This allows actions to
be taken depending on the abort code more easily.
(a) If a VMOVED abort is seen then this is handled by rechecking the
volume and restarting the iteration.
(b) If a VBUSY, VRESTARTING or VSALVAGING abort is seen then this is
handled by sleeping for a short period and retrying and/or trying
other servers that might serve that volume. A message is also
displayed once until the condition has cleared.
(c) If a VOFFLINE abort is seen, then this is handled as VBUSY for the
moment.
(d) If a VNOVOL abort is seen, the volume is rechecked in the VLDB to
see if it has been deleted; if not, the fileserver is probably
indicating that the volume couldn't be attached and needs
salvaging.
(e) If statfs() sees one of these aborts, it does not sleep, but
rather returns an error, so as not to block the umount program.
(5) The fileserver iteration functions in vnode.c are now merged into
their callers and more heavily macroised around the cursor. vnode.c
is removed.
(6) Operations on a particular vnode are serialised on that vnode because
the server will lock that vnode whilst it operates on it, so a second
op sent will just have to wait.
(7) Fileservers are probed with FS.GetCapabilities before being used.
This is where service upgrade will be done.
(8) A callback interest on a fileserver is set up before an FS operation
is performed and passed through to afs_make_call() so that it can be
set on the vnode if the operation returns a callback. The callback
interest is passed through to afs_iget() also so that it can be set
there too.
In general, record updating is done on an as-needed basis when we try to
access servers, volumes or vnodes rather than offloading it to work items
and special threads.
Notes:
(1) Pre AFS-3.4 servers are no longer supported, though this can be added
back if necessary (AFS-3.4 was released in 1998).
(2) VBUSY is retried forever for the moment at intervals of 1s.
(3) /proc/fs/afs/<cell>/servers no longer exists.
Signed-off-by: David Howells <dhowells@redhat.com>
2017-11-02 22:27:50 +07:00
|
|
|
for (i = 0; i < alist->nr_ipv4; i++) {
|
2018-10-04 15:32:28 +07:00
|
|
|
struct sockaddr_in *a = &alist->addrs[i].transport.sin;
|
|
|
|
u32 a_addr = ntohl(a->sin_addr.s_addr);
|
|
|
|
u16 a_port = ntohs(a->sin_port);
|
2018-10-04 15:32:28 +07:00
|
|
|
|
|
|
|
if (addr == a_addr && port == a_port)
|
afs: Overhaul volume and server record caching and fileserver rotation
The current code assumes that volumes and servers are per-cell and are
never shared, but this is not enforced, and, indeed, public cells do exist
that are aliases of each other. Further, an organisation can, say, set up
a public cell and a private cell with overlapping, but not identical, sets
of servers. The difference is purely in the database attached to the VL
servers.
The current code will malfunction if it sees a server in two cells as it
assumes global address -> server record mappings and that each server is in
just one cell.
Further, each server may have multiple addresses - and may have addresses
of different families (IPv4 and IPv6, say).
To this end, the following structural changes are made:
(1) Server record management is overhauled:
(a) Server records are made independent of cell. The namespace keeps
track of them, volume records have lists of them and each vnode
has a server on which its callback interest currently resides.
(b) The cell record no longer keeps a list of servers known to be in
that cell.
(c) The server records are now kept in a flat list because there's no
single address to sort on.
(d) Server records are now keyed by their UUID within the namespace.
(e) The addresses for a server are obtained with the VL.GetAddrsU
rather than with VL.GetEntryByName, using the server's UUID as a
parameter.
(f) Cached server records are garbage collected after a period of
non-use and are counted out of existence before purging is allowed
to complete. This protects the work functions against rmmod.
(g) The servers list is now in /proc/fs/afs/servers.
(2) Volume record management is overhauled:
(a) An RCU-replaceable server list is introduced. This tracks both
servers and their coresponding callback interests.
(b) The superblock is now keyed on cell record and numeric volume ID.
(c) The volume record is now tied to the superblock which mounts it,
and is activated when mounted and deactivated when unmounted.
This makes it easier to handle the cache cookie without causing a
double-use in fscache.
(d) The volume record is loaded from the VLDB using VL.GetEntryByNameU
to get the server UUID list.
(e) The volume name is updated if it is seen to have changed when the
volume is updated (the update is keyed on the volume ID).
(3) The vlocation record is got rid of and VLDB records are no longer
cached. Sufficient information is stored in the volume record, though
an update to a volume record is now no longer shared between related
volumes (volumes come in bundles of three: R/W, R/O and backup).
and the following procedural changes are made:
(1) The fileserver cursor introduced previously is now fleshed out and
used to iterate over fileservers and their addresses.
(2) Volume status is checked during iteration, and the server list is
replaced if a change is detected.
(3) Server status is checked during iteration, and the address list is
replaced if a change is detected.
(4) The abort code is saved into the address list cursor and -ECONNABORTED
returned in afs_make_call() if a remote abort happened rather than
translating the abort into an error message. This allows actions to
be taken depending on the abort code more easily.
(a) If a VMOVED abort is seen then this is handled by rechecking the
volume and restarting the iteration.
(b) If a VBUSY, VRESTARTING or VSALVAGING abort is seen then this is
handled by sleeping for a short period and retrying and/or trying
other servers that might serve that volume. A message is also
displayed once until the condition has cleared.
(c) If a VOFFLINE abort is seen, then this is handled as VBUSY for the
moment.
(d) If a VNOVOL abort is seen, the volume is rechecked in the VLDB to
see if it has been deleted; if not, the fileserver is probably
indicating that the volume couldn't be attached and needs
salvaging.
(e) If statfs() sees one of these aborts, it does not sleep, but
rather returns an error, so as not to block the umount program.
(5) The fileserver iteration functions in vnode.c are now merged into
their callers and more heavily macroised around the cursor. vnode.c
is removed.
(6) Operations on a particular vnode are serialised on that vnode because
the server will lock that vnode whilst it operates on it, so a second
op sent will just have to wait.
(7) Fileservers are probed with FS.GetCapabilities before being used.
This is where service upgrade will be done.
(8) A callback interest on a fileserver is set up before an FS operation
is performed and passed through to afs_make_call() so that it can be
set on the vnode if the operation returns a callback. The callback
interest is passed through to afs_iget() also so that it can be set
there too.
In general, record updating is done on an as-needed basis when we try to
access servers, volumes or vnodes rather than offloading it to work items
and special threads.
Notes:
(1) Pre AFS-3.4 servers are no longer supported, though this can be added
back if necessary (AFS-3.4 was released in 1998).
(2) VBUSY is retried forever for the moment at intervals of 1s.
(3) /proc/fs/afs/<cell>/servers no longer exists.
Signed-off-by: David Howells <dhowells@redhat.com>
2017-11-02 22:27:50 +07:00
|
|
|
return;
|
2018-10-04 15:32:28 +07:00
|
|
|
if (addr == a_addr && port < a_port)
|
2017-11-02 22:27:51 +07:00
|
|
|
break;
|
2018-10-04 15:32:28 +07:00
|
|
|
if (addr < a_addr)
|
afs: Overhaul volume and server record caching and fileserver rotation
The current code assumes that volumes and servers are per-cell and are
never shared, but this is not enforced, and, indeed, public cells do exist
that are aliases of each other. Further, an organisation can, say, set up
a public cell and a private cell with overlapping, but not identical, sets
of servers. The difference is purely in the database attached to the VL
servers.
The current code will malfunction if it sees a server in two cells as it
assumes global address -> server record mappings and that each server is in
just one cell.
Further, each server may have multiple addresses - and may have addresses
of different families (IPv4 and IPv6, say).
To this end, the following structural changes are made:
(1) Server record management is overhauled:
(a) Server records are made independent of cell. The namespace keeps
track of them, volume records have lists of them and each vnode
has a server on which its callback interest currently resides.
(b) The cell record no longer keeps a list of servers known to be in
that cell.
(c) The server records are now kept in a flat list because there's no
single address to sort on.
(d) Server records are now keyed by their UUID within the namespace.
(e) The addresses for a server are obtained with the VL.GetAddrsU
rather than with VL.GetEntryByName, using the server's UUID as a
parameter.
(f) Cached server records are garbage collected after a period of
non-use and are counted out of existence before purging is allowed
to complete. This protects the work functions against rmmod.
(g) The servers list is now in /proc/fs/afs/servers.
(2) Volume record management is overhauled:
(a) An RCU-replaceable server list is introduced. This tracks both
servers and their coresponding callback interests.
(b) The superblock is now keyed on cell record and numeric volume ID.
(c) The volume record is now tied to the superblock which mounts it,
and is activated when mounted and deactivated when unmounted.
This makes it easier to handle the cache cookie without causing a
double-use in fscache.
(d) The volume record is loaded from the VLDB using VL.GetEntryByNameU
to get the server UUID list.
(e) The volume name is updated if it is seen to have changed when the
volume is updated (the update is keyed on the volume ID).
(3) The vlocation record is got rid of and VLDB records are no longer
cached. Sufficient information is stored in the volume record, though
an update to a volume record is now no longer shared between related
volumes (volumes come in bundles of three: R/W, R/O and backup).
and the following procedural changes are made:
(1) The fileserver cursor introduced previously is now fleshed out and
used to iterate over fileservers and their addresses.
(2) Volume status is checked during iteration, and the server list is
replaced if a change is detected.
(3) Server status is checked during iteration, and the address list is
replaced if a change is detected.
(4) The abort code is saved into the address list cursor and -ECONNABORTED
returned in afs_make_call() if a remote abort happened rather than
translating the abort into an error message. This allows actions to
be taken depending on the abort code more easily.
(a) If a VMOVED abort is seen then this is handled by rechecking the
volume and restarting the iteration.
(b) If a VBUSY, VRESTARTING or VSALVAGING abort is seen then this is
handled by sleeping for a short period and retrying and/or trying
other servers that might serve that volume. A message is also
displayed once until the condition has cleared.
(c) If a VOFFLINE abort is seen, then this is handled as VBUSY for the
moment.
(d) If a VNOVOL abort is seen, the volume is rechecked in the VLDB to
see if it has been deleted; if not, the fileserver is probably
indicating that the volume couldn't be attached and needs
salvaging.
(e) If statfs() sees one of these aborts, it does not sleep, but
rather returns an error, so as not to block the umount program.
(5) The fileserver iteration functions in vnode.c are now merged into
their callers and more heavily macroised around the cursor. vnode.c
is removed.
(6) Operations on a particular vnode are serialised on that vnode because
the server will lock that vnode whilst it operates on it, so a second
op sent will just have to wait.
(7) Fileservers are probed with FS.GetCapabilities before being used.
This is where service upgrade will be done.
(8) A callback interest on a fileserver is set up before an FS operation
is performed and passed through to afs_make_call() so that it can be
set on the vnode if the operation returns a callback. The callback
interest is passed through to afs_iget() also so that it can be set
there too.
In general, record updating is done on an as-needed basis when we try to
access servers, volumes or vnodes rather than offloading it to work items
and special threads.
Notes:
(1) Pre AFS-3.4 servers are no longer supported, though this can be added
back if necessary (AFS-3.4 was released in 1998).
(2) VBUSY is retried forever for the moment at intervals of 1s.
(3) /proc/fs/afs/<cell>/servers no longer exists.
Signed-off-by: David Howells <dhowells@redhat.com>
2017-11-02 22:27:50 +07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i < alist->nr_addrs)
|
|
|
|
memmove(alist->addrs + i + 1,
|
|
|
|
alist->addrs + i,
|
|
|
|
sizeof(alist->addrs[0]) * (alist->nr_addrs - i));
|
|
|
|
|
2018-10-04 15:32:28 +07:00
|
|
|
srx = &alist->addrs[i];
|
2018-10-20 06:57:59 +07:00
|
|
|
srx->srx_family = AF_RXRPC;
|
|
|
|
srx->transport_type = SOCK_DGRAM;
|
2018-10-04 15:32:28 +07:00
|
|
|
srx->transport_len = sizeof(srx->transport.sin);
|
|
|
|
srx->transport.sin.sin_family = AF_INET;
|
|
|
|
srx->transport.sin.sin_port = htons(port);
|
|
|
|
srx->transport.sin.sin_addr.s_addr = xdr;
|
afs: Overhaul volume and server record caching and fileserver rotation
The current code assumes that volumes and servers are per-cell and are
never shared, but this is not enforced, and, indeed, public cells do exist
that are aliases of each other. Further, an organisation can, say, set up
a public cell and a private cell with overlapping, but not identical, sets
of servers. The difference is purely in the database attached to the VL
servers.
The current code will malfunction if it sees a server in two cells as it
assumes global address -> server record mappings and that each server is in
just one cell.
Further, each server may have multiple addresses - and may have addresses
of different families (IPv4 and IPv6, say).
To this end, the following structural changes are made:
(1) Server record management is overhauled:
(a) Server records are made independent of cell. The namespace keeps
track of them, volume records have lists of them and each vnode
has a server on which its callback interest currently resides.
(b) The cell record no longer keeps a list of servers known to be in
that cell.
(c) The server records are now kept in a flat list because there's no
single address to sort on.
(d) Server records are now keyed by their UUID within the namespace.
(e) The addresses for a server are obtained with the VL.GetAddrsU
rather than with VL.GetEntryByName, using the server's UUID as a
parameter.
(f) Cached server records are garbage collected after a period of
non-use and are counted out of existence before purging is allowed
to complete. This protects the work functions against rmmod.
(g) The servers list is now in /proc/fs/afs/servers.
(2) Volume record management is overhauled:
(a) An RCU-replaceable server list is introduced. This tracks both
servers and their coresponding callback interests.
(b) The superblock is now keyed on cell record and numeric volume ID.
(c) The volume record is now tied to the superblock which mounts it,
and is activated when mounted and deactivated when unmounted.
This makes it easier to handle the cache cookie without causing a
double-use in fscache.
(d) The volume record is loaded from the VLDB using VL.GetEntryByNameU
to get the server UUID list.
(e) The volume name is updated if it is seen to have changed when the
volume is updated (the update is keyed on the volume ID).
(3) The vlocation record is got rid of and VLDB records are no longer
cached. Sufficient information is stored in the volume record, though
an update to a volume record is now no longer shared between related
volumes (volumes come in bundles of three: R/W, R/O and backup).
and the following procedural changes are made:
(1) The fileserver cursor introduced previously is now fleshed out and
used to iterate over fileservers and their addresses.
(2) Volume status is checked during iteration, and the server list is
replaced if a change is detected.
(3) Server status is checked during iteration, and the address list is
replaced if a change is detected.
(4) The abort code is saved into the address list cursor and -ECONNABORTED
returned in afs_make_call() if a remote abort happened rather than
translating the abort into an error message. This allows actions to
be taken depending on the abort code more easily.
(a) If a VMOVED abort is seen then this is handled by rechecking the
volume and restarting the iteration.
(b) If a VBUSY, VRESTARTING or VSALVAGING abort is seen then this is
handled by sleeping for a short period and retrying and/or trying
other servers that might serve that volume. A message is also
displayed once until the condition has cleared.
(c) If a VOFFLINE abort is seen, then this is handled as VBUSY for the
moment.
(d) If a VNOVOL abort is seen, the volume is rechecked in the VLDB to
see if it has been deleted; if not, the fileserver is probably
indicating that the volume couldn't be attached and needs
salvaging.
(e) If statfs() sees one of these aborts, it does not sleep, but
rather returns an error, so as not to block the umount program.
(5) The fileserver iteration functions in vnode.c are now merged into
their callers and more heavily macroised around the cursor. vnode.c
is removed.
(6) Operations on a particular vnode are serialised on that vnode because
the server will lock that vnode whilst it operates on it, so a second
op sent will just have to wait.
(7) Fileservers are probed with FS.GetCapabilities before being used.
This is where service upgrade will be done.
(8) A callback interest on a fileserver is set up before an FS operation
is performed and passed through to afs_make_call() so that it can be
set on the vnode if the operation returns a callback. The callback
interest is passed through to afs_iget() also so that it can be set
there too.
In general, record updating is done on an as-needed basis when we try to
access servers, volumes or vnodes rather than offloading it to work items
and special threads.
Notes:
(1) Pre AFS-3.4 servers are no longer supported, though this can be added
back if necessary (AFS-3.4 was released in 1998).
(2) VBUSY is retried forever for the moment at intervals of 1s.
(3) /proc/fs/afs/<cell>/servers no longer exists.
Signed-off-by: David Howells <dhowells@redhat.com>
2017-11-02 22:27:50 +07:00
|
|
|
alist->nr_ipv4++;
|
|
|
|
alist->nr_addrs++;
|
|
|
|
}
|
|
|
|
|
2017-11-02 22:27:51 +07:00
|
|
|
/*
|
|
|
|
* Merge an IPv6 entry into a fileserver address list.
|
|
|
|
*/
|
|
|
|
void afs_merge_fs_addr6(struct afs_addr_list *alist, __be32 *xdr, u16 port)
|
|
|
|
{
|
2018-10-04 15:32:28 +07:00
|
|
|
struct sockaddr_rxrpc *srx;
|
2017-11-02 22:27:51 +07:00
|
|
|
int i, diff;
|
|
|
|
|
2018-10-04 15:32:27 +07:00
|
|
|
if (alist->nr_addrs >= alist->max_addrs)
|
|
|
|
return;
|
|
|
|
|
2017-11-02 22:27:51 +07:00
|
|
|
for (i = alist->nr_ipv4; i < alist->nr_addrs; i++) {
|
2018-10-04 15:32:28 +07:00
|
|
|
struct sockaddr_in6 *a = &alist->addrs[i].transport.sin6;
|
|
|
|
u16 a_port = ntohs(a->sin6_port);
|
|
|
|
|
2017-11-02 22:27:51 +07:00
|
|
|
diff = memcmp(xdr, &a->sin6_addr, 16);
|
2018-10-04 15:32:28 +07:00
|
|
|
if (diff == 0 && port == a_port)
|
2017-11-02 22:27:51 +07:00
|
|
|
return;
|
2018-10-04 15:32:28 +07:00
|
|
|
if (diff == 0 && port < a_port)
|
2017-11-02 22:27:51 +07:00
|
|
|
break;
|
|
|
|
if (diff < 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i < alist->nr_addrs)
|
|
|
|
memmove(alist->addrs + i + 1,
|
|
|
|
alist->addrs + i,
|
|
|
|
sizeof(alist->addrs[0]) * (alist->nr_addrs - i));
|
|
|
|
|
2018-10-04 15:32:28 +07:00
|
|
|
srx = &alist->addrs[i];
|
2018-10-20 06:57:59 +07:00
|
|
|
srx->srx_family = AF_RXRPC;
|
|
|
|
srx->transport_type = SOCK_DGRAM;
|
2018-10-04 15:32:28 +07:00
|
|
|
srx->transport_len = sizeof(srx->transport.sin6);
|
|
|
|
srx->transport.sin6.sin6_family = AF_INET6;
|
|
|
|
srx->transport.sin6.sin6_port = htons(port);
|
|
|
|
memcpy(&srx->transport.sin6.sin6_addr, xdr, 16);
|
2017-11-02 22:27:51 +07:00
|
|
|
alist->nr_addrs++;
|
|
|
|
}
|
|
|
|
|
2017-11-02 22:27:50 +07:00
|
|
|
/*
|
|
|
|
* Get an address to try.
|
|
|
|
*/
|
|
|
|
bool afs_iterate_addresses(struct afs_addr_cursor *ac)
|
|
|
|
{
|
2018-10-20 06:57:59 +07:00
|
|
|
unsigned long set, failed;
|
|
|
|
int index;
|
2017-11-02 22:27:50 +07:00
|
|
|
|
|
|
|
if (!ac->alist)
|
|
|
|
return false;
|
|
|
|
|
2018-10-20 06:57:59 +07:00
|
|
|
set = ac->alist->responded;
|
|
|
|
failed = ac->alist->failed;
|
|
|
|
_enter("%lx-%lx-%lx,%d", set, failed, ac->tried, ac->index);
|
|
|
|
|
2018-10-20 06:57:58 +07:00
|
|
|
ac->nr_iterations++;
|
|
|
|
|
2018-10-20 06:57:59 +07:00
|
|
|
set &= ~(failed | ac->tried);
|
2017-11-02 22:27:50 +07:00
|
|
|
|
2018-10-20 06:57:59 +07:00
|
|
|
if (!set)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
index = READ_ONCE(ac->alist->preferred);
|
|
|
|
if (test_bit(index, &set))
|
|
|
|
goto selected;
|
|
|
|
|
|
|
|
index = __ffs(set);
|
2017-11-02 22:27:50 +07:00
|
|
|
|
2018-10-20 06:57:59 +07:00
|
|
|
selected:
|
|
|
|
ac->index = index;
|
|
|
|
set_bit(index, &ac->tried);
|
2017-11-02 22:27:50 +07:00
|
|
|
ac->responded = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release an address list cursor.
|
|
|
|
*/
|
|
|
|
int afs_end_cursor(struct afs_addr_cursor *ac)
|
|
|
|
{
|
2018-02-06 13:26:30 +07:00
|
|
|
struct afs_addr_list *alist;
|
|
|
|
|
|
|
|
alist = ac->alist;
|
|
|
|
if (alist) {
|
2018-10-20 06:57:59 +07:00
|
|
|
if (ac->responded &&
|
|
|
|
ac->index != alist->preferred &&
|
|
|
|
test_bit(ac->alist->preferred, &ac->tried))
|
|
|
|
WRITE_ONCE(alist->preferred, ac->index);
|
2018-02-06 13:26:30 +07:00
|
|
|
afs_put_addrlist(alist);
|
2018-10-20 06:57:59 +07:00
|
|
|
ac->alist = NULL;
|
2018-02-06 13:26:30 +07:00
|
|
|
}
|
2017-11-02 22:27:50 +07:00
|
|
|
|
|
|
|
return ac->error;
|
|
|
|
}
|