]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfsprogs: sync xfs_calc_buf_res() to user space
authorJeff Liu <jeff.liu@oracle.com>
Tue, 19 Feb 2013 05:31:20 +0000 (05:31 +0000)
committerMark Tinguely <tinguely@eagdhcp-232-136.americas.sgi.com>
Wed, 20 Feb 2013 19:55:33 +0000 (13:55 -0600)
Sync the new helper xfs_calc_buf_res() to user space.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Mark Tinguely <tinguely@sgi.com>
libxfs/xfs_trans.c

index 635de8f28c59856d6f568155d28c9fe09a1bcfef..d7ff1a9e84d19281d111f6a038522c22c8210fb7 100644 (file)
 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.
  *