Add a helper xfs_calc_buf_res() to calcuate out the space log reservations per
item which were got
involved in a transaction. It will call the xfs_buf_log_overhead() to figure
out the extra space
for the struct xfs_buf_log_format that gets written into the log for every
buffer as well as a little
bit of extra space because there also needs a log opheader, i.e. struct
Signed-off-by: Jie Liu <jeff.liu@xxxxxxxxxx>
fs/xfs/xfs_trans.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 06ed520..6c601ea 100644
@@ -37,14 +37,45 @@
+ * 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.
+ 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.
+ uint nbufs,
+ uint size)
+ return nbufs * (size + xfs_buf_log_overhead());
* Various log reservation values.