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/kFgQl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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)