diff options
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r-- | fs/btrfs/transaction.c | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 0b8f36d4400a..bca82a4ca8e6 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -344,10 +344,10 @@ int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans, | |||
344 | /* | 344 | /* |
345 | * when btree blocks are allocated, they have some corresponding bits set for | 345 | * when btree blocks are allocated, they have some corresponding bits set for |
346 | * them in one of two extent_io trees. This is used to make sure all of | 346 | * them in one of two extent_io trees. This is used to make sure all of |
347 | * those extents are on disk for transaction or log commit | 347 | * those extents are sent to disk but does not wait on them |
348 | */ | 348 | */ |
349 | int btrfs_write_and_wait_marked_extents(struct btrfs_root *root, | 349 | int btrfs_write_marked_extents(struct btrfs_root *root, |
350 | struct extent_io_tree *dirty_pages) | 350 | struct extent_io_tree *dirty_pages) |
351 | { | 351 | { |
352 | int ret; | 352 | int ret; |
353 | int err = 0; | 353 | int err = 0; |
@@ -394,6 +394,29 @@ int btrfs_write_and_wait_marked_extents(struct btrfs_root *root, | |||
394 | page_cache_release(page); | 394 | page_cache_release(page); |
395 | } | 395 | } |
396 | } | 396 | } |
397 | if (err) | ||
398 | werr = err; | ||
399 | return werr; | ||
400 | } | ||
401 | |||
402 | /* | ||
403 | * when btree blocks are allocated, they have some corresponding bits set for | ||
404 | * them in one of two extent_io trees. This is used to make sure all of | ||
405 | * those extents are on disk for transaction or log commit. We wait | ||
406 | * on all the pages and clear them from the dirty pages state tree | ||
407 | */ | ||
408 | int btrfs_wait_marked_extents(struct btrfs_root *root, | ||
409 | struct extent_io_tree *dirty_pages) | ||
410 | { | ||
411 | int ret; | ||
412 | int err = 0; | ||
413 | int werr = 0; | ||
414 | struct page *page; | ||
415 | struct inode *btree_inode = root->fs_info->btree_inode; | ||
416 | u64 start = 0; | ||
417 | u64 end; | ||
418 | unsigned long index; | ||
419 | |||
397 | while (1) { | 420 | while (1) { |
398 | ret = find_first_extent_bit(dirty_pages, 0, &start, &end, | 421 | ret = find_first_extent_bit(dirty_pages, 0, &start, &end, |
399 | EXTENT_DIRTY); | 422 | EXTENT_DIRTY); |
@@ -424,6 +447,22 @@ int btrfs_write_and_wait_marked_extents(struct btrfs_root *root, | |||
424 | return werr; | 447 | return werr; |
425 | } | 448 | } |
426 | 449 | ||
450 | /* | ||
451 | * when btree blocks are allocated, they have some corresponding bits set for | ||
452 | * them in one of two extent_io trees. This is used to make sure all of | ||
453 | * those extents are on disk for transaction or log commit | ||
454 | */ | ||
455 | int btrfs_write_and_wait_marked_extents(struct btrfs_root *root, | ||
456 | struct extent_io_tree *dirty_pages) | ||
457 | { | ||
458 | int ret; | ||
459 | int ret2; | ||
460 | |||
461 | ret = btrfs_write_marked_extents(root, dirty_pages); | ||
462 | ret2 = btrfs_wait_marked_extents(root, dirty_pages); | ||
463 | return ret || ret2; | ||
464 | } | ||
465 | |||
427 | int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans, | 466 | int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans, |
428 | struct btrfs_root *root) | 467 | struct btrfs_root *root) |
429 | { | 468 | { |