diff options
Diffstat (limited to 'xlators/cluster/dht/src/dht-inode-write.c')
| -rw-r--r-- | xlators/cluster/dht/src/dht-inode-write.c | 174 | 
1 files changed, 100 insertions, 74 deletions
diff --git a/xlators/cluster/dht/src/dht-inode-write.c b/xlators/cluster/dht/src/dht-inode-write.c index 954a914e9cd..f925d4b59ed 100644 --- a/xlators/cluster/dht/src/dht-inode-write.c +++ b/xlators/cluster/dht/src/dht-inode-write.c @@ -44,13 +44,6 @@ dht_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                  goto out;          } -        if (op_ret == -1 && (op_errno == EBADF)) { -                ret = dht_check_and_open_fd_on_subvol (this, frame); -                if (ret) -                        goto out; -                return 0; -        } -          if (op_ret == -1 && !dht_inode_missing(op_errno)) {                  local->op_errno = op_errno;                  local->op_ret = -1; @@ -169,6 +162,7 @@ dht_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,          xlator_t     *subvol   = NULL;          int           op_errno = -1;          dht_local_t  *local    = NULL; +        int           ret      = -1;          VALIDATE_OR_GOTO (frame, err);          VALIDATE_OR_GOTO (this, err); @@ -189,6 +183,7 @@ dht_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,                  goto err;          } +          if (xdata)                  local->xattr_req = dict_ref (xdata); @@ -199,13 +194,22 @@ dht_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,          local->rebalance.iobref = iobref_ref (iobref);          local->call_cnt = 1; -        STACK_WIND_COOKIE (frame, dht_writev_cbk, subvol, subvol, -                           subvol->fops->writev, fd, -                           local->rebalance.vector, -                           local->rebalance.count, -                           local->rebalance.offset, -                           local->rebalance.flags, -                           local->rebalance.iobref, local->xattr_req); +        if (dht_fd_open_on_dst (this, fd, subvol)) { + +                STACK_WIND_COOKIE (frame, dht_writev_cbk, subvol, subvol, +                                   subvol->fops->writev, fd, +                                   local->rebalance.vector, +                                   local->rebalance.count, +                                   local->rebalance.offset, +                                   local->rebalance.flags, +                                   local->rebalance.iobref, local->xattr_req); +                return 0; + +        } else { +                ret = dht_check_and_open_fd_on_subvol (this, frame); +                if (ret) +                        goto err; +        }          return 0; @@ -249,14 +253,6 @@ dht_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                  goto out;          } -        /* Can only occur for ftruncate */ -        if (op_ret == -1 && (op_errno == EBADF)) { -                ret = dht_check_and_open_fd_on_subvol (this, frame); -                if (ret) -                        goto out; -                return 0; -        } -          if (local->call_cnt != 1) {                  if (local->stbuf.ia_blocks) {                          dht_iatt_merge (this, postbuf, &local->stbuf, NULL); @@ -412,6 +408,7 @@ dht_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,          xlator_t     *subvol = NULL;          int           op_errno = -1;          dht_local_t  *local = NULL; +        int           ret   = -1;          VALIDATE_OR_GOTO (frame, err); @@ -437,9 +434,20 @@ dht_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,          if (xdata)                  local->xattr_req = dict_ref (xdata); -        STACK_WIND_COOKIE (frame, dht_truncate_cbk, subvol, subvol, -                           subvol->fops->ftruncate, fd, -                           local->rebalance.offset, local->xattr_req); +        if (dht_fd_open_on_dst (this, fd, subvol)) { + +                STACK_WIND_COOKIE (frame, dht_truncate_cbk, subvol, subvol, +                                   subvol->fops->ftruncate, fd, +                                   local->rebalance.offset, local->xattr_req); +                return 0; + +        } else { + +                ret = dht_check_and_open_fd_on_subvol (this, frame); +                if (ret) +                        goto err; +        } +          return 0;  err: @@ -479,13 +487,6 @@ dht_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,                  goto out;          } -        if (op_ret == -1 && (op_errno == EBADF)) { -                ret = dht_check_and_open_fd_on_subvol (this, frame); -                if (ret) -                        goto out; -                return 0; -        } -          if (local->call_cnt != 1) {                  if (local->stbuf.ia_blocks) {                          dht_iatt_merge (this, postbuf, &local->stbuf, NULL); @@ -585,6 +586,7 @@ dht_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode,          xlator_t     *subvol = NULL;          int           op_errno = -1;          dht_local_t  *local = NULL; +        int           ret      = -1;          VALIDATE_OR_GOTO (frame, err);          VALIDATE_OR_GOTO (this, err); @@ -612,12 +614,22 @@ dht_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode,          if (xdata)                  local->xattr_req = dict_ref (xdata); -        STACK_WIND_COOKIE (frame, dht_fallocate_cbk, subvol, subvol, -                           subvol->fops->fallocate, fd, -                           local->rebalance.flags, -                           local->rebalance.offset, -                           local->rebalance.size, -                           local->xattr_req); +        if (dht_fd_open_on_dst (this, fd, subvol)) { + +                STACK_WIND_COOKIE (frame, dht_fallocate_cbk, subvol, subvol, +                                   subvol->fops->fallocate, fd, +                                   local->rebalance.flags, +                                   local->rebalance.offset, +                                   local->rebalance.size, +                                   local->xattr_req); +                return 0; + +        } else { + +                ret = dht_check_and_open_fd_on_subvol (this, frame); +                if (ret) +                        goto err; +        }          return 0; @@ -658,13 +670,6 @@ dht_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this,                  goto out;          } -        if (op_ret == -1 && (op_errno == EBADF)) { -                ret = dht_check_and_open_fd_on_subvol (this, frame); -                if (ret) -                        goto out; -                return 0; -        } -          if (local->call_cnt != 1) {                  if (local->stbuf.ia_blocks) {                          dht_iatt_merge (this, postbuf, &local->stbuf, NULL); @@ -764,6 +769,7 @@ dht_discard (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,          xlator_t     *subvol = NULL;          int           op_errno = -1;          dht_local_t  *local = NULL; +        int           ret      = -1;          VALIDATE_OR_GOTO (frame, err);          VALIDATE_OR_GOTO (this, err); @@ -790,11 +796,22 @@ dht_discard (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,          if (xdata)                  local->xattr_req = dict_ref (xdata); -        STACK_WIND_COOKIE (frame, dht_discard_cbk, subvol, subvol, -                           subvol->fops->discard, fd, -                           local->rebalance.offset, -                           local->rebalance.size, -                           local->xattr_req); +        if (dht_fd_open_on_dst (this, fd, subvol)) { + +                STACK_WIND_COOKIE (frame, dht_discard_cbk, subvol, subvol, +                                   subvol->fops->discard, fd, +                                   local->rebalance.offset, +                                   local->rebalance.size, +                                   local->xattr_req); +                return 0; + +        } else { + +                ret = dht_check_and_open_fd_on_subvol (this, frame); +                if (ret) +                        goto err; + +        }          return 0; @@ -832,13 +849,6 @@ dht_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this,                  goto out;          } -        if (op_ret == -1 && (op_errno == EBADF)) { -                ret = dht_check_and_open_fd_on_subvol (this, frame); -                if (ret) -                        goto out; -                return 0; -        } -          if (local->call_cnt != 1) {                  if (local->stbuf.ia_blocks) {                          dht_iatt_merge (this, postbuf, &local->stbuf, NULL); @@ -942,6 +952,7 @@ dht_zerofill (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,          xlator_t     *subvol       = NULL;          int           op_errno     = -1;          dht_local_t  *local        = NULL; +        int           ret          = -1;          VALIDATE_OR_GOTO (frame, err);          VALIDATE_OR_GOTO (this, err); @@ -968,10 +979,21 @@ dht_zerofill (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,          if (xdata)                  local->xattr_req = dict_ref (xdata); -        STACK_WIND_COOKIE (frame, dht_zerofill_cbk, subvol, subvol, -                           subvol->fops->zerofill, fd, -                           local->rebalance.offset, -                           local->rebalance.size, local->xattr_req); +        if (dht_fd_open_on_dst (this, fd, subvol)) { + +                STACK_WIND_COOKIE (frame, dht_zerofill_cbk, subvol, subvol, +                                   subvol->fops->zerofill, fd, +                                   local->rebalance.offset, +                                   local->rebalance.size, local->xattr_req); +                return 0; + +        } else { + +                ret = dht_check_and_open_fd_on_subvol (this, frame); +                if (ret) +                        goto err; +        } +          return 0; @@ -1005,17 +1027,9 @@ dht_file_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,                  goto out;          } -          if (local->call_cnt != 1)                  goto out; -        if (op_ret == -1 && (op_errno == EBADF)) { -                ret = dht_check_and_open_fd_on_subvol (this, frame); -                if (ret) -                        goto out; -                return 0; -        } -          local->op_ret = op_ret;          local->op_errno = op_errno; @@ -1227,6 +1241,8 @@ dht_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *stbuf,          int           op_errno = -1;          int           i = -1;          int           call_cnt = 0; +        int           ret      = -1; +          VALIDATE_OR_GOTO (frame, err);          VALIDATE_OR_GOTO (this, err); @@ -1263,11 +1279,21 @@ dht_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *stbuf,                  local->call_cnt = 1;                  subvol = local->cached_subvol; -                STACK_WIND_COOKIE (frame, dht_file_setattr_cbk, subvol, -                                   subvol, subvol->fops->fsetattr, fd, -                                   &local->rebalance.stbuf, -                                   local->rebalance.flags, -                                   local->xattr_req); +                if (dht_fd_open_on_dst (this, fd, subvol)) { + +                        STACK_WIND_COOKIE (frame, dht_file_setattr_cbk, subvol, +                                           subvol, subvol->fops->fsetattr, fd, +                                           &local->rebalance.stbuf, +                                           local->rebalance.flags, +                                           local->xattr_req); +                        return 0; + +                } else { +                        ret = dht_check_and_open_fd_on_subvol (this, frame); +                        if (ret) +                                goto err; + +                }                  return 0;          }  | 
