Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1213567pxm; Wed, 23 Feb 2022 21:24:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwfk0RYdrSwgD6gzxFBuXJqZJLQSPNqgS0EZojLVZexOCFvjD76jZBPAzvpvtIrLy9CIkbi X-Received: by 2002:aa7:cf06:0:b0:405:e0c8:8b5d with SMTP id a6-20020aa7cf06000000b00405e0c88b5dmr705842edy.367.1645680290414; Wed, 23 Feb 2022 21:24:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645680290; cv=none; d=google.com; s=arc-20160816; b=wyUgwy1QDYyyyHbKA6xx1WneCp79CxzNfdhni7fHDLIZzX/uOMGYsTJcnFKokwqnZj TGoIk3E7dWDWx/UGkgvTZshne3wjyixSThb3ncbeT57jojQqnhak80EF5MRc1PJKQgWt /B4CHTBdQbC7Zg7cT87Rlip59yQ7Ek37duEQyw9//hKdwf6dFQeGd87jpf8yAAAUObCP BzbUjl7CVPCahaxhl/V3/2WK57e/8hZnIeOtLjaTBuU4xY/9cAkp6Iw0vnxpYSe96yCS ynTwJodSdEz0NAp/udmN4SIehyjCtMckDdZ/6zA8Bo92Fp/3dJkJkAM8/DAll0Uf9IEZ kc6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding:dkim-signature :dkim-signature; bh=fvie5WjINF2XGuRYy4JLCTZ9z0jDxYZyBje3chiMYAU=; b=wPukYRWGdX4p4qr0FXM/30C50DLRsvS/f/1bjylUmteNkThSfNuFRX8BodbplrDVxH S+Oz6W3cwvhWthn3y7H1gMlsvmp5PiMeKzWRmGU7mbfPT9exIjPGGbuYcqGvPbjazDvA uRZkITGn6IME8/cx3UIa+TwBET1JFSt0qZyiGc5M3RV+OjD8NWiUfEx4aL2DVY148dHF /Z0AqH4GuGdm6th3oR2pxdSPrCNavW6J/VTZFW0/purgwFueCjWqym03I++QBQbpuQrE lAE6FlMYYUdyBjkBwjpgjFIAQPs1hLpR7jaG9d8oxlreBQAhgsqcHYtH5lzopGJJCiNB 4w/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="1l/5mEs+"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=PgnnkBfP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd4si1001764ejc.962.2022.02.23.21.24.28; Wed, 23 Feb 2022 21:24:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="1l/5mEs+"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=PgnnkBfP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230084AbiBXFJN (ORCPT + 99 others); Thu, 24 Feb 2022 00:09:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229715AbiBXFJN (ORCPT ); Thu, 24 Feb 2022 00:09:13 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B78E9165C26; Wed, 23 Feb 2022 21:08:43 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3A53A212B8; Thu, 24 Feb 2022 05:08:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1645679322; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fvie5WjINF2XGuRYy4JLCTZ9z0jDxYZyBje3chiMYAU=; b=1l/5mEs+6B3/VXgYICSwyNHJ7RHI1SknXQ/8jjpB7rdKIdJugA4IqQsyOM1TCV9QVONhfH Xyc1z/4fiv56fsMF5dVoEqrD2GG/IRZDdTugEgqLsIgtG+XQrfzewvJpGDqUUpMuBZFC2d lHl0Q/7b06PtV/VUSuswlJ2wm6M8vtU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1645679322; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fvie5WjINF2XGuRYy4JLCTZ9z0jDxYZyBje3chiMYAU=; b=PgnnkBfPxMfuL4hmd2LHwGDkf7ie5M5so/ATJb1QG4DdwCINRTFMhTZKevWqG4kJTmgScR 2ggPnpttKn2uIrBA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1B63813343; Thu, 24 Feb 2022 05:08:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 90EwMtcSF2JTBQAAMHmgww (envelope-from ); Thu, 24 Feb 2022 05:08:39 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "NeilBrown" To: "J. Bruce Fields" Cc: "Al Viro" , "Linux NFS Mailing List" , linux-fsdevel@vger.kernel.org, "LKML" , "Daire Byrne" , "Andreas Dilger" Subject: Re: [PATCH/RFC] VFS: support parallel updates in the one directory. In-reply-to: <20220222190751.GA7766@fieldses.org> References: <164549669043.5153.2021348013072574365@noble.neil.brown.name>, <20220222190751.GA7766@fieldses.org> Date: Thu, 24 Feb 2022 16:08:36 +1100 Message-id: <164567931673.25116.15009501732764258663@noble.neil.brown.name> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 23 Feb 2022, J. Bruce Fields wrote: > For what it's worth, I applied this to recent upstream (038101e6b2cd) > and fed it through my usual scripts--tests all passed, but I did see > this lockdep warning. >=20 > I'm not actually sure what was running at the time--probably just cthon. >=20 > --b. >=20 > [ 142.679891] =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D > [ 142.680883] WARNING: possible circular locking dependency detected > [ 142.681999] 5.17.0-rc5-00005-g64e79f877311 #1778 Not tainted > [ 142.682970] ------------------------------------------------------ > [ 142.684059] test1/4557 is trying to acquire lock: > [ 142.684881] ffff888023d85398 (DENTRY_PAR_UPDATE){+.+.}-{0:0}, at: d_lock= _update_nested+0x5/0x6a0 > [ 142.686421]=20 > but task is already holding lock: > [ 142.687171] ffff88801f618bd0 (&type->i_mutex_dir_key#6){++++}-{3:3}, at:= path_openat+0x7cb/0x24a0 > [ 142.689098]=20 > which lock already depends on the new lock. >=20 > [ 142.690045]=20 > the existing dependency chain (in reverse order) is: > [ 142.691171]=20 > -> #1 (&type->i_mutex_dir_key#6){++++}-{3:3}: > [ 142.692285] down_write+0x82/0x130 > [ 142.692844] vfs_rmdir+0xbd/0x560 > [ 142.693351] do_rmdir+0x33d/0x400 Thanks. I hadn't tested rmdir :-) "rmdir" and "open(O_CREATE)" take these locks in the opposite order. I think the simplest fix might be to change the inode_lock(_shared) taken on the dir in open_last_Lookups() to use I_MUTEX_PARENT. That is consistent with unlink and rmdir etc which use I_MUTEX_PARENT on the parent. open() doesn't currently use I_MUTEX_PARENT because it never needs to lock the child. But as it *is* a parent that is being locked, using I_MUTEX_PARENT probably make more sense. --- a/fs/namei.c +++ b/fs/namei.c @@ -3513,9 +3513,9 @@ static const char *open_last_lookups(struct nameidata *= nd, } shared =3D !!(dir->d_inode->i_flags & S_PAR_UPDATE); if ((open_flag & O_CREAT) && !shared) - inode_lock(dir->d_inode); + inode_lock_nested(dir->d_inode, I_MUTEX_PARENT); else - inode_lock_shared(dir->d_inode); + inode_lock_shared_nested(dir->d_inode, I_MUTEX_PARENT); dentry =3D lookup_open(nd, file, op, got_write); if (!IS_ERR(dentry) && (file->f_mode & FMODE_CREATED)) fsnotify_create(dir->d_inode, dentry); Thanks, NeilBrown