summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2013-06-04 11:54:43 -0400
committerAnand Avati <avati@redhat.com>2013-06-13 14:38:57 -0700
commitcede8eb3d0007dcd6eb8929d5031ff25be955ed6 (patch)
treeb6851fa4406ab628fc16f1e0aea4ab318d14f688 /api
parent17f287172413dc04244781aa5302a0e4f10e2777 (diff)
gfapi: async discard support
From: Bharata B Rao <bharata@linux.vnet.ibm.com> Add glfs_discard_async() to meet QEMU's discard requirements. BUG: 963678 Change-Id: I97723107fca88dd96cddc08cd67a286645a37922 Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com> Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-on: http://review.gluster.org/5144 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'api')
-rw-r--r--api/src/glfs-fops.c35
-rw-r--r--api/src/glfs.h3
2 files changed, 38 insertions, 0 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index fbc9f4b49e4..e30a3548ad0 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -592,6 +592,9 @@ glfs_io_async_task (void *data)
else
ret = glfs_fsync (gio->glfd);
break;
+ case GF_FOP_DISCARD:
+ ret = glfs_discard (gio->glfd, gio->offset, gio->count);
+ break;
}
return (int) ret;
@@ -1742,6 +1745,38 @@ glfs_seekdir (struct glfs_fd *fd, long offset)
*/
}
+int
+glfs_discard_async (struct glfs_fd *glfd, off_t offset, size_t len,
+ glfs_io_cbk fn, void *data)
+{
+ struct glfs_io *gio = NULL;
+ int ret = 0;
+
+ gio = GF_CALLOC (1, sizeof (*gio), glfs_mt_glfs_io_t);
+ if (!gio) {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ gio->op = GF_FOP_DISCARD;
+ gio->glfd = glfd;
+ gio->offset = offset;
+ gio->count = len;
+ gio->fn = fn;
+ gio->data = data;
+
+ ret = synctask_new (glfs_from_glfd (glfd)->ctx->env,
+ glfs_io_async_task, glfs_io_async_cbk,
+ NULL, gio);
+
+ if (ret) {
+ GF_FREE (gio->iov);
+ GF_FREE (gio);
+ }
+
+ return ret;
+}
+
void
gf_dirent_to_dirent (gf_dirent_t *gf_dirent, struct dirent *dirent)
diff --git a/api/src/glfs.h b/api/src/glfs.h
index 700e10f17c9..d9c1202cd4c 100644
--- a/api/src/glfs.h
+++ b/api/src/glfs.h
@@ -452,6 +452,9 @@ int glfs_fallocate(glfs_fd_t *fd, int keep_size, off_t offset, size_t len);
int glfs_discard(glfs_fd_t *fd, off_t offset, size_t len);
+int glfs_discard_async (glfs_fd_t *fd, off_t length, size_t lent,
+ glfs_io_cbk fn, void *data);
+
char *glfs_getcwd (glfs_t *fs, char *buf, size_t size);
int glfs_chdir (glfs_t *fs, const char *path);