diff options
Diffstat (limited to 'api/src/glfs-resolve.c')
| -rw-r--r-- | api/src/glfs-resolve.c | 98 |
1 files changed, 94 insertions, 4 deletions
diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c index 4a634df6e..4ca2eb6fc 100644 --- a/api/src/glfs-resolve.c +++ b/api/src/glfs-resolve.c @@ -67,6 +67,7 @@ __glfs_first_lookup (struct glfs *fs, xlator_t *subvol) } pthread_mutex_lock (&fs->mutex); fs->migration_in_progress = 0; + pthread_cond_broadcast (&fs->cond); return ret; } @@ -128,6 +129,7 @@ __glfs_refresh_inode (struct glfs *fs, xlator_t *subvol, inode_t *inode) } pthread_mutex_lock (&fs->mutex); fs->migration_in_progress = 0; + pthread_cond_broadcast (&fs->cond); return newinode; } @@ -191,7 +193,7 @@ out: } -void +int glfs_resolve_base (struct glfs *fs, xlator_t *subvol, inode_t *inode, struct iatt *iatt) { @@ -210,6 +212,8 @@ glfs_resolve_base (struct glfs *fs, xlator_t *subvol, inode_t *inode, ret = syncop_lookup (subvol, &loc, NULL, iatt, NULL, NULL); out: loc_wipe (&loc); + + return ret; } @@ -337,7 +341,8 @@ glfs_resolve_at (struct glfs *fs, xlator_t *subvol, inode_t *at, } else { inode = inode_ref (subvol->itable->root); - glfs_resolve_base (fs, subvol, inode, &ciatt); + if (strcmp (path, "/") == 0) + glfs_resolve_base (fs, subvol, inode, &ciatt); } for (component = strtok_r (path, "/", &saveptr); @@ -356,7 +361,8 @@ glfs_resolve_at (struct glfs *fs, xlator_t *subvol, inode_t *at, component, as the caller wants proper iatt filled */ - (reval || !next_component)); + (reval || (!next_component && + iatt))); if (!inode) break; @@ -368,6 +374,16 @@ glfs_resolve_at (struct glfs *fs, xlator_t *subvol, inode_t *at, char *lpath = NULL; loc_t sym_loc = {0,}; + if (follow > GLFS_SYMLINK_MAX_FOLLOW) { + errno = ELOOP; + ret = -1; + if (inode) { + inode_unref (inode); + inode = NULL; + } + break; + } + ret = glfs_resolve_symlink (fs, subvol, inode, &lpath); inode_unref (inode); inode = NULL; @@ -383,7 +399,7 @@ glfs_resolve_at (struct glfs *fs, xlator_t *subvol, inode_t *at, /* always recurisvely follow while following symlink */ - 1, reval); + follow + 1, reval); if (ret == 0) inode = inode_ref (sym_loc.inode); loc_wipe (&sym_loc); @@ -583,6 +599,15 @@ glfs_migrate_fd_safe (struct glfs *fs, xlator_t *newsubvol, fd_t *oldfd) loc.inode = inode_ref (newinode); + ret = inode_path (oldfd->inode, NULL, (char **)&loc.path); + if (ret < 0) { + gf_log (fs->volname, GF_LOG_INFO, "inode_path failed"); + goto out; + } + + uuid_copy (loc.gfid, oldinode->gfid); + + if (IA_ISDIR (oldinode->ia_type)) ret = syncop_opendir (newsubvol, &loc, newfd); else @@ -613,6 +638,7 @@ glfs_migrate_fd_safe (struct glfs *fs, xlator_t *newsubvol, fd_t *oldfd) goto out; } + newfd->flags = oldfd->flags; fd_bind (newfd); out: if (newinode) @@ -642,6 +668,7 @@ __glfs_migrate_fd (struct glfs *fs, xlator_t *newsubvol, struct glfs_fd *glfd) } pthread_mutex_lock (&fs->mutex); fs->migration_in_progress = 0; + pthread_cond_broadcast (&fs->cond); return newfd; } @@ -797,6 +824,9 @@ glfs_subvol_done (struct glfs *fs, xlator_t *subvol) int ref = 0; xlator_t *active_subvol = NULL; + if (!subvol) + return; + glfs_lock (fs); { ref = (--subvol->winds); @@ -877,3 +907,63 @@ glfs_cwd_get (struct glfs *fs) return cwd; } + +inode_t * +__glfs_resolve_inode (struct glfs *fs, xlator_t *subvol, + struct glfs_object *object) +{ + inode_t *inode = NULL; + + if (object->inode->table->xl == subvol) + return inode_ref (object->inode); + + inode = __glfs_refresh_inode (fs, fs->active_subvol, + object->inode); + if (!inode) + return NULL; + + if (subvol == fs->active_subvol) { + inode_unref (object->inode); + object->inode = inode_ref (inode); + } + + return inode; +} + +inode_t * +glfs_resolve_inode (struct glfs *fs, xlator_t *subvol, + struct glfs_object *object) +{ + inode_t *inode = NULL; + + glfs_lock (fs); + { + inode = __glfs_resolve_inode(fs, subvol, object); + } + glfs_unlock (fs); + + return inode; +} + +int +glfs_create_object (loc_t *loc, struct glfs_object **retobject) +{ + struct glfs_object *object = NULL; + + object = GF_CALLOC (1, sizeof(struct glfs_object), + glfs_mt_glfs_object_t); + if (object == NULL) { + errno = ENOMEM; + return -1; + } + + object->inode = loc->inode; + uuid_copy (object->gfid, object->inode->gfid); + + /* we hold the reference */ + loc->inode = NULL; + + *retobject = object; + + return 0; +} |
