Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3176046imu; Wed, 7 Nov 2018 06:21:29 -0800 (PST) X-Google-Smtp-Source: AJdET5eBSLq+LzegNceodW3DVl6qXOuiiX0CeSSvP9+Y1W0fnWpTDu+cLiwwluJBNucZG0LOow3F X-Received: by 2002:a62:3384:: with SMTP id z126-v6mr421189pfz.112.1541600489219; Wed, 07 Nov 2018 06:21:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541600489; cv=none; d=google.com; s=arc-20160816; b=KTdiFD4rsvnTfaGOKCKyGCnSprnU+lahDrVxKjoBoe6V3/kqiKYIHxQq1jrnE0/X6F KShPOVovcKqfjh6QSdWjaAsLphQVRFWvW0qLmBF/NWledZFmxzT+dFstyvtGK0Ptj6Tw F1kBUY/HglBwrjpjjI0VG9wxfTT0p8A8DmOeH1o4IDz+S8SMdSqXHrTliracrWqMeVTb gwxzuW1LBnWPPswmGTO+YxDHN+prQXyAvH3ZQm0XEWQLj6ncs0TYz1zzqNO+NUww/KX4 fMToefNL6JeCSBXl1f4FXJGroxuZO64P/dIS5K702N938Zn3dY4mnn4JPCVHjdIo8Men VM3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=UysIRM1+s3ufQpuvCORn3iMWOhSABN5WwdkCPVKKkrY=; b=u1bikChDc01P30iPMDWRKSatb2nmHM0HpjnScClqDN8rAEV+VoGT0Alk1SC3wv4cW9 KSJvM+OJ6QD8htDVNRxSZd127EXNBTVSImwFqwvKJ0Q6gfdqIf+TYjIkbxhwVOH+XoPj 9kYNxMxU4pYKZ/9ch4JYK3/1fi/6hX0lyQWGG8PWho6QLrhD0mEVCBnCZ9Q67uHSm65Z Eq8eJliHg4+/oWBX+Rm7ks0mj4eDUhkR2Z2d1E31PxDyVkOWgz5048ItLLyX6OyPYstJ 42I3oSgnGzCnzLjag45Xbd24IC6+YhPmH4i7xIFu2Iufw/5RVGSaQTFAJcgWLyQDmx9D LLtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=aMhK7rLB; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i13-v6si709740pgo.128.2018.11.07.06.21.13; Wed, 07 Nov 2018 06:21:29 -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; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=aMhK7rLB; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730618AbeKGXvS (ORCPT + 99 others); Wed, 7 Nov 2018 18:51:18 -0500 Received: from mail-it1-f195.google.com ([209.85.166.195]:33064 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726830AbeKGXvS (ORCPT ); Wed, 7 Nov 2018 18:51:18 -0500 Received: by mail-it1-f195.google.com with SMTP id p11-v6so13189932itf.0 for ; Wed, 07 Nov 2018 06:20:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=UysIRM1+s3ufQpuvCORn3iMWOhSABN5WwdkCPVKKkrY=; b=aMhK7rLBmfZ/wBM+cXqOSVSveFoxRbs7Rji6eFqpzdO2yXFXS+raKYT0jo+GCj6wFU 9x4LAg8Q9q2LWadfey0wwexjLssNSVBJxAlWssdI/s42JphIHGOhu2282MdkHGMZKzrV 7x7DysAfavS3uge2xbx75VEcIREcMkUm2/HQE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=UysIRM1+s3ufQpuvCORn3iMWOhSABN5WwdkCPVKKkrY=; b=mfs+VDN2fI/u8alyUt2PjmOpLMwzmG+LUJ/hiQDPzAooIojUmIfPcdReLZ1QOdTW/s 4XNd+H6ldOc7BbKVSEAIk8wSgzIS3f6jhqzk1Vhd77BbpJ5vti/oGhQuN+OhOHwvLYFZ 6izAq8typSGkf9buEVozxcq3mwioqjh1zFohk8dY6q69BiKZ0ERnzAmtL73lt27bXSMe KRurY/ahs5w+SLEsj9nI+ATSMmW/LOovNuSKxRDcAonvRjROSYU8xrBIyEMAn5uwbivI 07+HHkD8pyfNvhy7ermd3Vq4HoI1AaSPz0OlVaf80fenjRVkocK+jSO6jYfv4u5v20Vw Ik1A== X-Gm-Message-State: AGRZ1gIhgaKG2CDJgxZe34JK485aSzOaJbQjuPYvO5H/SbBYbPic7AOT +xgDxZJDZ38zJWGlMso5WnRybJQ39OmJpATX79xpnIyO X-Received: by 2002:a24:fe88:: with SMTP id w130-v6mr320641ith.69.1541600443235; Wed, 07 Nov 2018 06:20:43 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a6b:ac42:0:0:0:0:0 with HTTP; Wed, 7 Nov 2018 06:20:42 -0800 (PST) X-Originating-IP: [212.96.48.140] In-Reply-To: <154149744356.18189.13444618369955494886.stgit@localhost.localdomain> References: <154149673368.18189.14752124997476502777.stgit@localhost.localdomain> <154149744356.18189.13444618369955494886.stgit@localhost.localdomain> From: Miklos Szeredi Date: Wed, 7 Nov 2018 15:20:42 +0100 Message-ID: Subject: Re: [PATCH 5/6] fuse: Protect fuse_inode::nlookup with fuse_inode::lock To: Kirill Tkhai Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 6, 2018 at 10:44 AM, Kirill Tkhai wrote: > This continues previous patch and introduces the same > protection for nlookup field. It goes as separate patch > since it's separate logic change (sadly, but it looks > impossible to split previous patch more then in this way). Well, the way you can split things up better is to just add the fine grained lock first, which you can do in multiple patches, since all of it is going to be a no-op. And when that is done, remove the coarse grained lock in yet another patch, which hopefully will result in better performance and no other change. > > Signed-off-by: Kirill Tkhai > --- > fs/fuse/dir.c | 4 ++-- > fs/fuse/inode.c | 4 ++-- > fs/fuse/readdir.c | 4 ++-- > 3 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c > index 35f3b3d1e044..ac8519285327 100644 > --- a/fs/fuse/dir.c > +++ b/fs/fuse/dir.c > @@ -222,9 +222,9 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) > fuse_queue_forget(fc, forget, outarg.nodeid, 1); > goto invalid; > } > - spin_lock(&fc->lock); > + spin_lock(&fi->lock); > fi->nlookup++; > - spin_unlock(&fc->lock); > + spin_unlock(&fi->lock); > } > kfree(forget); > if (ret == -ENOMEM) > diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c > index 5f488b019cd9..b8092d49a4b2 100644 > --- a/fs/fuse/inode.c > +++ b/fs/fuse/inode.c > @@ -327,9 +327,9 @@ struct inode *fuse_iget(struct super_block *sb, u64 nodeid, > } > > fi = get_fuse_inode(inode); > - spin_lock(&fc->lock); > + spin_lock(&fi->lock); > fi->nlookup++; > - spin_unlock(&fc->lock); > + spin_unlock(&fi->lock); > fuse_change_attributes(inode, attr, attr_valid, attr_version); > > return inode; > diff --git a/fs/fuse/readdir.c b/fs/fuse/readdir.c > index ab18b78f4755..574d03f8a573 100644 > --- a/fs/fuse/readdir.c > +++ b/fs/fuse/readdir.c > @@ -213,9 +213,9 @@ static int fuse_direntplus_link(struct file *file, > } > > fi = get_fuse_inode(inode); > - spin_lock(&fc->lock); > + spin_lock(&fi->lock); > fi->nlookup++; > - spin_unlock(&fc->lock); > + spin_unlock(&fi->lock); > > forget_all_cached_acls(inode); > fuse_change_attributes(inode, &o->attr, >