2007-04-26 22:49:28 +00:00
|
|
|
/* AFS client file system
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
2009-04-03 15:42:41 +00:00
|
|
|
* Copyright (C) 2002,5 Red Hat, Inc. All Rights Reserved.
|
2005-04-16 22:20:36 +00: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-20 21:22:52 +00:00
|
|
|
#include <linux/sched.h>
|
2016-08-30 15:05:14 +00:00
|
|
|
#include <linux/random.h>
|
2017-01-05 10:38:34 +00:00
|
|
|
#define CREATE_TRACE_POINTS
|
2005-04-16 22:20:36 +00:00
|
|
|
#include "internal.h"
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("AFS Client File System");
|
|
|
|
MODULE_AUTHOR("Red Hat, Inc.");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
2007-04-26 22:55:03 +00:00
|
|
|
unsigned afs_debug;
|
|
|
|
module_param_named(debug, afs_debug, uint, S_IWUSR | S_IRUGO);
|
2008-04-16 10:08:22 +00:00
|
|
|
MODULE_PARM_DESC(debug, "AFS debugging mask");
|
2007-04-26 22:55:03 +00:00
|
|
|
|
2005-04-16 22:20:36 +00: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 15:56:37 +00:00
|
|
|
struct workqueue_struct *afs_wq;
|
2017-11-02 15:27:45 +00:00
|
|
|
struct afs_net __afs_net;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialise an AFS network namespace record.
|
|
|
|
*/
|
|
|
|
static int __net_init afs_net_init(struct afs_net *net)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
net->live = true;
|
|
|
|
generate_random_uuid((unsigned char *)&net->uuid);
|
|
|
|
|
|
|
|
INIT_WORK(&net->charge_preallocation_work, afs_charge_preallocation);
|
|
|
|
mutex_init(&net->socket_mutex);
|
|
|
|
INIT_LIST_HEAD(&net->cells);
|
|
|
|
rwlock_init(&net->cells_lock);
|
|
|
|
init_rwsem(&net->cells_sem);
|
|
|
|
init_waitqueue_head(&net->cells_freeable_wq);
|
|
|
|
init_rwsem(&net->proc_cells_sem);
|
|
|
|
INIT_LIST_HEAD(&net->proc_cells);
|
|
|
|
INIT_LIST_HEAD(&net->vl_updates);
|
|
|
|
INIT_LIST_HEAD(&net->vl_graveyard);
|
|
|
|
INIT_DELAYED_WORK(&net->vl_reaper, afs_vlocation_reaper);
|
|
|
|
INIT_DELAYED_WORK(&net->vl_updater, afs_vlocation_updater);
|
|
|
|
spin_lock_init(&net->vl_updates_lock);
|
|
|
|
spin_lock_init(&net->vl_graveyard_lock);
|
|
|
|
net->servers = RB_ROOT;
|
|
|
|
rwlock_init(&net->servers_lock);
|
|
|
|
INIT_LIST_HEAD(&net->server_graveyard);
|
|
|
|
spin_lock_init(&net->server_graveyard_lock);
|
2017-11-02 15:27:45 +00:00
|
|
|
INIT_WORK(&net->server_reaper, afs_reap_server);
|
|
|
|
timer_setup(&net->server_timer, afs_server_timer, 0);
|
2017-11-02 15:27:45 +00: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:
|
|
|
|
afs_vlocation_purge(net);
|
|
|
|
afs_cell_purge(net);
|
|
|
|
error_cell_init:
|
|
|
|
afs_proc_cleanup(net);
|
|
|
|
error_proc:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clean up and destroy an AFS network namespace record.
|
|
|
|
*/
|
|
|
|
static void __net_exit afs_net_exit(struct afs_net *net)
|
|
|
|
{
|
|
|
|
net->live = false;
|
|
|
|
afs_purge_servers(net);
|
|
|
|
afs_vlocation_purge(net);
|
|
|
|
afs_cell_purge(net);
|
2017-11-02 15:27:45 +00:00
|
|
|
afs_close_socket(net);
|
2017-11-02 15:27:45 +00:00
|
|
|
afs_proc_cleanup(net);
|
|
|
|
}
|
2007-04-26 22:58:17 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* initialise the AFS client FS module
|
|
|
|
*/
|
|
|
|
static int __init afs_init(void)
|
|
|
|
{
|
2017-11-02 15:27:45 +00:00
|
|
|
int ret = -ENOMEM;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
printk(KERN_INFO "kAFS: Red Hat AFS client v0.1 registering.\n");
|
|
|
|
|
2011-01-14 15:56:37 +00:00
|
|
|
afs_wq = alloc_workqueue("afs", 0, 0);
|
|
|
|
if (!afs_wq)
|
2017-11-02 15:27:45 +00:00
|
|
|
goto error_afs_wq;
|
|
|
|
afs_async_calls = alloc_workqueue("kafsd", WQ_MEM_RECLAIM, 0);
|
|
|
|
if (!afs_async_calls)
|
|
|
|
goto error_async;
|
|
|
|
afs_vlocation_update_worker =
|
|
|
|
alloc_workqueue("kafs_vlupdated", WQ_MEM_RECLAIM, 0);
|
|
|
|
if (!afs_vlocation_update_worker)
|
|
|
|
goto error_vl_up;
|
|
|
|
afs_lock_manager = alloc_workqueue("kafs_lockd", WQ_MEM_RECLAIM, 0);
|
|
|
|
if (!afs_lock_manager)
|
|
|
|
goto error_lockmgr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-04-03 15:42:41 +00:00
|
|
|
#ifdef CONFIG_AFS_FSCACHE
|
2005-04-16 22:20:36 +00:00
|
|
|
/* we want to be able to cache */
|
2009-04-03 15:42:41 +00:00
|
|
|
ret = fscache_register_netfs(&afs_cache_netfs);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ret < 0)
|
|
|
|
goto error_cache;
|
|
|
|
#endif
|
|
|
|
|
2017-11-02 15:27:45 +00:00
|
|
|
ret = afs_net_init(&__afs_net);
|
2010-08-06 16:26:48 +00:00
|
|
|
if (ret < 0)
|
2017-11-02 15:27:45 +00:00
|
|
|
goto error_net;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* register the filesystems */
|
|
|
|
ret = afs_fs_init();
|
|
|
|
if (ret < 0)
|
2007-04-26 22:49:28 +00:00
|
|
|
goto error_fs;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
2007-04-26 22:49:28 +00:00
|
|
|
error_fs:
|
2017-11-02 15:27:45 +00:00
|
|
|
afs_net_exit(&__afs_net);
|
|
|
|
error_net:
|
2009-04-03 15:42:41 +00:00
|
|
|
#ifdef CONFIG_AFS_FSCACHE
|
|
|
|
fscache_unregister_netfs(&afs_cache_netfs);
|
2007-04-26 22:49:28 +00:00
|
|
|
error_cache:
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
2017-11-02 15:27:45 +00:00
|
|
|
destroy_workqueue(afs_lock_manager);
|
|
|
|
error_lockmgr:
|
|
|
|
destroy_workqueue(afs_vlocation_update_worker);
|
|
|
|
error_vl_up:
|
|
|
|
destroy_workqueue(afs_async_calls);
|
|
|
|
error_async:
|
2011-01-14 15:56:37 +00:00
|
|
|
destroy_workqueue(afs_wq);
|
2017-11-02 15:27:45 +00:00
|
|
|
error_afs_wq:
|
2007-05-09 09:33:45 +00:00
|
|
|
rcu_barrier();
|
2005-04-16 22:20:36 +00:00
|
|
|
printk(KERN_ERR "kAFS: failed to register: %d\n", ret);
|
|
|
|
return ret;
|
2007-04-26 22:49:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00: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-26 22:49:28 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* clean up on module removal
|
|
|
|
*/
|
|
|
|
static void __exit afs_exit(void)
|
|
|
|
{
|
|
|
|
printk(KERN_INFO "kAFS: Red Hat AFS client v0.1 unregistering.\n");
|
|
|
|
|
|
|
|
afs_fs_exit();
|
2017-11-02 15:27:45 +00:00
|
|
|
afs_net_exit(&__afs_net);
|
2009-04-03 15:42:41 +00:00
|
|
|
#ifdef CONFIG_AFS_FSCACHE
|
|
|
|
fscache_unregister_netfs(&afs_cache_netfs);
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
2017-11-02 15:27:45 +00:00
|
|
|
destroy_workqueue(afs_lock_manager);
|
|
|
|
destroy_workqueue(afs_vlocation_update_worker);
|
|
|
|
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 15:27:49 +00:00
|
|
|
afs_clean_up_permit_cache();
|
2007-05-09 09:33:45 +00:00
|
|
|
rcu_barrier();
|
2007-04-26 22:49:28 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
module_exit(afs_exit);
|