diff options
-rw-r--r-- | fs/gfs2/incore.h | 1 | ||||
-rw-r--r-- | fs/gfs2/ops_fstype.c | 3 | ||||
-rw-r--r-- | fs/gfs2/rgrp.c | 21 |
3 files changed, 16 insertions, 9 deletions
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 3d469d37345e..24bb0b857860 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h | |||
@@ -621,6 +621,7 @@ struct gfs2_sbd { | |||
621 | u32 sd_hash_bsize_shift; | 621 | u32 sd_hash_bsize_shift; |
622 | u32 sd_hash_ptrs; /* Number of pointers in a hash block */ | 622 | u32 sd_hash_ptrs; /* Number of pointers in a hash block */ |
623 | u32 sd_qc_per_block; | 623 | u32 sd_qc_per_block; |
624 | u32 sd_blocks_per_bitmap; | ||
624 | u32 sd_max_dirres; /* Max blocks needed to add a directory entry */ | 625 | u32 sd_max_dirres; /* Max blocks needed to add a directory entry */ |
625 | u32 sd_max_height; /* Max height of a file's metadata tree */ | 626 | u32 sd_max_height; /* Max height of a file's metadata tree */ |
626 | u64 sd_heightsize[GFS2_MAX_META_HEIGHT + 1]; | 627 | u64 sd_heightsize[GFS2_MAX_META_HEIGHT + 1]; |
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index e443966c8106..0e3554edb8f2 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c | |||
@@ -278,6 +278,9 @@ static int gfs2_read_sb(struct gfs2_sbd *sdp, int silent) | |||
278 | sdp->sd_qc_per_block = (sdp->sd_sb.sb_bsize - | 278 | sdp->sd_qc_per_block = (sdp->sd_sb.sb_bsize - |
279 | sizeof(struct gfs2_meta_header)) / | 279 | sizeof(struct gfs2_meta_header)) / |
280 | sizeof(struct gfs2_quota_change); | 280 | sizeof(struct gfs2_quota_change); |
281 | sdp->sd_blocks_per_bitmap = (sdp->sd_sb.sb_bsize - | ||
282 | sizeof(struct gfs2_meta_header)) | ||
283 | * GFS2_NBBY; /* not the rgrp bitmap, subsequent bitmaps only */ | ||
281 | 284 | ||
282 | /* Compute maximum reservation required to add a entry to a directory */ | 285 | /* Compute maximum reservation required to add a entry to a directory */ |
283 | 286 | ||
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 38fe18f2f055..669b89b95ccc 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
@@ -251,22 +251,25 @@ static u32 gfs2_bitfit(const u8 *buf, const unsigned int len, | |||
251 | static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block) | 251 | static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block) |
252 | { | 252 | { |
253 | u64 rblock = block - rbm->rgd->rd_data0; | 253 | u64 rblock = block - rbm->rgd->rd_data0; |
254 | u32 goal = (u32)rblock; | 254 | u32 x; |
255 | int x; | ||
256 | 255 | ||
257 | if (WARN_ON_ONCE(rblock > UINT_MAX)) | 256 | if (WARN_ON_ONCE(rblock > UINT_MAX)) |
258 | return -EINVAL; | 257 | return -EINVAL; |
259 | if (block >= rbm->rgd->rd_data0 + rbm->rgd->rd_data) | 258 | if (block >= rbm->rgd->rd_data0 + rbm->rgd->rd_data) |
260 | return -E2BIG; | 259 | return -E2BIG; |
261 | 260 | ||
262 | for (x = 0; x < rbm->rgd->rd_length; x++) { | 261 | rbm->bi = rbm->rgd->rd_bits; |
263 | rbm->bi = rbm->rgd->rd_bits + x; | 262 | rbm->offset = (u32)(rblock); |
264 | if (goal < (rbm->bi->bi_start + rbm->bi->bi_len) * GFS2_NBBY) { | 263 | /* Check if the block is within the first block */ |
265 | rbm->offset = goal - (rbm->bi->bi_start * GFS2_NBBY); | 264 | if (rbm->offset < (rbm->bi->bi_start + rbm->bi->bi_len) * GFS2_NBBY) |
266 | break; | 265 | return 0; |
267 | } | ||
268 | } | ||
269 | 266 | ||
267 | /* Adjust for the size diff between gfs2_meta_header and gfs2_rgrp */ | ||
268 | rbm->offset += (sizeof(struct gfs2_rgrp) - | ||
269 | sizeof(struct gfs2_meta_header)) * GFS2_NBBY; | ||
270 | x = rbm->offset / rbm->rgd->rd_sbd->sd_blocks_per_bitmap; | ||
271 | rbm->offset -= x * rbm->rgd->rd_sbd->sd_blocks_per_bitmap; | ||
272 | rbm->bi += x; | ||
270 | return 0; | 273 | return 0; |
271 | } | 274 | } |
272 | 275 | ||