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