From: Jeff Liu Date: Tue, 19 Feb 2013 05:31:20 +0000 (+0000) Subject: xfsprogs: sync xfs_calc_buf_res() to user space X-Git-Tag: v3.1.11~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9aa758dee22eb386838ea87ef4c52a36803d4fd9;p=thirdparty%2Fxfsprogs-dev.git xfsprogs: sync xfs_calc_buf_res() to user space Sync the new helper xfs_calc_buf_res() to user space. Signed-off-by: Jie Liu Reviewed-by: Mark Tinguely Signed-off-by: Mark Tinguely --- diff --git a/libxfs/xfs_trans.c b/libxfs/xfs_trans.c index 635de8f28..d7ff1a9e8 100644 --- a/libxfs/xfs_trans.c +++ b/libxfs/xfs_trans.c @@ -22,6 +22,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. *