aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/pnfs.c
diff options
context:
space:
mode:
authorBenny Halevy <bhalevy@panasas.com>2011-05-22 12:51:33 -0400
committerBoaz Harrosh <bharrosh@panasas.com>2011-05-29 13:53:50 -0400
commit636fb9c89d7e216aac3d406e458864420057e981 (patch)
tree4342ccf39c4b4b26bdcf79833c7f98f8b9913262 /fs/nfs/pnfs.c
parentb6c05f1693115164c7b797152ac7ea3ef8e5d296 (diff)
pnfs: alloc and free layout_hdr layoutdriver methods
[gfp_flags] Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Diffstat (limited to 'fs/nfs/pnfs.c')
-rw-r--r--fs/nfs/pnfs.c21
1 files changed, 18 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
180static struct pnfs_layout_hdr *
181pnfs_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
188static void
189pnfs_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
180static void 195static void
181destroy_layout_hdr(struct pnfs_layout_hdr *lo) 196destroy_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
189static void 204static 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