linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fred Isaman <iisaman@netapp.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 04/11] wave 2: share code between put_lseg and pnfs_free_lseg_list
Date: Wed, 15 Dec 2010 11:03:04 -0500	[thread overview]
Message-ID: <1292428991-30788-4-git-send-email-iisaman@netapp.com> (raw)
In-Reply-To: <1292428991-30788-1-git-send-email-iisaman@netapp.com>

Create a free_lseg() function from the duplicated code.

Signed-off-by: Fred Isaman <iisaman@netapp.com>
---
 fs/nfs/pnfs.c |   34 ++++++++++++++++------------------
 1 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 5c6b4fb..df6561a 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -280,6 +280,18 @@ init_lseg(struct pnfs_layout_hdr *lo, struct pnfs_layout_segment *lseg)
 	lseg->pls_notify_count = 0;
 }
 
+static void free_lseg(struct pnfs_layout_segment *lseg)
+{
+	struct inode *ino = lseg->layout->inode;
+	int count = lseg->pls_notify_count;
+
+	BUG_ON(atomic_read(&lseg->pls_refcount) != 0);
+	NFS_SERVER(ino)->pnfs_curr_ld->free_lseg(lseg);
+	notify_drained(NFS_SERVER(ino)->nfs_client, count);
+	/* Matched by get_layout_hdr_locked in pnfs_insert_layout */
+	put_layout_hdr(NFS_I(ino)->layout);
+}
+
 static void
 _put_lseg_common(struct pnfs_layout_segment *lseg)
 {
@@ -329,14 +341,9 @@ put_lseg(struct pnfs_layout_segment *lseg)
 		test_bit(NFS_LSEG_VALID, &lseg->pls_flags));
 	ino = lseg->layout->inode;
 	if (atomic_dec_and_lock(&lseg->pls_refcount, &ino->i_lock)) {
-		int count = lseg->pls_notify_count;
-
 		_put_lseg_common(lseg);
 		spin_unlock(&ino->i_lock);
-		NFS_SERVER(ino)->pnfs_curr_ld->free_lseg(lseg);
-		notify_drained(NFS_SERVER(ino)->nfs_client, count);
-		/* Matched by get_layout_hdr_locked in pnfs_insert_layout */
-		put_layout_hdr(NFS_I(ino)->layout);
+		free_lseg(lseg);
 	}
 }
 EXPORT_SYMBOL_GPL(put_lseg);
@@ -402,18 +409,9 @@ void
 pnfs_free_lseg_list(struct list_head *free_me)
 {
 	struct pnfs_layout_segment *lseg, *tmp;
-	struct inode *ino;
-	int count;
-
-	list_for_each_entry_safe(lseg, tmp, free_me, fi_list) {
-		BUG_ON(atomic_read(&lseg->pls_refcount) != 0);
-		ino = lseg->layout->inode;
-		count = lseg->pls_notify_count;
-		NFS_SERVER(ino)->pnfs_curr_ld->free_lseg(lseg);
-		notify_drained(NFS_SERVER(ino)->nfs_client, count);
-		/* Matched by get_layout_hdr_locked in pnfs_insert_layout */
-		put_layout_hdr(NFS_I(ino)->layout);
-	}
+
+	list_for_each_entry_safe(lseg, tmp, free_me, fi_list)
+		free_lseg(lseg);
 	INIT_LIST_HEAD(free_me);
 }
 
-- 
1.7.2.1


  parent reply	other threads:[~2010-12-15 16:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-15 16:03 [PATCH 01/11] wave 2: restore removed comment in nfs4_evict_inode Fred Isaman
2010-12-15 16:03 ` [PATCH 02/11] wave 2: remove gratuitous changes to nfs4_layoutget_done Fred Isaman
2010-12-15 16:03 ` [PATCH 03/11] wave 2: remove pnfs_ld_layoutret_on_setattr() Fred Isaman
2010-12-15 16:03 ` Fred Isaman [this message]
2010-12-15 16:03 ` [PATCH 05/11] wave 2: remove notify_drained Fred Isaman
2010-12-15 16:03 ` [PATCH 06/11] wave 2: rename notify fields Fred Isaman
2010-12-15 16:03 ` [PATCH 07/11] wave 2: remove trigger_flush Fred Isaman
2010-12-15 16:03 ` [PATCH 08/11] wave 2: remove table above should_free_lseg Fred Isaman
2010-12-15 16:03 ` [PATCH 09/11] wave 2: Fix outdated comment above _pnfs_return_layout Fred Isaman
2010-12-15 16:03 ` [PATCH 10/11] wave 2: remove unneeded include from pnfs.h Fred Isaman
2010-12-15 16:03 ` [PATCH 11/11] wave 2: remove unneeded includes from callback_proc.c Fred Isaman

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=1292428991-30788-4-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;
as well as URLs for NNTP newsgroup(s).