From patchwork Mon Jan 16 08:55:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13102752 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 D5588C678D6 for ; Mon, 16 Jan 2023 08:55:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3F5A6B0073; Mon, 16 Jan 2023 03:55:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BA0406B0074; Mon, 16 Jan 2023 03:55:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A043E6B0078; Mon, 16 Jan 2023 03:55:44 -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 86B5C6B0074 for ; Mon, 16 Jan 2023 03:55:44 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E9B4116075E for ; Mon, 16 Jan 2023 08:55:43 +0000 (UTC) X-FDA: 80360054166.01.2117F79 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf21.hostedemail.com (Postfix) with ESMTP id 53ECD1C0002 for ; Mon, 16 Jan 2023 08:55:42 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=mRy4maM9; dmarc=none; spf=none (imf21.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 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=QCNp0MjEp23ArfIJ213HXzBCfkQxI9y/8H4Y/9jbIO4=; b=JhckcQq1MDFUYwKXYiKJ3TAk3nS/TW2NongI6Nc7gKPWk9lNfutpj67f+Fa0f2BhlIMdIg K7wSC+mHvve+CWcUGTGNJNKfnwtv1dTKkCjx8YHgzugUfMjCtG7oWe6yh46nKl2COQ9PfT d65v7wiQYRwJheCqq/cjj3mDtJC+4qM= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=mRy4maM9; dmarc=none; spf=none (imf21.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673859342; a=rsa-sha256; cv=none; b=36JkwI5rZkaiX/g7xfyYPeR7D6ar+th/ceOPBuEph6fRIC8P7Ag4qOdqdLWMwEaGWAMWMk veDAO+d/j4hZIwjMFEaoYq+tbLLRNnjdoVuxiUEoDeQigk+VTucQ1tJ9W/peKBzKdht4PG W3aHu9uH4CXjUyxgyXzOk3p0xyMZnkc= 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=QCNp0MjEp23ArfIJ213HXzBCfkQxI9y/8H4Y/9jbIO4=; b=mRy4maM935+DV+YcCBIpsd71Lr 7sZO4iblXJf5AMYHhO9W/mCToFpztmdszLYgqR5sKv/vM9fAVUnf8efucn9dFSYbGcXlFHeiTHAf3 0C0h/yd1xVkdjYOBQQHk4u+/ydG55Gjr1yOASZm1MR2zrEQViFDCxXIc0GJEMZNHUtEr3KS1spLKr 2SaJQ5nr+iG1qcoZcGMaZCop5lBypWU0JzxeBIminN4jXsulD9HnMZYB4ZV/fu1AVAnVEoX3fjx/0 TRpSLxdIeo8qB9j6igNDIPhTzcuk/YMJbKfUZnM9nwuogF3O1RN/a//yMYM1fCsddLUO9lVdY4xA8 02hxatDw==; 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 1pHLHB-009Eg6-Dc; Mon, 16 Jan 2023 08:55: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 3/6] minix: don't flush page immediately for DIRSYNC directories Date: Mon, 16 Jan 2023 09:55:20 +0100 Message-Id: <20230116085523.2343176-4-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-Queue-Id: 53ECD1C0002 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: hqi896sg7w9tzgehijns7ixb8mzx4gw9 X-HE-Tag: 1673859342-727392 X-HE-Meta: U2FsdGVkX1/Us8DrWlLEe5GEhMzXMtPlMARp5I3dxJxtbkVAf63pmOk0z5QpqbBXzsVSNvwjRfbNOGecg/PCKGjrOh9GuPVa0OLg0GboTqzIfJLOhVuHWhRMPn7nxRSPuXf5b48YufM0pg5AnmtUIEmhuWDDDJXEbvTErPjJraxfBXTNwzAv7KT+2hFqcQDu5cV/RfzbCxJVASoOFucqXuqoMaC9yUZ5cPesNo6bxHWFXCRdlnTcD7PH14GIEisOXSMy4GuAgaocG9rPEAOAcDEN9DlqwZh81I/+2soOhTFEnOLvunPcGDtJ3PIVEi42BhlTwNWK7DeqtVvmDehd6VuQfcehAKz2aTXxkTx6gY+0q2s8HfOSoPAMuZTdGG4zFuhdlkTjN6FQnIwHHcJe393zgY3elB7ahZzUcrmkWmur42YOLcCi/HbeGQEiOhUqZ5ji2Mi5PriL5QB5E+KIwzIHNO3jJXM9UcUsPjnicOZ7DQ4lnhP1nQrXNDs6rj8ZC5wXgt78utpQ4icvKgbqi08e2B0gE1SpG6Y+48vK3dCYQ1KgkPxEXcTI9us5eyf/ANs91ffstop51+mEjTaYo98oPBhxQVTtAJbku3DhGOun2CtuS61fTHwhLGf7qPwadYpUKJN+xT4a1mCPdzXZyvz5TlmLNHjDR/LHzrckg2QNaDAYgilPywvUl6VpW8UAnob223TEs96sNllgrSc4JydrBj4E1ioaW2jGPxuTCprAtgcNxPWmyafEm3+dyJuDPwmjv1MA64jIOx5nC+Cfz73lSmwsj/trFwfsC3xezOdLHf9Z2krfz/2QV/9FshAYy+SqCPJqOmyneZRQkTYSlXS35sqKbIGAj+x21jNo62WdbmsJV7+HDUP8alDVmdj0YzzZCtcX44RSSQpcWZ3pp4V4PrYeild0hKrzoebTKEiS734AWyS0PY8quWh+21KwM7i4l2ejaBewmH/Ejqr uEjEHJnx H7OawHuXUryW3puGK6KObgIaiY9jgcYxnDBuUBefyMPLJ92hAHAnZ4Pz4KjL+8JrcgUoiMbs86KvYxt0kfvBIQqxswf37Ay6muw2OMFz1y1STE9nrzowOnNkSR817TpSGRKmySNbLxdWORug78vZcoy0GKdHDj+62Eg5/kofvjjmtE+0ys22k4zMkxw== 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 | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/fs/minix/dir.c b/fs/minix/dir.c index c9a3d520b72671..e9a1dc6bdfb0a1 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,9 +312,11 @@ 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); + dir_commit_chunk(page, pos, len); inode->i_ctime = inode->i_mtime = current_time(inode); mark_inode_dirty(inode); + if (!err) + err = minix_handle_dirsync(inode); out_put_page: dir_put_page(page); return err; @@ -350,7 +359,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,9 +439,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); + 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_page: dir_put_page(page); return err;