diff options
author | Gerhard Heift <gerhard@heift.name> | 2014-01-30 16:23:57 +0100 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-06-13 03:20:39 +0200 |
commit | 25c9bc2e2bc9d67de7fc49ff2784cae5de755192 (patch) | |
tree | fe51f95796bd4e6126c70bcc48e01ed08add3f57 /fs/btrfs | |
parent | Btrfs: convert smp_mb__{before,after}_clear_bit (diff) | |
download | linux-25c9bc2e2bc9d67de7fc49ff2784cae5de755192.tar.xz linux-25c9bc2e2bc9d67de7fc49ff2784cae5de755192.zip |
btrfs: tree_search: eliminate redundant nr_items check
If the amount of items reached the given limit of nr_items, we can leave
copy_to_sk without updating the key. Also by returning 1 we leave the loop in
search_ioctl without rechecking if we reached the given limit.
Signed-off-by: Gerhard Heift <Gerhard@Heift.Name>
Signed-off-by: Chris Mason <clm@fb.com>
Acked-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/ioctl.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index c2e796b664c1..65148cd102cd 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1995,7 +1995,7 @@ static noinline int copy_to_sk(struct btrfs_root *root, if (sizeof(sh) + item_len + *sk_offset > BTRFS_SEARCH_ARGS_BUFSIZE) { ret = 1; - goto overflow; + goto out; } sh.objectid = key->objectid; @@ -2017,8 +2017,10 @@ static noinline int copy_to_sk(struct btrfs_root *root, } (*num_found)++; - if (*num_found >= sk->nr_items) - break; + if (*num_found >= sk->nr_items) { + ret = 1; + goto out; + } } advance_key: ret = 0; @@ -2033,7 +2035,7 @@ advance_key: key->objectid++; } else ret = 1; -overflow: +out: return ret; } @@ -2085,7 +2087,7 @@ static noinline int search_ioctl(struct inode *inode, ret = copy_to_sk(root, path, &key, sk, args->buf, &sk_offset, &num_found); btrfs_release_path(path); - if (ret || num_found >= sk->nr_items) + if (ret) break; } |