Skip to content

Commit

Permalink
btrfs: Ensure the tree search ioctl returns the right number of records
Browse files Browse the repository at this point in the history
Btrfs's tree search ioctl has a field to indicate that no more than a
given number of records should be returned. The ioctl doesn't honour
this, as the tested value is not incremented until the end of the
copy_to_sk function. This patch removes an unnecessary local variable,
and updates the num_found counter as each key is found in the tree.

Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Hugo Mills authored and Chris Mason committed May 23, 2011
1 parent 0956c79 commit e215686
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,6 @@ static noinline int copy_to_sk(struct btrfs_root *root,
int nritems;
int i;
int slot;
int found = 0;
int ret = 0;

leaf = path->nodes[0];
Expand Down Expand Up @@ -1326,7 +1325,7 @@ static noinline int copy_to_sk(struct btrfs_root *root,
item_off, item_len);
*sk_offset += item_len;
}
found++;
(*num_found)++;

if (*num_found >= sk->nr_items)
break;
Expand All @@ -1345,7 +1344,6 @@ static noinline int copy_to_sk(struct btrfs_root *root,
} else
ret = 1;
overflow:
*num_found += found;
return ret;
}

Expand Down

0 comments on commit e215686

Please sign in to comment.