aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ordered-data.c
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2015-04-17 12:08:37 -0400
committerChris Mason <clm@fb.com>2015-06-10 10:02:44 -0400
commit7558c8bc17481c1f856e009af8503ab40fec348a (patch)
tree5906acbed657779b76e966005c8a9624713d2ed2 /fs/btrfs/ordered-data.c
parentb659ef027792219b590d67a2baf1643a93727d29 (diff)
Btrfs: don't attach unnecessary extents to transaction on fsync
We don't need to attach ordered extents that have completed to the current transaction. Doing so only makes us hold memory for longer than necessary and delaying the iput of the inode until the transaction is committed (for each created ordered extent we do an igrab and then schedule an asynchronous iput when the ordered extent's reference count drops to 0), preventing the inode from being evictable until the transaction commits. Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/ordered-data.c')
-rw-r--r--fs/btrfs/ordered-data.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index ceccd078c93d..89656d799ff6 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -502,7 +502,21 @@ void btrfs_wait_logged_extents(struct btrfs_trans_handle *trans,
502 wait_event(ordered->wait, test_bit(BTRFS_ORDERED_IO_DONE, 502 wait_event(ordered->wait, test_bit(BTRFS_ORDERED_IO_DONE,
503 &ordered->flags)); 503 &ordered->flags));
504 504
505 list_add_tail(&ordered->trans_list, &trans->ordered); 505 /*
506 * If our ordered extent completed it means it updated the
507 * fs/subvol and csum trees already, so no need to make the
508 * current transaction's commit wait for it, as we end up
509 * holding memory unnecessarily and delaying the inode's iput
510 * until the transaction commit (we schedule an iput for the
511 * inode when the ordered extent's refcount drops to 0), which
512 * prevents it from being evictable until the transaction
513 * commits.
514 */
515 if (test_bit(BTRFS_ORDERED_COMPLETE, &ordered->flags))
516 btrfs_put_ordered_extent(ordered);
517 else
518 list_add_tail(&ordered->trans_list, &trans->ordered);
519
506 spin_lock_irq(&log->log_extents_lock[index]); 520 spin_lock_irq(&log->log_extents_lock[index]);
507 } 521 }
508 spin_unlock_irq(&log->log_extents_lock[index]); 522 spin_unlock_irq(&log->log_extents_lock[index]);