[PATCH 6/7] xfs: Use inode create transaction

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

 



Replace the use of buffer based logging of inode initialisation,
uses the new logical form to describe the range to be initialised
in recovery. We continue to "log" the inode buffers to push them
into the AIL and ensure that the inode create transaction is not
removed from the log before the inode buffers are written to disk.

Update the transaction identifier and reservations to match the
changed implementation.

Signed-off-by: Dave Chinner <david@xxxxxxxxxxxxx>
---
 fs/xfs/xfs_ialloc.c |   39 ++++++++++++++++++++++++++++++---------
 fs/xfs/xfs_ialloc.h |    7 +++++++
 2 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index c8f5ae1..9126b59 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -38,6 +38,7 @@
 #include "xfs_bmap.h"
 #include "xfs_cksum.h"
 #include "xfs_buf_item.h"
+#include "xfs_icreate_item.h"
 
 
 /*
@@ -152,7 +153,7 @@ xfs_check_agi_freecount(
 /*
  * Initialise a new set of inodes.
  */
-STATIC int
+int
 xfs_ialloc_inode_init(
 	struct xfs_mount	*mp,
 	struct xfs_trans	*tp,
@@ -208,6 +209,17 @@ xfs_ialloc_inode_init(
 		version = 3;
 		ino = XFS_AGINO_TO_INO(mp, agno,
 				       XFS_OFFBNO_TO_AGINO(mp, agbno, 0));
+
+		/*
+		 * log the initialisation that is about to take place as an
+		 * logical operation. This means the transaction does not
+		 * need to log the physical changes to the inode buffers as log
+		 * recovery will know what initialisation is actually needed.
+		 * Hence we only need to log the buffers as "ordered" buffers so
+		 * they track in the AIL as if they were physically logged.
+		 */
+		xfs_icreate_log(tp, agno, agbno, XFS_IALLOC_INODES(mp),
+				mp->m_sb.sb_inodesize, length, gen);
 	} else if (xfs_sb_version_hasnlink(&mp->m_sb))
 		version = 2;
 	else
@@ -223,13 +235,8 @@ xfs_ialloc_inode_init(
 					 XBF_UNMAPPED);
 		if (!fbuf)
 			return ENOMEM;
-		/*
-		 * Initialize all inodes in this buffer and then log them.
-		 *
-		 * XXX: It would be much better if we had just one transaction
-		 *	to log a whole cluster of inodes instead of all the
-		 *	individual transactions causing a lot of log traffic.
-		 */
+
+		/* Initialize the inode buffers and log them appropriately. */
 		fbuf->b_ops = &xfs_inode_buf_ops;
 		xfs_buf_zero(fbuf, 0, BBTOB(fbuf->b_length));
 		for (i = 0; i < ninodes; i++) {
@@ -253,11 +260,25 @@ xfs_ialloc_inode_init(
 						  ioffset + isize - 1);
 			}
 		}
+
 		if (version == 3) {
-			/* need to log the entire buffer */
+			/*
+			 * Mark the buffer as ordered so that it is not logged
+			 * in the transaction but still tracked in the AIL as
+			 * part of the transaction.
+			 */
+			xfs_trans_ordered_buf(tp, fbuf);
 			xfs_trans_log_buf(tp, fbuf, 0,
 					  BBTOB(fbuf->b_length) - 1);
 		}
+
+		/*
+		 * Mark the buffer as an inode allocation buffer so it sticks in
+		 * AIL at the point of this allocation transaction. This ensures
+		 * the they are on disk before the tail of the log can be moved
+		 * past this transaction (i.e. by preventing relogging from
+		 * moving it forward in the log).
+		 */
 		xfs_trans_inode_alloc_buf(tp, fbuf);
 	}
 	return 0;
diff --git a/fs/xfs/xfs_ialloc.h b/fs/xfs/xfs_ialloc.h
index c8da3df..ec1cc48 100644
--- a/fs/xfs/xfs_ialloc.h
+++ b/fs/xfs/xfs_ialloc.h
@@ -152,4 +152,11 @@ int xfs_inobt_get_rec(struct xfs_btree_cur *cur,
 
 extern const struct xfs_buf_ops xfs_agi_buf_ops;
 
+/*
+ * Inode buffer initialisation routine
+ */
+int xfs_ialloc_inode_init(struct xfs_mount *mp, struct xfs_trans *tp,
+		 xfs_agnumber_t agno, xfs_agblock_t agbno,
+		 xfs_agblock_t length, unsigned int gen);
+
 #endif	/* __XFS_IALLOC_H__ */
-- 
1.7.10.4

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs




[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux