diff options
Diffstat (limited to 'xlators/nfs/server/src/nfs-common.c')
| -rw-r--r-- | xlators/nfs/server/src/nfs-common.c | 69 |
1 files changed, 49 insertions, 20 deletions
diff --git a/xlators/nfs/server/src/nfs-common.c b/xlators/nfs/server/src/nfs-common.c index ec76c294f..f74396ee8 100644 --- a/xlators/nfs/server/src/nfs-common.c +++ b/xlators/nfs/server/src/nfs-common.c @@ -2,19 +2,10 @@ Copyright (c) 2010-2011 Gluster, Inc. <http://www.gluster.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. */ #ifndef _CONFIG_H @@ -88,13 +79,13 @@ nfs_mntpath_to_xlator (xlator_list_t *cl, char *path) { char volname[MNTPATHLEN]; char *volptr = NULL; - int pathlen = 0; + size_t pathlen; xlator_t *targetxl = NULL; if ((!cl) || (!path)) return NULL; - strcpy (volname, path); + strncpy (volname, path, MNTPATHLEN); pathlen = strlen (volname); gf_log (GF_NFS, GF_LOG_TRACE, "Subvolume search: %s", path); if (volname[0] == '/') @@ -102,7 +93,7 @@ nfs_mntpath_to_xlator (xlator_list_t *cl, char *path) else volptr = &volname[0]; - if (volname[pathlen - 1] == '/') + if (pathlen && volname[pathlen - 1] == '/') volname[pathlen - 1] = '\0'; while (cl) { @@ -221,6 +212,8 @@ nfs_inode_loc_fill (inode_t *inode, loc_t *loc, int how) snprintf (tmp_path, sizeof (tmp_path), "<gfid:%s>", uuid_utoa (loc->gfid)); resolvedpath = gf_strdup (tmp_path); + } else { + parent = inode_parent (inode, loc->pargfid, NULL); } ret = nfs_loc_fill (loc, inode, parent, resolvedpath); @@ -235,8 +228,7 @@ err: if (parent) inode_unref (parent); - if (resolvedpath) - GF_FREE (resolvedpath); + GF_FREE (resolvedpath); return ret; } @@ -397,8 +389,7 @@ err: if (entryinode) inode_unref (entryinode); - if (resolvedpath) - GF_FREE (resolvedpath); + GF_FREE (resolvedpath); return ret; } @@ -417,6 +408,9 @@ nfs_hash_gfid (uuid_t gfid) uint32_t b1 = 0; uint32_t b2 = 0; + if (__is_root_gfid (gfid)) + return 0x1; + memcpy (&msb64, &gfid[8], 8); memcpy (&lsb64, &gfid[0], 8); @@ -434,3 +428,38 @@ nfs_hash_gfid (uuid_t gfid) } +void +nfs_fix_generation (xlator_t *this, inode_t *inode) +{ + uint64_t raw_ctx = 0; + struct nfs_inode_ctx *ictx = NULL; + struct nfs_state *priv = NULL; + int ret = -1; + + if (!inode) { + return; + } + priv = this->private; + + if (inode_ctx_get(inode,this,&raw_ctx) == 0) { + ictx = (struct nfs_inode_ctx *)raw_ctx; + ictx->generation = priv->generation; + } + else { + ictx = GF_CALLOC (1, sizeof (struct nfs_inode_ctx), + gf_nfs_mt_inode_ctx); + if (!ictx) { + gf_log (this->name, GF_LOG_ERROR, + "could not allocate nfs inode ctx"); + return; + } + INIT_LIST_HEAD(&ictx->shares); + ictx->generation = priv->generation; + ret = inode_ctx_put (inode, this, (uint64_t)ictx); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "could not store nfs inode ctx"); + return; + } + } +} |
