cmogstored dev/user discussion/issues/patches/etc
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: cmogstored-public@yhbt.net
Subject: [PATCH v2] http: update in-memory devXX/usage on PUT+DELETE
Date: Sat, 25 Jul 2020 02:10:01 +0000	[thread overview]
Message-ID: <20200725020922.GA30804@dcvr> (raw)
In-Reply-To: <20200724060858.25068-1-e@80x24.org>

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.
---
 http_dav.c | 2 ++
 http_put.c | 1 +
 2 files changed, 3 insertions(+)

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);

      reply	other threads:[~2020-07-25  2:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-24  6:08 [PATCH] http: update in-memory devXX/usage on PUT+DELETE Eric Wong
2020-07-25  2:10 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/cmogstored/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200725020922.GA30804@dcvr \
    --to=e@80x24.org \
    --cc=cmogstored-public@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/cmogstored.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).