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