From patchwork Wed Jan 18 17:30:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13106732 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 E40C9C32793 for ; Wed, 18 Jan 2023 17:31:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 88CD86B0083; Wed, 18 Jan 2023 12:31:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 83BA06B0082; Wed, 18 Jan 2023 12:31:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6DC8E6B0083; Wed, 18 Jan 2023 12:31:00 -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 5DDDE6B0081 for ; Wed, 18 Jan 2023 12:31:00 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 38E98403B8 for ; Wed, 18 Jan 2023 17:31:00 +0000 (UTC) X-FDA: 80368610280.26.BA0E0B0 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf29.hostedemail.com (Postfix) with ESMTP id A2E17120028 for ; Wed, 18 Jan 2023 17:30:58 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=U05qheov; spf=none (imf29.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=1674063058; a=rsa-sha256; cv=none; b=FXiFQZtRXfTj4PmNq85iBGIQqFukhdulC/pr969CABGVdPWIvjY2SP5bpB2IYQEzLJ0/g3 /V6Pd2cFe4ay8jXuETBOFMn17rNmQJ1Hd9mSaYjJA+tfNYcNPX1Ouj8328WvIW9/ZOgk17 D76sCWr+EvVFL105osGL6OoNd7a9GFY= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=U05qheov; spf=none (imf29.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=1674063058; 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=uyHem9QNRIeubFLargNPuyGwdhOju9e+FE0OrDN4pApo4DWFs/kZcGuii3wtRZb54yZ357 /F/Ly5njGIdxNE5kC7NbdptlwwtXl4Fi+Hg0xTgg6x4Et6evLfM05om5ms1VQ4VRFrIuJ6 I/xbkMV3jZOcEhX1obFjO10Tt/mLZm8= 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=U05qheovgxBUbMhTKKemw5ZM2W +lw1zqiSw0fTKUbYGe4qcdGWpVpSVtuCixVD8X05UaJPzH0rV12qgPwg6yrdCoj58546B7wZkvItN aFBV6i6UuPYSTlEDevcYjEqKtWYeXCL9YJuF2o0ktbYV85kZYtLzrPpqLCUnrQOdm9tdrLM0zEJTT YGK7YdkqWaEvFJ/1iWN+aLUbVyyZE/fW3pvAcev6gYBqg4UUNvQ7LL3/j/TMEsY9lwC2STBR+1xQ3 OAGX583TWkypdhRyd5ZIFMj5ZNc1iYMPGalHjY5KsPCHBup21MLTKOruniP8ileEqsqVnakRllDNF lm4B09wg==; 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 1pICGu-0022EW-GD; Wed, 18 Jan 2023 17:30:49 +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 6/7] ufs: don't flush page immediately for DIRSYNC directories Date: Wed, 18 Jan 2023 18:30:26 +0100 Message-Id: <20230118173027.294869-7-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-Rspam-User: X-Rspamd-Queue-Id: A2E17120028 X-Rspamd-Server: rspam01 X-Stat-Signature: gd5d6ncyon36ntbb51zdmdi36nqz5y59 X-HE-Tag: 1674063058-7875 X-HE-Meta: U2FsdGVkX1/PEtrrtDqZEsrIJho2kTKQMluGiMxHYq0gRCvQA8L9An7ZZCFVpvQRoNFaca0PW8ZoMrn5unj7b+/zjjigoCI1Vx/UoOXfUfxkWTWZhvOd3CCa9qqkaPV5XsPsa+xvFrQ+kp64nxnV0TlTqYX+OXl2x76Qc4Tn4pKh7+o/N1ZStaP3EGAMyK2yKLVUYaScZYPpH3ZNrtKA2kT7wbRoOYNbdB4qUCaGqWaxYwmZcgjDSKSFWMcjaTAvTo7N9kVHrDfA5DowC+KmEQA5kWUJOrl1qjwpORiAbA239Djujx6ZAopShScheveGVnDkVCCrt+Flea/4Gq2Nlwfv+ZGAqh35NUTiefK/uU5uDXYoyr1KM/f3Bi998NkVoTHxhEjU9vE9GCBvVtarHLjx6tstzzbxgnxgxk3RYsssO51re5iBSu1KCHOrBam6Pm4Pq21W8ZPClvp++j5wNL2znQPFPko535y6CUhIrbO2akJdcEJnkO/vZ2b+pd/Uui4eMI9oYs6J4I+5WT8b4FfNVWonChYWWyXw1qYA55Qfki48c98ycnjd77nyBBul8n4FFd9qk6mdtRmZsSuDelCByTVVbGYEJajEjbDsyXKgKjT96onzcPWqptttHCpD6z0NY0XN0Hrz2RoDGR6NVktbG2P7Ot2zBHRi53Gan4S3gBSsQ72priKqDNXg90k/EpKHnFa12J+7e6Hx8qtU7vHrnzE3KDhFABGuEetwhfbG2k+6e+uoK2uhBOiDu9rpXbpv9WfPYn2smHBLg+3d17iEAxDsaZ2NwUIl9MZYwkAOCipdjiJeHfDVgPLmixuRSNSgFy0eS8Xi1uT3aO77YRk+QME5kScko95ABZhy+EbGA3NyTSZuUJCxBzNZA1b+WGKmeTkKxOUGwmlwVFAFyGsM+5Kb197IWCUq2kRBOqqgpYZpkRSAhvuDajqhC4px0ysLWo6fVXU0HJtBbvV hQIte36W 6wn69oA4FKgry+i0becbafOsKCVvadDCzs19/iDzSPpZ9OKMRecsFj7OtA0lt+qqF+/Q+0xcwuYs1qe+NiFZTrWisSxASiT2N31/vjry4HBPYQwMndDjFFIEslxJEK6R0JSvQSP4rdu/sYAJxSPKccwycXeHsMx5eaD4DwDcYSPEh+6enMjMl400kHA== 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;