Skip to content

Commit c24a480

Browse files
oromenaharbehlendorf
authored andcommitted
BRT should return EOPNOTSUPP
Return the more descriptive EOPNOTSUPP instead of EXDEV when the storage pool doesn't support block cloning. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Rob Norris <[email protected]> Signed-off-by: Kay Pedersen <[email protected]> Closes #15097
1 parent 36d1a3e commit c24a480

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

module/os/freebsd/zfs/zfs_vnops_os.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6290,7 +6290,7 @@ zfs_freebsd_copy_file_range(struct vop_copy_file_range_args *ap)
62906290

62916291
error = zfs_clone_range(VTOZ(invp), ap->a_inoffp, VTOZ(outvp),
62926292
ap->a_outoffp, &len, ap->a_outcred);
6293-
if (error == EXDEV)
6293+
if (error == EXDEV || error == EOPNOTSUPP)
62946294
goto bad_locked_fallback;
62956295
*ap->a_lenp = (size_t)len;
62966296
out_locked:

module/zfs/zfs_vnops.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,16 @@ zfs_clone_range(znode_t *inzp, uint64_t *inoffp, znode_t *outzp,
10781078
return (SET_ERROR(EXDEV));
10791079
}
10801080

1081+
/*
1082+
* outos and inos belongs to the same storage pool.
1083+
* see a few lines above, only one check.
1084+
*/
1085+
if (!spa_feature_is_enabled(dmu_objset_spa(outos),
1086+
SPA_FEATURE_BLOCK_CLONING)) {
1087+
zfs_exit_two(inzfsvfs, outzfsvfs, FTAG);
1088+
return (SET_ERROR(EOPNOTSUPP));
1089+
}
1090+
10811091
ASSERT(!outzfsvfs->z_replay);
10821092

10831093
error = zfs_verify_zp(inzp);
@@ -1088,12 +1098,6 @@ zfs_clone_range(znode_t *inzp, uint64_t *inoffp, znode_t *outzp,
10881098
return (error);
10891099
}
10901100

1091-
if (!spa_feature_is_enabled(dmu_objset_spa(outos),
1092-
SPA_FEATURE_BLOCK_CLONING)) {
1093-
zfs_exit_two(inzfsvfs, outzfsvfs, FTAG);
1094-
return (SET_ERROR(EXDEV));
1095-
}
1096-
10971101
/*
10981102
* We don't copy source file's flags that's why we don't allow to clone
10991103
* files that are in quarantine.

0 commit comments

Comments
 (0)