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