From patchwork Mon Aug 27 15:29:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10577371 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE11B13B8 for ; Mon, 27 Aug 2018 15:29:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAFC12969D for ; Mon, 27 Aug 2018 15:29:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CED62297BB; Mon, 27 Aug 2018 15:29:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 091FA2969D for ; Mon, 27 Aug 2018 15:29:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727118AbeH0TRC (ORCPT ); Mon, 27 Aug 2018 15:17:02 -0400 Received: from mail-he1eur01on0101.outbound.protection.outlook.com ([104.47.0.101]:2163 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727101AbeH0TRB (ORCPT ); Mon, 27 Aug 2018 15:17:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Hs72tYcwkrv+dJvDGXUM1JZO+7QAPLBwkNpBBRhU3QI=; b=e27hVvItteoy/87JZCEUtbS/YLs6QMd+TMiRVThuqPBXoyfrgb5pLjCqMc1vh66snKTXirDB15725u+j1FOjB8OH8MuZtWnICvhlH1XJWiWwXhGa08WNj74M0mm9xBQdUf4l90ZqsF5J+lv7CMWhGyVCuYmBwlCWwjzCoeKRmgQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Received: from localhost.localdomain (185.231.240.5) by HE1PR0801MB2026.eurprd08.prod.outlook.com (2603:10a6:3:50::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.15; Mon, 27 Aug 2018 15:29:50 +0000 Subject: [PATCH 5/6] fs: Introduce fuse_conn::bg_lock From: Kirill Tkhai To: miklos@szeredi.hu, ktkhai@virtuozzo.com, linux-fsdevel@vger.kernel.org Date: Mon, 27 Aug 2018 18:29:46 +0300 Message-ID: <153538378685.18303.16396611744482855136.stgit@localhost.localdomain> In-Reply-To: <153538208536.18303.10732945923322972743.stgit@localhost.localdomain> References: <153538208536.18303.10732945923322972743.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 X-Originating-IP: [185.231.240.5] X-ClientProxiedBy: AM4PR07CA0006.eurprd07.prod.outlook.com (2603:10a6:205:1::19) To HE1PR0801MB2026.eurprd08.prod.outlook.com (2603:10a6:3:50::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0ddc1049-68d7-4619-4a26-08d60c31ee2b X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:HE1PR0801MB2026; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB2026;3:eggMGv9iHZ1IJAe4PR/qd6DmZFM9VMngruQgsVgHZLO//rMgE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KMa79yZQGZLndPk39eTbj7SILY5E863x3oS6ZipgVf40OzYN0CiF2GtrIXUR64xXCCBRlMPZm2xqr43lC1BlpNlN6+T5Ng8FbqRG+aJN/8dVRTJHYMMgIleQU155YbHuyUKTgpzVyoG/jujRn8P999M1jT1tloL4tqSnmG3nJrZEJdyjYeA6AG2lwVB2U1pev/R/qyY9qx+/QLW+Jv7HJdpBLQVP+PkuRPpcWQQREgw1DJKaU8kJa3MOjXM9A+izUR31nKfqFqxnl+EqbjKNmER7A+eEJzizTKSvrc0wzfF4pAhMdkQ655nwQVP+NNApbxehu6WpiP;4:MknvEGeTC1uiqAOOKGq0anenOxz+dHhNIm8dwPX49U+v8Sn6vZnJDI2Lwe48Yx1nxhJ3ym5lvHeOPX0KXKAYghpbHJ7kjfjBKLGZp+t6eJNVCCrnkVqzARoSDC/bMB9H9mblWluh+HkB+wnpB5+1nrq4cricOWRDpcOY8q9FRZWpChqVE/y0/AXzqnLNdoAa+coGyu3QH1KFeG14iUfYRcTT6iK+EGtiFUO5ui9FdK96pNvx0+tBJhgsbLPa9hkwwV4fxxk9nswEuYdRsKuCdg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3002001)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123564045)(201708071742011)(7699016);SRVR:HE1PR0801MB2026;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0801MB2026; X-Forefront-PRVS: 07778E4001 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6069001)(136003)(366004)(396003)(346002)(376002)(39850400004)(189003)(199004)(14444005)(2486003)(305945005)(23676004)(52116002)(7696005)(76176011)(58126008)(7736002)(103116003)(61506002)(33896004)(316002)(25786009)(2906002)(66066001)(47776003)(3846002)(6116002)(5660300001)(478600001)(68736007)(26005)(386003)(186003)(6506007)(8936002)(230700001)(9686003)(6666003)(53936002)(11346002)(97736004)(446003)(8676002)(16526019)(81156014)(81166006)(105586002)(86362001)(575784001)(106356001)(476003)(956004)(55016002)(50466002)(486006);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR0801MB2026;H:localhost.localdomain;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BHE1PR0801MB2026=3B23=3Asvs7q?= =?utf-8?q?1EBTZp5Rf+UMAEa6xF8IT/G+jljcW4JrAukB9L+vibbGmaYfuRqY1qIyDwuxjmVy6?= =?utf-8?q?qUQjMhJQBRtx3/PCrMKEu1cx/HFCmwNA1lsUvqg77Ay4lyfkYyXJ4FR6UvSlllvpf?= =?utf-8?q?0YF83Xx0rN3qzAxflea0CclfSW2f+8+iGP79Pd6g7qWxw6ncS73js3bYl0TW0rFWK?= =?utf-8?q?4UaR3axP2CFxQkqva2Kil6TuD6wxaSvQp0G2qVEVRDNT3+igZpRB9FPwBnDkbhuHg?= =?utf-8?q?c4CpJneLLHshHxxmkGZFZ5S4GwCbeuGRUawPQyBrVOmZU5peqsFb4pHqRilO6+3MO?= =?utf-8?q?Lu9nYc59MdHuwBYEU9Wid4S3+E26pWFYjiYaNihE/OOh+9mSIO91DGMLwAmH2lKpR?= =?utf-8?q?JbhEv0Naye1DtOQV6Jl5GvKrPXur+9IjtPyZY5221QqReRjxkw393X83XoTnmpBmu?= =?utf-8?q?SyaNI9ugowSyx6FwKJcX1Dqv/se7esbhd/DD9CaKlqII69wErVvkAe2YDgfpgNqiY?= =?utf-8?q?C+SLsVSFjY7VOGsLomxfhWEH8rGC0zcAUazOqbz44/Gkd3khob3YOgldrXFuowwhM?= =?utf-8?q?P8EIYWDwt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E1PR0801MB2026;20:ZCTGhJnf4M9G3FLkQM5Dw/xO8rLZz4hCjJikdH9lr8LS4mQkXx20vFu/T53dit4DQuNr3hYoGBav9yQL47yGmhTahGLsi6ZqU/e4uCh7gHskCJl9G7JVicKFE8uyBPvExqHeE6Biy+VL0IFa6xwUMjODuGO7xgr6u0MNJ/aGDWY= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2018 15:29:50.4185 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0ddc1049-68d7-4619-4a26-08d60c31ee2b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB2026 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To reduce contention of fuse_conn::lock, this patch introduces bg_lock for protection of fields related to background queue. These are: max_background, congestion_threshold, num_background, active_background, bg_queue and blocked. This allows next patch to make async reads not requiring fuse_conn::lock, so async reads and writes will have better performance executed in parallel. Signed-off-by: Kirill Tkhai --- fs/fuse/control.c | 8 ++++---- fs/fuse/dev.c | 20 ++++++++++++-------- fs/fuse/file.c | 2 +- fs/fuse/fuse_i.h | 8 ++++++-- fs/fuse/inode.c | 3 +++ 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/fs/fuse/control.c b/fs/fuse/control.c index 9206501bd94d..63d0e9552140 100644 --- a/fs/fuse/control.c +++ b/fs/fuse/control.c @@ -125,12 +125,12 @@ static ssize_t fuse_conn_max_background_write(struct file *file, if (ret > 0) { struct fuse_conn *fc = fuse_ctl_file_conn_get(file); if (fc) { - spin_lock(&fc->lock); + spin_lock(&fc->bg_lock); fc->max_background = val; fc->blocked = (fc->num_background >= fc->max_background); if (!fc->blocked && waitqueue_active(&fc->blocked_waitq)) wake_up(&fc->blocked_waitq); - spin_unlock(&fc->lock); + spin_unlock(&fc->bg_lock); fuse_conn_put(fc); } } @@ -171,7 +171,7 @@ static ssize_t fuse_conn_congestion_threshold_write(struct file *file, if (!fc) goto out; - spin_lock(&fc->lock); + spin_lock(&fc->bg_lock); fc->congestion_threshold = val; if (fc->sb) { if (fc->num_background < fc->congestion_threshold) { @@ -182,7 +182,7 @@ static ssize_t fuse_conn_congestion_threshold_write(struct file *file, set_bdi_congested(fc->sb->s_bdi, BLK_RW_ASYNC); } } - spin_unlock(&fc->lock); + spin_unlock(&fc->bg_lock); fuse_conn_put(fc); out: return ret; diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index ce07a41ff8fe..9690e7c79df7 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -287,10 +287,10 @@ void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req) * We get here in the unlikely case that a background * request was allocated but not sent */ - spin_lock(&fc->lock); + spin_lock(&fc->bg_lock); if (!fc->blocked) wake_up(&fc->blocked_waitq); - spin_unlock(&fc->lock); + spin_unlock(&fc->bg_lock); } if (test_bit(FR_WAITING, &req->flags)) { @@ -391,7 +391,7 @@ static void request_end(struct fuse_conn *fc, struct fuse_req *req) WARN_ON(test_bit(FR_SENT, &req->flags)); if (test_bit(FR_BACKGROUND, &req->flags)) { clear_bit(FR_BACKGROUND, &req->flags); - spin_lock(&fc->lock); + spin_lock(&fc->bg_lock); if (fc->num_background == fc->max_background) fc->blocked = 0; @@ -406,7 +406,7 @@ static void request_end(struct fuse_conn *fc, struct fuse_req *req) fc->num_background--; fc->active_background--; flush_bg_queue(fc); - spin_unlock(&fc->lock); + spin_unlock(&fc->bg_lock); } wake_up(&req->waitq); if (req->end) @@ -579,8 +579,8 @@ ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args) * * fc->connected must have been checked previously */ -void fuse_request_send_background_locked(struct fuse_conn *fc, - struct fuse_req *req) +void fuse_request_send_background_nocheck(struct fuse_conn *fc, + struct fuse_req *req) { BUG_ON(!test_bit(FR_BACKGROUND, &req->flags)); if (!test_bit(FR_WAITING, &req->flags)) { @@ -588,6 +588,7 @@ void fuse_request_send_background_locked(struct fuse_conn *fc, atomic_inc(&fc->num_waiting); } __set_bit(FR_ISREPLY, &req->flags); + spin_lock(&fc->bg_lock); fc->num_background++; if (fc->num_background == fc->max_background) fc->blocked = 1; @@ -597,6 +598,7 @@ void fuse_request_send_background_locked(struct fuse_conn *fc, } list_add_tail(&req->list, &fc->bg_queue); flush_bg_queue(fc); + spin_unlock(&fc->bg_lock); } void fuse_request_send_background(struct fuse_conn *fc, struct fuse_req *req) @@ -604,7 +606,7 @@ void fuse_request_send_background(struct fuse_conn *fc, struct fuse_req *req) BUG_ON(!req->end); spin_lock(&fc->lock); if (fc->connected) { - fuse_request_send_background_locked(fc, req); + fuse_request_send_background_nocheck(fc, req); spin_unlock(&fc->lock); } else { spin_unlock(&fc->lock); @@ -2105,7 +2107,6 @@ void fuse_abort_conn(struct fuse_conn *fc, bool is_abort) LIST_HEAD(to_end); fc->connected = 0; - fc->blocked = 0; fc->aborted = is_abort; fuse_set_initialized(fc); list_for_each_entry(fud, &fc->devices, entry) { @@ -2127,8 +2128,11 @@ void fuse_abort_conn(struct fuse_conn *fc, bool is_abort) list_splice_tail_init(&fpq->processing, &to_end); spin_unlock(&fpq->lock); } + spin_lock(&fc->bg_lock); + fc->blocked = 0; fc->max_background = UINT_MAX; flush_bg_queue(fc); + spin_unlock(&fc->bg_lock); spin_lock(&fiq->waitq.lock); fiq->connected = 0; diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 32d0b883e74f..a875959dd939 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1502,7 +1502,7 @@ __acquires(fc->lock) req->in.args[1].size = inarg->size; fi->writectr++; - fuse_request_send_background_locked(fc, req); + fuse_request_send_background_nocheck(fc, req); return; out_free: diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index f78e9614bb5f..b2c6a1cd1e2c 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -500,6 +500,10 @@ struct fuse_conn { /** The list of background requests set aside for later queuing */ struct list_head bg_queue; + /** Protects: max_background, congestion_threshold, num_background, + * active_background, bg_queue, blocked */ + spinlock_t bg_lock; + /** Flag indicating that INIT reply has been received. Allocating * any fuse request will be suspended until the flag is set */ int initialized; @@ -857,8 +861,8 @@ ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args); */ void fuse_request_send_background(struct fuse_conn *fc, struct fuse_req *req); -void fuse_request_send_background_locked(struct fuse_conn *fc, - struct fuse_req *req); +void fuse_request_send_background_nocheck(struct fuse_conn *fc, + struct fuse_req *req); /* Abort all requests */ void fuse_abort_conn(struct fuse_conn *fc, bool is_abort); diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 9db8c0c745a9..a4285ec7c248 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -606,6 +606,7 @@ void fuse_conn_init(struct fuse_conn *fc, struct user_namespace *user_ns) { memset(fc, 0, sizeof(*fc)); spin_lock_init(&fc->lock); + spin_lock_init(&fc->bg_lock); init_rwsem(&fc->killsb); refcount_set(&fc->count, 1); atomic_set(&fc->dev_count, 1); @@ -853,6 +854,7 @@ static void process_init_limits(struct fuse_conn *fc, struct fuse_init_out *arg) sanitize_global_limit(&max_user_bgreq); sanitize_global_limit(&max_user_congthresh); + spin_lock(&fc->bg_lock); if (arg->max_background) { fc->max_background = arg->max_background; @@ -866,6 +868,7 @@ static void process_init_limits(struct fuse_conn *fc, struct fuse_init_out *arg) fc->congestion_threshold > max_user_congthresh) fc->congestion_threshold = max_user_congthresh; } + spin_unlock(&fc->bg_lock); } static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)