Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp803743rdh; Thu, 23 Nov 2023 20:22:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRHUxNFL1NaLqWmZJnBCh6aYvSgndrNKEanR+giY+FqHrezqqwLoHj++FmSlZUXwfyF4DS X-Received: by 2002:a17:903:11d0:b0:1cc:332f:9e4b with SMTP id q16-20020a17090311d000b001cc332f9e4bmr1949100plh.1.1700799740122; Thu, 23 Nov 2023 20:22:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700799740; cv=none; d=google.com; s=arc-20160816; b=d8T9s/YWqbIEAmsUxCtbF3/u4XOgJyf97FigOnOGxAtBjUVLnLWuRfbONvJJxFjWBR ZtfUwZ7ivu7165HrF1t5MBIn5KBIIJz9n8U4J5r/uR0S06LqyUKPjwx8AqQWRK/145MY 0IERuUA3kkvSyLDqAGLBUFaH7xxmuw93XyyN6C0/ntPDy1vhpNxBe8+uqdOsMf/ym1Jw 7YXqmVPxoQCxjeAHtPtA1ObbnE4TNMxo7vGZAMLF8LfaC3OVfL9zBv40c8xQcimKbSGM IP5ST7a8n2c3xvlt1VcGYPIgbbGmP1ee0nF2POj5q3j+KFl8dvzUfCGqxQsissDjujmP wMlg== 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; bh=dCwwKI/ZvMaJuiYUajfupUbjCwwYrpBZKX+n6Zko4TQ=; fh=1UvAp7GUQSaqrdARWG8zoUWPhj4hWkACxxyVSa4vxWY=; b=f9E2HRfAasQcKmEOOWpolD3QB5EFiyjsK+2fsrbYHUgIfZWVkZ1tpMDCERdWpP68ec 1fOXOcm+zXCVU/wX+gX/bOJntppuQgjJleT/J7XqjHGnCXg5OeuMkmtsDZJfditqfkL0 RVuynMoaMJ28uRDyacWy8F6y5zN6PqzuGZBu+UQt5VwLVkYmuLonHoNqppjCjST3wJae JDT+hjK8uC1aazFRLtNNUecfofuwQz3ZCUYEJazkdE+lgQSMkh54jbpz+GL3Y36TdlYv c7tU9Hx/PpW1HekSs/muRwUX9Vxug0Zqd926ZaUeeRENGmN6XN/rsHkR12Cr2T9kZZYv O1NQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id p8-20020a170902e74800b001cf69216445si2574556plf.392.2023.11.23.20.22.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 20:22:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 6BC0A807D699; Thu, 23 Nov 2023 20:21:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231221AbjKXEUz (ORCPT + 99 others); Thu, 23 Nov 2023 23:20:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231176AbjKXEUx (ORCPT ); Thu, 23 Nov 2023 23:20:53 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D400F10D9; Thu, 23 Nov 2023 20:20:59 -0800 (PST) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1E8B4219C8; Thu, 23 Nov 2023 15:28:12 +0000 (UTC) Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id CEB9B13AAD; Thu, 23 Nov 2023 11:52:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id C2kuMgA9X2U+ZgAAn2gu4w (envelope-from ); Thu, 23 Nov 2023 11:52:32 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 1DC1DA07D9; Thu, 23 Nov 2023 10:22:51 +0100 (CET) Date: Thu, 23 Nov 2023 10:22:51 +0100 From: Jan Kara To: Al Viro Cc: linux-fsdevel@vger.kernel.org, Linus Torvalds , Mo Zou , Jan Kara , linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/9] udf_rename(): only access the child content on cross-directory rename Message-ID: <20231123092251.pjeqi2hyrpmn24wi@quack3> References: <20231122193028.GE38156@ZenIV> <20231122193652.419091-1-viro@zeniv.linux.org.uk> <20231122193652.419091-3-viro@zeniv.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231122193652.419091-3-viro@zeniv.linux.org.uk> Authentication-Results: smtp-out1.suse.de; none X-Rspamd-Server: rspamd1 X-Spam-Level: X-Rspamd-Queue-Id: 1E8B4219C8 X-Spam-Score: -4.00 X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 23 Nov 2023 20:21:19 -0800 (PST) On Wed 22-11-23 19:36:46, Al Viro wrote: > We can't really afford locking the source on same-directory rename; > currently vfs_rename() tries to do that, but it will have to be > changed. The logics in udf_rename() is lazy and goes looking for > ".." in source even in same-directory case. It's not hard to get > rid of that, leaving that behaviour only for cross-directory case; > that VFS can get locks safely (and will keep doing that after the > coming changes). > > Signed-off-by: Al Viro Looks good. Feel free to add: Reviewed-by: Jan Kara Honza > --- > fs/udf/namei.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/fs/udf/namei.c b/fs/udf/namei.c > index 3508ac484da3..fac806a7a8d4 100644 > --- a/fs/udf/namei.c > +++ b/fs/udf/namei.c > @@ -766,7 +766,7 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir, > struct inode *old_inode = d_inode(old_dentry); > struct inode *new_inode = d_inode(new_dentry); > struct udf_fileident_iter oiter, niter, diriter; > - bool has_diriter = false; > + bool has_diriter = false, is_dir = false; > int retval; > struct kernel_lb_addr tloc; > > @@ -789,6 +789,9 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir, > if (!empty_dir(new_inode)) > goto out_oiter; > } > + is_dir = true; > + } > + if (is_dir && old_dir != new_dir) { > retval = udf_fiiter_find_entry(old_inode, &dotdot_name, > &diriter); > if (retval == -ENOENT) { > @@ -878,7 +881,9 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir, > udf_dir_entry_len(&diriter.fi)); > udf_fiiter_write_fi(&diriter, NULL); > udf_fiiter_release(&diriter); > + } > > + if (is_dir) { > inode_dec_link_count(old_dir); > if (new_inode) > inode_dec_link_count(new_inode); > -- > 2.39.2 > -- Jan Kara SUSE Labs, CR