Beispiel #1
0
static int
sdfs_build_parent_loc (loc_t *parent, loc_t *child)
{
        int     ret     = -1;
        char    *path   = NULL;

        if (!child->parent) {
                goto out;
        }
        parent->inode = inode_ref (child->parent);
        path = gf_strdup (child->path);
        if (!path) {
                ret = -ENOMEM;
                goto out;
        }

        parent->path = dirname(path);
        if (!parent->path) {
                goto out;
        }

        gf_uuid_copy (parent->gfid, child->pargfid);
        return 0;

out:
        GF_FREE (path);
        return ret;
}
Beispiel #2
0
int
afr_build_parent_loc (loc_t *parent, loc_t *child, int32_t *op_errno)
{
        int     ret = -1;
        char    *child_path = NULL;

        if (!child->parent) {
                if (op_errno)
                        *op_errno = EINVAL;
                goto out;
        }

        child_path = gf_strdup (child->path);
        if (!child_path) {
                if (op_errno)
                        *op_errno = ENOMEM;
                goto out;
        }

        parent->path = gf_strdup (dirname (child_path));
        if (!parent->path) {
                if (op_errno)
                        *op_errno = ENOMEM;
                goto out;
        }

        parent->inode = inode_ref (child->parent);
	gf_uuid_copy (parent->gfid, child->pargfid);

        ret = 0;
out:
        GF_FREE (child_path);

        return ret;
}
Beispiel #3
0
int
nfs_loc_fill (loc_t *loc, inode_t *inode, inode_t *parent, char *path)
{
        int     ret = -EFAULT;

        if (!loc)
                return ret;

        if (inode) {
                loc->inode = inode_ref (inode);
                if (!gf_uuid_is_null (inode->gfid))
                        gf_uuid_copy (loc->gfid, inode->gfid);
        }

        if (parent)
                loc->parent = inode_ref (parent);

        if (path) {
                loc->path = gf_strdup (path);
                if (!loc->path) {
                        gf_msg (GF_NFS, GF_LOG_ERROR, ENOMEM,
                                NFS_MSG_NO_MEMORY, "strdup failed");
                        goto loc_wipe;
                }
                loc->name = strrchr (loc->path, '/');
                if (loc->name)
                        loc->name++;
        }

        ret = 0;
loc_wipe:
        if (ret < 0)
                nfs_loc_wipe (loc);

        return ret;
}
Beispiel #4
0
void
nfl_inodes_init (struct nfs_fop_local *nfl, inode_t *inode, inode_t *parent,
                 inode_t *newparent, const char *name, const char *newname)
{
        if (!nfl)
                return;

        if (inode)
                nfl->inode = inode_ref (inode);

        if (parent)
                nfl->parent = inode_ref (parent);

        if (newparent)
                nfl->newparent = inode_ref (newparent);

        if (name)
                strcpy (nfl->path, name);

        if (newname)
                strcpy (nfl->newpath, newname);

        return;
}
Beispiel #5
0
static file_t *new_file(inode_t *node)
{
    file_t *f;
    int idx;

    for (idx = 0; idx < MAX_FILE_NUM; idx++) {
        f = &files[idx];

        if (f->node == NULL) {
            goto got_file;
        }
    }

    return NULL;

got_file:
    f->node = node;
    f->f_arg = NULL;
    f->offset = 0;
    inode_ref(node);
    return f;
}
Beispiel #6
0
void
afr_build_parent_loc (loc_t *parent, loc_t *child)
{
	char *tmp = NULL;

	if (!child->parent) {
		loc_copy (parent, child);
		return;
	}

	tmp = gf_strdup (child->path);
	parent->path   = gf_strdup (dirname (tmp));
	GF_FREE (tmp);

        parent->name   = strrchr (parent->path, '/');
	if (parent->name)
		parent->name++;

	parent->inode  = inode_ref (child->parent);
	parent->parent = inode_parent (parent->inode, 0, NULL);
	parent->ino    = parent->inode->ino;
}
int
__afr_selfheal_metadata_do (call_frame_t *frame, xlator_t *this, inode_t *inode,
                            int source, unsigned char *healed_sinks,
                            struct afr_reply *locked_replies)
{
	int ret = -1;
	loc_t loc = {0,};
	dict_t *xattr = NULL;
	dict_t *old_xattr = NULL;
	afr_private_t *priv = NULL;
	int i = 0;

