All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 10/15] xfs: Introduce a new transaction for shrinking fs data section
@ 2012-11-16  6:46 Jeff Liu
  0 siblings, 0 replies; only message in thread
From: Jeff Liu @ 2012-11-16  6:46 UTC (permalink / raw)
  To: xfs

This is a new transaction which would be used for shrinking fs data section.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
---
 fs/xfs/xfs_mount.h       |    1 +
 fs/xfs/xfs_trans.c       |   16 ++++++++++++++++
 fs/xfs/xfs_trans.h       |    7 +++++--
 fs/xfs/xfs_trans_space.h |    2 ++
 4 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 9eaea5a..9bf3ed6 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -41,6 +41,7 @@ typedef struct xfs_trans_reservations {
 	uint	tr_growrtzero;	/* grow realtime zeroing */
 	uint	tr_growrtfree;	/* grow realtime freeing */
 	uint	tr_setagstate;	/* set a.g. state trans */
+	uint	tr_shrinkdata;	/* fs data section shrink trans */
 } xfs_trans_reservations_t;
 
 #ifndef __KERNEL__
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 5a5c4d8..d7346da 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -542,6 +542,21 @@ xfs_calc_set_agstate_reservation(
 }
 
 /*
+ * Shrinking the data section of the filesystem.
+ *	superblock
+ *	agi and agf
+ *	allocation btrees
+ */
+STATIC uint
+xfs_calc_shrinkdata_reservation(
+	struct xfs_mount	*mp)
+{
+	return mp->m_sb.sb_sectsize * 3 +
+		XFS_ALLOCFREE_LOG_RES(mp, 1) +
+		128 * (3 + XFS_ALLOCFREE_LOG_COUNT(mp, 1));
+}
+
+/*
  * Initialize the precomputed transaction reservation values
  * in the mount structure.
  */
@@ -573,6 +588,7 @@ xfs_trans_init(
 	resp->tr_growrtzero = xfs_calc_growrtzero_reservation(mp);
 	resp->tr_growrtfree = xfs_calc_growrtfree_reservation(mp);
 	resp->tr_setagstate = xfs_calc_set_agstate_reservation(mp);
+	resp->tr_shrinkdata = xfs_calc_shrinkdata_reservation(mp);
 }
 
 /*
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index 33aafda..6dc1fe8 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -109,7 +109,8 @@ typedef struct xfs_trans_header {
 #define	XFS_TRANS_CHECKPOINT		42
 #define XFS_TRANS_SET_AGSTATE		43
 #define XFS_TRANS_SWAPINO		44
-#define	XFS_TRANS_TYPE_MAX		44
+#define XFS_TRANS_SHRINKFS		45
+#define	XFS_TRANS_TYPE_MAX		45
 /* new transaction types need to be reflected in xfs_logprint(8) */
 
 #define XFS_TRANS_TYPES \
@@ -156,7 +157,8 @@ typedef struct xfs_trans_header {
 	{ XFS_TRANS_DUMMY2,		"DUMMY2" }, \
 	{ XLOG_UNMOUNT_REC_TYPE,	"UNMOUNT" }, \
 	{ XFS_TRANS_SET_AGSTATE,	"SET_AGSTATE" }, \
-	{ XFS_TRANS_SWAPINO,		"SWAPINO" }
+	{ XFS_TRANS_SWAPINO,		"SWAPINO" }, \
+	{ XFS_TRANS_SHRINKFS,		"SHRINKFS" }
 
 /*
  * This structure is used to track log items associated with
@@ -267,6 +269,7 @@ struct xfs_log_item_desc {
 #define	XFS_ATTRRM_LOG_RES(mp)	((mp)->m_reservations.tr_attrrm)
 #define	XFS_CLEAR_AGI_BUCKET_LOG_RES(mp)  ((mp)->m_reservations.tr_clearagi)
 #define XFS_SETAGSTATE_LOG_RES(mp) ((mp)->m_reservations.tr_setagstate)
+#define XFS_SHRINKDATA_LOG_RES(mp) ((mp)->m_reservations.tr_shrinkdata)
 
 /*
  * Various log count values.
diff --git a/fs/xfs/xfs_trans_space.h b/fs/xfs/xfs_trans_space.h
index 7d2c920..103e442 100644
--- a/fs/xfs/xfs_trans_space.h
+++ b/fs/xfs/xfs_trans_space.h
@@ -82,5 +82,7 @@
 	(XFS_DIRREMOVE_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl))
 #define	XFS_SYMLINK_SPACE_RES(mp,nl,b)	\
 	(XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl) + (b))
+#define	XFS_SHRINKFS_SPACE_RES(mp)	\
+	(2 * XFS_AG_MAXLEVELS(mp))
 
 #endif	/* __XFS_TRANS_SPACE_H__ */
-- 
1.7.4.1

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-11-16  6:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-16  6:46 [PATCH 10/15] xfs: Introduce a new transaction for shrinking fs data section Jeff Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.