Commit bf97293e authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'nfs-for-3.12-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs

Pull NFS client updates from Trond Myklebust:
 "Highlights include:

   - Fix NFSv4 recovery so that it doesn't recover lost locks in cases
     such as lease loss due to a network partition, where doing so may
     result in data corruption.  Add a kernel parameter to control
     choice of legacy behaviour or not.
   - Performance improvements when 2 processes are writing to the same
     file.
   - Flush data to disk when an RPCSEC_GSS session timeout is imminent.
   - Implement NFSv4.1 SP4_MACH_CRED state protection to prevent other
     NFS clients from being able to manipulate our lease and file
     locking state.
   - Allow sharing of RPCSEC_GSS caches between different rpc clients.
   - Fix the broken NFSv4 security auto-negotiation between client and
     server.
   - Fix rmdir() to wait for outstanding sillyrename unlinks to complete
   - Add a tracepoint framework for debugging NFSv4 state recovery
     issues.
   - Add tracing to the generic NFS layer.
   - Add tracing for the SUNRPC socket connection state.
   - Clean up the rpc_pipefs mount/umount event management.
   - Merge more patches from Chuck in preparation for NFSv4 migration
     support"

* tag 'nfs-for-3.12-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: (107 commits)
  NFSv4: use mach cred for SECINFO_NO_NAME w/ integrity
  NFS: nfs_compare_super shouldn't check the auth flavour unless 'sec=' was set
  NFSv4: Allow security autonegotiation for submounts
  NFSv4: Disallow security negotiation for lookups when 'sec=' is specified
  NFSv4: Fix security auto-negotiation
  NFS: Clean up nfs_parse_security_flavors()
  NFS: Clean up the auth flavour array mess
  NFSv4.1 Use MDS auth flavor for data server connection
  NFS: Don't check lock owner compatability unless file is locked (part 2)
  NFS: Don't check lock owner compatibility in writes unless file is locked
  nfs4: Map NFS4ERR_WRONG_CRED to EPERM
  nfs4.1: Add SP4_MACH_CRED write and commit support
  nfs4.1: Add SP4_MACH_CRED stateid support
  nfs4.1: Add SP4_MACH_CRED secinfo support
  nfs4.1: Add SP4_MACH_CRED cleanup support
  nfs4.1: Add state protection handler
  nfs4.1: Minimal SP4_MACH_CRED implementation
  SUNRPC: Replace pointer values with task->tk_pid and rpc_clnt->cl_clid
  SUNRPC: Add an identifier for struct rpc_clnt
  SUNRPC: Ensure rpc_task->tk_pid is available for tracepoints
  ...
