summaryrefslogtreecommitdiffstats
path: root/api/src/glfs-handleops.c
diff options
context:
space:
mode:
authorJiffin Tony Thottan <jthottan@redhat.com>2015-03-11 14:20:48 +0530
committerVijay Bellur <vbellur@redhat.com>2015-05-07 23:50:07 -0700
commit753a603ce3259f3c6667a48ff4001512941f9128 (patch)
treea43fd56d7d8801e6adbe622563e6b2ffc9b598ff /api/src/glfs-handleops.c
parent54f8ee45a5152bea73009accb569c90994f16f08 (diff)
libgfapi : anonymous fd support
backport of http://review.gluster.org/#/c/9971/ Anonymous fd's are floating fd assigned to a glusterfs client without a explicit file open. Here either it will create a new anonymous fd or existing anonymous fd in the client stack for requested file.The anonymous fd's are mainly used for IO's. This patch introduces two api's glfs_h_anonymous_read and glfs_h_anonymous_write which performs read and write respectively cherry-picked as fa0ad231745846918b2625d0e1a89c0a5c3c24dc >Change-Id: Id646f2220e8387b2f8bb244c848dc1db6761444f >BUG: 1204651 >Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com> >Reviewed-by: Niels de Vos <ndevos@redhat.com> >Reviewed-on: http://review.gluster.org/9971 >Tested-by: Gluster Build System <jenkins@build.gluster.com> >Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com> Change-Id: I6b01d88f92ad045e48debee23aa79f4517c6bdc2 BUG: 1218857 Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com> Reviewed-on: http://review.gluster.org/10635 Reviewed-by: Niels de Vos <ndevos@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'api/src/glfs-handleops.c')
-rw-r--r--api/src/glfs-handleops.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c
index 4a544f7c905..2793e1cb118 100644
--- a/api/src/glfs-handleops.c
+++ b/api/src/glfs-handleops.c
@@ -1962,3 +1962,51 @@ pub_glfs_h_acl_set (struct glfs *fs, struct glfs_object *object,
#endif
GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_h_acl_set, 3.7.0);
GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_h_acl_get, 3.7.0);
+
+/* The API to perform read using anonymous fd */
+ssize_t
+pub_glfs_h_anonymous_read (struct glfs *fs, struct glfs_object *object,
+ const void *buf, size_t count, off_t offset)
+{
+ struct iovec iov = {0, };
+ ssize_t ret = 0;
+
+ /* validate in args */
+ if ((fs == NULL) || (object == NULL)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ iov.iov_base = (void *) buf;
+ iov.iov_len = count;
+
+ ret = glfs_anonymous_preadv (fs, object, &iov, 1, offset, 0);
+
+ return ret;
+}
+
+GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_h_anonymous_read, 3.7.0);
+
+/* The API to perform write using anonymous fd */
+ssize_t
+pub_glfs_h_anonymous_write (struct glfs *fs, struct glfs_object *object,
+ const void *buf, size_t count, off_t offset)
+{
+ struct iovec iov = {0, };
+ ssize_t ret = 0;
+
+ /* validate in args */
+ if ((fs == NULL) || (object == NULL)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ iov.iov_base = (void *) buf;
+ iov.iov_len = count;
+
+ ret = glfs_anonymous_pwritev (fs, object, &iov, 1, offset, 0);
+
+ return ret;
+}
+
+GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_h_anonymous_write, 3.7.0);