static void cluster_marker_unwind (call_frame_t *frame, char *key, void *value, size_t size, dict_t *dict) { xl_marker_local_t *local = frame->local; int ret = 0; int32_t op_ret = 0; int32_t op_errno = 0; gf_boolean_t unref = _gf_false; frame->local = local->xl_local; if (local->count[MCNT_FOUND]) { if (!dict) { dict = dict_new(); if (dict) { unref = _gf_true; } else { op_ret = -1; op_errno = ENOMEM; goto out; } } ret = dict_set_static_bin (dict, key, value, size); if (ret) { op_ret = -1; op_errno = ENOMEM; goto out; } } op_errno = evaluate_marker_results (local->gauge, local->count); if (op_errno) op_ret = -1; out: if (local->xl_specf_unwind) { local->xl_specf_unwind (frame, op_ret, op_errno, dict, NULL); } else { STACK_UNWIND_STRICT (getxattr, frame, op_ret, op_errno, dict, NULL); } GF_FREE (local); if (unref) dict_unref (dict); }
struct glfs_object * glfs_h_mknod (struct glfs *fs, struct glfs_object *parent, const char *path, mode_t mode, dev_t dev, struct stat *stat) { int ret = -1; xlator_t *subvol = NULL; inode_t *inode = NULL; loc_t loc = {0, }; struct iatt iatt = {0, }; uuid_t gfid; dict_t *xattr_req = NULL; struct glfs_object *object = NULL; /* validate in args */ if ((fs == NULL) || (parent == NULL) || (path == NULL)) { errno = EINVAL; return NULL; } __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, parent); if (!inode) { errno = ESTALE; goto out; } xattr_req = dict_new (); if (!xattr_req) { ret = -1; errno = ENOMEM; goto out; } uuid_generate (gfid); ret = dict_set_static_bin (xattr_req, "gfid-req", gfid, 16); if (ret) { ret = -1; errno = ENOMEM; goto out; } GLFS_LOC_FILL_PINODE (inode, loc, ret, errno, out, path); /* fop/op */ ret = syncop_mknod (subvol, &loc, mode, dev, xattr_req, &iatt); DECODE_SYNCOP_ERR (ret); /* populate out args */ if (ret == 0) { ret = glfs_loc_link (&loc, &iatt); if (ret != 0) { goto out; } if (stat) glfs_iatt_to_stat (fs, &iatt, stat); ret = glfs_create_object (&loc, &object); } out: if (ret && object != NULL) { glfs_h_close (object); object = NULL; } loc_wipe(&loc); if (inode) inode_unref (inode); if (xattr_req) dict_unref (xattr_req); glfs_subvol_done (fs, subvol); return object; }
struct glfs_object * glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path, int flags, mode_t mode, struct stat *stat) { int ret = -1; struct glfs_fd *glfd = NULL; xlator_t *subvol = NULL; inode_t *inode = NULL; loc_t loc = {0, }; struct iatt iatt = {0, }; uuid_t gfid; dict_t *xattr_req = NULL; struct glfs_object *object = NULL; /* validate in args */ if ((fs == NULL) || (parent == NULL) || (path == NULL)) { errno = EINVAL; return NULL; } __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, parent); if (!inode) { errno = ESTALE; goto out; } xattr_req = dict_new (); if (!xattr_req) { ret = -1; errno = ENOMEM; goto out; } uuid_generate (gfid); ret = dict_set_static_bin (xattr_req, "gfid-req", gfid, 16); if (ret) { ret = -1; errno = ENOMEM; goto out; } GLFS_LOC_FILL_PINODE (inode, loc, ret, errno, out, path); glfd = glfs_fd_new (fs); if (!glfd) goto out; glfd->fd = fd_create (loc.inode, getpid()); if (!glfd->fd) { ret = -1; errno = ENOMEM; goto out; } /* fop/op */ ret = syncop_create (subvol, &loc, flags, mode, glfd->fd, xattr_req, &iatt); DECODE_SYNCOP_ERR (ret); /* populate out args */ if (ret == 0) { /* TODO: If the inode existed in the cache (say file already exists), then the glfs_loc_link will not update the loc.inode, as a result we will have a 0000 GFID that we would copy out to the object, this needs to be fixed. */ ret = glfs_loc_link (&loc, &iatt); if (ret != 0) { goto out; } if (stat) glfs_iatt_to_stat (fs, &iatt, stat); ret = glfs_create_object (&loc, &object); } out: if (ret && object != NULL) { glfs_h_close (object); object = NULL; } loc_wipe(&loc); if (inode) inode_unref (inode); if (xattr_req) dict_unref (xattr_req); if (glfd) { glfs_fd_destroy (glfd); glfd = NULL; } glfs_subvol_done (fs, subvol); return object; }