NFSv4.1: Clean up the removal of pnfs_layout_hdr from the server list
Move the code into pnfs_free_layout_hdr(), and add checks to get_layout_by_fh_locked to ensure that they don't reference a layout that is being freed. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
@@ -122,7 +122,15 @@ static struct pnfs_layout_hdr * get_layout_by_fh_locked(struct nfs_client *clp,
|
|||||||
ino = igrab(lo->plh_inode);
|
ino = igrab(lo->plh_inode);
|
||||||
if (!ino)
|
if (!ino)
|
||||||
continue;
|
continue;
|
||||||
|
spin_lock(&ino->i_lock);
|
||||||
|
/* Is this layout in the process of being freed? */
|
||||||
|
if (NFS_I(ino)->layout != lo) {
|
||||||
|
spin_unlock(&ino->i_lock);
|
||||||
|
iput(ino);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
pnfs_get_layout_hdr(lo);
|
pnfs_get_layout_hdr(lo);
|
||||||
|
spin_unlock(&ino->i_lock);
|
||||||
return lo;
|
return lo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -196,9 +204,18 @@ static u32 initiate_bulk_draining(struct nfs_client *clp,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
list_for_each_entry(lo, &server->layouts, plh_layouts) {
|
list_for_each_entry(lo, &server->layouts, plh_layouts) {
|
||||||
if (!igrab(lo->plh_inode))
|
ino = igrab(lo->plh_inode);
|
||||||
|
if (ino)
|
||||||
continue;
|
continue;
|
||||||
|
spin_lock(&ino->i_lock);
|
||||||
|
/* Is this layout in the process of being freed? */
|
||||||
|
if (NFS_I(ino)->layout != lo) {
|
||||||
|
spin_unlock(&ino->i_lock);
|
||||||
|
iput(ino);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
pnfs_get_layout_hdr(lo);
|
pnfs_get_layout_hdr(lo);
|
||||||
|
spin_unlock(&ino->i_lock);
|
||||||
BUG_ON(!list_empty(&lo->plh_bulk_recall));
|
BUG_ON(!list_empty(&lo->plh_bulk_recall));
|
||||||
list_add(&lo->plh_bulk_recall, &recall_list);
|
list_add(&lo->plh_bulk_recall, &recall_list);
|
||||||
}
|
}
|
||||||
|
@@ -207,7 +207,16 @@ pnfs_alloc_layout_hdr(struct inode *ino, gfp_t gfp_flags)
|
|||||||
static void
|
static void
|
||||||
pnfs_free_layout_hdr(struct pnfs_layout_hdr *lo)
|
pnfs_free_layout_hdr(struct pnfs_layout_hdr *lo)
|
||||||
{
|
{
|
||||||
struct pnfs_layoutdriver_type *ld = NFS_SERVER(lo->plh_inode)->pnfs_curr_ld;
|
struct nfs_server *server = NFS_SERVER(lo->plh_inode);
|
||||||
|
struct pnfs_layoutdriver_type *ld = server->pnfs_curr_ld;
|
||||||
|
|
||||||
|
if (!list_empty(&lo->plh_layouts)) {
|
||||||
|
struct nfs_client *clp = server->nfs_client;
|
||||||
|
|
||||||
|
spin_lock(&clp->cl_lock);
|
||||||
|
list_del_init(&lo->plh_layouts);
|
||||||
|
spin_unlock(&clp->cl_lock);
|
||||||
|
}
|
||||||
put_rpccred(lo->plh_lc_cred);
|
put_rpccred(lo->plh_lc_cred);
|
||||||
return ld->alloc_layout_hdr ? ld->free_layout_hdr(lo) : kfree(lo);
|
return ld->alloc_layout_hdr ? ld->free_layout_hdr(lo) : kfree(lo);
|
||||||
}
|
}
|
||||||
@@ -217,7 +226,6 @@ pnfs_detach_layout_hdr(struct pnfs_layout_hdr *lo)
|
|||||||
{
|
{
|
||||||
struct nfs_inode *nfsi = NFS_I(lo->plh_inode);
|
struct nfs_inode *nfsi = NFS_I(lo->plh_inode);
|
||||||
dprintk("%s: freeing layout cache %p\n", __func__, lo);
|
dprintk("%s: freeing layout cache %p\n", __func__, lo);
|
||||||
BUG_ON(!list_empty(&lo->plh_layouts));
|
|
||||||
nfsi->layout = NULL;
|
nfsi->layout = NULL;
|
||||||
/* Reset MDS Threshold I/O counters */
|
/* Reset MDS Threshold I/O counters */
|
||||||
nfsi->write_io = 0;
|
nfsi->write_io = 0;
|
||||||
@@ -480,22 +488,10 @@ void
|
|||||||
pnfs_free_lseg_list(struct list_head *free_me)
|
pnfs_free_lseg_list(struct list_head *free_me)
|
||||||
{
|
{
|
||||||
struct pnfs_layout_segment *lseg, *tmp;
|
struct pnfs_layout_segment *lseg, *tmp;
|
||||||
struct pnfs_layout_hdr *lo;
|
|
||||||
|
|
||||||
if (list_empty(free_me))
|
if (list_empty(free_me))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lo = list_first_entry(free_me, struct pnfs_layout_segment,
|
|
||||||
pls_list)->pls_layout;
|
|
||||||
|
|
||||||
if (test_bit(NFS_LAYOUT_DESTROYED, &lo->plh_flags)) {
|
|
||||||
struct nfs_client *clp;
|
|
||||||
|
|
||||||
clp = NFS_SERVER(lo->plh_inode)->nfs_client;
|
|
||||||
spin_lock(&clp->cl_lock);
|
|
||||||
list_del_init(&lo->plh_layouts);
|
|
||||||
spin_unlock(&clp->cl_lock);
|
|
||||||
}
|
|
||||||
list_for_each_entry_safe(lseg, tmp, free_me, pls_list) {
|
list_for_each_entry_safe(lseg, tmp, free_me, pls_list) {
|
||||||
list_del(&lseg->pls_list);
|
list_del(&lseg->pls_list);
|
||||||
free_lseg(lseg);
|
free_lseg(lseg);
|
||||||
@@ -1148,11 +1144,6 @@ pnfs_update_layout(struct inode *ino,
|
|||||||
arg.length = PAGE_CACHE_ALIGN(arg.length);
|
arg.length = PAGE_CACHE_ALIGN(arg.length);
|
||||||
|
|
||||||
lseg = send_layoutget(lo, ctx, &arg, gfp_flags);
|
lseg = send_layoutget(lo, ctx, &arg, gfp_flags);
|
||||||
if (!lseg && first) {
|
|
||||||
spin_lock(&clp->cl_lock);
|
|
||||||
list_del_init(&lo->plh_layouts);
|
|
||||||
spin_unlock(&clp->cl_lock);
|
|
||||||
}
|
|
||||||
atomic_dec(&lo->plh_outstanding);
|
atomic_dec(&lo->plh_outstanding);
|
||||||
out_put_layout_hdr:
|
out_put_layout_hdr:
|
||||||
pnfs_put_layout_hdr(lo);
|
pnfs_put_layout_hdr(lo);
|
||||||
|
Reference in New Issue
Block a user