From 391a6263318dfa674b3cfecbd3725f4b54633bb7 Mon Sep 17 00:00:00 2001 From: moagrawa Date: Wed, 11 Apr 2018 16:39:47 +0530 Subject: [PATCH 218/236] posix: reserve option behavior is not correct while using fallocate Problem: storage.reserve option is not working correctly while disk space is allocate throguh fallocate Solution: In posix_disk_space_check_thread_proc after every 5 sec interval it calls posix_disk_space_check to monitor disk space and set the flag in posix priv.In 5 sec timestamp user can create big file with fallocate that can reach posix reserve limit and no error is shown on terminal even limit has reached. To resolve the same call posix_disk_space for every fallocate fop instead to call by a thread after 5 second > BUG: 1560411 > Signed-off-by: Mohit Agrawal > (cherry picked from commit 0002c36666c9b043a330ee08533a87fe7fd16491) > (Upstream patch link https://review.gluster.org/#/c/19771/) BUG: 1550991 Change-Id: I6a959dfe38d63ea37f25a431a49f9299fa3ae403 Signed-off-by: moagrawa Reviewed-on: https://code.engineering.redhat.com/gerrit/135208 Tested-by: RHGS Build Bot Reviewed-by: Sunil Kumar Heggodu Gopala Acharya --- xlators/storage/posix/src/posix-handle.h | 3 +++ xlators/storage/posix/src/posix.c | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/xlators/storage/posix/src/posix-handle.h b/xlators/storage/posix/src/posix-handle.h index 9af6a7a..a40feb5 100644 --- a/xlators/storage/posix/src/posix-handle.h +++ b/xlators/storage/posix/src/posix-handle.h @@ -285,4 +285,7 @@ int posix_create_link_if_gfid_exists (xlator_t *this, uuid_t gfid, int posix_handle_trash_init (xlator_t *this); + +void +posix_disk_space_check (xlator_t *this); #endif /* !_POSIX_HANDLE_H */ diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 56a2ca9..d1ef8a2 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -792,6 +792,15 @@ posix_do_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd, VALIDATE_OR_GOTO (fd, out); priv = this->private; + + /* fallocate case is special so call posix_disk_space_check separately + for every fallocate fop instead of calling posix_disk_space with + thread after every 5 sec sleep to working correctly storage.reserve + option behaviour + */ + if (priv->disk_reserve) + posix_disk_space_check (this); + DISK_SPACE_CHECK_AND_GOTO (frame, priv, xdata, ret, ret, out); ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno); -- 1.8.3.1