aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_log.c
diff options
context:
space:
mode:
authorJie Liu <jeff.liu@oracle.com>2013-08-12 06:50:01 -0400
committerBen Myers <bpm@sgi.com>2013-08-12 18:49:02 -0400
commite773fc934fcbe2536dc625c2bd76234b9b9a60b6 (patch)
tree25faa59058c2c6168bc3b61392c0a356b8c3b798 /fs/xfs/xfs_log.c
parentf749278c5a45e8a80f3e3ca41d4634b84948b9d9 (diff)
xfs: Refactor xfs_ticket_alloc() to extract a new helper
Refactor xlog_ticket_alloc() to extract a new helper, i.e. xfs_log_calc_unit_res(). This helper would be used to calculate the total log reservation size by adding extra log operation/transation headers for a new log ticket. Signed-off-by: Jie Liu <jeff.liu@oracle.com> Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_log.c')
-rw-r--r--fs/xfs/xfs_log.c60
1 files changed, 38 insertions, 22 deletions
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index bf89eb97fefd..704f0959e9c6 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -3391,24 +3391,17 @@ xfs_log_ticket_get(
3391} 3391}
3392 3392
3393/* 3393/*
3394 * Allocate and initialise a new log ticket. 3394 * Figure out the total log space unit (in bytes) that would be
3395 * required for a log ticket.
3395 */ 3396 */
3396struct xlog_ticket * 3397int
3397xlog_ticket_alloc( 3398xfs_log_calc_unit_res(
3398 struct xlog *log, 3399 struct xfs_mount *mp,
3399 int unit_bytes, 3400 int unit_bytes)
3400 int cnt,
3401 char client,
3402 bool permanent,
3403 xfs_km_flags_t alloc_flags)
3404{ 3401{
3405 struct xlog_ticket *tic; 3402 struct xlog *log = mp->m_log;
3406 uint num_headers; 3403 int iclog_space;
3407 int iclog_space; 3404 uint num_headers;
3408
3409 tic = kmem_zone_zalloc(xfs_log_ticket_zone, alloc_flags);
3410 if (!tic)
3411 return NULL;
3412 3405
3413 /* 3406 /*
3414 * Permanent reservations have up to 'cnt'-1 active log operations 3407 * Permanent reservations have up to 'cnt'-1 active log operations
@@ -3483,20 +3476,43 @@ xlog_ticket_alloc(
3483 unit_bytes += log->l_iclog_hsize; 3476 unit_bytes += log->l_iclog_hsize;
3484 3477
3485 /* for roundoff padding for transaction data and one for commit record */ 3478 /* for roundoff padding for transaction data and one for commit record */
3486 if (xfs_sb_version_haslogv2(&log->l_mp->m_sb) && 3479 if (xfs_sb_version_haslogv2(&mp->m_sb) && mp->m_sb.sb_logsunit > 1) {
3487 log->l_mp->m_sb.sb_logsunit > 1) {
3488 /* log su roundoff */ 3480 /* log su roundoff */
3489 unit_bytes += 2*log->l_mp->m_sb.sb_logsunit; 3481 unit_bytes += 2 * mp->m_sb.sb_logsunit;
3490 } else { 3482 } else {
3491 /* BB roundoff */ 3483 /* BB roundoff */
3492 unit_bytes += 2*BBSIZE; 3484 unit_bytes += 2 * BBSIZE;
3493 } 3485 }
3494 3486
3487 return unit_bytes;
3488}
3489
3490/*
3491 * Allocate and initialise a new log ticket.
3492 */
3493struct xlog_ticket *
3494xlog_ticket_alloc(
3495 struct xlog *log,
3496 int unit_bytes,
3497 int cnt,
3498 char client,
3499 bool permanent,
3500 xfs_km_flags_t alloc_flags)
3501{
3502 struct xlog_ticket *tic;
3503 int unit_res;
3504
3505 tic = kmem_zone_zalloc(xfs_log_ticket_zone, alloc_flags);
3506 if (!tic)
3507 return NULL;
3508
3509 unit_res = xfs_log_calc_unit_res(log->l_mp, unit_bytes);
3510
3495 atomic_set(&tic->t_ref, 1); 3511 atomic_set(&tic->t_ref, 1);
3496 tic->t_task = current; 3512 tic->t_task = current;
3497 INIT_LIST_HEAD(&tic->t_queue); 3513 INIT_LIST_HEAD(&tic->t_queue);
3498 tic->t_unit_res = unit_bytes; 3514 tic->t_unit_res = unit_res;
3499 tic->t_curr_res = unit_bytes; 3515 tic->t_curr_res = unit_res;
3500 tic->t_cnt = cnt; 3516 tic->t_cnt = cnt;
3501 tic->t_ocnt = cnt; 3517 tic->t_ocnt = cnt;
3502 tic->t_tid = prandom_u32(); 3518 tic->t_tid = prandom_u32();