linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sunrpc : make RPC channel buffer dynamic for slow case
@ 2020-10-26 15:05 Roberto Bergantinos Corpas
  2020-11-06 21:51 ` J. Bruce Fields
  0 siblings, 1 reply; 6+ messages in thread
From: Roberto Bergantinos Corpas @ 2020-10-26 15:05 UTC (permalink / raw)
  To: bfields; +Cc: linux-nfs

RPC channel buffer size for slow case (user buffer bigger than
one page) can be converted into dymanic and also allows us to
prescind from queue_io_mutex

Signed-off-by: Roberto Bergantinos Corpas <rbergant@redhat.com>
---
 net/sunrpc/cache.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index baef5ee43dbb..325393f75e17 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -777,7 +777,6 @@ void cache_clean_deferred(void *owner)
  */
 
 static DEFINE_SPINLOCK(queue_lock);
-static DEFINE_MUTEX(queue_io_mutex);
 
 struct cache_queue {
 	struct list_head	list;
@@ -908,14 +907,18 @@ static ssize_t cache_do_downcall(char *kaddr, const char __user *buf,
 static ssize_t cache_slow_downcall(const char __user *buf,
 				   size_t count, struct cache_detail *cd)
 {
-	static char write_buf[8192]; /* protected by queue_io_mutex */
+	char *write_buf;
 	ssize_t ret = -EINVAL;
 
-	if (count >= sizeof(write_buf))
+	if (count >= 32768) /* 32k is max userland buffer, lets check anyway */
 		goto out;
-	mutex_lock(&queue_io_mutex);
+
+	write_buf = kvmalloc(count + 1, GFP_KERNEL);
+	if (!write_buf)
+		return -ENOMEM;
+
 	ret = cache_do_downcall(write_buf, buf, count, cd);
-	mutex_unlock(&queue_io_mutex);
+	kvfree(write_buf);
 out:
 	return ret;
 }
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-11-23 16:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-26 15:05 [PATCH] sunrpc : make RPC channel buffer dynamic for slow case Roberto Bergantinos Corpas
2020-11-06 21:51 ` J. Bruce Fields
2020-11-21 10:54   ` Roberto Bergantinos Corpas
2020-11-23 15:36     ` J. Bruce Fields
2020-11-23 15:48       ` Chuck Lever
2020-11-23 16:05         ` Bruce Fields

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 NNTP newsgroup(s).