summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/storage/posix/src/posix.c')
-rw-r--r--xlators/storage/posix/src/posix.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 272d08f8654..e834fc09752 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -653,12 +653,13 @@ out:
}
static int32_t
-posix_do_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
- off_t offset, size_t len, struct iatt *statpre,
- struct iatt *statpost)
+posix_do_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd,
+ int32_t flags, off_t offset, size_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;
@@ -674,6 +675,11 @@ posix_do_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
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;
@@ -682,7 +688,7 @@ posix_do_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
goto out;
}
- ret = sys_fallocate(pfd->fd, flags, offset, len);
+ ret = sys_fallocate (pfd->fd, flags, offset, len);
if (ret == -1) {
ret = -errno;
goto out;
@@ -697,6 +703,10 @@ posix_do_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
}
out:
+ if (locked) {
+ UNLOCK (&fd->inode->lock);
+ locked = _gf_false;
+ }
SET_TO_OLD_FS_ID ();
return ret;
@@ -874,8 +884,8 @@ _posix_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t keep_siz
flags = FALLOC_FL_KEEP_SIZE;
#endif /* FALLOC_FL_KEEP_SIZE */
- ret = posix_do_fallocate(frame, this, fd, flags, offset, len,
- &statpre, &statpost);
+ ret = posix_do_fallocate (frame, this, fd, flags, offset, len,
+ &statpre, &statpost, xdata);
if (ret < 0)
goto err;
@@ -900,8 +910,8 @@ posix_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
struct iatt statpre = {0,};
struct iatt statpost = {0,};
- ret = posix_do_fallocate(frame, this, fd, flags, offset, len,
- &statpre, &statpost);
+ ret = posix_do_fallocate (frame, this, fd, flags, offset, len,
+ &statpre, &statpost, xdata);
if (ret < 0)
goto err;