diff options
author | Jeff Liu <jeff.liu@oracle.com> | 2013-01-28 08:25:35 -0500 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-02-01 15:35:06 -0500 |
commit | 4f3b57832ba39223c6f8823d07b9fb206e282ced (patch) | |
tree | 071d5d58fee6d361e4197804c37f8ffced556812 /fs/xfs/xfs_trans.c | |
parent | 2729423cf2ef3ac51d040f24a5ddd84c1b2acc70 (diff) |
xfs: add a helper to figure out the space log reservation per item
Add a new helper xfs_calc_buf_res() to calcuate out the transaction space
reservations per item. xfs_buf_log_overhead() is used to figure out the
extra space for struct xfs_buf_log_format that gets written into the log
for every buffer as well as a log opheader, i.e. struct xlog_op_header.
Signed-off-by: Jie Liu <jeff.liu@oracle.com>
CC: Dave Chinner <david@fromorbit.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_trans.c')
-rw-r--r-- | fs/xfs/xfs_trans.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 06ed520a767f..6c601ea77a9e 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c | |||
@@ -37,14 +37,45 @@ | |||
37 | #include "xfs_extent_busy.h" | 37 | #include "xfs_extent_busy.h" |
38 | #include "xfs_bmap.h" | 38 | #include "xfs_bmap.h" |
39 | #include "xfs_quota.h" | 39 | #include "xfs_quota.h" |
40 | #include "xfs_qm.h" | ||
40 | #include "xfs_trans_priv.h" | 41 | #include "xfs_trans_priv.h" |
41 | #include "xfs_trans_space.h" | 42 | #include "xfs_trans_space.h" |
42 | #include "xfs_inode_item.h" | 43 | #include "xfs_inode_item.h" |
44 | #include "xfs_log_priv.h" | ||
45 | #include "xfs_buf_item.h" | ||
43 | #include "xfs_trace.h" | 46 | #include "xfs_trace.h" |
44 | 47 | ||
45 | kmem_zone_t *xfs_trans_zone; | 48 | kmem_zone_t *xfs_trans_zone; |
46 | kmem_zone_t *xfs_log_item_desc_zone; | 49 | kmem_zone_t *xfs_log_item_desc_zone; |
47 | 50 | ||
51 | /* | ||
52 | * A buffer has a format structure overhead in the log in addition | ||
53 | * to the data, so we need to take this into account when reserving | ||
54 | * space in a transaction for a buffer. Round the space required up | ||
55 | * to a multiple of 128 bytes so that we don't change the historical | ||
56 | * reservation that has been used for this overhead. | ||
57 | */ | ||
58 | STATIC uint | ||
59 | xfs_buf_log_overhead(void) | ||
60 | { | ||
61 | return round_up(sizeof(struct xlog_op_header) + | ||
62 | sizeof(struct xfs_buf_log_format), 128); | ||
63 | } | ||
64 | |||
65 | /* | ||
66 | * Calculate out transaction log reservation per item in bytes. | ||
67 | * | ||
68 | * The nbufs argument is used to indicate the number of items that | ||
69 | * will be changed in a transaction. size is used to tell how many | ||
70 | * bytes should be reserved per item. | ||
71 | */ | ||
72 | STATIC uint | ||
73 | xfs_calc_buf_res( | ||
74 | uint nbufs, | ||
75 | uint size) | ||
76 | { | ||
77 | return nbufs * (size + xfs_buf_log_overhead()); | ||
78 | } | ||
48 | 79 | ||
49 | /* | 80 | /* |
50 | * Various log reservation values. | 81 | * Various log reservation values. |