2019-05-27 06:55:01 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2007-04-26 22:49:28 +00:00
|
|
|
/* /proc interface for AFS
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
|
|
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/seq_file.h>
|
Detach sched.h from mm.h
First thing mm.h does is including sched.h solely for can_do_mlock() inline
function which has "current" dereference inside. By dealing with can_do_mlock()
mm.h can be detached from sched.h which is good. See below, why.
This patch
a) removes unconditional inclusion of sched.h from mm.h
b) makes can_do_mlock() normal function in mm/mlock.c
c) exports can_do_mlock() to not break compilation
d) adds sched.h inclusions back to files that were getting it indirectly.
e) adds less bloated headers to some files (asm/signal.h, jiffies.h) that were
getting them indirectly
Net result is:
a) mm.h users would get less code to open, read, preprocess, parse, ... if
they don't need sched.h
b) sched.h stops being dependency for significant number of files:
on x86_64 allmodconfig touching sched.h results in recompile of 4083 files,
after patch it's only 3744 (-8.3%).
Cross-compile tested on
all arm defconfigs, all mips defconfigs, all powerpc defconfigs,
alpha alpha-up
arm
i386 i386-up i386-defconfig i386-allnoconfig
ia64 ia64-up
m68k
mips
parisc parisc-up
powerpc powerpc-up
s390 s390-up
sparc sparc-up
sparc64 sparc64-up
um-x86_64
x86_64 x86_64-up x86_64-defconfig x86_64-allnoconfig
as well as my two usual configs.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-20 21:22:52 +00:00
|
|
|
#include <linux/sched.h>
|
2016-12-24 19:46:01 +00:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include "internal.h"
|
|
|
|
|
2018-10-19 23:57:57 +00:00
|
|
|
struct afs_vl_seq_net_private {
|
|
|
|
struct seq_net_private seq; /* Must be first */
|
|
|
|
struct afs_vlserver_list *vllist;
|
|
|
|
};
|
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
static inline struct afs_net *afs_seq2net(struct seq_file *m)
|
2017-11-02 15:27:45 +00:00
|
|
|
{
|
2018-05-18 10:46:15 +00:00
|
|
|
return afs_net(seq_file_net(m));
|
2017-11-02 15:27:45 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
static inline struct afs_net *afs_seq2net_single(struct seq_file *m)
|
2017-11-02 15:27:45 +00:00
|
|
|
{
|
2018-05-18 10:46:15 +00:00
|
|
|
return afs_net(seq_file_single_net(m));
|
2017-11-02 15:27:45 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-05-18 10:46:14 +00:00
|
|
|
/*
|
2018-05-18 10:46:15 +00:00
|
|
|
* Display the list of cells known to the namespace.
|
2018-05-18 10:46:14 +00:00
|
|
|
*/
|
|
|
|
static int afs_proc_cells_show(struct seq_file *m, void *v)
|
|
|
|
{
|
2018-10-19 23:57:57 +00:00
|
|
|
struct afs_vlserver_list *vllist;
|
|
|
|
struct afs_cell *cell;
|
2018-05-18 10:46:14 +00:00
|
|
|
|
2018-10-11 21:45:49 +00:00
|
|
|
if (v == SEQ_START_TOKEN) {
|
2018-05-18 10:46:14 +00:00
|
|
|
/* display header on line 1 */
|
2019-07-23 10:24:59 +00:00
|
|
|
seq_puts(m, "USE ACT TTL SV ST NAME\n");
|
2018-05-18 10:46:14 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-19 23:57:57 +00:00
|
|
|
cell = list_entry(v, struct afs_cell, proc_link);
|
|
|
|
vllist = rcu_dereference(cell->vl_servers);
|
|
|
|
|
2018-05-18 10:46:14 +00:00
|
|
|
/* display one cell per line on subsequent lines */
|
2019-07-23 10:24:59 +00:00
|
|
|
seq_printf(m, "%3u %3u %6lld %2u %2u %s\n",
|
2022-07-06 09:52:14 +00:00
|
|
|
refcount_read(&cell->ref),
|
2019-07-23 10:24:59 +00:00
|
|
|
atomic_read(&cell->active),
|
2018-10-19 23:57:57 +00:00
|
|
|
cell->dns_expiry - ktime_get_real_seconds(),
|
2019-07-23 10:24:59 +00:00
|
|
|
vllist ? vllist->nr_servers : 0,
|
afs: Detect cell aliases 1 - Cells with root volumes
Put in the first phase of cell alias detection. This part handles alias
detection for cells that have root.cell volumes (which is expected to be
likely).
When a cell becomes newly active, it is probed for its root.cell volume,
and if it has one, this volume is compared against other root.cell volumes
to find out if the list of fileserver UUIDs have any in common - and if
that's the case, do the address lists of those fileservers have any
addresses in common. If they do, the new cell is adjudged to be an alias
of the old cell and the old cell is used instead.
Comparing is aided by the server list in struct afs_server_list being
sorted in UUID order and the addresses in the fileserver address lists
being sorted in address order.
The cell then retains the afs_volume object for the root.cell volume, even
if it's not mounted for future alias checking.
This necessary because:
(1) Whilst fileservers have UUIDs that are meant to be globally unique, in
practice they are not because cells get cloned without changing the
UUIDs - so afs_server records need to be per cell.
(2) Sometimes the DNS is used to make cell aliases - but if we don't know
they're the same, we may end up with multiple superblocks and multiple
afs_server records for the same thing, impairing our ability to
deliver callback notifications of third party changes
(3) The fileserver RPC API doesn't contain the cell name, so it can't tell
us which cell it's notifying and can't see that a change made to to
one cell should notify the same client that's also accessed as the
other cell.
Reported-by: Jeffrey Altman <jaltman@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
2020-04-25 09:26:02 +00:00
|
|
|
cell->state,
|
2018-10-19 23:57:57 +00:00
|
|
|
cell->name);
|
2018-05-18 10:46:14 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static void *afs_proc_cells_start(struct seq_file *m, loff_t *_pos)
|
2018-04-09 20:12:31 +00:00
|
|
|
__acquires(rcu)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-11-02 15:27:50 +00:00
|
|
|
rcu_read_lock();
|
2018-10-11 21:45:49 +00:00
|
|
|
return seq_hlist_start_head_rcu(&afs_seq2net(m)->proc_cells, *_pos);
|
2007-04-26 22:49:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2017-11-02 15:27:45 +00:00
|
|
|
static void *afs_proc_cells_next(struct seq_file *m, void *v, loff_t *pos)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2018-10-11 21:45:49 +00:00
|
|
|
return seq_hlist_next_rcu(v, &afs_seq2net(m)->proc_cells, pos);
|
2007-04-26 22:49:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2017-11-02 15:27:45 +00:00
|
|
|
static void afs_proc_cells_stop(struct seq_file *m, void *v)
|
2018-04-09 20:12:31 +00:00
|
|
|
__releases(rcu)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-11-02 15:27:50 +00:00
|
|
|
rcu_read_unlock();
|
2007-04-26 22:49:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
static const struct seq_operations afs_proc_cells_ops = {
|
|
|
|
.start = afs_proc_cells_start,
|
|
|
|
.next = afs_proc_cells_next,
|
|
|
|
.stop = afs_proc_cells_stop,
|
|
|
|
.show = afs_proc_cells_show,
|
|
|
|
};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* handle writes to /proc/fs/afs/cells
|
|
|
|
* - to add cells: echo "add <cellname> <IP>[:<IP>][:<IP>]"
|
|
|
|
*/
|
2018-05-18 10:46:15 +00:00
|
|
|
static int afs_proc_cells_write(struct file *file, char *buf, size_t size)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2018-05-18 10:46:15 +00:00
|
|
|
struct seq_file *m = file->private_data;
|
|
|
|
struct afs_net *net = afs_seq2net(m);
|
|
|
|
char *name, *args;
|
2005-04-16 22:20:36 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* trim to first NL */
|
2018-05-18 10:46:15 +00:00
|
|
|
name = memchr(buf, '\n', size);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (name)
|
|
|
|
*name = 0;
|
|
|
|
|
|
|
|
/* split into command, name and argslist */
|
2018-05-18 10:46:15 +00:00
|
|
|
name = strchr(buf, ' ');
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!name)
|
|
|
|
goto inval;
|
|
|
|
do {
|
|
|
|
*name++ = 0;
|
|
|
|
} while(*name == ' ');
|
|
|
|
if (!*name)
|
|
|
|
goto inval;
|
|
|
|
|
|
|
|
args = strchr(name, ' ');
|
2018-09-07 22:55:17 +00:00
|
|
|
if (args) {
|
|
|
|
do {
|
|
|
|
*args++ = 0;
|
|
|
|
} while(*args == ' ');
|
|
|
|
if (!*args)
|
|
|
|
goto inval;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* determine command to perform */
|
2018-05-18 10:46:15 +00:00
|
|
|
_debug("cmd=%s name=%s args=%s", buf, name, args);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
if (strcmp(buf, "add") == 0) {
|
2005-04-16 22:20:36 +00:00
|
|
|
struct afs_cell *cell;
|
2007-04-26 22:55:03 +00:00
|
|
|
|
2017-11-02 15:27:50 +00:00
|
|
|
cell = afs_lookup_cell(net, name, strlen(name), args, true);
|
2007-04-26 22:55:03 +00:00
|
|
|
if (IS_ERR(cell)) {
|
|
|
|
ret = PTR_ERR(cell);
|
2005-04-16 22:20:36 +00:00
|
|
|
goto done;
|
2007-04-26 22:55:03 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-04-09 20:12:31 +00:00
|
|
|
if (test_and_set_bit(AFS_CELL_FL_NO_GC, &cell->flags))
|
2020-10-13 19:51:59 +00:00
|
|
|
afs_unuse_cell(net, cell, afs_cell_trace_unuse_no_pin);
|
2007-04-26 22:49:28 +00:00
|
|
|
} else {
|
2005-04-16 22:20:36 +00:00
|
|
|
goto inval;
|
|
|
|
}
|
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
ret = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-04-26 22:49:28 +00:00
|
|
|
done:
|
2005-04-16 22:20:36 +00:00
|
|
|
_leave(" = %d", ret);
|
|
|
|
return ret;
|
|
|
|
|
2007-04-26 22:49:28 +00:00
|
|
|
inval:
|
2005-04-16 22:20:36 +00:00
|
|
|
ret = -EINVAL;
|
|
|
|
printk("kAFS: Invalid Command on /proc/fs/afs/cells file\n");
|
|
|
|
goto done;
|
2007-04-26 22:49:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2023-10-27 10:42:57 +00:00
|
|
|
/*
|
|
|
|
* Display the list of addr_prefs known to the namespace.
|
|
|
|
*/
|
|
|
|
static int afs_proc_addr_prefs_show(struct seq_file *m, void *v)
|
|
|
|
{
|
|
|
|
struct afs_addr_preference_list *preflist;
|
|
|
|
struct afs_addr_preference *pref;
|
|
|
|
struct afs_net *net = afs_seq2net_single(m);
|
|
|
|
union {
|
|
|
|
struct sockaddr_in sin;
|
|
|
|
struct sockaddr_in6 sin6;
|
|
|
|
} addr;
|
|
|
|
unsigned int i;
|
|
|
|
char buf[44]; /* Maximum ipv6 + max subnet is 43 */
|
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
preflist = rcu_dereference(net->address_prefs);
|
|
|
|
|
|
|
|
if (!preflist) {
|
|
|
|
seq_puts(m, "NO PREFS\n");
|
2024-01-17 15:49:26 +00:00
|
|
|
goto out;
|
2023-10-27 10:42:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
seq_printf(m, "PROT SUBNET PRIOR (v=%u n=%u/%u/%u)\n",
|
|
|
|
preflist->version, preflist->ipv6_off, preflist->nr, preflist->max_prefs);
|
|
|
|
|
|
|
|
memset(&addr, 0, sizeof(addr));
|
|
|
|
|
|
|
|
for (i = 0; i < preflist->nr; i++) {
|
|
|
|
pref = &preflist->prefs[i];
|
|
|
|
|
|
|
|
addr.sin.sin_family = pref->family;
|
|
|
|
if (pref->family == AF_INET) {
|
|
|
|
memcpy(&addr.sin.sin_addr, &pref->ipv4_addr,
|
|
|
|
sizeof(addr.sin.sin_addr));
|
|
|
|
snprintf(buf, sizeof(buf), "%pISc/%u", &addr.sin, pref->subnet_mask);
|
|
|
|
seq_printf(m, "UDP %-43.43s %5u\n", buf, pref->prio);
|
|
|
|
} else {
|
|
|
|
memcpy(&addr.sin6.sin6_addr, &pref->ipv6_addr,
|
|
|
|
sizeof(addr.sin6.sin6_addr));
|
|
|
|
snprintf(buf, sizeof(buf), "%pISc/%u", &addr.sin6, pref->subnet_mask);
|
|
|
|
seq_printf(m, "UDP %-43.43s %5u\n", buf, pref->prio);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-17 15:49:26 +00:00
|
|
|
out:
|
|
|
|
rcu_read_unlock();
|
2023-10-27 10:42:57 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
/*
|
2018-05-18 10:46:15 +00:00
|
|
|
* Display the name of the current workstation cell.
|
2018-05-18 10:46:15 +00:00
|
|
|
*/
|
2018-05-18 10:46:15 +00:00
|
|
|
static int afs_proc_rootcell_show(struct seq_file *m, void *v)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2018-04-06 13:17:23 +00:00
|
|
|
struct afs_cell *cell;
|
2018-05-18 10:46:15 +00:00
|
|
|
struct afs_net *net;
|
|
|
|
|
|
|
|
net = afs_seq2net_single(m);
|
2019-07-23 10:24:59 +00:00
|
|
|
down_read(&net->cells_lock);
|
|
|
|
cell = net->ws_cell;
|
|
|
|
if (cell)
|
|
|
|
seq_printf(m, "%s\n", cell->name);
|
|
|
|
up_read(&net->cells_lock);
|
2018-05-18 10:46:15 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2018-05-18 10:46:15 +00:00
|
|
|
* Set the current workstation cell and optionally supply its list of volume
|
|
|
|
* location servers.
|
|
|
|
*
|
|
|
|
* echo "cell.name:192.168.231.14" >/proc/fs/afs/rootcell
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2018-05-18 10:46:15 +00:00
|
|
|
static int afs_proc_rootcell_write(struct file *file, char *buf, size_t size)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2018-05-18 10:46:15 +00:00
|
|
|
struct seq_file *m = file->private_data;
|
|
|
|
struct afs_net *net = afs_seq2net_single(m);
|
|
|
|
char *s;
|
2005-04-16 22:20:36 +00:00
|
|
|
int ret;
|
|
|
|
|
2018-04-09 20:12:31 +00:00
|
|
|
ret = -EINVAL;
|
2018-05-18 10:46:15 +00:00
|
|
|
if (buf[0] == '.')
|
2018-04-09 20:12:31 +00:00
|
|
|
goto out;
|
2018-05-18 10:46:15 +00:00
|
|
|
if (memchr(buf, '/', size))
|
2018-04-09 20:12:31 +00:00
|
|
|
goto out;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* trim to first NL */
|
2018-05-18 10:46:15 +00:00
|
|
|
s = memchr(buf, '\n', size);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (s)
|
|
|
|
*s = 0;
|
|
|
|
|
|
|
|
/* determine command to perform */
|
2018-05-18 10:46:15 +00:00
|
|
|
_debug("rootcell=%s", buf);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
ret = afs_cell_init(net, buf);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-04-09 20:12:31 +00:00
|
|
|
out:
|
2005-04-16 22:20:36 +00:00
|
|
|
_leave(" = %d", ret);
|
|
|
|
return ret;
|
2007-04-26 22:49:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-05-18 10:46:14 +00:00
|
|
|
static const char afs_vol_types[3][3] = {
|
|
|
|
[AFSVL_RWVOL] = "RW",
|
|
|
|
[AFSVL_ROVOL] = "RO",
|
|
|
|
[AFSVL_BACKVOL] = "BK",
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2018-05-18 10:46:15 +00:00
|
|
|
* Display the list of volumes known to a cell.
|
2018-05-18 10:46:14 +00:00
|
|
|
*/
|
|
|
|
static int afs_proc_cell_volumes_show(struct seq_file *m, void *v)
|
|
|
|
{
|
2020-04-30 00:03:49 +00:00
|
|
|
struct afs_volume *vol = hlist_entry(v, struct afs_volume, proc_link);
|
2018-05-18 10:46:14 +00:00
|
|
|
|
|
|
|
/* Display header on line 1 */
|
2020-04-30 00:03:49 +00:00
|
|
|
if (v == SEQ_START_TOKEN) {
|
2019-12-11 08:58:59 +00:00
|
|
|
seq_puts(m, "USE VID TY NAME\n");
|
2018-05-18 10:46:14 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-12-11 08:58:59 +00:00
|
|
|
seq_printf(m, "%3d %08llx %s %s\n",
|
2022-07-06 09:52:14 +00:00
|
|
|
refcount_read(&vol->ref), vol->vid,
|
2019-12-11 08:58:59 +00:00
|
|
|
afs_vol_types[vol->type],
|
|
|
|
vol->name);
|
2018-05-18 10:46:14 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static void *afs_proc_cell_volumes_start(struct seq_file *m, loff_t *_pos)
|
2018-04-09 20:12:31 +00:00
|
|
|
__acquires(cell->proc_lock)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2022-01-22 06:14:23 +00:00
|
|
|
struct afs_cell *cell = pde_data(file_inode(m->file));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-04-30 00:03:49 +00:00
|
|
|
rcu_read_lock();
|
|
|
|
return seq_hlist_start_head_rcu(&cell->proc_volumes, *_pos);
|
2007-04-26 22:49:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
static void *afs_proc_cell_volumes_next(struct seq_file *m, void *v,
|
2005-04-16 22:20:36 +00:00
|
|
|
loff_t *_pos)
|
|
|
|
{
|
2022-01-22 06:14:23 +00:00
|
|
|
struct afs_cell *cell = pde_data(file_inode(m->file));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-04-30 00:03:49 +00:00
|
|
|
return seq_hlist_next_rcu(v, &cell->proc_volumes, _pos);
|
2007-04-26 22:49:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
static void afs_proc_cell_volumes_stop(struct seq_file *m, void *v)
|
2018-04-09 20:12:31 +00:00
|
|
|
__releases(cell->proc_lock)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2020-04-30 00:03:49 +00:00
|
|
|
rcu_read_unlock();
|
2007-04-26 22:49:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
static const struct seq_operations afs_proc_cell_volumes_ops = {
|
|
|
|
.start = afs_proc_cell_volumes_start,
|
|
|
|
.next = afs_proc_cell_volumes_next,
|
|
|
|
.stop = afs_proc_cell_volumes_stop,
|
|
|
|
.show = afs_proc_cell_volumes_show,
|
|
|
|
};
|
|
|
|
|
2018-10-19 23:57:57 +00:00
|
|
|
static const char *const dns_record_sources[NR__dns_record_source + 1] = {
|
|
|
|
[DNS_RECORD_UNAVAILABLE] = "unav",
|
|
|
|
[DNS_RECORD_FROM_CONFIG] = "cfg",
|
|
|
|
[DNS_RECORD_FROM_DNS_A] = "A",
|
|
|
|
[DNS_RECORD_FROM_DNS_AFSDB] = "AFSDB",
|
|
|
|
[DNS_RECORD_FROM_DNS_SRV] = "SRV",
|
|
|
|
[DNS_RECORD_FROM_NSS] = "nss",
|
|
|
|
[NR__dns_record_source] = "[weird]"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *const dns_lookup_statuses[NR__dns_lookup_status + 1] = {
|
|
|
|
[DNS_LOOKUP_NOT_DONE] = "no-lookup",
|
|
|
|
[DNS_LOOKUP_GOOD] = "good",
|
|
|
|
[DNS_LOOKUP_GOOD_WITH_BAD] = "good/bad",
|
|
|
|
[DNS_LOOKUP_BAD] = "bad",
|
|
|
|
[DNS_LOOKUP_GOT_NOT_FOUND] = "not-found",
|
|
|
|
[DNS_LOOKUP_GOT_LOCAL_FAILURE] = "local-failure",
|
|
|
|
[DNS_LOOKUP_GOT_TEMP_FAILURE] = "temp-failure",
|
|
|
|
[DNS_LOOKUP_GOT_NS_FAILURE] = "ns-failure",
|
|
|
|
[NR__dns_lookup_status] = "[weird]"
|
|
|
|
};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
2018-05-18 10:46:15 +00:00
|
|
|
* Display the list of Volume Location servers we're using for a cell.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2018-05-18 10:46:14 +00:00
|
|
|
static int afs_proc_cell_vlservers_show(struct seq_file *m, void *v)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2018-10-19 23:57:57 +00:00
|
|
|
const struct afs_vl_seq_net_private *priv = m->private;
|
|
|
|
const struct afs_vlserver_list *vllist = priv->vllist;
|
|
|
|
const struct afs_vlserver_entry *entry;
|
|
|
|
const struct afs_vlserver *vlserver;
|
|
|
|
const struct afs_addr_list *alist;
|
|
|
|
int i;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-10-19 23:57:57 +00:00
|
|
|
if (v == SEQ_START_TOKEN) {
|
|
|
|
seq_printf(m, "# source %s, status %s\n",
|
2019-05-07 14:30:34 +00:00
|
|
|
dns_record_sources[vllist ? vllist->source : 0],
|
|
|
|
dns_lookup_statuses[vllist ? vllist->status : 0]);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-19 23:57:57 +00:00
|
|
|
entry = v;
|
|
|
|
vlserver = entry->server;
|
|
|
|
alist = rcu_dereference(vlserver->addresses);
|
|
|
|
|
|
|
|
seq_printf(m, "%s [p=%hu w=%hu s=%s,%s]:\n",
|
|
|
|
vlserver->name, entry->priority, entry->weight,
|
|
|
|
dns_record_sources[alist ? alist->source : entry->source],
|
|
|
|
dns_lookup_statuses[alist ? alist->status : entry->status]);
|
|
|
|
if (alist) {
|
|
|
|
for (i = 0; i < alist->nr_addrs; i++)
|
|
|
|
seq_printf(m, " %c %pISpc\n",
|
2018-10-19 23:57:59 +00:00
|
|
|
alist->preferred == i ? '>' : '-',
|
rxrpc, afs: Allow afs to pin rxrpc_peer objects
Change rxrpc's API such that:
(1) A new function, rxrpc_kernel_lookup_peer(), is provided to look up an
rxrpc_peer record for a remote address and a corresponding function,
rxrpc_kernel_put_peer(), is provided to dispose of it again.
(2) When setting up a call, the rxrpc_peer object used during a call is
now passed in rather than being set up by rxrpc_connect_call(). For
afs, this meenat passing it to rxrpc_kernel_begin_call() rather than
the full address (the service ID then has to be passed in as a
separate parameter).
(3) A new function, rxrpc_kernel_remote_addr(), is added so that afs can
get a pointer to the transport address for display purposed, and
another, rxrpc_kernel_remote_srx(), to gain a pointer to the full
rxrpc address.
(4) The function to retrieve the RTT from a call, rxrpc_kernel_get_srtt(),
is then altered to take a peer. This now returns the RTT or -1 if
there are insufficient samples.
(5) Rename rxrpc_kernel_get_peer() to rxrpc_kernel_call_get_peer().
(6) Provide a new function, rxrpc_kernel_get_peer(), to get a ref on a
peer the caller already has.
This allows the afs filesystem to pin the rxrpc_peer records that it is
using, allowing faster lookups and pointer comparisons rather than
comparing sockaddr_rxrpc contents. It also makes it easier to get hold of
the RTT. The following changes are made to afs:
(1) The addr_list struct's addrs[] elements now hold a peer struct pointer
and a service ID rather than a sockaddr_rxrpc.
(2) When displaying the transport address, rxrpc_kernel_remote_addr() is
used.
(3) The port arg is removed from afs_alloc_addrlist() since it's always
overridden.
(4) afs_merge_fs_addr4() and afs_merge_fs_addr6() do peer lookup and may
now return an error that must be handled.
(5) afs_find_server() now takes a peer pointer to specify the address.
(6) afs_find_server(), afs_compare_fs_alists() and afs_merge_fs_addr[46]{}
now do peer pointer comparison rather than address comparison.
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
2023-10-19 11:55:11 +00:00
|
|
|
rxrpc_kernel_remote_addr(alist->addrs[i].peer));
|
2018-10-19 23:57:57 +00:00
|
|
|
}
|
2020-08-19 14:27:17 +00:00
|
|
|
seq_printf(m, " info: fl=%lx rtt=%d\n", vlserver->flags, vlserver->rtt);
|
2020-08-20 14:01:54 +00:00
|
|
|
seq_printf(m, " probe: fl=%x e=%d ac=%d out=%d\n",
|
|
|
|
vlserver->probe.flags, vlserver->probe.error,
|
|
|
|
vlserver->probe.abort_code,
|
|
|
|
atomic_read(&vlserver->probe_outstanding));
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
2007-04-26 22:49:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static void *afs_proc_cell_vlservers_start(struct seq_file *m, loff_t *_pos)
|
2018-04-09 20:12:31 +00:00
|
|
|
__acquires(rcu)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2018-10-19 23:57:57 +00:00
|
|
|
struct afs_vl_seq_net_private *priv = m->private;
|
|
|
|
struct afs_vlserver_list *vllist;
|
2022-01-22 06:14:23 +00:00
|
|
|
struct afs_cell *cell = pde_data(file_inode(m->file));
|
2005-04-16 22:20:36 +00:00
|
|
|
loff_t pos = *_pos;
|
|
|
|
|
2017-11-02 15:27:50 +00:00
|
|
|
rcu_read_lock();
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-10-19 23:57:57 +00:00
|
|
|
vllist = rcu_dereference(cell->vl_servers);
|
|
|
|
priv->vllist = vllist;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-10-19 23:57:57 +00:00
|
|
|
if (pos < 0)
|
|
|
|
*_pos = pos = 0;
|
|
|
|
if (pos == 0)
|
|
|
|
return SEQ_START_TOKEN;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2019-05-07 14:30:34 +00:00
|
|
|
if (pos - 1 >= vllist->nr_servers)
|
2005-04-16 22:20:36 +00:00
|
|
|
return NULL;
|
|
|
|
|
2018-10-19 23:57:57 +00:00
|
|
|
return &vllist->servers[pos - 1];
|
2007-04-26 22:49:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
static void *afs_proc_cell_vlservers_next(struct seq_file *m, void *v,
|
2005-04-16 22:20:36 +00:00
|
|
|
loff_t *_pos)
|
|
|
|
{
|
2018-10-19 23:57:57 +00:00
|
|
|
struct afs_vl_seq_net_private *priv = m->private;
|
|
|
|
struct afs_vlserver_list *vllist = priv->vllist;
|
2005-04-16 22:20:36 +00:00
|
|
|
loff_t pos;
|
|
|
|
|
|
|
|
pos = *_pos;
|
2018-10-19 23:57:57 +00:00
|
|
|
pos++;
|
|
|
|
*_pos = pos;
|
|
|
|
if (!vllist || pos - 1 >= vllist->nr_servers)
|
2005-04-16 22:20:36 +00:00
|
|
|
return NULL;
|
|
|
|
|
2018-10-19 23:57:57 +00:00
|
|
|
return &vllist->servers[pos - 1];
|
2007-04-26 22:49:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
static void afs_proc_cell_vlservers_stop(struct seq_file *m, void *v)
|
2018-04-09 20:12:31 +00:00
|
|
|
__releases(rcu)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2017-11-02 15:27:50 +00:00
|
|
|
rcu_read_unlock();
|
2007-04-26 22:49:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
static const struct seq_operations afs_proc_cell_vlservers_ops = {
|
|
|
|
.start = afs_proc_cell_vlservers_start,
|
|
|
|
.next = afs_proc_cell_vlservers_next,
|
|
|
|
.stop = afs_proc_cell_vlservers_stop,
|
|
|
|
.show = afs_proc_cell_vlservers_show,
|
|
|
|
};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
2018-05-18 10:46:15 +00:00
|
|
|
* Display the list of fileservers we're using within a namespace.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2018-05-18 10:46:14 +00:00
|
|
|
static int afs_proc_servers_show(struct seq_file *m, void *v)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2023-10-31 16:30:37 +00:00
|
|
|
struct afs_endpoint_state *estate;
|
2018-05-18 10:46:14 +00:00
|
|
|
struct afs_addr_list *alist;
|
2023-10-31 16:30:37 +00:00
|
|
|
struct afs_server *server;
|
2023-10-27 09:45:56 +00:00
|
|
|
unsigned long failed;
|
2018-06-02 21:20:31 +00:00
|
|
|
int i;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-05-18 10:46:14 +00:00
|
|
|
if (v == SEQ_START_TOKEN) {
|
2023-10-27 09:45:56 +00:00
|
|
|
seq_puts(m, "UUID REF ACT CELL\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-05-18 10:46:14 +00:00
|
|
|
server = list_entry(v, struct afs_server, proc_link);
|
2023-10-31 16:30:37 +00:00
|
|
|
estate = rcu_dereference(server->endpoint_state);
|
|
|
|
alist = estate->addresses;
|
2023-10-27 09:45:56 +00:00
|
|
|
seq_printf(m, "%pU %3d %3d %s\n",
|
2018-05-18 10:46:14 +00:00
|
|
|
&server->uuid,
|
2022-07-06 09:52:14 +00:00
|
|
|
refcount_read(&server->ref),
|
2023-10-27 09:45:56 +00:00
|
|
|
atomic_read(&server->active),
|
|
|
|
server->cell->name);
|
afs: Overhaul invalidation handling to better support RO volumes
Overhaul the third party-induced invalidation handling, making use of the
previously added volume-level event counters (cb_scrub and cb_ro_snapshot)
that are now being parsed out of the VolSync record returned by the
fileserver in many of its replies.
This allows better handling of RO (and Backup) volumes. Since these are
snapshot of a RW volume that are updated atomically simultantanously across
all servers that host them, they only require a single callback promise for
the entire volume. The currently upstream code assumes that RO volumes
operate in the same manner as RW volumes, and that each file has its own
individual callback - which means that it does a status fetch for *every*
file in a RO volume, whether or not the volume got "released" (volume
callback breaks can occur for other reasons too, such as the volumeserver
taking ownership of a volume from a fileserver).
To this end, make the following changes:
(1) Change the meaning of the volume's cb_v_break counter so that it is
now a hint that we need to issue a status fetch to work out the state
of a volume. cb_v_break is incremented by volume break callbacks and
by server initialisation callbacks.
(2) Add a second counter, cb_v_check, to the afs_volume struct such that
if this differs from cb_v_break, we need to do a check. When the
check is complete, cb_v_check is advanced to what cb_v_break was at
the start of the status fetch.
(3) Move the list of mmap'd vnodes to the volume and trigger removal of
PTEs that map to files on a volume break rather than on a server
break.
(4) When a server reinitialisation callback comes in, use the
server-to-volume reverse mapping added in a preceding patch to iterate
over all the volumes using that server and clear the volume callback
promises for that server and the general volume promise as a whole to
trigger reanalysis.
(5) Replace the AFS_VNODE_CB_PROMISED flag with an AFS_NO_CB_PROMISE
(TIME64_MIN) value in the cb_expires_at field, reducing the number of
checks we need to make.
(6) Change afs_check_validity() to quickly see if various event counters
have been incremented or if the vnode or volume callback promise is
due to expire/has expired without making any changes to the state.
That is now left to afs_validate() as this may get more complicated in
future as we may have to examine server records too.
(7) Overhaul afs_validate() so that it does a single status fetch if we
need to check the state of either the vnode or the volume - and do so
under appropriate locking. The function does the following steps:
(A) If the vnode/volume is no longer seen as valid, then we take the
vnode validation lock and, if the volume promise has expired, the
volume check lock also. The latter prevents redundant checks being
made to find out if a new version of the volume got released.
(B) If a previous RPC call found that the volsync changed unexpectedly
or that a RO volume was updated, then we unmap all PTEs pointing to
the file to stop mmap being used for access.
(C) If the vnode is still seen to be of uncertain validity, then we
perform an FS.FetchStatus RPC op to jointly update the volume status
and the vnode status. This assessment is done as part of parsing the
reply:
If the RO volume creation timestamp advances, cb_ro_snapshot is
incremented; if either the creation or update timestamps changes in
an unexpected way, the cb_scrub counter is incremented
If the Data Version returned doesn't match the copy we have
locally, then we ask for the pagecache to be zapped. This takes
care of handling RO update.
(D) If cb_scrub differs between volume and vnode, the vnode's
pagecache is zapped and the vnode's cb_scrub is updated unless the
file is marked as having been deleted.
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
2023-11-08 13:57:42 +00:00
|
|
|
seq_printf(m, " - info: fl=%lx rtt=%u\n",
|
|
|
|
server->flags, server->rtt);
|
2023-10-31 16:30:37 +00:00
|
|
|
seq_printf(m, " - probe: last=%d\n",
|
|
|
|
(int)(jiffies - server->probed_at) / HZ);
|
|
|
|
failed = estate->failed_set;
|
|
|
|
seq_printf(m, " - ESTATE pq=%x np=%u rsp=%lx f=%lx\n",
|
|
|
|
estate->probe_seq, atomic_read(&estate->nr_probing),
|
|
|
|
estate->responsive_set, estate->failed_set);
|
|
|
|
seq_printf(m, " - ALIST v=%u ap=%u\n",
|
|
|
|
alist->version, alist->addr_pref_version);
|
2023-10-27 09:45:56 +00:00
|
|
|
for (i = 0; i < alist->nr_addrs; i++) {
|
|
|
|
const struct afs_address *addr = &alist->addrs[i];
|
|
|
|
|
2023-10-30 08:25:44 +00:00
|
|
|
seq_printf(m, " [%x] %pISpc%s rtt=%d err=%d p=%u\n",
|
2023-10-27 09:45:56 +00:00
|
|
|
i, rxrpc_kernel_remote_addr(addr->peer),
|
|
|
|
alist->preferred == i ? "*" :
|
|
|
|
test_bit(i, &failed) ? "!" : "",
|
|
|
|
rxrpc_kernel_get_srtt(addr->peer),
|
2023-10-30 08:25:44 +00:00
|
|
|
addr->last_error, addr->prio);
|
2023-10-27 09:45:56 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
2007-04-26 22:49:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00: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 15:27:50 +00:00
|
|
|
static void *afs_proc_servers_start(struct seq_file *m, loff_t *_pos)
|
2018-04-09 20:12:31 +00:00
|
|
|
__acquires(rcu)
|
2005-04-16 22:20:36 +00: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 15:27:50 +00:00
|
|
|
rcu_read_lock();
|
2018-05-18 10:46:15 +00:00
|
|
|
return seq_hlist_start_head_rcu(&afs_seq2net(m)->fs_proc, *_pos);
|
2007-04-26 22:49:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00: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 15:27:50 +00:00
|
|
|
static void *afs_proc_servers_next(struct seq_file *m, void *v, loff_t *_pos)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2018-05-18 10:46:15 +00:00
|
|
|
return seq_hlist_next_rcu(v, &afs_seq2net(m)->fs_proc, _pos);
|
2007-04-26 22:49:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
static void afs_proc_servers_stop(struct seq_file *m, void *v)
|
2018-04-09 20:12:31 +00:00
|
|
|
__releases(rcu)
|
2005-04-16 22:20:36 +00: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 15:27:50 +00:00
|
|
|
rcu_read_unlock();
|
2007-04-26 22:49:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
static const struct seq_operations afs_proc_servers_ops = {
|
|
|
|
.start = afs_proc_servers_start,
|
|
|
|
.next = afs_proc_servers_next,
|
|
|
|
.stop = afs_proc_servers_stop,
|
|
|
|
.show = afs_proc_servers_show,
|
|
|
|
};
|
2018-04-09 20:12:31 +00:00
|
|
|
|
|
|
|
/*
|
2018-05-18 10:46:15 +00:00
|
|
|
* Display the list of strings that may be substituted for the @sys pathname
|
|
|
|
* macro.
|
2018-04-09 20:12:31 +00:00
|
|
|
*/
|
2018-05-18 10:46:15 +00:00
|
|
|
static int afs_proc_sysname_show(struct seq_file *m, void *v)
|
2018-04-09 20:12:31 +00:00
|
|
|
{
|
2018-05-18 10:46:15 +00:00
|
|
|
struct afs_net *net = afs_seq2net(m);
|
|
|
|
struct afs_sysnames *sysnames = net->sysnames;
|
|
|
|
unsigned int i = (unsigned long)v - 1;
|
2018-04-09 20:12:31 +00:00
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
if (i < sysnames->nr)
|
|
|
|
seq_printf(m, "%s\n", sysnames->subs[i]);
|
|
|
|
return 0;
|
|
|
|
}
|
2018-04-09 20:12:31 +00:00
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
static void *afs_proc_sysname_start(struct seq_file *m, loff_t *pos)
|
|
|
|
__acquires(&net->sysnames_lock)
|
|
|
|
{
|
|
|
|
struct afs_net *net = afs_seq2net(m);
|
2018-05-18 10:46:15 +00:00
|
|
|
struct afs_sysnames *names;
|
2018-04-09 20:12:31 +00:00
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
read_lock(&net->sysnames_lock);
|
2018-04-09 20:12:31 +00:00
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
names = net->sysnames;
|
2018-05-18 10:46:15 +00:00
|
|
|
if (*pos >= names->nr)
|
|
|
|
return NULL;
|
|
|
|
return (void *)(unsigned long)(*pos + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *afs_proc_sysname_next(struct seq_file *m, void *v, loff_t *pos)
|
|
|
|
{
|
|
|
|
struct afs_net *net = afs_seq2net(m);
|
|
|
|
struct afs_sysnames *names = net->sysnames;
|
|
|
|
|
|
|
|
*pos += 1;
|
|
|
|
if (*pos >= names->nr)
|
|
|
|
return NULL;
|
|
|
|
return (void *)(unsigned long)(*pos + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void afs_proc_sysname_stop(struct seq_file *m, void *v)
|
|
|
|
__releases(&net->sysnames_lock)
|
|
|
|
{
|
|
|
|
struct afs_net *net = afs_seq2net(m);
|
|
|
|
|
|
|
|
read_unlock(&net->sysnames_lock);
|
2018-04-09 20:12:31 +00:00
|
|
|
}
|
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
static const struct seq_operations afs_proc_sysname_ops = {
|
|
|
|
.start = afs_proc_sysname_start,
|
|
|
|
.next = afs_proc_sysname_next,
|
|
|
|
.stop = afs_proc_sysname_stop,
|
|
|
|
.show = afs_proc_sysname_show,
|
|
|
|
};
|
|
|
|
|
2018-04-09 20:12:31 +00:00
|
|
|
/*
|
2018-05-18 10:46:15 +00:00
|
|
|
* Allow the @sys substitution to be configured.
|
2018-04-09 20:12:31 +00:00
|
|
|
*/
|
2018-05-18 10:46:15 +00:00
|
|
|
static int afs_proc_sysname_write(struct file *file, char *buf, size_t size)
|
2018-04-09 20:12:31 +00:00
|
|
|
{
|
2018-05-18 10:46:15 +00:00
|
|
|
struct afs_sysnames *sysnames, *kill;
|
2018-04-09 20:12:31 +00:00
|
|
|
struct seq_file *m = file->private_data;
|
2018-05-18 10:46:15 +00:00
|
|
|
struct afs_net *net = afs_seq2net(m);
|
|
|
|
char *s, *p, *sub;
|
2018-04-09 20:12:31 +00:00
|
|
|
int ret, len;
|
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
sysnames = kzalloc(sizeof(*sysnames), GFP_KERNEL);
|
2018-04-09 20:12:31 +00:00
|
|
|
if (!sysnames)
|
2018-05-18 10:46:15 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
refcount_set(&sysnames->usage, 1);
|
|
|
|
kill = sysnames;
|
2018-04-09 20:12:31 +00:00
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
p = buf;
|
2018-04-09 20:12:31 +00:00
|
|
|
while ((s = strsep(&p, " \t\n"))) {
|
|
|
|
len = strlen(s);
|
|
|
|
if (len == 0)
|
|
|
|
continue;
|
|
|
|
ret = -ENAMETOOLONG;
|
|
|
|
if (len >= AFSNAMEMAX)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (len >= 4 &&
|
|
|
|
s[len - 4] == '@' &&
|
|
|
|
s[len - 3] == 's' &&
|
|
|
|
s[len - 2] == 'y' &&
|
|
|
|
s[len - 1] == 's')
|
|
|
|
/* Protect against recursion */
|
|
|
|
goto invalid;
|
|
|
|
|
|
|
|
if (s[0] == '.' &&
|
|
|
|
(len < 2 || (len == 2 && s[1] == '.')))
|
|
|
|
goto invalid;
|
|
|
|
|
|
|
|
if (memchr(s, '/', len))
|
|
|
|
goto invalid;
|
|
|
|
|
|
|
|
ret = -EFBIG;
|
|
|
|
if (sysnames->nr >= AFS_NR_SYSNAME)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (strcmp(s, afs_init_sysname) == 0) {
|
|
|
|
sub = (char *)afs_init_sysname;
|
|
|
|
} else {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
sub = kmemdup(s, len + 1, GFP_KERNEL);
|
|
|
|
if (!sub)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
sysnames->subs[sysnames->nr] = sub;
|
|
|
|
sysnames->nr++;
|
|
|
|
}
|
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
if (sysnames->nr == 0) {
|
|
|
|
sysnames->subs[0] = sysnames->blank;
|
|
|
|
sysnames->nr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
write_lock(&net->sysnames_lock);
|
|
|
|
kill = net->sysnames;
|
|
|
|
net->sysnames = sysnames;
|
|
|
|
write_unlock(&net->sysnames_lock);
|
|
|
|
ret = 0;
|
2018-04-09 20:12:31 +00:00
|
|
|
out:
|
2018-05-18 10:46:15 +00:00
|
|
|
afs_put_sysnames(kill);
|
2018-04-09 20:12:31 +00:00
|
|
|
return ret;
|
|
|
|
|
|
|
|
invalid:
|
|
|
|
ret = -EINVAL;
|
|
|
|
error:
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
void afs_put_sysnames(struct afs_sysnames *sysnames)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (sysnames && refcount_dec_and_test(&sysnames->usage)) {
|
|
|
|
for (i = 0; i < sysnames->nr; i++)
|
|
|
|
if (sysnames->subs[i] != afs_init_sysname &&
|
|
|
|
sysnames->subs[i] != sysnames->blank)
|
|
|
|
kfree(sysnames->subs[i]);
|
2020-06-02 01:30:45 +00:00
|
|
|
kfree(sysnames);
|
2018-05-18 10:46:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-06 13:17:24 +00:00
|
|
|
/*
|
|
|
|
* Display general per-net namespace statistics
|
|
|
|
*/
|
|
|
|
static int afs_proc_stats_show(struct seq_file *m, void *v)
|
|
|
|
{
|
2018-05-18 10:46:15 +00:00
|
|
|
struct afs_net *net = afs_seq2net_single(m);
|
2018-04-06 13:17:24 +00:00
|
|
|
|
|
|
|
seq_puts(m, "kAFS statistics\n");
|
|
|
|
|
afs: Fix directory handling
AFS directories are structured blobs that are downloaded just like files
and then parsed by the lookup and readdir code and, as such, are currently
handled in the pagecache like any other file, with the entire directory
content being thrown away each time the directory changes.
However, since the blob is a known structure and since the data version
counter on a directory increases by exactly one for each change committed
to that directory, we can actually edit the directory locally rather than
fetching it from the server after each locally-induced change.
What we can't do, though, is mix data from the server and data from the
client since the server is technically at liberty to rearrange or compress
a directory if it sees fit, provided it updates the data version number
when it does so and breaks the callback (ie. sends a notification).
Further, lookup with lookup-ahead, readdir and, when it arrives, local
editing are likely want to scan the whole of a directory.
So directory handling needs to be improved to maintain the coherency of the
directory blob prior to permitting local directory editing.
To this end:
(1) If any directory page gets discarded, invalidate and reread the entire
directory.
(2) If readpage notes that if when it fetches a single page that the
version number has changed, the entire directory is flagged for
invalidation.
(3) Read as much of the directory in one go as we can.
Note that this removes local caching of directories in fscache for the
moment as we can't pass the pages to fscache_read_or_alloc_pages() since
page->lru is in use by the LRU.
Signed-off-by: David Howells <dhowells@redhat.com>
2018-04-06 13:17:25 +00:00
|
|
|
seq_printf(m, "dir-mgmt: look=%u reval=%u inval=%u relpg=%u\n",
|
2018-04-06 13:17:24 +00:00
|
|
|
atomic_read(&net->n_lookup),
|
|
|
|
atomic_read(&net->n_reval),
|
afs: Fix directory handling
AFS directories are structured blobs that are downloaded just like files
and then parsed by the lookup and readdir code and, as such, are currently
handled in the pagecache like any other file, with the entire directory
content being thrown away each time the directory changes.
However, since the blob is a known structure and since the data version
counter on a directory increases by exactly one for each change committed
to that directory, we can actually edit the directory locally rather than
fetching it from the server after each locally-induced change.
What we can't do, though, is mix data from the server and data from the
client since the server is technically at liberty to rearrange or compress
a directory if it sees fit, provided it updates the data version number
when it does so and breaks the callback (ie. sends a notification).
Further, lookup with lookup-ahead, readdir and, when it arrives, local
editing are likely want to scan the whole of a directory.
So directory handling needs to be improved to maintain the coherency of the
directory blob prior to permitting local directory editing.
To this end:
(1) If any directory page gets discarded, invalidate and reread the entire
directory.
(2) If readpage notes that if when it fetches a single page that the
version number has changed, the entire directory is flagged for
invalidation.
(3) Read as much of the directory in one go as we can.
Note that this removes local caching of directories in fscache for the
moment as we can't pass the pages to fscache_read_or_alloc_pages() since
page->lru is in use by the LRU.
Signed-off-by: David Howells <dhowells@redhat.com>
2018-04-06 13:17:25 +00:00
|
|
|
atomic_read(&net->n_inval),
|
|
|
|
atomic_read(&net->n_relpg));
|
2018-04-06 13:17:24 +00:00
|
|
|
|
|
|
|
seq_printf(m, "dir-data: rdpg=%u\n",
|
|
|
|
atomic_read(&net->n_read_dir));
|
2018-04-06 13:17:25 +00:00
|
|
|
|
|
|
|
seq_printf(m, "dir-edit: cr=%u rm=%u\n",
|
|
|
|
atomic_read(&net->n_dir_cr),
|
|
|
|
atomic_read(&net->n_dir_rm));
|
2018-04-06 13:17:26 +00:00
|
|
|
|
|
|
|
seq_printf(m, "file-rd : n=%u nb=%lu\n",
|
|
|
|
atomic_read(&net->n_fetches),
|
|
|
|
atomic_long_read(&net->n_fetch_bytes));
|
|
|
|
seq_printf(m, "file-wr : n=%u nb=%lu\n",
|
|
|
|
atomic_read(&net->n_stores),
|
|
|
|
atomic_long_read(&net->n_store_bytes));
|
2018-04-06 13:17:24 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2018-05-18 10:46:14 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* initialise /proc/fs/afs/<cell>/
|
|
|
|
*/
|
2018-05-18 10:46:15 +00:00
|
|
|
int afs_proc_cell_setup(struct afs_cell *cell)
|
2018-05-18 10:46:14 +00:00
|
|
|
{
|
|
|
|
struct proc_dir_entry *dir;
|
2018-05-18 10:46:15 +00:00
|
|
|
struct afs_net *net = cell->net;
|
2018-05-18 10:46:14 +00:00
|
|
|
|
|
|
|
_enter("%p{%s},%p", cell, cell->name, net->proc_afs);
|
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
dir = proc_net_mkdir(net->net, cell->name, net->proc_afs);
|
2018-05-18 10:46:14 +00:00
|
|
|
if (!dir)
|
|
|
|
goto error_dir;
|
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
if (!proc_create_net_data("vlservers", 0444, dir,
|
|
|
|
&afs_proc_cell_vlservers_ops,
|
2018-10-19 23:57:57 +00:00
|
|
|
sizeof(struct afs_vl_seq_net_private),
|
2018-05-18 10:46:15 +00:00
|
|
|
cell) ||
|
|
|
|
!proc_create_net_data("volumes", 0444, dir,
|
|
|
|
&afs_proc_cell_volumes_ops,
|
|
|
|
sizeof(struct seq_net_private),
|
|
|
|
cell))
|
2018-05-18 10:46:14 +00:00
|
|
|
goto error_tree;
|
|
|
|
|
|
|
|
_leave(" = 0");
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error_tree:
|
|
|
|
remove_proc_subtree(cell->name, net->proc_afs);
|
|
|
|
error_dir:
|
|
|
|
_leave(" = -ENOMEM");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* remove /proc/fs/afs/<cell>/
|
|
|
|
*/
|
2018-05-18 10:46:15 +00:00
|
|
|
void afs_proc_cell_remove(struct afs_cell *cell)
|
2018-05-18 10:46:14 +00:00
|
|
|
{
|
2018-05-18 10:46:15 +00:00
|
|
|
struct afs_net *net = cell->net;
|
2018-05-18 10:46:14 +00:00
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
_enter("");
|
2018-05-18 10:46:14 +00:00
|
|
|
remove_proc_subtree(cell->name, net->proc_afs);
|
|
|
|
_leave("");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* initialise the /proc/fs/afs/ directory
|
|
|
|
*/
|
|
|
|
int afs_proc_init(struct afs_net *net)
|
|
|
|
{
|
2018-05-18 10:46:15 +00:00
|
|
|
struct proc_dir_entry *p;
|
|
|
|
|
2018-05-18 10:46:14 +00:00
|
|
|
_enter("");
|
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
p = proc_net_mkdir(net->net, "afs", net->net->proc_net);
|
|
|
|
if (!p)
|
2018-05-18 10:46:14 +00:00
|
|
|
goto error_dir;
|
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
if (!proc_create_net_data_write("cells", 0644, p,
|
|
|
|
&afs_proc_cells_ops,
|
|
|
|
afs_proc_cells_write,
|
|
|
|
sizeof(struct seq_net_private),
|
|
|
|
NULL) ||
|
|
|
|
!proc_create_net_single_write("rootcell", 0644, p,
|
|
|
|
afs_proc_rootcell_show,
|
|
|
|
afs_proc_rootcell_write,
|
|
|
|
NULL) ||
|
|
|
|
!proc_create_net("servers", 0444, p, &afs_proc_servers_ops,
|
|
|
|
sizeof(struct seq_net_private)) ||
|
|
|
|
!proc_create_net_single("stats", 0444, p, afs_proc_stats_show, NULL) ||
|
|
|
|
!proc_create_net_data_write("sysname", 0644, p,
|
|
|
|
&afs_proc_sysname_ops,
|
|
|
|
afs_proc_sysname_write,
|
|
|
|
sizeof(struct seq_net_private),
|
2023-10-27 10:42:57 +00:00
|
|
|
NULL) ||
|
|
|
|
!proc_create_net_single_write("addr_prefs", 0644, p,
|
|
|
|
afs_proc_addr_prefs_show,
|
|
|
|
afs_proc_addr_prefs_write,
|
|
|
|
NULL))
|
2018-05-18 10:46:14 +00:00
|
|
|
goto error_tree;
|
|
|
|
|
2018-05-18 10:46:15 +00:00
|
|
|
net->proc_afs = p;
|
2018-05-18 10:46:14 +00:00
|
|
|
_leave(" = 0");
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error_tree:
|
2018-05-18 10:46:15 +00:00
|
|
|
proc_remove(p);
|
2018-05-18 10:46:14 +00:00
|
|
|
error_dir:
|
|
|
|
_leave(" = -ENOMEM");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* clean up the /proc/fs/afs/ directory
|
|
|
|
*/
|
|
|
|
void afs_proc_cleanup(struct afs_net *net)
|
|
|
|
{
|
|
|
|
proc_remove(net->proc_afs);
|
|
|
|
net->proc_afs = NULL;
|
|
|
|
}
|