summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 fbc9f4b49..e30a3548a 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 700e10f17..d9c1202cd 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);