2019-05-27 09:55:01 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2007-04-27 02:49:28 +04:00
|
|
|
/* mountpoint management
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
|
|
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/pagemap.h>
|
|
|
|
#include <linux/mount.h>
|
|
|
|
#include <linux/namei.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 11:04:11 +03:00
|
|
|
#include <linux/gfp.h>
|
2018-11-02 02:07:27 +03:00
|
|
|
#include <linux/fs_context.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include "internal.h"
|
|
|
|
|
|
|
|
|
|
|
|
static struct dentry *afs_mntpt_lookup(struct inode *dir,
|
|
|
|
struct dentry *dentry,
|
2012-06-11 01:13:09 +04:00
|
|
|
unsigned int flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
static int afs_mntpt_open(struct inode *inode, struct file *file);
|
2007-04-27 02:55:03 +04:00
|
|
|
static void afs_mntpt_expiry_timed_out(struct work_struct *work);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2006-03-28 13:56:42 +04:00
|
|
|
const struct file_operations afs_mntpt_file_operations = {
|
2005-04-17 02:20:36 +04:00
|
|
|
.open = afs_mntpt_open,
|
llseek: automatically add .llseek fop
All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.
The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.
New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.
The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.
Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.
Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.
===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}
@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}
@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}
@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}
@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};
@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};
@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};
@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};
@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};
// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};
@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};
// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};
// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};
// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};
@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};
// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////
@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};
@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};
@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};
@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>
2010-08-15 20:52:59 +04:00
|
|
|
.llseek = noop_llseek,
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
2007-02-12 11:55:38 +03:00
|
|
|
const struct inode_operations afs_mntpt_inode_operations = {
|
2005-04-17 02:20:36 +04:00
|
|
|
.lookup = afs_mntpt_lookup,
|
|
|
|
.readlink = page_readlink,
|
2007-05-09 13:33:45 +04:00
|
|
|
.getattr = afs_getattr,
|
2017-07-06 17:50:27 +03:00
|
|
|
.listxattr = afs_listxattr,
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
2010-08-11 12:38:04 +04:00
|
|
|
const struct inode_operations afs_autocell_inode_operations = {
|
|
|
|
.getattr = afs_getattr,
|
|
|
|
};
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
static LIST_HEAD(afs_vfsmounts);
|
2007-04-27 02:55:03 +04:00
|
|
|
static DECLARE_DELAYED_WORK(afs_mntpt_expiry_timer, afs_mntpt_expiry_timed_out);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-10-17 10:26:41 +04:00
|
|
|
static unsigned long afs_mntpt_expiry_timeout = 10 * 60;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
static const char afs_root_volume[] = "root.cell";
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* no valid lookup procedure on this sort of dir
|
|
|
|
*/
|
|
|
|
static struct dentry *afs_mntpt_lookup(struct inode *dir,
|
|
|
|
struct dentry *dentry,
|
2012-06-11 01:13:09 +04:00
|
|
|
unsigned int flags)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2014-10-22 04:11:25 +04:00
|
|
|
_enter("%p,%p{%pd2}", dir, dentry, dentry);
|
2005-04-17 02:20:36 +04:00
|
|
|
return ERR_PTR(-EREMOTE);
|
2007-04-27 02:49:28 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* no valid open procedure on this sort of dir
|
|
|
|
*/
|
|
|
|
static int afs_mntpt_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
2014-10-22 04:11:25 +04:00
|
|
|
_enter("%p,%p{%pD2}", inode, file, file);
|
2005-04-17 02:20:36 +04:00
|
|
|
return -EREMOTE;
|
2007-04-27 02:49:28 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
2018-11-02 02:07:27 +03:00
|
|
|
* Set the parameters for the proposed superblock.
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
2018-11-02 02:07:27 +03:00
|
|
|
static int afs_mntpt_set_params(struct fs_context *fc, struct dentry *mntpt)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2018-11-02 02:07:27 +03:00
|
|
|
struct afs_fs_context *ctx = fc->fs_private;
|
|
|
|
struct afs_super_info *src_as = AFS_FS_S(mntpt->d_sb);
|
|
|
|
struct afs_vnode *vnode = AFS_FS_I(d_inode(mntpt));
|
|
|
|
struct afs_cell *cell;
|
|
|
|
const char *p;
|
2005-04-17 02:20:36 +04:00
|
|
|
int ret;
|
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
if (fc->net_ns != src_as->net_ns) {
|
|
|
|
put_net(fc->net_ns);
|
|
|
|
fc->net_ns = get_net(src_as->net_ns);
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
if (src_as->volume && src_as->volume->type == AFSVL_RWVOL) {
|
|
|
|
ctx->type = AFSVL_RWVOL;
|
|
|
|
ctx->force = true;
|
|
|
|
}
|
|
|
|
if (ctx->cell) {
|
|
|
|
afs_put_cell(ctx->net, ctx->cell);
|
|
|
|
ctx->cell = NULL;
|
|
|
|
}
|
2010-08-11 12:38:04 +04:00
|
|
|
if (test_bit(AFS_VNODE_PSEUDODIR, &vnode->flags)) {
|
|
|
|
/* if the directory is a pseudo directory, use the d_name */
|
|
|
|
unsigned size = mntpt->d_name.len;
|
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
if (size < 2)
|
|
|
|
return -ENOENT;
|
2010-08-11 12:38:04 +04:00
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
p = mntpt->d_name.name;
|
2010-08-11 12:38:04 +04:00
|
|
|
if (mntpt->d_name.name[0] == '.') {
|
2018-11-02 02:07:27 +03:00
|
|
|
size--;
|
|
|
|
p++;
|
|
|
|
ctx->type = AFSVL_RWVOL;
|
|
|
|
ctx->force = true;
|
2010-08-11 12:38:04 +04:00
|
|
|
}
|
2018-11-02 02:07:27 +03:00
|
|
|
if (size > AFS_MAXCELLNAME)
|
|
|
|
return -ENAMETOOLONG;
|
|
|
|
|
|
|
|
cell = afs_lookup_cell(ctx->net, p, size, NULL, false);
|
|
|
|
if (IS_ERR(cell)) {
|
|
|
|
pr_err("kAFS: unable to lookup cell '%pd'\n", mntpt);
|
|
|
|
return PTR_ERR(cell);
|
|
|
|
}
|
|
|
|
ctx->cell = cell;
|
|
|
|
|
|
|
|
ctx->volname = afs_root_volume;
|
|
|
|
ctx->volnamesz = sizeof(afs_root_volume) - 1;
|
2010-08-11 12:38:04 +04:00
|
|
|
} else {
|
|
|
|
/* read the contents of the AFS special symlink */
|
2018-11-02 02:07:27 +03:00
|
|
|
struct page *page;
|
2015-03-18 01:25:59 +03:00
|
|
|
loff_t size = i_size_read(d_inode(mntpt));
|
2010-08-11 12:38:04 +04:00
|
|
|
char *buf;
|
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
if (src_as->cell)
|
|
|
|
ctx->cell = afs_get_cell(src_as->cell);
|
|
|
|
|
2019-12-09 18:04:45 +03:00
|
|
|
if (size < 2 || size > PAGE_SIZE - 1)
|
2018-11-02 02:07:27 +03:00
|
|
|
return -EINVAL;
|
2010-08-11 12:38:04 +04:00
|
|
|
|
2015-03-18 01:25:59 +03:00
|
|
|
page = read_mapping_page(d_inode(mntpt)->i_mapping, 0, NULL);
|
2018-11-02 02:07:27 +03:00
|
|
|
if (IS_ERR(page))
|
|
|
|
return PTR_ERR(page);
|
2010-08-11 12:38:04 +04:00
|
|
|
|
2018-10-20 02:57:57 +03:00
|
|
|
if (PageError(page)) {
|
|
|
|
ret = afs_bad(AFS_FS_I(d_inode(mntpt)), afs_file_error_mntpt);
|
2018-11-02 02:07:27 +03:00
|
|
|
put_page(page);
|
|
|
|
return ret;
|
2018-10-20 02:57:57 +03:00
|
|
|
}
|
2010-08-11 12:38:04 +04:00
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
buf = kmap(page);
|
2019-12-09 18:04:45 +03:00
|
|
|
ret = -EINVAL;
|
|
|
|
if (buf[size - 1] == '.')
|
|
|
|
ret = vfs_parse_fs_string(fc, "source", buf, size - 1);
|
2018-11-02 02:07:27 +03:00
|
|
|
kunmap(page);
|
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
|
|
|
put_page(page);
|
2018-11-02 02:07:27 +03:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
return 0;
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
/*
|
|
|
|
* create a vfsmount to be automounted
|
|
|
|
*/
|
|
|
|
static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt)
|
|
|
|
{
|
|
|
|
struct fs_context *fc;
|
|
|
|
struct vfsmount *mnt;
|
|
|
|
int ret;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
BUG_ON(!d_inode(mntpt));
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2018-11-02 02:07:27 +03:00
|
|
|
fc = fs_context_for_submount(&afs_fs_type, mntpt);
|
|
|
|
if (IS_ERR(fc))
|
|
|
|
return ERR_CAST(fc);
|
|
|
|
|
|
|
|
ret = afs_mntpt_set_params(fc, mntpt);
|
|
|
|
if (!ret)
|
|
|
|
mnt = fc_mount(fc);
|
|
|
|
else
|
|
|
|
mnt = ERR_PTR(ret);
|
|
|
|
|
|
|
|
put_fs_context(fc);
|
|
|
|
return mnt;
|
2007-04-27 02:49:28 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
2011-01-14 22:04:05 +03:00
|
|
|
* handle an automount point
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
2011-01-14 22:04:05 +03:00
|
|
|
struct vfsmount *afs_d_automount(struct path *path)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
struct vfsmount *newmnt;
|
|
|
|
|
2014-10-22 04:11:25 +04:00
|
|
|
_enter("{%pd}", path->dentry);
|
2007-04-27 02:55:03 +04:00
|
|
|
|
2011-01-14 22:04:05 +03:00
|
|
|
newmnt = afs_mntpt_do_automount(path->dentry);
|
|
|
|
if (IS_ERR(newmnt))
|
|
|
|
return newmnt;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2011-01-14 22:10:03 +03:00
|
|
|
mntget(newmnt); /* prevent immediate expiration */
|
|
|
|
mnt_set_expiry(newmnt, &afs_vfsmounts);
|
|
|
|
queue_delayed_work(afs_wq, &afs_mntpt_expiry_timer,
|
|
|
|
afs_mntpt_expiry_timeout * HZ);
|
2011-11-25 11:22:06 +04:00
|
|
|
_leave(" = %p", newmnt);
|
2011-01-14 22:10:03 +03:00
|
|
|
return newmnt;
|
2007-04-27 02:49:28 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* handle mountpoint expiry timer going off
|
|
|
|
*/
|
2007-04-27 02:55:03 +04:00
|
|
|
static void afs_mntpt_expiry_timed_out(struct work_struct *work)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2007-04-27 02:55:03 +04:00
|
|
|
_enter("");
|
|
|
|
|
|
|
|
if (!list_empty(&afs_vfsmounts)) {
|
|
|
|
mark_mounts_for_expiry(&afs_vfsmounts);
|
2011-01-14 18:56:37 +03:00
|
|
|
queue_delayed_work(afs_wq, &afs_mntpt_expiry_timer,
|
|
|
|
afs_mntpt_expiry_timeout * HZ);
|
2007-04-27 02:55:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
_leave("");
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-04-27 02:55:03 +04:00
|
|
|
/*
|
|
|
|
* kill the AFS mountpoint timer if it's still running
|
|
|
|
*/
|
|
|
|
void afs_mntpt_kill_timer(void)
|
|
|
|
{
|
|
|
|
_enter("");
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-04-27 02:55:03 +04:00
|
|
|
ASSERT(list_empty(&afs_vfsmounts));
|
2011-01-14 18:56:37 +03:00
|
|
|
cancel_delayed_work_sync(&afs_mntpt_expiry_timer);
|
2007-04-27 02:55:03 +04:00
|
|
|
}
|