2007-04-27 02:49:28 +04:00
|
|
|
/* AFS superblock handling
|
|
|
|
*
|
2018-11-02 02:07:27 +03:00
|
|
|
* Copyright (c) 2002, 2007, 2018 Red Hat, Inc. All rights reserved.
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
|
|
|
* This software may be freely redistributed under the terms of the
|
|
|
|
* GNU General Public License.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
* Authors: David Howells <dhowells@redhat.com>
|
2008-06-06 09:46:18 +04:00
|
|
|
* David Woodhouse <dwmw2@infradead.org>
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
2010-08-11 12:38:04 +04:00
|
|
|
#include <linux/mount.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/pagemap.h>
|
2018-11-02 02:07:27 +03:00
|
|
|
#include <linux/fs_parser.h>
|
2007-05-11 09:22:20 +04:00
|
|
|
#include <linux/statfs.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-21 01:22:52 +04:00
|
|
|
#include <linux/sched.h>
|
2013-01-31 16:23:54 +04:00
|
|
|
#include <linux/nsproxy.h>
|
2017-11-02 18:27:45 +03:00
|
|
|
#include <linux/magic.h>
|
2013-01-31 16:23:54 +04:00
|
|
|
#include <net/net_namespace.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include "internal.h"
|
|
|
|
|
2008-07-26 06:45:34 +04:00
|
|
|
static void afs_i_init_once(void *foo);
|
2011-06-13 00:01:21 +04:00
|
|
|
static void afs_kill_super(struct super_block *sb);
|
2005-04-17 02:20:36 +04:00
|
|
|
static struct inode *afs_alloc_inode(struct super_block *sb);
|
|
|
|
static void afs_destroy_inode(struct inode *inode);
|
2007-05-11 09:22:20 +04:00
|
|
|
static int afs_statfs(struct dentry *dentry, struct kstatfs *buf);
|
2017-07-05 18:25:23 +03:00
|
|
|
static int afs_show_devname(struct seq_file *m, struct dentry *root);
|
|
|
|
static int afs_show_options(struct seq_file *m, struct dentry *root);
|
2018-11-02 02:07:27 +03:00
|
|
|
static int afs_init_fs_context(struct fs_context *fc);
|
|
|
|
static const struct fs_parameter_description afs_fs_parameters;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2006-06-09 17:34:16 +04:00
|
|
|
struct file_system_type afs_fs_type = {
|
2018-11-02 02:07:27 +03:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.name = "afs",
|
|
|
|
.init_fs_context = afs_init_fs_context,
|
|
|
|
.parameters = &afs_fs_parameters,
|
|
|
|
.kill_sb = afs_kill_super,
|
2019-04-25 16:26:51 +03:00
|
|
|
.fs_flags = FS_RENAME_DOES_D_MOVE,
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
2013-03-03 07:39:14 +04:00
|
|
|
MODULE_ALIAS_FS("afs");
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2018-05-18 13:46:15 +03:00
|
|
|
int afs_net_id;
|
|
|
|
|
2007-02-12 11:55:41 +03:00
|
|
|
static const struct super_operations afs_super_ops = {
|
2007-05-11 09:22:20 +04:00
|
|
|
.statfs = afs_statfs,
|
2005-04-17 02:20:36 +04:00
|
|
|
.alloc_inode = afs_alloc_inode,
|
2010-08-11 12:38:04 +04:00
|
|
|
.drop_inode = afs_drop_inode,
|
2005-04-17 02:20:36 +04:00
|
|
|
.destroy_inode = afs_destroy_inode,
|
2010-06-07 22:34:48 +04:00
|
|
|
.evict_inode = afs_evict_inode,
|
2017-07-05 18:25:23 +03:00
|
|
|
.show_devname = afs_show_devname,
|
|
|
|
.show_options = afs_show_options,
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
2006-12-07 07:33:20 +03:00
|
|
|
static struct kmem_cache *afs_inode_cachep;
|
2005-04-17 02:20:36 +04:00
|
|
|
static atomic_t afs_count_active_inodes;
|
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
enum afs_param {
|
|
|
|
Opt_autocell,
|
|
|
|
Opt_dyn,
|
|
|
|
Opt_source,
|
2007-05-03 14:11:29 +04:00
|
|
|
};
|
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
static const struct fs_parameter_spec afs_param_specs[] = {
|
|
|
|
fsparam_flag ("autocell", Opt_autocell),
|
|
|
|
fsparam_flag ("dyn", Opt_dyn),
|
|
|
|
fsparam_string("source", Opt_source),
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct fs_parameter_description afs_fs_parameters = {
|
|
|
|
.name = "kAFS",
|
|
|
|
.specs = afs_param_specs,
|
2007-05-03 14:11:29 +04:00
|
|
|
};
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* initialise the filesystem
|
|
|
|
*/
|
|
|
|
int __init afs_fs_init(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
_enter("");
|
|
|
|
|
|
|
|
/* create ourselves an inode cache */
|
|
|
|
atomic_set(&afs_count_active_inodes, 0);
|
|
|
|
|
|
|
|
ret = -ENOMEM;
|
|
|
|
afs_inode_cachep = kmem_cache_create("afs_inode_cache",
|
|
|
|
sizeof(struct afs_vnode),
|
|
|
|
0,
|
2016-01-15 02:18:21 +03:00
|
|
|
SLAB_HWCACHE_ALIGN|SLAB_ACCOUNT,
|
2007-07-20 05:11:58 +04:00
|
|
|
afs_i_init_once);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!afs_inode_cachep) {
|
|
|
|
printk(KERN_NOTICE "kAFS: Failed to allocate inode cache\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now export our filesystem to lesser mortals */
|
|
|
|
ret = register_filesystem(&afs_fs_type);
|
|
|
|
if (ret < 0) {
|
|
|
|
kmem_cache_destroy(afs_inode_cachep);
|
2007-04-27 02:55:03 +04:00
|
|
|
_leave(" = %d", ret);
|
2005-04-17 02:20:36 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-04-27 02:55:03 +04:00
|
|
|
_leave(" = 0");
|
2005-04-17 02:20:36 +04:00
|
|
|
return 0;
|
2007-04-27 02:49:28 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* clean up the filesystem
|
|
|
|
*/
|
2018-05-18 13:46:15 +03:00
|
|
|
void afs_fs_exit(void)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2007-04-27 02:55:03 +04:00
|
|
|
_enter("");
|
|
|
|
|
|
|
|
afs_mntpt_kill_timer();
|
2005-04-17 02:20:36 +04:00
|
|
|
unregister_filesystem(&afs_fs_type);
|
|
|
|
|
|
|
|
if (atomic_read(&afs_count_active_inodes) != 0) {
|
|
|
|
printk("kAFS: %d active inode objects still present\n",
|
|
|
|
atomic_read(&afs_count_active_inodes));
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
|
2012-09-26 05:33:07 +04:00
|
|
|
/*
|
|
|
|
* Make sure all delayed rcu free inodes are flushed before we
|
|
|
|
* destroy cache.
|
|
|
|
*/
|
|
|
|
rcu_barrier();
|
2005-04-17 02:20:36 +04:00
|
|
|
kmem_cache_destroy(afs_inode_cachep);
|
2007-04-27 02:55:03 +04:00
|
|
|
_leave("");
|
2007-04-27 02:49:28 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2017-07-05 18:25:23 +03:00
|
|
|
/*
|
|
|
|
* Display the mount device name in /proc/mounts.
|
|
|
|
*/
|
|
|
|
static int afs_show_devname(struct seq_file *m, struct dentry *root)
|
|
|
|
{
|
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 18:27:50 +03:00
|
|
|
struct afs_super_info *as = AFS_FS_S(root->d_sb);
|
2017-07-05 18:25:23 +03:00
|
|
|
struct afs_volume *volume = as->volume;
|
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 18:27:50 +03:00
|
|
|
struct afs_cell *cell = as->cell;
|
2017-07-05 18:25:23 +03:00
|
|
|
const char *suf = "";
|
|
|
|
char pref = '%';
|
|
|
|
|
2018-02-06 09:26:30 +03:00
|
|
|
if (as->dyn_root) {
|
|
|
|
seq_puts(m, "none");
|
|
|
|
return 0;
|
|
|
|
}
|
2018-04-06 16:17:25 +03:00
|
|
|
|
2017-07-05 18:25:23 +03:00
|
|
|
switch (volume->type) {
|
|
|
|
case AFSVL_RWVOL:
|
|
|
|
break;
|
|
|
|
case AFSVL_ROVOL:
|
|
|
|
pref = '#';
|
|
|
|
if (volume->type_force)
|
|
|
|
suf = ".readonly";
|
|
|
|
break;
|
|
|
|
case AFSVL_BACKVOL:
|
|
|
|
pref = '#';
|
|
|
|
suf = ".backup";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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 18:27:50 +03:00
|
|
|
seq_printf(m, "%c%s:%s%s", pref, cell->name, volume->name, suf);
|
2017-07-05 18:25:23 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Display the mount options in /proc/mounts.
|
|
|
|
*/
|
|
|
|
static int afs_show_options(struct seq_file *m, struct dentry *root)
|
|
|
|
{
|
2018-02-06 09:26:30 +03:00
|
|
|
struct afs_super_info *as = AFS_FS_S(root->d_sb);
|
|
|
|
|
|
|
|
if (as->dyn_root)
|
|
|
|
seq_puts(m, ",dyn");
|
2017-07-05 18:25:23 +03:00
|
|
|
if (test_bit(AFS_VNODE_AUTOCELL, &AFS_FS_I(d_inode(root))->flags))
|
2018-02-06 09:26:30 +03:00
|
|
|
seq_puts(m, ",autocell");
|
2017-07-05 18:25:23 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
2018-11-02 02:07:27 +03:00
|
|
|
* Parse the source name to get cell name, volume name, volume type and R/W
|
|
|
|
* selector.
|
|
|
|
*
|
|
|
|
* This can be one of the following:
|
2007-04-27 02:57:07 +04:00
|
|
|
* "%[cell:]volume[.]" R/W volume
|
2018-11-02 02:07:27 +03:00
|
|
|
* "#[cell:]volume[.]" R/O or R/W volume (R/O parent),
|
|
|
|
* or R/W (R/W parent) volume
|
2007-04-27 02:57:07 +04:00
|
|
|
* "%[cell:]volume.readonly" R/O volume
|
|
|
|
* "#[cell:]volume.readonly" R/O volume
|
|
|
|
* "%[cell:]volume.backup" Backup volume
|
|
|
|
* "#[cell:]volume.backup" Backup volume
|
|
|
|
*/
|
2018-11-02 02:07:27 +03:00
|
|
|
static int afs_parse_source(struct fs_context *fc, struct fs_parameter *param)
|
2007-04-27 02:57:07 +04:00
|
|
|
{
|
2018-11-02 02:07:27 +03:00
|
|
|
struct afs_fs_context *ctx = fc->fs_private;
|
2007-04-27 02:57:07 +04:00
|
|
|
struct afs_cell *cell;
|
2018-11-02 02:07:27 +03:00
|
|
|
const char *cellname, *suffix, *name = param->string;
|
2007-04-27 02:57:07 +04:00
|
|
|
int cellnamesz;
|
|
|
|
|
|
|
|
_enter(",%s", name);
|
2018-04-06 16:17:25 +03:00
|
|
|
|
2007-04-27 02:57:07 +04:00
|
|
|
if (!name) {
|
|
|
|
printk(KERN_ERR "kAFS: no volume name specified\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((name[0] != '%' && name[0] != '#') || !name[1]) {
|
2018-11-02 02:07:27 +03:00
|
|
|
/* To use dynroot, we don't want to have to provide a source */
|
|
|
|
if (strcmp(name, "none") == 0) {
|
|
|
|
ctx->no_cell = true;
|
|
|
|
return 0;
|
|
|
|
}
|
2007-04-27 02:57:07 +04:00
|
|
|
printk(KERN_ERR "kAFS: unparsable volume name\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* determine the type of volume we're looking for */
|
2018-11-02 02:07:27 +03:00
|
|
|
if (name[0] == '%') {
|
2018-11-02 02:07:27 +03:00
|
|
|
ctx->type = AFSVL_RWVOL;
|
|
|
|
ctx->force = true;
|
2007-04-27 02:57:07 +04:00
|
|
|
}
|
|
|
|
name++;
|
|
|
|
|
|
|
|
/* split the cell name out if there is one */
|
2018-11-02 02:07:27 +03:00
|
|
|
ctx->volname = strchr(name, ':');
|
|
|
|
if (ctx->volname) {
|
2007-04-27 02:57:07 +04:00
|
|
|
cellname = name;
|
2018-11-02 02:07:27 +03:00
|
|
|
cellnamesz = ctx->volname - name;
|
|
|
|
ctx->volname++;
|
2007-04-27 02:57:07 +04:00
|
|
|
} else {
|
2018-11-02 02:07:27 +03:00
|
|
|
ctx->volname = name;
|
2007-04-27 02:57:07 +04:00
|
|
|
cellname = NULL;
|
|
|
|
cellnamesz = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the volume type is further affected by a possible suffix */
|
2018-11-02 02:07:27 +03:00
|
|
|
suffix = strrchr(ctx->volname, '.');
|
2007-04-27 02:57:07 +04:00
|
|
|
if (suffix) {
|
|
|
|
if (strcmp(suffix, ".readonly") == 0) {
|
2018-11-02 02:07:27 +03:00
|
|
|
ctx->type = AFSVL_ROVOL;
|
|
|
|
ctx->force = true;
|
2007-04-27 02:57:07 +04:00
|
|
|
} else if (strcmp(suffix, ".backup") == 0) {
|
2018-11-02 02:07:27 +03:00
|
|
|
ctx->type = AFSVL_BACKVOL;
|
|
|
|
ctx->force = true;
|
2007-04-27 02:57:07 +04:00
|
|
|
} else if (suffix[1] == 0) {
|
|
|
|
} else {
|
|
|
|
suffix = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
ctx->volnamesz = suffix ?
|
|
|
|
suffix - ctx->volname : strlen(ctx->volname);
|
2007-04-27 02:57:07 +04:00
|
|
|
|
|
|
|
_debug("cell %*.*s [%p]",
|
2018-11-02 02:07:27 +03:00
|
|
|
cellnamesz, cellnamesz, cellname ?: "", ctx->cell);
|
2007-04-27 02:57:07 +04:00
|
|
|
|
|
|
|
/* lookup the cell record */
|
2018-11-02 02:07:27 +03:00
|
|
|
if (cellname) {
|
|
|
|
cell = afs_lookup_cell(ctx->net, cellname, cellnamesz,
|
2017-11-02 18:27:50 +03:00
|
|
|
NULL, false);
|
2007-04-27 02:57:07 +04:00
|
|
|
if (IS_ERR(cell)) {
|
2018-11-02 02:07:27 +03:00
|
|
|
pr_err("kAFS: unable to lookup cell '%*.*s'\n",
|
2010-08-11 12:38:04 +04:00
|
|
|
cellnamesz, cellnamesz, cellname ?: "");
|
2007-04-27 02:57:07 +04:00
|
|
|
return PTR_ERR(cell);
|
|
|
|
}
|
2018-11-02 02:07:27 +03:00
|
|
|
afs_put_cell(ctx->net, ctx->cell);
|
|
|
|
ctx->cell = cell;
|
2007-04-27 02:57:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
_debug("CELL:%s [%p] VOLUME:%*.*s SUFFIX:%s TYPE:%d%s",
|
2018-11-02 02:07:27 +03:00
|
|
|
ctx->cell->name, ctx->cell,
|
|
|
|
ctx->volnamesz, ctx->volnamesz, ctx->volname,
|
|
|
|
suffix ?: "-", ctx->type, ctx->force ? " FORCE" : "");
|
|
|
|
|
|
|
|
fc->source = param->string;
|
|
|
|
param->string = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse a single mount parameter.
|
|
|
|
*/
|
|
|
|
static int afs_parse_param(struct fs_context *fc, struct fs_parameter *param)
|
|
|
|
{
|
|
|
|
struct fs_parse_result result;
|
|
|
|
struct afs_fs_context *ctx = fc->fs_private;
|
|
|
|
int opt;
|
|
|
|
|
|
|
|
opt = fs_parse(fc, &afs_fs_parameters, param, &result);
|
|
|
|
if (opt < 0)
|
|
|
|
return opt;
|
|
|
|
|
|
|
|
switch (opt) {
|
|
|
|
case Opt_source:
|
|
|
|
return afs_parse_source(fc, param);
|
|
|
|
|
|
|
|
case Opt_autocell:
|
|
|
|
ctx->autocell = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Opt_dyn:
|
|
|
|
ctx->dyn_root = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
_leave(" = 0");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Validate the options, get the cell key and look up the volume.
|
|
|
|
*/
|
|
|
|
static int afs_validate_fc(struct fs_context *fc)
|
|
|
|
{
|
|
|
|
struct afs_fs_context *ctx = fc->fs_private;
|
|
|
|
struct afs_volume *volume;
|
|
|
|
struct key *key;
|
|
|
|
|
|
|
|
if (!ctx->dyn_root) {
|
|
|
|
if (ctx->no_cell) {
|
|
|
|
pr_warn("kAFS: Can only specify source 'none' with -o dyn\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ctx->cell) {
|
|
|
|
pr_warn("kAFS: No cell specified\n");
|
|
|
|
return -EDESTADDRREQ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We try to do the mount securely. */
|
|
|
|
key = afs_request_key(ctx->cell);
|
|
|
|
if (IS_ERR(key))
|
|
|
|
return PTR_ERR(key);
|
|
|
|
|
|
|
|
ctx->key = key;
|
|
|
|
|
|
|
|
if (ctx->volume) {
|
|
|
|
afs_put_volume(ctx->cell, ctx->volume);
|
|
|
|
ctx->volume = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
volume = afs_create_volume(ctx);
|
|
|
|
if (IS_ERR(volume))
|
|
|
|
return PTR_ERR(volume);
|
|
|
|
|
|
|
|
ctx->volume = volume;
|
|
|
|
}
|
2007-04-27 02:57:07 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* check a superblock to see if it's the one we're looking for
|
|
|
|
*/
|
2018-11-02 02:07:27 +03:00
|
|
|
static int afs_test_super(struct super_block *sb, struct fs_context *fc)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2018-11-02 02:07:27 +03:00
|
|
|
struct afs_fs_context *ctx = fc->fs_private;
|
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 18:27:50 +03:00
|
|
|
struct afs_super_info *as = AFS_FS_S(sb);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
return (as->net_ns == fc->net_ns &&
|
2018-02-06 09:26:30 +03:00
|
|
|
as->volume &&
|
2018-11-02 02:07:27 +03:00
|
|
|
as->volume->vid == ctx->volume->vid &&
|
2018-06-15 17:19:22 +03:00
|
|
|
!as->dyn_root);
|
2018-02-06 09:26:30 +03:00
|
|
|
}
|
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
static int afs_dynroot_test_super(struct super_block *sb, struct fs_context *fc)
|
2018-02-06 09:26:30 +03:00
|
|
|
{
|
2018-06-15 17:19:22 +03:00
|
|
|
struct afs_super_info *as = AFS_FS_S(sb);
|
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
return (as->net_ns == fc->net_ns &&
|
2018-06-15 17:19:22 +03:00
|
|
|
as->dyn_root);
|
2011-06-13 00:01:21 +04:00
|
|
|
}
|
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
static int afs_set_super(struct super_block *sb, struct fs_context *fc)
|
2011-06-13 00:01:21 +04:00
|
|
|
{
|
|
|
|
return set_anon_super(sb, NULL);
|
2007-04-27 02:49:28 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* fill in the superblock
|
|
|
|
*/
|
2018-11-02 02:07:27 +03:00
|
|
|
static int afs_fill_super(struct super_block *sb, struct afs_fs_context *ctx)
|
2005-04-17 02:20:36 +04: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 18:27:50 +03:00
|
|
|
struct afs_super_info *as = AFS_FS_S(sb);
|
2005-04-17 02:20:36 +04:00
|
|
|
struct afs_fid fid;
|
|
|
|
struct inode *inode = NULL;
|
|
|
|
int ret;
|
|
|
|
|
2007-04-27 02:55:03 +04:00
|
|
|
_enter("");
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* fill in the superblock */
|
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.
This promise never materialized. And unlikely will.
We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE. And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.
Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.
Let's stop pretending that pages in page cache are special. They are
not.
The changes are pretty straight-forward:
- <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
- PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
- page_cache_get() -> get_page();
- page_cache_release() -> put_page();
This patch contains automated changes generated with coccinelle using
script below. For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.
The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.
There are few places in the code where coccinelle didn't reach. I'll
fix them manually in a separate patch. Comments and documentation also
will be addressed with the separate patch.
virtual patch
@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E
@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT
@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE
@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK
@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)
@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)
@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-01 15:29:47 +03:00
|
|
|
sb->s_blocksize = PAGE_SIZE;
|
|
|
|
sb->s_blocksize_bits = PAGE_SHIFT;
|
2005-04-17 02:20:36 +04:00
|
|
|
sb->s_magic = AFS_FS_MAGIC;
|
|
|
|
sb->s_op = &afs_super_ops;
|
2018-02-06 09:26:30 +03:00
|
|
|
if (!as->dyn_root)
|
|
|
|
sb->s_xattr = afs_xattr_handlers;
|
2017-04-12 13:24:36 +03:00
|
|
|
ret = super_setup_bdi(sb);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2019-03-12 09:28:13 +03:00
|
|
|
sb->s_bdi->ra_pages = VM_READAHEAD_PAGES;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* allocate the root inode and dentry */
|
2018-02-06 09:26:30 +03:00
|
|
|
if (as->dyn_root) {
|
|
|
|
inode = afs_iget_pseudo_dir(sb, true);
|
|
|
|
sb->s_flags |= SB_RDONLY;
|
|
|
|
} else {
|
2018-10-20 02:57:57 +03:00
|
|
|
sprintf(sb->s_id, "%llu", as->volume->vid);
|
2018-02-06 09:26:30 +03:00
|
|
|
afs_activate_volume(as->volume);
|
|
|
|
fid.vid = as->volume->vid;
|
|
|
|
fid.vnode = 1;
|
2018-10-20 02:57:57 +03:00
|
|
|
fid.vnode_hi = 0;
|
2018-02-06 09:26:30 +03:00
|
|
|
fid.unique = 1;
|
2018-11-02 02:07:27 +03:00
|
|
|
inode = afs_iget(sb, ctx->key, &fid, NULL, NULL, NULL);
|
2018-02-06 09:26:30 +03:00
|
|
|
}
|
|
|
|
|
2007-04-27 02:55:03 +04:00
|
|
|
if (IS_ERR(inode))
|
2011-06-13 00:01:21 +04:00
|
|
|
return PTR_ERR(inode);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
if (ctx->autocell || as->dyn_root)
|
2010-08-11 12:38:04 +04:00
|
|
|
set_bit(AFS_VNODE_AUTOCELL, &AFS_FS_I(inode)->flags);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
ret = -ENOMEM;
|
2012-01-09 07:15:13 +04:00
|
|
|
sb->s_root = d_make_root(inode);
|
|
|
|
if (!sb->s_root)
|
2005-04-17 02:20:36 +04:00
|
|
|
goto error;
|
|
|
|
|
2018-06-15 17:19:22 +03:00
|
|
|
if (as->dyn_root) {
|
2018-04-06 16:17:25 +03:00
|
|
|
sb->s_d_op = &afs_dynroot_dentry_operations;
|
2018-06-15 17:19:22 +03:00
|
|
|
ret = afs_dynroot_populate(sb);
|
|
|
|
if (ret < 0)
|
|
|
|
goto error;
|
|
|
|
} else {
|
2018-04-06 16:17:25 +03:00
|
|
|
sb->s_d_op = &afs_fs_dentry_operations;
|
2018-06-15 17:19:22 +03:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-04-27 02:55:03 +04:00
|
|
|
_leave(" = 0");
|
2005-04-17 02:20:36 +04:00
|
|
|
return 0;
|
|
|
|
|
2007-04-27 02:49:28 +04:00
|
|
|
error:
|
2007-04-27 02:55:03 +04:00
|
|
|
_leave(" = %d", ret);
|
2005-04-17 02:20:36 +04:00
|
|
|
return ret;
|
2007-04-27 02:49:28 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
static struct afs_super_info *afs_alloc_sbi(struct fs_context *fc)
|
2017-11-02 18:27:46 +03:00
|
|
|
{
|
2018-11-02 02:07:27 +03:00
|
|
|
struct afs_fs_context *ctx = fc->fs_private;
|
2017-11-02 18:27:46 +03:00
|
|
|
struct afs_super_info *as;
|
|
|
|
|
|
|
|
as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
|
|
|
|
if (as) {
|
2018-11-02 02:07:27 +03:00
|
|
|
as->net_ns = get_net(fc->net_ns);
|
|
|
|
if (ctx->dyn_root) {
|
2018-02-06 09:26:30 +03:00
|
|
|
as->dyn_root = true;
|
2018-11-02 02:07:27 +03:00
|
|
|
} else {
|
|
|
|
as->cell = afs_get_cell(ctx->cell);
|
|
|
|
as->volume = __afs_get_volume(ctx->volume);
|
|
|
|
}
|
2017-11-02 18:27:46 +03:00
|
|
|
}
|
|
|
|
return as;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void afs_destroy_sbi(struct afs_super_info *as)
|
|
|
|
{
|
|
|
|
if (as) {
|
2017-11-02 18:27:46 +03:00
|
|
|
afs_put_volume(as->cell, as->volume);
|
2018-05-18 13:46:15 +03:00
|
|
|
afs_put_cell(afs_net(as->net_ns), as->cell);
|
|
|
|
put_net(as->net_ns);
|
2017-11-02 18:27:46 +03:00
|
|
|
kfree(as);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-15 17:19:22 +03:00
|
|
|
static void afs_kill_super(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct afs_super_info *as = AFS_FS_S(sb);
|
|
|
|
struct afs_net *net = afs_net(as->net_ns);
|
|
|
|
|
|
|
|
if (as->dyn_root)
|
|
|
|
afs_dynroot_depopulate(sb);
|
2018-11-02 02:07:27 +03:00
|
|
|
|
2018-06-15 17:19:22 +03:00
|
|
|
/* Clear the callback interests (which will do ilookup5) before
|
|
|
|
* deactivating the superblock.
|
|
|
|
*/
|
|
|
|
if (as->volume)
|
|
|
|
afs_clear_callback_interests(net, as->volume->servers);
|
|
|
|
kill_anon_super(sb);
|
|
|
|
if (as->volume)
|
|
|
|
afs_deactivate_volume(as->volume);
|
|
|
|
afs_destroy_sbi(as);
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
2018-11-02 02:07:27 +03:00
|
|
|
* Get an AFS superblock and root directory.
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
2018-11-02 02:07:27 +03:00
|
|
|
static int afs_get_tree(struct fs_context *fc)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2018-11-02 02:07:27 +03:00
|
|
|
struct afs_fs_context *ctx = fc->fs_private;
|
2005-04-17 02:20:36 +04:00
|
|
|
struct super_block *sb;
|
2011-06-13 00:01:21 +04:00
|
|
|
struct afs_super_info *as;
|
2005-04-17 02:20:36 +04:00
|
|
|
int ret;
|
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
ret = afs_validate_fc(fc);
|
|
|
|
if (ret)
|
2013-01-31 16:23:54 +04:00
|
|
|
goto error;
|
2007-04-27 02:57:07 +04:00
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
_enter("");
|
2007-04-27 02:57:07 +04:00
|
|
|
|
2017-11-02 18:27:46 +03:00
|
|
|
/* allocate a superblock info record */
|
|
|
|
ret = -ENOMEM;
|
2018-11-02 02:07:27 +03:00
|
|
|
as = afs_alloc_sbi(fc);
|
2017-11-02 18:27:46 +03:00
|
|
|
if (!as)
|
2018-11-02 02:07:27 +03:00
|
|
|
goto error;
|
|
|
|
fc->s_fs_info = as;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* allocate a deviceless superblock */
|
2018-11-02 02:07:27 +03:00
|
|
|
sb = sget_fc(fc,
|
|
|
|
as->dyn_root ? afs_dynroot_test_super : afs_test_super,
|
|
|
|
afs_set_super);
|
2007-04-27 02:55:03 +04:00
|
|
|
if (IS_ERR(sb)) {
|
|
|
|
ret = PTR_ERR(sb);
|
2018-11-02 02:07:27 +03:00
|
|
|
goto error;
|
2007-04-27 02:55:03 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-04-27 02:56:24 +04:00
|
|
|
if (!sb->s_root) {
|
|
|
|
/* initial superblock/root creation */
|
|
|
|
_debug("create");
|
2018-11-02 02:07:27 +03:00
|
|
|
ret = afs_fill_super(sb, ctx);
|
2017-11-02 18:27:45 +03:00
|
|
|
if (ret < 0)
|
|
|
|
goto error_sb;
|
2017-11-28 00:05:09 +03:00
|
|
|
sb->s_flags |= SB_ACTIVE;
|
2007-04-27 02:56:24 +04:00
|
|
|
} else {
|
|
|
|
_debug("reuse");
|
2017-11-28 00:05:09 +03:00
|
|
|
ASSERTCMP(sb->s_flags, &, SB_ACTIVE);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
fc->root = dget(sb->s_root);
|
2007-04-27 02:55:03 +04:00
|
|
|
_leave(" = 0 [%p]", sb);
|
2018-11-02 02:07:27 +03:00
|
|
|
return 0;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2017-11-02 18:27:45 +03:00
|
|
|
error_sb:
|
|
|
|
deactivate_locked_super(sb);
|
2007-04-27 02:49:28 +04:00
|
|
|
error:
|
2005-04-17 02:20:36 +04:00
|
|
|
_leave(" = %d", ret);
|
2018-11-02 02:07:27 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void afs_free_fc(struct fs_context *fc)
|
|
|
|
{
|
|
|
|
struct afs_fs_context *ctx = fc->fs_private;
|
|
|
|
|
|
|
|
afs_destroy_sbi(fc->s_fs_info);
|
|
|
|
afs_put_volume(ctx->cell, ctx->volume);
|
|
|
|
afs_put_cell(ctx->net, ctx->cell);
|
|
|
|
key_put(ctx->key);
|
|
|
|
kfree(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct fs_context_operations afs_context_ops = {
|
|
|
|
.free = afs_free_fc,
|
|
|
|
.parse_param = afs_parse_param,
|
|
|
|
.get_tree = afs_get_tree,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up the filesystem mount context.
|
|
|
|
*/
|
|
|
|
static int afs_init_fs_context(struct fs_context *fc)
|
|
|
|
{
|
|
|
|
struct afs_fs_context *ctx;
|
|
|
|
struct afs_cell *cell;
|
|
|
|
|
|
|
|
ctx = kzalloc(sizeof(struct afs_fs_context), GFP_KERNEL);
|
|
|
|
if (!ctx)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
ctx->type = AFSVL_ROVOL;
|
|
|
|
ctx->net = afs_net(fc->net_ns);
|
|
|
|
|
|
|
|
/* Default to the workstation cell. */
|
|
|
|
rcu_read_lock();
|
|
|
|
cell = afs_lookup_cell_rcu(ctx->net, NULL, 0);
|
|
|
|
rcu_read_unlock();
|
|
|
|
if (IS_ERR(cell))
|
|
|
|
cell = NULL;
|
|
|
|
ctx->cell = cell;
|
|
|
|
|
|
|
|
fc->fs_private = ctx;
|
|
|
|
fc->ops = &afs_context_ops;
|
|
|
|
return 0;
|
2007-04-27 02:49:28 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
2017-12-01 14:40:43 +03:00
|
|
|
* Initialise an inode cache slab element prior to any use. Note that
|
|
|
|
* afs_alloc_inode() *must* reset anything that could incorrectly leak from one
|
|
|
|
* inode to another.
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
2008-07-26 06:45:34 +04:00
|
|
|
static void afs_i_init_once(void *_vnode)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2007-04-27 02:49:28 +04:00
|
|
|
struct afs_vnode *vnode = _vnode;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-05-17 09:10:57 +04:00
|
|
|
memset(vnode, 0, sizeof(*vnode));
|
|
|
|
inode_init_once(&vnode->vfs_inode);
|
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 18:27:50 +03:00
|
|
|
mutex_init(&vnode->io_lock);
|
2018-04-27 22:46:22 +03:00
|
|
|
init_rwsem(&vnode->validate_lock);
|
2017-11-02 18:27:52 +03:00
|
|
|
spin_lock_init(&vnode->wb_lock);
|
2007-05-17 09:10:57 +04:00
|
|
|
spin_lock_init(&vnode->lock);
|
2017-11-02 18:27:52 +03:00
|
|
|
INIT_LIST_HEAD(&vnode->wb_keys);
|
2007-07-16 10:40:12 +04:00
|
|
|
INIT_LIST_HEAD(&vnode->pending_locks);
|
|
|
|
INIT_LIST_HEAD(&vnode->granted_locks);
|
|
|
|
INIT_DELAYED_WORK(&vnode->lock_work, afs_lock_work);
|
2017-11-02 18:27:49 +03:00
|
|
|
seqlock_init(&vnode->cb_lock);
|
2007-04-27 02:49:28 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* allocate an AFS inode struct from our slab cache
|
|
|
|
*/
|
|
|
|
static struct inode *afs_alloc_inode(struct super_block *sb)
|
|
|
|
{
|
|
|
|
struct afs_vnode *vnode;
|
|
|
|
|
2007-04-27 02:49:28 +04:00
|
|
|
vnode = kmem_cache_alloc(afs_inode_cachep, GFP_KERNEL);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!vnode)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
atomic_inc(&afs_count_active_inodes);
|
|
|
|
|
2017-12-01 14:40:43 +03:00
|
|
|
/* Reset anything that shouldn't leak from one inode to the next. */
|
2005-04-17 02:20:36 +04:00
|
|
|
memset(&vnode->fid, 0, sizeof(vnode->fid));
|
|
|
|
memset(&vnode->status, 0, sizeof(vnode->status));
|
|
|
|
|
|
|
|
vnode->volume = NULL;
|
2017-12-01 14:40:43 +03:00
|
|
|
vnode->lock_key = NULL;
|
|
|
|
vnode->permit_cache = NULL;
|
|
|
|
vnode->cb_interest = NULL;
|
|
|
|
#ifdef CONFIG_AFS_FSCACHE
|
|
|
|
vnode->cache = NULL;
|
|
|
|
#endif
|
|
|
|
|
2007-04-27 02:59:35 +04:00
|
|
|
vnode->flags = 1 << AFS_VNODE_UNSET;
|
2017-12-01 14:40:43 +03:00
|
|
|
vnode->cb_type = 0;
|
|
|
|
vnode->lock_state = AFS_VNODE_LOCK_NONE;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2019-04-25 16:26:51 +03:00
|
|
|
init_rwsem(&vnode->rmdir_lock);
|
|
|
|
|
2007-05-11 09:22:20 +04:00
|
|
|
_leave(" = %p", &vnode->vfs_inode);
|
2005-04-17 02:20:36 +04:00
|
|
|
return &vnode->vfs_inode;
|
2007-04-27 02:49:28 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2011-01-07 09:49:49 +03:00
|
|
|
static void afs_i_callback(struct rcu_head *head)
|
|
|
|
{
|
|
|
|
struct inode *inode = container_of(head, struct inode, i_rcu);
|
|
|
|
struct afs_vnode *vnode = AFS_FS_I(inode);
|
|
|
|
kmem_cache_free(afs_inode_cachep, vnode);
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* destroy an AFS inode struct
|
|
|
|
*/
|
|
|
|
static void afs_destroy_inode(struct inode *inode)
|
|
|
|
{
|
2007-04-27 02:55:03 +04:00
|
|
|
struct afs_vnode *vnode = AFS_FS_I(inode);
|
|
|
|
|
2018-10-20 02:57:57 +03:00
|
|
|
_enter("%p{%llx:%llu}", inode, vnode->fid.vid, vnode->fid.vnode);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-04-27 02:55:03 +04:00
|
|
|
_debug("DESTROY INODE %p", inode);
|
|
|
|
|
2017-11-02 18:27:49 +03:00
|
|
|
ASSERTCMP(vnode->cb_interest, ==, NULL);
|
2007-04-27 02:55:03 +04:00
|
|
|
|
2011-01-07 09:49:49 +03:00
|
|
|
call_rcu(&inode->i_rcu, afs_i_callback);
|
2005-04-17 02:20:36 +04:00
|
|
|
atomic_dec(&afs_count_active_inodes);
|
2007-04-27 02:49:28 +04:00
|
|
|
}
|
2007-05-11 09:22:20 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* return information about an AFS volume
|
|
|
|
*/
|
|
|
|
static int afs_statfs(struct dentry *dentry, struct kstatfs *buf)
|
|
|
|
{
|
2018-02-06 09:26:30 +03:00
|
|
|
struct afs_super_info *as = AFS_FS_S(dentry->d_sb);
|
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 18:27:50 +03:00
|
|
|
struct afs_fs_cursor fc;
|
2007-05-11 09:22:20 +04:00
|
|
|
struct afs_volume_status vs;
|
2015-03-18 01:25:59 +03:00
|
|
|
struct afs_vnode *vnode = AFS_FS_I(d_inode(dentry));
|
2007-05-11 09:22:20 +04:00
|
|
|
struct key *key;
|
|
|
|
int ret;
|
|
|
|
|
2018-02-06 09:26:30 +03:00
|
|
|
buf->f_type = dentry->d_sb->s_magic;
|
|
|
|
buf->f_bsize = AFS_BLOCK_SIZE;
|
|
|
|
buf->f_namelen = AFSNAMEMAX - 1;
|
|
|
|
|
|
|
|
if (as->dyn_root) {
|
|
|
|
buf->f_blocks = 1;
|
|
|
|
buf->f_bavail = 0;
|
|
|
|
buf->f_bfree = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
2018-04-06 16:17:25 +03:00
|
|
|
|
2007-05-11 09:22:20 +04:00
|
|
|
key = afs_request_key(vnode->volume->cell);
|
|
|
|
if (IS_ERR(key))
|
|
|
|
return PTR_ERR(key);
|
|
|
|
|
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 18:27:50 +03:00
|
|
|
ret = -ERESTARTSYS;
|
|
|
|
if (afs_begin_vnode_operation(&fc, vnode, key)) {
|
|
|
|
fc.flags |= AFS_FS_CURSOR_NO_VSLEEP;
|
|
|
|
while (afs_select_fileserver(&fc)) {
|
2018-05-13 00:31:33 +03:00
|
|
|
fc.cb_break = afs_calc_vnode_cb_break(vnode);
|
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 18:27:50 +03:00
|
|
|
afs_fs_get_volume_status(&fc, &vs);
|
|
|
|
}
|
|
|
|
|
|
|
|
afs_check_for_remote_deletion(&fc, fc.vnode);
|
|
|
|
afs_vnode_commit_status(&fc, vnode, fc.cb_break);
|
|
|
|
ret = afs_end_vnode_operation(&fc);
|
2007-05-11 09:22:20 +04: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 18:27:50 +03:00
|
|
|
key_put(key);
|
2007-05-11 09:22:20 +04: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 18:27:50 +03:00
|
|
|
if (ret == 0) {
|
|
|
|
if (vs.max_quota == 0)
|
|
|
|
buf->f_blocks = vs.part_max_blocks;
|
|
|
|
else
|
|
|
|
buf->f_blocks = vs.max_quota;
|
|
|
|
buf->f_bavail = buf->f_bfree = buf->f_blocks - vs.blocks_in_use;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2007-05-11 09:22:20 +04:00
|
|
|
}
|