Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2068417rdh; Sat, 25 Nov 2023 12:12:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGlund1ciC7sblbia9trBVSKO5aPZLT9yl5i+oABqAL3q2PzABZAJTHYz1kIuzhhcP5LqPE X-Received: by 2002:a05:6a00:3926:b0:68f:a92a:8509 with SMTP id fh38-20020a056a00392600b0068fa92a8509mr16143112pfb.7.1700943144805; Sat, 25 Nov 2023 12:12:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700943144; cv=none; d=google.com; s=arc-20160816; b=lgUbteE8JOGK4RrFRrpWQ8ebUliQ/jiku6fOPZ0duFyjvki2W/qbk70E4JL7/YOa7r U4BVq+wJhNGbP6WAKuIse65DrS/tKGN4OMK5VpOCD8DCb8IAoKQZTX+cs9onNPNX8psO XoRrHxoPlj14ZvzCM/m3owSRJtIZDjoYI9dHlwnrN3sIizyGzdGeBYKkXulpgD9zXT/0 GAhxG6VC8QBD/dRAtiXPhkY9iYzpltb7pxtC53Oyrp/3xXg+5eEQKhGqAhPR7JBuME6f eV46vE/Jmgt6JhrPn+UgaOynEFjsvwOFEYx4Uy0DAqLsYqDpB5bSssS7/BPblc+FqM6O iDnw== 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=74v1Dg7yBE+4rxKY7xG9GKf0VfPvIUvY43ZeQBhdM3Q=; fh=W6BEtqt7iV8phMzKg0C2MCZmXBORzGPTeuIhW3f8iqY=; b=DdJeCBHXbJxe1I18e06bPQCQWb5668jvItF2i2ptvDVo68J+MYoBkfK49heHO9RCRD KA2s+cF9yDKdMuwqeFaZ+kU2Rss0tDRTmRwhBsxbZ6g+MWw7Hd8Ifm9MlAz1b7xTRZfQ Ksb2MxTmkagueejDF+2v5Bl/MaSwJvQw7XfEEbrsILwvEzJPvF27+jDpjjxndI4su78w ZcQWhwPGioM82ORXR+ITvflBNSCaBIMq8oty/6P8Sp2aYpAJfp0G8ktZY5zrzOMyj35r GBXF8flUZhwzB2/AjQditFGB3lE1/9s5fuXGV3yIHTrP1SoBymoZ1sCoT3+o/GtIehbi KxMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=GCS6BehD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id fc26-20020a056a002e1a00b006910a45a234si6454760pfb.202.2023.11.25.12.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Nov 2023 12:12:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=GCS6BehD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 726CB8096FFC; Sat, 25 Nov 2023 12:12:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232354AbjKYULq (ORCPT + 99 others); Sat, 25 Nov 2023 15:11:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbjKYULm (ORCPT ); Sat, 25 Nov 2023 15:11:42 -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 0FAE7EE; Sat, 25 Nov 2023 12:11:49 -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=74v1Dg7yBE+4rxKY7xG9GKf0VfPvIUvY43ZeQBhdM3Q=; b=GCS6BehDYyWhwoOEelY07lezeA PEyv/KLN0SbEvpS/e06wueHjustBQp/xYqLZrFBS/3TPvRbzUFDNTyvc9r3pO/IldhUTrK/fQAm4p +JRpbgM8V12YVvLT9sQ4pQQMw7PcU4sYLGXoMBLQV+g8B5RcAmO4wkvuhfobl02fnKp9jxWJcEHRH 0hXoxN7L7opPGgrTTHQkgA/gxwWkaiMbkbZoa98I5L58HPsWiheFeHi/m551I8Y1RVKOvc2lyCH79 N6vLzgPViUpshm3YPaMB1n905dumyHQOaRwZEgO8zjaIm4bmWae9rozlgKIkiIFGSNRhWPURjxbhE edwkpGgg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1r6z0F-003A4X-21; Sat, 25 Nov 2023 20:11:47 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Linus Torvalds , Mo Zou , Jan Kara , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/9] ocfs2: Avoid touching renamed directory if parent does not change Date: Sat, 25 Nov 2023 20:11:40 +0000 Message-Id: <20231125201147.753695-2-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231125201147.753695-1-viro@zeniv.linux.org.uk> References: <20231125201015.GA38156@ZenIV> <20231125201147.753695-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 groat.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 (groat.vger.email [0.0.0.0]); Sat, 25 Nov 2023 12:12:14 -0800 (PST) From: Jan Kara The VFS will not be locking moved directory if its parent does not change. Change ocfs2 rename code to avoid touching renamed directory if its parent does not change as without locking that can corrupt the filesystem. Signed-off-by: Jan Kara Signed-off-by: Al Viro --- fs/ocfs2/namei.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index 814733ba2f4b..9221a33f917b 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c @@ -1336,7 +1336,7 @@ static int ocfs2_rename(struct mnt_idmap *idmap, goto bail; } - if (S_ISDIR(old_inode->i_mode)) { + if (S_ISDIR(old_inode->i_mode) && new_dir != old_dir) { u64 old_inode_parent; update_dot_dot = 1; @@ -1353,8 +1353,7 @@ static int ocfs2_rename(struct mnt_idmap *idmap, goto bail; } - if (!new_inode && new_dir != old_dir && - new_dir->i_nlink >= ocfs2_link_max(osb)) { + if (!new_inode && new_dir->i_nlink >= ocfs2_link_max(osb)) { status = -EMLINK; goto bail; } @@ -1601,6 +1600,9 @@ static int ocfs2_rename(struct mnt_idmap *idmap, mlog_errno(status); goto bail; } + } + + if (S_ISDIR(old_inode->i_mode)) { drop_nlink(old_dir); if (new_inode) { drop_nlink(new_inode); -- 2.39.2