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+2TX7XzR6lWS6HF1Xq4FfnuOU3IEu4Hkvii03FnxUhEfvlAZQk2YThybeuzRG8ZYUQbOIjnaakG26c8p/3f2k27b8grDKtJ4bD3iv9BL1eKT9awyv4AwyGGFY7U0H9wBOCPoaSA8Sy8KsRK9jypDWFJf/wWFIz5GITJC4DBB45TzHU+zTE9lJGzZiwV/KJ7opNIZPOnKw3CXLnHEJCzhUM6saFtF01Y8rI5nstmrUD7WkyWNl7GrSzGFOueh6UAVe//kmMAdOoSFhIbeGPCVBR6aN3o81ZCR2k9dzzbDnsO5dROQ8hWDJDHid16VVhjvL8kbWkJgDKH/DhPIsl9cExeMnRqSF28qIcMi8ljkTC2qPw9pLLEL7AFItNgpT6wKH2ArvWwhevitXwUYETMDSp9ARdJia3mhFrmsjmx51o4LgCoie4qzlKNZ4SnoEQQyhfphTpJ1+Gun0TlztCOViSEWR674/R3JuEMLdPu5AIZ0EcoeVPOIp3NEJ+LYVsp7oaf2o8MEmqzVEmnCUZAhhmyl7RjvWXTH9//xZaOjPmG4x6SUFf+bxpV/rmyBneZSkLVs0E1r8V7N8F1OU/o0XHH97UiuDfdl4LfVa+iPrWlTj3x4kuVXT4uCpWlCdZBSgcAUMlYCblYg1XXwrGZF64JltmMgJyVckutq8LS0rfulhxn1GaXDfyXaPW4EhlOgWv2bnJmDXlJYUXgxjMwjjSSGNQ3Ad9zYTQfgNxRWxAULKdsClDeJ3TOierT5JXZjlrfHm7HiHVIHBB2pZbG7QGal3uuv9zzYsKmkiWIbKrbffb9cTebQkhV9+yxBIKeA/el28lnhZ2Ig/D5tXZ4oRe6QstxZ26hW8k vtl6Y8n/ PFOJeMNzBa+PvdLhg5ra9YNvjfKmdWPsbsG4TyiVKD34sE4t2mQG5LYjU41zJ6bLKx7TfhQyw2ou4dqkAF0iUIJerF5Wi7n5noPOGtGgMAJ79t2hX6I4H3vbRnqgK1m6plxjDGoyLWBXbKKBEqS4Pl+IBSmTkAFJhdCmRm6zB1WpRbxiClOoMmrgRnQ== X-Bogosity: 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: 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); From patchwork Wed Jan 18 17:30:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13106728 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 6CB86C38159 for ; Wed, 18 Jan 2023 17:30:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61B9A6B0075; Wed, 18 Jan 2023 12:30:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A3CE6B007B; Wed, 18 Jan 2023 12:30:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 444206B007D; Wed, 18 Jan 2023 12:30:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 366AE6B0075 for ; Wed, 18 Jan 2023 12:30:48 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 029CA40C0F for ; Wed, 18 Jan 2023 17:30:47 +0000 (UTC) X-FDA: 80368609776.29.F189DCF Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf23.hostedemail.com (Postfix) with ESMTP id 7033014001A for ; Wed, 18 Jan 2023 17:30:46 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=kqj2fnr+; spf=none (imf23.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=1674063046; 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=MsUsFoYQrTDA+hFUE1VWaBiacxBoUahLt80xRKfGZMs=; b=5EwDqm0et+lyeCUZbe4fAqWD+OBEZixYOOWxlcvyv05MgWsW3XmLhwVvSC4SlRUrjWeKh+ TxVHbRbTGmJ7yLEHGDmyrBLCJLWs+/jBrrxOkj90+s7pRMXWUdAnYKu7BYU80rHKMGuAlR U7m/1Ygj2o+X9rGYD755cBKQtWM2erY= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=kqj2fnr+; spf=none (imf23.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=1674063046; a=rsa-sha256; cv=none; b=OFyOv0tTBvZ5mersEzOG99ht7w1b3lNLOv3DjK2rlP4JJsL3L7cxK5D4D0ovR1cfEulnFS ywjWhwlVoJZ8dMDs7vHslDpoM9LKmwJ6nPvavGSdRhC+YmlmeWEcEwgEFSfqaEAhRbw/Cv 1Ms1wSZzYq24xI/gk7m/MITCnjg0Z9U= 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=MsUsFoYQrTDA+hFUE1VWaBiacxBoUahLt80xRKfGZMs=; b=kqj2fnr+ij0si90SGxbS9qXDce 2JYRKEHhI08O/eeOkZ4fGkif49Gsu87pWSEM4bCYAka8wxoBOy8Zc580p2lB4mZWpTixufgfK4OWL QOavXNp6Asr34uSPGFg/IlFkuGxb7C9Oi725gTlRiHA/LbWnneZBscVJ9VevMC6By9zCafaIYLB2E AAtGIINa79oLsbuf7OKhFM5ul79N4sg8/31bpJaYz/xFON4czyRlrMVFTN7bYi0CwSZkkYVHqz2ja 0k4Y+DBDHOLUeyjVmwWHyPJIbN7Pq7wEVKXlZb0IoaURU0TlddjqfeacFkSNiucvibBPeu9Z+lfuf mpMph1gA==; 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 1pICGi-00227r-3e; Wed, 18 Jan 2023 17:30:36 +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 2/7] minix: fix error handling in minix_delete_entry Date: Wed, 18 Jan 2023 18:30:22 +0100 Message-Id: <20230118173027.294869-3-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-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 7033014001A X-Stat-Signature: ot6yn7nxetfqhb9anta3sgsseu75rfaz X-Rspam-User: X-HE-Tag: 1674063046-913565 X-HE-Meta: U2FsdGVkX19fmD523p6bGnWl9zq3xrcHvjaVwlvkn504TgIW/LXjoeo98NIeLHW4iz6D3+8oYtw9q2BFNNp8WawdZbft5KVibA/OXWVVTzff9QdRIw0LZA9tpyOEnq/XOwM3Mg+lXHIWAFQLm4SlU9ia0Or42kFZFcBjbOyJdB+iCywrZCjc5Ms3FNrWDEfIMxcQXJkfyZdqP8o2A0Tjs0loKS2c0yokt5q1gsBoCQF2ZoUVbxvHH1PLaRZEAuHHdUhmK/Q67vBKacWdxJvQae7YyC7ANc4dKdbtXRIeiPPWpVQQ7MZtdEKVREClxj5ZOUeNoFY8prdGwgpWUEH+yti+ss3zIIu0JCahe/KZMFnUFW4etJ1XbsXindwM4kIj9lx+tROiujwpGQZFJ4L4i6NkUtZEVmp8TrzL+IMTJ9fdka2eEFyAeajscLTl2t9MkEEvlcwFFRlDH9aOFADpbAkOFad9JOB4cAjyPCeaWS2jU7UauztTe5e6DYjhMYJfwy3ejdIuBwniy0J/npVhh1q3DGV7zgPI2jpNAtNrhwRyP/0MRGpcmyu9koO0w4uVJJTV9Ok68GJCftJKSfj58B4NbWI2gVWmUEzRyEeSHnVnMTOL6fORLPERIaHREGYF/HovJJqOcMMoEw1E0lAG1JbRX8Smy89eNXPqS405Wx1cLA+UQmFHYaKuRcuJ8T92/RaT26fl6oHwmGrMm5M37oQ63AsZ48ouxylw1JijT+FMnGY7bYDtu6BSEaPx6KS08IaDpfIOR615PqdTUL9TrwGedUL9PlRsYVWYOL0Z1TRJgFKg0vUgJdhJuOE16VzGygcIfk9d/9u8r6+rLsfK7Z+qX/ALiQA/THD10++/+KtHq6zrWaDS/Z+al5T5D9i7HZBw/1EAzD4bYUDHDu92ABiyxFjQpD8Xy3FaMCC67xtO7L5Tup7G8AEjaVhGZDfGhF7hUoH1EyPwiGhtt8P 71m45x3G +xJSixbEvxw7oi5j2IVhUquXvWcQuQQyIoWFJVTUNbSthV3rnP7g8AE7XivQ1170RVc7YkuJkMBIDblMWNhSnUphTfRHnyHMOg9hJ6quZWUAnqhkP6Odh1boduQST48gVyD1nwniZ6Y25pKnHLW8aerRvAjAZ+8jrR4LzeaDBYgx01o7Pn5sTL2StENFbaEq0MOuqDqeqdFdO/iRxOMW/VGGVknyTq2zNV8BS X-Bogosity: 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. Signed-off-by: Christoph Hellwig --- fs/minix/dir.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/fs/minix/dir.c b/fs/minix/dir.c index ec462330e749af..242e179aa1fbeb 100644 --- a/fs/minix/dir.c +++ b/fs/minix/dir.c @@ -297,18 +297,20 @@ 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); + return err; } + if (sbi->s_version == MINIX_V3) + ((minix3_dirent *)de)->inode = 0; + else + de->inode = 0; + err = dir_commit_chunk(page, pos, len); + if (err) + return err; inode->i_ctime = inode->i_mtime = current_time(inode); mark_inode_dirty(inode); - return err; + return 0; } int minix_make_empty(struct inode *inode, struct inode *dir) From patchwork Wed Jan 18 17:30:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13106729 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 0E016C32793 for ; Wed, 18 Jan 2023 17:30:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0E7C6B007D; Wed, 18 Jan 2023 12:30:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BC0F66B007E; Wed, 18 Jan 2023 12:30:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A112B6B0080; Wed, 18 Jan 2023 12:30:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 931B56B007D for ; Wed, 18 Jan 2023 12:30:50 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 542A01A0C11 for ; Wed, 18 Jan 2023 17:30:50 +0000 (UTC) X-FDA: 80368609860.18.A4CC513 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf23.hostedemail.com (Postfix) with ESMTP id AADB414001D for ; Wed, 18 Jan 2023 17:30:48 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=22EHDJ09; spf=none (imf23.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=1674063048; 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=IK5go+LYlZzyyL0UG1E7ybATwbkUdMWL1x4AyvlHUwI=; b=L76VtHGZ+jEh+c6pHP9Rd7fJMLRdAiq/y5kJ0GyG2QT9k2dogPtb6b5UNksDrW0PaKfjia KKvfDzXLNEpbPduiFdGj+EG7Cp/Y6EYWCUZYpY6xidO7FgA5O1EHs57XDdZXCIo4MfcfrO cs5PKOIhzzty7uv/xrWAzUjEDaP08wA= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=22EHDJ09; spf=none (imf23.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=1674063048; a=rsa-sha256; cv=none; b=P3pra1aqfj0QF5oP5jFFgs3zh1wwLPnz6kgmYakzjWLijpF2nWv501hxWH8yBXzHwY/Q1H yS9r4An0uZ1vUoGuz+Zk2HBj7C99STFs7X39x+3NUVpDs9DWlKz6tMke2K+iGoGEa8Mjbs ckt8ciwLjCqc/K4bix54YlwNUiFJ6pc= 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=IK5go+LYlZzyyL0UG1E7ybATwbkUdMWL1x4AyvlHUwI=; b=22EHDJ091Mc3KuCstacxTn+6U1 TtnzRBznDgrz0So3oaYkMeFGRgj57zvpXYFUDSdqIZCgYRkHBvwHfNjsXzrP/xQqOVenmai+nAW05 fAdQseByMb+clpStiSc1jaAggo5QN6wpqlWBa4LFiuGeCZQTwywEGcNFv57TECBX0jtat3EobXTs3 AAuTXZlnaD8uWKiY541D53Z2S5GCsZPQrhEooQxpEasFeFqVjWXpIG4T+M4rZXyBOYzvSLrlcDucJ OM2qASNW5swyWRdm0BMqklqdwx4TTiiRsUbp0AvE/p/fb51scw/1RLWSo3a+Nh0FNvVDREyxuYrqN vC+yzHTQ==; 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 1pICGk-002298-Oz; Wed, 18 Jan 2023 17:30:39 +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 3/7] minix: fix error handling in minix_set_link Date: Wed, 18 Jan 2023 18:30:23 +0100 Message-Id: <20230118173027.294869-4-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: rspam04 X-Rspamd-Queue-Id: AADB414001D X-Stat-Signature: b1tdns9w5hb5ca1cn69k8r6mqczemk4x X-HE-Tag: 1674063048-254515 X-HE-Meta: U2FsdGVkX19idALKOo4NdaENvGIC1Uzim6xcTokZNcy+G6Ylflt4S6WqNKk6C4a2V2sFfstTBW404YBqLn4f6k43PZkBA7rJIkCkLgOlfRXYnITG8Yj2HHvWAbliYRA2iErux1rUpscrtzPwYrt6kSNTvEWtxSFi9EhfBxRFraHgYEo8QRCuXN79RQB0j3G1AKE5HjMzu9M42MVGRts9lt+xrsBJCDctzOQqYAfqLagjXijY+nQdlz6MlcZxV86DQavV45dNY58yN3NtDXAlAbhGZWpPCOVj5Sf1bNcAGAXWfyOow5XMmF6Ygob0hRMAsZl0GYkm/aAAVDeD38m0nULRNI/uSRWpNMVVjrEw05GnIL6A+MaEgzp18gJzVoNN5cs/cmFpNsGMVGQmCIy4J3cYAwUioFPSZGCGyw5Aa+PMuDYha3bKiRUqny0gjNSnu39dr/V3gyLBYVv9ZXG7vpstlnE2LEyrCOHfDgsZySgP2m53cuPwBEO7gCYpQv9nIJijfcZPOt++RsUbtmiTZqqJP/5/0Nlt6rV5bvBLZF3TgLj69fxrw9wVGHaaFhth/eeDWoL51WNAG9Z2g98oT4Srwk/G/V2JBQNvyy9UmRPVlPc1bMjMn9boAkEmvOINvQ5d6mLA9/l84VIynXZMdkmd/iylv3TvCt0O+4OL28AtJbQ0OulrAw+hlxErwmxHnG6eWfcwizQxtLKQba8MySeqyFiCj9+OpalOuYTTCOjoSSWu7q9J2LlNBEhnliCY/natw63HJ4sxu3K9B5zkPsl8aSgBDdTD7BTvkFyKxJ8tlfzVk+29gG8GWVehsVe4NrqNz4gvlO3chj734r2jNbcYANWf8PYI2PuC1W9FqXmtx28KfSeBZYRvUmRA3ZyE4ufH1rlpmG57+b8pTwkDdBMkcU6a01mtIYH7odOn/TpstJLhXIRSrHT6fccTX6l/1H1aZrQArumJFwplyyC N72EepOh 5nUqHy+wGcNKsGH9seaCTQWtSQqWM/mTghpUB7kQyORBhaOwaxKIoeJthfTS96rjuv0Qi4iqaSNXzDpq4iknAmgnZ3BEeXpDQrD4AGdG061uyfXqjAV9hPD8/tD2tptPfPENRSQZ1FTbdbal0ZU9goLYusrzLfGr33gVUUNjibFDu2brbhlslQrXED4N1Sy9L+JA0IA9wvN5fHM45DkswZo9Ujon45hcKQCc173QLPR111AI= X-Bogosity: 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. Also propagate the error to the caller. 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 | 22 ++++++++++++---------- fs/minix/minix.h | 3 ++- fs/minix/namei.c | 10 ++++++---- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/fs/minix/dir.c b/fs/minix/dir.c index 242e179aa1fbeb..34c1cdb5dc7d47 100644 --- a/fs/minix/dir.c +++ b/fs/minix/dir.c @@ -410,8 +410,8 @@ int minix_empty_dir(struct inode * inode) } /* Releases the page */ -void minix_set_link(struct minix_dir_entry *de, struct page *page, - struct inode *inode) +int minix_set_link(struct minix_dir_entry *de, struct page *page, + struct inode *inode) { struct inode *dir = page->mapping->host; struct minix_sb_info *sbi = minix_sb(dir->i_sb); @@ -420,19 +420,21 @@ void minix_set_link(struct minix_dir_entry *de, struct page *page, int err; lock_page(page); - err = minix_prepare_chunk(page, pos, sbi->s_dirsize); - if (err == 0) { - if (sbi->s_version == MINIX_V3) - ((minix3_dirent *) de)->inode = inode->i_ino; - else - de->inode = inode->i_ino; - err = dir_commit_chunk(page, pos, sbi->s_dirsize); - } else { + if (err) { unlock_page(page); + return err; } + if (sbi->s_version == MINIX_V3) + ((minix3_dirent *)de)->inode = inode->i_ino; + else + de->inode = inode->i_ino; + err = dir_commit_chunk(page, pos, sbi->s_dirsize); + if (err) + return err; dir->i_mtime = dir->i_ctime = current_time(dir); mark_inode_dirty(dir); + return 0; } struct minix_dir_entry * minix_dotdot (struct inode *dir, struct page **p) diff --git a/fs/minix/minix.h b/fs/minix/minix.h index 20217336802570..8f7a636bd1b241 100644 --- a/fs/minix/minix.h +++ b/fs/minix/minix.h @@ -69,7 +69,8 @@ extern int minix_add_link(struct dentry*, struct inode*); extern int minix_delete_entry(struct minix_dir_entry*, struct page*); extern int minix_make_empty(struct inode*, struct inode*); extern int minix_empty_dir(struct inode*); -extern void minix_set_link(struct minix_dir_entry*, struct page*, struct inode*); +int minix_set_link(struct minix_dir_entry *de, struct page *page, + struct inode *inode); extern struct minix_dir_entry *minix_dotdot(struct inode*, struct page**); extern ino_t minix_inode_by_name(struct dentry*); diff --git a/fs/minix/namei.c b/fs/minix/namei.c index 5fc696e032c543..bfbadd85d01032 100644 --- a/fs/minix/namei.c +++ b/fs/minix/namei.c @@ -223,10 +223,11 @@ 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); + err = minix_set_link(new_de, new_page, old_inode); kunmap(new_page); put_page(new_page); + if (err) + goto out_dir; new_inode->i_ctime = current_time(new_inode); if (dir_de) drop_nlink(new_inode); @@ -243,8 +244,9 @@ static int minix_rename(struct user_namespace *mnt_userns, mark_inode_dirty(old_inode); if (dir_de) { - minix_set_link(dir_de, dir_page, new_dir); - inode_dec_link_count(old_dir); + err = minix_set_link(dir_de, dir_page, new_dir); + if (!err) + inode_dec_link_count(old_dir); } out_dir: if (dir_de) { From patchwork Wed Jan 18 17:30:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13106730 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 1A4C7C38147 for ; Wed, 18 Jan 2023 17:30:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50A516B007E; Wed, 18 Jan 2023 12:30:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4962C6B0080; Wed, 18 Jan 2023 12:30:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E6A56B0081; Wed, 18 Jan 2023 12:30:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 1A71D6B007E for ; Wed, 18 Jan 2023 12:30:53 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id BE6D3A6BE2 for ; Wed, 18 Jan 2023 17:30:52 +0000 (UTC) X-FDA: 80368609944.02.4DB4AE2 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf03.hostedemail.com (Postfix) with ESMTP id 4500420012 for ; Wed, 18 Jan 2023 17:30:51 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=ZQCLvKpS; spf=none (imf03.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=1674063051; 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=BoUmolxcC4WWev3Bomon8s2I6PcBF6tpLGBKR42OIV8=; b=WYaAd+kKuVNHvhq0IqgqzHirGlrIz+66G3yGzU2LkuUcvHei8vIJzoMJlQWlr+DsG+u5U2 FkVHO7twYyAtsF4CXB25o/dlndqo937QGetnhvYLeFx5lMc5x1u6V5DrFmVz7PxljNiLGu IXS810S9BTRXIdglB9eY5Z/0o6WQyaQ= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=ZQCLvKpS; spf=none (imf03.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=1674063051; a=rsa-sha256; cv=none; b=SqdqcmlrZcA9KAwStY4HLbMX+YawEoN6wdyK+C07WXUl9h4NrAXwwHps6QZXnR6BqGevrO gBD3KjiT1tBglcQDy+MT8hctjGLn59Rai5RfJpm6ycNpbDvk7Uz2D9TSWXlUy1iHIFlmO5 zH8G34bjPvqjGeNp1C87c+kjCC2y0zY= 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=BoUmolxcC4WWev3Bomon8s2I6PcBF6tpLGBKR42OIV8=; b=ZQCLvKpSD0KCAbbeXHpyfp33/6 qx0a/KrfAFDWErK41OUDp0S+BSBMCboHO/UrxmMoAIzr7RofHT8nUn9Z0cYLsDia4oBqBcxHsEsHn DgtNTzw6mUh3h1qKIMi1ccvVMnNrnywN2365w7y0YciLh0/5mUI7c5mAAgggpDJlVo+a2gYS6j5gf HQzin5r1Wvq09X86pLvUuXLWnxta7uxx9qHcpSS3UDz48bByC9KuOuV8pfOh+heFHaBsutGEMTzsQ vOflyNklFdlV19i73Z1dwLI408NnZpyVftwfyeJ2kdNGM7wV4We11Q58QrO+8b3qIuK5wmELaRtd5 YdSZhIIA==; 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 1pICGo-0022AZ-5G; Wed, 18 Jan 2023 17:30:42 +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 4/7] minix: don't flush page immediately for DIRSYNC directories Date: Wed, 18 Jan 2023 18:30:24 +0100 Message-Id: <20230118173027.294869-5-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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 4500420012 X-Rspam-User: X-Stat-Signature: w761yoz8f5ji4piehaodgff9rwdb9g1o X-HE-Tag: 1674063051-242178 X-HE-Meta: U2FsdGVkX1+sAdYm/glM/kSzhVowNg9qofjdgQyRB3G5ViTH520lIntlCMMqxlQ1HmUcpqYGaUEfCvgb1BkML2eweYEQKbBeoAsm8/X5Zbgqq1de/qrsr7NRELztsR/kFgQlz/wb6RZEleOpzexKD6aQ6uRXbpmgFJOnXWNHKSRSLrmGp4P7U57/uUe1g/yz7B7Fkt2L+v4FajYKdpP0d0Cp/EI2rW4J8EeAqljp4/utPAs74M3sTG6zAKs4QImC1UmPS1ZCCWS3snJQ8Jp7TUIenL4uLQd3Zp4VzY/2p6MxPiiLh+hVJTf+D44pEhpwQdl2mXb4NQHmroUMC7LDd6T1iAE3vutHfBg1xEVdRnm7/+OqhF+l1qtRrHHmDqxz5TA9uM1MvXDJR8q+mFfu4jzHRIk3H9R7n3BXKnyqQfqH/J7GJpUbS+rtOkbPHLWH5oY3aj4pFIz63o79+U6ol2+ln9A6aOPFkUexYcg24iTNrw2gXtRsakqTS0ijudmCbwf8VFdIySK4YRhOqfoqBIiL8KXx+era0OBeakgwp+l/ouPpdFEjDTY8TWMxU8BJcgi/okzrs2dUvOpvuk4yYexI/VbTdu0ucjQrwIe1lLD68EPKTv4wayCLiT+E9qUIF8yfU4t2xOOpqq/SYVamKdjkyXOSP65QJiKAHAplk1dmt65ZiI1DREJmx6+dqZEIAmT+C/eaAmnv3tYuYs5RxayX93hv842UaUN6CGYibGqtA5zie4OJ6qur0ofqhaReQRhSw5rmtFMTWJdNOFEe6bbhXpfhHqByAb4YyaUgEgXl84VZs3AaBkAKS7++TA80+N8FdMvVI8Ks5LBdWuEOZgWFwgFrTYAE66HOfU3kK8PiHvhclBsPrAsvWC0YaULym6GxBDRvwIHKVPeXYTRBfe0RE2xMIKqHksIkajD8v50Esgt1DLFzyA74h0+ppp1IF1W+ZxrhQBRY+nG7EQZ dnQNXkaD CbnCiC6wnb6FrlIecedYrsrd71kv88tY7gRVynBRVhSJauO+pSYGZ6rSAZhKQVuPKIQmR7NGUinkd+gURYpBpRs/nYgLSMj0HbubEJiJJtFr1fjSYtA0ijCLWvDBp11p8Q1BP7jNmiz3ooHC8czPpaTp8LtiJj0Np015GixuXA/r3VVBH0ZUtR9TiNQ== X-Bogosity: 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: We do not need to writeout modified directory blocks immediately when modifying them while the page is locked. It is enough to do the flush somewhat later which has the added benefit that inode times can be flushed as well. It also allows us to stop depending on write_one_page() function. Ported from an ext2 patch by Jan Kara. Signed-off-by: Christoph Hellwig --- fs/minix/dir.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/fs/minix/dir.c b/fs/minix/dir.c index 34c1cdb5dc7d47..bf9858f76b6ae1 100644 --- a/fs/minix/dir.c +++ b/fs/minix/dir.c @@ -46,21 +46,27 @@ minix_last_byte(struct inode *inode, unsigned long page_nr) return last_byte; } -static int dir_commit_chunk(struct page *page, loff_t pos, unsigned len) +static void dir_commit_chunk(struct page *page, loff_t pos, unsigned len) { struct address_space *mapping = page->mapping; struct inode *dir = mapping->host; - int err = 0; + block_write_end(NULL, mapping, pos, len, len, page, NULL); if (pos+len > dir->i_size) { i_size_write(dir, pos+len); mark_inode_dirty(dir); } - if (IS_DIRSYNC(dir)) - err = write_one_page(page); - else - unlock_page(page); + unlock_page(page); +} + +static int minix_handle_dirsync(struct inode *dir) +{ + int err; + + err = filemap_write_and_wait(dir->i_mapping); + if (!err) + err = sync_inode_metadata(dir, 1); return err; } @@ -274,9 +280,10 @@ int minix_add_link(struct dentry *dentry, struct inode *inode) memset (namx + namelen, 0, sbi->s_dirsize - namelen - 2); de->inode = inode->i_ino; } - err = dir_commit_chunk(page, pos, sbi->s_dirsize); + dir_commit_chunk(page, pos, sbi->s_dirsize); dir->i_mtime = dir->i_ctime = current_time(dir); mark_inode_dirty(dir); + err = minix_handle_dirsync(dir); out_put: dir_put_page(page); out: @@ -305,12 +312,10 @@ int minix_delete_entry(struct minix_dir_entry *de, struct page *page) ((minix3_dirent *)de)->inode = 0; else de->inode = 0; - err = dir_commit_chunk(page, pos, len); - if (err) - return err; + dir_commit_chunk(page, pos, len); inode->i_ctime = inode->i_mtime = current_time(inode); mark_inode_dirty(inode); - return 0; + return minix_handle_dirsync(inode); } int minix_make_empty(struct inode *inode, struct inode *dir) @@ -350,7 +355,8 @@ int minix_make_empty(struct inode *inode, struct inode *dir) } kunmap_atomic(kaddr); - err = dir_commit_chunk(page, 0, 2 * sbi->s_dirsize); + dir_commit_chunk(page, 0, 2 * sbi->s_dirsize); + err = minix_handle_dirsync(inode); fail: put_page(page); return err; @@ -429,12 +435,10 @@ int minix_set_link(struct minix_dir_entry *de, struct page *page, ((minix3_dirent *)de)->inode = inode->i_ino; else de->inode = inode->i_ino; - err = dir_commit_chunk(page, pos, sbi->s_dirsize); - if (err) - return err; + dir_commit_chunk(page, pos, sbi->s_dirsize); dir->i_mtime = dir->i_ctime = current_time(dir); mark_inode_dirty(dir); - return 0; + return minix_handle_dirsync(dir); } struct minix_dir_entry * minix_dotdot (struct inode *dir, struct page **p) From patchwork Wed Jan 18 17:30:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13106731 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 4A750C32793 for ; Wed, 18 Jan 2023 17:30:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE3706B0080; Wed, 18 Jan 2023 12:30:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D6ED56B0081; Wed, 18 Jan 2023 12:30:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BBE676B0082; Wed, 18 Jan 2023 12:30:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id A869A6B0080 for ; Wed, 18 Jan 2023 12:30:56 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7C33180C64 for ; Wed, 18 Jan 2023 17:30:56 +0000 (UTC) X-FDA: 80368610112.29.39EC074 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf28.hostedemail.com (Postfix) with ESMTP id F3D73C0025 for ; Wed, 18 Jan 2023 17:30:54 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=n97J6P4L; spf=none (imf28.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=1674063055; a=rsa-sha256; cv=none; b=5uDFVWUdrZ3nZbKBUBv5FEz7Z7XU/iF4qGmutGL1jLVugDfiVYOjEmeVQptVgkqh2UgfUu 6z4FdFNbTyNZClK4nIk4OH5z1I8J2yZvQKvOxGygag3Gy0kwpf4zOt1K2gJdqK+PiSwtFQ WSQNCL185fcirtuqlSZaQrp0gQ8OZoY= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=n97J6P4L; spf=none (imf28.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=1674063055; 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=RiDLIEceuZ9xYcAquYO1xUuvp0itrlt5jINwhutKHnw=; b=zWNu4j+Y2jgfO9m67IfxYA67/oELJZLbDG19ymOvgxMQKdBr2cH8hmVZ8oJObDEIENwBOn 8E20dek3Bv5QGY9cMdyb+7Sh09zq0VqUrrbxyeDA0q4ZNg3ESVheV25forzQkDl8lvHPq0 Kw2fHvaOcuQWDS/eh1Im3sUkdZGN2EE= 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=RiDLIEceuZ9xYcAquYO1xUuvp0itrlt5jINwhutKHnw=; b=n97J6P4Lj3rjm3/TGFmVVg8Wrr u/Z8bas8ry+fHYEM5YBXc8LfZPJatmLG0er+p8+/5CozJDOufcBh+tyW0g+wakyIsB/9H5FBTQ/B0 P9RF3jbwsVQOKtVzVYq7n5OOzt7LsHupFBPGD8lmcE/OHd7pBxTqExpqoyUj+zhmPtrIzvY6WCi74 ejoYGQAJZLfGPwCd34tL2WZjX757TewJV/7vUp0+iZHuP6KbIZypE49r+dwszdbfXvfZ0yZgwPc6T 5DRNKtiiyQUMu2UyCmj+gIm6vlzuH7QZqDupe5mw9DI9tktHePHc6C+y8Gg4JuWOk1p9RZQn4I0sW n3a9GVtw==; 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 1pICGr-0022CO-7p; Wed, 18 Jan 2023 17:30:45 +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 5/7] sysv: don't flush page immediately for DIRSYNC directories Date: Wed, 18 Jan 2023 18:30:25 +0100 Message-Id: <20230118173027.294869-6-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-Queue-Id: F3D73C0025 X-Rspamd-Server: rspam01 X-Stat-Signature: 9tpop4piitmw1guenitm6by6fri74grw X-HE-Tag: 1674063054-400617 X-HE-Meta: U2FsdGVkX19SIu9a7xCv3Xhb421iDL2GmuX4uxEvdrTa02OFwiYV03odO71Xz1q4WwHOOX/GEmYZwy/KYlA+FRtzffWyOETe4M/7jIFl1p/e44I6imnSc2ysevxFmS6hcUmh3LMjZepn/X15T4fBj5qgcTKONmJes2pRp01Bs7qcrIea5zfeYFWR3Zk8jl9jDRX6z1gWhvywaZXBVu0NBPCzj+7nn3TZ7kbkeI7TbsxHLoDydrzTeNq5zcyQY5YlJ+fHGF9TT53q5ifavX3ZRfvnGM+4TCJessTeXwNv0H0DQ+nMDT+ooGWc/PAhKNOXJfRd/vNgRyLQ0wkKdwHvkdRYZeLhqdH3xi2xu+8OSe3xESUMilKl4oZyMGP4oLhbkUasTAzOok9LegYZeW44DkYSj4oFFtgcGd77JYJk1ZUlpI3bOqLufKQ6RxdN5xl98nZ3vfkOUsVwm4Cyo1qYXPuGCtFxZ62bWAjy7qjG1vwOlpxsjICl0/QQusu/dpL4Jx7KzhzNo469aOMWOTgauzsfB+S1IEjKZRtyUQkMFdApxTaAxYslJRIZkSL/ciDfAGgE/e6AYgiI1V85K0z42ngDl2B8RqjxWahKHbs8bTG0xlVhrMtwmsv6NVbhfEMDIBXmS2sYll3N1fFdYXPttNrK9qprhvLi9bj8zXalhbcdmJ4JQtjO+T+AVw4bexCFuJafWEp3uCqt7LByqovmq3FEMFYkK/Suj+xja4FsbJnA9XyXM0L90eEBFzW7DHnkZEkAdVDelH50z16WATwWnbpFZY9/TcgzRrZNyP6ldSN9Sc9hfwijB55Q4i4R90P3PoO2ZxyBC+deh6VD5hFfr8b33n2XKH2Er+H3IJFAxApVsekbn0nXQre1mwWh1uD339PB9BZY4RY2w0SD8IQzFPTT34oZT+mOtDrfIhwhXSI6sCcWPWPQ/98GhpDBRMhCqXYA282/S37T0EaXWgn Ns5V0+AI YvHgEgandWxAjZ8vEtFlXjHFkO9dbjCDK+L9jMetMOUpqDw94Nhe7D06tKD+5dOEXXpVlzvf8ywAi3njZlxAaV06OSPYZ0ilq2ub1A5Ysk2Tqvxs1A2ypW0PTLb9C64ZOCPY8XjZtSQPNrHw4RA5k8mPw9Nz1hf1oHr15FT/PnSJE5RGGUhzN0Uc2Uw== X-Bogosity: 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: We do not need to writeout modified directory blocks immediately when modifying them while the page is locked. It is enough to do the flush somewhat later which has the added benefit that inode times can be flushed as well. It also allows us to stop depending on write_one_page() function. Ported from an ext2 patch by Jan Kara. Signed-off-by: Christoph Hellwig --- fs/sysv/dir.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c index 88e38cd8f5c9ae..16730795a62161 100644 --- a/fs/sysv/dir.c +++ b/fs/sysv/dir.c @@ -34,21 +34,26 @@ static inline void dir_put_page(struct page *page) put_page(page); } -static int dir_commit_chunk(struct page *page, loff_t pos, unsigned len) +static void dir_commit_chunk(struct page *page, loff_t pos, unsigned len) { struct address_space *mapping = page->mapping; struct inode *dir = mapping->host; - int err = 0; block_write_end(NULL, mapping, pos, len, len, page, NULL); if (pos+len > dir->i_size) { i_size_write(dir, pos+len); mark_inode_dirty(dir); } - if (IS_DIRSYNC(dir)) - err = write_one_page(page); - else - unlock_page(page); + unlock_page(page); +} + +static int sysv_handle_dirsync(struct inode *dir) +{ + int err; + + err = filemap_write_and_wait(dir->i_mapping); + if (!err) + err = sync_inode_metadata(dir, 1); return err; } @@ -215,9 +220,10 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode) memcpy (de->name, name, namelen); memset (de->name + namelen, 0, SYSV_DIRSIZE - namelen - 2); de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino); - err = dir_commit_chunk(page, pos, SYSV_DIRSIZE); + dir_commit_chunk(page, pos, SYSV_DIRSIZE); dir->i_mtime = dir->i_ctime = current_time(dir); mark_inode_dirty(dir); + err = sysv_handle_dirsync(dir); out_page: dir_put_page(page); out: @@ -238,11 +244,11 @@ int sysv_delete_entry(struct sysv_dir_entry *de, struct page *page) err = sysv_prepare_chunk(page, pos, SYSV_DIRSIZE); BUG_ON(err); de->inode = 0; - err = dir_commit_chunk(page, pos, SYSV_DIRSIZE); + dir_commit_chunk(page, pos, SYSV_DIRSIZE); dir_put_page(page); inode->i_ctime = inode->i_mtime = current_time(inode); mark_inode_dirty(inode); - return err; + return sysv_handle_dirsync(inode); } int sysv_make_empty(struct inode *inode, struct inode *dir) @@ -272,7 +278,8 @@ int sysv_make_empty(struct inode *inode, struct inode *dir) strcpy(de->name,".."); kunmap(page); - err = dir_commit_chunk(page, 0, 2 * SYSV_DIRSIZE); + dir_commit_chunk(page, 0, 2 * SYSV_DIRSIZE); + err = sysv_handle_dirsync(inode); fail: put_page(page); return err; @@ -336,10 +343,11 @@ void sysv_set_link(struct sysv_dir_entry *de, struct page *page, err = sysv_prepare_chunk(page, pos, SYSV_DIRSIZE); BUG_ON(err); de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino); - err = dir_commit_chunk(page, pos, SYSV_DIRSIZE); + dir_commit_chunk(page, pos, SYSV_DIRSIZE); dir_put_page(page); dir->i_mtime = dir->i_ctime = current_time(dir); mark_inode_dirty(dir); + sysv_handle_dirsync(inode); } struct sysv_dir_entry * sysv_dotdot (struct inode *dir, struct page **p) From patchwork Wed Jan 18 17:30:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13106732 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 E40C9C32793 for ; Wed, 18 Jan 2023 17:31:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 88CD86B0083; Wed, 18 Jan 2023 12:31:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 83BA06B0082; Wed, 18 Jan 2023 12:31:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6DC8E6B0083; Wed, 18 Jan 2023 12:31:00 -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 5DDDE6B0081 for ; Wed, 18 Jan 2023 12:31:00 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 38E98403B8 for ; Wed, 18 Jan 2023 17:31:00 +0000 (UTC) X-FDA: 80368610280.26.BA0E0B0 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf29.hostedemail.com (Postfix) with ESMTP id A2E17120028 for ; Wed, 18 Jan 2023 17:30:58 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=U05qheov; spf=none (imf29.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=1674063058; a=rsa-sha256; cv=none; b=FXiFQZtRXfTj4PmNq85iBGIQqFukhdulC/pr969CABGVdPWIvjY2SP5bpB2IYQEzLJ0/g3 /V6Pd2cFe4ay8jXuETBOFMn17rNmQJ1Hd9mSaYjJA+tfNYcNPX1Ouj8328WvIW9/ZOgk17 D76sCWr+EvVFL105osGL6OoNd7a9GFY= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=U05qheov; spf=none (imf29.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=1674063058; 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=v3PglRWzIOokZtWskK857KErIsUBx1dUWoEIj+rmors=; b=uyHem9QNRIeubFLargNPuyGwdhOju9e+FE0OrDN4pApo4DWFs/kZcGuii3wtRZb54yZ357 /F/Ly5njGIdxNE5kC7NbdptlwwtXl4Fi+Hg0xTgg6x4Et6evLfM05om5ms1VQ4VRFrIuJ6 I/xbkMV3jZOcEhX1obFjO10Tt/mLZm8= 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=v3PglRWzIOokZtWskK857KErIsUBx1dUWoEIj+rmors=; b=U05qheovgxBUbMhTKKemw5ZM2W +lw1zqiSw0fTKUbYGe4qcdGWpVpSVtuCixVD8X05UaJPzH0rV12qgPwg6yrdCoj58546B7wZkvItN aFBV6i6UuPYSTlEDevcYjEqKtWYeXCL9YJuF2o0ktbYV85kZYtLzrPpqLCUnrQOdm9tdrLM0zEJTT YGK7YdkqWaEvFJ/1iWN+aLUbVyyZE/fW3pvAcev6gYBqg4UUNvQ7LL3/j/TMEsY9lwC2STBR+1xQ3 OAGX583TWkypdhRyd5ZIFMj5ZNc1iYMPGalHjY5KsPCHBup21MLTKOruniP8ileEqsqVnakRllDNF lm4B09wg==; 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 1pICGu-0022EW-GD; Wed, 18 Jan 2023 17:30:49 +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 6/7] ufs: don't flush page immediately for DIRSYNC directories Date: Wed, 18 Jan 2023 18:30:26 +0100 Message-Id: <20230118173027.294869-7-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-Queue-Id: A2E17120028 X-Rspamd-Server: rspam01 X-Stat-Signature: gd5d6ncyon36ntbb51zdmdi36nqz5y59 X-HE-Tag: 1674063058-7875 X-HE-Meta: U2FsdGVkX1/PEtrrtDqZEsrIJho2kTKQMluGiMxHYq0gRCvQA8L9An7ZZCFVpvQRoNFaca0PW8ZoMrn5unj7b+/zjjigoCI1Vx/UoOXfUfxkWTWZhvOd3CCa9qqkaPV5XsPsa+xvFrQ+kp64nxnV0TlTqYX+OXl2x76Qc4Tn4pKh7+o/N1ZStaP3EGAMyK2yKLVUYaScZYPpH3ZNrtKA2kT7wbRoOYNbdB4qUCaGqWaxYwmZcgjDSKSFWMcjaTAvTo7N9kVHrDfA5DowC+KmEQA5kWUJOrl1qjwpORiAbA239Djujx6ZAopShScheveGVnDkVCCrt+Flea/4Gq2Nlwfv+ZGAqh35NUTiefK/uU5uDXYoyr1KM/f3Bi998NkVoTHxhEjU9vE9GCBvVtarHLjx6tstzzbxgnxgxk3RYsssO51re5iBSu1KCHOrBam6Pm4Pq21W8ZPClvp++j5wNL2znQPFPko535y6CUhIrbO2akJdcEJnkO/vZ2b+pd/Uui4eMI9oYs6J4I+5WT8b4FfNVWonChYWWyXw1qYA55Qfki48c98ycnjd77nyBBul8n4FFd9qk6mdtRmZsSuDelCByTVVbGYEJajEjbDsyXKgKjT96onzcPWqptttHCpD6z0NY0XN0Hrz2RoDGR6NVktbG2P7Ot2zBHRi53Gan4S3gBSsQ72priKqDNXg90k/EpKHnFa12J+7e6Hx8qtU7vHrnzE3KDhFABGuEetwhfbG2k+6e+uoK2uhBOiDu9rpXbpv9WfPYn2smHBLg+3d17iEAxDsaZ2NwUIl9MZYwkAOCipdjiJeHfDVgPLmixuRSNSgFy0eS8Xi1uT3aO77YRk+QME5kScko95ABZhy+EbGA3NyTSZuUJCxBzNZA1b+WGKmeTkKxOUGwmlwVFAFyGsM+5Kb197IWCUq2kRBOqqgpYZpkRSAhvuDajqhC4px0ysLWo6fVXU0HJtBbvV hQIte36W 6wn69oA4FKgry+i0becbafOsKCVvadDCzs19/iDzSPpZ9OKMRecsFj7OtA0lt+qqF+/Q+0xcwuYs1qe+NiFZTrWisSxASiT2N31/vjry4HBPYQwMndDjFFIEslxJEK6R0JSvQSP4rdu/sYAJxSPKccwycXeHsMx5eaD4DwDcYSPEh+6enMjMl400kHA== X-Bogosity: 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: We do not need to writeout modified directory blocks immediately when modifying them while the page is locked. It is enough to do the flush somewhat later which has the added benefit that inode times can be flushed as well. It also allows us to stop depending on write_one_page() function. Ported from an ext2 patch by Jan Kara. Signed-off-by: Christoph Hellwig --- fs/ufs/dir.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index 391efaf1d52897..379d75796a5ce3 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c @@ -42,11 +42,10 @@ static inline int ufs_match(struct super_block *sb, int len, return !memcmp(name, de->d_name, len); } -static int ufs_commit_chunk(struct page *page, loff_t pos, unsigned len) +static void ufs_commit_chunk(struct page *page, loff_t pos, unsigned len) { struct address_space *mapping = page->mapping; struct inode *dir = mapping->host; - int err = 0; inode_inc_iversion(dir); block_write_end(NULL, mapping, pos, len, len, page, NULL); @@ -54,10 +53,16 @@ static int ufs_commit_chunk(struct page *page, loff_t pos, unsigned len) i_size_write(dir, pos+len); mark_inode_dirty(dir); } - if (IS_DIRSYNC(dir)) - err = write_one_page(page); - else - unlock_page(page); + unlock_page(page); +} + +static int ufs_handle_dirsync(struct inode *dir) +{ + int err; + + err = filemap_write_and_wait(dir->i_mapping); + if (!err) + err = sync_inode_metadata(dir, 1); return err; } @@ -99,11 +104,12 @@ void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, de->d_ino = cpu_to_fs32(dir->i_sb, inode->i_ino); ufs_set_de_type(dir->i_sb, de, inode->i_mode); - err = ufs_commit_chunk(page, pos, len); + ufs_commit_chunk(page, pos, len); ufs_put_page(page); if (update_times) dir->i_mtime = dir->i_ctime = current_time(dir); mark_inode_dirty(dir); + ufs_handle_dirsync(dir); } @@ -390,10 +396,11 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode) de->d_ino = cpu_to_fs32(sb, inode->i_ino); ufs_set_de_type(sb, de, inode->i_mode); - err = ufs_commit_chunk(page, pos, rec_len); + ufs_commit_chunk(page, pos, rec_len); dir->i_mtime = dir->i_ctime = current_time(dir); mark_inode_dirty(dir); + err = ufs_handle_dirsync(dir); /* OFFSET_CACHE */ out_put: ufs_put_page(page); @@ -531,9 +538,10 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir, if (pde) pde->d_reclen = cpu_to_fs16(sb, to - from); dir->d_ino = 0; - err = ufs_commit_chunk(page, pos, to - from); + ufs_commit_chunk(page, pos, to - from); inode->i_ctime = inode->i_mtime = current_time(inode); mark_inode_dirty(inode); + err = ufs_handle_dirsync(inode); out: ufs_put_page(page); UFSD("EXIT\n"); @@ -579,7 +587,8 @@ int ufs_make_empty(struct inode * inode, struct inode *dir) strcpy (de->d_name, ".."); kunmap(page); - err = ufs_commit_chunk(page, 0, chunk_size); + ufs_commit_chunk(page, 0, chunk_size); + err = ufs_handle_dirsync(inode); fail: put_page(page); return err; From patchwork Wed Jan 18 17:30:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13106733 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 00E0FC54EBE for ; Wed, 18 Jan 2023 17:31:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7EF656B0081; Wed, 18 Jan 2023 12:31:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 777CA6B0082; Wed, 18 Jan 2023 12:31:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 640BB6B0085; Wed, 18 Jan 2023 12:31:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4F42A6B0081 for ; Wed, 18 Jan 2023 12:31:04 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 338A01205DA for ; Wed, 18 Jan 2023 17:31:04 +0000 (UTC) X-FDA: 80368610448.20.90650AB Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf15.hostedemail.com (Postfix) with ESMTP id A6FAAA000B for ; Wed, 18 Jan 2023 17:31:02 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="t/tZrpSS"; spf=none (imf15.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=1674063062; 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=jmbxaw5WGTdQC+qZyQllTG4rSUOzrNtp0wkWOB0SkzU=; b=pLC6XII/SC7KIA2WNI1HLqa3mv9IQqCh+x5sWFUmZnS05zmKGb60yzhKkQPyPXMyfNhUD+ T3F05SFxXZhci7fyDlf0frNsV5i9AmZudt/xFcRj81aKkWRRtS4OKPzVjkg/3AGdpI+4uM 0hGkwlda7SjgZPOh1jgR08BjBcJ4QQE= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="t/tZrpSS"; spf=none (imf15.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=1674063062; a=rsa-sha256; cv=none; b=h3C/j4AJ5PUt8EcYfUAhPU2ZkEcwMEIM9V2FN1A6QJJR45fjp7IGhDyCEmDzUdm09tJhl5 Ej4CjZhsOOO7v8l1F8zr9m9LUyi99de24XNb2DMdvhcrC/SSzeJYEdknCPpkLuyAkxg6tt 8IGfvq/B1m9ZCiU5iw7YzmcX9c19GZA= 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=jmbxaw5WGTdQC+qZyQllTG4rSUOzrNtp0wkWOB0SkzU=; b=t/tZrpSSAGJENEbey1iuxkY4ry DoU5y3Z4+8vXJK7yr+FX15ymQN81I4eYh+Ld5EsZ7QFqEDndjQwJk3U4pvySdS91GPbZqgEuJzKSc 3Hb+U6bsZh23jwkljYJIRJmeZmhtzKFA2xT/JLlfnDFLQzDCMBk0IwTSypcYjKrwmJgSb/gtP6Pxa vqIncS8uYulKZFlO9T7OpTj0BhbtHHGYpqhOlGXM2HT8Jx9qfzXF+bD/vDHXBFJZqpMAlFvudD4WT VHRCcgIEGkyXvIQnY4XTtcmPCC5sJHR2bvvK4vMMsHKgWPKo5D6SKWZhgAk4rd4Vnl+qQfpUU3NGd DadoCs/w==; 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 1pICGx-0022Gg-Pc; Wed, 18 Jan 2023 17:30:52 +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, Jan Kara Subject: [PATCH 7/7] ocfs2: don't use write_one_page in ocfs2_duplicate_clusters_by_page Date: Wed, 18 Jan 2023 18:30:27 +0100 Message-Id: <20230118173027.294869-8-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-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A6FAAA000B X-Stat-Signature: 66pwd638tbzwwey99kw6ibpegnzwu9ya X-Rspam-User: X-HE-Tag: 1674063062-204456 X-HE-Meta: U2FsdGVkX18aZbi3sR6ezFeDvwkmhV7EPobox3CffXoUYkLtNtH1Wm0rQIOgsaN8s3krKUsk/9R+meliWxUGFQbH771UswVTKuKhDzQx4+H228cx/CfcGgpFIjeK8sLzZCxLBx8xpArGOPDCIuzSwAT5Yxb6JeF4B3gjU8fxPP84jMd5QuZ/LiN4JvmMBnMENXpqGzsMfPdd0WN3iEz238Hc2M6A1iccxeik9GDi/KvHEfsv6cUKdbCyMEVi4rjqL+INB6ArqG2quJE69Jh+xtI183pTnUnULm/bNPTvzlLwALgQ0vsUGfchaiVGTXeu/pEsBHB6MxWgMSiBVT19kb4o4fBCmVf5gvHbz2LPtFXFBgcKq9uLxJNUsQXgThLAmRG0HaDMrZ9fFcelH7REIjHYAuaYiQVlBMc6gwctEk+fQJ0sdVlg2PukzqJSdB0oLTFqPKV4rnFxnB1n+IVlba3yKC6DSIJ7vmpAaP7hyVa0AmIGfpJN+l/XV19GSmRAESIzYh5mjRzRpzar2ArJySWgeWU4wUpaubiQA/Zu68jbWU53/HxhOkrJn/rbwBvRgarNXxsXLvpQhJhx75Vqm2YZVAzbSwH5zm2e8lxJycMI0jwFKMxzBlBesCvx+oJbJFzBood5p8GMAgiB56gEsyjKW/yK9Mzpc32gkqGAjQjUD5j4yrLlgrZXa/Or9KqOSqllE1slRVn+xiLTItWXWkGBztqSL81OEOV1VnBFiDghkEi7+7rMQZz+dcbvC1r3JbXQWSLKxtfxGoIDFIVm2yAC5JA5hXP6FylkzHYH2mm+fyUXqbYveT6xazf1eE44a2HAvmCt+uSYhmTjV1UvZfwqgqexqk2NdVelagcfehhI6ufjpKWJiWoZJ/W34M/dpxiVttkaPj+Gy3OyhpfYfv75MDcpc063UBj08/gZMqo2EhL6G1Z3OvCtQoNJMAnpmiQJEtKXvZub+rGxRf2 fUQsVrl3 Vm83oCKGhI7u5mo8DzAQtKGO7pjGxVqJDk9IW/zfUmtFRC0OzjBDxiMtpPsi3hqwMyRHj1efD8GbiK9EpSvViu4dp5W8v/TA7sUtEXZgwGz3PMEGLFELYDur/Y2DIhZbkOUTX3+DLqGng0bxEuMiMlPhd6g45jiVmMPhWyRPoEQEBwKJDLEcb9MttgtUEn8Ykx6ptSoOElfDEks9dT9+h2nwIc0oa8vzh9zS+CllDEcEEwBI= X-Bogosity: 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: Use filemap_write_and_wait_range to write back the range of the dirty page instead of write_one_page in preparation of removing write_one_page and eventually ->writepage. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Reviewed-by: Joseph Qi --- fs/ocfs2/refcounttree.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 623db358b1efa8..4a73405962ec4f 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -2952,10 +2952,11 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle, */ if (PAGE_SIZE <= OCFS2_SB(sb)->s_clustersize) { if (PageDirty(page)) { - /* - * write_on_page will unlock the page on return - */ - ret = write_one_page(page); + unlock_page(page); + put_page(page); + + ret = filemap_write_and_wait_range(mapping, + offset, map_end - 1); goto retry; } }