19 Dec, 2012

2 commits


17 Dec, 2012

5 commits

  • I noticed while doing fsync tests that we were always dropping the path and
    re-searching when we first cow the log root even though we've already gotten
    the write lock on the root. That's because we don't take into account that
    there might not be a parent node, so fix the check to make sure there is
    actually a parent node before we undo all of this work for nothing. Thanks,

    Signed-off-by: Josef Bacik
    Signed-off-by: Chris Mason

    Josef Bacik
     
  • This gets called at least 4 times for every level while adding an object,
    and it involves 3 kmapping calls, which on my box take about 5us a piece.
    So instead use a token, which brings us down to 1 kmap call and makes this
    function take 1/3 of the time per call. Thanks,

    Signed-off-by: Josef Bacik
    Signed-off-by: Chris Mason

    Josef Bacik
     
  • We don't really need to copy extents from the source tree since we have all
    of the information already available to us in the extent_map tree. So
    instead just write the extents straight to the log tree and don't bother to
    copy the extent items from the source tree.

    Signed-off-by: Josef Bacik
    Signed-off-by: Chris Mason

    Josef Bacik
     
  • You'd think path->keep_locks would keep all the locks wouldn't you? You'd
    be wrong. It only keeps them if the slot is pointing to the last item in
    the node. This is for use with btrfs_next_leaf, which needs this sort of
    thing. But the horrible horrible things I'm going to do to the tree log
    means I really need everything held from root to leaf so I can add and
    delete items in the same search. Thanks,

    Signed-off-by: Josef Bacik
    Signed-off-by: Chris Mason

    Josef Bacik
     
  • Originally root_times_lock was introduced as part of send/receive
    code however newly developed patch to label the subvol reused
    the same lock, so renaming it for a meaningful name.

    Signed-off-by: Anand Jain
    Signed-off-by: Chris Mason

    Anand Jain
     

13 Dec, 2012

