xfs
[Top] [All Lists]

[PATCH v3 1/3] xfsprogs: sync xfs_calc_buf_res() to user space

To: "xfs@xxxxxxxxxxx" <xfs@xxxxxxxxxxx>
Subject: [PATCH v3 1/3] xfsprogs: sync xfs_calc_buf_res() to user space
From: Jeff Liu <jeff.liu@xxxxxxxxxx>
Date: Tue, 19 Feb 2013 13:31:20 +0800
Cc: Mark Tinguely <tinguely@xxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121028 Thunderbird/16.0.2
Sync the new helper xfs_calc_buf_res() to user space.

Signed-off-by: Jie Liu <jeff.liu@xxxxxxxxxx>

---
 libxfs/xfs_trans.c |   29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/libxfs/xfs_trans.c b/libxfs/xfs_trans.c
index 635de8f..d7ff1a9 100644
--- a/libxfs/xfs_trans.c
+++ b/libxfs/xfs_trans.c
@@ -23,6 +23,35 @@ kmem_zone_t  *xfs_trans_zone;
 kmem_zone_t    *xfs_log_item_desc_zone;
 
 /*
+ * A buffer has a format structure overhead in the log in addition
+ * to the data, so we need to take this into account when reserving
+ * space in a transaction for a buffer.  Round the space required up
+ * to a multiple of 128 bytes so that we don't change the historical
+ * reservation that has been used for this overhead.
+ */
+STATIC uint
+xfs_buf_log_overhead(void)
+{
+       return round_up(sizeof(struct xlog_op_header) +
+                       sizeof(struct xfs_buf_log_format), 128);
+}
+
+/*
+ * Calculate out transaction log reservation per item in bytes.
+ *
+ * The nbufs argument is used to indicate the number of items that
+ * will be changed in a transaction.  size is used to tell how many
+ * bytes should be reserved per item.
+ */
+STATIC uint
+xfs_calc_buf_res(
+       uint            nbufs,
+       uint            size)
+{
+       return nbufs * (size + xfs_buf_log_overhead());
+}
+
+/*
  * Various log reservation values.
  *
  * These are based on the size of the file system block because that is what
-- 
1.7.9.5

<Prev in Thread] Current Thread [Next in Thread>