From patchwork Tue Mar 7 14:31: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: 13163721 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 C6C9CC6FD1B for ; Tue, 7 Mar 2023 14:31:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4774F6B0073; Tue, 7 Mar 2023 09:31:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 427FA280001; Tue, 7 Mar 2023 09:31:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F00C6B0075; Tue, 7 Mar 2023 09:31:48 -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 1EB036B0073 for ; Tue, 7 Mar 2023 09:31:48 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DA7B01602F8 for ; Tue, 7 Mar 2023 14:31:47 +0000 (UTC) X-FDA: 80542341054.01.93DB6C5 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf14.hostedemail.com (Postfix) with ESMTP id E0CF410000F for ; Tue, 7 Mar 2023 14:31:44 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=3VLrWMLI; spf=none (imf14.hostedemail.com: domain of BATV+c1e934a3c65946ab7b64+7135+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+c1e934a3c65946ab7b64+7135+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=1678199505; 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=e7+CDOA4124JBRCEvFKTPsUneLuiXf/X6sOT6LF5JYU=; b=MIAGRh5JA/vW0Ibr8O5snzfL0MSWm1+Bs/8t1SZqsNibXS+XSoVEl0G7QIMj3jc7lZ0ABH QekMv0LkMCbnKTpMgNyNlFaGQgVoKw7G2Np5JmxK7LtBlilSqE36m0AbB6fnKzRR3sKSnb TQRjxNrWbrpOu/YYSSjnyDUHBDw3aDg= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=3VLrWMLI; spf=none (imf14.hostedemail.com: domain of BATV+c1e934a3c65946ab7b64+7135+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+c1e934a3c65946ab7b64+7135+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678199505; a=rsa-sha256; cv=none; b=kaGjxPzVeObKLjku7sFT0OMr014W07YhRKzSdUhIlgstkg8FxP4EdVNjLdd8OKWgHqOrQr wp9CHUOKvlT+OMqJXDC/fkn/6TAtcXR2kAL6KhfS6YXqUhcGtPYWJeV8cjsgdfwmgAbf9a gi2QFx3gy5HTV5VnxCLcougs3CrZArE= 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=e7+CDOA4124JBRCEvFKTPsUneLuiXf/X6sOT6LF5JYU=; b=3VLrWMLIKSJjYMH4ZGWGdhRkYI fyOCFd3v+NtSl8hn7DOZBGlkXjhNRGKJYK1KJUbmqVvGjBXHbQ4pWxEj1Xy+AasYVTEGNLDA0nS1E DApI3LDqQ4EeNdTFmdhqZH8EamjAPqPF1ANyX1+LcIG+ww+EPmqmM1n0eGfjt8ypjqTWKkQcFfZI3 29DLkn35ry7LUTKVec6PhJljXJBWoIfj05k/ZYOthsYc/5hOIyyu8WxT/F5yWqt8X/+Ba3Y6yPWgR d4dvdU+RHPFfWx5iVW+Me+OkDdg6zig4ymm/VKchIINJUHz6at9sFZkydHrpDJIf10pTV7LLzSWnH drG+kNQw==; Received: from [46.183.103.17] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZYLj-000omV-5Z; Tue, 07 Mar 2023 14:31:31 +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/3] ufs: don't flush page immediately for DIRSYNC directories Date: Tue, 7 Mar 2023 15:31:23 +0100 Message-Id: <20230307143125.27778-2-hch@lst.de> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230307143125.27778-1-hch@lst.de> References: <20230307143125.27778-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-Stat-Signature: 6grjca19t66djbxyngjr3c3masxxnqpg X-Rspam-User: X-Rspamd-Queue-Id: E0CF410000F X-Rspamd-Server: rspam06 X-HE-Tag: 1678199504-413729 X-HE-Meta: U2FsdGVkX187GH3u8spXLhczll/a3Zq9Q+gAodg9wGfy3hRKfJodYztdKew0l2R/eRKKnCvp96gvFnW3K6ShhAWxjUAvbrkTMPZzScP0p928KxexvWkIPRwc9HYlVmoaOuJZ4trdGeEwAta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ldg/nvioMCX9gOJ4CK8pbm4f0IklN+B5anHek9waed6YOOymfLlpTCVabKNXMA59OJZS0nZnbU9t1HE3AsnqDNXaG0yeZ/2so1yDu+jWnjfQve6TslG/kHafQBtt8LxNtiLfELpw5cG007L2G0M+nlVnwUYNZpk2DIgPfBkjEXisv5+1n8CUBPQe6R0HzQ2FQ/J6HHTU1jTjxQGwxdLdBFE5vaYYqFjhtAqSC41m1DudhmV+lzPvRDoTS2niUwn879z+RBmG1g== 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;