[lustre-devel] [PATCH 36/39] lustre: llite: return EOPNOTSUPP if fallocate is not supported

James Simmons jsimmons at infradead.org
Thu Jan 21 09:16:59 PST 2021


From: "John L. Hammond" <jhammond at whamcloud.com>

In ll_fallocate() if the server returns the NFSv3 specific error code
ENOTSUPP then replace it with EOPNOTSUPP to avoid confusing
applications.

WC-bug-id: https://jira.whamcloud.com/browse/LU-14301
Lustre-commit: 71a9f5a466bfa4 ("LU-14301 llite: return EOPNOTSUPP if fallocate is not supported")
Signed-off-by: John L. Hammond <jhammond at whamcloud.com>
Reviewed-on: https://review.whamcloud.com/41148
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain at aeoncomputing.com>
Reviewed-by: Wang Shilong <wshilong at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 fs/lustre/llite/file.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c
index a3a8d1a..7c7ac01 100644
--- a/fs/lustre/llite/file.c
+++ b/fs/lustre/llite/file.c
@@ -4934,6 +4934,7 @@ int cl_falloc(struct inode *inode, int mode, loff_t offset, loff_t len)
 long ll_fallocate(struct file *filp, int mode, loff_t offset, loff_t len)
 {
 	struct inode *inode = filp->f_path.dentry->d_inode;
+	int rc;
 
 	/*
 	 * Encrypted inodes can't handle collapse range or zero range or insert
@@ -4955,7 +4956,17 @@ long ll_fallocate(struct file *filp, int mode, loff_t offset, loff_t len)
 
 	ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_FALLOCATE, 1);
 
-	return cl_falloc(inode, mode, offset, len);
+	rc = cl_falloc(inode, mode, offset, len);
+	/*
+	 * ENOTSUPP (524) is an NFSv3 specific error code erroneously
+	 * used by Lustre in several places. Retuning it here would
+	 * confuse applications that explicity test for EOPNOTSUPP
+	 * (95) and fall back to ftruncate().
+	 */
+	if (rc == -ENOTSUPP)
+		rc = -EOPNOTSUPP;
+
+	return rc;
 }
 
 static int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
-- 
1.8.3.1



More information about the lustre-devel mailing list