From patchwork Mon Jan 16 08:55:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13102753 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65D10C46467 for ; Mon, 16 Jan 2023 08:55:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3B2DF6B0074; Mon, 16 Jan 2023 03:55:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 315A16B0075; Mon, 16 Jan 2023 03:55:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18DCE6B0078; Mon, 16 Jan 2023 03:55:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 048D66B0074 for ; Mon, 16 Jan 2023 03:55:45 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C81C8407FD for ; Mon, 16 Jan 2023 08:55:44 +0000 (UTC) X-FDA: 80360054208.26.CDC2517 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf07.hostedemail.com (Postfix) with ESMTP id B335A40012 for ; Mon, 16 Jan 2023 08:55:41 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Jv+WhniY; spf=none (imf07.hostedemail.com: domain of BATV+12421fe7f975503e585d+7085+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+12421fe7f975503e585d+7085+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673859342; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=OG2B/ZSWByZRN4fMNjXk/odq7YMNkG/R7DDN5iMhUtQ=; b=mD3H/nHM1CeApzZpwQdxUA2q3Lfd6yHpqNgKA7oXlVuOtgi//sQS+xJ5Kj3M2XDqvw12aO 5kvSGnGouMOpSIsz6/oZy3OfTVip+xW5AlpP2IuxWzjTTAPucexrX5MMa6nabOykP0pB/S zZhFoxzOgFHtVwP7E9v1Mjo2k9NiMW0= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Jv+WhniY; spf=none (imf07.hostedemail.com: domain of BATV+12421fe7f975503e585d+7085+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+12421fe7f975503e585d+7085+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673859342; a=rsa-sha256; cv=none; b=xkUbiCTWmpfqghGQZ0mopZuQDgksmCu/lYXcCoS1JeAjlnyYZZ2CVervg5Ab3AZLJjgMKW fkcqPD5rNrlPQglheZ6GLp55jcILmZNNgjl2saK8kXMySXLvhaytMylwukumTBod6MYGS+ SmyANYQ5YVUvPc3U1rAA0LujMT9Vv68= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=OG2B/ZSWByZRN4fMNjXk/odq7YMNkG/R7DDN5iMhUtQ=; b=Jv+WhniY9VGch/zC8+PJm+chhT /+rHupK5uBALMlQaZjsepoMcl0mFl8uuNrYuXeGgWwGj280ui4kquded1Op5jmigdG0CjbLd+GpKk XFjxxRaTMGGMYG/Opr2gTEVG87otTdyk3f8TYMf9cI3e7X5AhB4ud2Di9Ptan7y6agqCRO2RhWRsv Hhx+g/gzwuId7dh/3Wc8WfDcAdvNfyWswpDFfQCatswiEOV9LxxHcAHtjbj0lRK9O/lYSyK3ZTARP 3MFPat1picSmsva4N/FL6ON2qSYkYLSo9kJf0HEAU3aCjtxxKnU9sMTH3fcrzJ3qOIfIKQjh4fQoa FeKc/8kQ==; Received: from [2001:4bb8:19a:2039:c63c:c37c:1cda:3fb2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pHLH6-009Eea-02; Mon, 16 Jan 2023 08:55:28 +0000 From: Christoph Hellwig To: Andrew Morton , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Cc: ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 1/6] minix: fix error handling in minix_delete_entry Date: Mon, 16 Jan 2023 09:55:18 +0100 Message-Id: <20230116085523.2343176-2-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116085523.2343176-1-hch@lst.de> References: <20230116085523.2343176-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B335A40012 X-Rspam-User: X-Stat-Signature: uo58piegspx919axn9c8oe3587z49aw9 X-HE-Tag: 1673859341-753780 X-HE-Meta: U2FsdGVkX18Lz5aGcxk8AO4zgPXLllPbrHBNAewCwchpUXEG3OaXNxOo73eIulW8H+dUmVzMoR3bnB7jqAii83ZeB4+D7635+khFoA4KTZVjEWCK0Dj3ozZ3i7Ajt374Esrc4VicxhvcOltoaU5eL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ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: If minix_prepare_chunk fails, updating c/mtime and marking the dir inode dirty is wrong, as the inode hasn't been modified. Note that this moves the dir_put_page call later, but that matches other uses of this helper in the directory code. Signed-off-by: Christoph Hellwig --- fs/minix/dir.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/minix/dir.c b/fs/minix/dir.c index dcfe5b25378b54..a8e76284cb71ec 100644 --- a/fs/minix/dir.c +++ b/fs/minix/dir.c @@ -297,18 +297,19 @@ int minix_delete_entry(struct minix_dir_entry *de, struct page *page) lock_page(page); err = minix_prepare_chunk(page, pos, len); - if (err == 0) { - if (sbi->s_version == MINIX_V3) - ((minix3_dirent *) de)->inode = 0; - else - de->inode = 0; - err = dir_commit_chunk(page, pos, len); - } else { + if (err) { unlock_page(page); + goto out_put_page; } - dir_put_page(page); + if (sbi->s_version == MINIX_V3) + ((minix3_dirent *)de)->inode = 0; + else + de->inode = 0; + err = dir_commit_chunk(page, pos, len); inode->i_ctime = inode->i_mtime = current_time(inode); mark_inode_dirty(inode); +out_put_page: + dir_put_page(page); return err; }