From patchwork Mon Jan 16 08:55: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: 13102755 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 5DF70C46467 for ; Mon, 16 Jan 2023 08:55:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB90E6B0078; Mon, 16 Jan 2023 03:55:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A42796B007B; Mon, 16 Jan 2023 03:55:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 86CEE6B007D; Mon, 16 Jan 2023 03:55:48 -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 746F06B0078 for ; Mon, 16 Jan 2023 03:55:48 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3A1CBAAA9A for ; Mon, 16 Jan 2023 08:55:48 +0000 (UTC) X-FDA: 80360054376.12.550BC01 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf14.hostedemail.com (Postfix) with ESMTP id C555710000D for ; Mon, 16 Jan 2023 08:55:46 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=DixsK5MM; spf=none (imf14.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=1673859346; 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=xbreCkL0BBq8LkiMvjur3qmmfGNv2MWOawPrewKC0L0DuioyBrX8SC1JEC6F1si58hAsms vy9652ScaUFYkBUGxmHfqBRXIte6sH7xl7vnd/1v2K4rugB7L+tswOsNGQh2mEmJXHDC6a fvZuWYJpG/2DGBEHPbWgX7IgZmEiUdM= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=DixsK5MM; spf=none (imf14.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=1673859346; a=rsa-sha256; cv=none; b=U5cmqcSNIkNEA3r05oc6WXySHYXyVT/Nht49r/KCnB9KIisK1ptDhctKAy2TorVL/HMfnO c3yvU755Itk/Y+zKoFV79c60oDcm1+RDg5lcWZ3Nm/yWdCgFuGrnV693znVsxRUx1CQwJZ 2Dj2QyiEGiwPUWUoH4Pinry8TaCqtQ0= 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=DixsK5MM2bUui4MhH0EvJ72lp2 WhWrahLLw2Q/qCkiyikiq6XfFLKWN9P3q0gTvzEOIuokGykPQDu36/ApNtX+68TdqIpsiIvwbKmBK WChJb99QuBiIiAmdjFhPdecye2p2/hbTlow+e87ry4NaVYuv45yJKbm1BSHtCEMeY9IzsEzuyhHsI cRF5YIYL5sx5LSKyoLnapfmAikJcKAOPzh5nCv/DESlQiHoqGnAZbDOD/SpNLlksyaLknUB1nwSFN tFu76c7m97LBY5Ji5xIZkKBmr+3mJx0/EGuTioAoPwY/iSj9JSHSAP1zp2XtLL4UKxG2kuc2qdJzB MyLorMnw==; 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 1pHLHG-009EhF-Sk; Mon, 16 Jan 2023 08:55: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 5/6] ufs: don't flush page immediately for DIRSYNC directories Date: Mon, 16 Jan 2023 09:55:22 +0100 Message-Id: <20230116085523.2343176-6-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-Stat-Signature: 5667t7xk9bh5gdj1ei411bgba4utds67 X-Rspam-User: X-Rspamd-Queue-Id: C555710000D X-Rspamd-Server: rspam06 X-HE-Tag: 1673859346-662214 X-HE-Meta: U2FsdGVkX189amugnUGVwQWCch2i9Bk5puMcHaamASG/ZUdFDjNZvEvliKOC+Ja/irXW1pDgageGYHYDUuKSGEAFpdijq1p2MHBuRu0+x9MFGS54yiRVEjcApBtapAGDnvMxUdLqNzhONv+T83oniR4teUdCTRT90zzRHR6xNexGqcQMt4hNfLOwXZ+BZXYCuJAqefYk7HvqQ/MvmjfrqQaNaEyvxHHi5G2XjJZZBrp+yMoDRkYSh7rnGyoANLMGp/mY76Rj781DI9UJ6zuEL0iC3RAtbuKNF3/+tdjqgdUrIAg3vqXZpsMCosKiZMovoJB7g2KBRp1bHxAoPVcezfUz2V5MSsBo1ajsiY6asPzoC86AjJvL9HF4G97L+VVSApQSJop0EC8I7dBA+ZPvgdYLHcjptev+FKzL3HKuGMPa4yKuEp0OEPc+sFGJSwroDIrTmJv4hqzAlqWe+NG5qpcq5Yn9GPD7/irkJEcYWT3+MCjnnBne0movg0n2gKQkeFy9M3nqQZsU4EV+729kkJ/nOAZOpC/o2o1rJZRS815bJ02xbFlGU+nzv5Wn1CIdBxJPj2/IKoAAYG5+PsV+c0WPrCMqXiHqN3A4c2ZMqpWdHE0eaukNWqZPgVb5o0lwYzBkYnOiQL5cc7zyViHdwBGKPaelFbHmRk0uRXetBirpItBkiNf57dsw2zjfFZx4xE8my/zc4cxLrKruO67e5Y7fiMmeLKAk07GZsKbl8TJ7ujGRHZf1elu4WHEFC352mDwayoUGf5ehheqyeeBT0yebqPmMdSE0g+jD66ZR+lPdwjTGvMVK050waaTdyaRmiXT66dBxnnY7SlezKmKaPqBBxvO6OKuLP4kWcvF6czXEHdFN3UiUTa/QF/IC4uU98Jgnnm0oT+SiADf3+nmQLI5JG28se0tfSMyAkoq7OD6Q7ce8QaYtTq056fmsQLpeTOmJON6FI+eYT7Hehgz U+ndnlG0 AUPzZzgwF4bn1jqqYb2Y8oahP+lPKgKD08dtsJWSyKzMlzaptavY/zJg3N6js4eN9e39DK6tbFjeoZrmmX4B8ye/OX68jfOLcrYoIdjPQSvimP3Vm8P/50BwrCJaAl5guSwE9QKgEuZdewtgixvnHPyaNOgFVqnW3vdoUil84XVmvaueVGdaOKahlIQ== 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;