From patchwork Mon Jan 16 08:55: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: 13102754 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 EEB84C54EBE for ; Mon, 16 Jan 2023 08:55:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A1AD96B0075; Mon, 16 Jan 2023 03:55:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 956256B0078; Mon, 16 Jan 2023 03:55:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D06E6B007B; Mon, 16 Jan 2023 03:55:47 -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 5ABCF6B0075 for ; Mon, 16 Jan 2023 03:55:47 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id F17E41C6192 for ; Mon, 16 Jan 2023 08:55:46 +0000 (UTC) X-FDA: 80360054292.16.DC3F1CC Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf03.hostedemail.com (Postfix) with ESMTP id 6CAE320009 for ; Mon, 16 Jan 2023 08:55:45 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=45KjjDK9; spf=none (imf03.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; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673859345; a=rsa-sha256; cv=none; b=m9nDpSiEeXsNDfTbo+tISgZhTnfWARa+tVyUsYoKcA2RwbjrmbMEwp+8TpQmIExLK47yHx LDqtMZOdDtmb+gkCdXsUPF0xMwhz/shu1h1b8EzbCPF2QpOS+lW+afY31gKrcAc3RGPkx9 P9122yxS5RanY2GbDSbdt5WqY6TSk5I= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=45KjjDK9; spf=none (imf03.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; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673859345; 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=6X3MxJ3mew70DWz5X1czLDfWyKjYo30EpqdKm2WkGclqSglCDIOf94/w5/j4a60p78rGRt 9TWeBksnTJqrdrqNg0ywz18JBE8BBI1Q4oENAvxzcV3u9FYVkHDloCn+hvJAHTh7Bm5WjW bEdrm5kmAONUZyBcGPeqdX7QzSE5pao= 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=45KjjDK9HcGMupbHi8/ccd2lsk fppYv0+p3TbWlTYws63J9CCnCl/AjpUsqGf6TmfN1ePwYYudyAtmZ7Unotrxgp2ANUKUK5KL7BHR4 XA4mCttnzQ8oVfaW6fBs2R/evPrQ3GwRokqUv7AfYrw/mu4L2IROYrxoD9Yw7fUYfhtP00HKihi/q Y87KScBT9rsWb3KqrM9iZM2WU0eTnF9eVl8y+AFynnB6puXTb1ojZ3/NatLxoXwNQJ5LMF2tkinht tR4wbttPfOvNRgbB+u/+C0jDHTsi82wKIzzYrY9Nmmejm1QgKrISw+bDPG+QRL4x4PZmRF3knVCA8 Gg+V8y5A==; 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 1pHLHE-009Ege-4b; Mon, 16 Jan 2023 08:55: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 4/6] sysv: don't flush page immediately for DIRSYNC directories Date: Mon, 16 Jan 2023 09:55:21 +0100 Message-Id: <20230116085523.2343176-5-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-Rspam-User: X-Rspamd-Queue-Id: 6CAE320009 X-Rspamd-Server: rspam01 X-Stat-Signature: 9ouykx3pifqcpc1xaep994ck4njszspt X-HE-Tag: 1673859345-206424 X-HE-Meta: U2FsdGVkX18l3QGz7z/BWvY1xh3KSaMyak6G8SvJaYRgFnmPfEKBKICstB1qSovduQnNnhJTmjFxzByaumfZzE8X78X6QOUCWlTyyRv1J8F+2N1StIeHv9DKX4otnQNigGp3fYQdL+JNTS2FaPj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m@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)