diff options
Diffstat (limited to 'xlators/performance/symlink-cache/src/symlink-cache.c')
| -rw-r--r-- | xlators/performance/symlink-cache/src/symlink-cache.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/xlators/performance/symlink-cache/src/symlink-cache.c b/xlators/performance/symlink-cache/src/symlink-cache.c index ad0836c5e..3b5fbc252 100644 --- a/xlators/performance/symlink-cache/src/symlink-cache.c +++ b/xlators/performance/symlink-cache/src/symlink-cache.c @@ -1,20 +1,11 @@ /* - Copyright (c) 2008-2009 Z RESEARCH, Inc. <http://www.zresearch.com> + Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> This file is part of GlusterFS. - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - GlusterFS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see - <http://www.gnu.org/licenses/>. + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. */ @@ -90,7 +81,7 @@ sc_cache_update (xlator_t *this, inode_t *inode, const char *link) int -sc_cache_set (xlator_t *this, inode_t *inode, struct stat *buf, +sc_cache_set (xlator_t *this, inode_t *inode, struct iatt *buf, const char *link) { struct symlink_cache *sc = NULL; @@ -126,7 +117,7 @@ sc_cache_set (xlator_t *this, inode_t *inode, struct stat *buf, } } - sc->ctime = buf->st_ctime; + sc->ctime = buf->ia_ctime; gf_log (this->name, GF_LOG_DEBUG, "setting symlink cache: %s", link); @@ -146,8 +137,7 @@ sc_cache_set (xlator_t *this, inode_t *inode, struct stat *buf, err: if (sc) { - if (sc->readlink) - FREE (sc->readlink); + FREE (sc->readlink); sc->readlink = NULL; FREE (sc); } @@ -180,12 +170,12 @@ sc_cache_flush (xlator_t *this, inode_t *inode) int -sc_cache_validate (xlator_t *this, inode_t *inode, struct stat *buf) +sc_cache_validate (xlator_t *this, inode_t *inode, struct iatt *buf) { struct symlink_cache *sc = NULL; uint64_t tmp_sc = 0; - if (!S_ISLNK (buf->st_mode)) { + if (!IA_ISLNK (buf->ia_type)) { sc_cache_flush (this, inode); return 0; } @@ -204,7 +194,7 @@ sc_cache_validate (xlator_t *this, inode_t *inode, struct stat *buf) sc = (struct symlink_cache *)(long)tmp_sc; } - if (sc->ctime == buf->st_ctime) + if (sc->ctime == buf->ia_ctime) return 0; /* STALE */ @@ -216,7 +206,7 @@ sc_cache_validate (xlator_t *this, inode_t *inode, struct stat *buf) sc->readlink = NULL; } - sc->ctime = buf->st_ctime; + sc->ctime = buf->ia_ctime; return 0; } @@ -242,7 +232,7 @@ sc_cache_get (xlator_t *this, inode_t *inode, char **link) int sc_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, - const char *link) + const char *link, struct iatt *sbuf, dict_t *xdata) { if (op_ret > 0) sc_cache_update (this, frame->local, link); @@ -250,16 +240,18 @@ sc_readlink_cbk (call_frame_t *frame, void *cookie, inode_unref (frame->local); frame->local = NULL; - STACK_UNWIND (frame, op_ret, op_errno, link); + STACK_UNWIND_STRICT (readlink, frame, op_ret, op_errno, link, sbuf, + xdata); return 0; } int sc_readlink (call_frame_t *frame, xlator_t *this, - loc_t *loc, size_t size) + loc_t *loc, size_t size, dict_t *xdata) { char *link = NULL; + struct iatt buf = {0, }; sc_cache_get (this, loc->inode, &link); @@ -268,7 +260,14 @@ sc_readlink (call_frame_t *frame, xlator_t *this, gf_log (this->name, GF_LOG_DEBUG, "cache hit %s -> %s", loc->path, link); - STACK_UNWIND (frame, strlen (link), 0, link); + + /* + libglusterfsclient, nfs or any other translators + using buf in readlink_cbk should be aware that @buf + is 0 filled + */ + STACK_UNWIND_STRICT (readlink, frame, strlen (link), 0, link, + &buf, NULL); FREE (link); return 0; } @@ -278,7 +277,7 @@ sc_readlink (call_frame_t *frame, xlator_t *this, STACK_WIND (frame, sc_readlink_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->readlink, - loc, size); + loc, size, xdata); return 0; } @@ -287,7 +286,8 @@ sc_readlink (call_frame_t *frame, xlator_t *this, int sc_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, - inode_t *inode, struct stat *buf) + inode_t *inode, struct iatt *buf, struct iatt *preparent, + struct iatt *postparent, dict_t *xdata) { if (op_ret == 0) { if (frame->local) { @@ -295,21 +295,22 @@ sc_symlink_cbk (call_frame_t *frame, void *cookie, } } - STACK_UNWIND (frame, op_ret, op_errno, inode, buf); + STACK_UNWIND_STRICT (symlink, frame, op_ret, op_errno, inode, buf, + preparent, postparent, xdata); return 0; } int sc_symlink (call_frame_t *frame, xlator_t *this, - const char *dst, loc_t *src) + const char *dst, loc_t *src, mode_t umask, dict_t *xdata) { frame->local = strdup (dst); STACK_WIND (frame, sc_symlink_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->symlink, - dst, src); + dst, src, umask, xdata); return 0; } @@ -318,26 +319,28 @@ sc_symlink (call_frame_t *frame, xlator_t *this, int sc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, - inode_t *inode, struct stat *buf, dict_t *xattr) + inode_t *inode, struct iatt *buf, dict_t *xdata, + struct iatt *postparent) { if (op_ret == 0) sc_cache_validate (this, inode, buf); else sc_cache_flush (this, inode); - STACK_UNWIND (frame, op_ret, op_errno, inode, buf, xattr); + STACK_UNWIND_STRICT (lookup, frame, op_ret, op_errno, inode, buf, + xdata, postparent); return 0; } int sc_lookup (call_frame_t *frame, xlator_t *this, - loc_t *loc, dict_t *xattr_req) + loc_t *loc, dict_t *xdata) { STACK_WIND (frame, sc_lookup_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->lookup, - loc, xattr_req); + loc, xdata); return 0; } @@ -353,10 +356,9 @@ sc_forget (xlator_t *this, } -int32_t +int32_t init (xlator_t *this) { - if (!this->children || this->children->next) { gf_log (this->name, GF_LOG_ERROR, @@ -387,8 +389,6 @@ struct xlator_fops fops = { .readlink = sc_readlink, }; -struct xlator_mops mops = { -}; struct xlator_cbks cbks = { .forget = sc_forget, |