parents 16d70e15 b1b3e136
...@@ -1899,6 +1899,18 @@ bytes respectively. Such letter suffixes can also be entirely omitted. ...@@ -1899,6 +1899,18 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
The default is to send the implementation identification The default is to send the implementation identification
information. information.
nfs.recover_lost_locks =
[NFSv4] Attempt to recover locks that were lost due
to a lease timeout on the server. Please note that
doing this risks data corruption, since there are
no guarantees that the file will remain unchanged
after the locks are lost.
If you want to enable the kernel legacy behaviour of
attempting to recover these locks, then set this
parameter to '1'.
The default parameter value of '0' causes the kernel
not to attempt recovery of lost locks.
nfsd.nfs4_disable_idmapping= nfsd.nfs4_disable_idmapping=
[NFSv4] When set to the default of '1', the NFSv4 [NFSv4] When set to the default of '1', the NFSv4
server will return only numeric uids and gids to server will return only numeric uids and gids to
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
obj-$(CONFIG_NFS_FS) += nfs.o obj-$(CONFIG_NFS_FS) += nfs.o
CFLAGS_nfstrace.o += -I$(src)
nfs-y := client.o dir.o file.o getroot.o inode.o super.o \ nfs-y := client.o dir.o file.o getroot.o inode.o super.o \
direct.o pagelist.o read.o symlink.o unlink.o \ direct.o pagelist.o read.o symlink.o unlink.o \
write.o namespace.o mount_clnt.o write.o namespace.o mount_clnt.o nfstrace.o
nfs-$(CONFIG_ROOT_NFS) += nfsroot.o nfs-$(CONFIG_ROOT_NFS) += nfsroot.o
nfs-$(CONFIG_SYSCTL) += sysctl.o nfs-$(CONFIG_SYSCTL) += sysctl.o
nfs-$(CONFIG_NFS_FSCACHE) += fscache.o fscache-index.o nfs-$(CONFIG_NFS_FSCACHE) += fscache.o fscache-index.o
...@@ -19,12 +20,14 @@ nfsv3-y := nfs3super.o nfs3client.o nfs3proc.o nfs3xdr.o ...@@ -19,12 +20,14 @@ nfsv3-y := nfs3super.o nfs3client.o nfs3proc.o nfs3xdr.o
nfsv3-$(CONFIG_NFS_V3_ACL) += nfs3acl.o nfsv3-$(CONFIG_NFS_V3_ACL) += nfs3acl.o
obj-$(CONFIG_NFS_V4) += nfsv4.o obj-$(CONFIG_NFS_V4) += nfsv4.o
CFLAGS_nfs4trace.o += -I$(src)
nfsv4-y := nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o nfs4super.o nfs4file.o \ nfsv4-y := nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o nfs4super.o nfs4file.o \
delegation.o idmap.o callback.o callback_xdr.o callback_proc.o \ delegation.o idmap.o callback.o callback_xdr.o callback_proc.o \
nfs4namespace.o nfs4getroot.o nfs4client.o dns_resolve.o nfs4namespace.o nfs4getroot.o nfs4client.o nfs4session.o \
dns_resolve.o nfs4trace.o
nfsv4-$(CONFIG_NFS_USE_LEGACY_DNS) += cache_lib.o nfsv4-$(CONFIG_NFS_USE_LEGACY_DNS) += cache_lib.o
nfsv4-$(CONFIG_SYSCTL) += nfs4sysctl.o nfsv4-$(CONFIG_SYSCTL) += nfs4sysctl.o
nfsv4-$(CONFIG_NFS_V4_1) += nfs4session.o pnfs.o pnfs_dev.o nfsv4-$(CONFIG_NFS_V4_1) += pnfs.o pnfs_dev.o
obj-$(CONFIG_PNFS_FILE_LAYOUT) += nfs_layout_nfsv41_files.o obj-$(CONFIG_PNFS_FILE_LAYOUT) += nfs_layout_nfsv41_files.o
nfs_layout_nfsv41_files-y := nfs4filelayout.o nfs4filelayoutdev.o nfs_layout_nfsv41_files-y := nfs4filelayout.o nfs4filelayoutdev.o
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "internal.h" #include "internal.h"
#include "pnfs.h" #include "pnfs.h"
#include "nfs4session.h" #include "nfs4session.h"
#include "nfs4trace.h"
#ifdef NFS_DEBUG #ifdef NFS_DEBUG
#define NFSDBG_FACILITY NFSDBG_CALLBACK #define NFSDBG_FACILITY NFSDBG_CALLBACK
...@@ -93,6 +94,7 @@ __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy, ...@@ -93,6 +94,7 @@ __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy,
default: default:
res = htonl(NFS4ERR_RESOURCE); res = htonl(NFS4ERR_RESOURCE);
} }
trace_nfs4_recall_delegation(inode, -ntohl(res));
iput(inode); iput(inode);
out: out:
dprintk("%s: exit with status = %d\n", __func__, ntohl(res)); dprintk("%s: exit with status = %d\n", __func__, ntohl(res));
...@@ -301,14 +303,14 @@ validate_seqid(struct nfs4_slot_table *tbl, struct cb_sequenceargs * args) ...@@ -301,14 +303,14 @@ validate_seqid(struct nfs4_slot_table *tbl, struct cb_sequenceargs * args)
{ {
struct nfs4_slot *slot; struct nfs4_slot *slot;
dprintk("%s enter. slotid %d seqid %d\n", dprintk("%s enter. slotid %u seqid %u\n",
__func__, args->csa_slotid, args->csa_sequenceid); __func__, args->csa_slotid, args->csa_sequenceid);
if (args->csa_slotid >= NFS41_BC_MAX_CALLBACKS) if (args->csa_slotid >= NFS41_BC_MAX_CALLBACKS)
return htonl(NFS4ERR_BADSLOT); return htonl(NFS4ERR_BADSLOT);
slot = tbl->slots + args->csa_slotid; slot = tbl->slots + args->csa_slotid;
dprintk("%s slot table seqid: %d\n", __func__, slot->seq_nr); dprintk("%s slot table seqid: %u\n", __func__, slot->seq_nr);
/* Normal */ /* Normal */
if (likely(args->csa_sequenceid == slot->seq_nr + 1)) { if (likely(args->csa_sequenceid == slot->seq_nr + 1)) {
...@@ -318,7 +320,7 @@ validate_seqid(struct nfs4_slot_table *tbl, struct cb_sequenceargs * args) ...@@ -318,7 +320,7 @@ validate_seqid(struct nfs4_slot_table *tbl, struct cb_sequenceargs * args)
/* Replay */ /* Replay */
if (args->csa_sequenceid == slot->seq_nr) { if (args->csa_sequenceid == slot->seq_nr) {
dprintk("%s seqid %d is a replay\n", dprintk("%s seqid %u is a replay\n",
__func__, args->csa_sequenceid); __func__, args->csa_sequenceid);
/* Signal process_op to set this error on next op */ /* Signal process_op to set this error on next op */
if (args->csa_cachethis == 0) if (args->csa_cachethis == 0)
...@@ -462,6 +464,7 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args, ...@@ -462,6 +464,7 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
} else } else
res->csr_status = status; res->csr_status = status;
trace_nfs4_cb_sequence(args, res, status);
dprintk("%s: exit with status = %d res->csr_status %d\n", __func__, dprintk("%s: exit with status = %d res->csr_status %d\n", __func__,
ntohl(status), ntohl(res->csr_status)); ntohl(status), ntohl(res->csr_status));
return status; return status;
...@@ -518,7 +521,7 @@ __be32 nfs4_callback_recallslot(struct cb_recallslotargs *args, void *dummy, ...@@ -518,7 +521,7 @@ __be32 nfs4_callback_recallslot(struct cb_recallslotargs *args, void *dummy,
if (!cps->clp) /* set in cb_sequence */ if (!cps->clp) /* set in cb_sequence */
goto out; goto out;
dprintk_rcu("NFS: CB_RECALL_SLOT request from %s target highest slotid %d\n", dprintk_rcu("NFS: CB_RECALL_SLOT request from %s target highest slotid %u\n",
rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR), rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR),
args->crsa_target_highest_slotid); args->crsa_target_highest_slotid);
......
...@@ -501,8 +501,7 @@ nfs_get_client(const struct nfs_client_initdata *cl_init, ...@@ -501,8 +501,7 @@ nfs_get_client(const struct nfs_client_initdata *cl_init,
&nn->nfs_client_list); &nn->nfs_client_list);
spin_unlock(&nn->nfs_client_lock); spin_unlock(&nn->nfs_client_lock);
new->cl_flags = cl_init->init_flags; new->cl_flags = cl_init->init_flags;
return rpc_ops->init_client(new, timeparms, ip_addr, return rpc_ops->init_client(new, timeparms, ip_addr);
authflavour);
} }
spin_unlock(&nn->nfs_client_lock); spin_unlock(&nn->nfs_client_lock);
...@@ -694,13 +693,12 @@ EXPORT_SYMBOL_GPL(nfs_init_server_rpcclient); ...@@ -694,13 +693,12 @@ EXPORT_SYMBOL_GPL(nfs_init_server_rpcclient);
* @clp: nfs_client to initialise * @clp: nfs_client to initialise
* @timeparms: timeout parameters for underlying RPC transport * @timeparms: timeout parameters for underlying RPC transport
* @ip_addr: IP presentation address (not used) * @ip_addr: IP presentation address (not used)
* @authflavor: authentication flavor for underlying RPC transport
* *
* Returns pointer to an NFS client, or an ERR_PTR value. * Returns pointer to an NFS client, or an ERR_PTR value.
*/ */
struct nfs_client *nfs_init_client(struct nfs_client *clp, struct nfs_client *nfs_init_client(struct nfs_client *clp,
const struct rpc_timeout *timeparms, const struct rpc_timeout *timeparms,
const char *ip_addr, rpc_authflavor_t authflavour) const char *ip_addr)
{ {
int error; int error;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "nfs4_fs.h" #include "nfs4_fs.h"
#include "delegation.h" #include "delegation.h"
#include "internal.h" #include "internal.h"
#include "nfs4trace.h"
static void nfs_free_delegation(struct nfs_delegation *delegation) static void nfs_free_delegation(struct nfs_delegation *delegation)
{ {
...@@ -160,6 +161,7 @@ void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, ...@@ -160,6 +161,7 @@ void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred,
spin_unlock(&delegation->lock); spin_unlock(&delegation->lock);
put_rpccred(oldcred); put_rpccred(oldcred);
rcu_read_unlock(); rcu_read_unlock();
trace_nfs4_reclaim_delegation(inode, res->delegation_type);
} else { } else {
/* We appear to have raced with a delegation return. */ /* We appear to have raced with a delegation return. */
spin_unlock(&delegation->lock); spin_unlock(&delegation->lock);
...@@ -344,6 +346,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct ...@@ -344,6 +346,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
nfsi->cache_validity |= NFS_INO_REVAL_FORCED; nfsi->cache_validity |= NFS_INO_REVAL_FORCED;
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
trace_nfs4_set_delegation(inode, res->delegation_type);
out: out:
spin_unlock(&clp->cl_lock); spin_unlock(&clp->cl_lock);
......
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
#include "internal.h" #include "internal.h"
#include "fscache.h" #include "fscache.h"
#include "nfstrace.h"
/* #define NFS_DEBUG_VERBOSE 1 */ /* #define NFS_DEBUG_VERBOSE 1 */
static int nfs_opendir(struct inode *, struct file *); static int nfs_opendir(struct inode *, struct file *);
...@@ -1100,7 +1102,9 @@ static int nfs_lookup_revalidate(struct dentry *dentry, unsigned int flags) ...@@ -1100,7 +1102,9 @@ static int nfs_lookup_revalidate(struct dentry *dentry, unsigned int flags)
if (IS_ERR(label)) if (IS_ERR(label))
goto out_error; goto out_error;
trace_nfs_lookup_revalidate_enter(dir, dentry, flags);
error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, label); error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, label);
trace_nfs_lookup_revalidate_exit(dir, dentry, flags, error);
if (error) if (error)
goto out_bad; goto out_bad;
if (nfs_compare_fh(NFS_FH(inode), fhandle)) if (nfs_compare_fh(NFS_FH(inode), fhandle))
...@@ -1312,6 +1316,7 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in ...@@ -1312,6 +1316,7 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in
parent = dentry->d_parent; parent = dentry->d_parent;
/* Protect against concurrent sillydeletes */ /* Protect against concurrent sillydeletes */
trace_nfs_lookup_enter(dir, dentry, flags);
nfs_block_sillyrename(parent); nfs_block_sillyrename(parent);
error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, label); error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, label);
if (error == -ENOENT) if (error == -ENOENT)
...@@ -1338,6 +1343,7 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in ...@@ -1338,6 +1343,7 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in
nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
out_unblock_sillyrename: out_unblock_sillyrename:
nfs_unblock_sillyrename(parent); nfs_unblock_sillyrename(parent);
trace_nfs_lookup_exit(dir, dentry, flags, error);
nfs4_label_free(label); nfs4_label_free(label);
out: out:
nfs_free_fattr(fattr); nfs_free_fattr(fattr);
...@@ -1392,7 +1398,6 @@ static int nfs_finish_open(struct nfs_open_context *ctx, ...@@ -1392,7 +1398,6 @@ static int nfs_finish_open(struct nfs_open_context *ctx,
nfs_file_set_open_context(file, ctx); nfs_file_set_open_context(file, ctx);
out: out:
put_nfs_open_context(ctx);
return err; return err;
} }
...@@ -1404,6 +1409,7 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry, ...@@ -1404,6 +1409,7 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
struct dentry *res; struct dentry *res;
struct iattr attr = { .ia_valid = ATTR_OPEN }; struct iattr attr = { .ia_valid = ATTR_OPEN };
struct inode *inode; struct inode *inode;
unsigned int lookup_flags = 0;
int err; int err;
/* Expect a negative dentry */ /* Expect a negative dentry */
...@@ -1412,6 +1418,10 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry, ...@@ -1412,6 +1418,10 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
dfprintk(VFS, "NFS: atomic_open(%s/%ld), %s\n", dfprintk(VFS, "NFS: atomic_open(%s/%ld), %s\n",
dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
err = nfs_check_flags(open_flags);
if (err)
return err;
/* NFS only supports OPEN on regular files */ /* NFS only supports OPEN on regular files */
if ((open_flags & O_DIRECTORY)) { if ((open_flags & O_DIRECTORY)) {
if (!d_unhashed(dentry)) { if (!d_unhashed(dentry)) {
...@@ -1422,6 +1432,7 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry, ...@@ -1422,6 +1432,7 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
*/ */
return -ENOENT; return -ENOENT;
} }
lookup_flags = LOOKUP_OPEN|LOOKUP_DIRECTORY;
goto no_open; goto no_open;
} }
...@@ -1442,12 +1453,14 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry, ...@@ -1442,12 +1453,14 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
if (IS_ERR(ctx)) if (IS_ERR(ctx))
goto out; goto out;
trace_nfs_atomic_open_enter(dir, ctx, open_flags);
nfs_block_sillyrename(dentry->d_parent); nfs_block_sillyrename(dentry->d_parent);
inode = NFS_PROTO(dir)->open_context(dir, ctx, open_flags, &attr); inode = NFS_PROTO(dir)->open_context(dir, ctx, open_flags, &attr);
nfs_unblock_sillyrename(dentry->d_parent); nfs_unblock_sillyrename(dentry->d_parent);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
put_nfs_open_context(ctx);
err = PTR_ERR(inode); err = PTR_ERR(inode);
trace_nfs_atomic_open_exit(dir, ctx, open_flags, err);
put_nfs_open_context(ctx);
switch (err) { switch (err) {
case -ENOENT: case -ENOENT:
d_drop(dentry); d_drop(dentry);
...@@ -1468,11 +1481,13 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry, ...@@ -1468,11 +1481,13 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
} }
err = nfs_finish_open(ctx, ctx->dentry, file, open_flags, opened); err = nfs_finish_open(ctx, ctx->dentry, file, open_flags, opened);
trace_nfs_atomic_open_exit(dir, ctx, open_flags, err);
put_nfs_open_context(ctx);
out: out:
return err; return err;
no_open: no_open:
res = nfs_lookup(dir, dentry, 0); res = nfs_lookup(dir, dentry, lookup_flags);
err = PTR_ERR(res); err = PTR_ERR(res);
if (IS_ERR(res)) if (IS_ERR(res))
goto out; goto out;
...@@ -1596,7 +1611,9 @@ int nfs_create(struct inode *dir, struct dentry *dentry, ...@@ -1596,7 +1611,9 @@ int nfs_create(struct inode *dir, struct dentry *dentry,
attr.ia_mode = mode; attr.ia_mode = mode;
attr.ia_valid = ATTR_MODE; attr.ia_valid = ATTR_MODE;
trace_nfs_create_enter(dir, dentry, open_flags);
error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags); error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags);
trace_nfs_create_exit(dir, dentry, open_flags, error);
if (error != 0) if (error != 0)
goto out_err; goto out_err;
return 0; return 0;
...@@ -1624,7 +1641,9 @@ nfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) ...@@ -1624,7 +1641,9 @@ nfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev)
attr.ia_mode = mode; attr.ia_mode = mode;
attr.ia_valid = ATTR_MODE; attr.ia_valid = ATTR_MODE;
trace_nfs_mknod_enter(dir, dentry);
status = NFS_PROTO(dir)->mknod(dir, dentry, &attr, rdev); status = NFS_PROTO(dir)->mknod(dir, dentry, &attr, rdev);
trace_nfs_mknod_exit(dir, dentry, status);
if (status != 0) if (status != 0)
goto out_err; goto out_err;
return 0; return 0;
...@@ -1648,7 +1667,9 @@ int nfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) ...@@ -1648,7 +1667,9 @@ int nfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
attr.ia_valid = ATTR_MODE; attr.ia_valid = ATTR_MODE;
attr.ia_mode = mode | S_IFDIR; attr.ia_mode = mode | S_IFDIR;
trace_nfs_mkdir_enter(dir, dentry);
error = NFS_PROTO(dir)->mkdir(dir, dentry, &attr); error = NFS_PROTO(dir)->mkdir(dir, dentry, &attr);
trace_nfs_mkdir_exit(dir, dentry, error);
if (error != 0) if (error != 0)
goto out_err; goto out_err;
return 0; return 0;
...@@ -1671,12 +1692,21 @@ int nfs_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -1671,12 +1692,21 @@ int nfs_rmdir(struct inode *dir, struct dentry *dentry)
dfprintk(VFS, "NFS: rmdir(%s/%ld), %s\n", dfprintk(VFS, "NFS: rmdir(%s/%ld), %s\n",
dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
trace_nfs_rmdir_enter(dir, dentry);
if (dentry->d_inode) {
nfs_wait_on_sillyrename(dentry);
error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name); error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name);
/* Ensure the VFS deletes this inode */ /* Ensure the VFS deletes this inode */
if (error == 0 && dentry->d_inode != NULL) switch (error) {
case 0:
clear_nlink(dentry->d_inode); clear_nlink(dentry->d_inode);
else if (error == -ENOENT) break;
case -ENOENT:
nfs_dentry_handle_enoent(dentry); nfs_dentry_handle_enoent(dentry);
}
} else
error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name);
trace_nfs_rmdir_exit(dir, dentry, error);
return error; return error;
} }
...@@ -1704,6 +1734,7 @@ static int nfs_safe_remove(struct dentry *dentry) ...@@ -1704,6 +1734,7 @@ static int nfs_safe_remove(struct dentry *dentry)
goto out; goto out;
} }
trace_nfs_remove_enter(dir, dentry);
if (inode != NULL) { if (inode != NULL) {
NFS_PROTO(inode)->return_delegation(inode); NFS_PROTO(inode)->return_delegation(inode);
error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); error = NFS_PROTO(dir)->remove(dir, &dentry->d_name);
...@@ -1713,6 +1744,7 @@ static int nfs_safe_remove(struct dentry *dentry) ...@@ -1713,6 +1744,7 @@ static int nfs_safe_remove(struct dentry *dentry)
error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); error = NFS_PROTO(dir)->remove(dir, &dentry->d_name);
if (error == -ENOENT) if (error == -ENOENT)
nfs_dentry_handle_enoent(dentry); nfs_dentry_handle_enoent(dentry);
trace_nfs_remove_exit(dir, dentry, error);
out: out:
return error; return error;
} }
...@@ -1730,13 +1762,14 @@ int nfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -1730,13 +1762,14 @@ int nfs_unlink(struct inode *dir, struct dentry *dentry)
dfprintk(VFS, "NFS: unlink(%s/%ld, %s)\n", dir->i_sb->s_id, dfprintk(VFS, "NFS: unlink(%s/%ld, %s)\n", dir->i_sb->s_id,
dir->i_ino, dentry->d_name.name); dir->i_ino, dentry->d_name.name);
trace_nfs_unlink_enter(dir, dentry);
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
if (d_count(dentry) > 1) { if (d_count(dentry) > 1) {
spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_lock);
/* Start asynchronous writeout of the inode */ /* Start asynchronous writeout of the inode */
write_inode_now(dentry->d_inode, 0); write_inode_now(dentry->d_inode, 0);
error = nfs_sillyrename(dir, dentry); error = nfs_sillyrename(dir, dentry);
return error; goto out;
} }
if (!d_unhashed(dentry)) { if (!d_unhashed(dentry)) {
__d_drop(dentry); __d_drop(dentry);
...@@ -1748,6 +1781,8 @@ int nfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -1748,6 +1781,8 @@ int nfs_unlink(struct inode *dir, struct dentry *dentry)
nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
} else if (need_rehash) } else if (need_rehash)
d_rehash(dentry); d_rehash(dentry);
out:
trace_nfs_unlink_exit(dir, dentry, error);
return error; return error;
} }
EXPORT_SYMBOL_GPL(nfs_unlink); EXPORT_SYMBOL_GPL(nfs_unlink);
...@@ -1794,7 +1829,9 @@ int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) ...@@ -1794,7 +1829,9 @@ int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
memset(kaddr + pathlen, 0, PAGE_SIZE - pathlen); memset(kaddr + pathlen, 0, PAGE_SIZE - pathlen);
kunmap_atomic(kaddr); kunmap_atomic(kaddr);
trace_nfs_symlink_enter(dir, dentry);
error = NFS_PROTO(dir)->symlink(dir, dentry, page, pathlen, &attr); error = NFS_PROTO(dir)->symlink(dir, dentry, page, pathlen, &attr);
trace_nfs_symlink_exit(dir, dentry, error);
if (error != 0) { if (error != 0) {
dfprintk(VFS, "NFS: symlink(%s/%ld, %s, %s) error %d\n", dfprintk(VFS, "NFS: symlink(%s/%ld, %s, %s) error %d\n",
dir->i_sb->s_id, dir->i_ino, dir->i_sb->s_id, dir->i_ino,
...@@ -1829,6 +1866,7 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) ...@@ -1829,6 +1866,7 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
old_dentry->d_parent->d_name.name, old_dentry->d_name.name, old_dentry->d_parent->d_name.name, old_dentry->d_name.name,
dentry->d_parent->d_name.name, dentry->d_name.name); dentry->d_parent->d_name.name, dentry->d_name.name);
trace_nfs_link_enter(inode, dir, dentry);
NFS_PROTO(inode)->return_delegation(inode); NFS_PROTO(inode)->return_delegation(inode);
d_drop(dentry); d_drop(dentry);
...@@ -1837,6 +1875,7 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) ...@@ -1837,6 +1875,7 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
ihold(inode); ihold(inode);
d_add(dentry, inode); d_add(dentry, inode);
} }
trace_nfs_link_exit(inode, dir, dentry, error);
return error; return error;
} }
EXPORT_SYMBOL_GPL(nfs_link); EXPORT_SYMBOL_GPL(nfs_link);
...@@ -1878,6 +1917,7 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1878,6 +1917,7 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
new_dentry->d_parent->d_name.name, new_dentry->d_name.name, new_dentry->d_parent->d_name.name, new_dentry->d_name.name,
d_count(new_dentry)); d_count(new_dentry));
trace_nfs_rename_enter(old_dir, old_dentry, new_dir, new_dentry);
/* /*
* For non-directories, check whether the target is busy and if so, * For non-directories, check whether the target is busy and if so,
* make a copy of the dentry and then do a silly-rename. If the * make a copy of the dentry and then do a silly-rename. If the
...@@ -1924,6 +1964,8 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1924,6 +1964,8 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
out: out:
if (rehash) if (rehash)
d_rehash(rehash); d_rehash(rehash);
trace_nfs_rename_exit(old_dir, old_dentry,
new_dir, new_dentry, error);
if (!error) { if (!error) {
if (new_inode != NULL) if (new_inode != NULL)
nfs_drop_nlink(new_inode); nfs_drop_nlink(new_inode);
...@@ -2173,9 +2215,11 @@ static int nfs_do_access(struct inode *inode, struct rpc_cred *cred, int mask) ...@@ -2173,9 +2215,11 @@ static int nfs_do_access(struct inode *inode, struct rpc_cred *cred, int mask)
struct nfs_access_entry cache; struct nfs_access_entry cache;
int status; int status;
trace_nfs_access_enter(inode);
status = nfs_access_get_cached(inode, cred, &cache); status = nfs_access_get_cached(inode, cred, &cache);
if (status == 0) if (status == 0)
goto out; goto out_cached;
/* Be clever: ask server to check for all possible rights */ /* Be clever: ask server to check for all possible rights */
cache.mask = MAY_EXEC | MAY_WRITE | MAY_READ; cache.mask = MAY_EXEC | MAY_WRITE | MAY_READ;
...@@ -2188,13 +2232,15 @@ static int nfs_do_access(struct inode *inode, struct rpc_cred *cred, int mask) ...@@ -2188,13 +2232,15 @@ static int nfs_do_access(struct inode *inode, struct rpc_cred *cred, int mask)
if (!S_ISDIR(inode->i_mode)) if (!S_ISDIR(inode->i_mode))
set_bit(NFS_INO_STALE, &NFS_I(inode)->flags); set_bit(NFS_INO_STALE, &NFS_I(inode)->flags);
} }
return status; goto out;
} }
nfs_access_add_cache(inode, &cache); nfs_access_add_cache(inode, &cache);
out_cached:
if ((mask & ~cache.mask & (MAY_READ | MAY_WRITE | MAY_EXEC)) != 0)
status = -EACCES;
out: out:
if ((mask & ~cache.mask & (MAY_READ | MAY_WRITE | MAY_EXEC)) == 0) trace_nfs_access_exit(inode, status);
return 0; return status;
return -EACCES;
} }
static int nfs_open_permission_mask(int openflags) static int nfs_open_permission_mask(int openflags)
...@@ -2240,11 +2286,6 @@ int nfs_permission(struct inode *inode, int mask) ...@@ -2240,11 +2286,6 @@ int nfs_permission(struct inode *inode, int mask)
case S_IFLNK: case S_IFLNK:
goto out; goto out;
case S_IFREG: case S_IFREG:
/* NFSv4 has atomic_open... */
if (nfs_server_capable(inode, NFS_CAP_ATOMIC_OPEN)
&& (mask & MAY_OPEN)
&& !(mask & MAY_EXEC))
goto out;
break; break;
case S_IFDIR: case S_IFDIR:
/* /*
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include "iostat.h" #include "iostat.h"
#include "fscache.h" #include "fscache.h"
#include "nfstrace.h"
#define NFSDBG_FACILITY NFSDBG_FILE #define NFSDBG_FACILITY NFSDBG_FILE
static const struct vm_operations_struct nfs_file_vm_ops; static const struct vm_operations_struct nfs_file_vm_ops;
...@@ -294,6 +296,8 @@ nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync) ...@@ -294,6 +296,8 @@ nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
int ret; int ret;
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
trace_nfs_fsync_enter(inode);
do { do {
ret = filemap_write_and_wait_range(inode->i_mapping, start, end); ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
if (ret != 0) if (ret != 0)
...@@ -310,6 +314,7 @@ nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync) ...@@ -310,6 +314,7 @@ nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
end = LLONG_MAX; end = LLONG_MAX;
} while (ret == -EAGAIN); } while (ret == -EAGAIN);
trace_nfs_fsync_exit(inode, ret);
return ret; return ret;
} }
...@@ -406,6 +411,7 @@ static int nfs_write_end(struct file *file, struct address_space *mapping, ...@@ -406,6 +411,7 @@ static int nfs_write_end(struct file *file, struct address_space *mapping,
struct page *page, void *fsdata) struct page *page, void *fsdata)
{ {
unsigned offset = pos & (PAGE_CACHE_SIZE - 1); unsigned offset = pos & (PAGE_CACHE_SIZE - 1);
struct nfs_open_context *ctx = nfs_file_open_context(file);
int status; int status;
dfprintk(PAGECACHE, "NFS: write_end(%s/%s(%ld), %u@%lld)\n", dfprintk(PAGECACHE, "NFS: write_end(%s/%s(%ld), %u@%lld)\n",
...@@ -441,6 +447,13 @@ static int nfs_write_end(struct file *file, struct address_space *mapping, ...@@ -441,6 +447,13 @@ static int nfs_write_end(struct file *file, struct address_space *mapping,
if (status < 0) if (status < 0)
return status; return status;
NFS_I(mapping->host)->write_io += copied; NFS_I(mapping->host)->write_io += copied;
if (nfs_ctx_key_to_expire(ctx)) {
status = nfs_wb_all(mapping->host);
if (status < 0)
return status;
}
return copied; return copied;
} }
...@@ -637,7 +650,8 @@ static int nfs_need_sync_write(struct file *filp, struct inode *inode) ...@@ -637,7 +650,8 @@ static int nfs_need_sync_write(struct file *filp, struct inode *inode)
if (IS_SYNC(inode) || (filp->f_flags & O_DSYNC)) if (IS_SYNC(inode) || (filp->f_flags & O_DSYNC))
return 1; return 1;
ctx = nfs_file_open_context(filp); ctx = nfs_file_open_context(filp);
if (test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags)) if (test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags) ||
nfs_ctx_key_to_expire(ctx))
return 1; return 1;
return 0; return 0;
} }
...@@ -651,6 +665,10 @@ ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -651,6 +665,10 @@ ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
ssize_t result; ssize_t result;
size_t count = iov_length(iov, nr_segs); size_t count = iov_length(iov, nr_segs);
result = nfs_key_timeout_notify(iocb->ki_filp, inode);
if (result)
return result;
if (iocb->ki_filp->f_flags & O_DIRECT) if (iocb->ki_filp->f_flags & O_DIRECT)
return nfs_file_direct_write(iocb, iov, nr_segs, pos, true); return nfs_file_direct_write(iocb, iov, nr_segs, pos, true);
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#include "internal.h" #include "internal.h"
#include "netns.h" #include "netns.h"
#include "nfs4trace.h"
#define NFS_UINT_MAXLEN 11 #define NFS_UINT_MAXLEN 11
...@@ -63,6 +64,7 @@ struct idmap_legacy_upcalldata { ...@@ -63,6 +64,7 @@ struct idmap_legacy_upcalldata {
}; };
struct idmap { struct idmap {
struct rpc_pipe_dir_object idmap_pdo;
struct rpc_pipe *idmap_pipe; struct rpc_pipe *idmap_pipe;
struct idmap_legacy_upcalldata *idmap_upcall_data; struct idmap_legacy_upcalldata *idmap_upcall_data;
struct mutex idmap_mutex; struct mutex idmap_mutex;
...@@ -310,7 +312,7 @@ static ssize_t nfs_idmap_get_key(const char *name, size_t namelen, ...@@ -310,7 +312,7 @@ static ssize_t nfs_idmap_get_key(const char *name, size_t namelen,
if (ret < 0) if (ret < 0)
goto out_up; goto out_up;
payload = rcu_dereference(rkey->payload.data); payload = rcu_dereference(rkey->payload.rcudata);
if (IS_ERR_OR_NULL(payload)) { if (IS_ERR_OR_NULL(payload)) {
ret = PTR_ERR(payload); ret = PTR_ERR(payload);
goto out_up; goto out_up;
...@@ -401,16 +403,23 @@ static struct key_type key_type_id_resolver_legacy = { ...@@ -401,16 +403,23 @@ static struct key_type key_type_id_resolver_legacy = {
.request_key = nfs_idmap_legacy_upcall, .request_key = nfs_idmap_legacy_upcall,
}; };
static void __nfs_idmap_unregister(struct rpc_pipe *pipe) static void nfs_idmap_pipe_destroy(struct dentry *dir,
struct rpc_pipe_dir_object *pdo)
{ {
if (pipe->dentry) struct idmap *idmap = pdo->pdo_data;
struct rpc_pipe *pipe = idmap->idmap_pipe;
if (pipe->dentry) {
rpc_unlink(pipe->dentry); rpc_unlink(pipe->dentry);
pipe->dentry = NULL;
}
} }
static int __nfs_idmap_register(struct dentry *dir, static int nfs_idmap_pipe_create(struct dentry *dir,
struct idmap *idmap, struct rpc_pipe_dir_object *pdo)
struct rpc_pipe *pipe)
{ {
struct idmap *idmap = pdo->pdo_data;
struct rpc_pipe *pipe = idmap->idmap_pipe;
struct dentry *dentry; struct dentry *dentry;
dentry = rpc_mkpipe_dentry(dir, "idmap", idmap, pipe); dentry = rpc_mkpipe_dentry(dir, "idmap", idmap, pipe);
...@@ -420,36 +429,10 @@ static int __nfs_idmap_register(struct dentry *dir, ...@@ -420,36 +429,10 @@ static int __nfs_idmap_register(struct dentry *dir,
return 0; return 0;
} }
static void nfs_idmap_unregister(struct nfs_client *clp, static const struct rpc_pipe_dir_object_ops nfs_idmap_pipe_dir_object_ops = {
struct rpc_pipe *pipe) .create = nfs_idmap_pipe_create,
{ .destroy = nfs_idmap_pipe_destroy,
struct net *net = clp->cl_net; };
struct super_block *pipefs_sb;
pipefs_sb = rpc_get_sb_net(net);
if (pipefs_sb) {
__nfs_idmap_unregister(pipe);
rpc_put_sb_net(net);
}
}
static int nfs_idmap_register(struct nfs_client *clp,
struct idmap *idmap,
struct rpc_pipe *pipe)
{
struct net *net = clp->cl_net;
struct super_block *pipefs_sb;
int err = 0;
pipefs_sb = rpc_get_sb_net(net);
if (pipefs_sb) {
if (clp->cl_rpcclient->cl_dentry)
err = __nfs_idmap_register(clp->cl_rpcclient->cl_dentry,
idmap, pipe);
rpc_put_sb_net(net);
}
return err;
}
int int
nfs_idmap_new(struct nfs_client *clp) nfs_idmap_new(struct nfs_client *clp)
...@@ -462,23 +445,31 @@ nfs_idmap_new(struct nfs_client *clp) ...@@ -462,23 +445,31 @@ nfs_idmap_new(struct nfs_client *clp)
if (idmap == NULL) if (idmap == NULL)
return -ENOMEM; return -ENOMEM;
rpc_init_pipe_dir_object(&idmap->idmap_pdo,
&nfs_idmap_pipe_dir_object_ops,
idmap);
pipe = rpc_mkpipe_data(&idmap_upcall_ops, 0); pipe = rpc_mkpipe_data(&idmap_upcall_ops, 0);
if (IS_ERR(pipe)) { if (IS_ERR(pipe)) {
error = PTR_ERR(pipe); error = PTR_ERR(pipe);
kfree(idmap); goto err;
return error;
}
error = nfs_idmap_register(clp, idmap, pipe);
if (error) {
rpc_destroy_pipe_data(pipe);
kfree(idmap);
return error;
} }
idmap->idmap_pipe = pipe; idmap->idmap_pipe = pipe;
mutex_init(&idmap->idmap_mutex); mutex_init(&idmap->idmap_mutex);
error = rpc_add_pipe_dir_object(clp->cl_net,
&clp->cl_rpcclient->cl_pipedir_objects,
&idmap->idmap_pdo);
if (error)
goto err_destroy_pipe;
clp->cl_idmap = idmap; clp->cl_idmap = idmap;
return 0; return 0;
err_destroy_pipe:
rpc_destroy_pipe_data(idmap->idmap_pipe);
err:
kfree(idmap);
return error;
} }
void void
...@@ -488,130 +479,26 @@ nfs_idmap_delete(struct nfs_client *clp) ...@@ -488,130 +479,26 @@ nfs_idmap_delete(struct nfs_client *clp)
if (!idmap) if (!idmap)
return; return;
nfs_idmap_unregister(clp, idmap->idmap_pipe);
rpc_destroy_pipe_data(idmap->idmap_pipe);
clp->cl_idmap = NULL; clp->cl_idmap = NULL;
rpc_remove_pipe_dir_object(clp->cl_net,
&clp->cl_rpcclient->cl_pipedir_objects,
&idmap->idmap_pdo);
rpc_destroy_pipe_data(idmap->idmap_pipe);
kfree(idmap); kfree(idmap);
} }
static int __rpc_pipefs_event(struct nfs_client *clp, unsigned long event,
struct super_block *sb)
{
int err = 0;
switch (event) {
case RPC_PIPEFS_MOUNT:
err = __nfs_idmap_register(clp->cl_rpcclient->cl_dentry,
clp->cl_idmap,
clp->cl_idmap->idmap_pipe);
break;
case RPC_PIPEFS_UMOUNT:
if (clp->cl_idmap->idmap_pipe) {
struct dentry *parent;
parent = clp->cl_idmap->idmap_pipe->dentry->d_parent;
__nfs_idmap_unregister(clp->cl_idmap->idmap_pipe);
/*
* Note: This is a dirty hack. SUNRPC hook has been
* called already but simple_rmdir() call for the
* directory returned with error because of idmap pipe
* inside. Thus now we have to remove this directory
* here.
*/
if (rpc_rmdir(parent))
printk(KERN_ERR "NFS: %s: failed to remove "
"clnt dir!\n", __func__);
}
break;
default:
printk(KERN_ERR "NFS: %s: unknown event: %ld\n", __func__,
event);
return -ENOTSUPP;
}
return err;
}
static struct nfs_client *nfs_get_client_for_event(struct net *net, int event)
{
struct nfs_net *nn = net_generic(net, nfs_net_id);
struct dentry *cl_dentry;
struct nfs_client *clp;
int err;
restart:
spin_lock(&nn->nfs_client_lock);
list_for_each_entry(clp, &nn->nfs_client_list, cl_share_link) {
/* Wait for initialisation to finish */
if (clp->cl_cons_state == NFS_CS_INITING) {
atomic_inc(&clp->cl_count);
spin_unlock(&nn->nfs_client_lock);
err = nfs_wait_client_init_complete(clp);
nfs_put_client(clp);
if (err)
return NULL;
goto restart;
}
/* Skip nfs_clients that failed to initialise */
if (clp->cl_cons_state < 0)
continue;
smp_rmb();
if (clp->rpc_ops != &nfs_v4_clientops)
continue;
cl_dentry = clp->cl_idmap->idmap_pipe->dentry;
if (((event == RPC_PIPEFS_MOUNT) && cl_dentry) ||
((event == RPC_PIPEFS_UMOUNT) && !cl_dentry))
continue;
atomic_inc(&clp->cl_count);
spin_unlock(&nn->nfs_client_lock);
return clp;
}
spin_unlock(&nn->nfs_client_lock);
return NULL;
}
static int rpc_pipefs_event(struct notifier_block *nb, unsigned long event,
void *ptr)
{
struct super_block *sb = ptr;
struct nfs_client *clp;
int error = 0;
if (!try_module_get(THIS_MODULE))
return 0;
while ((clp = nfs_get_client_for_event(sb->s_fs_info, event))) {
error = __rpc_pipefs_event(clp, event, sb);
nfs_put_client(clp);
if (error)
break;
}
module_put(THIS_MODULE);
return error;
}
#define PIPEFS_NFS_PRIO 1
static struct notifier_block nfs_idmap_block = {
.notifier_call = rpc_pipefs_event,
.priority = SUNRPC_PIPEFS_NFS_PRIO,
};
int nfs_idmap_init(void) int nfs_idmap_init(void)
{ {
int ret; int ret;
ret = nfs_idmap_init_keyring(); ret = nfs_idmap_init_keyring();
if (ret != 0) if (ret != 0)
goto out; goto out;
ret = rpc_pipefs_notifier_register(&nfs_idmap_block);
if (ret != 0)
nfs_idmap_quit_keyring();
out: out:
return ret; return ret;
} }
void nfs_idmap_quit(void) void nfs_idmap_quit(void)
{ {
rpc_pipefs_notifier_unregister(&nfs_idmap_block);
nfs_idmap_quit_keyring(); nfs_idmap_quit_keyring();
} }
...@@ -849,6 +736,7 @@ int nfs_map_name_to_uid(const struct nfs_server *server, const char *name, size_ ...@@ -849,6 +736,7 @@ int nfs_map_name_to_uid(const struct nfs_server *server, const char *name, size_
if (!uid_valid(*uid)) if (!uid_valid(*uid))
ret = -ERANGE; ret = -ERANGE;
} }
trace_nfs4_map_name_to_uid(name, namelen, id, ret);
return ret; return ret;
} }
...@@ -865,6 +753,7 @@ int nfs_map_group_to_gid(const struct nfs_server *server, const char *name, size ...@@ -865,6 +753,7 @@ int nfs_map_group_to_gid(const struct nfs_server *server, const char *name, size
if (!gid_valid(*gid)) if (!gid_valid(*gid))
ret = -ERANGE; ret = -ERANGE;
} }
trace_nfs4_map_group_to_gid(name, namelen, id, ret);
return ret; return ret;
} }
...@@ -879,6 +768,7 @@ int nfs_map_uid_to_name(const struct nfs_server *server, kuid_t uid, char *buf, ...@@ -879,6 +768,7 @@ int nfs_map_uid_to_name(const struct nfs_server *server, kuid_t uid, char *buf,
ret = nfs_idmap_lookup_name(id, "user", buf, buflen, idmap); ret = nfs_idmap_lookup_name(id, "user", buf, buflen, idmap);
if (ret < 0) if (ret < 0)
ret = nfs_map_numeric_to_string(id, buf, buflen); ret = nfs_map_numeric_to_string(id, buf, buflen);
trace_nfs4_map_uid_to_name(buf, ret, id, ret);
return ret; return ret;
} }
int nfs_map_gid_to_group(const struct nfs_server *server, kgid_t gid, char *buf, size_t buflen) int nfs_map_gid_to_group(const struct nfs_server *server, kgid_t gid, char *buf, size_t buflen)
...@@ -892,5 +782,6 @@ int nfs_map_gid_to_group(const struct nfs_server *server, kgid_t gid, char *buf, ...@@ -892,5 +782,6 @@ int nfs_map_gid_to_group(const struct nfs_server *server, kgid_t gid, char *buf,
ret = nfs_idmap_lookup_name(id, "group", buf, buflen, idmap); ret = nfs_idmap_lookup_name(id, "group", buf, buflen, idmap);
if (ret < 0) if (ret < 0)
ret = nfs_map_numeric_to_string(id, buf, buflen); ret = nfs_map_numeric_to_string(id, buf, buflen);
trace_nfs4_map_gid_to_group(buf, ret, id, ret);
return ret; return ret;
} }
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/freezer.h> #include <linux/freezer.h>
#include <linux/crc32.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -52,6 +51,8 @@ ...@@ -52,6 +51,8 @@
#include "nfs.h" #include "nfs.h"
#include "netns.h" #include "netns.h"
#include "nfstrace.h"
#define NFSDBG_FACILITY NFSDBG_VFS #define NFSDBG_FACILITY NFSDBG_VFS
#define NFS_64_BIT_INODE_NUMBERS_ENABLED 1 #define NFS_64_BIT_INODE_NUMBERS_ENABLED 1
...@@ -503,6 +504,8 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -503,6 +504,8 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
if ((attr->ia_valid & ~(ATTR_FILE|ATTR_OPEN)) == 0) if ((attr->ia_valid & ~(ATTR_FILE|ATTR_OPEN)) == 0)
return 0; return 0;
trace_nfs_setattr_enter(inode);
/* Write all dirty data */ /* Write all dirty data */
if (S_ISREG(inode->i_mode)) { if (S_ISREG(inode->i_mode)) {
nfs_inode_dio_wait(inode); nfs_inode_dio_wait(inode);
...@@ -522,6 +525,7 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -522,6 +525,7 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
error = nfs_refresh_inode(inode, fattr); error = nfs_refresh_inode(inode, fattr);
nfs_free_fattr(fattr); nfs_free_fattr(fattr);
out: out:
trace_nfs_setattr_exit(inode, error);
return error; return error;
} }
EXPORT_SYMBOL_GPL(nfs_setattr); EXPORT_SYMBOL_GPL(nfs_setattr);
...@@ -591,6 +595,7 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) ...@@ -591,6 +595,7 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
int need_atime = NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATIME; int need_atime = NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATIME;
int err; int err;
trace_nfs_getattr_enter(inode);
/* Flush out writes to the server in order to update c/mtime. */ /* Flush out writes to the server in order to update c/mtime. */
if (S_ISREG(inode->i_mode)) { if (S_ISREG(inode->i_mode)) {
nfs_inode_dio_wait(inode); nfs_inode_dio_wait(inode);
...@@ -621,6 +626,7 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) ...@@ -621,6 +626,7 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
stat->ino = nfs_compat_user_ino64(NFS_FILEID(inode)); stat->ino = nfs_compat_user_ino64(NFS_FILEID(inode));
} }
out: out:
trace_nfs_getattr_exit(inode, err);
return err; return err;
} }
EXPORT_SYMBOL_GPL(nfs_getattr); EXPORT_SYMBOL_GPL(nfs_getattr);
...@@ -875,6 +881,8 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) ...@@ -875,6 +881,8 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n", dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n",
inode->i_sb->s_id, (long long)NFS_FILEID(inode)); inode->i_sb->s_id, (long long)NFS_FILEID(inode));
trace_nfs_revalidate_inode_enter(inode);
if (is_bad_inode(inode)) if (is_bad_inode(inode))
goto out; goto out;
if (NFS_STALE(inode)) if (NFS_STALE(inode))
...@@ -925,6 +933,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) ...@@ -925,6 +933,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
nfs4_label_free(label); nfs4_label_free(label);
out: out:
nfs_free_fattr(fattr); nfs_free_fattr(fattr);
trace_nfs_revalidate_inode_exit(inode, status);
return status; return status;
} }
...@@ -981,6 +990,7 @@ static int nfs_invalidate_mapping(struct inode *inode, struct address_space *map ...@@ -981,6 +990,7 @@ static int nfs_invalidate_mapping(struct inode *inode, struct address_space *map
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
nfs_inc_stats(inode, NFSIOS_DATAINVALIDATE); nfs_inc_stats(inode, NFSIOS_DATAINVALIDATE);
nfs_fscache_wait_on_invalidate(inode); nfs_fscache_wait_on_invalidate(inode);
dfprintk(PAGECACHE, "NFS: (%s/%Ld) data cache invalidated\n", dfprintk(PAGECACHE, "NFS: (%s/%Ld) data cache invalidated\n",
inode->i_sb->s_id, (long long)NFS_FILEID(inode)); inode->i_sb->s_id, (long long)NFS_FILEID(inode));
return 0; return 0;
...@@ -1014,8 +1024,12 @@ int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping) ...@@ -1014,8 +1024,12 @@ int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping)
if (ret < 0) if (ret < 0)
goto out; goto out;
} }
if (nfsi->cache_validity & NFS_INO_INVALID_DATA) if (nfsi->cache_validity & NFS_INO_INVALID_DATA) {
trace_nfs_invalidate_mapping_enter(inode);
ret = nfs_invalidate_mapping(inode, mapping); ret = nfs_invalidate_mapping(inode, mapping);
trace_nfs_invalidate_mapping_exit(inode, ret);
}
out: out:
return ret; return ret;
} }
...@@ -1195,7 +1209,7 @@ u32 _nfs_display_fhandle_hash(const struct nfs_fh *fh) ...@@ -1195,7 +1209,7 @@ u32 _nfs_display_fhandle_hash(const struct nfs_fh *fh)
{ {
/* wireshark uses 32-bit AUTODIN crc and does a bitwise /* wireshark uses 32-bit AUTODIN crc and does a bitwise
* not on the result */ * not on the result */
return ~crc32(0xFFFFFFFF, &fh->data[0], fh->size); return nfs_fhandle_hash(fh);
} }
/* /*
...@@ -1274,9 +1288,17 @@ static int nfs_inode_attrs_need_update(const struct inode *inode, const struct n ...@@ -1274,9 +1288,17 @@ static int nfs_inode_attrs_need_update(const struct inode *inode, const struct n
static int nfs_refresh_inode_locked(struct inode *inode, struct nfs_fattr *fattr) static int nfs_refresh_inode_locked(struct inode *inode, struct nfs_fattr *fattr)
{ {
int ret;
trace_nfs_refresh_inode_enter(inode);
if (nfs_inode_attrs_need_update(inode, fattr)) if (nfs_inode_attrs_need_update(inode, fattr))
return nfs_update_inode(inode, fattr); ret = nfs_update_inode(inode, fattr);
return nfs_check_inode_attributes(inode, fattr); else
ret = nfs_check_inode_attributes(inode, fattr);
trace_nfs_refresh_inode_exit(inode, ret);
return ret;
} }
/** /**
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "nfs4_fs.h" #include "nfs4_fs.h"
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/crc32.h>
#define NFS_MS_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS) #define NFS_MS_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS)
...@@ -185,6 +186,8 @@ extern struct nfs_client *nfs4_set_ds_client(struct nfs_client* mds_clp, ...@@ -185,6 +186,8 @@ extern struct nfs_client *nfs4_set_ds_client(struct nfs_client* mds_clp,
int ds_addrlen, int ds_proto, int ds_addrlen, int ds_proto,
unsigned int ds_timeo, unsigned int ds_timeo,
unsigned int ds_retrans); unsigned int ds_retrans);
extern struct rpc_clnt *nfs4_find_or_create_ds_client(struct nfs_client *,
struct inode *);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
extern int __init nfs_fs_proc_init(void); extern int __init nfs_fs_proc_init(void);
extern void nfs_fs_proc_exit(void); extern void nfs_fs_proc_exit(void);
...@@ -267,7 +270,7 @@ extern struct rpc_procinfo nfs4_procedures[]; ...@@ -267,7 +270,7 @@ extern struct rpc_procinfo nfs4_procedures[];
void nfs_close_context(struct nfs_open_context *ctx, int is_sync); void nfs_close_context(struct nfs_open_context *ctx, int is_sync);
extern struct nfs_client *nfs_init_client(struct nfs_client *clp, extern struct nfs_client *nfs_init_client(struct nfs_client *clp,
const struct rpc_timeout *timeparms, const struct rpc_timeout *timeparms,
const char *ip_addr, rpc_authflavor_t authflavour); const char *ip_addr);
/* dir.c */ /* dir.c */
extern int nfs_access_cache_shrinker(struct shrinker *shrink, extern int nfs_access_cache_shrinker(struct shrinker *shrink,
...@@ -355,7 +358,7 @@ extern struct dentry *nfs_get_root(struct super_block *, struct nfs_fh *, ...@@ -355,7 +358,7 @@ extern struct dentry *nfs_get_root(struct super_block *, struct nfs_fh *,
extern struct dentry *nfs4_get_root(struct super_block *, struct nfs_fh *, extern struct dentry *nfs4_get_root(struct super_block *, struct nfs_fh *,
const char *); const char *);
extern int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh); extern int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh, bool);
#endif #endif
struct nfs_pgio_completion_ops; struct nfs_pgio_completion_ops;
...@@ -430,6 +433,8 @@ void nfs_request_remove_commit_list(struct nfs_page *req, ...@@ -430,6 +433,8 @@ void nfs_request_remove_commit_list(struct nfs_page *req,
void nfs_init_cinfo(struct nfs_commit_info *cinfo, void nfs_init_cinfo(struct nfs_commit_info *cinfo,
struct inode *inode, struct inode *inode,
struct nfs_direct_req *dreq); struct nfs_direct_req *dreq);
int nfs_key_timeout_notify(struct file *filp, struct inode *inode);
bool nfs_ctx_key_to_expire(struct nfs_open_context *ctx);
#ifdef CONFIG_MIGRATION #ifdef CONFIG_MIGRATION
extern int nfs_migrate_page(struct address_space *, extern int nfs_migrate_page(struct address_space *,
...@@ -451,8 +456,7 @@ extern ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq); ...@@ -451,8 +456,7 @@ extern ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq);
extern void __nfs4_read_done_cb(struct nfs_read_data *); extern void __nfs4_read_done_cb(struct nfs_read_data *);
extern struct nfs_client *nfs4_init_client(struct nfs_client *clp, extern struct nfs_client *nfs4_init_client(struct nfs_client *clp,
const struct rpc_timeout *timeparms, const struct rpc_timeout *timeparms,
const char *ip_addr, const char *ip_addr);
rpc_authflavor_t authflavour);
extern int nfs40_walk_client_list(struct nfs_client *clp, extern int nfs40_walk_client_list(struct nfs_client *clp,
struct nfs_client **result, struct nfs_client **result,
struct rpc_cred *cred); struct rpc_cred *cred);
...@@ -575,3 +579,22 @@ u64 nfs_timespec_to_change_attr(const struct timespec *ts) ...@@ -575,3 +579,22 @@ u64 nfs_timespec_to_change_attr(const struct timespec *ts)
{ {
return ((u64)ts->tv_sec << 30) + ts->tv_nsec; return ((u64)ts->tv_sec << 30) + ts->tv_nsec;
} }
#ifdef CONFIG_CRC32
/**
* nfs_fhandle_hash - calculate the crc32 hash for the filehandle
* @fh - pointer to filehandle
*
* returns a crc32 hash for the filehandle that is compatible with
* the one displayed by "wireshark".
*/
static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
{
return ~crc32_le(0xFFFFFFFF, &fh->data[0], fh->size);
}
#else
static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
{
return 0;
}
#endif
...@@ -336,8 +336,8 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, ...@@ -336,8 +336,8 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
data->arg.create.createmode = NFS3_CREATE_UNCHECKED; data->arg.create.createmode = NFS3_CREATE_UNCHECKED;
if (flags & O_EXCL) { if (flags & O_EXCL) {
data->arg.create.createmode = NFS3_CREATE_EXCLUSIVE; data->arg.create.createmode = NFS3_CREATE_EXCLUSIVE;
data->arg.create.verifier[0] = jiffies; data->arg.create.verifier[0] = cpu_to_be32(jiffies);
data->arg.create.verifier[1] = current->pid; data->arg.create.verifier[1] = cpu_to_be32(current->pid);
} }
sattr->ia_mode &= ~current_umask(); sattr->ia_mode &= ~current_umask();
...@@ -826,9 +826,10 @@ static void nfs3_proc_read_setup(struct nfs_read_data *data, struct rpc_message ...@@ -826,9 +826,10 @@ static void nfs3_proc_read_setup(struct nfs_read_data *data, struct rpc_message
msg->rpc_proc = &nfs3_procedures[NFS3PROC_READ]; msg->rpc_proc = &nfs3_procedures[NFS3PROC_READ];
} }
static void nfs3_proc_read_rpc_prepare(struct rpc_task *task, struct nfs_read_data *data) static int nfs3_proc_read_rpc_prepare(struct rpc_task *task, struct nfs_read_data *data)
{ {
rpc_call_start(task); rpc_call_start(task);
return 0;
} }
static int nfs3_write_done(struct rpc_task *task, struct nfs_write_data *data) static int nfs3_write_done(struct rpc_task *task, struct nfs_write_data *data)
...@@ -847,9 +848,10 @@ static void nfs3_proc_write_setup(struct nfs_write_data *data, struct rpc_messag ...@@ -847,9 +848,10 @@ static void nfs3_proc_write_setup(struct nfs_write_data *data, struct rpc_messag
msg->rpc_proc = &nfs3_procedures[NFS3PROC_WRITE]; msg->rpc_proc = &nfs3_procedures[NFS3PROC_WRITE];
} }
static void nfs3_proc_write_rpc_prepare(struct rpc_task *task, struct nfs_write_data *data) static int nfs3_proc_write_rpc_prepare(struct rpc_task *task, struct nfs_write_data *data)
{ {
rpc_call_start(task); rpc_call_start(task);
return 0;
} }
static void nfs3_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data) static void nfs3_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data)
......
...@@ -38,17 +38,15 @@ struct nfs4_minor_version_ops { ...@@ -38,17 +38,15 @@ struct nfs4_minor_version_ops {
u32 minor_version; u32 minor_version;
unsigned init_caps; unsigned init_caps;
int (*call_sync)(struct rpc_clnt *clnt, int (*init_client)(struct nfs_client *);
struct nfs_server *server, void (*shutdown_client)(struct nfs_client *);
struct rpc_message *msg,
struct nfs4_sequence_args *args,
struct nfs4_sequence_res *res);
bool (*match_stateid)(const nfs4_stateid *, bool (*match_stateid)(const nfs4_stateid *,
const nfs4_stateid *); const nfs4_stateid *);
int (*find_root_sec)(struct nfs_server *, struct nfs_fh *, int (*find_root_sec)(struct nfs_server *, struct nfs_fh *,
struct nfs_fsinfo *); struct nfs_fsinfo *);
int (*free_lock_state)(struct nfs_server *, int (*free_lock_state)(struct nfs_server *,
struct nfs4_lock_state *); struct nfs4_lock_state *);
const struct rpc_call_ops *call_sync_ops;
const struct nfs4_state_recovery_ops *reboot_recovery_ops; const struct nfs4_state_recovery_ops *reboot_recovery_ops;
const struct nfs4_state_recovery_ops *nograce_recovery_ops; const struct nfs4_state_recovery_ops *nograce_recovery_ops;
const struct nfs4_state_maintenance_ops *state_renewal_ops; const struct nfs4_state_maintenance_ops *state_renewal_ops;
...@@ -135,6 +133,7 @@ struct nfs4_lock_state { ...@@ -135,6 +133,7 @@ struct nfs4_lock_state {
struct list_head ls_locks; /* Other lock stateids */ struct list_head ls_locks; /* Other lock stateids */
struct nfs4_state * ls_state; /* Pointer to open state */ struct nfs4_state * ls_state; /* Pointer to open state */
#define NFS_LOCK_INITIALIZED 0 #define NFS_LOCK_INITIALIZED 0
#define NFS_LOCK_LOST 1
unsigned long ls_flags; unsigned long ls_flags;
struct nfs_seqid_counter ls_seqid; struct nfs_seqid_counter ls_seqid;
nfs4_stateid ls_stateid; nfs4_stateid ls_stateid;
...@@ -193,7 +192,6 @@ struct nfs4_state_recovery_ops { ...@@ -193,7 +192,6 @@ struct nfs4_state_recovery_ops {
int (*recover_open)(struct nfs4_state_owner *, struct nfs4_state *); int (*recover_open)(struct nfs4_state_owner *, struct nfs4_state *);
int (*recover_lock)(struct nfs4_state *, struct file_lock *); int (*recover_lock)(struct nfs4_state *, struct file_lock *);
int (*establish_clid)(struct nfs_client *, struct rpc_cred *); int (*establish_clid)(struct nfs_client *, struct rpc_cred *);
struct rpc_cred * (*get_clid_cred)(struct nfs_client *);
int (*reclaim_complete)(struct nfs_client *, struct rpc_cred *); int (*reclaim_complete)(struct nfs_client *, struct rpc_cred *);
int (*detect_trunking)(struct nfs_client *, struct nfs_client **, int (*detect_trunking)(struct nfs_client *, struct nfs_client **,
struct rpc_cred *); struct rpc_cred *);
...@@ -223,7 +221,7 @@ struct vfsmount *nfs4_submount(struct nfs_server *, struct dentry *, ...@@ -223,7 +221,7 @@ struct vfsmount *nfs4_submount(struct nfs_server *, struct dentry *,
/* nfs4proc.c */ /* nfs4proc.c */
extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *); extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *);
extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, struct rpc_cred *); extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, struct rpc_cred *);
extern int nfs4_proc_get_rootfh(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *); extern int nfs4_proc_get_rootfh(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *, bool);
extern int nfs4_proc_bind_conn_to_session(struct nfs_client *, struct rpc_cred *cred); extern int nfs4_proc_bind_conn_to_session(struct nfs_client *, struct rpc_cred *cred);
extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred); extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred);
extern int nfs4_destroy_clientid(struct nfs_client *clp); extern int nfs4_destroy_clientid(struct nfs_client *clp);
...@@ -248,9 +246,6 @@ static inline struct nfs4_session *nfs4_get_session(const struct nfs_server *ser ...@@ -248,9 +246,6 @@ static inline struct nfs4_session *nfs4_get_session(const struct nfs_server *ser
return server->nfs_client->cl_session; return server->nfs_client->cl_session;
} }
extern int nfs4_setup_sequence(const struct nfs_server *server,
struct nfs4_sequence_args *args, struct nfs4_sequence_res *res,
struct rpc_task *task);
extern int nfs41_setup_sequence(struct nfs4_session *session, extern int nfs41_setup_sequence(struct nfs4_session *session,
struct nfs4_sequence_args *args, struct nfs4_sequence_res *res, struct nfs4_sequence_args *args, struct nfs4_sequence_res *res,
struct rpc_task *task); struct rpc_task *task);
...@@ -273,18 +268,63 @@ is_ds_client(struct nfs_client *clp) ...@@ -273,18 +268,63 @@ is_ds_client(struct nfs_client *clp)
{ {
return clp->cl_exchange_flags & EXCHGID4_FLAG_USE_PNFS_DS; return clp->cl_exchange_flags & EXCHGID4_FLAG_USE_PNFS_DS;
} }
#else /* CONFIG_NFS_v4_1 */
static inline struct nfs4_session *nfs4_get_session(const struct nfs_server *server) static inline bool
_nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode,
struct rpc_clnt **clntp, struct rpc_message *msg)
{ {
return NULL; struct rpc_cred *newcred = NULL;
rpc_authflavor_t flavor;
if (test_bit(sp4_mode, &clp->cl_sp4_flags)) {
spin_lock(&clp->cl_lock);
if (clp->cl_machine_cred != NULL)
newcred = get_rpccred(clp->cl_machine_cred);
spin_unlock(&clp->cl_lock);
if (msg->rpc_cred)
put_rpccred(msg->rpc_cred);
msg->rpc_cred = newcred;
flavor = clp->cl_rpcclient->cl_auth->au_flavor;
WARN_ON(flavor != RPC_AUTH_GSS_KRB5I &&
flavor != RPC_AUTH_GSS_KRB5P);
*clntp = clp->cl_rpcclient;
return true;
}
return false;
} }
static inline int nfs4_setup_sequence(const struct nfs_server *server, /*
struct nfs4_sequence_args *args, struct nfs4_sequence_res *res, * Function responsible for determining if an rpc_message should use the
struct rpc_task *task) * machine cred under SP4_MACH_CRED and if so switching the credential and
* authflavor (using the nfs_client's rpc_clnt which will be krb5i/p).
* Should be called before rpc_call_sync/rpc_call_async.
*/
static inline void
nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode,
struct rpc_clnt **clntp, struct rpc_message *msg)
{ {
rpc_call_start(task); _nfs4_state_protect(clp, sp4_mode, clntp, msg);
return 0; }
/*
* Special wrapper to nfs4_state_protect for write.
* If WRITE can use machine cred but COMMIT cannot, make sure all writes
* that use machine cred use NFS_FILE_SYNC.
*/
static inline void
nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp,
struct rpc_message *msg, struct nfs_write_data *wdata)
{
if (_nfs4_state_protect(clp, NFS_SP4_MACH_CRED_WRITE, clntp, msg) &&
!test_bit(NFS_SP4_MACH_CRED_COMMIT, &clp->cl_sp4_flags))
wdata->args.stable = NFS_FILE_SYNC;
}
#else /* CONFIG_NFS_v4_1 */
static inline struct nfs4_session *nfs4_get_session(const struct nfs_server *server)
{
return NULL;
} }
static inline bool static inline bool
...@@ -298,6 +338,18 @@ is_ds_client(struct nfs_client *clp) ...@@ -298,6 +338,18 @@ is_ds_client(struct nfs_client *clp)
{ {
return false; return false;
} }
static inline void
nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_flags,
struct rpc_clnt **clntp, struct rpc_message *msg)
{
}
static inline void
nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp,
struct rpc_message *msg, struct nfs_write_data *wdata)
{
}
#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4_1 */
extern const struct nfs4_minor_version_ops *nfs_v4_minor_ops[]; extern const struct nfs4_minor_version_ops *nfs_v4_minor_ops[];
...@@ -308,6 +360,10 @@ extern const u32 nfs4_pathconf_bitmap[3]; ...@@ -308,6 +360,10 @@ extern const u32 nfs4_pathconf_bitmap[3];
extern const u32 nfs4_fsinfo_bitmap[3]; extern const u32 nfs4_fsinfo_bitmap[3];
extern const u32 nfs4_fs_locations_bitmap[3]; extern const u32 nfs4_fs_locations_bitmap[3];
void nfs40_shutdown_client(struct nfs_client *);
void nfs41_shutdown_client(struct nfs_client *);
int nfs40_init_client(struct nfs_client *);
int nfs41_init_client(struct nfs_client *);
void nfs4_free_client(struct nfs_client *); void nfs4_free_client(struct nfs_client *);
struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *); struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *);
...@@ -319,7 +375,7 @@ extern void nfs4_kill_renewd(struct nfs_client *); ...@@ -319,7 +375,7 @@ extern void nfs4_kill_renewd(struct nfs_client *);
extern void nfs4_renew_state(struct work_struct *); extern void nfs4_renew_state(struct work_struct *);
/* nfs4state.c */ /* nfs4state.c */
struct rpc_cred *nfs4_get_setclientid_cred(struct nfs_client *clp); struct rpc_cred *nfs4_get_clid_cred(struct nfs_client *clp);
struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp); struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp);
struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp); struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp);
int nfs4_discover_server_trunking(struct nfs_client *clp, int nfs4_discover_server_trunking(struct nfs_client *clp,
...@@ -327,7 +383,6 @@ int nfs4_discover_server_trunking(struct nfs_client *clp, ...@@ -327,7 +383,6 @@ int nfs4_discover_server_trunking(struct nfs_client *clp,
int nfs40_discover_server_trunking(struct nfs_client *clp, int nfs40_discover_server_trunking(struct nfs_client *clp,
struct nfs_client **, struct rpc_cred *); struct nfs_client **, struct rpc_cred *);
#if defined(CONFIG_NFS_V4_1) #if defined(CONFIG_NFS_V4_1)
struct rpc_cred *nfs4_get_exchange_id_cred(struct nfs_client *clp);
int nfs41_discover_server_trunking(struct nfs_client *clp, int nfs41_discover_server_trunking(struct nfs_client *clp,
struct nfs_client **, struct rpc_cred *); struct nfs_client **, struct rpc_cred *);
extern void nfs4_schedule_session_recovery(struct nfs4_session *, int); extern void nfs4_schedule_session_recovery(struct nfs4_session *, int);
...@@ -382,6 +437,7 @@ struct dentry *nfs4_try_mount(int, const char *, struct nfs_mount_info *, struct ...@@ -382,6 +437,7 @@ struct dentry *nfs4_try_mount(int, const char *, struct nfs_mount_info *, struct
extern bool nfs4_disable_idmapping; extern bool nfs4_disable_idmapping;
extern unsigned short max_session_slots; extern unsigned short max_session_slots;
extern unsigned short send_implementation_id; extern unsigned short send_implementation_id;
extern bool recover_lost_locks;
#define NFS4_CLIENT_ID_UNIQ_LEN (64) #define NFS4_CLIENT_ID_UNIQ_LEN (64)
extern char nfs4_client_id_uniquifier[NFS4_CLIENT_ID_UNIQ_LEN]; extern char nfs4_client_id_uniquifier[NFS4_CLIENT_ID_UNIQ_LEN];
...@@ -429,6 +485,8 @@ static inline bool nfs4_valid_open_stateid(const struct nfs4_state *state) ...@@ -429,6 +485,8 @@ static inline bool nfs4_valid_open_stateid(const struct nfs4_state *state)
#define nfs4_close_state(a, b) do { } while (0) #define nfs4_close_state(a, b) do { } while (0)
#define nfs4_close_sync(a, b) do { } while (0) #define nfs4_close_sync(a, b) do { } while (0)
#define nfs4_state_protect(a, b, c, d) do { } while (0)
#define nfs4_state_protect_write(a, b, c, d) do { } while (0)
#endif /* CONFIG_NFS_V4 */ #endif /* CONFIG_NFS_V4 */
#endif /* __LINUX_FS_NFS_NFS4_FS.H */ #endif /* __LINUX_FS_NFS_NFS4_FS.H */
...@@ -41,19 +41,138 @@ static int nfs_get_cb_ident_idr(struct nfs_client *clp, int minorversion) ...@@ -41,19 +41,138 @@ static int nfs_get_cb_ident_idr(struct nfs_client *clp, int minorversion)
} }
#ifdef CONFIG_NFS_V4_1 #ifdef CONFIG_NFS_V4_1
static void nfs4_shutdown_session(struct nfs_client *clp) /**
* Per auth flavor data server rpc clients
*/
struct nfs4_ds_server {
struct list_head list; /* ds_clp->cl_ds_clients */
struct rpc_clnt *rpc_clnt;
};
/**
* Common lookup case for DS I/O
*/
static struct nfs4_ds_server *
nfs4_find_ds_client(struct nfs_client *ds_clp, rpc_authflavor_t flavor)
{
struct nfs4_ds_server *dss;
rcu_read_lock();
list_for_each_entry_rcu(dss, &ds_clp->cl_ds_clients, list) {
if (dss->rpc_clnt->cl_auth->au_flavor != flavor)
continue;
goto out;
}
dss = NULL;
out:
rcu_read_unlock();
return dss;
}
static struct nfs4_ds_server *
nfs4_add_ds_client(struct nfs_client *ds_clp, rpc_authflavor_t flavor,
struct nfs4_ds_server *new)
{
struct nfs4_ds_server *dss;
spin_lock(&ds_clp->cl_lock);
list_for_each_entry(dss, &ds_clp->cl_ds_clients, list) {
if (dss->rpc_clnt->cl_auth->au_flavor != flavor)
continue;
goto out;
}
if (new)
list_add_rcu(&new->list, &ds_clp->cl_ds_clients);
dss = new;
out:
spin_unlock(&ds_clp->cl_lock); /* need some lock to protect list */
return dss;
}
static struct nfs4_ds_server *
nfs4_alloc_ds_server(struct nfs_client *ds_clp, rpc_authflavor_t flavor)
{
struct nfs4_ds_server *dss;
dss = kmalloc(sizeof(*dss), GFP_NOFS);
if (dss == NULL)
return ERR_PTR(-ENOMEM);
dss->rpc_clnt = rpc_clone_client_set_auth(ds_clp->cl_rpcclient, flavor);
if (IS_ERR(dss->rpc_clnt)) {
int err = PTR_ERR(dss->rpc_clnt);
kfree (dss);
return ERR_PTR(err);
}
INIT_LIST_HEAD(&dss->list);
return dss;
}
static void
nfs4_free_ds_server(struct nfs4_ds_server *dss)
{
rpc_release_client(dss->rpc_clnt);
kfree(dss);
}
/**
* Find or create a DS rpc client with th MDS server rpc client auth flavor
* in the nfs_client cl_ds_clients list.
*/
struct rpc_clnt *
nfs4_find_or_create_ds_client(struct nfs_client *ds_clp, struct inode *inode)
{
struct nfs4_ds_server *dss, *new;
rpc_authflavor_t flavor = NFS_SERVER(inode)->client->cl_auth->au_flavor;
dss = nfs4_find_ds_client(ds_clp, flavor);
if (dss != NULL)
goto out;
new = nfs4_alloc_ds_server(ds_clp, flavor);
if (IS_ERR(new))
return ERR_CAST(new);
dss = nfs4_add_ds_client(ds_clp, flavor, new);
if (dss != new)
nfs4_free_ds_server(new);
out:
return dss->rpc_clnt;
}
EXPORT_SYMBOL_GPL(nfs4_find_or_create_ds_client);
static void
nfs4_shutdown_ds_clients(struct nfs_client *clp)
{
struct nfs4_ds_server *dss;
LIST_HEAD(shutdown_list);
while (!list_empty(&clp->cl_ds_clients)) {
dss = list_entry(clp->cl_ds_clients.next,
struct nfs4_ds_server, list);
list_del(&dss->list);
rpc_shutdown_client(dss->rpc_clnt);
kfree (dss);
}
}
void nfs41_shutdown_client(struct nfs_client *clp)
{ {
if (nfs4_has_session(clp)) { if (nfs4_has_session(clp)) {
nfs4_shutdown_ds_clients(clp);
nfs4_destroy_session(clp->cl_session); nfs4_destroy_session(clp->cl_session);
nfs4_destroy_clientid(clp); nfs4_destroy_clientid(clp);
} }
} }
#else /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4_1 */
static void nfs4_shutdown_session(struct nfs_client *clp)
void nfs40_shutdown_client(struct nfs_client *clp)
{ {
if (clp->cl_slot_tbl) {
nfs4_release_slot_table(clp->cl_slot_tbl);
kfree(clp->cl_slot_tbl);
}
} }
#endif /* CONFIG_NFS_V4_1 */
struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init) struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
{ {
...@@ -73,6 +192,7 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init) ...@@ -73,6 +192,7 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
spin_lock_init(&clp->cl_lock); spin_lock_init(&clp->cl_lock);
INIT_DELAYED_WORK(&clp->cl_renewd, nfs4_renew_state); INIT_DELAYED_WORK(&clp->cl_renewd, nfs4_renew_state);
INIT_LIST_HEAD(&clp->cl_ds_clients);
rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS client"); rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS client");
clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED; clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;
clp->cl_minorversion = cl_init->minorversion; clp->cl_minorversion = cl_init->minorversion;
...@@ -97,7 +217,7 @@ static void nfs4_shutdown_client(struct nfs_client *clp) ...@@ -97,7 +217,7 @@ static void nfs4_shutdown_client(struct nfs_client *clp)
{ {
if (__test_and_clear_bit(NFS_CS_RENEWD, &clp->cl_res_state)) if (__test_and_clear_bit(NFS_CS_RENEWD, &clp->cl_res_state))
nfs4_kill_renewd(clp); nfs4_kill_renewd(clp);
nfs4_shutdown_session(clp); clp->cl_mvops->shutdown_client(clp);
nfs4_destroy_callback(clp); nfs4_destroy_callback(clp);
if (__test_and_clear_bit(NFS_CS_IDMAP, &clp->cl_res_state)) if (__test_and_clear_bit(NFS_CS_IDMAP, &clp->cl_res_state))
nfs_idmap_delete(clp); nfs_idmap_delete(clp);
...@@ -144,14 +264,44 @@ static int nfs4_init_callback(struct nfs_client *clp) ...@@ -144,14 +264,44 @@ static int nfs4_init_callback(struct nfs_client *clp)
return 0; return 0;
} }
/* /**
* Initialize the minor version specific parts of an NFS4 client record * nfs40_init_client - nfs_client initialization tasks for NFSv4.0
* @clp - nfs_client to initialize
*
* Returns zero on success, or a negative errno if some error occurred.
*/ */
static int nfs4_init_client_minor_version(struct nfs_client *clp) int nfs40_init_client(struct nfs_client *clp)
{ {
struct nfs4_slot_table *tbl;
int ret;
tbl = kzalloc(sizeof(*tbl), GFP_NOFS);
if (tbl == NULL)
return -ENOMEM;
ret = nfs4_setup_slot_table(tbl, NFS4_MAX_SLOT_TABLE,
"NFSv4.0 transport Slot table");
if (ret) {
kfree(tbl);
return ret;
}
clp->cl_slot_tbl = tbl;
return 0;
}
#if defined(CONFIG_NFS_V4_1) #if defined(CONFIG_NFS_V4_1)
if (clp->cl_mvops->minor_version) {
/**
* nfs41_init_client - nfs_client initialization tasks for NFSv4.1+
* @clp - nfs_client to initialize
*
* Returns zero on success, or a negative errno if some error occurred.
*/
int nfs41_init_client(struct nfs_client *clp)
{
struct nfs4_session *session = NULL; struct nfs4_session *session = NULL;
/* /*
* Create the session and mark it expired. * Create the session and mark it expired.
* When a SEQUENCE operation encounters the expired session * When a SEQUENCE operation encounters the expired session
...@@ -162,6 +312,7 @@ static int nfs4_init_client_minor_version(struct nfs_client *clp) ...@@ -162,6 +312,7 @@ static int nfs4_init_client_minor_version(struct nfs_client *clp)
return -ENOMEM; return -ENOMEM;
clp->cl_session = session; clp->cl_session = session;
/* /*
* The create session reply races with the server back * The create session reply races with the server back
* channel probe. Mark the client NFS_CS_SESSION_INITING * channel probe. Mark the client NFS_CS_SESSION_INITING
...@@ -169,9 +320,21 @@ static int nfs4_init_client_minor_version(struct nfs_client *clp) ...@@ -169,9 +320,21 @@ static int nfs4_init_client_minor_version(struct nfs_client *clp)
* nfs_client struct * nfs_client struct
*/ */
nfs_mark_client_ready(clp, NFS_CS_SESSION_INITING); nfs_mark_client_ready(clp, NFS_CS_SESSION_INITING);
} return 0;
}
#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4_1 */
/*
* Initialize the minor version specific parts of an NFS4 client record
*/
static int nfs4_init_client_minor_version(struct nfs_client *clp)
{
int ret;
ret = clp->cl_mvops->init_client(clp);
if (ret)
return ret;
return nfs4_init_callback(clp); return nfs4_init_callback(clp);
} }
...@@ -187,8 +350,7 @@ static int nfs4_init_client_minor_version(struct nfs_client *clp) ...@@ -187,8 +350,7 @@ static int nfs4_init_client_minor_version(struct nfs_client *clp)
*/ */
struct nfs_client *nfs4_init_client(struct nfs_client *clp, struct nfs_client *nfs4_init_client(struct nfs_client *clp,
const struct rpc_timeout *timeparms, const struct rpc_timeout *timeparms,
const char *ip_addr, const char *ip_addr)
rpc_authflavor_t authflavour)
{ {
char buf[INET6_ADDRSTRLEN + 1]; char buf[INET6_ADDRSTRLEN + 1];
struct nfs_client *old; struct nfs_client *old;
...@@ -723,7 +885,7 @@ static void nfs4_session_set_rwsize(struct nfs_server *server) ...@@ -723,7 +885,7 @@ static void nfs4_session_set_rwsize(struct nfs_server *server)
} }
static int nfs4_server_common_setup(struct nfs_server *server, static int nfs4_server_common_setup(struct nfs_server *server,
struct nfs_fh *mntfh) struct nfs_fh *mntfh, bool auth_probe)
{ {
struct nfs_fattr *fattr; struct nfs_fattr *fattr;
int error; int error;
...@@ -755,7 +917,7 @@ static int nfs4_server_common_setup(struct nfs_server *server, ...@@ -755,7 +917,7 @@ static int nfs4_server_common_setup(struct nfs_server *server,
/* Probe the root fh to retrieve its FSID and filehandle */ /* Probe the root fh to retrieve its FSID and filehandle */
error = nfs4_get_rootfh(server, mntfh); error = nfs4_get_rootfh(server, mntfh, auth_probe);
if (error < 0) if (error < 0)
goto out; goto out;
...@@ -787,6 +949,7 @@ static int nfs4_server_common_setup(struct nfs_server *server, ...@@ -787,6 +949,7 @@ static int nfs4_server_common_setup(struct nfs_server *server,
static int nfs4_init_server(struct nfs_server *server, static int nfs4_init_server(struct nfs_server *server,
const struct nfs_parsed_mount_data *data) const struct nfs_parsed_mount_data *data)
{ {
rpc_authflavor_t pseudoflavor = RPC_AUTH_UNIX;
struct rpc_timeout timeparms; struct rpc_timeout timeparms;
int error; int error;
...@@ -799,13 +962,16 @@ static int nfs4_init_server(struct nfs_server *server, ...@@ -799,13 +962,16 @@ static int nfs4_init_server(struct nfs_server *server,
server->flags = data->flags; server->flags = data->flags;
server->options = data->options; server->options = data->options;
if (data->auth_flavor_len >= 1)
pseudoflavor = data->auth_flavors[0];
/* Get a client record */ /* Get a client record */
error = nfs4_set_client(server, error = nfs4_set_client(server,
data->nfs_server.hostname, data->nfs_server.hostname,
(const struct sockaddr *)&data->nfs_server.address, (const struct sockaddr *)&data->nfs_server.address,
data->nfs_server.addrlen, data->nfs_server.addrlen,
data->client_address, data->client_address,
data->auth_flavors[0], pseudoflavor,
data->nfs_server.protocol, data->nfs_server.protocol,
&timeparms, &timeparms,
data->minorversion, data->minorversion,
...@@ -825,7 +991,7 @@ static int nfs4_init_server(struct nfs_server *server, ...@@ -825,7 +991,7 @@ static int nfs4_init_server(struct nfs_server *server,
server->port = data->nfs_server.port; server->port = data->nfs_server.port;
error = nfs_init_server_rpcclient(server, &timeparms, data->auth_flavors[0]); error = nfs_init_server_rpcclient(server, &timeparms, pseudoflavor);
error: error:
/* Done */ /* Done */
...@@ -843,6 +1009,7 @@ struct nfs_server *nfs4_create_server(struct nfs_mount_info *mount_info, ...@@ -843,6 +1009,7 @@ struct nfs_server *nfs4_create_server(struct nfs_mount_info *mount_info,
struct nfs_subversion *nfs_mod) struct nfs_subversion *nfs_mod)
{ {
struct nfs_server *server; struct nfs_server *server;
bool auth_probe;
int error; int error;
dprintk("--> nfs4_create_server()\n"); dprintk("--> nfs4_create_server()\n");
...@@ -851,12 +1018,14 @@ struct nfs_server *nfs4_create_server(struct nfs_mount_info *mount_info, ...@@ -851,12 +1018,14 @@ struct nfs_server *nfs4_create_server(struct nfs_mount_info *mount_info,
if (!server) if (!server)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
auth_probe = mount_info->parsed->auth_flavor_len < 1;
/* set up the general RPC client */ /* set up the general RPC client */
error = nfs4_init_server(server, mount_info->parsed); error = nfs4_init_server(server, mount_info->parsed);
if (error < 0) if (error < 0)
goto error; goto error;
error = nfs4_server_common_setup(server, mount_info->mntfh); error = nfs4_server_common_setup(server, mount_info->mntfh, auth_probe);
if (error < 0) if (error < 0)
goto error; goto error;
...@@ -909,7 +1078,8 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, ...@@ -909,7 +1078,8 @@ struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data,
if (error < 0) if (error < 0)
goto error; goto error;
error = nfs4_server_common_setup(server, mntfh); error = nfs4_server_common_setup(server, mntfh,
!(parent_server->flags & NFS_MOUNT_SECFLAVOUR));
if (error < 0) if (error < 0)
goto error; goto error;
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "internal.h" #include "internal.h"
#include "delegation.h" #include "delegation.h"
#include "nfs4filelayout.h" #include "nfs4filelayout.h"
#include "nfs4trace.h"
#define NFSDBG_FACILITY NFSDBG_PNFS_LD #define NFSDBG_FACILITY NFSDBG_PNFS_LD
...@@ -247,6 +248,7 @@ static int filelayout_read_done_cb(struct rpc_task *task, ...@@ -247,6 +248,7 @@ static int filelayout_read_done_cb(struct rpc_task *task,
struct nfs_pgio_header *hdr = data->header; struct nfs_pgio_header *hdr = data->header;
int err; int err;
trace_nfs4_pnfs_read(data, task->tk_status);
err = filelayout_async_handle_error(task, data->args.context->state, err = filelayout_async_handle_error(task, data->args.context->state,
data->ds_clp, hdr->lseg); data->ds_clp, hdr->lseg);
...@@ -363,6 +365,7 @@ static int filelayout_write_done_cb(struct rpc_task *task, ...@@ -363,6 +365,7 @@ static int filelayout_write_done_cb(struct rpc_task *task,
struct nfs_pgio_header *hdr = data->header; struct nfs_pgio_header *hdr = data->header;
int err; int err;
trace_nfs4_pnfs_write(data, task->tk_status);
err = filelayout_async_handle_error(task, data->args.context->state, err = filelayout_async_handle_error(task, data->args.context->state,
data->ds_clp, hdr->lseg); data->ds_clp, hdr->lseg);
...@@ -395,6 +398,7 @@ static int filelayout_commit_done_cb(struct rpc_task *task, ...@@ -395,6 +398,7 @@ static int filelayout_commit_done_cb(struct rpc_task *task,
{ {
int err; int err;
trace_nfs4_pnfs_commit_ds(data, task->tk_status);
err = filelayout_async_handle_error(task, NULL, data->ds_clp, err = filelayout_async_handle_error(task, NULL, data->ds_clp,
data->lseg); data->lseg);
...@@ -524,6 +528,7 @@ filelayout_read_pagelist(struct nfs_read_data *data) ...@@ -524,6 +528,7 @@ filelayout_read_pagelist(struct nfs_read_data *data)
struct nfs_pgio_header *hdr = data->header; struct nfs_pgio_header *hdr = data->header;
struct pnfs_layout_segment *lseg = hdr->lseg; struct pnfs_layout_segment *lseg = hdr->lseg;
struct nfs4_pnfs_ds *ds; struct nfs4_pnfs_ds *ds;
struct rpc_clnt *ds_clnt;
loff_t offset = data->args.offset; loff_t offset = data->args.offset;
u32 j, idx; u32 j, idx;
struct nfs_fh *fh; struct nfs_fh *fh;
...@@ -538,6 +543,11 @@ filelayout_read_pagelist(struct nfs_read_data *data) ...@@ -538,6 +543,11 @@ filelayout_read_pagelist(struct nfs_read_data *data)
ds = nfs4_fl_prepare_ds(lseg, idx); ds = nfs4_fl_prepare_ds(lseg, idx);
if (!ds) if (!ds)
return PNFS_NOT_ATTEMPTED; return PNFS_NOT_ATTEMPTED;
ds_clnt = nfs4_find_or_create_ds_client(ds->ds_clp, hdr->inode);
if (IS_ERR(ds_clnt))
return PNFS_NOT_ATTEMPTED;
dprintk("%s USE DS: %s cl_count %d\n", __func__, dprintk("%s USE DS: %s cl_count %d\n", __func__,
ds->ds_remotestr, atomic_read(&ds->ds_clp->cl_count)); ds->ds_remotestr, atomic_read(&ds->ds_clp->cl_count));
...@@ -552,7 +562,7 @@ filelayout_read_pagelist(struct nfs_read_data *data) ...@@ -552,7 +562,7 @@ filelayout_read_pagelist(struct nfs_read_data *data)
data->mds_offset = offset; data->mds_offset = offset;
/* Perform an asynchronous read to ds */ /* Perform an asynchronous read to ds */
nfs_initiate_read(ds->ds_clp->cl_rpcclient, data, nfs_initiate_read(ds_clnt, data,
&filelayout_read_call_ops, RPC_TASK_SOFTCONN); &filelayout_read_call_ops, RPC_TASK_SOFTCONN);
return PNFS_ATTEMPTED; return PNFS_ATTEMPTED;
} }
...@@ -564,6 +574,7 @@ filelayout_write_pagelist(struct nfs_write_data *data, int sync) ...@@ -564,6 +574,7 @@ filelayout_write_pagelist(struct nfs_write_data *data, int sync)
struct nfs_pgio_header *hdr = data->header; struct nfs_pgio_header *hdr = data->header;
struct pnfs_layout_segment *lseg = hdr->lseg; struct pnfs_layout_segment *lseg = hdr->lseg;
struct nfs4_pnfs_ds *ds; struct nfs4_pnfs_ds *ds;
struct rpc_clnt *ds_clnt;
loff_t offset = data->args.offset; loff_t offset = data->args.offset;
u32 j, idx; u32 j, idx;
struct nfs_fh *fh; struct nfs_fh *fh;
...@@ -574,6 +585,11 @@ filelayout_write_pagelist(struct nfs_write_data *data, int sync) ...@@ -574,6 +585,11 @@ filelayout_write_pagelist(struct nfs_write_data *data, int sync)
ds = nfs4_fl_prepare_ds(lseg, idx); ds = nfs4_fl_prepare_ds(lseg, idx);
if (!ds) if (!ds)
return PNFS_NOT_ATTEMPTED; return PNFS_NOT_ATTEMPTED;
ds_clnt = nfs4_find_or_create_ds_client(ds->ds_clp, hdr->inode);
if (IS_ERR(ds_clnt))
return PNFS_NOT_ATTEMPTED;
dprintk("%s ino %lu sync %d req %Zu@%llu DS: %s cl_count %d\n", dprintk("%s ino %lu sync %d req %Zu@%llu DS: %s cl_count %d\n",
__func__, hdr->inode->i_ino, sync, (size_t) data->args.count, __func__, hdr->inode->i_ino, sync, (size_t) data->args.count,
offset, ds->ds_remotestr, atomic_read(&ds->ds_clp->cl_count)); offset, ds->ds_remotestr, atomic_read(&ds->ds_clp->cl_count));
...@@ -591,7 +607,7 @@ filelayout_write_pagelist(struct nfs_write_data *data, int sync) ...@@ -591,7 +607,7 @@ filelayout_write_pagelist(struct nfs_write_data *data, int sync)
data->args.offset = filelayout_get_dserver_offset(lseg, offset); data->args.offset = filelayout_get_dserver_offset(lseg, offset);
/* Perform an asynchronous write */ /* Perform an asynchronous write */
nfs_initiate_write(ds->ds_clp->cl_rpcclient, data, nfs_initiate_write(ds_clnt, data,
&filelayout_write_call_ops, sync, &filelayout_write_call_ops, sync,
RPC_TASK_SOFTCONN); RPC_TASK_SOFTCONN);
return PNFS_ATTEMPTED; return PNFS_ATTEMPTED;
...@@ -1101,16 +1117,19 @@ static int filelayout_initiate_commit(struct nfs_commit_data *data, int how) ...@@ -1101,16 +1117,19 @@ static int filelayout_initiate_commit(struct nfs_commit_data *data, int how)
{ {
struct pnfs_layout_segment *lseg = data->lseg; struct pnfs_layout_segment *lseg = data->lseg;
struct nfs4_pnfs_ds *ds; struct nfs4_pnfs_ds *ds;
struct rpc_clnt *ds_clnt;
u32 idx; u32 idx;
struct nfs_fh *fh; struct nfs_fh *fh;
idx = calc_ds_index_from_commit(lseg, data->ds_commit_index); idx = calc_ds_index_from_commit(lseg, data->ds_commit_index);
ds = nfs4_fl_prepare_ds(lseg, idx); ds = nfs4_fl_prepare_ds(lseg, idx);
if (!ds) { if (!ds)
prepare_to_resend_writes(data); goto out_err;
filelayout_commit_release(data);
return -EAGAIN; ds_clnt = nfs4_find_or_create_ds_client(ds->ds_clp, data->inode);
} if (IS_ERR(ds_clnt))
goto out_err;
dprintk("%s ino %lu, how %d cl_count %d\n", __func__, dprintk("%s ino %lu, how %d cl_count %d\n", __func__,
data->inode->i_ino, how, atomic_read(&ds->ds_clp->cl_count)); data->inode->i_ino, how, atomic_read(&ds->ds_clp->cl_count));
data->commit_done_cb = filelayout_commit_done_cb; data->commit_done_cb = filelayout_commit_done_cb;
...@@ -1119,9 +1138,13 @@ static int filelayout_initiate_commit(struct nfs_commit_data *data, int how) ...@@ -1119,9 +1138,13 @@ static int filelayout_initiate_commit(struct nfs_commit_data *data, int how)
fh = select_ds_fh_from_commit(lseg, data->ds_commit_index); fh = select_ds_fh_from_commit(lseg, data->ds_commit_index);
if (fh) if (fh)
data->args.fh = fh; data->args.fh = fh;
return nfs_initiate_commit(ds->ds_clp->cl_rpcclient, data, return nfs_initiate_commit(ds_clnt, data,
&filelayout_commit_call_ops, how, &filelayout_commit_call_ops, how,
RPC_TASK_SOFTCONN); RPC_TASK_SOFTCONN);
out_err:
prepare_to_resend_writes(data);
filelayout_commit_release(data);
return -EAGAIN;
} }
static int static int
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#define NFSDBG_FACILITY NFSDBG_CLIENT #define NFSDBG_FACILITY NFSDBG_CLIENT
int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh) int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh, bool auth_probe)
{ {
struct nfs_fsinfo fsinfo; struct nfs_fsinfo fsinfo;
int ret = -ENOMEM; int ret = -ENOMEM;
...@@ -21,7 +21,7 @@ int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh) ...@@ -21,7 +21,7 @@ int nfs4_get_rootfh(struct nfs_server *server, struct nfs_fh *mntfh)
goto out; goto out;
/* Start by getting the root filehandle from the server */ /* Start by getting the root filehandle from the server */
ret = nfs4_proc_get_rootfh(server, mntfh, &fsinfo); ret = nfs4_proc_get_rootfh(server, mntfh, &fsinfo, auth_probe);
if (ret < 0) { if (ret < 0) {
dprintk("nfs4_get_rootfh: getroot error = %d\n", -ret); dprintk("nfs4_get_rootfh: getroot error = %d\n", -ret);
goto out; goto out;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/nfs_fs.h> #include <linux/nfs_fs.h>
#include <linux/nfs_mount.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/clnt.h>
...@@ -369,21 +370,33 @@ static struct vfsmount *nfs_do_refmount(struct rpc_clnt *client, struct dentry * ...@@ -369,21 +370,33 @@ static struct vfsmount *nfs_do_refmount(struct rpc_clnt *client, struct dentry *
struct vfsmount *nfs4_submount(struct nfs_server *server, struct dentry *dentry, struct vfsmount *nfs4_submount(struct nfs_server *server, struct dentry *dentry,
struct nfs_fh *fh, struct nfs_fattr *fattr) struct nfs_fh *fh, struct nfs_fattr *fattr)
{ {
rpc_authflavor_t flavor = server->client->cl_auth->au_flavor;
struct dentry *parent = dget_parent(dentry); struct dentry *parent = dget_parent(dentry);
struct inode *dir = parent->d_inode;
struct qstr *name = &dentry->d_name;
struct rpc_clnt *client; struct rpc_clnt *client;
struct vfsmount *mnt; struct vfsmount *mnt;
/* Look it up again to get its attributes and sec flavor */ /* Look it up again to get its attributes and sec flavor */
client = nfs4_proc_lookup_mountpoint(parent->d_inode, &dentry->d_name, fh, fattr); client = nfs4_proc_lookup_mountpoint(dir, name, fh, fattr);
dput(parent); dput(parent);
if (IS_ERR(client)) if (IS_ERR(client))
return ERR_CAST(client); return ERR_CAST(client);
if (fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) if (fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) {
mnt = nfs_do_refmount(client, dentry); mnt = nfs_do_refmount(client, dentry);
else goto out;
mnt = nfs_do_submount(dentry, fh, fattr, client->cl_auth->au_flavor); }
if (client->cl_auth->au_flavor != flavor)
flavor = client->cl_auth->au_flavor;
else if (!(server->flags & NFS_MOUNT_SECFLAVOUR)) {
rpc_authflavor_t new = nfs4_negotiate_security(dir, name);
if ((int)new >= 0)
flavor = new;
}
mnt = nfs_do_submount(dentry, fh, fattr, flavor);
out:
rpc_shutdown_client(client); rpc_shutdown_client(client);
return mnt; return mnt;
} }
This diff is collapsed.
...@@ -23,6 +23,14 @@ ...@@ -23,6 +23,14 @@
#define NFSDBG_FACILITY NFSDBG_STATE #define NFSDBG_FACILITY NFSDBG_STATE
static void nfs4_init_slot_table(struct nfs4_slot_table *tbl, const char *queue)
{
tbl->highest_used_slotid = NFS4_NO_SLOT;
spin_lock_init(&tbl->slot_tbl_lock);
rpc_init_priority_wait_queue(&tbl->slot_tbl_waitq, queue);
init_completion(&tbl->complete);
}
/* /*
* nfs4_shrink_slot_table - free retired slots from the slot table * nfs4_shrink_slot_table - free retired slots from the slot table
*/ */
...@@ -44,6 +52,17 @@ static void nfs4_shrink_slot_table(struct nfs4_slot_table *tbl, u32 newsize) ...@@ -44,6 +52,17 @@ static void nfs4_shrink_slot_table(struct nfs4_slot_table *tbl, u32 newsize)
} }
} }
/**
* nfs4_slot_tbl_drain_complete - wake waiters when drain is complete
* @tbl - controlling slot table
*
*/
void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl)
{
if (nfs4_slot_tbl_draining(tbl))
complete(&tbl->complete);
}
/* /*
* nfs4_free_slot - free a slot and efficiently update slot table. * nfs4_free_slot - free a slot and efficiently update slot table.
* *
...@@ -76,7 +95,7 @@ void nfs4_free_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot) ...@@ -76,7 +95,7 @@ void nfs4_free_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot)
nfs4_slot_tbl_drain_complete(tbl); nfs4_slot_tbl_drain_complete(tbl);
} }
} }
dprintk("%s: slotid %u highest_used_slotid %d\n", __func__, dprintk("%s: slotid %u highest_used_slotid %u\n", __func__,
slotid, tbl->highest_used_slotid); slotid, tbl->highest_used_slotid);
} }
...@@ -146,9 +165,9 @@ struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl) ...@@ -146,9 +165,9 @@ struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl)
ret->generation = tbl->generation; ret->generation = tbl->generation;
out: out:
dprintk("<-- %s used_slots=%04lx highest_used=%d slotid=%d \n", dprintk("<-- %s used_slots=%04lx highest_used=%u slotid=%u\n",
__func__, tbl->used_slots[0], tbl->highest_used_slotid, __func__, tbl->used_slots[0], tbl->highest_used_slotid,
!IS_ERR(ret) ? ret->slot_nr : -1); !IS_ERR(ret) ? ret->slot_nr : NFS4_NO_SLOT);
return ret; return ret;
} }
...@@ -191,7 +210,7 @@ static int nfs4_realloc_slot_table(struct nfs4_slot_table *tbl, ...@@ -191,7 +210,7 @@ static int nfs4_realloc_slot_table(struct nfs4_slot_table *tbl,
{ {
int ret; int ret;
dprintk("--> %s: max_reqs=%u, tbl->max_slots %d\n", __func__, dprintk("--> %s: max_reqs=%u, tbl->max_slots %u\n", __func__,
max_reqs, tbl->max_slots); max_reqs, tbl->max_slots);
if (max_reqs > NFS4_MAX_SLOT_TABLE) if (max_reqs > NFS4_MAX_SLOT_TABLE)
...@@ -205,18 +224,36 @@ static int nfs4_realloc_slot_table(struct nfs4_slot_table *tbl, ...@@ -205,18 +224,36 @@ static int nfs4_realloc_slot_table(struct nfs4_slot_table *tbl,
nfs4_reset_slot_table(tbl, max_reqs - 1, ivalue); nfs4_reset_slot_table(tbl, max_reqs - 1, ivalue);
spin_unlock(&tbl->slot_tbl_lock); spin_unlock(&tbl->slot_tbl_lock);
dprintk("%s: tbl=%p slots=%p max_slots=%d\n", __func__, dprintk("%s: tbl=%p slots=%p max_slots=%u\n", __func__,
tbl, tbl->slots, tbl->max_slots); tbl, tbl->slots, tbl->max_slots);
out: out:
dprintk("<-- %s: return %d\n", __func__, ret); dprintk("<-- %s: return %d\n", __func__, ret);
return ret; return ret;
} }
/* Destroy the slot table */ /**
static void nfs4_destroy_slot_tables(struct nfs4_session *session) * nfs4_release_slot_table - release resources attached to a slot table
* @tbl: slot table to shut down
*
*/
void nfs4_release_slot_table(struct nfs4_slot_table *tbl)
{
nfs4_shrink_slot_table(tbl, 0);
}
/**
* nfs4_setup_slot_table - prepare a stand-alone slot table for use
* @tbl: slot table to set up
* @max_reqs: maximum number of requests allowed
* @queue: name to give RPC wait queue
*
* Returns zero on success, or a negative errno.
*/
int nfs4_setup_slot_table(struct nfs4_slot_table *tbl, unsigned int max_reqs,
const char *queue)
{ {
nfs4_shrink_slot_table(&session->fc_slot_table, 0); nfs4_init_slot_table(tbl, queue);
nfs4_shrink_slot_table(&session->bc_slot_table, 0); return nfs4_realloc_slot_table(tbl, max_reqs, 0);
} }
static bool nfs41_assign_slot(struct rpc_task *task, void *pslot) static bool nfs41_assign_slot(struct rpc_task *task, void *pslot)
...@@ -273,6 +310,8 @@ void nfs41_wake_slot_table(struct nfs4_slot_table *tbl) ...@@ -273,6 +310,8 @@ void nfs41_wake_slot_table(struct nfs4_slot_table *tbl)
} }
} }
#if defined(CONFIG_NFS_V4_1)
static void nfs41_set_max_slotid_locked(struct nfs4_slot_table *tbl, static void nfs41_set_max_slotid_locked(struct nfs4_slot_table *tbl,
u32 target_highest_slotid) u32 target_highest_slotid)
{ {
...@@ -383,6 +422,12 @@ void nfs41_update_target_slotid(struct nfs4_slot_table *tbl, ...@@ -383,6 +422,12 @@ void nfs41_update_target_slotid(struct nfs4_slot_table *tbl,
spin_unlock(&tbl->slot_tbl_lock); spin_unlock(&tbl->slot_tbl_lock);
} }
static void nfs4_destroy_session_slot_tables(struct nfs4_session *session)
{
nfs4_release_slot_table(&session->fc_slot_table);
nfs4_release_slot_table(&session->bc_slot_table);
}
/* /*
* Initialize or reset the forechannel and backchannel tables * Initialize or reset the forechannel and backchannel tables
*/ */
...@@ -405,31 +450,20 @@ int nfs4_setup_session_slot_tables(struct nfs4_session *ses) ...@@ -405,31 +450,20 @@ int nfs4_setup_session_slot_tables(struct nfs4_session *ses)
if (status && tbl->slots == NULL) if (status && tbl->slots == NULL)
/* Fore and back channel share a connection so get /* Fore and back channel share a connection so get
* both slot tables or neither */ * both slot tables or neither */
nfs4_destroy_slot_tables(ses); nfs4_destroy_session_slot_tables(ses);
return status; return status;
} }
struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp) struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp)
{ {
struct nfs4_session *session; struct nfs4_session *session;
struct nfs4_slot_table *tbl;
session = kzalloc(sizeof(struct nfs4_session), GFP_NOFS); session = kzalloc(sizeof(struct nfs4_session), GFP_NOFS);
if (!session) if (!session)
return NULL; return NULL;
tbl = &session->fc_slot_table; nfs4_init_slot_table(&session->fc_slot_table, "ForeChannel Slot table");
tbl->highest_used_slotid = NFS4_NO_SLOT; nfs4_init_slot_table(&session->bc_slot_table, "BackChannel Slot table");
spin_lock_init(&tbl->slot_tbl_lock);
rpc_init_priority_wait_queue(&tbl->slot_tbl_waitq, "ForeChannel Slot table");
init_completion(&tbl->complete);
tbl = &session->bc_slot_table;
tbl->highest_used_slotid = NFS4_NO_SLOT;
spin_lock_init(&tbl->slot_tbl_lock);
rpc_init_wait_queue(&tbl->slot_tbl_waitq, "BackChannel Slot table");
init_completion(&tbl->complete);
session->session_state = 1<<NFS4_SESSION_INITING; session->session_state = 1<<NFS4_SESSION_INITING;
session->clp = clp; session->clp = clp;
...@@ -441,7 +475,7 @@ void nfs4_destroy_session(struct nfs4_session *session) ...@@ -441,7 +475,7 @@ void nfs4_destroy_session(struct nfs4_session *session)
struct rpc_xprt *xprt; struct rpc_xprt *xprt;
struct rpc_cred *cred; struct rpc_cred *cred;
cred = nfs4_get_exchange_id_cred(session->clp); cred = nfs4_get_clid_cred(session->clp);
nfs4_proc_destroy_session(session, cred); nfs4_proc_destroy_session(session, cred);
if (cred) if (cred)
put_rpccred(cred); put_rpccred(cred);
...@@ -452,7 +486,7 @@ void nfs4_destroy_session(struct nfs4_session *session) ...@@ -452,7 +486,7 @@ void nfs4_destroy_session(struct nfs4_session *session)
dprintk("%s Destroy backchannel for xprt %p\n", dprintk("%s Destroy backchannel for xprt %p\n",
__func__, xprt); __func__, xprt);
xprt_destroy_backchannel(xprt, NFS41_BC_MIN_CALLBACKS); xprt_destroy_backchannel(xprt, NFS41_BC_MIN_CALLBACKS);
nfs4_destroy_slot_tables(session); nfs4_destroy_session_slot_tables(session);
kfree(session); kfree(session);
} }
...@@ -513,4 +547,4 @@ int nfs4_init_ds_session(struct nfs_client *clp, unsigned long lease_time) ...@@ -513,4 +547,4 @@ int nfs4_init_ds_session(struct nfs_client *clp, unsigned long lease_time)
} }
EXPORT_SYMBOL_GPL(nfs4_init_ds_session); EXPORT_SYMBOL_GPL(nfs4_init_ds_session);
#endif /* defined(CONFIG_NFS_V4_1) */
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#define __LINUX_FS_NFS_NFS4SESSION_H #define __LINUX_FS_NFS_NFS4SESSION_H
/* maximum number of slots to use */ /* maximum number of slots to use */
#define NFS4_DEF_SLOT_TABLE_SIZE (16U) #define NFS4_DEF_SLOT_TABLE_SIZE (64U)
#define NFS4_MAX_SLOT_TABLE (1024U) #define NFS4_MAX_SLOT_TABLE (1024U)
#define NFS4_NO_SLOT ((u32)-1) #define NFS4_NO_SLOT ((u32)-1)
...@@ -72,10 +72,22 @@ enum nfs4_session_state { ...@@ -72,10 +72,22 @@ enum nfs4_session_state {
NFS4_SESSION_INITING, NFS4_SESSION_INITING,
}; };
#if defined(CONFIG_NFS_V4_1) extern int nfs4_setup_slot_table(struct nfs4_slot_table *tbl,
unsigned int max_reqs, const char *queue);
extern void nfs4_release_slot_table(struct nfs4_slot_table *tbl);
extern struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl); extern struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl);
extern void nfs4_free_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot); extern void nfs4_free_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot);
extern void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl);
bool nfs41_wake_and_assign_slot(struct nfs4_slot_table *tbl,
struct nfs4_slot *slot);
void nfs41_wake_slot_table(struct nfs4_slot_table *tbl);
static inline bool nfs4_slot_tbl_draining(struct nfs4_slot_table *tbl)
{
return !!test_bit(NFS4_SLOT_TBL_DRAINING, &tbl->slot_tbl_state);
}
#if defined(CONFIG_NFS_V4_1)
extern void nfs41_set_target_slotid(struct nfs4_slot_table *tbl, extern void nfs41_set_target_slotid(struct nfs4_slot_table *tbl,
u32 target_highest_slotid); u32 target_highest_slotid);
extern void nfs41_update_target_slotid(struct nfs4_slot_table *tbl, extern void nfs41_update_target_slotid(struct nfs4_slot_table *tbl,
...@@ -89,17 +101,6 @@ extern void nfs4_destroy_session(struct nfs4_session *session); ...@@ -89,17 +101,6 @@ extern void nfs4_destroy_session(struct nfs4_session *session);
extern int nfs4_init_session(struct nfs_client *clp); extern int nfs4_init_session(struct nfs_client *clp);
extern int nfs4_init_ds_session(struct nfs_client *, unsigned long); extern int nfs4_init_ds_session(struct nfs_client *, unsigned long);
extern void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl);
static inline bool nfs4_slot_tbl_draining(struct nfs4_slot_table *tbl)
{
return !!test_bit(NFS4_SLOT_TBL_DRAINING, &tbl->slot_tbl_state);
}
bool nfs41_wake_and_assign_slot(struct nfs4_slot_table *tbl,
struct nfs4_slot *slot);
void nfs41_wake_slot_table(struct nfs4_slot_table *tbl);
/* /*
* Determine if sessions are in use. * Determine if sessions are in use.
*/ */
...@@ -117,6 +118,16 @@ static inline int nfs4_has_persistent_session(const struct nfs_client *clp) ...@@ -117,6 +118,16 @@ static inline int nfs4_has_persistent_session(const struct nfs_client *clp)
return 0; return 0;
} }
#ifdef CONFIG_CRC32
/*
* nfs_session_id_hash - calculate the crc32 hash for the session id
* @session - pointer to session
*/
#define nfs_session_id_hash(sess_id) \
(~crc32_le(0xFFFFFFFF, &(sess_id)->data[0], sizeof((sess_id)->data)))
#else
#define nfs_session_id_hash(session) (0)
#endif
#else /* defined(CONFIG_NFS_V4_1) */ #else /* defined(CONFIG_NFS_V4_1) */
static inline int nfs4_init_session(struct nfs_client *clp) static inline int nfs4_init_session(struct nfs_client *clp)
......
...@@ -154,6 +154,19 @@ struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp) ...@@ -154,6 +154,19 @@ struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp)
return cred; return cred;
} }
static void nfs4_root_machine_cred(struct nfs_client *clp)
{
struct rpc_cred *cred, *new;
new = rpc_lookup_machine_cred(NULL);
spin_lock(&clp->cl_lock);
cred = clp->cl_machine_cred;
clp->cl_machine_cred = new;
spin_unlock(&clp->cl_lock);
if (cred != NULL)
put_rpccred(cred);
}
static struct rpc_cred * static struct rpc_cred *
nfs4_get_renew_cred_server_locked(struct nfs_server *server) nfs4_get_renew_cred_server_locked(struct nfs_server *server)
{ {
...@@ -202,32 +215,6 @@ struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp) ...@@ -202,32 +215,6 @@ struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp)
return cred; return cred;
} }
#if defined(CONFIG_NFS_V4_1)
static int nfs41_setup_state_renewal(struct nfs_client *clp)
{
int status;
struct nfs_fsinfo fsinfo;
if (!test_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state)) {
nfs4_schedule_state_renewal(clp);
return 0;
}
status = nfs4_proc_get_lease_time(clp, &fsinfo);
if (status == 0) {
/* Update lease time and schedule renewal */
spin_lock(&clp->cl_lock);
clp->cl_lease_time = fsinfo.lease_time * HZ;
clp->cl_last_renewal = jiffies;
spin_unlock(&clp->cl_lock);
nfs4_schedule_state_renewal(clp);
}
return status;
}
static void nfs4_end_drain_slot_table(struct nfs4_slot_table *tbl) static void nfs4_end_drain_slot_table(struct nfs4_slot_table *tbl)
{ {
if (test_and_clear_bit(NFS4_SLOT_TBL_DRAINING, &tbl->slot_tbl_state)) { if (test_and_clear_bit(NFS4_SLOT_TBL_DRAINING, &tbl->slot_tbl_state)) {
...@@ -241,20 +228,18 @@ static void nfs4_end_drain_session(struct nfs_client *clp) ...@@ -241,20 +228,18 @@ static void nfs4_end_drain_session(struct nfs_client *clp)
{ {
struct nfs4_session *ses = clp->cl_session; struct nfs4_session *ses = clp->cl_session;
if (clp->cl_slot_tbl) {
nfs4_end_drain_slot_table(clp->cl_slot_tbl);
return;
}
if (ses != NULL) { if (ses != NULL) {
nfs4_end_drain_slot_table(&ses->bc_slot_table); nfs4_end_drain_slot_table(&ses->bc_slot_table);
nfs4_end_drain_slot_table(&ses->fc_slot_table); nfs4_end_drain_slot_table(&ses->fc_slot_table);
} }
} }
/* #if defined(CONFIG_NFS_V4_1)
* Signal state manager thread if session fore channel is drained
*/
void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl)
{
if (nfs4_slot_tbl_draining(tbl))
complete(&tbl->complete);
}
static int nfs4_drain_slot_tbl(struct nfs4_slot_table *tbl) static int nfs4_drain_slot_tbl(struct nfs4_slot_table *tbl)
{ {
...@@ -274,6 +259,9 @@ static int nfs4_begin_drain_session(struct nfs_client *clp) ...@@ -274,6 +259,9 @@ static int nfs4_begin_drain_session(struct nfs_client *clp)
struct nfs4_session *ses = clp->cl_session; struct nfs4_session *ses = clp->cl_session;
int ret = 0; int ret = 0;
if (clp->cl_slot_tbl)
return nfs4_drain_slot_tbl(clp->cl_slot_tbl);
/* back channel */ /* back channel */
ret = nfs4_drain_slot_tbl(&ses->bc_slot_table); ret = nfs4_drain_slot_tbl(&ses->bc_slot_table);
if (ret) if (ret)
...@@ -282,6 +270,30 @@ static int nfs4_begin_drain_session(struct nfs_client *clp) ...@@ -282,6 +270,30 @@ static int nfs4_begin_drain_session(struct nfs_client *clp)
return nfs4_drain_slot_tbl(&ses->fc_slot_table); return nfs4_drain_slot_tbl(&ses->fc_slot_table);
} }
static int nfs41_setup_state_renewal(struct nfs_client *clp)
{
int status;
struct nfs_fsinfo fsinfo;
if (!test_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state)) {
nfs4_schedule_state_renewal(clp);
return 0;
}
status = nfs4_proc_get_lease_time(clp, &fsinfo);
if (status == 0) {
/* Update lease time and schedule renewal */
spin_lock(&clp->cl_lock);
clp->cl_lease_time = fsinfo.lease_time * HZ;
clp->cl_last_renewal = jiffies;
spin_unlock(&clp->cl_lock);
nfs4_schedule_state_renewal(clp);
}
return status;
}
static void nfs41_finish_session_reset(struct nfs_client *clp) static void nfs41_finish_session_reset(struct nfs_client *clp)
{ {
clear_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state); clear_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
...@@ -339,62 +351,21 @@ int nfs41_discover_server_trunking(struct nfs_client *clp, ...@@ -339,62 +351,21 @@ int nfs41_discover_server_trunking(struct nfs_client *clp,
return nfs41_walk_client_list(clp, result, cred); return nfs41_walk_client_list(clp, result, cred);
} }
struct rpc_cred *nfs4_get_exchange_id_cred(struct nfs_client *clp)
{
struct rpc_cred *cred;
spin_lock(&clp->cl_lock);
cred = nfs4_get_machine_cred_locked(clp);
spin_unlock(&clp->cl_lock);
return cred;
}
#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4_1 */
static struct rpc_cred *
nfs4_get_setclientid_cred_server(struct nfs_server *server)
{
struct nfs_client *clp = server->nfs_client;
struct rpc_cred *cred = NULL;
struct nfs4_state_owner *sp;
struct rb_node *pos;
spin_lock(&clp->cl_lock);
pos = rb_first(&server->state_owners);
if (pos != NULL) {
sp = rb_entry(pos, struct nfs4_state_owner, so_server_node);
cred = get_rpccred(sp->so_cred);
}
spin_unlock(&clp->cl_lock);
return cred;
}
/** /**
* nfs4_get_setclientid_cred - Acquire credential for a setclientid operation * nfs4_get_clid_cred - Acquire credential for a setclientid operation
* @clp: client state handle * @clp: client state handle
* *
* Returns an rpc_cred with reference count bumped, or NULL. * Returns an rpc_cred with reference count bumped, or NULL.
*/ */
struct rpc_cred *nfs4_get_setclientid_cred(struct nfs_client *clp) struct rpc_cred *nfs4_get_clid_cred(struct nfs_client *clp)
{ {
struct nfs_server *server;
struct rpc_cred *cred; struct rpc_cred *cred;
spin_lock(&clp->cl_lock); spin_lock(&clp->cl_lock);
cred = nfs4_get_machine_cred_locked(clp); cred = nfs4_get_machine_cred_locked(clp);
spin_unlock(&clp->cl_lock); spin_unlock(&clp->cl_lock);
if (cred != NULL)
goto out;
rcu_read_lock();
list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
cred = nfs4_get_setclientid_cred_server(server);
if (cred != NULL)
break;
}
rcu_read_unlock();
out:
return cred; return cred;
} }
...@@ -998,7 +969,9 @@ static int nfs4_copy_lock_stateid(nfs4_stateid *dst, ...@@ -998,7 +969,9 @@ static int nfs4_copy_lock_stateid(nfs4_stateid *dst,
fl_pid = lockowner->l_pid; fl_pid = lockowner->l_pid;
spin_lock(&state->state_lock); spin_lock(&state->state_lock);
lsp = __nfs4_find_lock_state(state, fl_owner, fl_pid, NFS4_ANY_LOCK_TYPE); lsp = __nfs4_find_lock_state(state, fl_owner, fl_pid, NFS4_ANY_LOCK_TYPE);
if (lsp != NULL && test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags) != 0) { if (lsp && test_bit(NFS_LOCK_LOST, &lsp->ls_flags))
ret = -EIO;
else if (lsp != NULL && test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags) != 0) {
nfs4_stateid_copy(dst, &lsp->ls_stateid); nfs4_stateid_copy(dst, &lsp->ls_stateid);
ret = 0; ret = 0;
smp_rmb(); smp_rmb();
...@@ -1038,11 +1011,17 @@ static int nfs4_copy_open_stateid(nfs4_stateid *dst, struct nfs4_state *state) ...@@ -1038,11 +1011,17 @@ static int nfs4_copy_open_stateid(nfs4_stateid *dst, struct nfs4_state *state)
int nfs4_select_rw_stateid(nfs4_stateid *dst, struct nfs4_state *state, int nfs4_select_rw_stateid(nfs4_stateid *dst, struct nfs4_state *state,
fmode_t fmode, const struct nfs_lockowner *lockowner) fmode_t fmode, const struct nfs_lockowner *lockowner)
{ {
int ret = 0; int ret = nfs4_copy_lock_stateid(dst, state, lockowner);
if (ret == -EIO)
/* A lost lock - don't even consider delegations */
goto out;
if (nfs4_copy_delegation_stateid(dst, state->inode, fmode)) if (nfs4_copy_delegation_stateid(dst, state->inode, fmode))
goto out; goto out;
ret = nfs4_copy_lock_stateid(dst, state, lockowner);
if (ret != -ENOENT) if (ret != -ENOENT)
/* nfs4_copy_delegation_stateid() didn't over-write
* dst, so it still has the lock stateid which we now
* choose to use.
*/
goto out; goto out;
ret = nfs4_copy_open_stateid(dst, state); ret = nfs4_copy_open_stateid(dst, state);
out: out:
...@@ -1443,6 +1422,7 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs ...@@ -1443,6 +1422,7 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs
if (status >= 0) { if (status >= 0) {
status = nfs4_reclaim_locks(state, ops); status = nfs4_reclaim_locks(state, ops);
if (status >= 0) { if (status >= 0) {
if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) {
spin_lock(&state->state_lock); spin_lock(&state->state_lock);
list_for_each_entry(lock, &state->lock_states, ls_locks) { list_for_each_entry(lock, &state->lock_states, ls_locks) {
if (!test_bit(NFS_LOCK_INITIALIZED, &lock->ls_flags)) if (!test_bit(NFS_LOCK_INITIALIZED, &lock->ls_flags))
...@@ -1451,6 +1431,7 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs ...@@ -1451,6 +1431,7 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs
"failed!\n", __func__); "failed!\n", __func__);
} }
spin_unlock(&state->state_lock); spin_unlock(&state->state_lock);
}
nfs4_put_open_state(state); nfs4_put_open_state(state);
spin_lock(&sp->so_lock); spin_lock(&sp->so_lock);
goto restart; goto restart;
...@@ -1618,7 +1599,7 @@ static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp) ...@@ -1618,7 +1599,7 @@ static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp)
if (!nfs4_state_clear_reclaim_reboot(clp)) if (!nfs4_state_clear_reclaim_reboot(clp))
return; return;
ops = clp->cl_mvops->reboot_recovery_ops; ops = clp->cl_mvops->reboot_recovery_ops;
cred = ops->get_clid_cred(clp); cred = nfs4_get_clid_cred(clp);
nfs4_reclaim_complete(clp, ops, cred); nfs4_reclaim_complete(clp, ops, cred);
put_rpccred(cred); put_rpccred(cred);
} }
...@@ -1732,7 +1713,7 @@ static int nfs4_check_lease(struct nfs_client *clp) ...@@ -1732,7 +1713,7 @@ static int nfs4_check_lease(struct nfs_client *clp)
cred = ops->get_state_renewal_cred_locked(clp); cred = ops->get_state_renewal_cred_locked(clp);
spin_unlock(&clp->cl_lock); spin_unlock(&clp->cl_lock);
if (cred == NULL) { if (cred == NULL) {
cred = nfs4_get_setclientid_cred(clp); cred = nfs4_get_clid_cred(clp);
status = -ENOKEY; status = -ENOKEY;
if (cred == NULL) if (cred == NULL)
goto out; goto out;
...@@ -1804,7 +1785,7 @@ static int nfs4_establish_lease(struct nfs_client *clp) ...@@ -1804,7 +1785,7 @@ static int nfs4_establish_lease(struct nfs_client *clp)
clp->cl_mvops->reboot_recovery_ops; clp->cl_mvops->reboot_recovery_ops;
int status; int status;
cred = ops->get_clid_cred(clp); cred = nfs4_get_clid_cred(clp);
if (cred == NULL) if (cred == NULL)
return -ENOENT; return -ENOENT;
status = ops->establish_clid(clp, cred); status = ops->establish_clid(clp, cred);
...@@ -1878,7 +1859,7 @@ int nfs4_discover_server_trunking(struct nfs_client *clp, ...@@ -1878,7 +1859,7 @@ int nfs4_discover_server_trunking(struct nfs_client *clp,
mutex_lock(&nfs_clid_init_mutex); mutex_lock(&nfs_clid_init_mutex);
again: again:
status = -ENOENT; status = -ENOENT;
cred = ops->get_clid_cred(clp); cred = nfs4_get_clid_cred(clp);
if (cred == NULL) if (cred == NULL)
goto out_unlock; goto out_unlock;
...@@ -1896,7 +1877,11 @@ int nfs4_discover_server_trunking(struct nfs_client *clp, ...@@ -1896,7 +1877,11 @@ int nfs4_discover_server_trunking(struct nfs_client *clp,
__func__, status); __func__, status);
goto again; goto again;
case -EACCES: case -EACCES:
if (i++) if (i++ == 0) {
nfs4_root_machine_cred(clp);
goto again;
}
if (i > 2)
break; break;
case -NFS4ERR_CLID_INUSE: case -NFS4ERR_CLID_INUSE:
case -NFS4ERR_WRONGSEC: case -NFS4ERR_WRONGSEC:
...@@ -2052,7 +2037,7 @@ static int nfs4_reset_session(struct nfs_client *clp) ...@@ -2052,7 +2037,7 @@ static int nfs4_reset_session(struct nfs_client *clp)
if (!nfs4_has_session(clp)) if (!nfs4_has_session(clp))
return 0; return 0;
nfs4_begin_drain_session(clp); nfs4_begin_drain_session(clp);
cred = nfs4_get_exchange_id_cred(clp); cred = nfs4_get_clid_cred(clp);
status = nfs4_proc_destroy_session(clp->cl_session, cred); status = nfs4_proc_destroy_session(clp->cl_session, cred);
switch (status) { switch (status) {
case 0: case 0:
...@@ -2095,7 +2080,7 @@ static int nfs4_bind_conn_to_session(struct nfs_client *clp) ...@@ -2095,7 +2080,7 @@ static int nfs4_bind_conn_to_session(struct nfs_client *clp)
if (!nfs4_has_session(clp)) if (!nfs4_has_session(clp))
return 0; return 0;
nfs4_begin_drain_session(clp); nfs4_begin_drain_session(clp);
cred = nfs4_get_exchange_id_cred(clp); cred = nfs4_get_clid_cred(clp);
ret = nfs4_proc_bind_conn_to_session(clp, cred); ret = nfs4_proc_bind_conn_to_session(clp, cred);
if (cred) if (cred)
put_rpccred(cred); put_rpccred(cred);
...@@ -2116,7 +2101,6 @@ static int nfs4_bind_conn_to_session(struct nfs_client *clp) ...@@ -2116,7 +2101,6 @@ static int nfs4_bind_conn_to_session(struct nfs_client *clp)
} }
#else /* CONFIG_NFS_V4_1 */ #else /* CONFIG_NFS_V4_1 */
static int nfs4_reset_session(struct nfs_client *clp) { return 0; } static int nfs4_reset_session(struct nfs_client *clp) { return 0; }
static int nfs4_end_drain_session(struct nfs_client *clp) { return 0; }
static int nfs4_bind_conn_to_session(struct nfs_client *clp) static int nfs4_bind_conn_to_session(struct nfs_client *clp)
{ {
......
...@@ -253,8 +253,6 @@ struct dentry *nfs4_try_mount(int flags, const char *dev_name, ...@@ -253,8 +253,6 @@ struct dentry *nfs4_try_mount(int flags, const char *dev_name,
dfprintk(MOUNT, "--> nfs4_try_mount()\n"); dfprintk(MOUNT, "--> nfs4_try_mount()\n");
if (data->auth_flavors[0] == RPC_AUTH_MAXFLAVOR)
data->auth_flavors[0] = RPC_AUTH_UNIX;
export_path = data->nfs_server.export_path; export_path = data->nfs_server.export_path;
data->nfs_server.export_path = "/"; data->nfs_server.export_path = "/";
root_mnt = nfs_do_root_mount(&nfs4_remote_fs_type, flags, mount_info, root_mnt = nfs_do_root_mount(&nfs4_remote_fs_type, flags, mount_info,
......
/*
* Copyright (c) 2013 Trond Myklebust <Trond.Myklebust@netapp.com>
*/
#include <linux/nfs_fs.h>
#include "nfs4_fs.h"
#include "internal.h"
#include "nfs4session.h"
#include "callback.h"
#define CREATE_TRACE_POINTS
#include "nfs4trace.h"
#ifdef CONFIG_NFS_V4_1
EXPORT_TRACEPOINT_SYMBOL_GPL(nfs4_pnfs_read);
EXPORT_TRACEPOINT_SYMBOL_GPL(nfs4_pnfs_write);
EXPORT_TRACEPOINT_SYMBOL_GPL(nfs4_pnfs_commit_ds);
#endif
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (c) 2013 Trond Myklebust <Trond.Myklebust@netapp.com>
*/
#include <linux/nfs_fs.h>
#include <linux/namei.h>
#include "internal.h"
#define CREATE_TRACE_POINTS
#include "nfstrace.h"
This diff is collapsed.
...@@ -328,6 +328,19 @@ void nfs_pageio_init(struct nfs_pageio_descriptor *desc, ...@@ -328,6 +328,19 @@ void nfs_pageio_init(struct nfs_pageio_descriptor *desc,
} }
EXPORT_SYMBOL_GPL(nfs_pageio_init); EXPORT_SYMBOL_GPL(nfs_pageio_init);
static bool nfs_match_open_context(const struct nfs_open_context *ctx1,
const struct nfs_open_context *ctx2)
{
return ctx1->cred == ctx2->cred && ctx1->state == ctx2->state;
}
static bool nfs_match_lock_context(const struct nfs_lock_context *l1,
const struct nfs_lock_context *l2)
{
return l1->lockowner.l_owner == l2->lockowner.l_owner
&& l1->lockowner.l_pid == l2->lockowner.l_pid;
}
/** /**
* nfs_can_coalesce_requests - test two requests for compatibility * nfs_can_coalesce_requests - test two requests for compatibility
* @prev: pointer to nfs_page * @prev: pointer to nfs_page
...@@ -343,13 +356,10 @@ static bool nfs_can_coalesce_requests(struct nfs_page *prev, ...@@ -343,13 +356,10 @@ static bool nfs_can_coalesce_requests(struct nfs_page *prev,
struct nfs_page *req, struct nfs_page *req,
struct nfs_pageio_descriptor *pgio) struct nfs_pageio_descriptor *pgio)
{ {
if (req->wb_context->cred != prev->wb_context->cred) if (!nfs_match_open_context(req->wb_context, prev->wb_context))
return false;
if (req->wb_lock_context->lockowner.l_owner != prev->wb_lock_context->lockowner.l_owner)
return false;
if (req->wb_lock_context->lockowner.l_pid != prev->wb_lock_context->lockowner.l_pid)
return false; return false;
if (req->wb_context->state != prev->wb_context->state) if (req->wb_context->dentry->d_inode->i_flock != NULL &&
!nfs_match_lock_context(req->wb_lock_context, prev->wb_lock_context))
return false; return false;
if (req->wb_pgbase != 0) if (req->wb_pgbase != 0)
return false; return false;
......
This diff is collapsed.
This diff is collapsed.
...@@ -513,9 +513,10 @@ static void nfs_readpage_release_common(void *calldata) ...@@ -513,9 +513,10 @@ static void nfs_readpage_release_common(void *calldata)
void nfs_read_prepare(struct rpc_task *task, void *calldata) void nfs_read_prepare(struct rpc_task *task, void *calldata)
{ {
struct nfs_read_data *data = calldata; struct nfs_read_data *data = calldata;
NFS_PROTO(data->header->inode)->read_rpc_prepare(task, data); int err;
if (unlikely(test_bit(NFS_CONTEXT_BAD, &data->args.context->flags))) err = NFS_PROTO(data->header->inode)->read_rpc_prepare(task, data);
rpc_exit(task, -EIO); if (err)
rpc_exit(task, err);
} }
static const struct rpc_call_ops nfs_read_common_ops = { static const struct rpc_call_ops nfs_read_common_ops = {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment