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