From 248152767b0599986bbb6bb35fc27197f6be6964 Mon Sep 17 00:00:00 2001 From: Kinglong Mee Date: Thu, 1 Feb 2018 10:13:07 +0800 Subject: gfapi: return pre/post attributes from glfs_ftruncate Updates: #389 Change-Id: I8faea0828921fb17f05f7321c3cb01747373f21e Signed-off-by: Kinglong Mee --- libglusterfs/src/generator.py | 2 ++ libglusterfs/src/syncop.c | 15 +++++++++++++-- libglusterfs/src/syncop.h | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/generator.py b/libglusterfs/src/generator.py index e565438bfeb..c9311ea3856 100755 --- a/libglusterfs/src/generator.py +++ b/libglusterfs/src/generator.py @@ -303,6 +303,8 @@ ops['access'] = ( ops['ftruncate'] = ( ('fop-arg', 'fd', 'fd_t *', 'fd'), ('fop-arg', 'offset', 'off_t', 'offset'), + ('extra', 'preop', 'struct iatt', '&preop'), + ('extra', 'postop', 'struct iatt', '&postop'), ('fop-arg', 'xdata', 'dict_t *', 'xdata'), ('cbk-arg', 'prebuf', 'struct iatt *'), ('cbk-arg', 'postbuf', 'struct iatt *'), diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c index 76e1a5e9116..202b3aba4ab 100644 --- a/libglusterfs/src/syncop.c +++ b/libglusterfs/src/syncop.c @@ -2326,20 +2326,31 @@ syncop_ftruncate_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; } int -syncop_ftruncate (xlator_t *subvol, fd_t *fd, off_t offset, dict_t *xdata_in, - dict_t **xdata_out) +syncop_ftruncate (xlator_t *subvol, fd_t *fd, off_t offset, + struct iatt *preiatt, struct iatt *postiatt, + dict_t *xdata_in, dict_t **xdata_out) { struct syncargs args = {0, }; SYNCOP (subvol, (&args), syncop_ftruncate_cbk, subvol->fops->ftruncate, fd, offset, 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 b0052b368b7..7d3afa823e3 100644 --- a/libglusterfs/src/syncop.h +++ b/libglusterfs/src/syncop.h @@ -470,6 +470,7 @@ int syncop_readv (xlator_t *subvol, fd_t *fd, size_t size, off_t off, struct iatt *iatt, dict_t *xdata_in, dict_t **xdata_out); int syncop_ftruncate (xlator_t *subvol, fd_t *fd, off_t offset, + struct iatt *preiatt, struct iatt *postiatt, dict_t *xdata_in, dict_t **xdata_out); int syncop_truncate (xlator_t *subvol, loc_t *loc, off_t offset, -- cgit