Skip to content

Commit

Permalink
Btrfs: always pin metadata in discard mode
Browse files Browse the repository at this point in the history
We have an optimization in btrfs to allow blocks to be
immediately freed if they were allocated in this transaction and never
written.  Otherwise they are pinned and freed when the transaction
commits.

This isn't optimal for discard mode because immediately freeing
them means immediately discarding them.  It is better to give the
block to the pinning code and letting the (slow) discard happen later.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
chrismason-xx committed Oct 14, 2009
1 parent 0634857 commit 444528b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fs/btrfs/extent-tree.c
Expand Up @@ -3686,6 +3686,14 @@ static int pin_down_bytes(struct btrfs_trans_handle *trans,
if (is_data)
goto pinit;

/*
* discard is sloooow, and so triggering discards on
* individual btree blocks isn't a good plan. Just
* pin everything in discard mode.
*/
if (btrfs_test_opt(root, DISCARD))
goto pinit;

buf = btrfs_find_tree_block(root, bytenr, num_bytes);
if (!buf)
goto pinit;
Expand Down

0 comments on commit 444528b

Please sign in to comment.