Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp27661imm; Thu, 10 May 2018 14:50:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZplaROOAggrUONVw8Fm1b4yeu+CgRJcrIzTbZoszegc4i3WWqoGcLDBVvCCnu9BNCjIMYNY X-Received: by 2002:a17:902:22a:: with SMTP id 39-v6mr2957008plc.128.1525989022311; Thu, 10 May 2018 14:50:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525989022; cv=none; d=google.com; s=arc-20160816; b=LfnUfdTA7ibFxf6aRjJKheridb0LMk4FT/dAoKn+aj2lRWNAQf50ZSHz7YIZErmEWA L6w0E9BYZE8pb7ZrLcUNtmLvmWMKiU9K/Q5zSvYVeGfOqrraxrWprtNlu5TMS0bc4cCK PmMLCqnKKXKrOQPPEqWNBJwhhppyOKN9NmAC83Kph1lMUQafR0f8k/SzZbkCVwK3t4Ye pJ8BGKcNtd5wykoUHSfz/LJ+AN4UoSrCiqfZXq0QPFPnGAk3L0JauodQwPXIW/45uqei wLukk+ck/G5/BYxxbLfDjKCu2UVNe4uL3+S0hMOgq6P6RYDv9ZQe6imVn10R6fpbMxrk zvKQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=IW6dvcmPDdlot/SmyBneRUA+XoefhNQszaN7bcD0lDg=; b=ltI7D7X4fhTW6xtNgosB5qfPLeaPyCqzcodoLXF4Y8LRoBYQYG/mdRoJ6o9CzqyMvI KEhaFAlnJb5GRhzNcP3i0Wtx9qClVattXYdhD0UoaHHExFDX2HCKJtywvguC455HgRDv KaISEfEcvmDLqww9gWDDzbZtbYE/Dm6T0T9OSf6+KlaxTqQoGFcEVcenwisFO6AgYDmF kPNk0fod+GPzpbEImQGy+2eQeTi0XllXhb2M4WiKXTd+Dmb0LEQmCDi+CYzpdY0ZOPlt eQgkhvDGoKkqwng3p6sQokG9hQnSS8IU+Wc4aZmkKGJPjdpoCfRI76CzcmQYn1BCFxA7 kLwg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6-v6si1727140pfi.147.2018.05.10.14.50.07; Thu, 10 May 2018 14:50:22 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752631AbeEJVtq (ORCPT + 99 others); Thu, 10 May 2018 17:49:46 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47084 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752374AbeEJVtp (ORCPT ); Thu, 10 May 2018 17:49:45 -0400 Received: from akpm3.svl.corp.google.com (unknown [104.133.9.71]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 2C5575AA; Thu, 10 May 2018 21:49:45 +0000 (UTC) Date: Thu, 10 May 2018 14:49:44 -0700 From: Andrew Morton To: Larry Chen Cc: mfasheh@versity.com, jlbec@evilplan.org, linux-kernel@vger.kernel.org, ocfs2-devel@oss.oracle.com Subject: Re: [PATCH] ocfs2: ocfs2_inode_lock_tracker does not distinguish lock level Message-Id: <20180510144944.d0842b82b99a471dbbc745ad@linux-foundation.org> In-Reply-To: <20180510053230.17217-1-lchen@suse.com> References: <20180510053230.17217-1-lchen@suse.com> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 10 May 2018 13:32:30 +0800 Larry Chen wrote: > ocfs2_inode_lock_tracker as a variant of ocfs2_inode_lock, > is used to prevent deadlock due to recursive lock acquisition. > > But this function does not distinguish > whether the requested level is EX or PR. > > If a RP lock has been attained, this function > will immediately return success afterwards even > an EX lock is requested. > > But actually the return value does not mean that > the process got a EX lock, because ocfs2_inode_lock > has not been called. > > When taking lock levels into account, we face some different situations. > 1. no lock is held > In this case, just lock the inode and return 0 > > 2. We are holding a lock > For this situation, things diverges into several cases > > wanted holding what to do > ex ex see 2.1 below > ex pr see 2.2 below > pr ex see 2.1 below > pr pr see 2.1 below > > 2.1 lock level that is been held is compatible > with the wanted level, so no lock action will be tacken. > > 2.2 Otherwise, an upgrade is needed, but it is forbidden. > > Reason why upgrade within a process is forbidden is that > lock upgrade may cause dead lock. The following illustrate > how it happens. > > process 1 process 2 > ocfs2_inode_lock_tracker(ex=0) > <====== ocfs2_inode_lock_tracker(ex=1) > > ocfs2_inode_lock_tracker(ex=1) > Nice changelog, but it gives no information about the severity of the bug: how often does it hit and what is the end-user impact. This info is needed so that I and others can decide which kernel version(s) need the patch, so please always include it when fixing a bug, thanks.