xfs: Refactor xfs_ticket_alloc() to extract a new helper
PATCH v2 6/8 xfs: Refactor xfs_ticket_alloc() to extract a new helper
From: Jie Liu <[email protected]>
Refactor xfs_ticket_alloc() to extract a new helper, i.e. xfs_log_calc_unit_res().
This helper would be used to calcaulation the total log reservation size by adding extra log operation/transation headers for a new log ticket.
Signed-off-by Jie Liu <[email protected]>
--- fs/xfs/xfs_log.c | 53 +++++++++++++++++++++++++++++++++++------------------ fs/xfs/xfs_log.h | 1 + 2 files changed, 36 insertions(+), 18 deletions(-)
fs/xfs/xfs_log.c +35 -18
@@ -3377,24 +3377,17 @@ xfs_log_ticket_get( }/* -* Allocate and initialise a new log ticket. +* Figure out the total log space unit (in bytes) that would be +* required for a log ticket. */ -struct xlog_ticket * -xlog_ticket_alloc ( -struct xlog *log, -int unit_bytes, -int cnt, -char client, -bool permanent, -xfs_km_flags_t alloc_flags) +int +xfs_log_calc_unit_res ( +struct xfs_mount *mp, +int unit_bytes) { -struct xlog_ticket *tic; -uint num_headers; -int iclog_space; - - tic =kmem_zone_zalloc (xfs_log_ticket_zone, alloc_flags); -if (!tic) -return NULL ; +struct xlog *log = mp->m_log; +int iclog_space; +uint num_headers;/* * Permanent reservations have up to 'cnt'-1 active log operations
@@ -3478,11 +3471,35 @@ xlog_ticket_alloc( unit_bytes +=2 *BBSIZE ; } +return unit_bytes; +} + +/* +* Allocate and initialise a new log ticket. +*/ +struct xlog_ticket * +xlog_ticket_alloc ( +struct xlog *log, +int unit_bytes, +int cnt, +char client, +bool permanent, +xfs_km_flags_t alloc_flags) +{ +struct xlog_ticket *tic; +int unit_res; + + unit_res =xfs_log_calc_unit_res (log->l_mp, unit_bytes); + + tic =kmem_zone_zalloc (xfs_log_ticket_zone, alloc_flags); +if (!tic) +return NULL ; +atomic_set (&tic->t_ref,1 ); tic->t_task = current;INIT_LIST_HEAD (&tic->t_queue); - tic->t_unit_res = unit_bytes; - tic->t_curr_res = unit_bytes; + tic->t_unit_res = unit_res; + tic->t_curr_res = unit_res; tic->t_cnt = cnt; tic->t_ocnt = cnt; tic->t_tid =prandom_u32 ();
fs/xfs/xfs_log.h +1 -0
@@ -184,6 +184,7 @@ bool xfs_log_item_in_current_chkpt(struct xfs_log_item *lip);void xfs_log_work_queue (struct xfs_mount *mp);void xfs_log_worker (struct work_struct *work);void xfs_log_quiesce (struct xfs_mount *mp); +int xfs_log_calc_unit_res (struct xfs_mount *mp,int unit_bytes);#endif #endif /* __XFS_LOG_H__ */
Signature · 6 lines
1.7.9.5 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs