📄 stripe.c
字号:
} return 0;}/** * stripe_chmod - */int32_tstripe_chmod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode){ stripe_private_t *priv = this->private; xlator_list_t *trav = this->children; stripe_local_t *local = NULL; int8_t striped = 0; STRIPE_CHECK_INODE_CTX_AND_UNWIND_ON_ERR (loc); if (priv->first_child_down) { gf_log (this->name, GF_LOG_WARNING, "First node down, returning ENOTCONN"); STACK_UNWIND (frame, -1, ENOTCONN, NULL); return 0; } striped = data_to_int8 (dict_get (loc->inode->ctx, this->name)); if (striped == 1) { STACK_WIND (frame, stripe_common_buf_cbk, trav->xlator, trav->xlator->fops->chmod, loc, mode); } else { /* Initialization */ local = calloc (1, sizeof (stripe_local_t)); local->op_ret = -1; frame->local = local; local->inode = loc->inode; local->call_count = priv->child_count; while (trav) { STACK_WIND (frame, stripe_stack_unwind_buf_cbk, trav->xlator, trav->xlator->fops->chmod, loc, mode); trav = trav->next; } } return 0;}/** * stripe_chown - */int32_tstripe_chown (call_frame_t *frame, xlator_t *this, loc_t *loc, uid_t uid, gid_t gid){ stripe_local_t *local = NULL; stripe_private_t *priv = this->private; xlator_list_t *trav = this->children; int8_t striped = 0; STRIPE_CHECK_INODE_CTX_AND_UNWIND_ON_ERR (loc); if (priv->first_child_down) { gf_log (this->name, GF_LOG_WARNING, "First node down, returning ENOTCONN"); STACK_UNWIND (frame, -1, ENOTCONN, NULL); return 0; } striped = data_to_int8 (dict_get (loc->inode->ctx, this->name)); if (striped == 1) { STACK_WIND (frame, stripe_common_buf_cbk, trav->xlator, trav->xlator->fops->chown, loc, uid, gid); } else { /* Initialization */ local = calloc (1, sizeof (stripe_local_t)); local->op_ret = -1; frame->local = local; local->inode = loc->inode; local->call_count = priv->child_count; while (trav) { STACK_WIND (frame, stripe_stack_unwind_buf_cbk, trav->xlator, trav->xlator->fops->chown, loc, uid, gid); trav = trav->next; } } return 0;}/** * stripe_statfs_cbk - */int32_tstripe_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct statvfs *stbuf){ stripe_local_t *local = (stripe_local_t *)frame->local; int32_t callcnt; LOCK(&frame->lock); { callcnt = --local->call_count; if (op_ret != 0 && op_errno != ENOTCONN) { local->op_errno = op_errno; } if (op_ret == 0) { struct statvfs *dict_buf = &local->statvfs_buf; dict_buf->f_bsize = stbuf->f_bsize; dict_buf->f_frsize = stbuf->f_frsize; dict_buf->f_blocks += stbuf->f_blocks; dict_buf->f_bfree += stbuf->f_bfree; dict_buf->f_bavail += stbuf->f_bavail; dict_buf->f_files += stbuf->f_files; dict_buf->f_ffree += stbuf->f_ffree; dict_buf->f_favail += stbuf->f_favail; dict_buf->f_fsid = stbuf->f_fsid; dict_buf->f_flag = stbuf->f_flag; dict_buf->f_namemax = stbuf->f_namemax; local->op_ret = 0; } } UNLOCK (&frame->lock); if (!callcnt) { STACK_UNWIND (frame, local->op_ret, local->op_errno, &local->statvfs_buf); } return 0;}/** * stripe_statfs - */int32_tstripe_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc){ stripe_local_t *local = NULL; xlator_list_t *trav = this->children; /* Initialization */ local = calloc (1, sizeof (stripe_local_t)); local->op_ret = -1; local->op_errno = ENOTCONN; frame->local = local; local->call_count = ((stripe_private_t *)this->private)->child_count; while (trav) { STACK_WIND (frame, stripe_statfs_cbk, trav->xlator, trav->xlator->fops->statfs, loc); trav = trav->next; } return 0;}/** * stripe_truncate - */int32_tstripe_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset){ stripe_local_t *local = NULL; stripe_private_t *priv = this->private; xlator_list_t *trav = this->children; int8_t striped = 0; STRIPE_CHECK_INODE_CTX_AND_UNWIND_ON_ERR (loc); if (priv->first_child_down) { gf_log (this->name, GF_LOG_WARNING, "First node down, returning ENOTCONN"); STACK_UNWIND (frame, -1, ENOTCONN, NULL); return 0; } striped = data_to_int8 (dict_get (loc->inode->ctx, this->name)); if (striped == 1) { STACK_WIND (frame, stripe_common_buf_cbk, trav->xlator, trav->xlator->fops->truncate, loc, offset); } else { /* Initialization */ local = calloc (1, sizeof (stripe_local_t)); local->op_ret = -1; frame->local = local; local->inode = loc->inode; local->call_count = priv->child_count; while (trav) { STACK_WIND (frame, stripe_stack_unwind_buf_cbk, trav->xlator, trav->xlator->fops->truncate, loc, offset); trav = trav->next; } } return 0;}/** * stripe_utimens - */int32_t stripe_utimens (call_frame_t *frame, xlator_t *this, loc_t *loc, struct timespec tv[2]){ stripe_local_t *local = NULL; stripe_private_t *priv = this->private; xlator_list_t *trav = this->children; int8_t striped = 0; STRIPE_CHECK_INODE_CTX_AND_UNWIND_ON_ERR (loc); if (priv->first_child_down) { gf_log (this->name, GF_LOG_WARNING, "First node down, returning ENOTCONN"); STACK_UNWIND (frame, -1, ENOTCONN, NULL); return 0; } striped = data_to_int8 (dict_get (loc->inode->ctx, this->name)); if (striped == 1) { STACK_WIND (frame, stripe_common_buf_cbk, trav->xlator, trav->xlator->fops->utimens, loc, tv); } else { /* Initialization */ local = calloc (1, sizeof (stripe_local_t)); local->op_ret = -1; frame->local = local; local->inode = loc->inode; local->call_count = priv->child_count; while (trav) { STACK_WIND (frame, stripe_stack_unwind_buf_cbk, trav->xlator, trav->xlator->fops->utimens, loc, tv); trav = trav->next; } } return 0;}/** * stripe_rename - */int32_tstripe_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc){ stripe_private_t *priv = this->private; stripe_local_t *local = NULL; xlator_list_t *trav = this->children; int8_t striped = 0; STRIPE_CHECK_INODE_CTX_AND_UNWIND_ON_ERR (oldloc); if (priv->first_child_down) { gf_log (this->name, GF_LOG_WARNING, "First node down, returning ENOTCONN"); STACK_UNWIND (frame, -1, EIO, NULL); return 0; } striped = data_to_int8 (dict_get (oldloc->inode->ctx, this->name)); if (striped == 1) { STACK_WIND (frame, stripe_common_buf_cbk, trav->xlator, trav->xlator->fops->rename, oldloc, newloc); /* TODO: if oldloc is unstripped, and newloc is stripped file, send unlink to those nodes */ } else { /* Initialization */ local = calloc (1, sizeof (stripe_local_t)); local->op_ret = -1; frame->local = local; local->inode = oldloc->inode; local->call_count = priv->child_count; while (trav) { STACK_WIND (frame, stripe_stack_unwind_buf_cbk, trav->xlator, trav->xlator->fops->rename, oldloc, newloc); trav = trav->next; } } return 0;}/** * stripe_access - */int32_tstripe_access (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask){ STRIPE_CHECK_INODE_CTX_AND_UNWIND_ON_ERR (loc); STACK_WIND (frame, stripe_common_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->access, loc, mask); return 0;}/** * stripe_readlink_cbk - */int32_t stripe_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, const char *path){ STACK_UNWIND (frame, op_ret, op_errno, path); return 0;}/** * stripe_readlink - */int32_tstripe_readlink (call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size){ stripe_private_t *priv = this->private; STRIPE_CHECK_INODE_CTX_AND_UNWIND_ON_ERR (loc); if (priv->first_child_down) { gf_log (this->name, GF_LOG_WARNING, "First node down, returning ENOTCONN"); STACK_UNWIND (frame, -1, ENOTCONN, NULL); return 0; } STACK_WIND (frame, stripe_readlink_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->readlink, loc, size); return 0;}/** * stripe_unlink - */int32_tstripe_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc){ stripe_local_t *local = NULL; stripe_private_t *priv = this->private; xlator_list_t *trav = this->children; int8_t striped = 0; STRIPE_CHECK_INODE_CTX_AND_UNWIND_ON_ERR (loc); if (priv->first_child_down) { gf_log (this->name, GF_LOG_WARNING, "First node down, returning EIO"); STACK_UNWIND (frame, -1, EIO); return 0; } striped = data_to_int8 (dict_get (loc->inode->ctx, this->name)); if (striped == 1) { STACK_WIND (frame, stripe_common_cbk, trav->xlator, trav->xlator->fops->unlink, loc); } else { /* Initialization */ local = calloc (1, sizeof (stripe_local_t)); local->op_ret = -1; frame->local = local; local->call_count = priv->child_count; while (trav) { STACK_WIND (frame, stripe_stack_unwind_cbk, trav->xlator, trav->xlator->fops->unlink, loc); trav = trav->next; } } return 0;}/** * stripe_rmdir - */int32_tstripe_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc){ stripe_local_t *local = NULL; stripe_private_t *priv = this->private; xlator_list_t *trav = this->children; int8_t striped = 0; STRIPE_CHECK_INODE_CTX_AND_UNWIND_ON_ERR (loc); if (priv->first_child_down) { gf_log (this->name, GF_LOG_WARNING, "First node down, returning EIO"); STACK_UNWIND (frame, -1, EIO); return 0; } striped = data_to_int8 (dict_get (loc->inode->ctx, this->name)); if (striped == 1) { STACK_WIND (frame, stripe_common_cbk, trav->xlator, trav->xlator->fops->rmdir, loc); } else { /* Initialization */ local = calloc (1, sizeof (stripe_local_t)); local->op_ret = -1; frame->local = local; local->call_count = priv->child_count; while (trav) { STACK_WIND (frame, stripe_stack_unwind_cbk, trav->xlator, trav->xlator->fops->rmdir, loc); trav = trav->next; } } return 0;}/** * stripe_setxattr - */int32_tstripe_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, int32_t flags){ stripe_private_t *priv = this->private; if (!loc) { gf_log (this->name, GF_LOG_ERROR, "returning EINVAL"); STACK_UNWIND (frame, -1, EINVAL, NULL, NULL, NULL); return 0; } //STRIPE_CHECK_INODE_CTX_AND_UNWIND_ON_ERR (loc); if (priv->first_child_down) { gf_log (this->name, GF_LOG_WARNING, "First node down, returning ENOTCONN"); STACK_UNWIND (frame, -1, ENOTCONN); return 0; } STACK_WIND (frame, stripe_common_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->setxattr, loc, dict, flags); return 0;}int32_t stripe_mknod_ifreg_fail_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno){ int32_t callcnt = 0; stripe_local_t *local = frame->local; LOCK (&frame->lock); { callcnt = --local->call_count; } UNLOCK (&frame->lock); if (!callcnt) { if (local->path) freee (local->path); STACK_UNWIND (frame, local->op_ret, local->op_errno, local->inode, &local->stbuf); } return 0;}/** */int32_tstripe_mknod_ifreg_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno){ int32_t callcnt = 0; stripe_local_t *local = frame->local;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -