about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-07-22 18:40:41 +0000
committerEric Wong <e@80x24.org>2020-08-09 03:12:31 +0000
commit3a97c98e07fdfc988199fe00f3471bb76620215b (patch)
tree879f56ac706af60efbf1abacf792f7deb9315f83
parentd5451338548c9cbfc159c5f166a4236e70d098aa (diff)
downloadcmogstored-3a97c98e07fdfc988199fe00f3471bb76620215b.tar.gz
Under heavy write traffic, free space changes constantly, and
the periodic updates every 10 (or MOG_DISK_USAGE_INTERVAL)
seconds can be too far behind.  Since we keep the usage file
contents in-memory now for out-of-FD situations, we can update
that without incurring extra VFS traffic.

v2: We no longer try to use fstatvfs(2) and instead pay the cost of
an extra name lookups and just update all usage files.  This was
necessary since calculating free space while a file is still
open can take a long time on some FSes and we need to send the
HTTP response back ASAP to avoid timeouts on the client-side.

This avoids contention in the request worker threads and the
mostly idle main thread to do more work.
-rw-r--r--http_dav.c2
-rw-r--r--http_put.c1
2 files changed, 3 insertions, 0 deletions
diff --git a/http_dav.c b/http_dav.c
index 4b6df9b..43b6c7a 100644
--- a/http_dav.c
+++ b/http_dav.c
@@ -29,6 +29,8 @@ void mog_http_delete(struct mog_fd *mfd, char *buf)
         rc = mog_unlink(http->svc, path);
         if (rc == 0) {
                 mog_http_resp(mfd, "204 No Content", true);
+                mog_notify(MOG_NOTIFY_DEVICE_REFRESH);
+
                 return;
         }
 
diff --git a/http_put.c b/http_put.c
index fc36ba7..11d6342 100644
--- a/http_put.c
+++ b/http_put.c
@@ -153,6 +153,7 @@ static void put_commit_resp(struct mog_fd *mfd)
                 if (set_perms_commit(http)) {
                         file_close_null(mfd);
                         mog_http_resp(mfd, "201 Created", true);
+                        mog_notify(MOG_NOTIFY_DEVICE_REFRESH);
                 } else {
                         file_close_null(mfd);
                         mog_http_resp(mfd, "500 Internal Server Error", false);