From 09943beb499617212f2985ca8ea9ecd1ed1b470e Mon Sep 17 00:00:00 2001 From: Kinglong Mee Date: Thu, 18 Jan 2018 15:51:18 +0800 Subject: gfapi: return pre/post attributes from glfs_fsync/fdatasync Updates: #389 Change-Id: I4153df72d5eeecefa7579170899db4c340128bea Signed-off-by: Kinglong Mee --- libglusterfs/src/generator.py | 2 ++ libglusterfs/src/syncop.c | 14 ++++++++++++-- libglusterfs/src/syncop.h | 5 +++-- 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'libglusterfs/src') diff --git a/libglusterfs/src/generator.py b/libglusterfs/src/generator.py index 5b5d54e3567..e565438bfeb 100755 --- a/libglusterfs/src/generator.py +++ b/libglusterfs/src/generator.py @@ -123,6 +123,8 @@ ops['fstat'] = ( ops['fsync'] = ( ('fop-arg', 'fd', 'fd_t *'), ('fop-arg', 'flags', 'int32_t'), + ('extra', 'preop', 'struct iatt', '&preop'), + ('extra', 'postop', 'struct iatt', '&postop'), ('fop-arg', 'xdata', 'dict_t *'), ('cbk-arg', 'prebuf', 'struct iatt *'), ('cbk-arg', 'postbuf', 'struct iatt *'), diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c index 01036f59f8a..76e1a5e9116 100644 --- a/libglusterfs/src/syncop.c +++ b/libglusterfs/src/syncop.c @@ -2383,6 +2383,11 @@ syncop_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (xdata) args->xdata = dict_ref (xdata); + if (op_ret >= 0) { + args->iatt1 = *prebuf; + args->iatt2 = *postbuf; + } + __wake (args); return 0; @@ -2390,14 +2395,19 @@ syncop_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } int -syncop_fsync (xlator_t *subvol, fd_t *fd, int dataonly, dict_t *xdata_in, - dict_t **xdata_out) +syncop_fsync (xlator_t *subvol, fd_t *fd, int dataonly, struct iatt *preiatt, + struct iatt *postiatt, dict_t *xdata_in, dict_t **xdata_out) { struct syncargs args = {0, }; SYNCOP (subvol, (&args), syncop_fsync_cbk, subvol->fops->fsync, fd, dataonly, xdata_in); + if (preiatt) + *preiatt = args.iatt1; + if (postiatt) + *postiatt = args.iatt2; + if (xdata_out) *xdata_out = args.xdata; else if (args.xdata) diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h index c7d58402df0..b0052b368b7 100644 --- a/libglusterfs/src/syncop.h +++ b/libglusterfs/src/syncop.h @@ -481,8 +481,9 @@ int syncop_unlink (xlator_t *subvol, loc_t *loc, dict_t *xdata_in, int syncop_rmdir (xlator_t *subvol, loc_t *loc, int flags, dict_t *xdata_in, dict_t **xdata_out); -int syncop_fsync (xlator_t *subvol, fd_t *fd, int dataonly, dict_t *xdata_in, - dict_t **xdata_out); +int syncop_fsync (xlator_t *subvol, fd_t *fd, int dataonly, + struct iatt *preiatt, struct iatt *postiatt, + dict_t *xdata_in, dict_t **xdata_out); int syncop_flush (xlator_t *subvol, fd_t *fd, dict_t *xdata_in, dict_t **xdata_out); -- cgit