diff options
Diffstat (limited to 'xlators/storage/posix/src/posix.c')
| -rw-r--r-- | xlators/storage/posix/src/posix.c | 28 | 
1 files changed, 20 insertions, 8 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index e834fc09752..b0c23716a64 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -809,12 +809,13 @@ err:  }  static int32_t -posix_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, -                  off_t offset, off_t len, struct iatt *statpre, -                  struct iatt *statpost) +posix_do_zerofill (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, +                   off_t len, struct iatt *statpre, struct iatt *statpost, +                   dict_t *xdata)  { -        struct posix_fd *pfd       = NULL; -        int32_t          ret       = -1; +        int32_t            ret       = -1; +        struct posix_fd   *pfd       = NULL; +        gf_boolean_t       locked    = _gf_false;          DECLARE_OLD_FS_ID_VAR; @@ -830,6 +831,11 @@ posix_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd,                  goto out;          } +        if (dict_get (xdata, GLUSTERFS_WRITE_UPDATE_ATOMIC)) { +                locked = _gf_true; +                LOCK(&fd->inode->lock); +        } +          ret = posix_fdstat (this, pfd->fd, statpre);          if (ret == -1) {                  ret = -errno; @@ -837,7 +843,8 @@ posix_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd,                          "pre-operation fstat failed on fd = %p", fd);                  goto out;          } -        ret = _posix_do_zerofill(pfd->fd, offset, len, pfd->flags & O_DIRECT); + +        ret = _posix_do_zerofill (pfd->fd, offset, len, pfd->flags & O_DIRECT);          if (ret < 0) {                  ret = -errno;                  gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ZEROFILL_FAILED, @@ -845,6 +852,7 @@ posix_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd,                          pfd->fd, len);                  goto out;          } +          if (pfd->flags & (O_SYNC|O_DSYNC)) {                  ret = sys_fsync (pfd->fd);                  if (ret) { @@ -865,6 +873,10 @@ posix_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd,          }  out: +	if (locked) { +		UNLOCK (&fd->inode->lock); +		locked = _gf_false; +	}          SET_TO_OLD_FS_ID ();          return ret; @@ -932,8 +944,8 @@ posix_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,          struct  iatt statpre             = {0,};          struct  iatt statpost            = {0,}; -        ret = posix_do_zerofill(frame, this, fd, offset, len, -                                 &statpre, &statpost); +        ret = posix_do_zerofill (frame, this, fd, offset, len, +                                 &statpre, &statpost, xdata);          if (ret < 0)                  goto err;  | 
