Skip to content

Commit 3f9e3df

Browse files
kdavemasoncl
authored andcommitted
btrfs: replace error code from btrfs_drop_extents
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>
1 parent c5f7d0b commit 3f9e3df

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

fs/btrfs/file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
805805
if (start > key.offset && end < extent_end) {
806806
BUG_ON(del_nr > 0);
807807
if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
808-
ret = -EINVAL;
808+
ret = -EOPNOTSUPP;
809809
break;
810810
}
811811

@@ -851,7 +851,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
851851
*/
852852
if (start <= key.offset && end < extent_end) {
853853
if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
854-
ret = -EINVAL;
854+
ret = -EOPNOTSUPP;
855855
break;
856856
}
857857

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

fs/btrfs/ioctl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3088,7 +3088,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
30883088
new_key.offset + datal,
30893089
1);
30903090
if (ret) {
3091-
if (ret != -EINVAL)
3091+
if (ret != -EOPNOTSUPP)
30923092
btrfs_abort_transaction(trans,
30933093
root, ret);
30943094
btrfs_end_transaction(trans, root);
@@ -3163,7 +3163,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
31633163
new_key.offset + datal,
31643164
1);
31653165
if (ret) {
3166-
if (ret != -EINVAL)
3166+
if (ret != -EOPNOTSUPP)
31673167
btrfs_abort_transaction(trans,
31683168
root, ret);
31693169
btrfs_end_transaction(trans, root);

0 commit comments

Comments
 (0)