Skip to contentSkip to conversation

a late clone fix

PATCH In review Christoph Hellwig 2 participants 3 messages Feb 26, 2016 VFS

lore
Share & tools
lore
#0 lore raw

Not sure why I messed up the return value for a missing clone_file_range method, but EBADF is a really bad choice.

#1 lore raw

PATCH 1/1 fs: return -EOPNOTSUPP if clone is not supported

-EBADF is a rather confusing error if an operations is not supported, and nfsd gets rather upset about it.

---
 fs/read_write.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
fs/read_write.c +4 -2
index 324ec27..1cdfdfe 100644
@@ -1532,10 +1532,12 @@ int vfs_clone_file_range(struct file *file_in, loff_t pos_in,
 
 	if (!(file_in->f_mode & FMODE_READ) ||
 	    !(file_out->f_mode & FMODE_WRITE) ||
-	    (file_out->f_flags & O_APPEND) ||
-	    !file_in->f_op->clone_file_range)
+	    (file_out->f_flags & O_APPEND))
 		return -EBADF;
 
+	if (!file_in->f_op->clone_file_range)
+		return -EOPNOTSUPP;
+
 	ret = clone_verify_area(file_in, pos_in, len, false);
 	if (ret)
 		return ret;
Signature · 1 line
2.1.4
Reviewed-by on v1 1/1
#2 lore raw

Re: [PATCH] fs: return -EOPNOTSUPP if clone is not supported

Quoted 2 lines · Christoph Hellwig

-EBADF is a rather confusing error if an operations is not supported, and nfsd gets rather upset about it.

I was wondering why I kept getting EBADF trying to run xfstests over NFS before I figured out to pass -o nfsvers=4.2 to mount.

Anyhow,

--D

Quoted 28 lines
---
 fs/read_write.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
fs/read_write.c +4 -2
index 324ec27..1cdfdfe 100644
@@ -1532,10 +1532,12 @@ int vfs_clone_file_range(struct file *file_in, loff_t pos_in,
 
 	if (!(file_in->f_mode & FMODE_READ) ||
 	    !(file_out->f_mode & FMODE_WRITE) ||
-	    (file_out->f_flags & O_APPEND) ||
-	    !file_in->f_op->clone_file_range)
+	    (file_out->f_flags & O_APPEND))
 		return -EBADF;
 
+	if (!file_in->f_op->clone_file_range)
+		return -EOPNOTSUPP;
+
 	ret = clone_verify_area(file_in, pos_in, len, false);
 	if (ret)
 		return ret;
Signature · 1 line
2.1.4