From patchwork Fri Apr 27 10:30:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helmut Grohne X-Patchwork-Id: 905646 X-Patchwork-Delegate: dwmw2@infradead.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=intenta.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mDJ1Hd4+"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="DqJLzE61"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40XVk66J24z9s0v for ; Fri, 27 Apr 2018 20:37:18 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HculuwMmASfla44Ilhl2U3s+OppITzz9DUIJsL0mnSU=; b=mDJ1Hd4+PFFMI3 YuoHZcgx/BXn85obRFiW2y3Xz4Yb1LBvCmpjDXXfMyySX5x074ukla4OHvHxRk9RLLYvETBdbnZ2r 5x6WkfeU0Diy3pEmAMfhDw/oVEmtWDUajcJk9u0IJN/LQUB6ZJ1xtso7qDDkHYcE+B0R4UfyMV3x3 N+QfcBATnTqRK/t+AhoQ0ghZowsaIzf1tAUIlVTYDXeTmVefVvtI2P4pq1Ggpx8/i0gu3B0YKZ0r+ PbPw6ViWEyaeZnbkVGvPGqlkbjpI05Ue/kMfr4MtRyxDYcBSAUGPdQ0UIHVysDDENhZbAlUc8U3Sn 1Gv3czS0txkRRqXuq58Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fC0kY-0002D4-CC; Fri, 27 Apr 2018 10:37:10 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fC0eg-0006ls-Cr for linux-mtd@bombadil.infradead.org; Fri, 27 Apr 2018 10:31:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:CC:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=0cGD/Li86bv11xVNErU44dXvlkLXVkI7dHzqRuB/BdI=; b=DqJLzE61OxL0hxAXIPik3VWUr EWPjcDtvT1fl1YPAEHzhFAmvUOSI9EN6UUr4jVAGkyuQgFj7eEhirh6SH+vwkHYobS+af9+m2rG/Q V6ReCiBUffJjJlIItXMEMOxMkDYAYmQCh+DsSBxb4ZhcKn3h137B5bwqZxyp03zryIjcZkuX/MR6h ZSs2e6dVIX0djjqlxlyiYEYMajVFo1KLQR83eNdwfsY1N7QGwaUNR+jbdnOVPwvM46dMy/3QKROJ2 q0kbKHUUWmo22CLnrd6mhSe8sY+TLGzlPtsiJoSqflZwZi9/cgiSCFn++jeshweNG9zgppUc2IZ7O zYJ6LBdUQ==; Received: from mail.intenta.de ([178.249.25.132]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fC0ed-00054D-FU for linux-mtd@lists.infradead.org; Fri, 27 Apr 2018 10:31:04 +0000 Received: from [10.10.16.42] (port=31136 helo=ICSMA001.intenta.de) by mail.intenta.de with esmtps (TLSv1.2:AES256-SHA:256) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1fC0eL-0000F5-0A; Fri, 27 Apr 2018 12:30:45 +0200 Received: from localhost (10.10.136.106) by ICSMA001.intenta.de (10.10.16.42) with Microsoft SMTP Server (TLS) id 15.0.1365.1; Fri, 27 Apr 2018 12:30:44 +0200 X-CTCH-RefID: str=0001.0A0C0206.5AE2FBD5.0039, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 Date: Fri, 27 Apr 2018 12:30:44 +0200 From: Helmut Grohne To: David Woodhouse , Subject: [PATCH 2/3] jffs2: jffs2_iget defer f->sem acquisition Message-ID: <95327ddd01e86d0160c2d678f4306a737cb6a085.1524823321.git.h.grohne@intenta.de> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-Originating-IP: [10.10.136.106] X-ClientProxiedBy: ICSMA001.intenta.de (10.10.16.42) To ICSMA001.intenta.de (10.10.16.42) X-EsetResult: clean, is OK X-EsetId: 47C16134FCD33537148C3F X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180427_063103_666990_549AD44C X-CRM114-Status: UNSURE ( 9.27 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [178.249.25.132 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org At the point where f->sem is taken, we know that we have a locked I_NEW inode. Since jffs2_iget is the only function processing I_NEW inodes and iget_locked blocks on I_NEW inodes, we know that we are the only user of the inode until we unlock_new_inode it. Since 7aaea7605c0 ("jffs2: fix unbalanced locking"), jffs2_do_read_inode no longer touches f->sem and does not make the inode visible to others either. Thus we can call it without f->sem acquired. Nextup, inode->i_mode is protected until unlock_new_inode. After deferring the locking, we can decide upon the proper lock class depending on inode->i_mode. Signed-off-by: Helmut Grohne Cc: Peter Zijlstra Reviewed-by: Richard Weinberger --- fs/jffs2/fs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index eab04eca95a3..89a10b398d00 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c @@ -270,13 +270,15 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) c = JFFS2_SB_INFO(inode->i_sb); jffs2_init_inode_info(f); - mutex_lock(&f->sem); ret = jffs2_do_read_inode(c, f, inode->i_ino, &latest_node); if (ret) goto error; inode->i_mode = jemode_to_cpu(latest_node.mode); + + mutex_lock(&f->sem); + i_uid_write(inode, je16_to_cpu(latest_node.uid)); i_gid_write(inode, je16_to_cpu(latest_node.gid)); inode->i_size = je32_to_cpu(latest_node.isize);