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