[PATCH 04/11] wave 2: share code between put_lseg and pnfs_free_lseg_list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Create a free_lseg() function from the duplicated code.

Signed-off-by: Fred Isaman <iisaman@xxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux