Commit 58ac3e59 authored by Trond Myklebust's avatar Trond Myklebust

NFSv4/pnfs: Clean up nfs_layout_find_inode()

Now that we can rely on just the rcu_read_lock(), remove the
clp->cl_lock and clean up.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent cf6605d1
...@@ -121,33 +121,31 @@ __be32 nfs4_callback_recall(void *argp, void *resp, ...@@ -121,33 +121,31 @@ __be32 nfs4_callback_recall(void *argp, void *resp,
*/ */
static struct inode *nfs_layout_find_inode_by_stateid(struct nfs_client *clp, static struct inode *nfs_layout_find_inode_by_stateid(struct nfs_client *clp,
const nfs4_stateid *stateid) const nfs4_stateid *stateid)
__must_hold(RCU)
{ {
struct nfs_server *server; struct nfs_server *server;
struct inode *inode; struct inode *inode;
struct pnfs_layout_hdr *lo; struct pnfs_layout_hdr *lo;
rcu_read_lock();
list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) { list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
list_for_each_entry(lo, &server->layouts, plh_layouts) { list_for_each_entry_rcu(lo, &server->layouts, plh_layouts) {
if (!pnfs_layout_is_valid(lo)) if (!pnfs_layout_is_valid(lo))
continue; continue;
if (stateid != NULL && if (stateid != NULL &&
!nfs4_stateid_match_other(stateid, &lo->plh_stateid)) !nfs4_stateid_match_other(stateid, &lo->plh_stateid))
continue; continue;
if (!nfs_sb_active(server->super))
continue;
inode = igrab(lo->plh_inode); inode = igrab(lo->plh_inode);
if (!inode) rcu_read_unlock();
return ERR_PTR(-EAGAIN); if (inode)
if (!nfs_sb_active(inode->i_sb)) { return inode;
rcu_read_unlock(); nfs_sb_deactive(server->super);
spin_unlock(&clp->cl_lock); return ERR_PTR(-EAGAIN);
iput(inode);
spin_lock(&clp->cl_lock);
rcu_read_lock();
return ERR_PTR(-EAGAIN);
}
return inode;
} }
} }
rcu_read_unlock();
return ERR_PTR(-ENOENT); return ERR_PTR(-ENOENT);
} }
...@@ -165,28 +163,25 @@ static struct inode *nfs_layout_find_inode_by_fh(struct nfs_client *clp, ...@@ -165,28 +163,25 @@ static struct inode *nfs_layout_find_inode_by_fh(struct nfs_client *clp,
struct inode *inode; struct inode *inode;
struct pnfs_layout_hdr *lo; struct pnfs_layout_hdr *lo;
rcu_read_lock();
list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) { list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
list_for_each_entry(lo, &server->layouts, plh_layouts) { list_for_each_entry_rcu(lo, &server->layouts, plh_layouts) {
nfsi = NFS_I(lo->plh_inode); nfsi = NFS_I(lo->plh_inode);
if (nfs_compare_fh(fh, &nfsi->fh)) if (nfs_compare_fh(fh, &nfsi->fh))
continue; continue;
if (nfsi->layout != lo) if (nfsi->layout != lo)
continue; continue;
if (!nfs_sb_active(server->super))
continue;
inode = igrab(lo->plh_inode); inode = igrab(lo->plh_inode);
if (!inode) rcu_read_unlock();
return ERR_PTR(-EAGAIN); if (inode)
if (!nfs_sb_active(inode->i_sb)) { return inode;
rcu_read_unlock(); nfs_sb_deactive(server->super);
spin_unlock(&clp->cl_lock); return ERR_PTR(-EAGAIN);
iput(inode);
spin_lock(&clp->cl_lock);
rcu_read_lock();
return ERR_PTR(-EAGAIN);
}
return inode;
} }
} }
rcu_read_unlock();
return ERR_PTR(-ENOENT); return ERR_PTR(-ENOENT);
} }
...@@ -196,14 +191,9 @@ static struct inode *nfs_layout_find_inode(struct nfs_client *clp, ...@@ -196,14 +191,9 @@ static struct inode *nfs_layout_find_inode(struct nfs_client *clp,
{ {
struct inode *inode; struct inode *inode;
spin_lock(&clp->cl_lock);
rcu_read_lock();
inode = nfs_layout_find_inode_by_stateid(clp, stateid); inode = nfs_layout_find_inode_by_stateid(clp, stateid);
if (inode == ERR_PTR(-ENOENT)) if (inode == ERR_PTR(-ENOENT))
inode = nfs_layout_find_inode_by_fh(clp, fh); inode = nfs_layout_find_inode_by_fh(clp, fh);
rcu_read_unlock();
spin_unlock(&clp->cl_lock);
return inode; return inode;
} }
......
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