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",
|
|
|
|
atomic_read(&cell->ref),
|
|
|
|
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
|
|
|
|
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",
|
2018-05-18 10:46:14 +00:00
|
|
|
atomic_read(&vol->usage), 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
|
|
|
{
|
2018-04-13 18:45:09 +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)
|
|
|
|
{
|
2018-05-18 10:46:15 +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 ? '>' : '-',
|
2018-10-19 23:57:57 +00:00
|
|
|
&alist->addrs[i].transport);
|
|
|
|
}
|
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;
|
2018-04-13 18:45:09 +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
|
|
|
{
|
2018-05-18 10:46:14 +00:00
|
|
|
struct afs_server *server;
|
|
|
|
struct afs_addr_list *alist;
|
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) {
|
2020-04-20 21:34:12 +00:00
|
|
|
seq_puts(m, "UUID REF ACT\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);
|
|
|
|
alist = rcu_dereference(server->addresses);
|
2020-04-20 21:34:12 +00:00
|
|
|
seq_printf(m, "%pU %3d %3d\n",
|
2018-05-18 10:46:14 +00:00
|
|
|
&server->uuid,
|
2020-04-17 16:31:26 +00:00
|
|
|
atomic_read(&server->ref),
|
2020-04-20 21:34:12 +00:00
|
|
|
atomic_read(&server->active));
|
2020-05-02 12:44:50 +00:00
|
|
|
seq_printf(m, " - info: fl=%lx rtt=%u brk=%x\n",
|
|
|
|
server->flags, server->rtt, server->cb_s_break);
|
|
|
|
seq_printf(m, " - probe: last=%d out=%d\n",
|
|
|
|
(int)(jiffies - server->probed_at) / HZ,
|
|
|
|
atomic_read(&server->probe_outstanding));
|
|
|
|
seq_printf(m, " - ALIST v=%u rsp=%lx f=%lx\n",
|
|
|
|
alist->version, alist->responded, alist->failed);
|
2020-04-20 21:34:12 +00:00
|
|
|
for (i = 0; i < alist->nr_addrs; i++)
|
|
|
|
seq_printf(m, " [%x] %pISpc%s\n",
|
|
|
|
i, &alist->addrs[i].transport,
|
2018-10-19 23:57:59 +00:00
|
|
|
alist->preferred == i ? "*" : "");
|
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),
|
|
|
|
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;
|
|
|
|
}
|