Skip to content

Commit b271b31

Browse files
Christoph HellwigChandan Babu R
authored andcommitted
xfs: split xfs_rtmodify_summary_int
Inline the logic of xfs_rtmodify_summary_int into xfs_rtmodify_summary and xfs_rtget_summary instead of having a somewhat awkward helper to share a little bit of code. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
1 parent c2adcfa commit b271b31

File tree

1 file changed

+25
-51
lines changed

1 file changed

+25
-51
lines changed

fs/xfs/libxfs/xfs_rtbitmap.c

Lines changed: 25 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -452,71 +452,38 @@ xfs_trans_log_rtsummary(
452452
}
453453

454454
/*
455-
* Read and/or modify the summary information for a given extent size,
456-
* bitmap block combination.
457-
* Keeps track of a current summary block, so we don't keep reading
458-
* it from the buffer cache.
459-
*
460-
* Summary information is returned in *sum if specified.
461-
* If no delta is specified, returns summary only.
455+
* Modify the summary information for a given extent size, bitmap block
456+
* combination.
462457
*/
463458
int
464-
xfs_rtmodify_summary_int(
459+
xfs_rtmodify_summary(
465460
struct xfs_rtalloc_args *args,
466461
int log, /* log2 of extent size */
467462
xfs_fileoff_t bbno, /* bitmap block number */
468-
int delta, /* change to make to summary info */
469-
xfs_suminfo_t *sum) /* out: summary info for this block */
463+
int delta) /* in/out: summary block number */
470464
{
471465
struct xfs_mount *mp = args->mp;
472-
int error;
473-
xfs_fileoff_t sb; /* summary fsblock */
474-
xfs_rtsumoff_t so; /* index into the summary file */
466+
xfs_rtsumoff_t so = xfs_rtsumoffs(mp, log, bbno);
475467
unsigned int infoword;
468+
xfs_suminfo_t val;
469+
int error;
476470

477-
/*
478-
* Compute entry number in the summary file.
479-
*/
480-
so = xfs_rtsumoffs(mp, log, bbno);
481-
/*
482-
* Compute the block number in the summary file.
483-
*/
484-
sb = xfs_rtsumoffs_to_block(mp, so);
485-
486-
error = xfs_rtsummary_read_buf(args, sb);
471+
error = xfs_rtsummary_read_buf(args, xfs_rtsumoffs_to_block(mp, so));
487472
if (error)
488473
return error;
489474

490-
/*
491-
* Point to the summary information, modify/log it, and/or copy it out.
492-
*/
493475
infoword = xfs_rtsumoffs_to_infoword(mp, so);
494-
if (delta) {
495-
xfs_suminfo_t val = xfs_suminfo_add(args, infoword, delta);
496-
497-
if (mp->m_rsum_cache) {
498-
if (val == 0 && log + 1 == mp->m_rsum_cache[bbno])
499-
mp->m_rsum_cache[bbno] = log;
500-
if (val != 0 && log >= mp->m_rsum_cache[bbno])
501-
mp->m_rsum_cache[bbno] = log + 1;
502-
}
503-
xfs_trans_log_rtsummary(args, infoword);
504-
if (sum)
505-
*sum = val;
506-
} else if (sum) {
507-
*sum = xfs_suminfo_get(args, infoword);
476+
val = xfs_suminfo_add(args, infoword, delta);
477+
478+
if (mp->m_rsum_cache) {
479+
if (val == 0 && log + 1 == mp->m_rsum_cache[bbno])
480+
mp->m_rsum_cache[bbno] = log;
481+
if (val != 0 && log >= mp->m_rsum_cache[bbno])
482+
mp->m_rsum_cache[bbno] = log + 1;
508483
}
509-
return 0;
510-
}
511484

512-
int
513-
xfs_rtmodify_summary(
514-
struct xfs_rtalloc_args *args,
515-
int log, /* log2 of extent size */
516-
xfs_fileoff_t bbno, /* bitmap block number */
517-
int delta) /* in/out: summary block number */
518-
{
519-
return xfs_rtmodify_summary_int(args, log, bbno, delta, NULL);
485+
xfs_trans_log_rtsummary(args, infoword);
486+
return 0;
520487
}
521488

522489
/*
@@ -530,7 +497,14 @@ xfs_rtget_summary(
530497
xfs_fileoff_t bbno, /* bitmap block number */
531498
xfs_suminfo_t *sum) /* out: summary info for this block */
532499
{
533-
return xfs_rtmodify_summary_int(args, log, bbno, 0, sum);
500+
struct xfs_mount *mp = args->mp;
501+
xfs_rtsumoff_t so = xfs_rtsumoffs(mp, log, bbno);
502+
int error;
503+
504+
error = xfs_rtsummary_read_buf(args, xfs_rtsumoffs_to_block(mp, so));
505+
if (!error)
506+
*sum = xfs_suminfo_get(args, xfs_rtsumoffs_to_infoword(mp, so));
507+
return error;
534508
}
535509

536510
/* Log rtbitmap block from the word @from to the byte before @next. */

0 commit comments

Comments
 (0)