@@ -99,7 +99,6 @@ xfs_rtfind_back(
99
99
xfs_rtxnum_t limit , /* last rtext to look at */
100
100
xfs_rtxnum_t * rtx ) /* out: start rtext found */
101
101
{
102
- xfs_rtword_t * b ; /* current word in buffer */
103
102
int bit ; /* bit number in the word */
104
103
xfs_fileoff_t block ; /* bitmap block number */
105
104
struct xfs_buf * bp ; /* buf for the block */
@@ -110,6 +109,7 @@ xfs_rtfind_back(
110
109
xfs_rtword_t mask ; /* mask of relevant bits for value */
111
110
xfs_rtword_t want ; /* mask for "good" values */
112
111
xfs_rtword_t wdiff ; /* difference from wanted value */
112
+ xfs_rtword_t incore ;
113
113
unsigned int word ; /* word number in the buffer */
114
114
115
115
/*
@@ -125,14 +125,14 @@ xfs_rtfind_back(
125
125
* Get the first word's index & point to it.
126
126
*/
127
127
word = xfs_rtx_to_rbmword (mp , start );
128
- b = xfs_rbmblock_wordptr (bp , word );
129
128
bit = (int )(start & (XFS_NBWORD - 1 ));
130
129
len = start - limit + 1 ;
131
130
/*
132
131
* Compute match value, based on the bit at start: if 1 (free)
133
132
* then all-ones, else all-zeroes.
134
133
*/
135
- want = (* b & ((xfs_rtword_t )1 << bit )) ? -1 : 0 ;
134
+ incore = xfs_rtbitmap_getword (bp , word );
135
+ want = (incore & ((xfs_rtword_t )1 << bit )) ? -1 : 0 ;
136
136
/*
137
137
* If the starting position is not word-aligned, deal with the
138
138
* partial word.
@@ -149,7 +149,7 @@ xfs_rtfind_back(
149
149
* Calculate the difference between the value there
150
150
* and what we're looking for.
151
151
*/
152
- if ((wdiff = (* b ^ want ) & mask )) {
152
+ if ((wdiff = (incore ^ want ) & mask )) {
153
153
/*
154
154
* Different. Mark where we are and return.
155
155
*/
@@ -174,12 +174,6 @@ xfs_rtfind_back(
174
174
}
175
175
176
176
word = mp -> m_blockwsize - 1 ;
177
- b = xfs_rbmblock_wordptr (bp , word );
178
- } else {
179
- /*
180
- * Go on to the previous word in the buffer.
181
- */
182
- b -- ;
183
177
}
184
178
} else {
185
179
/*
@@ -195,7 +189,8 @@ xfs_rtfind_back(
195
189
/*
196
190
* Compute difference between actual and desired value.
197
191
*/
198
- if ((wdiff = * b ^ want )) {
192
+ incore = xfs_rtbitmap_getword (bp , word );
193
+ if ((wdiff = incore ^ want )) {
199
194
/*
200
195
* Different, mark where we are and return.
201
196
*/
@@ -220,12 +215,6 @@ xfs_rtfind_back(
220
215
}
221
216
222
217
word = mp -> m_blockwsize - 1 ;
223
- b = xfs_rbmblock_wordptr (bp , word );
224
- } else {
225
- /*
226
- * Go on to the previous word in the buffer.
227
- */
228
- b -- ;
229
218
}
230
219
}
231
220
/*
@@ -242,7 +231,8 @@ xfs_rtfind_back(
242
231
/*
243
232
* Compute difference between actual and desired value.
244
233
*/
245
- if ((wdiff = (* b ^ want ) & mask )) {
234
+ incore = xfs_rtbitmap_getword (bp , word );
235
+ if ((wdiff = (incore ^ want ) & mask )) {
246
236
/*
247
237
* Different, mark where we are and return.
248
238
*/
@@ -273,7 +263,6 @@ xfs_rtfind_forw(
273
263
xfs_rtxnum_t limit , /* last rtext to look at */
274
264
xfs_rtxnum_t * rtx ) /* out: start rtext found */
275
265
{
276
- xfs_rtword_t * b ; /* current word in buffer */
277
266
int bit ; /* bit number in the word */
278
267
xfs_fileoff_t block ; /* bitmap block number */
279
268
struct xfs_buf * bp ; /* buf for the block */
@@ -284,6 +273,7 @@ xfs_rtfind_forw(
284
273
xfs_rtword_t mask ; /* mask of relevant bits for value */
285
274
xfs_rtword_t want ; /* mask for "good" values */
286
275
xfs_rtword_t wdiff ; /* difference from wanted value */
276
+ xfs_rtword_t incore ;
287
277
unsigned int word ; /* word number in the buffer */
288
278
289
279
/*
@@ -299,14 +289,14 @@ xfs_rtfind_forw(
299
289
* Get the first word's index & point to it.
300
290
*/
301
291
word = xfs_rtx_to_rbmword (mp , start );
302
- b = xfs_rbmblock_wordptr (bp , word );
303
292
bit = (int )(start & (XFS_NBWORD - 1 ));
304
293
len = limit - start + 1 ;
305
294
/*
306
295
* Compute match value, based on the bit at start: if 1 (free)
307
296
* then all-ones, else all-zeroes.
308
297
*/
309
- want = (* b & ((xfs_rtword_t )1 << bit )) ? -1 : 0 ;
298
+ incore = xfs_rtbitmap_getword (bp , word );
299
+ want = (incore & ((xfs_rtword_t )1 << bit )) ? -1 : 0 ;
310
300
/*
311
301
* If the starting position is not word-aligned, deal with the
312
302
* partial word.
@@ -322,7 +312,7 @@ xfs_rtfind_forw(
322
312
* Calculate the difference between the value there
323
313
* and what we're looking for.
324
314
*/
325
- if ((wdiff = (* b ^ want ) & mask )) {
315
+ if ((wdiff = (incore ^ want ) & mask )) {
326
316
/*
327
317
* Different. Mark where we are and return.
328
318
*/
@@ -347,12 +337,6 @@ xfs_rtfind_forw(
347
337
}
348
338
349
339
word = 0 ;
350
- b = xfs_rbmblock_wordptr (bp , word );
351
- } else {
352
- /*
353
- * Go on to the previous word in the buffer.
354
- */
355
- b ++ ;
356
340
}
357
341
} else {
358
342
/*
@@ -368,7 +352,8 @@ xfs_rtfind_forw(
368
352
/*
369
353
* Compute difference between actual and desired value.
370
354
*/
371
- if ((wdiff = * b ^ want )) {
355
+ incore = xfs_rtbitmap_getword (bp , word );
356
+ if ((wdiff = incore ^ want )) {
372
357
/*
373
358
* Different, mark where we are and return.
374
359
*/
@@ -393,12 +378,6 @@ xfs_rtfind_forw(
393
378
}
394
379
395
380
word = 0 ;
396
- b = xfs_rbmblock_wordptr (bp , word );
397
- } else {
398
- /*
399
- * Go on to the next word in the buffer.
400
- */
401
- b ++ ;
402
381
}
403
382
}
404
383
/*
@@ -413,7 +392,8 @@ xfs_rtfind_forw(
413
392
/*
414
393
* Compute difference between actual and desired value.
415
394
*/
416
- if ((wdiff = (* b ^ want ) & mask )) {
395
+ incore = xfs_rtbitmap_getword (bp , word );
396
+ if ((wdiff = (incore ^ want ) & mask )) {
417
397
/*
418
398
* Different, mark where we are and return.
419
399
*/
@@ -568,15 +548,14 @@ xfs_rtmodify_range(
568
548
xfs_rtxlen_t len , /* length of extent to modify */
569
549
int val ) /* 1 for free, 0 for allocated */
570
550
{
571
- xfs_rtword_t * b ; /* current word in buffer */
572
551
int bit ; /* bit number in the word */
573
552
xfs_fileoff_t block ; /* bitmap block number */
574
553
struct xfs_buf * bp ; /* buf for the block */
575
554
int error ; /* error value */
576
- xfs_rtword_t * first ; /* first used word in the buffer */
577
555
int i ; /* current bit number rel. to start */
578
556
int lastbit ; /* last useful bit in word */
579
557
xfs_rtword_t mask ; /* mask o frelevant bits for value */
558
+ xfs_rtword_t incore ;
580
559
unsigned int firstword ; /* first word used in the buffer */
581
560
unsigned int word ; /* word number in the buffer */
582
561
@@ -596,7 +575,6 @@ xfs_rtmodify_range(
596
575
* Compute the starting word's address, and starting bit.
597
576
*/
598
577
firstword = word = xfs_rtx_to_rbmword (mp , start );
599
- first = b = xfs_rbmblock_wordptr (bp , word );
600
578
bit = (int )(start & (XFS_NBWORD - 1 ));
601
579
/*
602
580
* 0 (allocated) => all zeroes; 1 (free) => all ones.
@@ -615,10 +593,12 @@ xfs_rtmodify_range(
615
593
/*
616
594
* Set/clear the active bits.
617
595
*/
596
+ incore = xfs_rtbitmap_getword (bp , word );
618
597
if (val )
619
- * b |= mask ;
598
+ incore |= mask ;
620
599
else
621
- * b &= ~mask ;
600
+ incore &= ~mask ;
601
+ xfs_rtbitmap_setword (bp , word , incore );
622
602
i = lastbit - bit ;
623
603
/*
624
604
* Go on to the next block if that's where the next word is
@@ -636,12 +616,6 @@ xfs_rtmodify_range(
636
616
}
637
617
638
618
firstword = word = 0 ;
639
- first = b = xfs_rbmblock_wordptr (bp , word );
640
- } else {
641
- /*
642
- * Go on to the next word in the buffer
643
- */
644
- b ++ ;
645
619
}
646
620
} else {
647
621
/*
@@ -657,7 +631,7 @@ xfs_rtmodify_range(
657
631
/*
658
632
* Set the word value correctly.
659
633
*/
660
- * b = val ;
634
+ xfs_rtbitmap_setword ( bp , word , val ) ;
661
635
i += XFS_NBWORD ;
662
636
/*
663
637
* Go on to the next block if that's where the next word is
@@ -675,12 +649,6 @@ xfs_rtmodify_range(
675
649
}
676
650
677
651
firstword = word = 0 ;
678
- first = b = xfs_rbmblock_wordptr (bp , word );
679
- } else {
680
- /*
681
- * Go on to the next word in the buffer
682
- */
683
- b ++ ;
684
652
}
685
653
}
686
654
/*
@@ -695,17 +663,18 @@ xfs_rtmodify_range(
695
663
/*
696
664
* Set/clear the active bits.
697
665
*/
666
+ incore = xfs_rtbitmap_getword (bp , word );
698
667
if (val )
699
- * b |= mask ;
668
+ incore |= mask ;
700
669
else
701
- * b &= ~mask ;
670
+ incore &= ~mask ;
671
+ xfs_rtbitmap_setword (bp , word , incore );
702
672
word ++ ;
703
- b ++ ;
704
673
}
705
674
/*
706
675
* Log any remaining changed bytes.
707
676
*/
708
- if (b > first )
677
+ if (word > firstword )
709
678
xfs_trans_log_rtbitmap (tp , bp , firstword , word );
710
679
return 0 ;
711
680
}
@@ -800,7 +769,6 @@ xfs_rtcheck_range(
800
769
xfs_rtxnum_t * new , /* out: first rtext not matching */
801
770
int * stat ) /* out: 1 for matches, 0 for not */
802
771
{
803
- xfs_rtword_t * b ; /* current word in buffer */
804
772
int bit ; /* bit number in the word */
805
773
xfs_fileoff_t block ; /* bitmap block number */
806
774
struct xfs_buf * bp ; /* buf for the block */
@@ -809,6 +777,7 @@ xfs_rtcheck_range(
809
777
xfs_rtxnum_t lastbit ; /* last useful bit in word */
810
778
xfs_rtword_t mask ; /* mask of relevant bits for value */
811
779
xfs_rtword_t wdiff ; /* difference from wanted value */
780
+ xfs_rtword_t incore ;
812
781
unsigned int word ; /* word number in the buffer */
813
782
814
783
/*
@@ -827,7 +796,6 @@ xfs_rtcheck_range(
827
796
* Compute the starting word's address, and starting bit.
828
797
*/
829
798
word = xfs_rtx_to_rbmword (mp , start );
830
- b = xfs_rbmblock_wordptr (bp , word );
831
799
bit = (int )(start & (XFS_NBWORD - 1 ));
832
800
/*
833
801
* 0 (allocated) => all zero's; 1 (free) => all one's.
@@ -849,7 +817,8 @@ xfs_rtcheck_range(
849
817
/*
850
818
* Compute difference between actual and desired value.
851
819
*/
852
- if ((wdiff = (* b ^ val ) & mask )) {
820
+ incore = xfs_rtbitmap_getword (bp , word );
821
+ if ((wdiff = (incore ^ val ) & mask )) {
853
822
/*
854
823
* Different, compute first wrong bit and return.
855
824
*/
@@ -875,12 +844,6 @@ xfs_rtcheck_range(
875
844
}
876
845
877
846
word = 0 ;
878
- b = xfs_rbmblock_wordptr (bp , word );
879
- } else {
880
- /*
881
- * Go on to the next word in the buffer.
882
- */
883
- b ++ ;
884
847
}
885
848
} else {
886
849
/*
@@ -896,7 +859,8 @@ xfs_rtcheck_range(
896
859
/*
897
860
* Compute difference between actual and desired value.
898
861
*/
899
- if ((wdiff = * b ^ val )) {
862
+ incore = xfs_rtbitmap_getword (bp , word );
863
+ if ((wdiff = incore ^ val )) {
900
864
/*
901
865
* Different, compute first wrong bit and return.
902
866
*/
@@ -922,12 +886,6 @@ xfs_rtcheck_range(
922
886
}
923
887
924
888
word = 0 ;
925
- b = xfs_rbmblock_wordptr (bp , word );
926
- } else {
927
- /*
928
- * Go on to the next word in the buffer.
929
- */
930
- b ++ ;
931
889
}
932
890
}
933
891
/*
@@ -942,7 +900,8 @@ xfs_rtcheck_range(
942
900
/*
943
901
* Compute difference between actual and desired value.
944
902
*/
945
- if ((wdiff = (* b ^ val ) & mask )) {
903
+ incore = xfs_rtbitmap_getword (bp , word );
904
+ if ((wdiff = (incore ^ val ) & mask )) {
946
905
/*
947
906
* Different, compute first wrong bit and return.
948
907
*/
0 commit comments