From: Jeff Liu <jeff.liu@oracle.com>
To: xfs@oss.sgi.com
Subject: [PATCH 10/15] xfs: Introduce a new transaction for shrinking fs data section
Date: Fri, 16 Nov 2012 14:46:16 +0800 [thread overview]
Message-ID: <50A5E138.3080801@oracle.com> (raw)
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
reply other threads:[~2012-11-16 6:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=50A5E138.3080801@oracle.com \
--to=jeff.liu@oracle.com \
--cc=xfs@oss.sgi.com \
/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 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.