From 4634bb05cc82526e5c55e60746ae5d167f28bea0 Mon Sep 17 00:00:00 2001 From: Kinglong Mee Date: Sat, 29 Sep 2018 11:02:58 +0800 Subject: md-cache: request cached xattrs at stat/fstat Ganesha always operate file by filehandle, and translates to glusterfs's stat/fstat many time. Change-Id: Idd0dc33c31131331ac948754c8b7f898777c31d3 Updates: bz#1634220 Signed-off-by: Kinglong Mee --- xlators/performance/md-cache/src/md-cache.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'xlators/performance') diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c index fc9d601015b..bbe47fc545b 100644 --- a/xlators/performance/md-cache/src/md-cache.c +++ b/xlators/performance/md-cache/src/md-cache.c @@ -1310,6 +1310,7 @@ mdc_stat_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, } mdc_inode_iatt_set(this, local->loc.inode, buf, local->incident_time); + mdc_inode_xatt_set(this, local->loc.inode, xdata); out: MDC_STACK_UNWIND(stat, frame, op_ret, op_errno, buf, xdata); @@ -1323,6 +1324,7 @@ mdc_stat(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) int ret; struct iatt stbuf; mdc_local_t *local = NULL; + dict_t *xattr_alloc = NULL; struct mdc_conf *conf = this->private; local = mdc_local_get(frame, loc->inode); @@ -1346,9 +1348,17 @@ mdc_stat(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) return 0; uncached: + if (!xdata) + xdata = xattr_alloc = dict_new(); + if (xdata) + mdc_load_reqs(this, xdata); + GF_ATOMIC_INC(conf->mdc_counter.stat_miss); STACK_WIND(frame, mdc_stat_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->stat, loc, xdata); + + if (xattr_alloc) + dict_unref(xattr_alloc); return 0; } @@ -1371,6 +1381,7 @@ mdc_fstat_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, } mdc_inode_iatt_set(this, local->fd->inode, buf, local->incident_time); + mdc_inode_xatt_set(this, local->fd->inode, xdata); out: MDC_STACK_UNWIND(fstat, frame, op_ret, op_errno, buf, xdata); @@ -1384,6 +1395,7 @@ mdc_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) int ret; struct iatt stbuf; mdc_local_t *local = NULL; + dict_t *xattr_alloc = NULL; struct mdc_conf *conf = this->private; local = mdc_local_get(frame, fd->inode); @@ -1402,9 +1414,17 @@ mdc_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) return 0; uncached: + if (!xdata) + xdata = xattr_alloc = dict_new(); + if (xdata) + mdc_load_reqs(this, xdata); + GF_ATOMIC_INC(conf->mdc_counter.stat_miss); STACK_WIND(frame, mdc_fstat_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->fstat, fd, xdata); + + if (xattr_alloc) + dict_unref(xattr_alloc); return 0; } -- cgit