xfs_rtxnum_t limit, /* last rtext to look at */
xfs_rtxnum_t *rtx) /* out: start rtext found */
{
- xfs_rtword_t *b; /* current word in buffer */
int bit; /* bit number in the word */
xfs_fileoff_t block; /* bitmap block number */
struct xfs_buf *bp; /* buf for the block */
xfs_rtword_t mask; /* mask of relevant bits for value */
xfs_rtword_t want; /* mask for "good" values */
xfs_rtword_t wdiff; /* difference from wanted value */
+ xfs_rtword_t incore;
unsigned int word; /* word number in the buffer */
/*
* Get the first word's index & point to it.
*/
word = xfs_rtx_to_rbmword(mp, start);
- b = xfs_rbmblock_wordptr(bp, word);
bit = (int)(start & (XFS_NBWORD - 1));
len = start - limit + 1;
/*
* Compute match value, based on the bit at start: if 1 (free)
* then all-ones, else all-zeroes.
*/
- want = (*b & ((xfs_rtword_t)1 << bit)) ? -1 : 0;
+ incore = xfs_rtbitmap_getword(bp, word);
+ want = (incore & ((xfs_rtword_t)1 << bit)) ? -1 : 0;
/*
* If the starting position is not word-aligned, deal with the
* partial word.
* Calculate the difference between the value there
* and what we're looking for.
*/
- if ((wdiff = (*b ^ want) & mask)) {
+ if ((wdiff = (incore ^ want) & mask)) {
/*
* Different. Mark where we are and return.
*/
}
word = mp->m_blockwsize - 1;
- b = xfs_rbmblock_wordptr(bp, word);
- } else {
- /*
- * Go on to the previous word in the buffer.
- */
- b--;
}
} else {
/*
/*
* Compute difference between actual and desired value.
*/
- if ((wdiff = *b ^ want)) {
+ incore = xfs_rtbitmap_getword(bp, word);
+ if ((wdiff = incore ^ want)) {
/*
* Different, mark where we are and return.
*/
}
word = mp->m_blockwsize - 1;
- b = xfs_rbmblock_wordptr(bp, word);
- } else {
- /*
- * Go on to the previous word in the buffer.
- */
- b--;
}
}
/*
/*
* Compute difference between actual and desired value.
*/
- if ((wdiff = (*b ^ want) & mask)) {
+ incore = xfs_rtbitmap_getword(bp, word);
+ if ((wdiff = (incore ^ want) & mask)) {
/*
* Different, mark where we are and return.
*/
xfs_rtxnum_t limit, /* last rtext to look at */
xfs_rtxnum_t *rtx) /* out: start rtext found */
{
- xfs_rtword_t *b; /* current word in buffer */
int bit; /* bit number in the word */
xfs_fileoff_t block; /* bitmap block number */
struct xfs_buf *bp; /* buf for the block */
xfs_rtword_t mask; /* mask of relevant bits for value */
xfs_rtword_t want; /* mask for "good" values */
xfs_rtword_t wdiff; /* difference from wanted value */
+ xfs_rtword_t incore;
unsigned int word; /* word number in the buffer */
/*
* Get the first word's index & point to it.
*/
word = xfs_rtx_to_rbmword(mp, start);
- b = xfs_rbmblock_wordptr(bp, word);
bit = (int)(start & (XFS_NBWORD - 1));
len = limit - start + 1;
/*
* Compute match value, based on the bit at start: if 1 (free)
* then all-ones, else all-zeroes.
*/
- want = (*b & ((xfs_rtword_t)1 << bit)) ? -1 : 0;
+ incore = xfs_rtbitmap_getword(bp, word);
+ want = (incore & ((xfs_rtword_t)1 << bit)) ? -1 : 0;
/*
* If the starting position is not word-aligned, deal with the
* partial word.
* Calculate the difference between the value there
* and what we're looking for.
*/
- if ((wdiff = (*b ^ want) & mask)) {
+ if ((wdiff = (incore ^ want) & mask)) {
/*
* Different. Mark where we are and return.
*/
}
word = 0;
- b = xfs_rbmblock_wordptr(bp, word);
- } else {
- /*
- * Go on to the previous word in the buffer.
- */
- b++;
}
} else {
/*
/*
* Compute difference between actual and desired value.
*/
- if ((wdiff = *b ^ want)) {
+ incore = xfs_rtbitmap_getword(bp, word);
+ if ((wdiff = incore ^ want)) {
/*
* Different, mark where we are and return.
*/
}
word = 0;
- b = xfs_rbmblock_wordptr(bp, word);
- } else {
- /*
- * Go on to the next word in the buffer.
- */
- b++;
}
}
/*
/*
* Compute difference between actual and desired value.
*/
- if ((wdiff = (*b ^ want) & mask)) {
+ incore = xfs_rtbitmap_getword(bp, word);
+ if ((wdiff = (incore ^ want) & mask)) {
/*
* Different, mark where we are and return.
*/
xfs_rtxlen_t len, /* length of extent to modify */
int val) /* 1 for free, 0 for allocated */
{
- xfs_rtword_t *b; /* current word in buffer */
int bit; /* bit number in the word */
xfs_fileoff_t block; /* bitmap block number */
struct xfs_buf *bp; /* buf for the block */
int error; /* error value */
- xfs_rtword_t *first; /* first used word in the buffer */
int i; /* current bit number rel. to start */
int lastbit; /* last useful bit in word */
xfs_rtword_t mask; /* mask o frelevant bits for value */
+ xfs_rtword_t incore;
unsigned int firstword; /* first word used in the buffer */
unsigned int word; /* word number in the buffer */
* Compute the starting word's address, and starting bit.
*/
firstword = word = xfs_rtx_to_rbmword(mp, start);
- first = b = xfs_rbmblock_wordptr(bp, word);
bit = (int)(start & (XFS_NBWORD - 1));
/*
* 0 (allocated) => all zeroes; 1 (free) => all ones.
/*
* Set/clear the active bits.
*/
+ incore = xfs_rtbitmap_getword(bp, word);
if (val)
- *b |= mask;
+ incore |= mask;
else
- *b &= ~mask;
+ incore &= ~mask;
+ xfs_rtbitmap_setword(bp, word, incore);
i = lastbit - bit;
/*
* Go on to the next block if that's where the next word is
}
firstword = word = 0;
- first = b = xfs_rbmblock_wordptr(bp, word);
- } else {
- /*
- * Go on to the next word in the buffer
- */
- b++;
}
} else {
/*
/*
* Set the word value correctly.
*/
- *b = val;
+ xfs_rtbitmap_setword(bp, word, val);
i += XFS_NBWORD;
/*
* Go on to the next block if that's where the next word is
}
firstword = word = 0;
- first = b = xfs_rbmblock_wordptr(bp, word);
- } else {
- /*
- * Go on to the next word in the buffer
- */
- b++;
}
}
/*
/*
* Set/clear the active bits.
*/
+ incore = xfs_rtbitmap_getword(bp, word);
if (val)
- *b |= mask;
+ incore |= mask;
else
- *b &= ~mask;
+ incore &= ~mask;
+ xfs_rtbitmap_setword(bp, word, incore);
word++;
- b++;
}
/*
* Log any remaining changed bytes.
*/
- if (b > first)
+ if (word > firstword)
xfs_trans_log_rtbitmap(tp, bp, firstword, word);
return 0;
}
xfs_rtxnum_t *new, /* out: first rtext not matching */
int *stat) /* out: 1 for matches, 0 for not */
{
- xfs_rtword_t *b; /* current word in buffer */
int bit; /* bit number in the word */
xfs_fileoff_t block; /* bitmap block number */
struct xfs_buf *bp; /* buf for the block */
xfs_rtxnum_t lastbit; /* last useful bit in word */
xfs_rtword_t mask; /* mask of relevant bits for value */
xfs_rtword_t wdiff; /* difference from wanted value */
+ xfs_rtword_t incore;
unsigned int word; /* word number in the buffer */
/*
* Compute the starting word's address, and starting bit.
*/
word = xfs_rtx_to_rbmword(mp, start);
- b = xfs_rbmblock_wordptr(bp, word);
bit = (int)(start & (XFS_NBWORD - 1));
/*
* 0 (allocated) => all zero's; 1 (free) => all one's.
/*
* Compute difference between actual and desired value.
*/
- if ((wdiff = (*b ^ val) & mask)) {
+ incore = xfs_rtbitmap_getword(bp, word);
+ if ((wdiff = (incore ^ val) & mask)) {
/*
* Different, compute first wrong bit and return.
*/
}
word = 0;
- b = xfs_rbmblock_wordptr(bp, word);
- } else {
- /*
- * Go on to the next word in the buffer.
- */
- b++;
}
} else {
/*
/*
* Compute difference between actual and desired value.
*/
- if ((wdiff = *b ^ val)) {
+ incore = xfs_rtbitmap_getword(bp, word);
+ if ((wdiff = incore ^ val)) {
/*
* Different, compute first wrong bit and return.
*/
}
word = 0;
- b = xfs_rbmblock_wordptr(bp, word);
- } else {
- /*
- * Go on to the next word in the buffer.
- */
- b++;
}
}
/*
/*
* Compute difference between actual and desired value.
*/
- if ((wdiff = (*b ^ val) & mask)) {
+ incore = xfs_rtbitmap_getword(bp, word);
+ if ((wdiff = (incore ^ val) & mask)) {
/*
* Different, compute first wrong bit and return.
*/