aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-05-27 13:23:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-27 13:23:10 -0400
commit81faae7f9c245a17f585d6edb7d4683cc6336b11 (patch)
tree17f1f67095002d64a6b18bec4217cdb9ed8df512
parent95948c31bec26e631ecf138cb04dcd547519c7af (diff)
parentd194f1aa194d83ba3df0975497f9eaed48c95f6d (diff)
Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jlbec/ocfs2
* 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jlbec/ocfs2: Ocfs2/move_extents: Validate moving goal after the adjustment. Ocfs2/move_extents: Avoid doing division in extent moving.
-rw-r--r--fs/ocfs2/move_extents.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
index 4c5488468c14..cd9427023d2e 100644
--- a/fs/ocfs2/move_extents.c
+++ b/fs/ocfs2/move_extents.c
@@ -368,7 +368,7 @@ static int ocfs2_find_victim_alloc_group(struct inode *inode,
368 int *vict_bit, 368 int *vict_bit,
369 struct buffer_head **ret_bh) 369 struct buffer_head **ret_bh)
370{ 370{
371 int ret, i, blocks_per_unit = 1; 371 int ret, i, bits_per_unit = 0;
372 u64 blkno; 372 u64 blkno;
373 char namebuf[40]; 373 char namebuf[40];
374 374
@@ -398,14 +398,14 @@ static int ocfs2_find_victim_alloc_group(struct inode *inode,
398 rec = &(cl->cl_recs[0]); 398 rec = &(cl->cl_recs[0]);
399 399
400 if (type == GLOBAL_BITMAP_SYSTEM_INODE) 400 if (type == GLOBAL_BITMAP_SYSTEM_INODE)
401 blocks_per_unit <<= (osb->s_clustersize_bits - 401 bits_per_unit = osb->s_clustersize_bits -
402 inode->i_sb->s_blocksize_bits); 402 inode->i_sb->s_blocksize_bits;
403 /* 403 /*
404 * 'vict_blkno' was out of the valid range. 404 * 'vict_blkno' was out of the valid range.
405 */ 405 */
406 if ((vict_blkno < le64_to_cpu(rec->c_blkno)) || 406 if ((vict_blkno < le64_to_cpu(rec->c_blkno)) ||
407 (vict_blkno >= (le32_to_cpu(ac_dinode->id1.bitmap1.i_total) * 407 (vict_blkno >= (le32_to_cpu(ac_dinode->id1.bitmap1.i_total) <<
408 blocks_per_unit))) { 408 bits_per_unit))) {
409 ret = -EINVAL; 409 ret = -EINVAL;
410 goto out; 410 goto out;
411 } 411 }
@@ -441,8 +441,8 @@ static int ocfs2_find_victim_alloc_group(struct inode *inode,
441 le16_to_cpu(bg->bg_bits))) { 441 le16_to_cpu(bg->bg_bits))) {
442 442
443 *ret_bh = gd_bh; 443 *ret_bh = gd_bh;
444 *vict_bit = (vict_blkno - blkno) / 444 *vict_bit = (vict_blkno - blkno) >>
445 blocks_per_unit; 445 bits_per_unit;
446 mlog(0, "find the victim group: #%llu, " 446 mlog(0, "find the victim group: #%llu, "
447 "total_bits: %u, vict_bit: %u\n", 447 "total_bits: %u, vict_bit: %u\n",
448 blkno, le16_to_cpu(bg->bg_bits), 448 blkno, le16_to_cpu(bg->bg_bits),
@@ -472,12 +472,24 @@ static int ocfs2_validate_and_adjust_move_goal(struct inode *inode,
472 int ret, goal_bit = 0; 472 int ret, goal_bit = 0;
473 473
474 struct buffer_head *gd_bh = NULL; 474 struct buffer_head *gd_bh = NULL;
475 struct ocfs2_group_desc *bg; 475 struct ocfs2_group_desc *bg = NULL;
476 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 476 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
477 int c_to_b = 1 << (osb->s_clustersize_bits - 477 int c_to_b = 1 << (osb->s_clustersize_bits -
478 inode->i_sb->s_blocksize_bits); 478 inode->i_sb->s_blocksize_bits);
479 479
480 /* 480 /*
481 * make goal become cluster aligned.
482 */
483 range->me_goal = ocfs2_block_to_cluster_start(inode->i_sb,
484 range->me_goal);
485 /*
486 * moving goal is not allowd to start with a group desc blok(#0 blk)
487 * let's compromise to the latter cluster.
488 */
489 if (range->me_goal == le64_to_cpu(bg->bg_blkno))
490 range->me_goal += c_to_b;
491
492 /*
481 * validate goal sits within global_bitmap, and return the victim 493 * validate goal sits within global_bitmap, and return the victim
482 * group desc 494 * group desc
483 */ 495 */
@@ -491,19 +503,6 @@ static int ocfs2_validate_and_adjust_move_goal(struct inode *inode,
491 bg = (struct ocfs2_group_desc *)gd_bh->b_data; 503 bg = (struct ocfs2_group_desc *)gd_bh->b_data;
492 504
493 /* 505 /*
494 * make goal become cluster aligned.
495 */
496 if (range->me_goal % c_to_b)
497 range->me_goal = range->me_goal / c_to_b * c_to_b;
498
499 /*
500 * moving goal is not allowd to start with a group desc blok(#0 blk)
501 * let's compromise to the latter cluster.
502 */
503 if (range->me_goal == le64_to_cpu(bg->bg_blkno))
504 range->me_goal += c_to_b;
505
506 /*
507 * movement is not gonna cross two groups. 506 * movement is not gonna cross two groups.
508 */ 507 */
509 if ((le16_to_cpu(bg->bg_bits) - goal_bit) * osb->s_clustersize < 508 if ((le16_to_cpu(bg->bg_bits) - goal_bit) * osb->s_clustersize <