2 commits

  • Just use WARN_ON rather than an if containing only WARN_ON(1).

    A simplified version of the semantic patch that makes this transformation
    is as follows: (http://coccinelle.lip6.fr/)

    //
    @@
    expression e;
    @@
    - if (e) WARN_ON(1);
    + WARN_ON(e);
    //

    Signed-off-by: Julia Lawall
    Reviewed-by: David Sterba
    Signed-off-by: Chris Mason

    Julia Lawall
     
  • Use WARN rather than printk followed by WARN_ON(1), for conciseness.

    A simplified version of the semantic patch that makes this transformation
    is as follows: (http://coccinelle.lip6.fr/)

    //
    @@
    expression list es;
    @@

    -printk(
    +WARN(1,
    es);
    -WARN_ON(1);
    //

    Signed-off-by: Julia Lawall
    Reviewed-by: David Sterba
    Signed-off-by: Chris Mason

    Julia Lawall
     

12 Dec, 2012

4 commits

  • 'disk_key' is not used at all.

    Signed-off-by: Liu Bo
    Signed-off-by: Chris Mason

    Liu Bo
     
  • The argument 'tree_mod_log' is not necessary since all of callers enable it.

    Signed-off-by: Liu Bo
    Signed-off-by: Chris Mason

    Liu Bo
     
  • Since we don't use MOD_LOG_KEY_REMOVE_WHILE_MOVING to add nritems
    during rewinding, we should insert a MOD_LOG_KEY_REMOVE operation first.

    Signed-off-by: Liu Bo
    Signed-off-by: Chris Mason

    Liu Bo
     
  • Key MOD_LOG_KEY_REMOVE_WHILE_MOVING means that we're doing memmove inside
    an extent buffer node, and the node's number of items remains unchanged
    (unless we are inserting a single pointer, but we have MOD_LOG_KEY_ADD for that).

    So we don't need to increase node's number of items during rewinding,
    otherwise we may get an node larger than leafsize and cause general protection
    errors later.

    Here is the details,
    - If we do memory move for inserting a single pointer, we need to
    add node's nritems by one, and we honor MOD_LOG_KEY_ADD for adding.

    - If we do memory move for deleting a single pointer, we need to
    decrease node's nritems by one, and we honor MOD_LOG_KEY_REMOVE for
    deleting.

    - If we do memory move for balance left/right, we need to decrease
    node's nritems, and we honor MOD_LOG_KEY_REMOVE for balaning.

    Signed-off-by: Liu Bo
    Signed-off-by: Chris Mason

    Liu Bo
     

26 Oct, 2012

1 commit


24 Oct, 2012

4 commits


23 Oct, 2012

2 commits


09 Oct, 2012

1 commit


02 Oct, 2012

1 commit

  • The btrfs send code was assuming the offset of the file item into the
    extent translated to bytes on disk. If we're compressed, this isn't
    true, and so it was off into extents owned by other files.

    It was also improperly handling inline extents. This solves a crash
    where we may have gone past the end of the file extent item by not
    testing early enough for an inline extent. It also solves problems
    where we have a whole between the end of the inline item and the start
    of the full extent.

    Signed-off-by: Chris Mason

    Chris Mason
     

29 Aug, 2012

2 commits

  • When we split a leaf, we may end up inserting a new root on top of that
    leaf. The reflog code was incorrectly assuming the old root was always
    a node. This makes sure we skip over leaves.

    Signed-off-by: Chris Mason

    Chris Mason
     
  • Commit a168650c introduced a waiting mechanism to prevent busy waiting in
    btrfs_run_delayed_refs. This can deadlock with btrfs_run_ordered_operations,
    where a tree_mod_seq is held while waiting for the io to complete, while
    the end_io calls btrfs_run_delayed_refs.
    This whole mechanism is unnecessary. If not enough runnable refs are
    available to satisfy count, just return as count is more like a guideline
    than a strict requirement.
    In case we have to run all refs, commit transaction makes sure that no
    other threads are working in the transaction anymore, so we just assert
    here that no refs are blocked.

    Signed-off-by: Arne Jansen
    Signed-off-by: Chris Mason

    Arne Jansen
     

26 Jul, 2012

2 commits


25 Jul, 2012

1 commit

  • Often no exact match is wanted but just the next lower or
    higher item. There's a lot of duplicated code throughout
    btrfs to deal with the corner cases. This patch adds a
    helper function that can facilitate searching.

    Signed-off-by: Arne Jansen

    Arne Jansen
     

10 Jul, 2012

3 commits


27 Jun, 2012

4 commits

  • With the tree mod log, we may end up with two roots (the current root and a
    rewinded version of it) both pointing to two leaves, l1 and l2, of which l2
    had already been cow-ed in the current transaction. If we don't rewind any
    tree blocks, we cannot have two roots both pointing to an already cowed tree
    block.

    Now there is btrfs_next_leaf, which has a leaf locked and wants a lock on
    the next (right) leaf. And there is push_leaf_left, which has a (cowed!)
    leaf locked and wants a lock on the previous (left) leaf.

    In order to solve this dead lock situation, we use try_lock in
    btrfs_next_leaf (only in case it's called with a tree mod log time_seq
    paramter) and if we fail to get a lock on the next leaf, we give up our lock
    on the current leaf and retry from the very beginning.

    Signed-off-by: Jan Schmidt

    Jan Schmidt
     
  • When a MOD_LOG_KEY_ADD operation is rewinded, we remove the key from the
    tree block. If its not the last key, removal involves a move operation.
    This move operation was explicitly done before this commit.

    However, at insertion time, there's a move operation before the actual
    addition to make room for the new key, which is recorded in the tree mod
    log as well. This means, we must drop the move operation when rewinding the
    add operation, because the next operation we'll be rewinding will be the
    corresponding MOD_LOG_MOVE_KEYS operation.

    Signed-off-by: Jan Schmidt

    Jan Schmidt
     
  • Several callers of insert_ptr set the tree_mod_log parameter to 0 to avoid
    addition to the tree mod log. In fact, we need all of those operations. This
    commit simply removes the additional parameter and makes addition to the
    tree mod log unconditional.

    Signed-off-by: Jan Schmidt

    Jan Schmidt
     
  • For the tree mod log, we don't log any operations at leaf level. If the root
    is at the leaf level (i.e. the tree consists only of the root), then
    __tree_mod_log_oldest_root will find a ROOT_REPLACE operation in the log
    (because we always log that one no matter which level), but no other
    operations.

    With this patch __tree_mod_log_oldest_root exits cleanly instead of
    BUGging in this situation. get_old_root checks if its really a root at leaf
    level in case we don't have any operations and WARNs if this assumption
    breaks.

    Signed-off-by: Jan Schmidt

    Jan Schmidt
     

16 Jun, 2012

1 commit


15 Jun, 2012

4 commits

  • When adding to the tree modification log, we grab two locks at different
    stages. We must not drop the outer lock until we're done with section
    protected by the inner lock. This moves the unlock call for the outer lock
    to the appropriate position.

    Signed-off-by: Jan Schmidt

    Jan Schmidt
     
  • To make sense of the tree mod log, the backref walker not only needs
    btrfs_search_old_slot, but it also called btrfs_next_leaf, which in turn was
    calling btrfs_search_slot. This obviously didn't give the correct result.

    This commit adds btrfs_next_old_leaf, a drop-in replacement for
    btrfs_next_leaf with a time_seq parameter. If it is zero, it behaves exactly
    like btrfs_next_leaf. If it is non-zero, it will use btrfs_search_old_slot
    with this time_seq parameter.

    Signed-off-by: Jan Schmidt

    Jan Schmidt
     
  • In __tree_mod_log_oldest_root() we must return the found operation even if
    it's not a ROOT_REPLACE operation. Otherwise, the caller assumes that there
    are no operations to be rewinded and returns immediately.

    The code in the caller is modified to improve readability.

    Signed-off-by: Jan Schmidt

    Jan Schmidt
     
  • get_old_root could race with root node updates because we weren't locking
    the node early enough. Use btrfs_read_lock_root_node to grab the root locked
    in the very beginning and release the lock as soon as possible (just like
    btrfs_search_slot does).

    Signed-off-by: Jan Schmidt

    Jan Schmidt
     

04 Jun, 2012

1 commit