2007-04-27 06:49:28 +08:00
|
|
|
/* AFS client file system
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2009-04-03 23:42:41 +08:00
|
|
|
* Copyright (C) 2002,5 Red Hat, Inc. All Rights Reserved.
|
2005-04-17 06:20:36 +08:00
|
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/moduleparam.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/completion.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 05:22:52 +08:00
|
|
|
#include <linux/sched.h>
|
2016-08-30 23:05:14 +08:00
|
|
|
#include <linux/random.h>
|
2018-05-18 18:46:15 +08:00
|
|
|
#include <linux/proc_fs.h>
|
2017-01-05 18:38:34 +08:00
|
|
|
#define CREATE_TRACE_POINTS
|
2005-04-17 06:20:36 +08:00
|
|
|
#include "internal.h"
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("AFS Client File System");
|
|
|
|
MODULE_AUTHOR("Red Hat, Inc.");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
2007-04-27 06:55:03 +08:00
|
|
|
unsigned afs_debug;
|
|
|
|
module_param_named(debug, afs_debug, uint, S_IWUSR | S_IRUGO);
|
2008-04-16 18:08:22 +08:00
|
|
|
MODULE_PARM_DESC(debug, "AFS debugging mask");
|
2007-04-27 06:55:03 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static char *rootcell;
|
|
|
|
|
|
|
|
module_param(rootcell, charp, 0);
|
|
|
|
MODULE_PARM_DESC(rootcell, "root AFS cell name and VL server IP addr list");
|
|
|
|
|
2011-01-14 23:56:37 +08:00
|
|
|
struct workqueue_struct *afs_wq;
|
2018-05-18 18:46:15 +08:00
|
|
|
static struct proc_dir_entry *afs_proc_symlink;
|
2017-11-02 23:27:45 +08:00
|
|
|
|
2018-04-10 04:12:31 +08:00
|
|
|
#if defined(CONFIG_ALPHA)
|
|
|
|
const char afs_init_sysname[] = "alpha_linux26";
|
|
|
|
#elif defined(CONFIG_X86_64)
|
|
|
|
const char afs_init_sysname[] = "amd64_linux26";
|
|
|
|
#elif defined(CONFIG_ARM)
|
|
|
|
const char afs_init_sysname[] = "arm_linux26";
|
|
|
|
#elif defined(CONFIG_ARM64)
|
|
|
|
const char afs_init_sysname[] = "aarch64_linux26";
|
|
|
|
#elif defined(CONFIG_X86_32)
|
|
|
|
const char afs_init_sysname[] = "i386_linux26";
|
|
|
|
#elif defined(CONFIG_IA64)
|
|
|
|
const char afs_init_sysname[] = "ia64_linux26";
|
|
|
|
#elif defined(CONFIG_PPC64)
|
|
|
|
const char afs_init_sysname[] = "ppc64_linux26";
|
|
|
|
#elif defined(CONFIG_PPC32)
|
|
|
|
const char afs_init_sysname[] = "ppc_linux26";
|
|
|
|
#elif defined(CONFIG_S390)
|
|
|
|
#ifdef CONFIG_64BIT
|
|
|
|
const char afs_init_sysname[] = "s390x_linux26";
|
|
|
|
#else
|
|
|
|
const char afs_init_sysname[] = "s390_linux26";
|
|
|
|
#endif
|
|
|
|
#elif defined(CONFIG_SPARC64)
|
|
|
|
const char afs_init_sysname[] = "sparc64_linux26";
|
|
|
|
#elif defined(CONFIG_SPARC32)
|
|
|
|
const char afs_init_sysname[] = "sparc_linux26";
|
|
|
|
#else
|
|
|
|
const char afs_init_sysname[] = "unknown_linux26";
|
|
|
|
#endif
|
|
|
|
|
2017-11-02 23:27:45 +08:00
|
|
|
/*
|
|
|
|
* Initialise an AFS network namespace record.
|
|
|
|
*/
|
2018-05-18 18:46:15 +08:00
|
|
|
static int __net_init afs_net_init(struct net *net_ns)
|
2017-11-02 23:27:45 +08:00
|
|
|
{
|
2018-04-10 04:12:31 +08:00
|
|
|
struct afs_sysnames *sysnames;
|
2018-05-18 18:46:15 +08:00
|
|
|
struct afs_net *net = afs_net(net_ns);
|
2017-11-02 23:27:45 +08:00
|
|
|
int ret;
|
|
|
|
|
2018-05-18 18:46:15 +08:00
|
|
|
net->net = net_ns;
|
2017-11-02 23:27:45 +08:00
|
|
|
net->live = true;
|
|
|
|
generate_random_uuid((unsigned char *)&net->uuid);
|
|
|
|
|
|
|
|
INIT_WORK(&net->charge_preallocation_work, afs_charge_preallocation);
|
|
|
|
mutex_init(&net->socket_mutex);
|
2017-11-02 23:27:50 +08:00
|
|
|
|
|
|
|
net->cells = RB_ROOT;
|
|
|
|
seqlock_init(&net->cells_lock);
|
|
|
|
INIT_WORK(&net->cells_manager, afs_manage_cells);
|
|
|
|
timer_setup(&net->cells_timer, afs_cells_timer, 0);
|
|
|
|
|
2018-06-15 22:19:22 +08:00
|
|
|
mutex_init(&net->proc_cells_lock);
|
2017-11-02 23:27:45 +08:00
|
|
|
INIT_LIST_HEAD(&net->proc_cells);
|
2017-11-02 23:27:50 +08: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 23:27:50 +08:00
|
|
|
seqlock_init(&net->fs_lock);
|
|
|
|
net->fs_servers = RB_ROOT;
|
|
|
|
INIT_LIST_HEAD(&net->fs_updates);
|
|
|
|
INIT_HLIST_HEAD(&net->fs_proc);
|
|
|
|
|
|
|
|
INIT_HLIST_HEAD(&net->fs_addresses4);
|
|
|
|
INIT_HLIST_HEAD(&net->fs_addresses6);
|
|
|
|
seqlock_init(&net->fs_addr_lock);
|
|
|
|
|
|
|
|
INIT_WORK(&net->fs_manager, afs_manage_servers);
|
|
|
|
timer_setup(&net->fs_timer, afs_servers_timer, 0);
|
2017-11-02 23:27:45 +08:00
|
|
|
|
2018-04-10 04:12:31 +08:00
|
|
|
ret = -ENOMEM;
|
|
|
|
sysnames = kzalloc(sizeof(*sysnames), GFP_KERNEL);
|
|
|
|
if (!sysnames)
|
|
|
|
goto error_sysnames;
|
|
|
|
sysnames->subs[0] = (char *)&afs_init_sysname;
|
|
|
|
sysnames->nr = 1;
|
|
|
|
refcount_set(&sysnames->usage, 1);
|
|
|
|
net->sysnames = sysnames;
|
|
|
|
rwlock_init(&net->sysnames_lock);
|
|
|
|
|
2017-11-02 23:27:45 +08:00
|
|
|
/* Register the /proc stuff */
|
|
|
|
ret = afs_proc_init(net);
|
|
|
|
if (ret < 0)
|
|
|
|
goto error_proc;
|
|
|
|
|
|
|
|
/* Initialise the cell DB */
|
|
|
|
ret = afs_cell_init(net, rootcell);
|
|
|
|
if (ret < 0)
|
|
|
|
goto error_cell_init;
|
|
|
|
|
|
|
|
/* Create the RxRPC transport */
|
|
|
|
ret = afs_open_socket(net);
|
|
|
|
if (ret < 0)
|
|
|
|
goto error_open_socket;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error_open_socket:
|
2017-11-02 23:27:50 +08:00
|
|
|
net->live = false;
|
2017-11-02 23:27:45 +08:00
|
|
|
afs_cell_purge(net);
|
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 23:27:50 +08:00
|
|
|
afs_purge_servers(net);
|
2017-11-02 23:27:45 +08:00
|
|
|
error_cell_init:
|
2017-11-02 23:27:50 +08:00
|
|
|
net->live = false;
|
2017-11-02 23:27:45 +08:00
|
|
|
afs_proc_cleanup(net);
|
|
|
|
error_proc:
|
2018-04-10 04:12:31 +08:00
|
|
|
afs_put_sysnames(net->sysnames);
|
|
|
|
error_sysnames:
|
2017-11-02 23:27:50 +08:00
|
|
|
net->live = false;
|
2017-11-02 23:27:45 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clean up and destroy an AFS network namespace record.
|
|
|
|
*/
|
2018-05-18 18:46:15 +08:00
|
|
|
static void __net_exit afs_net_exit(struct net *net_ns)
|
2017-11-02 23:27:45 +08:00
|
|
|
{
|
2018-05-18 18:46:15 +08:00
|
|
|
struct afs_net *net = afs_net(net_ns);
|
|
|
|
|
2017-11-02 23:27:45 +08:00
|
|
|
net->live = false;
|
|
|
|
afs_cell_purge(net);
|
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 23:27:50 +08:00
|
|
|
afs_purge_servers(net);
|
2017-11-02 23:27:45 +08:00
|
|
|
afs_close_socket(net);
|
2017-11-02 23:27:45 +08:00
|
|
|
afs_proc_cleanup(net);
|
2018-04-10 04:12:31 +08:00
|
|
|
afs_put_sysnames(net->sysnames);
|
2017-11-02 23:27:45 +08:00
|
|
|
}
|
2007-04-27 06:58:17 +08:00
|
|
|
|
2018-05-18 18:46:15 +08:00
|
|
|
static struct pernet_operations afs_net_ops = {
|
|
|
|
.init = afs_net_init,
|
|
|
|
.exit = afs_net_exit,
|
|
|
|
.id = &afs_net_id,
|
|
|
|
.size = sizeof(struct afs_net),
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* initialise the AFS client FS module
|
|
|
|
*/
|
|
|
|
static int __init afs_init(void)
|
|
|
|
{
|
2017-11-02 23:27:45 +08:00
|
|
|
int ret = -ENOMEM;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
printk(KERN_INFO "kAFS: Red Hat AFS client v0.1 registering.\n");
|
|
|
|
|
2011-01-14 23:56:37 +08:00
|
|
|
afs_wq = alloc_workqueue("afs", 0, 0);
|
|
|
|
if (!afs_wq)
|
2017-11-02 23:27:45 +08:00
|
|
|
goto error_afs_wq;
|
|
|
|
afs_async_calls = alloc_workqueue("kafsd", WQ_MEM_RECLAIM, 0);
|
|
|
|
if (!afs_async_calls)
|
|
|
|
goto error_async;
|
|
|
|
afs_lock_manager = alloc_workqueue("kafs_lockd", WQ_MEM_RECLAIM, 0);
|
|
|
|
if (!afs_lock_manager)
|
|
|
|
goto error_lockmgr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-04-03 23:42:41 +08:00
|
|
|
#ifdef CONFIG_AFS_FSCACHE
|
2005-04-17 06:20:36 +08:00
|
|
|
/* we want to be able to cache */
|
2009-04-03 23:42:41 +08:00
|
|
|
ret = fscache_register_netfs(&afs_cache_netfs);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ret < 0)
|
|
|
|
goto error_cache;
|
|
|
|
#endif
|
|
|
|
|
2018-05-18 18:46:15 +08:00
|
|
|
ret = register_pernet_subsys(&afs_net_ops);
|
2010-08-07 00:26:48 +08:00
|
|
|
if (ret < 0)
|
2017-11-02 23:27:45 +08:00
|
|
|
goto error_net;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* register the filesystems */
|
|
|
|
ret = afs_fs_init();
|
|
|
|
if (ret < 0)
|
2007-04-27 06:49:28 +08:00
|
|
|
goto error_fs;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-05-18 18:46:15 +08:00
|
|
|
afs_proc_symlink = proc_symlink("fs/afs", NULL, "../self/net/afs");
|
|
|
|
if (IS_ERR(afs_proc_symlink)) {
|
|
|
|
ret = PTR_ERR(afs_proc_symlink);
|
|
|
|
goto error_proc;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return ret;
|
|
|
|
|
2018-05-18 18:46:15 +08:00
|
|
|
error_proc:
|
|
|
|
afs_fs_exit();
|
2007-04-27 06:49:28 +08:00
|
|
|
error_fs:
|
2018-05-18 18:46:15 +08:00
|
|
|
unregister_pernet_subsys(&afs_net_ops);
|
2017-11-02 23:27:45 +08:00
|
|
|
error_net:
|
2009-04-03 23:42:41 +08:00
|
|
|
#ifdef CONFIG_AFS_FSCACHE
|
|
|
|
fscache_unregister_netfs(&afs_cache_netfs);
|
2007-04-27 06:49:28 +08:00
|
|
|
error_cache:
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
2017-11-02 23:27:45 +08:00
|
|
|
destroy_workqueue(afs_lock_manager);
|
|
|
|
error_lockmgr:
|
|
|
|
destroy_workqueue(afs_async_calls);
|
|
|
|
error_async:
|
2011-01-14 23:56:37 +08:00
|
|
|
destroy_workqueue(afs_wq);
|
2017-11-02 23:27:45 +08:00
|
|
|
error_afs_wq:
|
2007-05-09 17:33:45 +08:00
|
|
|
rcu_barrier();
|
2005-04-17 06:20:36 +08:00
|
|
|
printk(KERN_ERR "kAFS: failed to register: %d\n", ret);
|
|
|
|
return ret;
|
2007-04-27 06:49:28 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* XXX late_initcall is kludgy, but the only alternative seems to create
|
|
|
|
* a transport upon the first mount, which is worse. Or is it?
|
|
|
|
*/
|
|
|
|
late_initcall(afs_init); /* must be called after net/ to create socket */
|
2007-04-27 06:49:28 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* clean up on module removal
|
|
|
|
*/
|
|
|
|
static void __exit afs_exit(void)
|
|
|
|
{
|
|
|
|
printk(KERN_INFO "kAFS: Red Hat AFS client v0.1 unregistering.\n");
|
|
|
|
|
2018-05-18 18:46:15 +08:00
|
|
|
proc_remove(afs_proc_symlink);
|
2005-04-17 06:20:36 +08:00
|
|
|
afs_fs_exit();
|
2018-05-18 18:46:15 +08:00
|
|
|
unregister_pernet_subsys(&afs_net_ops);
|
2009-04-03 23:42:41 +08:00
|
|
|
#ifdef CONFIG_AFS_FSCACHE
|
|
|
|
fscache_unregister_netfs(&afs_cache_netfs);
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
2017-11-02 23:27:45 +08:00
|
|
|
destroy_workqueue(afs_lock_manager);
|
|
|
|
destroy_workqueue(afs_async_calls);
|
|
|
|
destroy_workqueue(afs_wq);
|
afs: Overhaul permit caching
Overhaul permit caching in AFS by making it per-vnode and sharing permit
lists where possible.
When most of the fileserver operations are called, they return a status
structure indicating the (revised) details of the vnode or vnodes involved
in the operation. This includes the access mark derived from the ACL
(named CallerAccess in the protocol definition file). This is cacheable
and if the ACL changes, the server will tell us that it is breaking the
callback promise, at which point we can discard the currently cached
permits.
With this patch, the afs_permits structure has, at the end, an array of
{ key, CallerAccess } elements, sorted by key pointer. This is then cached
in a hash table so that it can be shared between vnodes with the same
access permits.
Permit lists can only be shared if they contain the exact same set of
key->CallerAccess mappings.
Note that that table is global rather than being per-net_ns. If the keys
in a permit list cross net_ns boundaries, there is no problem sharing the
cached permits, since the permits are just integer masks.
Since permit lists pin keys, the permit cache also makes it easier for a
future patch to find all occurrences of a key and remove them by means of
setting the afs_permits::invalidated flag and then clearing the appropriate
key pointer. In such an event, memory barriers will need adding.
Lastly, the permit caching is skipped if the server has sent either a
vnode-specific or an entire-server callback since the start of the
operation.
Signed-off-by: David Howells <dhowells@redhat.com>
2017-11-02 23:27:49 +08:00
|
|
|
afs_clean_up_permit_cache();
|
2007-05-09 17:33:45 +08:00
|
|
|
rcu_barrier();
|
2007-04-27 06:49:28 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
module_exit(afs_exit);
|