Skip to content

Commit b650738

Browse files
AstralBobswhiteho
authored andcommitted
GFS2: Change maxlen variables to size_t
This patch changes some variables (especially maxlen in function gfs2_block_map) from unsigned int to size_t. We need 64-bit arithmetic for very large files (e.g. 1PB) where the variables otherwise get shifted to all 0's. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent eaebded commit b650738

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎fs/gfs2/bmap.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ static inline void release_metapath(struct metapath *mp)
359359
* Returns: The length of the extent (minimum of one block)
360360
*/
361361

362-
static inline unsigned int gfs2_extent_length(void *start, unsigned int len, __be64 *ptr, unsigned limit, int *eob)
362+
static inline unsigned int gfs2_extent_length(void *start, unsigned int len, __be64 *ptr, size_t limit, int *eob)
363363
{
364364
const __be64 *end = (start + len);
365365
const __be64 *first = ptr;
@@ -449,7 +449,7 @@ static int gfs2_bmap_alloc(struct inode *inode, const sector_t lblock,
449449
struct buffer_head *bh_map, struct metapath *mp,
450450
const unsigned int sheight,
451451
const unsigned int height,
452-
const unsigned int maxlen)
452+
const size_t maxlen)
453453
{
454454
struct gfs2_inode *ip = GFS2_I(inode);
455455
struct gfs2_sbd *sdp = GFS2_SB(inode);
@@ -483,7 +483,8 @@ static int gfs2_bmap_alloc(struct inode *inode, const sector_t lblock,
483483
} else {
484484
/* Need to allocate indirect blocks */
485485
ptrs_per_blk = height > 1 ? sdp->sd_inptrs : sdp->sd_diptrs;
486-
dblks = min(maxlen, ptrs_per_blk - mp->mp_list[end_of_metadata]);
486+
dblks = min(maxlen, (size_t)(ptrs_per_blk -
487+
mp->mp_list[end_of_metadata]));
487488
if (height == ip->i_height) {
488489
/* Writing into existing tree, extend tree down */
489490
iblks = height - sheight;
@@ -605,7 +606,7 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
605606
struct gfs2_inode *ip = GFS2_I(inode);
606607
struct gfs2_sbd *sdp = GFS2_SB(inode);
607608
unsigned int bsize = sdp->sd_sb.sb_bsize;
608-
const unsigned int maxlen = bh_map->b_size >> inode->i_blkbits;
609+
const size_t maxlen = bh_map->b_size >> inode->i_blkbits;
609610
const u64 *arr = sdp->sd_heightsize;
610611
__be64 *ptr;
611612
u64 size;

0 commit comments

Comments
 (0)