summaryrefslogtreecommitdiff
path: root/fs/nfs/callback_proc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-12-16 05:47:31 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2016-12-16 05:47:31 +0300
commit73e2e0c9b13c97df1c8565f6e158caac3c481b44 (patch)
treef3c561172579175a37a3b7908e8af05f4d6a70be /fs/nfs/callback_proc.c
parented3c5a0be38c180ab0899a0f52719e81f36b87a1 (diff)
parent2549f307b5997bf5dd91071428e8090d9faa8b1b (diff)
downloadlinux-73e2e0c9b13c97df1c8565f6e158caac3c481b44.tar.xz
Merge tag 'nfs-for-4.10-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
Pull NFS client updates from Trond Myklebust: "Highlights include: Stable bugfixes: - Fix a pnfs deadlock between read resends and layoutreturn - Don't invalidate the layout stateid while a layout return is outstanding - Don't schedule a layoutreturn if the layout stateid is marked as invalid - On a pNFS error, do not send LAYOUTGET until the LAYOUTRETURN is complete - SUNRPC: fix refcounting problems with auth_gss messages. Features: - Add client support for the NFSv4 umask attribute. - NFSv4: Correct support for flock() stateids. - Add a LAYOUTRETURN operation to CLOSE and DELEGRETURN when return-on-close is specified - Allow the pNFS/flexfiles layoutstat information to piggyback on LAYOUTRETURN - Optimise away redundant GETATTR calls when doing state recovery and/or when not required by cache revalidation rules or close-to-open cache consistency. - Attribute cache improvements - RPC/RDMA support for SG_GAP devices Bugfixes: - NFS: Fix performance regressions in readdir - pNFS/flexfiles: Fix a deadlock on LAYOUTGET - NFSv4: Add missing nfs_put_lock_context() - NFSv4.1: Fix regression in callback retry handling - Fix false positive NFSv4.0 trunking detection. - pNFS/flexfiles: Only send layoutstats updates for mirrors that were updated - Various layout stateid related bugfixes - RPC/RDMA bugfixes" * tag 'nfs-for-4.10-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: (82 commits) SUNRPC: fix refcounting problems with auth_gss messages. nfs: add support for the umask attribute pNFS/flexfiles: Ensure we have enough buffer for layoutreturn pNFS/flexfiles: Remove a redundant parameter in ff_layout_encode_ioerr() pNFS/flexfiles: Fix a deadlock on LAYOUTGET pNFS: Layoutreturn must free the layout after the layout-private data pNFS/flexfiles: Fix ff_layout_add_ds_error_locked() NFSv4: Add missing nfs_put_lock_context() pNFS: Release NFS_LAYOUT_RETURN when invalidating the layout stateid NFSv4.1: Don't schedule lease recovery in nfs4_schedule_session_recovery() NFSv4.1: Handle NFS4ERR_BADSESSION/NFS4ERR_DEADSESSION replies to OP_SEQUENCE NFS: Only look at the change attribute cache state in nfs_check_verifier NFS: Fix incorrect size revalidation when holding a delegation NFS: Fix incorrect mapping revalidation when holding a delegation pNFS/flexfiles: Support sending layoutstats in layoutreturn pNFS/flexfiles: Minor refactoring before adding iostats to layoutreturn NFS: Fix up read of mirror stats pNFS/flexfiles: Clean up layoutstats pNFS/flexfiles: Refactor encoding of the layoutreturn payload pNFS: Add a layoutreturn callback to performa layout-private setup ...
Diffstat (limited to 'fs/nfs/callback_proc.c')
-rw-r--r--fs/nfs/callback_proc.c99
1 files changed, 67 insertions, 32 deletions
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index e9aa235e9d10..f073a6d2c6a5 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -110,20 +110,52 @@ out:
#if defined(CONFIG_NFS_V4_1)
/*
- * Lookup a layout by filehandle.
+ * Lookup a layout inode by stateid
*
- * Note: gets a refcount on the layout hdr and on its respective inode.
- * Caller must put the layout hdr and the inode.
+ * Note: returns a refcount on the inode and superblock
+ */
+static struct inode *nfs_layout_find_inode_by_stateid(struct nfs_client *clp,
+ const nfs4_stateid *stateid)
+{
+ struct nfs_server *server;
+ struct inode *inode;
+ struct pnfs_layout_hdr *lo;
+
+restart:
+ list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
+ list_for_each_entry(lo, &server->layouts, plh_layouts) {
+ if (stateid != NULL &&
+ !nfs4_stateid_match_other(stateid, &lo->plh_stateid))
+ continue;
+ inode = igrab(lo->plh_inode);
+ if (!inode)
+ continue;
+ if (!nfs_sb_active(inode->i_sb)) {
+ rcu_read_lock();
+ spin_unlock(&clp->cl_lock);
+ iput(inode);
+ spin_lock(&clp->cl_lock);
+ goto restart;
+ }
+ return inode;
+ }
+ }
+
+ return NULL;
+}
+
+/*
+ * Lookup a layout inode by filehandle.
+ *
+ * Note: returns a refcount on the inode and superblock
*
- * TODO: keep track of all layouts (and delegations) in a hash table
- * hashed by filehandle.
*/
-static struct pnfs_layout_hdr * get_layout_by_fh_locked(struct nfs_client *clp,
- struct nfs_fh *fh)
+static struct inode *nfs_layout_find_inode_by_fh(struct nfs_client *clp,
+ const struct nfs_fh *fh)
{
struct nfs_server *server;
struct nfs_inode *nfsi;
- struct inode *ino;
+ struct inode *inode;
struct pnfs_layout_hdr *lo;
restart:
@@ -134,37 +166,38 @@ restart:
continue;
if (nfsi->layout != lo)
continue;
- ino = igrab(lo->plh_inode);
- if (!ino)
- break;
- spin_lock(&ino->i_lock);
- /* Is this layout in the process of being freed? */
- if (nfsi->layout != lo) {
- spin_unlock(&ino->i_lock);
- iput(ino);
+ inode = igrab(lo->plh_inode);
+ if (!inode)
+ continue;
+ if (!nfs_sb_active(inode->i_sb)) {
+ rcu_read_lock();
+ spin_unlock(&clp->cl_lock);
+ iput(inode);
+ spin_lock(&clp->cl_lock);
goto restart;
}
- pnfs_get_layout_hdr(lo);
- spin_unlock(&ino->i_lock);
- return lo;
+ return inode;
}
}
return NULL;
}
-static struct pnfs_layout_hdr * get_layout_by_fh(struct nfs_client *clp,
- struct nfs_fh *fh)
+static struct inode *nfs_layout_find_inode(struct nfs_client *clp,
+ const struct nfs_fh *fh,
+ const nfs4_stateid *stateid)
{
- struct pnfs_layout_hdr *lo;
+ struct inode *inode;
spin_lock(&clp->cl_lock);
rcu_read_lock();
- lo = get_layout_by_fh_locked(clp, fh);
+ inode = nfs_layout_find_inode_by_stateid(clp, stateid);
+ if (!inode)
+ inode = nfs_layout_find_inode_by_fh(clp, fh);
rcu_read_unlock();
spin_unlock(&clp->cl_lock);
- return lo;
+ return inode;
}
/*
@@ -213,18 +246,20 @@ static u32 initiate_file_draining(struct nfs_client *clp,
u32 rv = NFS4ERR_NOMATCHING_LAYOUT;
LIST_HEAD(free_me_list);
- lo = get_layout_by_fh(clp, &args->cbl_fh);
- if (!lo) {
- trace_nfs4_cb_layoutrecall_file(clp, &args->cbl_fh, NULL,
- &args->cbl_stateid, -rv);
+ ino = nfs_layout_find_inode(clp, &args->cbl_fh, &args->cbl_stateid);
+ if (!ino)
goto out;
- }
- ino = lo->plh_inode;
pnfs_layoutcommit_inode(ino, false);
spin_lock(&ino->i_lock);
+ lo = NFS_I(ino)->layout;
+ if (!lo) {
+ spin_unlock(&ino->i_lock);
+ goto out;
+ }
+ pnfs_get_layout_hdr(lo);
rv = pnfs_check_callback_stateid(lo, &args->cbl_stateid);
if (rv != NFS_OK)
goto unlock;
@@ -258,10 +293,10 @@ unlock:
/* Free all lsegs that are attached to commit buckets */
nfs_commit_inode(ino, 0);
pnfs_put_layout_hdr(lo);
+out:
trace_nfs4_cb_layoutrecall_file(clp, &args->cbl_fh, ino,
&args->cbl_stateid, -rv);
- iput(ino);
-out:
+ nfs_iput_and_deactive(ino);
return rv;
}