diff options
Diffstat (limited to 'xlators/cluster/dht/src/dht-inode-write.c')
| -rw-r--r-- | xlators/cluster/dht/src/dht-inode-write.c | 130 | 
1 files changed, 110 insertions, 20 deletions
diff --git a/xlators/cluster/dht/src/dht-inode-write.c b/xlators/cluster/dht/src/dht-inode-write.c index 825822a27e6..f925d4b59ed 100644 --- a/xlators/cluster/dht/src/dht-inode-write.c +++ b/xlators/cluster/dht/src/dht-inode-write.c @@ -159,9 +159,10 @@ dht_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,              struct iovec *vector, int count, off_t off, uint32_t flags,              struct iobref *iobref, dict_t *xdata)  { -        xlator_t     *subvol = NULL; +        xlator_t     *subvol   = NULL;          int           op_errno = -1; -        dht_local_t  *local = NULL; +        dht_local_t  *local    = NULL; +        int           ret      = -1;          VALIDATE_OR_GOTO (frame, err);          VALIDATE_OR_GOTO (this, err); @@ -181,6 +182,8 @@ dht_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,                  op_errno = EINVAL;                  goto err;          } + +          if (xdata)                  local->xattr_req = dict_ref (xdata); @@ -191,9 +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, vector, count, off, flags, -                           iobref, xdata); +        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; @@ -218,6 +234,7 @@ dht_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,          xlator_t     *dst_subvol = NULL;          inode_t      *inode      = NULL; +          GF_VALIDATE_OR_GOTO ("dht", frame, err);          GF_VALIDATE_OR_GOTO ("dht", this, out);          GF_VALIDATE_OR_GOTO ("dht", frame->local, out); @@ -368,6 +385,7 @@ dht_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,                  op_errno = EINVAL;                  goto err;          } +          if (xdata)                  local->xattr_req = dict_ref (xdata); @@ -390,6 +408,8 @@ 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);          VALIDATE_OR_GOTO (this, err); @@ -410,11 +430,23 @@ dht_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,                  op_errno = EINVAL;                  goto err;          } +          if (xdata)                  local->xattr_req = dict_ref (xdata); -        STACK_WIND_COOKIE (frame, dht_truncate_cbk, subvol, subvol, -                           subvol->fops->ftruncate, fd, offset, xdata); +        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; @@ -548,12 +580,13 @@ out:  }  int -dht_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, +dht_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode,  	      off_t offset, size_t len, dict_t *xdata)  {          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); @@ -577,12 +610,26 @@ dht_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode,                  op_errno = EINVAL;                  goto err;          } +          if (xdata)                  local->xattr_req = dict_ref (xdata); -        STACK_WIND_COOKIE (frame, dht_fallocate_cbk, subvol, subvol, -                           subvol->fops->fallocate, fd, mode, offset, len, -                           xdata); +        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; @@ -716,12 +763,13 @@ out:  }  int -dht_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, +dht_discard (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,  	    size_t len, dict_t *xdata)  {          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); @@ -744,11 +792,26 @@ dht_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,                  op_errno = EINVAL;                  goto err;          } +          if (xdata)                  local->xattr_req = dict_ref (xdata); -        STACK_WIND_COOKIE (frame, dht_discard_cbk, subvol, subvol, -                           subvol->fops->discard, fd, offset, len, xdata); +        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; @@ -883,12 +946,13 @@ out:  }  int -dht_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, +dht_zerofill (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,              off_t len, dict_t *xdata)  {          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); @@ -911,11 +975,25 @@ dht_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,                  op_errno = EINVAL;                  goto err;          } +          if (xdata)                  local->xattr_req = dict_ref (xdata); -        STACK_WIND_COOKIE (frame, dht_zerofill_cbk, subvol, subvol, -                           subvol->fops->zerofill, fd, offset, len, xdata); +        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; @@ -1163,6 +1241,7 @@ 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); @@ -1200,10 +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, stbuf, -                                   valid, xdata); +                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;          }  | 
