Release 4.10 fs/nfsd/nfs4recover.c
/*
* Copyright (c) 2004 The Regents of the University of Michigan.
* Copyright (c) 2012 Jeff Layton <jlayton@redhat.com>
* All rights reserved.
*
* Andy Adamson <andros@citi.umich.edu>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <crypto/hash.h>
#include <linux/file.h>
#include <linux/slab.h>
#include <linux/namei.h>
#include <linux/sched.h>
#include <linux/fs.h>
#include <linux/module.h>
#include <net/net_namespace.h>
#include <linux/sunrpc/rpc_pipe_fs.h>
#include <linux/sunrpc/clnt.h>
#include <linux/nfsd/cld.h>
#include "nfsd.h"
#include "state.h"
#include "vfs.h"
#include "netns.h"
#define NFSDDBG_FACILITY NFSDDBG_PROC
/* Declarations */
struct nfsd4_client_tracking_ops {
int (*init)(struct net *);
void (*exit)(struct net *);
void (*create)(struct nfs4_client *);
void (*remove)(struct nfs4_client *);
int (*check)(struct nfs4_client *);
void (*grace_done)(struct nfsd_net *);
};
/* Globals */
static char user_recovery_dirname[PATH_MAX] = "/var/lib/nfs/v4recovery";
static int
nfs4_save_creds(const struct cred **original_creds)
{
struct cred *new;
new = prepare_creds();
if (!new)
return -ENOMEM;
new->fsuid = GLOBAL_ROOT_UID;
new->fsgid = GLOBAL_ROOT_GID;
*original_creds = override_creds(new);
put_cred(new);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david howells | david howells | 43 | 71.67% | 2 | 50.00% |
neil brown | neil brown | 15 | 25.00% | 1 | 25.00% |
eric w. biederman | eric w. biederman | 2 | 3.33% | 1 | 25.00% |
| Total | 60 | 100.00% | 4 | 100.00% |
static void
nfs4_reset_creds(const struct cred *original)
{
revert_creds(original);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
david howells | david howells | 10 | 58.82% | 1 | 50.00% |
neil brown | neil brown | 7 | 41.18% | 1 | 50.00% |
| Total | 17 | 100.00% | 2 | 100.00% |
static void
md5_to_hex(char *out, char *md5)
{
int i;
for (i=0; i<16; i++) {
unsigned char c = md5[i];
*out++ = '0' + ((c&0xf0)>>4) + (c>=0xa0)*('a'-'9'-1);
*out++ = '0' + (c&0x0f) + ((c&0x0f)>=0x0a)*('a'-'9'-1);
}
*out = '\0';
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
neil brown | neil brown | 106 | 100.00% | 1 | 100.00% |
| Total | 106 | 100.00% | 1 | 100.00% |
static int
nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname)
{
struct xdr_netobj cksum;
struct crypto_shash *tfm;
int status;
dprintk("NFSD: nfs4_make_rec_clidname for %.*s\n",
clname->len, clname->data);
tfm = crypto_alloc_shash("md5", 0, 0);
if (IS_ERR(tfm)) {
status = PTR_ERR(tfm);
goto out_no_tfm;
}
cksum.len = crypto_shash_digestsize(tfm);
cksum.data = kmalloc(cksum.len, GFP_KERNEL);
if (cksum.data == NULL) {
status = -ENOMEM;
goto out;
}
{
SHASH_DESC_ON_STACK(desc, tfm);
desc->tfm = tfm;
desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP;
status = crypto_shash_digest(desc, clname->data, clname->len,
cksum.data);
shash_desc_zero(desc);
}
if (status)
goto out;
md5_to_hex(dname, cksum.data);
status = 0;
out:
kfree(cksum.data);
crypto_free_shash(tfm);
out_no_tfm:
return status;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
neil brown | neil brown | 114 | 58.46% | 1 | 16.67% |
herbert xu | herbert xu | 48 | 24.62% | 2 | 33.33% |
jeff layton | jeff layton | 27 | 13.85% | 1 | 16.67% |
krishna kumar | krishna kumar | 5 | 2.56% | 1 | 16.67% |
jens axboe | jens axboe | 1 | 0.51% | 1 | 16.67% |
| Total | 195 | 100.00% | 6 | 100.00% |
/*
* If we had an error generating the recdir name for the legacy tracker
* then warn the admin. If the error doesn't appear to be transient,
* then disable recovery tracking.
*/
static void
legacy_recdir_name_error(struct nfs4_client *clp, int error)
{
printk(KERN_ERR "NFSD: unable to generate recoverydir "
"name (%d).\n", error);
/*
* if the algorithm just doesn't exist, then disable the recovery
* tracker altogether. The crypto libs will generally return this if
* FIPS is enabled as well.
*/
if (error == -ENOENT) {
printk(KERN_ERR "NFSD: disabling legacy clientid tracking. "
"Reboot recovery will not function correctly!\n");
nfsd4_client_tracking_exit(clp->net);
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jeff layton | jeff layton | 47 | 100.00% | 2 | 100.00% |
| Total | 47 | 100.00% | 2 | 100.00% |
static void
nfsd4_create_clid_dir(struct nfs4_client *clp)
{
const struct cred *original_cred;
char dname[HEXDIR_LEN];
struct dentry *dir, *dentry;
struct nfs4_client_reclaim *crp;
int status;
struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
if (test_and_set_bit(NFSD4_CLIENT_STABLE, &clp->cl_flags))
return;
if (!nn->rec_file)
return;
status = nfs4_make_rec_clidname(dname, &clp->cl_name);
if (status)
return legacy_recdir_name_error(clp, status);
status = nfs4_save_creds(&original_cred);
if (status < 0)
return;
status = mnt_want_write_file(nn->rec_file);
if (status)
goto out_creds;
dir = nn->rec_file->f_path.dentry;
/* lock the parent */
inode_lock(d_inode(dir));
dentry = lookup_one_len(dname, dir, HEXDIR_LEN-1);
if (IS_ERR(dentry)) {
status = PTR_ERR(dentry);
goto out_unlock;
}
if (d_really_is_positive(dentry))
/*
* In the 4.1 case, where we're called from
* reclaim_complete(), records from the previous reboot
* may still be left, so this is OK.
*
* In the 4.0 case, we should never get here; but we may
* as well be forgiving and just succeed silently.
*/
goto out_put;
status = vfs_mkdir(d_inode(dir), dentry, S_IRWXU);
out_put:
dput(dentry);
out_unlock:
inode_unlock(d_inode(dir));
if (status == 0) {
if (nn->in_grace) {
crp = nfs4_client_to_reclaim(dname, nn);
if (crp)
crp->cr_clp = clp;
}
vfs_fsync(nn->rec_file, 0);
} else {
printk(KERN_ERR "NFSD: failed to write recovery record"
" (err %d); please check that %s exists"
" and is writeable", status,
user_recovery_dirname);
}
mnt_drop_write_file(nn->rec_file);
out_creds:
nfs4_reset_creds(original_cred);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
neil brown | neil brown | 109 | 36.95% | 1 | 5.26% |
jeff layton | jeff layton | 67 | 22.71% | 5 | 26.32% |
david howells | david howells | 28 | 9.49% | 2 | 10.53% |
stanislav kinsbursky | stanislav kinsbursky | 28 | 9.49% | 3 | 15.79% |
christoph hellwig | christoph hellwig | 18 | 6.10% | 1 | 5.26% |
jan kara | jan kara | 16 | 5.42% | 1 | 5.26% |
boaz harrosh | boaz harrosh | 12 | 4.07% | 1 | 5.26% |
j. bruce fields | j. bruce fields | 10 | 3.39% | 3 | 15.79% |
kinglong mee | kinglong mee | 5 | 1.69% | 1 | 5.26% |
al viro | al viro | 2 | 0.68% | 1 | 5.26% |
| Total | 295 | 100.00% | 19 | 100.00% |
typedef int (recdir_func)(struct dentry *, struct dentry *, struct nfsd_net *);
struct name_list {
char name[HEXDIR_LEN];
struct list_head list;
};
struct nfs4_dir_ctx {
struct dir_context ctx;
struct list_head names;
};
static int
nfsd4_build_namelist(struct dir_context *__ctx, const char *name, int namlen,
loff_t offset, u64 ino, unsigned int d_type)
{
struct nfs4_dir_ctx *ctx =
container_of(__ctx, struct nfs4_dir_ctx, ctx);
struct name_list *entry;
if (namlen != HEXDIR_LEN - 1)
return 0;
entry = kmalloc(sizeof(struct name_list), GFP_KERNEL);
if (entry == NULL)
return -ENOMEM;
memcpy(entry->name, name, HEXDIR_LEN - 1);
entry->name[HEXDIR_LEN - 1] = '\0';
list_add(&entry->list, &ctx->names);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
neil brown | neil brown | 70 | 56.91% | 1 | 16.67% |
j. bruce fields | j. bruce fields | 34 | 27.64% | 1 | 16.67% |
miklos szeredi | miklos szeredi | 12 | 9.76% | 1 | 16.67% |
al viro | al viro | 6 | 4.88% | 2 | 33.33% |
david howells | david howells | 1 | 0.81% | 1 | 16.67% |
| Total | 123 | 100.00% | 6 | 100.00% |
static int
nfsd4_list_rec_dir(recdir_func *f, struct nfsd_net *nn)
{
const struct cred *original_cred;
struct dentry *dir = nn->rec_file->f_path.dentry;
struct nfs4_dir_ctx ctx = {
.ctx.actor = nfsd4_build_namelist,
.names = LIST_HEAD_INIT(ctx.names)
};
struct name_list *entry, *tmp;
int status;
status = nfs4_save_creds(&original_cred);
if (status < 0)
return status;
status = vfs_llseek(nn->rec_file, 0, SEEK_SET);
if (status < 0) {
nfs4_reset_creds(original_cred);
return status;
}
status = iterate_dir(nn->rec_file, &ctx.ctx);
inode_lock_nested(d_inode(dir), I_MUTEX_PARENT);
list_for_each_entry_safe(entry, tmp, &ctx.names, list) {
if (!status) {
struct dentry *dentry;
dentry = lookup_one_len(entry->name, dir, HEXDIR_LEN-1);
if (IS_ERR(dentry)) {
status = PTR_ERR(dentry);
break;
}
status = f(dir, dentry, nn);
dput(dentry);
}
list_del(&entry->list);
kfree(entry);
}
inode_unlock(d_inode(dir));
nfs4_reset_creds(original_cred);
list_for_each_entry_safe(entry, tmp, &ctx.names, list) {
dprintk("NFSD: %s. Left entry %s\n", __func__, entry->name);
list_del(&entry->list);
kfree(entry);
}
return status;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
neil brown | neil brown | 67 | 24.54% | 1 | 6.25% |
al viro | al viro | 64 | 23.44% | 5 | 31.25% |
kinglong mee | kinglong mee | 51 | 18.68% | 1 | 6.25% |
j. bruce fields | j. bruce fields | 40 | 14.65% | 2 | 12.50% |
david howells | david howells | 28 | 10.26% | 3 | 18.75% |
stanislav kinsbursky | stanislav kinsbursky | 13 | 4.76% | 2 | 12.50% |
david woodhouse | david woodhouse | 9 | 3.30% | 1 | 6.25% |
christoph hellwig | christoph hellwig | 1 | 0.37% | 1 | 6.25% |
| Total | 273 | 100.00% | 16 | 100.00% |
static int
nfsd4_unlink_clid_dir(char *name, int namlen, struct nfsd_net *nn)
{
struct dentry *dir, *dentry;
int status;
dprintk("NFSD: nfsd4_unlink_clid_dir. name %.*s\n", namlen, name);
dir = nn->rec_file->f_path.dentry;
inode_lock_nested(d_inode(dir), I_MUTEX_PARENT);
dentry = lookup_one_len(name, dir, namlen);
if (IS_ERR(dentry)) {
status = PTR_ERR(dentry);
goto out_unlock;
}
status = -ENOENT;
if (d_really_is_negative(dentry))
goto out;
status = vfs_rmdir(d_inode(dir), dentry);
out:
dput(dentry);
out_unlock:
inode_unlock(d_inode(dir));
return status;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
neil brown | neil brown | 89 | 65.93% | 3 | 33.33% |
david howells | david howells | 12 | 8.89% | 1 | 11.11% |
christoph hellwig | christoph hellwig | 12 | 8.89% | 1 | 11.11% |
david woodhouse | david woodhouse | 11 | 8.15% | 1 | 11.11% |
stanislav kinsbursky | stanislav kinsbursky | 7 | 5.19% | 1 | 11.11% |
j. bruce fields | j. bruce fields | 2 | 1.48% | 1 | 11.11% |
al viro | al viro | 2 | 1.48% | 1 | 11.11% |
| Total | 135 | 100.00% | 9 | 100.00% |
static void
nfsd4_remove_clid_dir(struct nfs4_client *clp)
{
const struct cred *original_cred;
struct nfs4_client_reclaim *crp;
char dname[HEXDIR_LEN];
int status;
struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
if (!nn->rec_file || !test_bit(NFSD4_CLIENT_STABLE, &clp->cl_flags))
return;
status = nfs4_make_rec_clidname(dname, &clp->cl_name);
if (status)
return legacy_recdir_name_error(clp, status);
status = mnt_want_write_file(nn->rec_file);
if (status)
goto out;
clear_bit(NFSD4_CLIENT_STABLE, &clp->cl_flags);
status = nfs4_save_creds(&original_cred);
if (status < 0)
goto out_drop_write;
status = nfsd4_unlink_clid_dir(dname, HEXDIR_LEN-1, nn);
nfs4_reset_creds(original_cred);
if (status == 0) {
vfs_fsync(nn->rec_file, 0);
if (nn->in_grace) {
/* remove reclaim record */
crp = nfsd4_find_reclaim_client(dname, nn);
if (crp)
nfs4_remove_reclaim_record(crp, nn);
}
}
out_drop_write:
mnt_drop_write_file(nn->rec_file);
out:
if (status)
printk("NFSD: Failed to remove expired client state directory"
" %.*s\n", HEXDIR_LEN, dname);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jeff layton | jeff layton | 80 | 36.36% | 6 | 35.29% |
neil brown | neil brown | 63 | 28.64% | 3 | 17.65% |
stanislav kinsbursky | stanislav kinsbursky | 30 | 13.64% | 3 | 17.65% |
david howells | david howells | 19 | 8.64% | 1 | 5.88% |
dave hansen | dave hansen | 17 | 7.73% | 1 | 5.88% |
christoph hellwig | christoph hellwig | 9 | 4.09% | 1 | 5.88% |
al viro | al viro | 2 | 0.91% | 2 | 11.76% |
| Total | 220 | 100.00% | 17 | 100.00% |
static int
purge_old(struct dentry *parent, struct dentry *child, struct nfsd_net *nn)
{
int status;
if (nfs4_has_reclaimed_state(child->d_name.name, nn))
return 0;
status = vfs_rmdir(d_inode(parent), child);
if (status)
printk("failed to remove client recovery directory %pd\n",
child);
/* Keep trying, success or failure: */
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
neil brown | neil brown | 52 | 77.61% | 2 | 28.57% |
stanislav kinsbursky | stanislav kinsbursky | 7 | 10.45% | 1 | 14.29% |
al viro | al viro | 3 | 4.48% | 2 | 28.57% |
david howells | david howells | 3 | 4.48% | 1 | 14.29% |
david woodhouse | david woodhouse | 2 | 2.99% | 1 | 14.29% |
| Total | 67 | 100.00% | 7 | 100.00% |
static void
nfsd4_recdir_purge_old(struct nfsd_net *nn)
{
int status;
nn->in_grace = false;
if (!nn->rec_file)
return;
status = mnt_want_write_file(nn->rec_file);
if (status)
goto out;
status = nfsd4_list_rec_dir(purge_old, nn);
if (status == 0)
vfs_fsync(nn->rec_file, 0);
mnt_drop_write_file(nn->rec_file);
out:
nfs4_release_reclaim(nn);
if (status)
printk("nfsd4: failed to purge old clients from recovery"
" directory %pD\n", nn->rec_file);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
neil brown | neil brown | 38 | 39.58% | 2 | 14.29% |
stanislav kinsbursky | stanislav kinsbursky | 19 | 19.79% | 4 | 28.57% |
dave hansen | dave hansen | 17 | 17.71% | 1 | 7.14% |
christoph hellwig | christoph hellwig | 10 | 10.42% | 1 | 7.14% |
jeff layton | jeff layton | 9 | 9.38% | 3 | 21.43% |
al viro | al viro | 3 | 3.12% | 3 | 21.43% |
| Total | 96 | 100.00% | 14 | 100.00% |
static int
load_recdir(struct dentry *parent, struct dentry *child, struct nfsd_net *nn)
{
if (child->d_name.len != HEXDIR_LEN - 1) {
printk("nfsd4: illegal name %pd in recovery directory\n",
child);
/* Keep trying; maybe the others are OK: */
return 0;
}
nfs4_client_to_reclaim(child->d_name.name, nn);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
neil brown | neil brown | 50 | 83.33% | 1 | 25.00% |
stanislav kinsbursky | stanislav kinsbursky | 7 | 11.67% | 1 | 25.00% |
al viro | al viro | 3 | 5.00% | 2 | 50.00% |
| Total | 60 | 100.00% | 4 | 100.00% |
static int
nfsd4_recdir_load(struct net *net) {
int status;
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
if (!nn->rec_file)
return 0;
status = nfsd4_list_rec_dir(load_recdir, nn);
if (status)
printk("nfsd4: failed loading clients from recovery"
" directory %pD\n", nn->rec_file);
return status;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
neil brown | neil brown | 29 | 46.77% | 1 | 16.67% |
stanislav kinsbursky | stanislav kinsbursky | 22 | 35.48% | 2 | 33.33% |
christoph hellwig | christoph hellwig | 9 | 14.52% | 1 | 16.67% |
jeff layton | jeff layton | 1 | 1.61% | 1 | 16.67% |
al viro | al viro | 1 | 1.61% | 1 | 16.67% |
| Total | 62 | 100.00% | 6 | 100.00% |
/*
* Hold reference to the recovery directory.
*/
static int
nfsd4_init_recdir(struct net *net)
{
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
const struct cred *original_cred;
int status;
printk("NFSD: Using %s as the NFSv4 state recovery directory\n",
user_recovery_dirname);
BUG_ON(nn->rec_file);
status = nfs4_save_creds(&original_cred);
if (status < 0) {
printk("NFSD: Unable to change credentials to find recovery"
" directory: error %d\n",
status);
return status;
}
nn->rec_file = filp_open(user_recovery_dirname, O_RDONLY | O_DIRECTORY, 0);
if (IS_ERR(nn->rec_file)) {
printk("NFSD: unable to find recovery directory %s\n",
user_recovery_dirname);
status = PTR_ERR(nn->rec_file);
nn->rec_file = NULL;
}
nfs4_reset_creds(original_cred);
if (!status)
nn->in_grace = true;
return status;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
neil brown | neil brown | 40 | 28.57% | 1 | 11.11% |
stanislav kinsbursky | stanislav kinsbursky | 28 | 20.00% | 2 | 22.22% |
jeff layton | jeff layton | 27 | 19.29% | 2 | 22.22% |
david howells | david howells | 26 | 18.57% | 1 | 11.11% |
christoph hellwig | christoph hellwig | 14 | 10.00% | 1 | 11.11% |
j. bruce fields | j. bruce fields | 5 | 3.57% | 2 | 22.22% |
| Total | 140 | 100.00% | 9 | 100.00% |
static void
nfsd4_shutdown_recdir(struct net *net)
{
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
if (!nn->rec_file)
return;
fput(nn->rec_file);
nn->rec_file = NULL;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
kinglong mee | kinglong mee | 43 | 97.73% | 1 | 50.00% |
jeff layton | jeff layton | 1 | 2.27% | 1 | 50.00% |
| Total | 44 | 100.00% | 2 | 100.00% |
static int
nfs4_legacy_state_init(struct net *net)
{
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
int i;
nn->reclaim_str_hashtbl = kmalloc(sizeof(struct list_head) *
CLIENT_HASH_SIZE, GFP_KERNEL);
if (!nn->reclaim_str_hashtbl)
return -ENOMEM;
for (i = 0; i < CLIENT_HASH_SIZE; i++)
INIT_LIST_HEAD(&nn->reclaim_str_hashtbl[i]);
nn->reclaim_str_hashtbl_size = 0;
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
stanislav kinsbursky | stanislav kinsbursky | 85 | 97.70% | 1 | 33.33% |
kinglong mee | kinglong mee | 1 | 1.15% | 1 | 33.33% |
jeff layton | jeff layton | 1 | 1.15% | 1 | 33.33% |
| Total | 87 | 100.00% | 3 | 100.00% |
static void
nfs4_legacy_state_shutdown(struct net *net)
{
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
kfree(nn->reclaim_str_hashtbl);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
stanislav kinsbursky | stanislav kinsbursky | 30 | 100.00% | 1 | 100.00% |
| Total | 30 | 100.00% | 1 | 100.00% |
static int
nfsd4_load_reboot_recovery_data(struct net *net)
{
int status;
status = nfsd4_init_recdir(net);
if (status)
return status;
status = nfsd4_recdir_load(net);
if (status)
nfsd4_shutdown_recdir(net);
return status;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
stanislav kinsbursky | stanislav kinsbursky | 31 | 65.96% | 2 | 50.00% |
jeff layton | jeff layton | 11 | 23.40% | 1 | 25.00% |
kinglong mee | kinglong mee | 5 | 10.64% | 1 | 25.00% |
| Total | 47 | 100.00% | 4 | 100.00% |
static int
nfsd4_legacy_tracking_init(struct net *net)
{
int status;
/* XXX: The legacy code won't work in a container */
if (net != &init_net) {
pr_warn("NFSD: attempt to initialize legacy client tracking in a container ignored.\n");
return -EINVAL;
}
status = nfs4_legacy_state_init(net);
if (status)
return status;
status = nfsd4_load_reboot_recovery_data(net);
if (status)
goto err;
return 0;
err:
nfs4_legacy_state_shutdown(net);
return status;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jeff layton | jeff layton | 37 | 50.00% | 2 | 40.00% |
stanislav kinsbursky | stanislav kinsbursky | 34 | 45.95% | 1 | 20.00% |
paul gortmaker | paul gortmaker | 2 | 2.70% | 1 | 20.00% |
neil brown | neil brown | 1 | 1.35% | 1 | 20.00% |
| Total | 74 | 100.00% | 5 | 100.00% |
static void
nfsd4_legacy_tracking_exit(struct net *net)
{
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
nfs4_release_reclaim(nn);
nfsd4_shutdown_recdir(net);
nfs4_legacy_state_shutdown(net);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
stanislav kinsbursky | stanislav kinsbursky | 22 | 57.89% | 2 | 40.00% |
jeff layton | jeff layton | 14 | 36.84% | 1 | 20.00% |
neil brown | neil brown | 1 | 2.63% | 1 | 20.00% |
kinglong mee | kinglong mee | 1 | 2.63% | 1 | 20.00% |
| Total | 38 | 100.00% | 5 | 100.00% |
/*
* Change the NFSv4 recovery directory to recdir.
*/
int
nfs4_reset_recoverydir(char *recdir)
{
int status;
struct path path;
status = kern_path(recdir, LOOKUP_FOLLOW, &path);
if (status)
return status;
status = -ENOTDIR;
if (d_is_dir(path.dentry)) {
strcpy(user_recovery_dirname, recdir);
status = 0;
}
path_put(&path);
return status;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
j. bruce fields | j. bruce fields | 70 | 98.59% | 1 | 50.00% |
david howells | david howells | 1 | 1.41% | 1 | 50.00% |
| Total | 71 | 100.00% | 2 | 100.00% |
char *
nfs4_recoverydir(void)
{
return user_recovery_dirname;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
j. bruce fields | j. bruce fields | 11 | 100.00% | 1 | 100.00% |
| Total | 11 | 100.00% | 1 | 100.00% |
static int
nfsd4_check_legacy_client(struct nfs4_client *clp)
{
int status;
char dname[HEXDIR_LEN];
struct nfs4_client_reclaim *crp;
struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
/* did we already find that this client is stable? */
if (test_bit(NFSD4_CLIENT_STABLE, &clp->cl_flags))
return 0;
status = nfs4_make_rec_clidname(dname, &clp->cl_name);
if (status) {
legacy_recdir_name_error(clp, status);
return status;
}
/* look for it in the reclaim hashtable otherwise */
crp = nfsd4_find_reclaim_client(dname, nn);
if (crp) {
set_bit(NFSD4_CLIENT_STABLE, &clp->cl_flags);
crp->cr_clp = clp;
return 0;
}
return -ENOENT;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jeff layton | jeff layton | 106 | 86.89% | 4 | 80.00% |
stanislav kinsbursky | stanislav kinsbursky | 16 | 13.11% | 1 | 20.00% |
| Total | 122 | 100.00% | 5 | 100.00% |
static const struct nfsd4_client_tracking_ops nfsd4_legacy_tracking_ops = {
.init = nfsd4_legacy_tracking_init,
.exit = nfsd4_legacy_tracking_exit,
.create = nfsd4_create_clid_dir,
.remove = nfsd4_remove_clid_dir,
.check = nfsd4_check_legacy_client,
.grace_done = nfsd4_recdir_purge_old,
};
/* Globals */
#define NFSD_PIPE_DIR "nfsd"
#define NFSD_CLD_PIPE "cld"
/* per-net-ns structure for holding cld upcall info */
struct cld_net {
struct rpc_pipe *cn_pipe;
spinlock_t cn_lock;
struct list_head cn_list;
unsigned int cn_xid;
};
struct cld_upcall {
struct list_head cu_list;
struct cld_net *cu_net;
struct task_struct *cu_task;
struct cld_msg cu_msg;
};
static int
__cld_pipe_upcall(struct rpc_pipe *pipe, struct cld_msg *cmsg)
{
int ret;
struct rpc_pipe_msg msg;
memset(&msg, 0, sizeof(msg));
msg.data = cmsg;
msg.len = sizeof(*cmsg);
/*
* Set task state before we queue the upcall. That prevents
* wake_up_process in the downcall from racing with schedule.
*/
set_current_state(TASK_UNINTERRUPTIBLE);
ret = rpc_queue_upcall(pipe, &msg);
if (ret < 0) {
set_current_state(TASK_RUNNING);
goto out;
}
schedule();
if (msg.errno < 0)
ret = msg.errno;
out:
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jeff layton | jeff layton | 106 | 100.00% | 2 | 100.00% |
| Total | 106 | 100.00% | 2 | 100.00% |
static int
cld_pipe_upcall(struct rpc_pipe *pipe, struct cld_msg *cmsg)
{
int ret;
/*
* -EAGAIN occurs when pipe is closed and reopened while there are
* upcalls queued.
*/
do {
ret = __cld_pipe_upcall(pipe, cmsg);
} while (ret == -EAGAIN);
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
jeff layton | jeff layton | 43 | 100.00% | 1 | 100.00% |
| Total | 43 | 100.00% | 1 | 100.00% |
static ssize_t
cld_pipe_downcall(struct file *filp, const char __user *src,