Skip to contentSkip to conversation

xfsprogs: sync xfs_calc_buf_res() to the user space

PATCH Superseded Jeff Liu 2 participants 2 messages Jan 28, 2013

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jeff Liu

author
#0 lore raw

PATCH v2 1/2 xfsprogs: sync xfs_calc_buf_res() to the user space

Sync the new helper xfs_calc_buf_res() to the user space.

---
 libxfs/xfs_trans.c |   29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
libxfs/xfs_trans.c +29 -0
index 635de8f..d7ff1a9 100644
@@ -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
Signature · 6 lines
1.7.9.5

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v2 1/2
#1 lore raw
Quoted 37 lines · Jeff Liu

Sync the new helper xfs_calc_buf_res() to the user space.

---
  libxfs/xfs_trans.c |   29 +++++++++++++++++++++++++++++
  1 file changed, 29 insertions(+)
libxfs/xfs_trans.c +22 -0
index 635de8f..d7ff1a9 100644
@@ -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(

libxfs/xfs_trans.c kmem_zone_t *xfs_trans_zone; · line 57

Quoted 10 lines
libxfs/xfs_trans.c +7 -0
+	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

Looks good.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs