17b94a
From f78a5d86c55149d80b6efdf60eae7221c238654e Mon Sep 17 00:00:00 2001
17b94a
From: Rinku Kothiya <rkothiya@redhat.com>
17b94a
Date: Thu, 24 Sep 2020 12:43:51 +0000
17b94a
Subject: [PATCH 499/511] gfapi: give appropriate error when size exceeds
17b94a
17b94a
This patch help generate appropriate error message
17b94a
when the gfapi tries to write data equal to or
17b94a
greater than 1 Gb due to the limitation at the
17b94a
socket layer.
17b94a
17b94a
Upstream:
17b94a
> Reviewed-on: https://github.com/gluster/glusterfs/pull/1557
17b94a
> fixes: #1518
17b94a
> Change-Id: I1234a0b5a6e675a0b20c6b1afe0f4390fd721f6f
17b94a
> Signed-off-by: Rinku Kothiya <rkothiya@redhat.com>
17b94a
17b94a
BUG: 1691320
17b94a
Change-Id: I1234a0b5a6e675a0b20c6b1afe0f4390fd721f6f
17b94a
Signed-off-by: Rinku Kothiya <rkothiya@redhat.com>
17b94a
Signed-off-by: Sunil Kumar Acharya <sheggodu@redhat.com>
17b94a
Reviewed-on: https://code.engineering.redhat.com/gerrit/219998
17b94a
Tested-by: RHGS Build Bot <nigelb@redhat.com>
17b94a
---
17b94a
 api/src/gfapi-messages.h | 4 +++-
17b94a
 api/src/glfs-fops.c      | 8 ++++++++
17b94a
 2 files changed, 11 insertions(+), 1 deletion(-)
17b94a
17b94a
diff --git a/api/src/gfapi-messages.h b/api/src/gfapi-messages.h
17b94a
index 68d1242..2ffd5ac 100644
17b94a
--- a/api/src/gfapi-messages.h
17b94a
+++ b/api/src/gfapi-messages.h
17b94a
@@ -49,6 +49,8 @@ GLFS_MSGID(API, API_MSG_MEM_ACCT_INIT_FAILED, API_MSG_MASTER_XLATOR_INIT_FAILED,
17b94a
            API_MSG_INODE_LINK_FAILED, API_MSG_STATEDUMP_FAILED,
17b94a
            API_MSG_XREADDIRP_R_FAILED, API_MSG_LOCK_INSERT_MERGE_FAILED,
17b94a
            API_MSG_SETTING_LOCK_TYPE_FAILED, API_MSG_INODE_FIND_FAILED,
17b94a
-           API_MSG_FDCTX_SET_FAILED, API_MSG_UPCALL_SYNCOP_FAILED);
17b94a
+           API_MSG_FDCTX_SET_FAILED, API_MSG_UPCALL_SYNCOP_FAILED,
17b94a
+           API_MSG_INVALID_ARG);
17b94a
 
17b94a
+#define API_MSG_INVALID_ARG_STR "Invalid"
17b94a
 #endif /* !_GFAPI_MESSAGES_H__ */
17b94a
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
17b94a
index e6adea5..051541f 100644
17b94a
--- a/api/src/glfs-fops.c
17b94a
+++ b/api/src/glfs-fops.c
17b94a
@@ -1525,6 +1525,14 @@ glfs_pwritev_common(struct glfs_fd *glfd, const struct iovec *iovec, int iovcnt,
17b94a
 
17b94a
     GF_REF_GET(glfd);
17b94a
 
17b94a
+    if (iovec->iov_len >= GF_UNIT_GB) {
17b94a
+        ret = -1;
17b94a
+        errno = EINVAL;
17b94a
+        gf_smsg(THIS->name, GF_LOG_ERROR, errno, API_MSG_INVALID_ARG,
17b94a
+                "size >= %llu is not allowed", GF_UNIT_GB, NULL);
17b94a
+        goto out;
17b94a
+    }
17b94a
+
17b94a
     subvol = glfs_active_subvol(glfd->fs);
17b94a
     if (!subvol) {
17b94a
         ret = -1;
17b94a
-- 
17b94a
1.8.3.1
17b94a