mirror of
https://github.com/FEX-Emu/linux.git
synced 2025-01-19 16:17:40 +00:00
pnfs: alloc and free layout_hdr layoutdriver methods
[gfp_flags] Signed-off-by: Benny Halevy <bhalevy@panasas.com>
This commit is contained in:
parent
b6c05f1693
commit
636fb9c89d
@ -177,13 +177,28 @@ get_layout_hdr(struct pnfs_layout_hdr *lo)
|
|||||||
atomic_inc(&lo->plh_refcount);
|
atomic_inc(&lo->plh_refcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct pnfs_layout_hdr *
|
||||||
|
pnfs_alloc_layout_hdr(struct inode *ino, gfp_t gfp_flags)
|
||||||
|
{
|
||||||
|
struct pnfs_layoutdriver_type *ld = NFS_SERVER(ino)->pnfs_curr_ld;
|
||||||
|
return ld->alloc_layout_hdr ? ld->alloc_layout_hdr(ino, gfp_flags) :
|
||||||
|
kzalloc(sizeof(struct pnfs_layout_hdr), gfp_flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
pnfs_free_layout_hdr(struct pnfs_layout_hdr *lo)
|
||||||
|
{
|
||||||
|
struct pnfs_layoutdriver_type *ld = NFS_SERVER(lo->plh_inode)->pnfs_curr_ld;
|
||||||
|
return ld->alloc_layout_hdr ? ld->free_layout_hdr(lo) : kfree(lo);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
destroy_layout_hdr(struct pnfs_layout_hdr *lo)
|
destroy_layout_hdr(struct pnfs_layout_hdr *lo)
|
||||||
{
|
{
|
||||||
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));
|
BUG_ON(!list_empty(&lo->plh_layouts));
|
||||||
NFS_I(lo->plh_inode)->layout = NULL;
|
NFS_I(lo->plh_inode)->layout = NULL;
|
||||||
kfree(lo);
|
pnfs_free_layout_hdr(lo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -744,7 +759,7 @@ alloc_init_layout_hdr(struct inode *ino, gfp_t gfp_flags)
|
|||||||
{
|
{
|
||||||
struct pnfs_layout_hdr *lo;
|
struct pnfs_layout_hdr *lo;
|
||||||
|
|
||||||
lo = kzalloc(sizeof(struct pnfs_layout_hdr), gfp_flags);
|
lo = pnfs_alloc_layout_hdr(ino, gfp_flags);
|
||||||
if (!lo)
|
if (!lo)
|
||||||
return NULL;
|
return NULL;
|
||||||
atomic_set(&lo->plh_refcount, 1);
|
atomic_set(&lo->plh_refcount, 1);
|
||||||
@ -777,7 +792,7 @@ pnfs_find_alloc_layout(struct inode *ino, gfp_t gfp_flags)
|
|||||||
if (likely(nfsi->layout == NULL)) /* Won the race? */
|
if (likely(nfsi->layout == NULL)) /* Won the race? */
|
||||||
nfsi->layout = new;
|
nfsi->layout = new;
|
||||||
else
|
else
|
||||||
kfree(new);
|
pnfs_free_layout_hdr(new);
|
||||||
return nfsi->layout;
|
return nfsi->layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +73,10 @@ struct pnfs_layoutdriver_type {
|
|||||||
const u32 id;
|
const u32 id;
|
||||||
const char *name;
|
const char *name;
|
||||||
struct module *owner;
|
struct module *owner;
|
||||||
|
|
||||||
|
struct pnfs_layout_hdr * (*alloc_layout_hdr) (struct inode *inode, gfp_t gfp_flags);
|
||||||
|
void (*free_layout_hdr) (struct pnfs_layout_hdr *);
|
||||||
|
|
||||||
struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_hdr *layoutid, struct nfs4_layoutget_res *lgr, gfp_t gfp_flags);
|
struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_hdr *layoutid, struct nfs4_layoutget_res *lgr, gfp_t gfp_flags);
|
||||||
void (*free_lseg) (struct pnfs_layout_segment *lseg);
|
void (*free_lseg) (struct pnfs_layout_segment *lseg);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user