diff options
author | Kinglong Mee <kinglongmee@gmail.com> | 2018-02-01 11:20:37 +0800 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-02-12 21:34:46 +0000 |
commit | 384562b294e9a7847403961e878a4daa0fff33eb (patch) | |
tree | 903cd2cc4552ce1fe17c0d6a707718107e749d43 /api/src | |
parent | 248152767b0599986bbb6bb35fc27197f6be6964 (diff) |
gfapi: return pre/post attributes at callback for glfs api
Updates: #389
Change-Id: Ic71632722effe4b8855d5de3e65688efd9afe1e3
Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
Diffstat (limited to 'api/src')
-rw-r--r-- | api/src/gfapi.aliases | 31 | ||||
-rw-r--r-- | api/src/gfapi.map | 26 | ||||
-rw-r--r-- | api/src/glfs-fops.c | 386 | ||||
-rw-r--r-- | api/src/glfs.h | 32 |
4 files changed, 379 insertions, 96 deletions
diff --git a/api/src/gfapi.aliases b/api/src/gfapi.aliases index 0445c0ac640..42256726f63 100644 --- a/api/src/gfapi.aliases +++ b/api/src/gfapi.aliases @@ -18,31 +18,25 @@ _pub_glfs_from_glfd _glfs_from_glfd$GFAPI_3.4.0 _pub_glfs_set_xlator_option _glfs_set_xlator_option$GFAPI_3.4.0 _pub_glfs_read _glfs_read$GFAPI_3.4.0 _pub_glfs_write _glfs_write$GFAPI_3.4.0 -_pub_glfs_read_async _glfs_read_async$GFAPI_3.4.0 -_pub_glfs_write_async _glfs_write_async$GFAPI_3.4.0 _pub_glfs_readv _glfs_readv$GFAPI_3.4.0 _pub_glfs_writev _glfs_writev$GFAPI_3.4.0 -_pub_glfs_readv_async _glfs_readv_async$GFAPI_3.4.0 -_pub_glfs_writev_async _glfs_writev_async$GFAPI_3.4.0 _pub_glfs_pread34 _glfs_pread$GFAPI_3.4.0 _pub_glfs_pwrite34 _glfs_pwrite$GFAPI_3.4.0 -_pub_glfs_pread_async _glfs_pread_async$GFAPI_3.4.0 -_pub_glfs_pwrite_async _glfs_pwrite_async$GFAPI_3.4.0 +_pub_glfs_pread_async34 _glfs_pread_async$GFAPI_3.4.0 +_pub_glfs_pwrite_async34 _glfs_pwrite_async$GFAPI_3.4.0 _pub_glfs_preadv _glfs_preadv$GFAPI_3.4.0 _pub_glfs_pwritev _glfs_pwritev$GFAPI_3.4.0 -_pub_glfs_preadv_async _glfs_preadv_async$GFAPI_3.4.0 -_pub_glfs_pwritev_async _glfs_pwritev_async$GFAPI_3.4.0 _pub_glfs_lseek _glfs_lseek$GFAPI_3.4.0 _pub_glfs_truncate _glfs_truncate$GFAPI_3.7.15 _pub_glfs_ftruncate34 _glfs_ftruncate34$GFAPI_3.4.0 -_pub_glfs_ftruncate_async _glfs_ftruncate_async$GFAPI_3.4.0 +_pub_glfs_ftruncate_async34 _glfs_ftruncate_async34$GFAPI_3.4.0 _pub_glfs_lstat _glfs_lstat$GFAPI_3.4.0 _pub_glfs_stat _glfs_stat$GFAPI_3.4.0 _pub_glfs_fstat _glfs_fstat$GFAPI_3.4.0 _pub_glfs_fsync34 _glfs_fsync34$GFAPI_3.4.0 -_pub_glfs_fsync_async _glfs_fsync_async$GFAPI_3.4.0 +_pub_glfs_fsync_async34 _glfs_fsync_async34$GFAPI_3.4.0 _pub_glfs_fdatasync34 _glfs_fdatasync34$GFAPI_3.4.0 -_pub_glfs_fdatasync_async _glfs_fdatasync_async$GFAPI_3.4.0 +_pub_glfs_fdatasync_async34 _glfs_fdatasync_async34$GFAPI_3.4.0 _pub_glfs_access _glfs_access$GFAPI_3.4.0 _pub_glfs_symlink _glfs_symlink$GFAPI_3.4.0 _pub_glfs_readlink _glfs_readlink$GFAPI_3.4.0 @@ -113,9 +107,7 @@ _pub_glfs_readdir _glfs_readdir$GFAPI_3.5.0 _pub_glfs_readdirplus _glfs_readdirplus$GFAPI_3.5.0 _pub_glfs_fallocate _glfs_fallocate$GFAPI_3.5.0 _pub_glfs_discard _glfs_discard$GFAPI_3.5.0 -_pub_glfs_discard_async _glfs_discard_async$GFAPI_3.5.0 _pub_glfs_zerofill _glfs_zerofill$GFAPI_3.5.0 -_pub_glfs_zerofill_async _glfs_zerofill_async$GFAPI_3.5.0 _pub_glfs_h_setxattrs _glfs_h_setxattrs$GFAPI_3.5.0 _pub_glfs_unset_volfile_server _glfs_unset_volfile_server$GFAPI_3.5.1 @@ -172,8 +164,21 @@ _pub_glfs_setfsleaseid _glfs_setfsleaseid$GFAPI_4.0.0 _pub_glfs_file_lock _glfs_file_lock$GFAPI_4.0.0 _pub_glfs_lease _glfs_lease$GFAPI_4.0.0 _pub_glfs_h_lease _glfs_h_lease$GFAPI_4.0.0 +_pub_glfs_read_async _glfs_read_async$GFAPI_4.0.0 +_pub_glfs_write_async _glfs_write_async$GFAPI_4.0.0 +_pub_glfs_readv_async _glfs_readv_async$GFAPI_4.0.0 +_pub_glfs_writev_async _glfs_writev_async$GFAPI_4.0.0 _pub_glfs_pread _glfs_pread$GFAPI_4.0.0 _pub_glfs_pwrite _glfs_pwrite$GFAPI_4.0.0 +_pub_glfs_pread_async _glfs_pread_async$GFAPI_4.0.0 +_pub_glfs_pwrite_async _glfs_pwrite_async$GFAPI_4.0.0 +_pub_glfs_preadv_async _glfs_preadv_async$GFAPI_4.0.0 +_pub_glfs_pwritev_async _glfs_pwritev_async$GFAPI_4.0.0 _pub_glfs_fsync _glfs_fsync$GFAPI_4.0.0 +_pub_glfs_fsync_async _glfs_fsync_async$GFAPI_4.0.0 _pub_glfs_fdatasync _glfs_fdatasync$GFAPI_4.0.0 +_pub_glfs_fdatasync_async _glfs_fdatasync_async$GFAPI_4.0.0 _pub_glfs_ftruncate _glfs_ftruncate$GFAPI_4.0.0 +_pub_glfs_ftruncate_async _glfs_ftruncate_async$GFAPI_4.0.0 +_pub_glfs_discard_async _glfs_discard_async$GFAPI_4.0.0 +_pub_glfs_zerofill_async _glfs_zerofill_async$GFAPI_4.0.0 diff --git a/api/src/gfapi.map b/api/src/gfapi.map index fbf0985d990..96ea13ab73b 100644 --- a/api/src/gfapi.map +++ b/api/src/gfapi.map @@ -24,25 +24,14 @@ GFAPI_3.4.0 { glfs_set_xlator_option; glfs_read; glfs_write; - glfs_read_async; - glfs_write_async; glfs_readv; glfs_writev; - glfs_readv_async; - glfs_writev_async; - glfs_pread_async; - glfs_pwrite_async; glfs_preadv; glfs_pwritev; - glfs_preadv_async; - glfs_pwritev_async; glfs_lseek; - glfs_ftruncate_async; glfs_lstat; glfs_stat; glfs_fstat; - glfs_fsync_async; - glfs_fdatasync_async; glfs_access; glfs_symlink; glfs_readlink; @@ -119,9 +108,7 @@ GFAPI_3.5.0 { glfs_readdirplus; glfs_fallocate; glfs_discard; - glfs_discard_async; glfs_zerofill; - glfs_zerofill_async; glfs_caller_specific_init; glfs_h_setxattrs; } GFAPI_3.4.2; @@ -222,9 +209,22 @@ GFAPI_4.0.0 { glfs_file_lock; glfs_lease; glfs_h_lease; + glfs_read_async; + glfs_write_async; + glfs_readv_async; + glfs_writev_async; glfs_pread; glfs_pwrite; + glfs_pread_async; + glfs_pwrite_async; + glfs_preadv_async; + glfs_pwritev_async; glfs_fsync; + glfs_fsync_async; glfs_fdatasync; + glfs_fdatasync_async; glfs_ftruncate; + glfs_ftruncate_async; + glfs_discard_async; + glfs_zerofill_async; } GFAPI_3.13.0; diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c index 1cd7669438f..a01499a6bf6 100644 --- a/api/src/glfs-fops.c +++ b/api/src/glfs-fops.c @@ -846,20 +846,27 @@ struct glfs_io { struct iovec *iov; int count; int flags; - glfs_io_cbk fn; + gf_boolean_t oldcb; + union { + glfs_io_cbk34 fn34; + glfs_io_cbk fn; + }; void *data; }; static int glfs_io_async_cbk (int op_ret, int op_errno, call_frame_t *frame, - void *cookie, struct iovec *iovec, int count) + void *cookie, struct iovec *iovec, int count, + struct iatt *prebuf, struct iatt *postbuf) { struct glfs_io *gio = NULL; xlator_t *subvol = NULL; struct glfs *fs = NULL; struct glfs_fd *glfd = NULL; int ret = -1; + struct stat prestat = {}, *prestatp = NULL; + struct stat poststat = {}, *poststatp = NULL; GF_VALIDATE_OR_GOTO ("gfapi", frame, inval); GF_VALIDATE_OR_GOTO ("gfapi", cookie, inval); @@ -890,8 +897,21 @@ glfs_io_async_cbk (int op_ret, int op_errno, call_frame_t *frame, out: errno = op_errno; - gio->fn (gio->glfd, op_ret, gio->data); + if (gio->oldcb) { + gio->fn34 (gio->glfd, op_ret, gio->data); + } else { + if (prebuf) { + prestatp = &prestat; + glfs_iatt_to_stat (fs, prebuf, prestatp); + } + + if (postbuf) { + poststatp = &poststat; + glfs_iatt_to_stat (fs, postbuf, poststatp); + } + gio->fn (gio->glfd, op_ret, prestatp, poststatp, gio->data); + } err: fd_unref (glfd->fd); /* Since the async operation is complete @@ -916,16 +936,17 @@ glfs_preadv_async_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int count, struct iatt *stbuf, struct iobref *iobref, dict_t *xdata) { - glfs_io_async_cbk (op_ret, op_errno, frame, cookie, iovec, count); + glfs_io_async_cbk (op_ret, op_errno, frame, cookie, iovec, count, + NULL, stbuf); return 0; } -int -pub_glfs_preadv_async (struct glfs_fd *glfd, const struct iovec *iovec, - int count, off_t offset, int flags, glfs_io_cbk fn, - void *data) +static int +glfs_preadv_async_common (struct glfs_fd *glfd, const struct iovec *iovec, + int count, off_t offset, int flags, + gf_boolean_t oldcb, glfs_io_cbk fn, void *data) { struct glfs_io *gio = NULL; int ret = 0; @@ -981,6 +1002,7 @@ pub_glfs_preadv_async (struct glfs_fd *glfd, const struct iovec *iovec, gio->count = count; gio->offset = offset; gio->flags = flags; + gio->oldcb = oldcb; gio->fn = fn; gio->data = data; @@ -1014,7 +1036,47 @@ invalid_fs: return -1; } -GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_preadv_async, 3.4.0); +int +pub_glfs_preadv_async34 (struct glfs_fd *glfd, const struct iovec *iovec, + int count, off_t offset, int flags, glfs_io_cbk34 fn, + void *data) +{ + return glfs_preadv_async_common (glfd, iovec, count, offset, flags, + _gf_true, (void *)fn, data); +} + +GFAPI_SYMVER_PUBLIC(glfs_preadv_async34, glfs_preadv_async, 3.4.0); + + +int +pub_glfs_preadv_async (struct glfs_fd *glfd, const struct iovec *iovec, + int count, off_t offset, int flags, glfs_io_cbk fn, + void *data) +{ + return glfs_preadv_async_common (glfd, iovec, count, offset, flags, + _gf_false, fn, data); +} + +GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_preadv_async, 4.0.0); + + +int +pub_glfs_read_async34 (struct glfs_fd *glfd, void *buf, size_t count, int flags, + glfs_io_cbk34 fn, void *data) +{ + struct iovec iov = {0, }; + ssize_t ret = 0; + + iov.iov_base = buf; + iov.iov_len = count; + + ret = glfs_preadv_async_common (glfd, &iov, 1, glfd->offset, flags, + _gf_true, (void *)fn, data); + + return ret; +} + +GFAPI_SYMVER_PUBLIC(glfs_read_async34, glfs_read_async, 3.4.0); int @@ -1027,17 +1089,18 @@ pub_glfs_read_async (struct glfs_fd *glfd, void *buf, size_t count, int flags, iov.iov_base = buf; iov.iov_len = count; - ret = pub_glfs_preadv_async (glfd, &iov, 1, glfd->offset, flags, fn, data); + ret = glfs_preadv_async_common (glfd, &iov, 1, glfd->offset, flags, + _gf_false, fn, data); return ret; } -GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_read_async, 3.4.0); +GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_read_async, 4.0.0); int -pub_glfs_pread_async (struct glfs_fd *glfd, void *buf, size_t count, - off_t offset, int flags, glfs_io_cbk fn, void *data) +pub_glfs_pread_async34 (struct glfs_fd *glfd, void *buf, size_t count, + off_t offset, int flags, glfs_io_cbk34 fn, void *data) { struct iovec iov = {0, }; ssize_t ret = 0; @@ -1045,12 +1108,46 @@ pub_glfs_pread_async (struct glfs_fd *glfd, void *buf, size_t count, iov.iov_base = buf; iov.iov_len = count; - ret = pub_glfs_preadv_async (glfd, &iov, 1, offset, flags, fn, data); + ret = glfs_preadv_async_common (glfd, &iov, 1, offset, flags, + _gf_true, (void *)fn, data); return ret; } -GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_pread_async, 3.4.0); +GFAPI_SYMVER_PUBLIC(glfs_pread_async34, glfs_pread_async, 3.4.0); + + +int +pub_glfs_pread_async (struct glfs_fd *glfd, void *buf, size_t count, + off_t offset, int flags, glfs_io_cbk fn, void *data) +{ + struct iovec iov = {0, }; + ssize_t ret = 0; + + iov.iov_base = buf; + iov.iov_len = count; + + ret = glfs_preadv_async_common (glfd, &iov, 1, offset, flags, + _gf_false, fn, data); + + return ret; +} + +GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_pread_async, 4.0.0); + + +int +pub_glfs_readv_async34 (struct glfs_fd *glfd, const struct iovec *iov, + int count, int flags, glfs_io_cbk34 fn, void *data) +{ + ssize_t ret = 0; + + ret = glfs_preadv_async_common (glfd, iov, count, glfd->offset, flags, + _gf_true, (void *)fn, data); + return ret; +} + +GFAPI_SYMVER_PUBLIC(glfs_readv_async34, glfs_readv_async, 3.4.0); int @@ -1059,12 +1156,12 @@ pub_glfs_readv_async (struct glfs_fd *glfd, const struct iovec *iov, int count, { ssize_t ret = 0; - ret = pub_glfs_preadv_async (glfd, iov, count, glfd->offset, flags, - fn, data); + ret = glfs_preadv_async_common (glfd, iov, count, glfd->offset, flags, + _gf_false, fn, data); return ret; } -GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_readv_async, 3.4.0); +GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_readv_async, 4.0.0); static int @@ -1266,15 +1363,16 @@ glfs_pwritev_async_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata) { - glfs_io_async_cbk (op_ret, op_errno, frame, cookie, NULL, 0); + glfs_io_async_cbk (op_ret, op_errno, frame, cookie, NULL, 0, + prebuf, postbuf); return 0; } -int -pub_glfs_pwritev_async (struct glfs_fd *glfd, const struct iovec *iovec, - int count, off_t offset, int flags, glfs_io_cbk fn, - void *data) +static int +glfs_pwritev_async_common (struct glfs_fd *glfd, const struct iovec *iovec, + int count, off_t offset, int flags, + gf_boolean_t oldcb, glfs_io_cbk fn, void *data) { struct glfs_io *gio = NULL; int ret = -1; @@ -1314,6 +1412,7 @@ pub_glfs_pwritev_async (struct glfs_fd *glfd, const struct iovec *iovec, gio->glfd = glfd; gio->offset = offset; gio->flags = flags; + gio->oldcb = oldcb; gio->fn = fn; gio->data = data; gio->count = 1; @@ -1367,7 +1466,47 @@ invalid_fs: return ret; } -GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_pwritev_async, 3.4.0); +int +pub_glfs_pwritev_async34 (struct glfs_fd *glfd, const struct iovec *iovec, + int count, off_t offset, int flags, glfs_io_cbk34 fn, + void *data) +{ + return glfs_pwritev_async_common (glfd, iovec, count, offset, flags, + _gf_true, (void *)fn, data); +} + +GFAPI_SYMVER_PUBLIC(glfs_pwritev_async34, glfs_pwritev_async, 3.4.0); + + +int +pub_glfs_pwritev_async (struct glfs_fd *glfd, const struct iovec *iovec, + int count, off_t offset, int flags, glfs_io_cbk fn, + void *data) +{ + return glfs_pwritev_async_common (glfd, iovec, count, offset, flags, + _gf_false, fn, data); +} + +GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_pwritev_async, 4.0.0); + + +int +pub_glfs_write_async34 (struct glfs_fd *glfd, const void *buf, size_t count, + int flags, glfs_io_cbk34 fn, void *data) +{ + struct iovec iov = {0, }; + ssize_t ret = 0; + + iov.iov_base = (void *) buf; + iov.iov_len = count; + + ret = glfs_pwritev_async_common (glfd, &iov, 1, glfd->offset, flags, + _gf_true, (void *)fn, data); + + return ret; +} + +GFAPI_SYMVER_PUBLIC(glfs_write_async34, glfs_write_async, 3.4.0); int @@ -1380,17 +1519,18 @@ pub_glfs_write_async (struct glfs_fd *glfd, const void *buf, size_t count, iov.iov_base = (void *) buf; iov.iov_len = count; - ret = pub_glfs_pwritev_async (glfd, &iov, 1, glfd->offset, flags, fn, data); + ret = glfs_pwritev_async_common (glfd, &iov, 1, glfd->offset, flags, + _gf_false, fn, data); return ret; } -GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_write_async, 3.4.0); +GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_write_async, 4.0.0); int -pub_glfs_pwrite_async (struct glfs_fd *glfd, const void *buf, int count, - off_t offset, int flags, glfs_io_cbk fn, void *data) +pub_glfs_pwrite_async34 (struct glfs_fd *glfd, const void *buf, int count, + off_t offset, int flags, glfs_io_cbk34 fn, void *data) { struct iovec iov = {0, }; ssize_t ret = 0; @@ -1398,12 +1538,46 @@ pub_glfs_pwrite_async (struct glfs_fd *glfd, const void *buf, int count, iov.iov_base = (void *) buf; iov.iov_len = count; - ret = pub_glfs_pwritev_async (glfd, &iov, 1, offset, flags, fn, data); + ret = glfs_pwritev_async_common (glfd, &iov, 1, offset, flags, + _gf_true, (void *)fn, data); return ret; } -GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_pwrite_async, 3.4.0); +GFAPI_SYMVER_PUBLIC(glfs_pwrite_async34, glfs_pwrite_async, 3.4.0); + + +int +pub_glfs_pwrite_async (struct glfs_fd *glfd, const void *buf, int count, + off_t offset, int flags, glfs_io_cbk fn, void *data) +{ + struct iovec iov = {0, }; + ssize_t ret = 0; + + iov.iov_base = (void *) buf; + iov.iov_len = count; + + ret = glfs_pwritev_async_common (glfd, &iov, 1, offset, flags, + _gf_false, fn, data); + + return ret; +} + +GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_pwrite_async, 4.0.0); + + +int +pub_glfs_writev_async34 (struct glfs_fd *glfd, const struct iovec *iov, + int count, int flags, glfs_io_cbk34 fn, void *data) +{ + ssize_t ret = 0; + + ret = glfs_pwritev_async_common (glfd, iov, count, glfd->offset, flags, + _gf_true, (void *)fn, data); + return ret; +} + +GFAPI_SYMVER_PUBLIC(glfs_writev_async34, glfs_writev_async, 3.4.0); int @@ -1412,12 +1586,12 @@ pub_glfs_writev_async (struct glfs_fd *glfd, const struct iovec *iov, int count, { ssize_t ret = 0; - ret = pub_glfs_pwritev_async (glfd, iov, count, glfd->offset, flags, - fn, data); + ret = glfs_pwritev_async_common (glfd, iov, count, glfd->offset, flags, + _gf_false, fn, data); return ret; } -GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_writev_async, 3.4.0); +GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_writev_async, 4.0.0); static int @@ -1496,14 +1670,15 @@ glfs_fsync_async_cbk (call_frame_t *frame, void *cookie, int32_t op_errno, struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata) { - glfs_io_async_cbk (op_ret, op_errno, frame, cookie, NULL, 0); + glfs_io_async_cbk (op_ret, op_errno, frame, cookie, NULL, 0, + prebuf, postbuf); return 0; } static int -glfs_fsync_async_common (struct glfs_fd *glfd, glfs_io_cbk fn, void *data, - int dataonly) +glfs_fsync_async_common (struct glfs_fd *glfd, gf_boolean_t oldcb, + glfs_io_cbk fn, void *data, int dataonly) { struct glfs_io *gio = NULL; int ret = 0; @@ -1547,6 +1722,7 @@ glfs_fsync_async_common (struct glfs_fd *glfd, glfs_io_cbk fn, void *data, gio->op = GF_FOP_FSYNC; gio->glfd = glfd; gio->flags = dataonly; + gio->oldcb = oldcb; gio->fn = fn; gio->data = data; @@ -1571,6 +1747,25 @@ out: int +pub_glfs_fsync_async34 (struct glfs_fd *glfd, glfs_io_cbk34 fn, void *data) +{ + int ret = -1; + + DECLARE_OLD_THIS; + __GLFS_ENTRY_VALIDATE_FD (glfd, invalid_fs); + + ret = glfs_fsync_async_common (glfd, _gf_true, (void *)fn, data, 0); + + __GLFS_EXIT_FS; + +invalid_fs: + return ret; +} + +GFAPI_SYMVER_PUBLIC(glfs_fsync_async34, glfs_fsync_async, 3.4.0); + + +int pub_glfs_fsync_async (struct glfs_fd *glfd, glfs_io_cbk fn, void *data) { int ret = -1; @@ -1578,7 +1773,7 @@ pub_glfs_fsync_async (struct glfs_fd *glfd, glfs_io_cbk fn, void *data) DECLARE_OLD_THIS; __GLFS_ENTRY_VALIDATE_FD (glfd, invalid_fs); - ret = glfs_fsync_async_common (glfd, fn, data, 0); + ret = glfs_fsync_async_common (glfd, _gf_false, fn, data, 0); __GLFS_EXIT_FS; @@ -1586,7 +1781,7 @@ invalid_fs: return ret; } -GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_fsync_async, 3.4.0); +GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_fsync_async, 4.0.0); static int @@ -1660,6 +1855,25 @@ GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_fdatasync, 4.0.0); int +pub_glfs_fdatasync_async34 (struct glfs_fd *glfd, glfs_io_cbk34 fn, void *data) +{ + int ret = -1; + + DECLARE_OLD_THIS; + __GLFS_ENTRY_VALIDATE_FD (glfd, invalid_fs); + + ret = glfs_fsync_async_common (glfd, _gf_true, (void *)fn, data, 1); + + __GLFS_EXIT_FS; + +invalid_fs: + return ret; +} + +GFAPI_SYMVER_PUBLIC(glfs_fdatasync_async34, glfs_fdatasync_async, 3.4.0); + + +int pub_glfs_fdatasync_async (struct glfs_fd *glfd, glfs_io_cbk fn, void *data) { int ret = -1; @@ -1667,7 +1881,7 @@ pub_glfs_fdatasync_async (struct glfs_fd *glfd, glfs_io_cbk fn, void *data) DECLARE_OLD_THIS; __GLFS_ENTRY_VALIDATE_FD (glfd, invalid_fs); - ret = glfs_fsync_async_common (glfd, fn, data, 1); + ret = glfs_fsync_async_common (glfd, _gf_false, fn, data, 1); __GLFS_EXIT_FS; @@ -1675,7 +1889,7 @@ invalid_fs: return ret; } -GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_fdatasync_async, 3.4.0); +GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_fdatasync_async, 4.0.0); static int @@ -1799,14 +2013,15 @@ glfs_ftruncate_async_cbk (call_frame_t *frame, void *cookie, xlator_t *this, struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata) { - glfs_io_async_cbk (op_ret, op_errno, frame, cookie, NULL, 0); + glfs_io_async_cbk (op_ret, op_errno, frame, cookie, NULL, 0, + prebuf, postbuf); return 0; } -int -pub_glfs_ftruncate_async (struct glfs_fd *glfd, off_t offset, glfs_io_cbk fn, - void *data) +static int +glfs_ftruncate_async_common (struct glfs_fd *glfd, off_t offset, + gf_boolean_t oldcb, glfs_io_cbk fn, void *data) { struct glfs_io *gio = NULL; int ret = -1; @@ -1849,6 +2064,7 @@ pub_glfs_ftruncate_async (struct glfs_fd *glfd, off_t offset, glfs_io_cbk fn, gio->op = GF_FOP_FTRUNCATE; gio->glfd = glfd; gio->offset = offset; + gio->oldcb = oldcb; gio->fn = fn; gio->data = data; @@ -1877,7 +2093,25 @@ invalid_fs: return ret; } -GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_ftruncate_async, 3.4.0); +int +pub_glfs_ftruncate_async34 (struct glfs_fd *glfd, off_t offset, + glfs_io_cbk34 fn, void *data) +{ + return glfs_ftruncate_async_common (glfd, offset, _gf_true, + (void *)fn, data); +} + +GFAPI_SYMVER_PUBLIC(glfs_ftruncate_async34, glfs_ftruncate_async, 3.4.0); + + +int +pub_glfs_ftruncate_async (struct glfs_fd *glfd, off_t offset, + glfs_io_cbk fn, void *data) +{ + return glfs_ftruncate_async_common (glfd, offset, _gf_false, fn, data); +} + +GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_ftruncate_async, 4.0.0); int @@ -2655,14 +2889,15 @@ glfs_discard_async_cbk (call_frame_t *frame, void *cookie, int32_t op_errno, struct iatt *preop_stbuf, struct iatt *postop_stbuf, dict_t *xdata) { - glfs_io_async_cbk (op_ret, op_errno, frame, cookie, NULL, 0); + glfs_io_async_cbk (op_ret, op_errno, frame, cookie, NULL, 0, + preop_stbuf, postop_stbuf); return 0; } -int -pub_glfs_discard_async (struct glfs_fd *glfd, off_t offset, size_t len, - glfs_io_cbk fn, void *data) +static int +glfs_discard_async_common (struct glfs_fd *glfd, off_t offset, size_t len, + gf_boolean_t oldcb, glfs_io_cbk fn, void *data) { struct glfs_io *gio = NULL; int ret = -1; @@ -2706,6 +2941,7 @@ pub_glfs_discard_async (struct glfs_fd *glfd, off_t offset, size_t len, gio->glfd = glfd; gio->offset = offset; gio->count = len; + gio->oldcb = oldcb; gio->fn = fn; gio->data = data; @@ -2733,7 +2969,26 @@ invalid_fs: return ret; } -GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_discard_async, 3.5.0); +int +pub_glfs_discard_async35 (struct glfs_fd *glfd, off_t offset, size_t len, + glfs_io_cbk34 fn, void *data) +{ + return glfs_discard_async_common (glfd, offset, len, _gf_true, + (void *)fn, data); +} + +GFAPI_SYMVER_PUBLIC(glfs_discard_async35, glfs_discard_async, 3.5.0); + + +int +pub_glfs_discard_async (struct glfs_fd *glfd, off_t offset, size_t len, + glfs_io_cbk fn, void *data) +{ + return glfs_discard_async_common (glfd, offset, len, _gf_false, fn, + data); +} + +GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_discard_async, 4.0.0); static int @@ -2742,15 +2997,16 @@ glfs_zerofill_async_cbk (call_frame_t *frame, void *cookie, int32_t op_errno, struct iatt *preop_stbuf, struct iatt *postop_stbuf, dict_t *xdata) { - glfs_io_async_cbk (op_ret, op_errno, frame, cookie, NULL, 0); + glfs_io_async_cbk (op_ret, op_errno, frame, cookie, NULL, 0, + preop_stbuf, postop_stbuf); return 0; } -int -pub_glfs_zerofill_async (struct glfs_fd *glfd, off_t offset, off_t len, - glfs_io_cbk fn, void *data) +static int +glfs_zerofill_async_common (struct glfs_fd *glfd, off_t offset, off_t len, + gf_boolean_t oldcb, glfs_io_cbk fn, void *data) { struct glfs_io *gio = NULL; int ret = -1; @@ -2794,6 +3050,7 @@ pub_glfs_zerofill_async (struct glfs_fd *glfd, off_t offset, off_t len, gio->glfd = glfd; gio->offset = offset; gio->count = len; + gio->oldcb = oldcb; gio->fn = fn; gio->data = data; @@ -2820,7 +3077,26 @@ invalid_fs: return ret; } -GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_zerofill_async, 3.5.0); +int +pub_glfs_zerofill_async35 (struct glfs_fd *glfd, off_t offset, off_t len, + glfs_io_cbk34 fn, void *data) +{ + return glfs_zerofill_async_common (glfd, offset, len, _gf_true, + (void *)fn, data); +} + +GFAPI_SYMVER_PUBLIC(glfs_zerofill_async35, glfs_zerofill_async, 3.5.0); + + +int +pub_glfs_zerofill_async (struct glfs_fd *glfd, off_t offset, off_t len, + glfs_io_cbk fn, void *data) +{ + return glfs_zerofill_async_common (glfd, offset, len, _gf_false, + fn, data); +} + +GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_zerofill_async, 4.0.0); void diff --git a/api/src/glfs.h b/api/src/glfs.h index e2f2a2c1804..c8b261efc83 100644 --- a/api/src/glfs.h +++ b/api/src/glfs.h @@ -499,7 +499,9 @@ int glfs_set_xlator_option (glfs_t *fs, const char *xlator, const char *key, in a common callback function. */ -typedef void (*glfs_io_cbk) (glfs_fd_t *fd, ssize_t ret, void *data); +typedef void (*glfs_io_cbk34) (glfs_fd_t *fd, ssize_t ret, void *data); +typedef void (*glfs_io_cbk) (glfs_fd_t *fd, ssize_t ret, struct stat *prestat, + struct stat *poststat, void *data); // glfs_{read,write}[_async] @@ -511,10 +513,10 @@ ssize_t glfs_write (glfs_fd_t *fd, const void *buf, GFAPI_PUBLIC(glfs_write, 3.4.0); int glfs_read_async (glfs_fd_t *fd, void *buf, size_t count, int flags, glfs_io_cbk fn, void *data) __THROW - GFAPI_PUBLIC(glfs_read_async, 3.4.0); + GFAPI_PUBLIC(glfs_read_async, 4.0.0); int glfs_write_async (glfs_fd_t *fd, const void *buf, size_t count, int flags, glfs_io_cbk fn, void *data) __THROW - GFAPI_PUBLIC(glfs_write_async, 3.4.0); + GFAPI_PUBLIC(glfs_write_async, 4.0.0); // glfs_{read,write}v[_async] @@ -526,10 +528,10 @@ ssize_t glfs_writev (glfs_fd_t *fd, const struct iovec *iov, int iovcnt, GFAPI_PUBLIC(glfs_writev, 3.4.0); int glfs_readv_async (glfs_fd_t *fd, const struct iovec *iov, int count, int flags, glfs_io_cbk fn, void *data) __THROW - GFAPI_PUBLIC(glfs_readv_async, 3.4.0); + GFAPI_PUBLIC(glfs_readv_async, 4.0.0); int glfs_writev_async (glfs_fd_t *fd, const struct iovec *iov, int count, int flags, glfs_io_cbk fn, void *data) __THROW - GFAPI_PUBLIC(glfs_writev_async, 3.4.0); + GFAPI_PUBLIC(glfs_writev_async, 4.0.0); // glfs_p{read,write}[_async] @@ -542,10 +544,10 @@ ssize_t glfs_pwrite (glfs_fd_t *fd, const void *buf, size_t count, GFAPI_PUBLIC(glfs_pwrite, 4.0.0); int glfs_pread_async (glfs_fd_t *fd, void *buf, size_t count, off_t offset, int flags, glfs_io_cbk fn, void *data) __THROW - GFAPI_PUBLIC(glfs_pread_async, 3.4.0); + GFAPI_PUBLIC(glfs_pread_async, 4.0.0); int glfs_pwrite_async (glfs_fd_t *fd, const void *buf, int count, off_t offset, int flags, glfs_io_cbk fn, void *data) __THROW - GFAPI_PUBLIC(glfs_pwrite_async, 3.4.0); + GFAPI_PUBLIC(glfs_pwrite_async, 4.0.0); // glfs_p{read,write}v[_async] @@ -558,11 +560,11 @@ ssize_t glfs_pwritev (glfs_fd_t *fd, const struct iovec *iov, int iovcnt, int glfs_preadv_async (glfs_fd_t *fd, const struct iovec *iov, int count, off_t offset, int flags, glfs_io_cbk fn, void *data) __THROW - GFAPI_PUBLIC(glfs_preadv_async, 3.4.0); + GFAPI_PUBLIC(glfs_preadv_async, 4.0.0); int glfs_pwritev_async (glfs_fd_t *fd, const struct iovec *iov, int count, off_t offset, int flags, glfs_io_cbk fn, void *data) __THROW - GFAPI_PUBLIC(glfs_pwritev_async, 3.4.0); + GFAPI_PUBLIC(glfs_pwritev_async, 4.0.0); off_t glfs_lseek (glfs_fd_t *fd, off_t offset, int whence) __THROW @@ -576,7 +578,7 @@ int glfs_ftruncate (glfs_fd_t *fd, off_t length, struct stat *prestat, GFAPI_PUBLIC(glfs_ftruncate, 4.0.0); int glfs_ftruncate_async (glfs_fd_t *fd, off_t length, glfs_io_cbk fn, void *data) __THROW - GFAPI_PUBLIC(glfs_ftruncate_async, 3.4.0); + GFAPI_PUBLIC(glfs_ftruncate_async, 4.0.0); int glfs_lstat (glfs_t *fs, const char *path, struct stat *buf) __THROW GFAPI_PUBLIC(glfs_lstat, 3.4.0); @@ -589,13 +591,13 @@ int glfs_fsync (glfs_fd_t *fd, struct stat *prestat, struct stat *poststat) __THROW GFAPI_PUBLIC(glfs_fsync, 4.0.0); int glfs_fsync_async (glfs_fd_t *fd, glfs_io_cbk fn, void *data) __THROW - GFAPI_PUBLIC(glfs_fsync_async, 3.4.0); + GFAPI_PUBLIC(glfs_fsync_async, 4.0.0); int glfs_fdatasync (glfs_fd_t *fd, struct stat *prestat, struct stat *poststat) __THROW GFAPI_PUBLIC(glfs_fdatasync, 4.0.0); int glfs_fdatasync_async (glfs_fd_t *fd, glfs_io_cbk fn, void *data) __THROW - GFAPI_PUBLIC(glfs_fdatasync_async, 3.4.0); + GFAPI_PUBLIC(glfs_fdatasync_async, 4.0.0); int glfs_access (glfs_t *fs, const char *path, int mode) __THROW GFAPI_PUBLIC(glfs_access, 3.4.0); @@ -749,14 +751,14 @@ int glfs_discard(glfs_fd_t *fd, off_t offset, size_t len) __THROW int glfs_discard_async (glfs_fd_t *fd, off_t length, size_t lent, glfs_io_cbk fn, void *data) __THROW - GFAPI_PUBLIC(glfs_discard_async, 3.5.0); + GFAPI_PUBLIC(glfs_discard_async, 4.0.0); int glfs_zerofill(glfs_fd_t *fd, off_t offset, off_t len) __THROW GFAPI_PUBLIC(glfs_zerofill, 3.5.0); int glfs_zerofill_async (glfs_fd_t *fd, off_t length, off_t len, - glfs_io_cbk fn, void *data) __THROW - GFAPI_PUBLIC(glfs_zerofill_async, 3.5.0); + glfs_io_cbk fn, void *data) __THROW + GFAPI_PUBLIC(glfs_zerofill_async, 4.0.0); char *glfs_getcwd (glfs_t *fs, char *buf, size_t size) __THROW GFAPI_PUBLIC(glfs_getcwd, 3.4.0); |