public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Fred Isaman <iisaman@netapp.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 09/10] pnfs-submit: API change: alloc_layout returns layout cache head
Date: Mon, 14 Jun 2010 21:46:14 -0400	[thread overview]
Message-ID: <1276566375-24566-10-git-send-email-iisaman@netapp.com> (raw)
In-Reply-To: <1276566375-24566-9-git-send-email-iisaman@netapp.com>

From: Andy Adamson <andros@netapp.com>

pnfs_layout_type (to be renamed later) is the head of the inode layout
segment cache. Embed the layout cache head struct in the per layout cache
head struct and allocate them both in the alloc_layout
layoutdriver_io_operation.

This requires layout drivers to change their alloc/free_layout routines.

Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Fred Isaman <iisaman@netapp.com>
---
 fs/nfs/pnfs.c             |   21 +++++----------------
 include/linux/nfs4_pnfs.h |    8 +-------
 include/linux/nfs_fs.h    |    1 -
 3 files changed, 6 insertions(+), 24 deletions(-)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 943519b..edffee3 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -380,10 +380,9 @@ put_layout(struct pnfs_layout_type *lo)
 		struct layoutdriver_io_operations *io_ops =
 			PNFS_LD_IO_OPS(lo);
 
-		dprintk("%s: freeing layout %p\n", __func__, lo->ld_data);
-		io_ops->free_layout(lo->ld_data);
+		dprintk("%s: freeing layout %p\n", __func__, lo);
+		io_ops->free_layout(lo);
 		nfsi->layout = NULL;
-		kfree(lo);
 	}
 }
 
@@ -919,27 +918,17 @@ pnfs_insert_layout(struct pnfs_layout_type *lo,
 static struct pnfs_layout_type *
 alloc_init_layout(struct inode *ino)
 {
-	void *ld_data;
 	struct pnfs_layout_type *lo;
-	struct layoutdriver_io_operations *io_ops;
 
-	lo = kzalloc(sizeof(struct pnfs_layout_type), GFP_KERNEL);
-	if (!lo)
-		return NULL;
-	io_ops = NFS_SERVER(ino)->pnfs_curr_ld->ld_io_ops;
-	ld_data = io_ops->alloc_layout(ino);
-	if (!ld_data) {
+	/* Layoutdriver must zero (kzalloc) lo_cache fields */
+	lo = NFS_SERVER(ino)->pnfs_curr_ld->ld_io_ops->alloc_layout(ino);
+	if (!lo) {
 		printk(KERN_ERR
 			"%s: out of memory: io_ops->alloc_layout failed\n",
 			__func__);
-		kfree(lo);
 		return NULL;
 	}
-
-	lo->ld_data = ld_data;
-	memset(&lo->stateid, 0, NFS4_STATEID_SIZE);
 	lo->refcount = 1;
-	lo->roc_iomode = 0;
 	lo->lo_inode = ino;
 	INIT_LIST_HEAD(&lo->lo_layouts);
 	INIT_LIST_HEAD(&lo->segs);
diff --git a/include/linux/nfs4_pnfs.h b/include/linux/nfs4_pnfs.h
index 5885352..dd11022 100644
--- a/include/linux/nfs4_pnfs.h
+++ b/include/linux/nfs4_pnfs.h
@@ -50,12 +50,6 @@ PNFS_NFS_SERVER(struct pnfs_layout_type *lo)
 	return NFS_SERVER(PNFS_INODE(lo));
 }
 
-static inline void *
-PNFS_LD_DATA(struct pnfs_layout_type *lo)
-{
-	return lo->ld_data;
-}
-
 static inline struct pnfs_layoutdriver_type *
 PNFS_LD(struct pnfs_layout_type *lo)
 {
@@ -151,7 +145,7 @@ struct layoutdriver_io_operations {
 	/* Layout information. For each inode, alloc_layout is executed once to retrieve an
 	 * inode specific layout structure.  Each subsequent layoutget operation results in
 	 * a set_layout call to set the opaque layout in the layout driver.*/
-	void * (*alloc_layout) (struct inode *inode);
+	struct pnfs_layout_type * (*alloc_layout) (struct inode *inode);
 	void (*free_layout) (void *layoutid);
 	struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_type *layoutid, struct nfs4_pnfs_layoutget_res *lgr);
 	void (*free_lseg) (struct pnfs_layout_segment *lseg);
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 6b62a53..149051c 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -104,7 +104,6 @@ struct pnfs_layout_type {
 	int roc_iomode;			/* iomode to return on close, 0=none */
 	seqlock_t seqlock;		/* Protects the stateid */
 	nfs4_stateid stateid;
-	void *ld_data;			/* layout driver private data */
 	struct rpc_cred         *lo_cred; /* layoutcommit credential */
 	/* DH: These vars keep track of the maximum write range
 	 * so the values can be used for layoutcommit.
-- 
1.6.6.1


  reply	other threads:[~2010-06-15 14:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-15  1:46 [PATCH 00/10] layout refcounting changes Fred Isaman
2010-06-15  1:46 ` [PATCH 01/10] pnfs-submit: separate locking from get and put of layout Fred Isaman
2010-06-15  1:46   ` [PATCH 02/10] pnfs-submit: split get_layout and grab_current_layout Fred Isaman
2010-06-15  1:46     ` [PATCH 03/10] pnfs-submit: remove list_empty check from put_layout Fred Isaman
2010-06-15  1:46       ` [PATCH 04/10] pnfs-submit: add backpointer to pnfs_layout_type Fred Isaman
2010-06-15  1:46         ` [PATCH 05/10] pnfs-submit: Move pnfs_layout_state and pnfs_layout_suspend back to nfs_inode Fred Isaman
2010-06-15  1:46           ` [PATCH 06/10] pnfs-submit: Add state flag for layoutcommit_needed Fred Isaman
2010-06-15  1:46             ` [PATCH 07/10] pnfs-submit: avoid race handling return on close Fred Isaman
2010-06-15  1:46               ` [PATCH 08/10] pnfs-submit: change nfsi->layout to a pointer Fred Isaman
2010-06-15  1:46                 ` Fred Isaman [this message]
2010-06-15  1:46                   ` [PATCH 10/10] pnfs-submit: filelayout: adjust to new alloc_layout API Fred Isaman
2010-06-15 17:06               ` [PATCH 07/10] pnfs-submit: avoid race handling return on close Benny Halevy
2010-06-15 17:32                 ` Fred Isaman
     [not found]                   ` <AANLkTilDj2Ua_t77kk5Gj_t0vqEcOJFKlqODAj18KQnm-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-06-15 17:33                     ` Trond Myklebust
     [not found]                       ` <1276623230.8767.48.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2010-06-15 17:52                         ` Fred Isaman
     [not found]                           ` <AANLkTimScICltrCrtEIz7qw1GzuaTGNwCVTk-ZTsZO4_-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-06-15 18:19                             ` Trond Myklebust
     [not found]                               ` <1276625991.2988.1.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2010-06-15 18:47                                 ` Benny Halevy
2010-06-15 17:00         ` [PATCH 04/10] pnfs-submit: add backpointer to pnfs_layout_type Benny Halevy
2010-06-15 16:56       ` [PATCH 03/10] pnfs-submit: remove list_empty check from put_layout Benny Halevy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1276566375-24566-10-git-send-email-iisaman@netapp.com \
    --to=iisaman@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox