diff options
author | Kinglong Mee <kinglongmee@gmail.com> | 2018-02-01 10:13:07 +0800 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-02-12 21:34:46 +0000 |
commit | 248152767b0599986bbb6bb35fc27197f6be6964 (patch) | |
tree | f18550ce89d0786cc21dca474d187d45a49017fb /api | |
parent | 09943beb499617212f2985ca8ea9ecd1ed1b470e (diff) |
gfapi: return pre/post attributes from glfs_ftruncate
Updates: #389
Change-Id: I8faea0828921fb17f05f7321c3cb01747373f21e
Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
Diffstat (limited to 'api')
-rw-r--r-- | api/src/gfapi.aliases | 3 | ||||
-rw-r--r-- | api/src/gfapi.map | 2 | ||||
-rw-r--r-- | api/src/glfs-fops.c | 35 | ||||
-rw-r--r-- | api/src/glfs.h | 5 |
4 files changed, 37 insertions, 8 deletions
diff --git a/api/src/gfapi.aliases b/api/src/gfapi.aliases index 16777fa417c..0445c0ac640 100644 --- a/api/src/gfapi.aliases +++ b/api/src/gfapi.aliases @@ -34,7 +34,7 @@ _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_ftruncate _glfs_ftruncate$GFAPI_3.4.0 +_pub_glfs_ftruncate34 _glfs_ftruncate34$GFAPI_3.4.0 _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 @@ -176,3 +176,4 @@ _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 +_pub_glfs_ftruncate _glfs_ftruncate$GFAPI_4.0.0 diff --git a/api/src/gfapi.map b/api/src/gfapi.map index fec0f4ff807..fbf0985d990 100644 --- a/api/src/gfapi.map +++ b/api/src/gfapi.map @@ -37,7 +37,6 @@ GFAPI_3.4.0 { glfs_preadv_async; glfs_pwritev_async; glfs_lseek; - glfs_ftruncate; glfs_ftruncate_async; glfs_lstat; glfs_stat; @@ -227,4 +226,5 @@ GFAPI_4.0.0 { glfs_pwrite; glfs_fsync; glfs_fdatasync; + glfs_ftruncate; } GFAPI_3.13.0; diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c index a63c175d052..1cd7669438f 100644 --- a/api/src/glfs-fops.c +++ b/api/src/glfs-fops.c @@ -1678,12 +1678,14 @@ invalid_fs: GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_fdatasync_async, 3.4.0); -int -pub_glfs_ftruncate (struct glfs_fd *glfd, off_t offset) +static int +glfs_ftruncate_common (struct glfs_fd *glfd, off_t offset, + 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); @@ -1704,8 +1706,16 @@ pub_glfs_ftruncate (struct glfs_fd *glfd, off_t offset) goto out; } - ret = syncop_ftruncate (subvol, fd, offset, NULL, NULL); + ret = syncop_ftruncate (subvol, fd, offset, &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); @@ -1720,7 +1730,24 @@ invalid_fs: return ret; } -GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_ftruncate, 3.4.0); +int +pub_glfs_ftruncate34 (struct glfs_fd *glfd, off_t offset) +{ + return glfs_ftruncate_common (glfd, offset, NULL, NULL); +} + +GFAPI_SYMVER_PUBLIC(glfs_ftruncate34, glfs_ftruncate, 3.4.0); + + +int +pub_glfs_ftruncate (struct glfs_fd *glfd, off_t offset, struct stat *prestat, + struct stat *poststat) +{ + return glfs_ftruncate_common (glfd, offset, prestat, poststat); +} + +GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_ftruncate, 4.0.0); + int pub_glfs_truncate (struct glfs *fs, const char *path, off_t length) diff --git a/api/src/glfs.h b/api/src/glfs.h index 2addacb7ecf..e2f2a2c1804 100644 --- a/api/src/glfs.h +++ b/api/src/glfs.h @@ -571,8 +571,9 @@ off_t glfs_lseek (glfs_fd_t *fd, off_t offset, int whence) __THROW int glfs_truncate (glfs_t *fs, const char *path, off_t length) __THROW GFAPI_PUBLIC(glfs_truncate, 3.7.15); -int glfs_ftruncate (glfs_fd_t *fd, off_t length) __THROW - GFAPI_PUBLIC(glfs_ftruncate, 3.4.0); +int glfs_ftruncate (glfs_fd_t *fd, off_t length, struct stat *prestat, + struct stat *poststat) __THROW + 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); |