Skip to content

Commit e2cf427

Browse files
author
Darrick J. Wong
committed
xfs: simplify rt bitmap/summary block accessor functions
Simplify the calling convention of these functions since the xfs_rtalloc_args structure contains the parameters we need. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent 5b1d0ae commit e2cf427

File tree

3 files changed

+42
-45
lines changed

3 files changed

+42
-45
lines changed

fs/xfs/libxfs/xfs_rtbitmap.c

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ xfs_rtfind_back(
173173
* Compute match value, based on the bit at start: if 1 (free)
174174
* then all-ones, else all-zeroes.
175175
*/
176-
incore = xfs_rtbitmap_getword(args->rbmbp, word);
176+
incore = xfs_rtbitmap_getword(args, word);
177177
want = (incore & ((xfs_rtword_t)1 << bit)) ? -1 : 0;
178178
/*
179179
* If the starting position is not word-aligned, deal with the
@@ -228,7 +228,7 @@ xfs_rtfind_back(
228228
/*
229229
* Compute difference between actual and desired value.
230230
*/
231-
incore = xfs_rtbitmap_getword(args->rbmbp, word);
231+
incore = xfs_rtbitmap_getword(args, word);
232232
if ((wdiff = incore ^ want)) {
233233
/*
234234
* Different, mark where we are and return.
@@ -267,7 +267,7 @@ xfs_rtfind_back(
267267
/*
268268
* Compute difference between actual and desired value.
269269
*/
270-
incore = xfs_rtbitmap_getword(args->rbmbp, word);
270+
incore = xfs_rtbitmap_getword(args, word);
271271
if ((wdiff = (incore ^ want) & mask)) {
272272
/*
273273
* Different, mark where we are and return.
@@ -327,7 +327,7 @@ xfs_rtfind_forw(
327327
* Compute match value, based on the bit at start: if 1 (free)
328328
* then all-ones, else all-zeroes.
329329
*/
330-
incore = xfs_rtbitmap_getword(args->rbmbp, word);
330+
incore = xfs_rtbitmap_getword(args, word);
331331
want = (incore & ((xfs_rtword_t)1 << bit)) ? -1 : 0;
332332
/*
333333
* If the starting position is not word-aligned, deal with the
@@ -381,7 +381,7 @@ xfs_rtfind_forw(
381381
/*
382382
* Compute difference between actual and desired value.
383383
*/
384-
incore = xfs_rtbitmap_getword(args->rbmbp, word);
384+
incore = xfs_rtbitmap_getword(args, word);
385385
if ((wdiff = incore ^ want)) {
386386
/*
387387
* Different, mark where we are and return.
@@ -418,7 +418,7 @@ xfs_rtfind_forw(
418418
/*
419419
* Compute difference between actual and desired value.
420420
*/
421-
incore = xfs_rtbitmap_getword(args->rbmbp, word);
421+
incore = xfs_rtbitmap_getword(args, word);
422422
if ((wdiff = (incore ^ want) & mask)) {
423423
/*
424424
* Different, mark where we are and return.
@@ -439,16 +439,16 @@ xfs_rtfind_forw(
439439
/* Log rtsummary counter at @infoword. */
440440
static inline void
441441
xfs_trans_log_rtsummary(
442-
struct xfs_trans *tp,
443-
struct xfs_buf *bp,
442+
struct xfs_rtalloc_args *args,
444443
unsigned int infoword)
445444
{
445+
struct xfs_buf *bp = args->sumbp;
446446
size_t first, last;
447447

448-
first = (void *)xfs_rsumblock_infoptr(bp, infoword) - bp->b_addr;
448+
first = (void *)xfs_rsumblock_infoptr(args, infoword) - bp->b_addr;
449449
last = first + sizeof(xfs_suminfo_t) - 1;
450450

451-
xfs_trans_log_buf(tp, bp, first, last);
451+
xfs_trans_log_buf(args->tp, bp, first, last);
452452
}
453453

454454
/*
@@ -492,20 +492,19 @@ xfs_rtmodify_summary_int(
492492
*/
493493
infoword = xfs_rtsumoffs_to_infoword(mp, so);
494494
if (delta) {
495-
xfs_suminfo_t val = xfs_suminfo_add(args->sumbp, infoword,
496-
delta);
495+
xfs_suminfo_t val = xfs_suminfo_add(args, infoword, delta);
497496

498497
if (mp->m_rsum_cache) {
499498
if (val == 0 && log == mp->m_rsum_cache[bbno])
500499
mp->m_rsum_cache[bbno]++;
501500
if (val != 0 && log < mp->m_rsum_cache[bbno])
502501
mp->m_rsum_cache[bbno] = log;
503502
}
504-
xfs_trans_log_rtsummary(args->tp, args->sumbp, infoword);
503+
xfs_trans_log_rtsummary(args, infoword);
505504
if (sum)
506505
*sum = val;
507506
} else if (sum) {
508-
*sum = xfs_suminfo_get(args->sumbp, infoword);
507+
*sum = xfs_suminfo_get(args, infoword);
509508
}
510509
return 0;
511510
}
@@ -523,17 +522,17 @@ xfs_rtmodify_summary(
523522
/* Log rtbitmap block from the word @from to the byte before @next. */
524523
static inline void
525524
xfs_trans_log_rtbitmap(
526-
struct xfs_trans *tp,
527-
struct xfs_buf *bp,
525+
struct xfs_rtalloc_args *args,
528526
unsigned int from,
529527
unsigned int next)
530528
{
529+
struct xfs_buf *bp = args->rbmbp;
531530
size_t first, last;
532531

533-
first = (void *)xfs_rbmblock_wordptr(bp, from) - bp->b_addr;
534-
last = ((void *)xfs_rbmblock_wordptr(bp, next) - 1) - bp->b_addr;
532+
first = (void *)xfs_rbmblock_wordptr(args, from) - bp->b_addr;
533+
last = ((void *)xfs_rbmblock_wordptr(args, next) - 1) - bp->b_addr;
535534

536-
xfs_trans_log_buf(tp, bp, first, last);
535+
xfs_trans_log_buf(args->tp, bp, first, last);
537536
}
538537

539538
/*
@@ -591,12 +590,12 @@ xfs_rtmodify_range(
591590
/*
592591
* Set/clear the active bits.
593592
*/
594-
incore = xfs_rtbitmap_getword(args->rbmbp, word);
593+
incore = xfs_rtbitmap_getword(args, word);
595594
if (val)
596595
incore |= mask;
597596
else
598597
incore &= ~mask;
599-
xfs_rtbitmap_setword(args->rbmbp, word, incore);
598+
xfs_rtbitmap_setword(args, word, incore);
600599
i = lastbit - bit;
601600
/*
602601
* Go on to the next block if that's where the next word is
@@ -607,8 +606,7 @@ xfs_rtmodify_range(
607606
* Log the changed part of this block.
608607
* Get the next one.
609608
*/
610-
xfs_trans_log_rtbitmap(args->tp, args->rbmbp, firstword,
611-
word);
609+
xfs_trans_log_rtbitmap(args, firstword, word);
612610
error = xfs_rtbitmap_read_buf(args, ++block);
613611
if (error)
614612
return error;
@@ -629,7 +627,7 @@ xfs_rtmodify_range(
629627
/*
630628
* Set the word value correctly.
631629
*/
632-
xfs_rtbitmap_setword(args->rbmbp, word, val);
630+
xfs_rtbitmap_setword(args, word, val);
633631
i += XFS_NBWORD;
634632
/*
635633
* Go on to the next block if that's where the next word is
@@ -640,8 +638,7 @@ xfs_rtmodify_range(
640638
* Log the changed part of this block.
641639
* Get the next one.
642640
*/
643-
xfs_trans_log_rtbitmap(args->tp, args->rbmbp, firstword,
644-
word);
641+
xfs_trans_log_rtbitmap(args, firstword, word);
645642
error = xfs_rtbitmap_read_buf(args, ++block);
646643
if (error)
647644
return error;
@@ -661,19 +658,19 @@ xfs_rtmodify_range(
661658
/*
662659
* Set/clear the active bits.
663660
*/
664-
incore = xfs_rtbitmap_getword(args->rbmbp, word);
661+
incore = xfs_rtbitmap_getword(args, word);
665662
if (val)
666663
incore |= mask;
667664
else
668665
incore &= ~mask;
669-
xfs_rtbitmap_setword(args->rbmbp, word, incore);
666+
xfs_rtbitmap_setword(args, word, incore);
670667
word++;
671668
}
672669
/*
673670
* Log any remaining changed bytes.
674671
*/
675672
if (word > firstword)
676-
xfs_trans_log_rtbitmap(args->tp, args->rbmbp, firstword, word);
673+
xfs_trans_log_rtbitmap(args, firstword, word);
677674
return 0;
678675
}
679676

@@ -810,7 +807,7 @@ xfs_rtcheck_range(
810807
/*
811808
* Compute difference between actual and desired value.
812809
*/
813-
incore = xfs_rtbitmap_getword(args->rbmbp, word);
810+
incore = xfs_rtbitmap_getword(args, word);
814811
if ((wdiff = (incore ^ val) & mask)) {
815812
/*
816813
* Different, compute first wrong bit and return.
@@ -849,7 +846,7 @@ xfs_rtcheck_range(
849846
/*
850847
* Compute difference between actual and desired value.
851848
*/
852-
incore = xfs_rtbitmap_getword(args->rbmbp, word);
849+
incore = xfs_rtbitmap_getword(args, word);
853850
if ((wdiff = incore ^ val)) {
854851
/*
855852
* Different, compute first wrong bit and return.
@@ -887,7 +884,7 @@ xfs_rtcheck_range(
887884
/*
888885
* Compute difference between actual and desired value.
889886
*/
890-
incore = xfs_rtbitmap_getword(args->rbmbp, word);
887+
incore = xfs_rtbitmap_getword(args, word);
891888
if ((wdiff = (incore ^ val) & mask)) {
892889
/*
893890
* Different, compute first wrong bit and return.

fs/xfs/libxfs/xfs_rtbitmap.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,33 +172,33 @@ xfs_rbmblock_to_rtx(
172172
/* Return a pointer to a bitmap word within a rt bitmap block. */
173173
static inline union xfs_rtword_raw *
174174
xfs_rbmblock_wordptr(
175-
struct xfs_buf *bp,
175+
struct xfs_rtalloc_args *args,
176176
unsigned int index)
177177
{
178-
union xfs_rtword_raw *words = bp->b_addr;
178+
union xfs_rtword_raw *words = args->rbmbp->b_addr;
179179

180180
return words + index;
181181
}
182182

183183
/* Convert an ondisk bitmap word to its incore representation. */
184184
static inline xfs_rtword_t
185185
xfs_rtbitmap_getword(
186-
struct xfs_buf *bp,
186+
struct xfs_rtalloc_args *args,
187187
unsigned int index)
188188
{
189-
union xfs_rtword_raw *word = xfs_rbmblock_wordptr(bp, index);
189+
union xfs_rtword_raw *word = xfs_rbmblock_wordptr(args, index);
190190

191191
return word->old;
192192
}
193193

194194
/* Set an ondisk bitmap word from an incore representation. */
195195
static inline void
196196
xfs_rtbitmap_setword(
197-
struct xfs_buf *bp,
197+
struct xfs_rtalloc_args *args,
198198
unsigned int index,
199199
xfs_rtword_t value)
200200
{
201-
union xfs_rtword_raw *word = xfs_rbmblock_wordptr(bp, index);
201+
union xfs_rtword_raw *word = xfs_rbmblock_wordptr(args, index);
202202

203203
word->old = value;
204204
}
@@ -245,33 +245,33 @@ xfs_rtsumoffs_to_infoword(
245245
/* Return a pointer to a summary info word within a rt summary block. */
246246
static inline union xfs_suminfo_raw *
247247
xfs_rsumblock_infoptr(
248-
struct xfs_buf *bp,
248+
struct xfs_rtalloc_args *args,
249249
unsigned int index)
250250
{
251-
union xfs_suminfo_raw *info = bp->b_addr;
251+
union xfs_suminfo_raw *info = args->sumbp->b_addr;
252252

253253
return info + index;
254254
}
255255

256256
/* Get the current value of a summary counter. */
257257
static inline xfs_suminfo_t
258258
xfs_suminfo_get(
259-
struct xfs_buf *bp,
259+
struct xfs_rtalloc_args *args,
260260
unsigned int index)
261261
{
262-
union xfs_suminfo_raw *info = xfs_rsumblock_infoptr(bp, index);
262+
union xfs_suminfo_raw *info = xfs_rsumblock_infoptr(args, index);
263263

264264
return info->old;
265265
}
266266

267267
/* Add to the current value of a summary counter and return the new value. */
268268
static inline xfs_suminfo_t
269269
xfs_suminfo_add(
270-
struct xfs_buf *bp,
270+
struct xfs_rtalloc_args *args,
271271
unsigned int index,
272272
int delta)
273273
{
274-
union xfs_suminfo_raw *info = xfs_rsumblock_infoptr(bp, index);
274+
union xfs_suminfo_raw *info = xfs_rsumblock_infoptr(args, index);
275275

276276
info->old += delta;
277277
return info->old;

fs/xfs/scrub/rtsummary.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ xchk_rtsum_compare(
231231
return error;
232232
}
233233

234-
ondisk_info = xfs_rsumblock_infoptr(args.sumbp, 0);
234+
ondisk_info = xfs_rsumblock_infoptr(&args, 0);
235235
if (memcmp(ondisk_info, sc->buf,
236236
mp->m_blockwsize << XFS_WORDLOG) != 0)
237237
xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, off);

0 commit comments

Comments
 (0)