Skip to content

Commit 035cfc6

Browse files
committed
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] fix gfs2 block allocation (cleaned up) [GFS2] BUG: unable to handle kernel paging request at ffff81002690e000
2 parents 919c0d1 + 5af4e7a commit 035cfc6

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

fs/gfs2/bmap.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,11 @@ static void find_metapath(const struct gfs2_sbd *sdp, u64 block,
246246

247247
}
248248

249-
static inline unsigned int zero_metapath_length(const struct metapath *mp,
250-
unsigned height)
249+
static inline unsigned int metapath_branch_start(const struct metapath *mp)
251250
{
252-
unsigned int i;
253-
for (i = 0; i < height - 1; i++) {
254-
if (mp->mp_list[i] != 0)
255-
return i;
256-
}
257-
return height;
251+
if (mp->mp_list[0] == 0)
252+
return 2;
253+
return 1;
258254
}
259255

260256
/**
@@ -436,7 +432,7 @@ static int gfs2_bmap_alloc(struct inode *inode, const sector_t lblock,
436432
struct gfs2_sbd *sdp = GFS2_SB(inode);
437433
struct buffer_head *dibh = mp->mp_bh[0];
438434
u64 bn, dblock = 0;
439-
unsigned n, i, blks, alloced = 0, iblks = 0, zmpl = 0;
435+
unsigned n, i, blks, alloced = 0, iblks = 0, branch_start = 0;
440436
unsigned dblks = 0;
441437
unsigned ptrs_per_blk;
442438
const unsigned end_of_metadata = height - 1;
@@ -471,9 +467,8 @@ static int gfs2_bmap_alloc(struct inode *inode, const sector_t lblock,
471467
/* Building up tree height */
472468
state = ALLOC_GROW_HEIGHT;
473469
iblks = height - ip->i_height;
474-
zmpl = zero_metapath_length(mp, height);
475-
iblks -= zmpl;
476-
iblks += height;
470+
branch_start = metapath_branch_start(mp);
471+
iblks += (height - branch_start);
477472
}
478473
}
479474

@@ -509,13 +504,13 @@ static int gfs2_bmap_alloc(struct inode *inode, const sector_t lblock,
509504
sizeof(struct gfs2_meta_header));
510505
*ptr = zero_bn;
511506
state = ALLOC_GROW_DEPTH;
512-
for(i = zmpl; i < height; i++) {
507+
for(i = branch_start; i < height; i++) {
513508
if (mp->mp_bh[i] == NULL)
514509
break;
515510
brelse(mp->mp_bh[i]);
516511
mp->mp_bh[i] = NULL;
517512
}
518-
i = zmpl;
513+
i = branch_start;
519514
}
520515
if (n == 0)
521516
break;

fs/gfs2/rgrp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static u32 gfs2_bitfit(const u8 *buffer, unsigned int buflen, u32 goal,
195195
depending on architecture. I've experimented with several ways
196196
of writing this section such as using an else before the goto
197197
but this one seems to be the fastest. */
198-
while ((unsigned char *)plong < end - 1) {
198+
while ((unsigned char *)plong < end - sizeof(unsigned long)) {
199199
prefetch(plong + 1);
200200
if (((*plong) & LBITMASK) != lskipval)
201201
break;

0 commit comments

Comments
 (0)