Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp942659rwd; Thu, 1 Jun 2023 08:27:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5R8o1mDLmX3sA3V2bfqWfYNHWP5drOG2jMhsxlGqGGLwgzyTtI0zAJUm1UN5Is/IZTAk7X X-Received: by 2002:a17:902:e54e:b0:1b1:84c5:8adb with SMTP id n14-20020a170902e54e00b001b184c58adbmr2887241plf.40.1685633228598; Thu, 01 Jun 2023 08:27:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685633228; cv=none; d=google.com; s=arc-20160816; b=Z0Q2TUWX1so/MYfX4xQ5LCNkuPs4m2f7JlpEuhsPlU461U7IVMuEmbEOqY0zdMsN5O O4UA/rPpmUGjRtkmll1gegKklpp2yzRBCamVYfxsQfX1NlQ5Nseu1nSjK5iB9zn+fXua rue5sjtzHs+iVt74Y/Ly3SfS+c5u2xEfEdAi3OkO4ZiUQWOf/HxbZFrp0yAzByDBEals bnMKOPHBkcftsQ4pHLuc5uCYwVHxDz0L2khJkfwHLbYzGeRPKTnwdXSzJjTpNDZfd0Az S2tMHOlCkXbew8ZM7zjyNJI6tD1iXNX7o2BJLLdkbLKglB72LkYm/uWlEXRcZkMk1fmW MD2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=NMMC3ehgaWslWeASfjcmQ+SuyyB+zQPCwx9GtXbqe3Y=; b=TVOSk2s/f1s2pMq9ngiwcOzoM8QPhJpmTKvZiSYGzNo5Cu5aKNhvBpA+tzopIKmL2X bMu24LL1lPJszmU+PvhT74PqRUVRi9GxOVTvfm9/xAZOID+0NLH58uDV8QmTLSBv5vnp /oLJk7U8SSgBswckS9dgpS2ysD/OC1RSAcMSFElUeuQR5KGsVNgcm1FhnUdPtfwvwbq8 nBOy9bxw3iLK1d0XK3d+DSxy67+rd682gUaqvB9uLmSRuVNSkMuvkWYZ0q3SMWiYUo73 rq0J2W5LLv/t1sq21AQPdcEDrZXFg/qRcuEeI9xlLnjMsCYdI20waQdrtlKF89q43bG2 ddJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=WjHviSuQ; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u5-20020a170902b28500b001afb96f4b8fsi2812585plr.519.2023.06.01.08.26.52; Thu, 01 Jun 2023 08:27:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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.cz header.s=susede2_rsa header.b=WjHviSuQ; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231607AbjFAPZN (ORCPT + 99 others); Thu, 1 Jun 2023 11:25:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234227AbjFAPYx (ORCPT ); Thu, 1 Jun 2023 11:24:53 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADE8F136; Thu, 1 Jun 2023 08:24:51 -0700 (PDT) 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-out2.suse.de (Postfix) with ESMTPS id 439421FDAF; Thu, 1 Jun 2023 15:24:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1685633090; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NMMC3ehgaWslWeASfjcmQ+SuyyB+zQPCwx9GtXbqe3Y=; b=WjHviSuQYqQL5ww/WGZrxQ9IaSK+faKZeFG2YF8j1TneF9hscLLx1tqg0Bx8EgldewEIHi PBEV92dYJc9WiX/PL/Fl3kvtNUHQ7iVPTlmwqgOKI3ucMytqhW2aWsSuZSvUhP7hf/zFKn KNnBc370aTHSrj3tbsurPTnkkfqoXmA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1685633090; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NMMC3ehgaWslWeASfjcmQ+SuyyB+zQPCwx9GtXbqe3Y=; b=9kcmzqr/0hZ1iA49qNNzf1cUeGB4/rjsaKBaQ3EqCfnWgDiqMRyj80AFflpKW9e0YgPeZl nKRmR487X7h99zBQ== 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 3109D139B7; Thu, 1 Jun 2023 15:24:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 7FLvC0K4eGQuawAAMHmgww (envelope-from ); Thu, 01 Jun 2023 15:24:50 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 91EB1A0754; Thu, 1 Jun 2023 17:24:49 +0200 (CEST) Date: Thu, 1 Jun 2023 17:24:49 +0200 From: Jan Kara To: Christian Brauner Cc: Jan Kara , Al Viro , linux-fsdevel@vger.kernel.org, Miklos Szeredi , "Darrick J. Wong" , Ted Tso , Jaegeuk Kim , linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, stable@vger.kernel.org Subject: Re: [PATCH v2 4/6] fs: Establish locking order for unrelated directories Message-ID: <20230601152449.h4ur5zrfqjqygujd@quack3> References: <20230601104525.27897-1-jack@suse.cz> <20230601105830.13168-4-jack@suse.cz> <20230601-gebracht-gesehen-c779a56b3bf3@brauner> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230601-gebracht-gesehen-c779a56b3bf3@brauner> 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-ext4@vger.kernel.org On Thu 01-06-23 15:58:58, Christian Brauner wrote: > On Thu, Jun 01, 2023 at 12:58:24PM +0200, Jan Kara wrote: > > Currently the locking order of inode locks for directories that are not > > in ancestor relationship is not defined because all operations that > > needed to lock two directories like this were serialized by > > sb->s_vfs_rename_mutex. However some filesystems need to lock two > > subdirectories for RENAME_EXCHANGE operations and for this we need the > > locking order established even for two tree-unrelated directories. > > Provide a helper function lock_two_inodes() that establishes lock > > ordering for any two inodes and use it in lock_two_directories(). > > > > CC: stable@vger.kernel.org > > Signed-off-by: Jan Kara > > --- > > fs/inode.c | 42 ++++++++++++++++++++++++++++++++++++++++++ > > fs/internal.h | 2 ++ > > fs/namei.c | 4 ++-- > > 3 files changed, 46 insertions(+), 2 deletions(-) > > > > diff --git a/fs/inode.c b/fs/inode.c > > index 577799b7855f..4000ab08bbc0 100644 > > --- a/fs/inode.c > > +++ b/fs/inode.c > > @@ -1103,6 +1103,48 @@ void discard_new_inode(struct inode *inode) > > } > > EXPORT_SYMBOL(discard_new_inode); > > > > +/** > > + * lock_two_inodes - lock two inodes (may be regular files but also dirs) > > + * > > + * Lock any non-NULL argument. The caller must make sure that if he is passing > > + * in two directories, one is not ancestor of the other. Zero, one or two > > + * objects may be locked by this function. > > + * > > + * @inode1: first inode to lock > > + * @inode2: second inode to lock > > + * @subclass1: inode lock subclass for the first lock obtained > > + * @subclass2: inode lock subclass for the second lock obtained > > + */ > > +void lock_two_inodes(struct inode *inode1, struct inode *inode2, > > + unsigned subclass1, unsigned subclass2) > > +{ > > + if (!inode1 || !inode2) > > I think you forgot the opening bracket... > I can just fix this up for you though. Oh, yes. Apparently I forgot to rerun git-format-patch after fixing up this bit. I'm sorry for that. The patch series has survived full ext4 fstests run on my end. Honza -- Jan Kara SUSE Labs, CR