Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 76047
b: refs/heads/master
c: 5fdc2ee
h: refs/heads/master
i:
  76045: 38d64c5
  76043: 5570517
  76039: 573fac8
  76031: 8e74306
v: v3
  • Loading branch information
Bob Peterson authored and Steven Whitehouse committed Jan 25, 2008
1 parent 95146ad commit 7adcd5b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 26 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0d0868bde33273a200b33e54f4fad6099ad0c566
refs/heads/master: 5fdc2eeb5d1d3800367f471690b01fcd1fd5b963
54 changes: 29 additions & 25 deletions trunk/fs/gfs2/rgrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,41 +126,46 @@ static unsigned char gfs2_testbit(struct gfs2_rgrpd *rgd, unsigned char *buffer,
* Return: the block number (bitmap buffer scope) that was found
*/

static u32 gfs2_bitfit(struct gfs2_rgrpd *rgd, unsigned char *buffer,
unsigned int buflen, u32 goal,
unsigned char old_state)
static u32 gfs2_bitfit(unsigned char *buffer, unsigned int buflen, u32 goal,
unsigned char old_state)
{
unsigned char *byte, *end, alloc;
unsigned char *byte;
u32 blk = goal;
unsigned int bit;
unsigned int bit, bitlong;
unsigned long *plong, plong55;
static int c = 0;

byte = buffer + (goal / GFS2_NBBY);
plong = buffer + (goal / GFS2_NBBY);
bit = (goal % GFS2_NBBY) * GFS2_BIT_SIZE;
end = buffer + buflen;
alloc = (old_state == GFS2_BLKST_FREE) ? 0x55 : 0;

while (byte < end) {
/* If we're looking for a free block we can eliminate all
bitmap settings with 0x55, which represents four data
blocks in a row. If we're looking for a data block, we can
eliminate 0x00 which corresponds to four free blocks. */
if ((*byte & 0x55) == alloc) {
blk += (8 - bit) >> 1;

bit = 0;
byte++;

bitlong = bit;
#if BITS_PER_LONG == 32
plong55 = 0x55555555;
#else
plong55 = 0x5555555555555555;
#endif
while (byte < buffer + buflen) {

if (bitlong == 0 && old_state == 0 && *plong == plong55) {
plong++;
byte += sizeof(unsigned long);
blk += sizeof(unsigned long) * GFS2_NBBY;
continue;
}

if (((*byte >> bit) & GFS2_BIT_MASK) == old_state)
if (((*byte >> bit) & GFS2_BIT_MASK) == old_state) {
c++;
return blk;

}
bit += GFS2_BIT_SIZE;
if (bit >= 8) {
bit = 0;
byte++;
}
bitlong += GFS2_BIT_SIZE;
if (bitlong >= sizeof(unsigned long) * 8) {
bitlong = 0;
plong++;
}

blk++;
}
Expand Down Expand Up @@ -1318,11 +1323,10 @@ static u32 rgblk_search(struct gfs2_rgrpd *rgd, u32 goal,
/* The GFS2_BLKST_UNLINKED state doesn't apply to the clone
bitmaps, so we must search the originals for that. */
if (old_state != GFS2_BLKST_UNLINKED && bi->bi_clone)
blk = gfs2_bitfit(rgd, bi->bi_clone + bi->bi_offset,
blk = gfs2_bitfit(bi->bi_clone + bi->bi_offset,
bi->bi_len, goal, old_state);
else
blk = gfs2_bitfit(rgd,
bi->bi_bh->b_data + bi->bi_offset,
blk = gfs2_bitfit(bi->bi_bh->b_data + bi->bi_offset,
bi->bi_len, goal, old_state);
if (blk != BFITNOENT)
break;
Expand Down

0 comments on commit 7adcd5b

Please sign in to comment.