From patchwork Wed Jan 18 17:30:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13106727 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 65828C32793 for ; Wed, 18 Jan 2023 17:30:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA6106B0072; Wed, 18 Jan 2023 12:30:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E56726B0075; Wed, 18 Jan 2023 12:30:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1ECF6B007B; Wed, 18 Jan 2023 12:30:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id C2AC96B0072 for ; Wed, 18 Jan 2023 12:30:47 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 87F84160C1B for ; Wed, 18 Jan 2023 17:30:47 +0000 (UTC) X-FDA: 80368609734.12.1C014D6 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf24.hostedemail.com (Postfix) with ESMTP id 6DABC180010 for ; Wed, 18 Jan 2023 17:30:45 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=W2RLJZtW; spf=none (imf24.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+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=1674063045; 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=tKKUPVUCc1vcjlD9WoFla6fgqGJV6pEZLd5u8wPj4kY=; b=vAVAs048TdrvrPUZPd00d8Olw6IH9RdTAGAUw0LLtgdVY5qSastQg8u4rM2KmjM3nt9uY0 1LJOlGVOW0ecieym9RUcqjpUJvaMoz+ilBdwQSpmFSkI84vMMn87k9A3QsmL0nL5nIIRhD cc2pXG4xLj0en9/LlG2t4roP97buboU= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=W2RLJZtW; spf=none (imf24.hostedemail.com: domain of BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aec3eaf5b774c69d00f8+7087+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674063045; a=rsa-sha256; cv=none; b=pOcrBuDJX7x8vpXsOmyP5wi/U6X3Zg5xDwXkHwj9EpvALmHmNJCJiqL4N26h2hUgX/KepM YwL9T98zyWKY0neZOqXxaxpBBGqK2pzzmu6cxCt+1eYXT6Vb7mpPJ7F16xgUrZT3DPrHRp bBErkoJuAyt9JLg8ckta4/IgmTISkpA= 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=tKKUPVUCc1vcjlD9WoFla6fgqGJV6pEZLd5u8wPj4kY=; b=W2RLJZtWjZmHv9sTcMQH48sXB/ JAHhsX1mtELnQxarHrPAvgoQZ/CtP7dC4EJQcW5jwgduy+PTzAUSNbidoYL2CCsx4T1g1EAJE/+bs vhnZKih4QVXkR3XHuN5lyqL9REaBX/aSqtuhPh7kUikPHUQSqk50bv2C91GV+3pL4e5EPgQPuqfGM pePNW2rboF5ElpEixHLdm7XU5CHV01F9sUldqJXn5K7Nv9ej49ndyAZCfNKB0q8VSicGkqQb451Od Ze44hQEf2g3VOFwBvBXQ09WyfI81/CGsglkNf9S7mTE8p+XuujCBqktlBUATnjwIbxC5ygo51PCNK sJk88oBQ==; Received: from [2001:4bb8:19a:2039:cce7:a1cd:f61c:a80d] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pICGf-002261-8A; Wed, 18 Jan 2023 17:30:33 +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/7] minix: move releasing pages into unlink and rename Date: Wed, 18 Jan 2023 18:30:21 +0100 Message-Id: <20230118173027.294869-2-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118173027.294869-1-hch@lst.de> References: <20230118173027.294869-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-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: n97cyakgr71jppqh9zxkxqib6agmudrj X-Rspamd-Queue-Id: 6DABC180010 X-HE-Tag: 1674063045-549165 X-HE-Meta: U2FsdGVkX1/OlW9gLWYMkGlXSA5jrk90Xkbi0Tnv7OByZ3ip3hSuvEj8XdPEHTNQniTmKYrqw7lWGU92gJd0JQfMaYa4cVhhVYxV8uFCQCETTz3mt+2TX7XzR6lWS6HF1Xq4FfnuO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icity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Instead of consuming the page reference and kmap in the low-level minix_delete_entry and minix_set_link helpers, do it in the callers where that code can be shared with the error cleanup path. Signed-off-by: Christoph Hellwig --- fs/minix/dir.c | 2 -- fs/minix/namei.c | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/fs/minix/dir.c b/fs/minix/dir.c index dcfe5b25378b54..ec462330e749af 100644 --- a/fs/minix/dir.c +++ b/fs/minix/dir.c @@ -306,7 +306,6 @@ int minix_delete_entry(struct minix_dir_entry *de, struct page *page) } else { unlock_page(page); } - dir_put_page(page); inode->i_ctime = inode->i_mtime = current_time(inode); mark_inode_dirty(inode); return err; @@ -430,7 +429,6 @@ void minix_set_link(struct minix_dir_entry *de, struct page *page, } else { unlock_page(page); } - dir_put_page(page); dir->i_mtime = dir->i_ctime = current_time(dir); mark_inode_dirty(dir); } diff --git a/fs/minix/namei.c b/fs/minix/namei.c index 8afdc408ca4fd5..5fc696e032c543 100644 --- a/fs/minix/namei.c +++ b/fs/minix/namei.c @@ -150,23 +150,23 @@ static int minix_mkdir(struct user_namespace *mnt_userns, struct inode *dir, static int minix_unlink(struct inode * dir, struct dentry *dentry) { - int err = -ENOENT; struct inode * inode = d_inode(dentry); struct page * page; struct minix_dir_entry * de; + int err; de = minix_find_entry(dentry, &page); if (!de) - goto end_unlink; - + return -ENOENT; err = minix_delete_entry(de, page); - if (err) - goto end_unlink; + kunmap(page); + put_page(page); + if (err) + return err; inode->i_ctime = dir->i_ctime; inode_dec_link_count(inode); -end_unlink: - return err; + return 0; } static int minix_rmdir(struct inode * dir, struct dentry *dentry) @@ -223,7 +223,10 @@ static int minix_rename(struct user_namespace *mnt_userns, new_de = minix_find_entry(new_dentry, &new_page); if (!new_de) goto out_dir; + err = 0; minix_set_link(new_de, new_page, old_inode); + kunmap(new_page); + put_page(new_page); new_inode->i_ctime = current_time(new_inode); if (dir_de) drop_nlink(new_inode); @@ -243,8 +246,6 @@ static int minix_rename(struct user_namespace *mnt_userns, minix_set_link(dir_de, dir_page, new_dir); inode_dec_link_count(old_dir); } - return 0; - out_dir: if (dir_de) { kunmap(dir_page);