summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorKinglong Mee <mijinlong@open-fs.com>2018-01-18 15:51:18 +0800
committerAmar Tumballi <amarts@redhat.com>2018-02-12 21:34:46 +0000
commit09943beb499617212f2985ca8ea9ecd1ed1b470e (patch)
tree49e9f10bfbb66f4ea52f0a9ed3392d9fb69c072b /api
parentd01f7244e9d9f7e3ef84e0ba7b48ef1b1b09d809 (diff)
gfapi: return pre/post attributes from glfs_fsync/fdatasync
Updates: #389 Change-Id: I4153df72d5eeecefa7579170899db4c340128bea Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
Diffstat (limited to 'api')
-rw-r--r--api/src/gfapi.aliases6
-rw-r--r--api/src/gfapi.map4
-rw-r--r--api/src/glfs-fops.c67
-rw-r--r--api/src/glfs-resolve.c2
-rw-r--r--api/src/glfs.h10
5 files changed, 72 insertions, 17 deletions
diff --git a/api/src/gfapi.aliases b/api/src/gfapi.aliases
index d8c5162e684..16777fa417c 100644
--- a/api/src/gfapi.aliases
+++ b/api/src/gfapi.aliases
@@ -39,9 +39,9 @@ _pub_glfs_ftruncate_async _glfs_ftruncate_async$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_fsync _glfs_fsync$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_fdatasync _glfs_fdatasync$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_access _glfs_access$GFAPI_3.4.0
_pub_glfs_symlink _glfs_symlink$GFAPI_3.4.0
@@ -174,3 +174,5 @@ _pub_glfs_lease _glfs_lease$GFAPI_4.0.0
_pub_glfs_h_lease _glfs_h_lease$GFAPI_4.0.0
_pub_glfs_pread _glfs_pread$GFAPI_4.0.0
_pub_glfs_pwrite _glfs_pwrite$GFAPI_4.0.0
+_pub_glfs_fsync _glfs_fsync$GFAPI_4.0.0
+_pub_glfs_fdatasync _glfs_fdatasync$GFAPI_4.0.0
diff --git a/api/src/gfapi.map b/api/src/gfapi.map
index c122023e7f5..fec0f4ff807 100644
--- a/api/src/gfapi.map
+++ b/api/src/gfapi.map
@@ -42,9 +42,7 @@ GFAPI_3.4.0 {
glfs_lstat;
glfs_stat;
glfs_fstat;
- glfs_fsync;
glfs_fsync_async;
- glfs_fdatasync;
glfs_fdatasync_async;
glfs_access;
glfs_symlink;
@@ -227,4 +225,6 @@ GFAPI_4.0.0 {
glfs_h_lease;
glfs_pread;
glfs_pwrite;
+ glfs_fsync;
+ glfs_fdatasync;
} GFAPI_3.13.0;
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index 98ffa5ea68d..a63c175d052 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -1420,12 +1420,14 @@ pub_glfs_writev_async (struct glfs_fd *glfd, const struct iovec *iov, int count,
GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_writev_async, 3.4.0);
-int
-pub_glfs_fsync (struct glfs_fd *glfd)
+static int
+glfs_fsync_common (struct glfs_fd *glfd, struct stat *prestat,
+ struct stat *poststat)
{
int ret = -1;
xlator_t *subvol = NULL;
fd_t *fd = NULL;
+ struct iatt preiatt = {0, }, postiatt = {0, };
DECLARE_OLD_THIS;
__GLFS_ENTRY_VALIDATE_FD (glfd, invalid_fs);
@@ -1446,8 +1448,15 @@ pub_glfs_fsync (struct glfs_fd *glfd)
goto out;
}
- ret = syncop_fsync (subvol, fd, 0, NULL, NULL);
+ ret = syncop_fsync (subvol, fd, 0, &preiatt, &postiatt, NULL, NULL);
DECODE_SYNCOP_ERR (ret);
+
+ if (ret >= 0) {
+ if (prestat)
+ glfs_iatt_to_stat (glfd->fs, &preiatt, prestat);
+ if (poststat)
+ glfs_iatt_to_stat (glfd->fs, &postiatt, poststat);
+ }
out:
if (fd)
fd_unref (fd);
@@ -1462,7 +1471,24 @@ invalid_fs:
return ret;
}
-GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_fsync, 3.4.0);
+int
+pub_glfs_fsync34 (struct glfs_fd *glfd)
+{
+ return glfs_fsync_common (glfd, NULL, NULL);
+}
+
+GFAPI_SYMVER_PUBLIC(glfs_fsync34, glfs_fsync, 3.4.0);
+
+
+int
+pub_glfs_fsync (struct glfs_fd *glfd, struct stat *prestat,
+ struct stat *poststat)
+{
+ return glfs_fsync_common (glfd, prestat, poststat);
+}
+
+GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_fsync, 4.0.0);
+
static int
glfs_fsync_async_cbk (call_frame_t *frame, void *cookie,
@@ -1563,12 +1589,14 @@ invalid_fs:
GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_fsync_async, 3.4.0);
-int
-pub_glfs_fdatasync (struct glfs_fd *glfd)
+static int
+glfs_fdatasync_common (struct glfs_fd *glfd, struct stat *prestat,
+ struct stat *poststat)
{
int ret = -1;
xlator_t *subvol = NULL;
fd_t *fd = NULL;
+ struct iatt preiatt = {0, }, postiatt = {0, };
DECLARE_OLD_THIS;
__GLFS_ENTRY_VALIDATE_FD (glfd, invalid_fs);
@@ -1589,8 +1617,15 @@ pub_glfs_fdatasync (struct glfs_fd *glfd)
goto out;
}
- ret = syncop_fsync (subvol, fd, 1, NULL, NULL);
+ ret = syncop_fsync (subvol, fd, 1, &preiatt, &postiatt, NULL, NULL);
DECODE_SYNCOP_ERR (ret);
+
+ if (ret >= 0) {
+ if (prestat)
+ glfs_iatt_to_stat (glfd->fs, &preiatt, prestat);
+ if (poststat)
+ glfs_iatt_to_stat (glfd->fs, &postiatt, poststat);
+ }
out:
if (fd)
fd_unref (fd);
@@ -1605,7 +1640,23 @@ invalid_fs:
return ret;
}
-GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_fdatasync, 3.4.0);
+int
+pub_glfs_fdatasync34 (struct glfs_fd *glfd)
+{
+ return glfs_fdatasync_common (glfd, NULL, NULL);
+}
+
+GFAPI_SYMVER_PUBLIC(glfs_fdatasync34, glfs_fdatasync, 3.4.0);
+
+
+int
+pub_glfs_fdatasync (struct glfs_fd *glfd, struct stat *prestat,
+ struct stat *poststat)
+{
+ return glfs_fdatasync_common (glfd, prestat, poststat);
+}
+
+GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_fdatasync, 4.0.0);
int
diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c
index 6c9fc38901f..03be7c7eda7 100644
--- a/api/src/glfs-resolve.c
+++ b/api/src/glfs-resolve.c
@@ -730,7 +730,7 @@ glfs_migrate_fd_safe (struct glfs *fs, xlator_t *newsubvol, fd_t *oldfd)
return fd_ref (oldfd);
if (!oldsubvol->switched) {
- ret = syncop_fsync (oldsubvol, oldfd, 0, NULL, NULL);
+ ret = syncop_fsync (oldsubvol, oldfd, 0, NULL, NULL, NULL, NULL);
DECODE_SYNCOP_ERR (ret);
if (ret) {
gf_msg (fs->volname, GF_LOG_WARNING, errno,
diff --git a/api/src/glfs.h b/api/src/glfs.h
index 39caf3efc3f..2addacb7ecf 100644
--- a/api/src/glfs.h
+++ b/api/src/glfs.h
@@ -584,13 +584,15 @@ int glfs_stat (glfs_t *fs, const char *path, struct stat *buf) __THROW
int glfs_fstat (glfs_fd_t *fd, struct stat *buf) __THROW
GFAPI_PUBLIC(glfs_fstat, 3.4.0);
-int glfs_fsync (glfs_fd_t *fd) __THROW
- GFAPI_PUBLIC(glfs_fsync, 3.4.0);
+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);
-int glfs_fdatasync (glfs_fd_t *fd) __THROW
- GFAPI_PUBLIC(glfs_fdatasync, 3.4.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);