	priv = this->private;

	loc.inode = inode_ref (inode);
	gf_uuid_copy (loc.gfid, inode->gfid);

        gf_msg (this->name, GF_LOG_INFO, 0,
                AFR_MSG_SELF_HEAL_INFO, "performing metadata selfheal on %s",
		uuid_utoa (inode->gfid));

	ret = syncop_getxattr (priv->children[source], &loc, &xattr, NULL,
                               NULL, NULL);
	if (ret < 0) {
		ret = -EIO;
                goto out;
	}

	afr_delete_ignorable_xattrs (xattr);
static int
afr_selfheal_entry_delete (xlator_t *this, inode_t *dir, const char *name,
                           inode_t *inode, int child, struct afr_reply *replies)
{
	afr_private_t *priv = NULL;
	xlator_t *subvol = NULL;
	int ret = 0;
	loc_t loc = {0, };
	char g[64];

	priv = this->private;

	subvol = priv->children[child];

	loc.parent = inode_ref (dir);
	gf_uuid_copy (loc.pargfid, dir->gfid);
	loc.name = name;
	loc.inode = inode_ref (inode);

	if (replies[child].valid && replies[child].op_ret == 0) {
		switch (replies[child].poststat.ia_type) {
		case IA_IFDIR:
		        gf_msg (this->name, GF_LOG_WARNING, 0,
                                AFR_MSG_EXPUNGING_FILE_OR_DIR,
				"expunging dir %s/%s (%s) on %s",
				uuid_utoa (dir->gfid), name,
				uuid_utoa_r (replies[child].poststat.ia_gfid, g),
				subvol->name);
			ret = syncop_rmdir (subvol, &loc, 1, NULL, NULL);
			break;
Beispiel #9
0
int
glfs_h_link (struct glfs *fs, struct glfs_object *linksrc,
	     struct glfs_object *parent, const char *name)
{
	int                 ret = -1;
	xlator_t           *subvol = NULL;
	inode_t            *inode = NULL;
	inode_t            *pinode = NULL;
	loc_t               oldloc = {0, };
	loc_t               newloc = {0, };

	/* validate in args */
	if ((fs == NULL) || (linksrc == NULL) || (parent == NULL) ||
		(name == NULL)) {
		errno = EINVAL;
		return -1;
	}

	__glfs_entry_fs (fs);

	/* get the active volume */
	subvol = glfs_active_subvol (fs);
	if (!subvol) {
		ret = -1;
		errno = EIO;
		goto out;
	}

	/* get/refresh the in arg objects inode in correlation to the xlator */
	inode = glfs_resolve_inode (fs, subvol, linksrc);
	if (!inode) {
		errno = ESTALE;
		goto out;
	}

	if (inode->ia_type == IA_IFDIR) {
		ret = -1;
		errno = EISDIR;
		goto out;
	}

	GLFS_LOC_FILL_INODE (inode, oldloc, out);

	/* get/refresh the in arg objects inode in correlation to the xlator */
	pinode = glfs_resolve_inode (fs, subvol, parent);
	if (!pinode) {
		errno = ESTALE;
		goto out;
	}

	/* setup newloc based on parent */
	newloc.parent = inode_ref (pinode);
	newloc.name = name;
	ret = glfs_loc_touchup (&newloc);
	if (ret != 0) {
		errno = EINVAL;
		goto out;
	}

	/* Filling the inode of the hard link to be same as that of the
	 * original file
	 */
	newloc.inode = inode_ref (inode);

	/* fop/op */
	ret = syncop_link (subvol, &oldloc, &newloc);
        DECODE_SYNCOP_ERR (ret);

	if (ret == 0)
		/* TODO: No iatt to pass as there has been no lookup */
		ret = glfs_loc_link (&newloc, NULL);
out:
	loc_wipe (&oldloc);
	loc_wipe (&newloc);

	if (inode)
		inode_unref (inode);

	if (pinode)
		inode_unref (pinode);

	glfs_subvol_done (fs, subvol);

	return ret;
}
int32_t ida_inode_assign(ida_local_t * local, inode_t ** dst, inode_t * src)
{
    *dst = inode_ref(src);

    return 0;
}