@@ -4655,7 +4655,12 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path,
int ret;
int i;
- ASSERT(!path->nowait);
+ /*
+ * The nowait semantics are used only for write paths, where we don't
+ * use the tree mod log and sequence numbers.
+ */
+ if (time_seq)
+ ASSERT(!path->nowait);
nritems = btrfs_header_nritems(path->nodes[0]);
if (nritems == 0)
@@ -4751,8 +4756,11 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path,
next = c;
ret = read_block_for_search(root, path, &next, level,
slot, &key);
- if (ret == -EAGAIN)
+ if (ret == -EAGAIN) {
+ if (path->nowait)
+ goto done;
goto again;
+ }
if (ret < 0) {
btrfs_release_path(path);
@@ -4761,6 +4769,10 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path,
if (!path->skip_locking) {
ret = btrfs_try_tree_read_lock(next);
+ if (!ret && path->nowait) {
+ ret = -EAGAIN;
+ goto done;
+ }
if (!ret && time_seq) {
/*
* If we don't get the lock, we may be racing
@@ -4791,8 +4803,11 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path,
ret = read_block_for_search(root, path, &next, level,
0, &key);
- if (ret == -EAGAIN)
+ if (ret == -EAGAIN) {
+ if (path->nowait)
+ goto done;
goto again;
+ }
if (ret < 0) {
btrfs_release_path(path);