diff options
author | Yan, Zheng <zheng.yan@oracle.com> | 2009-11-12 04:33:26 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2009-12-15 21:24:25 -0500 |
commit | 8cef4e160d74920ad1725f58c89fd75ec4c4ac38 (patch) | |
tree | c1592369c7085e75d67a1709438a4f56351b2348 /fs/btrfs/transaction.c | |
parent | 22763c5cf3690a681551162c15d34d935308c8d7 (diff) |
Btrfs: Avoid superfluous tree-log writeout
We allow two log transactions at a time, but use same flag
to mark dirty tree-log btree blocks. So we may flush dirty
blocks belonging to newer log transaction when committing a
log transaction. This patch fixes the issue by using two
flags to mark dirty tree-log btree blocks.
Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r-- | fs/btrfs/transaction.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index c207e8c32c9b..b7b22c344b66 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -354,7 +354,7 @@ int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans, | |||
354 | * those extents are sent to disk but does not wait on them | 354 | * those extents are sent to disk but does not wait on them |
355 | */ | 355 | */ |
356 | int btrfs_write_marked_extents(struct btrfs_root *root, | 356 | int btrfs_write_marked_extents(struct btrfs_root *root, |
357 | struct extent_io_tree *dirty_pages) | 357 | struct extent_io_tree *dirty_pages, int mark) |
358 | { | 358 | { |
359 | int ret; | 359 | int ret; |
360 | int err = 0; | 360 | int err = 0; |
@@ -367,7 +367,7 @@ int btrfs_write_marked_extents(struct btrfs_root *root, | |||
367 | 367 | ||
368 | while (1) { | 368 | while (1) { |
369 | ret = find_first_extent_bit(dirty_pages, start, &start, &end, | 369 | ret = find_first_extent_bit(dirty_pages, start, &start, &end, |
370 | EXTENT_DIRTY); | 370 | mark); |
371 | if (ret) | 371 | if (ret) |
372 | break; | 372 | break; |
373 | while (start <= end) { | 373 | while (start <= end) { |
@@ -413,7 +413,7 @@ int btrfs_write_marked_extents(struct btrfs_root *root, | |||
413 | * on all the pages and clear them from the dirty pages state tree | 413 | * on all the pages and clear them from the dirty pages state tree |
414 | */ | 414 | */ |
415 | int btrfs_wait_marked_extents(struct btrfs_root *root, | 415 | int btrfs_wait_marked_extents(struct btrfs_root *root, |
416 | struct extent_io_tree *dirty_pages) | 416 | struct extent_io_tree *dirty_pages, int mark) |
417 | { | 417 | { |
418 | int ret; | 418 | int ret; |
419 | int err = 0; | 419 | int err = 0; |
@@ -425,12 +425,12 @@ int btrfs_wait_marked_extents(struct btrfs_root *root, | |||
425 | unsigned long index; | 425 | unsigned long index; |
426 | 426 | ||
427 | while (1) { | 427 | while (1) { |
428 | ret = find_first_extent_bit(dirty_pages, 0, &start, &end, | 428 | ret = find_first_extent_bit(dirty_pages, start, &start, &end, |
429 | EXTENT_DIRTY); | 429 | mark); |
430 | if (ret) | 430 | if (ret) |
431 | break; | 431 | break; |
432 | 432 | ||
433 | clear_extent_dirty(dirty_pages, start, end, GFP_NOFS); | 433 | clear_extent_bits(dirty_pages, start, end, mark, GFP_NOFS); |
434 | while (start <= end) { | 434 | while (start <= end) { |
435 | index = start >> PAGE_CACHE_SHIFT; | 435 | index = start >> PAGE_CACHE_SHIFT; |
436 | start = (u64)(index + 1) << PAGE_CACHE_SHIFT; | 436 | start = (u64)(index + 1) << PAGE_CACHE_SHIFT; |
@@ -460,13 +460,13 @@ int btrfs_wait_marked_extents(struct btrfs_root *root, | |||
460 | * those extents are on disk for transaction or log commit | 460 | * those extents are on disk for transaction or log commit |
461 | */ | 461 | */ |
462 | int btrfs_write_and_wait_marked_extents(struct btrfs_root *root, | 462 | int btrfs_write_and_wait_marked_extents(struct btrfs_root *root, |
463 | struct extent_io_tree *dirty_pages) | 463 | struct extent_io_tree *dirty_pages, int mark) |
464 | { | 464 | { |
465 | int ret; | 465 | int ret; |
466 | int ret2; | 466 | int ret2; |
467 | 467 | ||
468 | ret = btrfs_write_marked_extents(root, dirty_pages); | 468 | ret = btrfs_write_marked_extents(root, dirty_pages, mark); |
469 | ret2 = btrfs_wait_marked_extents(root, dirty_pages); | 469 | ret2 = btrfs_wait_marked_extents(root, dirty_pages, mark); |
470 | return ret || ret2; | 470 | return ret || ret2; |
471 | } | 471 | } |
472 | 472 | ||
@@ -479,7 +479,8 @@ int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans, | |||
479 | return filemap_write_and_wait(btree_inode->i_mapping); | 479 | return filemap_write_and_wait(btree_inode->i_mapping); |
480 | } | 480 | } |
481 | return btrfs_write_and_wait_marked_extents(root, | 481 | return btrfs_write_and_wait_marked_extents(root, |
482 | &trans->transaction->dirty_pages); | 482 | &trans->transaction->dirty_pages, |
483 | EXTENT_DIRTY); | ||
483 | } | 484 | } |
484 | 485 | ||
485 | /* | 486 | /* |