diff options
author | Benny Halevy <bhalevy@panasas.com> | 2011-05-22 12:51:33 -0400 |
---|---|---|
committer | Boaz Harrosh <bharrosh@panasas.com> | 2011-05-29 13:53:50 -0400 |
commit | 636fb9c89d7e216aac3d406e458864420057e981 (patch) | |
tree | 4342ccf39c4b4b26bdcf79833c7f98f8b9913262 /fs/nfs | |
parent | b6c05f1693115164c7b797152ac7ea3ef8e5d296 (diff) |
pnfs: alloc and free layout_hdr layoutdriver methods
[gfp_flags]
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/pnfs.c | 21 | ||||
-rw-r--r-- | fs/nfs/pnfs.h | 4 |
2 files changed, 22 insertions, 3 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 20436a5e76cd..ef535f2a2c74 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
@@ -177,13 +177,28 @@ get_layout_hdr(struct pnfs_layout_hdr *lo) | |||
177 | atomic_inc(&lo->plh_refcount); | 177 | atomic_inc(&lo->plh_refcount); |
178 | } | 178 | } |
179 | 179 | ||
180 | static struct pnfs_layout_hdr * | ||
181 | pnfs_alloc_layout_hdr(struct inode *ino, gfp_t gfp_flags) | ||
182 | { | ||
183 | struct pnfs_layoutdriver_type *ld = NFS_SERVER(ino)->pnfs_curr_ld; | ||
184 | return ld->alloc_layout_hdr ? ld->alloc_layout_hdr(ino, gfp_flags) : | ||
185 | kzalloc(sizeof(struct pnfs_layout_hdr), gfp_flags); | ||
186 | } | ||
187 | |||
188 | static void | ||
189 | pnfs_free_layout_hdr(struct pnfs_layout_hdr *lo) | ||
190 | { | ||
191 | struct pnfs_layoutdriver_type *ld = NFS_SERVER(lo->plh_inode)->pnfs_curr_ld; | ||
192 | return ld->alloc_layout_hdr ? ld->free_layout_hdr(lo) : kfree(lo); | ||
193 | } | ||
194 | |||
180 | static void | 195 | static void |
181 | destroy_layout_hdr(struct pnfs_layout_hdr *lo) | 196 | destroy_layout_hdr(struct pnfs_layout_hdr *lo) |
182 | { | 197 | { |
183 | dprintk("%s: freeing layout cache %p\n", __func__, lo); | 198 | dprintk("%s: freeing layout cache %p\n", __func__, lo); |
184 | BUG_ON(!list_empty(&lo->plh_layouts)); | 199 | BUG_ON(!list_empty(&lo->plh_layouts)); |
185 | NFS_I(lo->plh_inode)->layout = NULL; | 200 | NFS_I(lo->plh_inode)->layout = NULL; |
186 | kfree(lo); | 201 | pnfs_free_layout_hdr(lo); |
187 | } | 202 | } |
188 | 203 | ||
189 | static void | 204 | static void |
@@ -744,7 +759,7 @@ alloc_init_layout_hdr(struct inode *ino, gfp_t gfp_flags) | |||
744 | { | 759 | { |
745 | struct pnfs_layout_hdr *lo; | 760 | struct pnfs_layout_hdr *lo; |
746 | 761 | ||
747 | lo = kzalloc(sizeof(struct pnfs_layout_hdr), gfp_flags); | 762 | lo = pnfs_alloc_layout_hdr(ino, gfp_flags); |
748 | if (!lo) | 763 | if (!lo) |
749 | return NULL; | 764 | return NULL; |
750 | atomic_set(&lo->plh_refcount, 1); | 765 | atomic_set(&lo->plh_refcount, 1); |
@@ -777,7 +792,7 @@ pnfs_find_alloc_layout(struct inode *ino, gfp_t gfp_flags) | |||
777 | if (likely(nfsi->layout == NULL)) /* Won the race? */ | 792 | if (likely(nfsi->layout == NULL)) /* Won the race? */ |
778 | nfsi->layout = new; | 793 | nfsi->layout = new; |
779 | else | 794 | else |
780 | kfree(new); | 795 | pnfs_free_layout_hdr(new); |
781 | return nfsi->layout; | 796 | return nfsi->layout; |
782 | } | 797 | } |
783 | 798 | ||
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index f37ab3539cbf..925d6ef8ba79 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h | |||
@@ -73,6 +73,10 @@ struct pnfs_layoutdriver_type { | |||
73 | const u32 id; | 73 | const u32 id; |
74 | const char *name; | 74 | const char *name; |
75 | struct module *owner; | 75 | struct module *owner; |
76 | |||
77 | struct pnfs_layout_hdr * (*alloc_layout_hdr) (struct inode *inode, gfp_t gfp_flags); | ||
78 | void (*free_layout_hdr) (struct pnfs_layout_hdr *); | ||
79 | |||
76 | struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_hdr *layoutid, struct nfs4_layoutget_res *lgr, gfp_t gfp_flags); | 80 | struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_hdr *layoutid, struct nfs4_layoutget_res *lgr, gfp_t gfp_flags); |
77 | void (*free_lseg) (struct pnfs_layout_segment *lseg); | 81 | void (*free_lseg) (struct pnfs_layout_segment *lseg); |
78 | 82 | ||