Received: by 2002:a05:7412:e79e:b0:f3:1519:9f41 with SMTP id o30csp145552rdd; Wed, 22 Nov 2023 11:38:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGgM8eHjYjD3arPqRHExeHQvgJ09hQBKnyHc5ItFnUmaxPuwYoACHJp5MgJYEewlUsCK+Ez X-Received: by 2002:a05:6808:14ce:b0:3ae:2bc8:2b93 with SMTP id f14-20020a05680814ce00b003ae2bc82b93mr4616993oiw.3.1700681901206; Wed, 22 Nov 2023 11:38:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700681901; cv=none; d=google.com; s=arc-20160816; b=Rs+v/itXyHi+kbqaAD31PMrK4k8PXWolbj9IcA4Vh6+I1yUc3HrnVLs6LBeiXQQsOg 779Kzv/jhi3I8d9YEW9vEiYw9BCYi2Z9vs1um2tv9m0Z3gMeMQVG0pzGgaql6PJKywVd W+kZE3lzpHkH/4LshU3F0/PhMjvlyc5/Pc+wtbOWrw53B5PfKM/vSt+/srhSs7AJdyU6 apRNnhJ+Y91lAq5rVF/gxhRCXdmPrkMsA/gESDRQimuPlVwU9PMSquSkmpUvNPZY6KEt 2tYf0gd4llN9Mw1gT0llRuhmP71u5KC0EgHOdlEel7DSq9XDCvM/Gq7zasclN1m9uUqz q4ZA== 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:date:subject:cc:to:from :dkim-signature; bh=rNmpOBKWoYfvVrhEukRAAHBSo1Q96GuxaczyMAbV7AU=; fh=W6BEtqt7iV8phMzKg0C2MCZmXBORzGPTeuIhW3f8iqY=; b=dX0yq23eBO+vE9+HHBrqvYRaEYXwpSEMWRcdJw2pePBfNPaRXhZyayJKkyDuyXCCJl BYJNNwMSjeH1asSvPIbQQuNvH1HcIsTxXJAJhJN8zVW6ZQWaoF6Mww+IuVL64eyP75AN p56QOLsnp5dR5jOeVZQqVfgqP6dutko+c5FY4rkvN5iShWOGtnT0UCzW2HcsTus9SWiD j3qheiTa865U4lbl4binYBy03IlKTkaAYLt5tVuhAcJqPVaOO1alhAkfyJ9arIrGzLNV imqxN1mke/TUnOelTT/hvd63HEmPiE/bd4y0ceXaF1Ck736uAh4S9PbsVBxZgR6N2tgZ bClQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=pG8jo4TP; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id j9-20020a635509000000b005c1e7583b8csi118959pgb.96.2023.11.22.11.38.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 11:38:21 -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; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=pG8jo4TP; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id CEA44825B520; Wed, 22 Nov 2023 11:37:59 -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 S1344585AbjKVThL (ORCPT + 99 others); Wed, 22 Nov 2023 14:37:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344421AbjKVTg7 (ORCPT ); Wed, 22 Nov 2023 14:36:59 -0500 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D47A1AE; Wed, 22 Nov 2023 11:36:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=rNmpOBKWoYfvVrhEukRAAHBSo1Q96GuxaczyMAbV7AU=; b=pG8jo4TPLP4OImKO1wWH4A1imn jY0RlChB5b9gcRdaSNvfTTygnHegbVfpY3EmJWx5Z6c1WUqI/Io1RU5pcNeH22yLPk54ZUe2T4eCf o7jGAJSzH3FksmBNhRWpSPA56egeiD7tUjiBFz/FIk6xNOI0PDTRmIgwzQqwuGaNueXaYKsGdKZgX LTNxN7fbMbs0T4dweEgv9ND+T8geZzkwX3NNjV1vAmzeCHrfSl3wL38z8I5eEhr/8ri0PHe5NfpVf tZwIHghZnX3G1D5CBeRIaW52QlCUgo4GEXaw/XBli2BF+5eLGwQU6PjNGOGHOtOm66D50TaHNVpnG ukkxBUZw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1r5t1o-001l1i-2l; Wed, 22 Nov 2023 19:36:52 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Linus Torvalds , Mo Zou , Jan Kara , linux-kernel@vger.kernel.org Subject: [PATCH 3/9] udf_rename(): only access the child content on cross-directory rename Date: Wed, 22 Nov 2023 19:36:46 +0000 Message-Id: <20231122193652.419091-3-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231122193652.419091-1-viro@zeniv.linux.org.uk> References: <20231122193028.GE38156@ZenIV> <20231122193652.419091-1-viro@zeniv.linux.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Al Viro X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, 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]); Wed, 22 Nov 2023 11:38:00 -0800 (PST) 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 --- 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