Skip to content

Commit

Permalink
btrfs: replace error code from btrfs_drop_extents
Browse files Browse the repository at this point in the history
There's a case which clone does not handle and used to BUG_ON instead,
(testcase xfstests/btrfs/035), now returns EINVAL. This error code is
confusing to the ioctl caller, as it normally signifies errorneous
arguments.

Change it to ENOPNOTSUPP which allows a fall back to copy instead of
clone. This does not affect the common reflink operation.

Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
  • Loading branch information
kdave authored and masoncl committed Apr 24, 2014
1 parent c5f7d0b commit 3f9e3df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions fs/btrfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
if (start > key.offset && end < extent_end) {
BUG_ON(del_nr > 0);
if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
ret = -EINVAL;
ret = -EOPNOTSUPP;
break;
}

Expand Down Expand Up @@ -851,7 +851,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
*/
if (start <= key.offset && end < extent_end) {
if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
ret = -EINVAL;
ret = -EOPNOTSUPP;
break;
}

Expand All @@ -877,7 +877,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
if (start > key.offset && end >= extent_end) {
BUG_ON(del_nr > 0);
if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
ret = -EINVAL;
ret = -EOPNOTSUPP;
break;
}

Expand Down
4 changes: 2 additions & 2 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3088,7 +3088,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
new_key.offset + datal,
1);
if (ret) {
if (ret != -EINVAL)
if (ret != -EOPNOTSUPP)
btrfs_abort_transaction(trans,
root, ret);
btrfs_end_transaction(trans, root);
Expand Down Expand Up @@ -3163,7 +3163,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
new_key.offset + datal,
1);
if (ret) {
if (ret != -EINVAL)
if (ret != -EOPNOTSUPP)
btrfs_abort_transaction(trans,
root, ret);
btrfs_end_transaction(trans, root);
Expand Down

0 comments on commit 3f9e3df

Please sign in to comment.