Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1644677imu; Tue, 6 Nov 2018 01:53:03 -0800 (PST) X-Google-Smtp-Source: AJdET5fE3WWGnwH0FypiyGISUDyIEpXI5gbiYShdr6rzE2EbZe3aqmajFaKJJItuc7zOllmyK2yO X-Received: by 2002:a17:902:5a4:: with SMTP id f33-v6mr16678476plf.324.1541497983217; Tue, 06 Nov 2018 01:53:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541497983; cv=none; d=google.com; s=arc-20160816; b=QD28QXGiaR3i1De7E+Lh97xVj1kB2zDA9qV+PkpbE75k/DA8w38K8cWSIBQCWt5qh2 6bdr/zQ6d6hWz2hbHy5n5BoY2AfdALEY9jfLN7padqws1JkltgIufVZ5wFZ10j8pqK5a I5d5BukFMYgfRWagfp6+7mT/Wl6UAY6GDQW6XV76yzNQnMUB7NSD/dXbZjYJlCkoKva/ Tz7bkQ/of7rljw+ITjRI+aNEooPEmBp7qkjVqAlbSGLTZ+pOVKG8BVAd8uTTXL7xW4Ra JOJVxZaXD3+glBCsAFpheqQsFMUxSEK2fKJqR1tAv7F+rA4pYOWA3/oD6t215knR61h7 soRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:to:from:subject; bh=UCSp1D9ZefEEg0Atwr++xexxMTZBD13ItXXBF6R5w3s=; b=aTsSxqHycKx5XHyZKQ6b6i4oRCAFxaisvaT07Bu9j4WMWboK+cF8B9RU8lE/SxI1RA b1tmY2WhlIIhhY4EI913DvQqzyawgVdBRdaq2UmE6fSTqaEa9GgvOVQl4kAjNv8m/E4W EBagwL5eZhiYtwhVZtMupNj60jpX+JhlHMBOttDNPJZ/EFTTA9luB4vi4G54hLQKsjX9 d6YxVi9iRbLjU2vUhorbS/mh6ulB+cR1Vxi3FgdXe5Ur/JSKDe7YynQg99ik8kmdOfUK JXI5nvx38T96bbglBV8y+RdNTC+FD1Cycuh0tHd5RDYWBWMRqqMfz7jYhM0D83cTCWJa 564g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10si4107734pgj.416.2018.11.06.01.52.48; Tue, 06 Nov 2018 01:53:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387542AbeKFTIg (ORCPT + 99 others); Tue, 6 Nov 2018 14:08:36 -0500 Received: from relay.sw.ru ([185.231.240.75]:60018 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387498AbeKFTIe (ORCPT ); Tue, 6 Nov 2018 14:08:34 -0500 Received: from [172.16.25.169] (helo=localhost.localdomain) by relay.sw.ru with esmtp (Exim 4.90_1) (envelope-from ) id 1gJxu4-00039H-UH; Tue, 06 Nov 2018 12:44:09 +0300 Subject: [PATCH 6/6] fuse: Protect fuse_file::reserved_req via corresponding fuse_inode::lock From: Kirill Tkhai To: miklos@szeredi.hu, ktkhai@virtuozzo.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 06 Nov 2018 12:44:08 +0300 Message-ID: <154149744887.18189.9866673230837073311.stgit@localhost.localdomain> In-Reply-To: <154149673368.18189.14752124997476502777.stgit@localhost.localdomain> References: <154149673368.18189.14752124997476502777.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is rather natural action after previous patches, and it just decreases load of fc->lock. Signed-off-by: Kirill Tkhai --- fs/fuse/dev.c | 10 ++++++---- fs/fuse/fuse_i.h | 5 ++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 3bfc5ed61c9a..cc8b95ad5b16 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -247,17 +247,18 @@ static struct fuse_req *get_reserved_req(struct fuse_conn *fc, struct file *file) { struct fuse_req *req = NULL; + struct fuse_inode *fi = get_fuse_inode(file_inode(file)); struct fuse_file *ff = file->private_data; do { wait_event(fc->reserved_req_waitq, ff->reserved_req); - spin_lock(&fc->lock); + spin_lock(&fi->lock); if (ff->reserved_req) { req = ff->reserved_req; ff->reserved_req = NULL; req->stolen_file = get_file(file); } - spin_unlock(&fc->lock); + spin_unlock(&fi->lock); } while (!req); return req; @@ -269,16 +270,17 @@ static struct fuse_req *get_reserved_req(struct fuse_conn *fc, static void put_reserved_req(struct fuse_conn *fc, struct fuse_req *req) { struct file *file = req->stolen_file; + struct fuse_inode *fi = get_fuse_inode(file_inode(file)); struct fuse_file *ff = file->private_data; WARN_ON(req->max_pages); - spin_lock(&fc->lock); + spin_lock(&fi->lock); memset(req, 0, sizeof(*req)); fuse_request_init(req, NULL, NULL, 0); BUG_ON(ff->reserved_req); ff->reserved_req = req; wake_up_all(&fc->reserved_req_waitq); - spin_unlock(&fc->lock); + spin_unlock(&fi->lock); fput(file); } diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index f7442bcecbb0..10b20a24f693 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -166,7 +166,10 @@ struct fuse_file { /** Fuse connection for this file */ struct fuse_conn *fc; - /** Request reserved for flush and release */ + /* + * Request reserved for flush and release. + * Modified under relative fuse_inode::lock. + */ struct fuse_req *reserved_req; /** Kernel file handle guaranteed to be unique */