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