Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3157756ybb; Mon, 6 Apr 2020 03:22:16 -0700 (PDT) X-Google-Smtp-Source: APiQypK2dbqL07K8YJA6lXTmptE+Ke2WVm2xI7mqQS+u6VZ3TYEf2iWdsBPnjkzcJwBraGzEA7Ob X-Received: by 2002:a4a:1ec3:: with SMTP id 186mr16338913ooq.66.1586168536209; Mon, 06 Apr 2020 03:22:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586168536; cv=none; d=google.com; s=arc-20160816; b=yZgO+FMb4tDXZ+10VoNjXGsBgxmAcPQ08ghQumyVMKRdHn//r+Z0pvYI5+L/Y8Ougt 5QRb5NvrW9PYnF18Z9sOHgmerL3Mvc79dzsZcu+Bp6Ynnz5xTf/Po+VBUPJhG/+28LLZ Bjnkr5JFmqWeioOQirh4Xe+PlqTt4OLJKphSCykU97ntPMA0y+ZbnKFmu1ooOYdLxgcq Bt36TLpRd+Xp40HxYTzySJ87hkFsnHCNa76CXpx8WUsf3yubwmC7NU27b8BQt/+ber0+ ZmkYQyxwvFyO2+ftQSWe4yKzpDhTuZVEk175cUvct5rHzx1Lhr6JgDA7tWFLLw8ne7wM 5D1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Qq/suq2Uxj9GT2YCqXve2nKy0u6kkhYE3EiPoZTfees=; b=nUgg1571RxSR+R3kf6qkvTF10pRI+CSfoaMqLwfBkZMttTJkQYT85wkO+ccNj4IQ5K oxp9mWPQlSUFI973Vg1gaLTVZPXW6e8Adb6V+SnamxoXKgzde1fITiHgsahEVWrVu+1l pcjejAfJkORhz6SHUc5OzEMow/AxRuy2QKUYykKYy4qOmkdfP1fMj5AzXQwsQHXGnLfr uv9j/DPws/qelijG4akcNFffQiCmwUdmApdX8xC1s6dP59zUiRyi9+HGRPLAw6eY1oA5 U+mNb5lWrW1nwO9biFjRp/ReWEgFsAKJ3FmZzk2eSI+EZf4ajkpksqcCtJte23+EJVE0 uH9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 e6si7703367otr.262.2020.04.06.03.21.55; Mon, 06 Apr 2020 03:22:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726825AbgDFKVu (ORCPT + 99 others); Mon, 6 Apr 2020 06:21:50 -0400 Received: from mx2.suse.de ([195.135.220.15]:47766 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726675AbgDFKVu (ORCPT ); Mon, 6 Apr 2020 06:21:50 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4AAF5AD1E; Mon, 6 Apr 2020 10:21:48 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 619581E1244; Mon, 6 Apr 2020 12:21:48 +0200 (CEST) Date: Mon, 6 Apr 2020 12:21:48 +0200 From: Jan Kara To: "J. R. Okajima" Cc: Jan Kara , linux-ext4@vger.kernel.org Subject: Re: [PATCH v2] ext2: Silence lockdep warning about reclaim under xattr_sem Message-ID: <20200406102148.GC1143@quack2.suse.cz> References: <20200225120803.7901-1-jack@suse.cz> <30602.1586151377@jrobl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <30602.1586151377@jrobl> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon 06-04-20 14:36:17, J. R. Okajima wrote: > Jan Kara: > > Lockdep complains about a chain: > > sb_internal#2 --> &ei->xattr_sem#2 --> fs_reclaim > > > > and shrink_dentry_list -> ext2_evict_inode -> ext2_xattr_delete_inode -> > > down_write(ei->xattr_sem) creating a locking cycle in the reclaim path. > > This is however a false positive because when we are in > > ext2_evict_inode() we are the only holder of the inode reference and > > nobody else should touch xattr_sem of that inode. So we cannot ever > > block on acquiring the xattr_sem in the reclaim path. > > > > Silence the lockdep warning by using down_write_trylock() in > > ext2_xattr_delete_inode() to not create false locking dependency. > > v5.6 is released. > But I cannot see this patch applied. Sad. It will go in for this merge window. Since this was just a problem with lockdep reporting, there's no hurry in pushing it... > Anyway I am wondering whether acquiring xattr_sem in > ext2_xattr_delete_inode() is really necessary or not. > It is necessary because this function refers and clears i_file_acl, > right? > > But this function handles the removed (nlink==0) and unused inodes only. > If nobody else touches xattr_sem as you wrote, then it is same to > i_file_acl, isn't it? Can we replace xattr_sem (only here) by memory > barrier, or remove xattr_sem from ext2_xattr_delete_inode()? It is not really necessary because the inode is completely private to the process evicting it at that point. So any inode-local locking is not going to serialize anything. But from a maintenance point of view it is better to acquire the lock so that possible assertions that lock is held in some helper functions don't barf or for the case the function gets used in a different code path in the future. Honza -- Jan Kara SUSE Labs, CR