diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-24 11:27:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-24 11:27:02 -0400 |
commit | 12bac708e6242b0ccd969519582b2938d78289bb (patch) | |
tree | 4cf804bcf1a3afb90044f8b33405ea6713c8731e | |
parent | 60911731fe7fd4ec4d088fc1a48a56c9fb14103f (diff) | |
parent | d9ba7615bfd8bb06f79c853f9dfff9e93a837941 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-2.6-fixes
* git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-2.6-fixes:
GFS2: Ensure that the inode goal block settings are updated
GFS2: Fix bug in block allocation
bitops: Add __ffs64 bitop
-rw-r--r-- | fs/gfs2/rgrp.c | 13 | ||||
-rw-r--r-- | include/linux/bitops.h | 19 |
2 files changed, 29 insertions, 3 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index f03d024038ea..565038243fa2 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
@@ -212,8 +212,7 @@ static u32 gfs2_bitfit(const u8 *buf, const unsigned int len, | |||
212 | if (tmp == 0) | 212 | if (tmp == 0) |
213 | return BFITNOENT; | 213 | return BFITNOENT; |
214 | ptr--; | 214 | ptr--; |
215 | bit = fls64(tmp); | 215 | bit = __ffs64(tmp); |
216 | bit--; /* fls64 always adds one to the bit count */ | ||
217 | bit /= 2; /* two bits per entry in the bitmap */ | 216 | bit /= 2; /* two bits per entry in the bitmap */ |
218 | return (((const unsigned char *)ptr - buf) * GFS2_NBBY) + bit; | 217 | return (((const unsigned char *)ptr - buf) * GFS2_NBBY) + bit; |
219 | } | 218 | } |
@@ -1445,10 +1444,12 @@ static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, u64 bstart, | |||
1445 | u64 gfs2_alloc_block(struct gfs2_inode *ip, unsigned int *n) | 1444 | u64 gfs2_alloc_block(struct gfs2_inode *ip, unsigned int *n) |
1446 | { | 1445 | { |
1447 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 1446 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
1447 | struct buffer_head *dibh; | ||
1448 | struct gfs2_alloc *al = ip->i_alloc; | 1448 | struct gfs2_alloc *al = ip->i_alloc; |
1449 | struct gfs2_rgrpd *rgd = al->al_rgd; | 1449 | struct gfs2_rgrpd *rgd = al->al_rgd; |
1450 | u32 goal, blk; | 1450 | u32 goal, blk; |
1451 | u64 block; | 1451 | u64 block; |
1452 | int error; | ||
1452 | 1453 | ||
1453 | if (rgrp_contains_block(rgd, ip->i_goal)) | 1454 | if (rgrp_contains_block(rgd, ip->i_goal)) |
1454 | goal = ip->i_goal - rgd->rd_data0; | 1455 | goal = ip->i_goal - rgd->rd_data0; |
@@ -1461,7 +1462,13 @@ u64 gfs2_alloc_block(struct gfs2_inode *ip, unsigned int *n) | |||
1461 | rgd->rd_last_alloc = blk; | 1462 | rgd->rd_last_alloc = blk; |
1462 | block = rgd->rd_data0 + blk; | 1463 | block = rgd->rd_data0 + blk; |
1463 | ip->i_goal = block; | 1464 | ip->i_goal = block; |
1464 | 1465 | error = gfs2_meta_inode_buffer(ip, &dibh); | |
1466 | if (error == 0) { | ||
1467 | struct gfs2_dinode *di = (struct gfs2_dinode *)dibh->b_data; | ||
1468 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); | ||
1469 | di->di_goal_meta = di->di_goal_data = cpu_to_be64(ip->i_goal); | ||
1470 | brelse(dibh); | ||
1471 | } | ||
1465 | gfs2_assert_withdraw(sdp, rgd->rd_free >= *n); | 1472 | gfs2_assert_withdraw(sdp, rgd->rd_free >= *n); |
1466 | rgd->rd_free -= *n; | 1473 | rgd->rd_free -= *n; |
1467 | 1474 | ||
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 61829139795a..c05a29cb9bb2 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h | |||
@@ -112,6 +112,25 @@ static inline unsigned fls_long(unsigned long l) | |||
112 | return fls64(l); | 112 | return fls64(l); |
113 | } | 113 | } |
114 | 114 | ||
115 | /** | ||
116 | * __ffs64 - find first set bit in a 64 bit word | ||
117 | * @word: The 64 bit word | ||
118 | * | ||
119 | * On 64 bit arches this is a synomyn for __ffs | ||
120 | * The result is not defined if no bits are set, so check that @word | ||
121 | * is non-zero before calling this. | ||
122 | */ | ||
123 | static inline unsigned long __ffs64(u64 word) | ||
124 | { | ||
125 | #if BITS_PER_LONG == 32 | ||
126 | if (((u32)word) == 0UL) | ||
127 | return __ffs((u32)(word >> 32)) + 32; | ||
128 | #elif BITS_PER_LONG != 64 | ||
129 | #error BITS_PER_LONG not 32 or 64 | ||
130 | #endif | ||
131 | return __ffs((unsigned long)word); | ||
132 | } | ||
133 | |||
115 | #ifdef __KERNEL__ | 134 | #ifdef __KERNEL__ |
116 | #ifdef CONFIG_GENERIC_FIND_FIRST_BIT | 135 | #ifdef CONFIG_GENERIC_FIND_FIRST_BIT |
117 | 136 | ||