Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp264108pxx; Mon, 26 Oct 2020 08:06:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+mlj1VUlHZ4qwpYvc8c46Z3cMfnVCQ/Au6tFWEIMIckWWJQRpdEbK0FTIjGIh0cgRLatN X-Received: by 2002:aa7:d3d0:: with SMTP id o16mr547412edr.47.1603724804298; Mon, 26 Oct 2020 08:06:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603724804; cv=none; d=google.com; s=arc-20160816; b=GxaBTEAkz/3VeynxjobjdCbvy/Ox8mcQred2ciApuPh6kpBgMnutM5e71goiJyxgcQ bSDUlhLUa+cs/fZ78O7RAvxrqFJOdYHzdCiIBkNne+pt29OE9zG7huJQON5Dn91/mdAU LvPMXHaoqI01SuoFJlUDrRghvM3AZOfJK3rwVvRYj9eR4X23Zuk4gY82b6EnU+bFfcbK KxXPFtAeRj6ePZZMn7opdo+YuV28BTZGp1c93ylwK2Wsuu2toLCJJnl+IVhIoewfoltD TV5Wy1v3byMoFFF124P3oYaUoaoZKRprRphvv0+Y9G069UvjgYS9Duq0JyTILZGV3cbX VwPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ZH1AbaUNoIFiiF2HbJepWq664il8WWobUCRiDkdhzq8=; b=BR9xJpQVH8djEenv9TZPQjeOCkmn2bhZVmye67ZujvJwFTvuohU5JEEu7MrupQasL5 mU6nBx754sjm7z4jjsRivmWRoCwrg0pECKe+/zA1M0ZAJcI+UA/BdX46K9a2YISNmIJs EvN/aZQOVVrb5IOIKU5tWq2wr2MkMhI2BpYrimptBYDG4lsHEzMhU6tH730VL8Q0YwZj 4Rj3bObJ85C2SBYpn7uVtG8q+STt/BI66GKdV6FPLn8njcI26WTKvo4rVFJ5dBt/aKpH v2Ai/ErbFbfIWSIo+8nM1b20v6eFjXli9kR3CmKd4wgg9zYQ1SgduvZAqt0gfBaZX9wj ng5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HqBoXNhX; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t6si7168752edy.233.2020.10.26.08.06.18; Mon, 26 Oct 2020 08:06:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HqBoXNhX; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1783062AbgJZPFh (ORCPT + 99 others); Mon, 26 Oct 2020 11:05:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31907 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403968AbgJZPFh (ORCPT ); Mon, 26 Oct 2020 11:05:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603724736; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ZH1AbaUNoIFiiF2HbJepWq664il8WWobUCRiDkdhzq8=; b=HqBoXNhXsDVY04yeoh/DXXDT6bx5mKg0DIcHdtFDIWbjRAJng9GR4A52pr1Jh4Buqh76SJ E/chZTUzlKscRLjr/FeazEmZMwHII1LL8K86NEEr9xxHi1qVD8i5b6qTZxRf7MltyZbkhK SMDeS7cibLyji03SFk2hf5N9PHBLrTA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-413--fRyDzxvMNqb516DZ05PBw-1; Mon, 26 Oct 2020 11:05:34 -0400 X-MC-Unique: -fRyDzxvMNqb516DZ05PBw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5D06C101F7A6; Mon, 26 Oct 2020 15:05:33 +0000 (UTC) Received: from idlethread.redhat.com (unknown [10.40.192.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56C7E19728; Mon, 26 Oct 2020 15:05:31 +0000 (UTC) From: Roberto Bergantinos Corpas To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH] sunrpc : make RPC channel buffer dynamic for slow case Date: Mon, 26 Oct 2020 16:05:30 +0100 Message-Id: <20201026150530.29019-1-rbergant@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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 --- 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