From patchwork Sun Dec 10 11:35:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13486382 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2A9C5C4167B for ; Sun, 10 Dec 2023 11:36:14 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rCI6Y-0000pA-OH; Sun, 10 Dec 2023 11:36:13 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rCI6X-0000p4-2r for linux-f2fs-devel@lists.sourceforge.net; Sun, 10 Dec 2023 11:36:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=8+1qvF+S90X+3f5I0kunpxz8Hd4Y0sJorduuL2QvI20=; b=mHdDPi4LdCinQ8zAK1rsWDRmrD mX29teYzZXdXgGUs49o17bIST1WvNQYH2xNVnjp5ZDDqM2tAfMS4SGMC4vjVFrfB0D7+iT3p/IPVC RS9gw1p4sCuITomIbkvtsMcUWiD83cHA91CZqtnsD890NwspU4Z6IEk+UAURIQO7TXhY=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=8+1qvF+S90X+3f5I0kunpxz8Hd4Y0sJorduuL2QvI20=; b=m uFIFZ49f4KMzDPQFfe1pb4N7oO4H/0kfbA8Kf3fPqj3BpkgLEJjHbVz+0l8crESFrkEuOuypOCyrM ErZ1JrSBEqHh+X/D+/8jf/DCTA4VoRH3bJgdwuPYk6fKhmh2rdmK/++ZdgjNEPMi1jwR4aeb/JLNn CmXzfcXycqz0mMlo=; Received: from sin.source.kernel.org ([145.40.73.55]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rCI6V-0000U0-0A for linux-f2fs-devel@lists.sourceforge.net; Sun, 10 Dec 2023 11:36:11 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 268C7CE0AD0 for ; Sun, 10 Dec 2023 11:36:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8C3AC433C7; Sun, 10 Dec 2023 11:35:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702208159; bh=rLcyF1ZrszFFVhog4TqrXAnFuqCYoRmQyE22OkV/4iY=; h=From:To:Cc:Subject:Date:From; b=enRuddIEf8bqGYbgra4E2dbFPYn2xIF/4SgpYcYlljGw7xqldMI0SUQIgjvBO2nuA BKwyGFp0hMoAm4BiD+wo9ZE9GHHSXHVSNQUP92fw3zQjDW9b2/Hp5z/L5tv3KJbqby 8SaZ056f/hCouqDOEXQglytYMp4RBzHAtfgz2DQA2TY3uBHmNpNbmAfzMtQPmPosCN CnGBtmVKkIslvgul/9tI9fhJkuHrBXbszL6W0YqMp29yvWLNS4Oz4QmCVrDKzrEB+M 41GlkTNJN4EkLSvW8GBmhHLNHAfIMG9+ohCQQjFvmms8VWHqdsuiZ728EhdNnDLkvi 0d/fCyzrGQPLQ== From: Chao Yu To: jaegeuk@kernel.org Date: Sun, 10 Dec 2023 19:35:42 +0800 Message-Id: <20231210113547.3412782-1-chao@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Headers-End: 1rCI6V-0000U0-0A Subject: [f2fs-dev] [PATCH 1/6] f2fs: fix to tag gcing flag on page during block migration X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net It needs to add missing gcing flag on page during block migration, in order to garantee migrated data be persisted during checkpoint, otherwise out-of-order persistency between data and node may cause data corruption after SPOR. Similar issue was fixed by commit 2d1fe8a86bf5 ("f2fs: fix to tag gcing flag on page during file defragment"). Signed-off-by: Chao Yu --- fs/f2fs/compress.c | 4 +++- fs/f2fs/file.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index b35be5799726..c5a4364c4482 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -1036,8 +1036,10 @@ static void set_cluster_dirty(struct compress_ctx *cc) int i; for (i = 0; i < cc->cluster_size; i++) - if (cc->rpages[i]) + if (cc->rpages[i]) { set_page_dirty(cc->rpages[i]); + set_page_private_gcing(cc->rpages[i]); + } } static int prepare_compress_overwrite(struct compress_ctx *cc, diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 60290940018d..156b0ff05a3b 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1312,6 +1312,7 @@ static int __clone_blkaddrs(struct inode *src_inode, struct inode *dst_inode, } memcpy_page(pdst, 0, psrc, 0, PAGE_SIZE); set_page_dirty(pdst); + set_page_private_gcing(pdst); f2fs_put_page(pdst, 1); f2fs_put_page(psrc, 1); @@ -4046,6 +4047,7 @@ static int redirty_blocks(struct inode *inode, pgoff_t page_idx, int len) f2fs_bug_on(F2FS_I_SB(inode), !page); set_page_dirty(page); + set_page_private_gcing(page); f2fs_put_page(page, 1); f2fs_put_page(page, 0); } From patchwork Sun Dec 10 11:35:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13486381 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A172FC4167B for ; Sun, 10 Dec 2023 11:36:11 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rCI6T-00078x-HJ; Sun, 10 Dec 2023 11:36:10 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rCI6R-00078k-LB for linux-f2fs-devel@lists.sourceforge.net; Sun, 10 Dec 2023 11:36:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; 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:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=jcL7Yex4CvXuPOOYTfHIYu62fStL4uVqhA/YSylsCCc=; b=ekMY7cONZ5cP8C5AyFSbTzOFlh EN1oE94hycwKFvtyAkBIk+8ZD4miPhnfsNOyT3c3LDDeHXgjrrP+kd8qp9fdXoyREG2DYgLzYTW6e mVdODk0sVwvXnSxvtcKvEtbpPOhXc0XrNfYcSpotcPWhDpY5pDmlQXftMTlxdEOALiE0=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; 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:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=jcL7Yex4CvXuPOOYTfHIYu62fStL4uVqhA/YSylsCCc=; b=U0dgnSELgkprC1d9blJNSo4Y/i GYvWkSTqpeQ6gbqZFg/gUfHDfzHmJCp2NSKkbCCcQVfrNjn2Mhy3qYXMhFX9d3HFxXFb+3pf/E+u9 u4/Ly9jQVk7ZvyUDjVY/85m8qG8f79D4ieFpu9/bJtjhJK4Z4/jSxbNAr0+deDOGvhMg=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rCI6R-0000U5-H9 for linux-f2fs-devel@lists.sourceforge.net; Sun, 10 Dec 2023 11:36:08 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0B8BB60C5B for ; Sun, 10 Dec 2023 11:36:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E864C433C9; Sun, 10 Dec 2023 11:35:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702208161; bh=dLds5jvPY7Yl05BDqmaObZ0ySYYRFXngO3CypVRgnUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f0r5UZOClT+qxOhTdmYQ5XIChARJWxNgHecNvTNmjAykLquVh3aAgFAyVWKqs2xep qZREYMfFsuYh0dUfNi9MHVzHXWebCXChp9SK6Bjbc20Y8MSlastnbfp3NIJF/6s5Cx KAxkucpK0lghl+M4lfsuwHNlpRYHfo14s6Z/OMF7Ld/ewODQSRj0sBvPw3lfXk+riR wizq5S8I54LwWIrKPmNy3ZcJlpE6KTcZ8M/77szdlhGFcTOtmeEZoblhMNagdh9KdM W3SwghyJX35n9dRggoyvpJS9YhzTpPa8PGq3Exvx/H48b6W1pGCOrwjVZ83ZbmJvvC 9UdldAVXXF8Hg== From: Chao Yu To: jaegeuk@kernel.org Date: Sun, 10 Dec 2023 19:35:43 +0800 Message-Id: <20231210113547.3412782-2-chao@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231210113547.3412782-1-chao@kernel.org> References: <20231210113547.3412782-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1rCI6R-0000U5-H9 Subject: [f2fs-dev] [PATCH 2/6] f2fs: fix to wait on block writeback for post_read case X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net If inode is compressed, but not encrypted, it missed to call f2fs_wait_on_block_writeback() to wait for GCed page writeback in IPU write path. Thread A GC-Thread - f2fs_gc - do_garbage_collect - gc_data_segment - move_data_block - f2fs_submit_page_write migrate normal cluster's block via meta_inode's page cache - f2fs_write_single_data_page - f2fs_do_write_data_page - f2fs_inplace_write_data - f2fs_submit_page_bio IRQ - f2fs_read_end_io IRQ old data overrides new data due to out-of-order GC and common IO. - f2fs_read_end_io Fixes: 4c8ff7095bef ("f2fs: support data compression") Signed-off-by: Chao Yu --- fs/f2fs/data.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 27015b7875ae..dce8defdf4c7 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2556,9 +2556,6 @@ int f2fs_encrypt_one_page(struct f2fs_io_info *fio) page = fio->compressed_page ? fio->compressed_page : fio->page; - /* wait for GCed page writeback via META_MAPPING */ - f2fs_wait_on_block_writeback(inode, fio->old_blkaddr); - if (fscrypt_inode_uses_inline_crypto(inode)) return 0; @@ -2745,6 +2742,10 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio) goto out_writepage; } + /* wait for GCed page writeback via META_MAPPING */ + if (fio->post_read) + f2fs_wait_on_block_writeback(inode, fio->old_blkaddr); + /* * If current allocation needs SSR, * it had better in-place writes for updated data. From patchwork Sun Dec 10 11:35:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13486384 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1B972C4167B for ; Sun, 10 Dec 2023 11:36:21 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rCI6d-0006B7-1b; Sun, 10 Dec 2023 11:36:19 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rCI6a-0006Az-P5 for linux-f2fs-devel@lists.sourceforge.net; Sun, 10 Dec 2023 11:36:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; 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:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=iU1aT0mmJyAWhLFKiZQwM8RSU3RFe2MlFfjAeYq2rx0=; b=lNuekq+H67b9d8to61KfWHxZS1 5F0dDiUt8zqGKBpgEmsur4SlOEEvAnVDwMJWzczQcvKfLb8vvPhO+Safn2s5rStX1F0HRockG3Jdj WeigSXT6Qi9hUiprhI0MEWNOlzLRVI0151WftA4dPmJpoES0EYXPbL2bsh8TljVdz2TM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; 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:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=iU1aT0mmJyAWhLFKiZQwM8RSU3RFe2MlFfjAeYq2rx0=; b=eyjRuRZ0bm23BpRPLxarnGVmvA oEAakpr3bswQHKzeOyjnGVCEmuElxWVkizzGZjoQHz1VcmWHHLAh9hFcX02QqAEXeGpaEGxN/8qRg NBo2d63PGFW1j3fja5UM3CEfSVqTroPq65MUUT4YclQeGz+wfUFa0LtpOZfv3LvIsyx4=; Received: from sin.source.kernel.org ([145.40.73.55]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rCI6a-0000Uo-BM for linux-f2fs-devel@lists.sourceforge.net; Sun, 10 Dec 2023 11:36:17 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B807DCE0AD4 for ; Sun, 10 Dec 2023 11:36:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58A48C433CA; Sun, 10 Dec 2023 11:36:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702208164; bh=VE5AOlHytLIsYFQS7gWhjGZv4ckuyxkhp1hOk55UcyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tdPbIg6hNIf4BrSLKKH6gkTlFHSLALJrVqs3hKrjjDzV1Z7N4lyErMKyrSrhPqF7d iDT98jSa2Mz2myBQzmpz0LGNxShqhREACRFoJFP8z9mMvMC4j7W5fVpKMk9dvkoEht ZBJYvH5X4Eb4MjaeI0gwVC6rd7/wMWDI09mb4LImSzt8t/LBzhR1tibOn1tVzB831a kyx429rqHwieBBykrwNU6dE2nr8JRecr3bFGyPcb873PK3V2sKqqhhLxiSkvC9A+Cf qdJCcEvhTGnogiltiFqOifxY4+RzPMm8+eZanbGQJTjrsqQF0hP6+oDYrsX8KmHQnS /RHhQZ8M3q9aw== From: Chao Yu To: jaegeuk@kernel.org Date: Sun, 10 Dec 2023 19:35:44 +0800 Message-Id: <20231210113547.3412782-3-chao@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231210113547.3412782-1-chao@kernel.org> References: <20231210113547.3412782-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1rCI6a-0000Uo-BM Subject: [f2fs-dev] [PATCH 3/6] f2fs: fix to check compress file in f2fs_move_file_range() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net f2fs_move_file_range() doesn't support migrating compressed cluster data, let's add the missing check condition and return -EOPNOTSUPP for the case until we support it. Fixes: 4c8ff7095bef ("f2fs: support data compression") Signed-off-by: Chao Yu --- fs/f2fs/file.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 156b0ff05a3b..5c2f99ada6be 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -2813,6 +2813,11 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in, goto out; } + if (f2fs_compressed_file(src) || f2fs_compressed_file(dst)) { + ret = -EOPNOTSUPP; + goto out_unlock; + } + ret = -EINVAL; if (pos_in + len > src->i_size || pos_in + len < pos_in) goto out_unlock; From patchwork Sun Dec 10 11:35:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13486383 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6B3F7C4167B for ; Sun, 10 Dec 2023 11:36:17 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rCI6a-00044B-Ii; Sun, 10 Dec 2023 11:36:16 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rCI6W-000445-Ug for linux-f2fs-devel@lists.sourceforge.net; Sun, 10 Dec 2023 11:36:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; 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:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=LoV3aU+OeYj0J0DMe7rQ2hXcaDTfLCZAvSvKZ4YzN/M=; b=akbSTOjcd0HpD1G/LilRa0Z5Df hnvYo5PYbr4O6oLtYaNKUMw7S6tkN5p5nB/CZV8hZaaJeP45PZjkFBasvIG2RWOpLYHUQ0cqEIr89 Drd5oX/0WMhYRWZlOtiDKaislQD9Wya+stEKHVUySBnUD/SyQeGwTHBknM7ZajBoAG9Y=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; 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:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=LoV3aU+OeYj0J0DMe7rQ2hXcaDTfLCZAvSvKZ4YzN/M=; b=GgtlHSOnvRkAxbCkZdojKEklqt Vbyyns4nsauxKrMKe8F3IvTK9JJuHgQiqoxHyLqs1pi/B8Y8pOaUcB7RjFV/0GRLwvQHSoQgvX+Vz PcnzGVYsmaZdzw89rNHuWo2luoPVPxk1SYAFTUDXu10tIh0SOebGhp+qr3kdaQibCgaA=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rCI6W-0000UZ-Bj for linux-f2fs-devel@lists.sourceforge.net; Sun, 10 Dec 2023 11:36:12 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E41A360C5D; Sun, 10 Dec 2023 11:36:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2476C433C7; Sun, 10 Dec 2023 11:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702208166; bh=hIUlpOJ3aDB7nGkcog2qFsHcADMxnRlMDotLaomis/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K6wvItDiHuOzned+j4BhIjpFIQoZDWqwoE4wwGaR4Fw+eY5+AkRtDWnwteNFlwMrv +CaTN0Kh7EwMjhsSMWh/CfmCoTSjUstW04Q4ro+besEvfsC0nVcfwpr256ctyDlolw QCKDXMbUs5vv2nMM4qA7zii7GlhNcLsokDcrr8yVYiHm9OLgW6xznggE816B5fwOnb o/8/3pCllvh2sUfJolQ+l0fVepwd1uImEVX8aMmesN5mM8e61tuCJROLZI5Pl1XUrO xOK08NqPz5D2euciBnLvdkzhWYo2cVrDSUTy+0hPQoWwhowAezT3QysEst52Hq92Tn GYBWdA36GuvXw== From: Chao Yu To: jaegeuk@kernel.org Date: Sun, 10 Dec 2023 19:35:45 +0800 Message-Id: <20231210113547.3412782-4-chao@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231210113547.3412782-1-chao@kernel.org> References: <20231210113547.3412782-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1rCI6W-0000UZ-Bj Subject: [f2fs-dev] [PATCH 4/6] f2fs: don't set FI_PREALLOCATED_ALL for partial write X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Biggers , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net In f2fs_preallocate_blocks(), if it is partial write in 4KB, it's not necessary to call f2fs_map_blocks() and set FI_PREALLOCATED_ALL flag. Cc: Eric Biggers Signed-off-by: Chao Yu --- fs/f2fs/file.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 5c2f99ada6be..1a3c29a9a6a0 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4561,13 +4561,14 @@ static int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *iter, return ret; } - /* Do not preallocate blocks that will be written partially in 4KB. */ map.m_lblk = F2FS_BLK_ALIGN(pos); map.m_len = F2FS_BYTES_TO_BLK(pos + count); - if (map.m_len > map.m_lblk) - map.m_len -= map.m_lblk; - else - map.m_len = 0; + + /* Do not preallocate blocks that will be written partially in 4KB. */ + if (map.m_len <= map.m_lblk) + return 0; + + map.m_len -= map.m_lblk; map.m_may_create = true; if (dio) { map.m_seg_type = f2fs_rw_hint_to_seg_type(inode->i_write_hint); From patchwork Sun Dec 10 11:35:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13486385 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1E6A8C4167B for ; Sun, 10 Dec 2023 11:36:24 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rCI6h-0007AD-4g; Sun, 10 Dec 2023 11:36:23 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rCI6d-00079q-Ob for linux-f2fs-devel@lists.sourceforge.net; Sun, 10 Dec 2023 11:36:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; 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:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=AHfFwKYujQQVoHs5zJPh6KRKf6rlctCcGvr++i9cGOI=; b=i5hI1m0oaXOOwZj2ebAQN73tHV bGwCDwCVl8baBIgwmYm31W184LnmRrzcWpgWSONxTfKQ+YcJUQQk9cdEx356zKBHlrllYCZSiUc/P Eya3DK6CzgVLJt2s6XZVXTg3f7FowearXcYX9U6m9vAEjl2/2LD1k1RTYzOK2Bv71mi8=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; 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:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=AHfFwKYujQQVoHs5zJPh6KRKf6rlctCcGvr++i9cGOI=; b=PdOpKKC6T3ugILvTSLJrY7KyU8 hld6j/hwsZj52Kb7VdazCAEGQyn8RpRxOvp/F2Qz71XO9Zmf1M5i0LrGW63L4/OJFY1m4fZf178Tr iCc2euTdiOtPbfCpnCXocuBgtoNe9cpCL3vM82wsstJaklVR5MN+0SoEbDMm3DBcvTyE=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rCI6d-0000V5-KB for linux-f2fs-devel@lists.sourceforge.net; Sun, 10 Dec 2023 11:36:20 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 37DA360C5C for ; Sun, 10 Dec 2023 11:36:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C726C433CB; Sun, 10 Dec 2023 11:36:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702208168; bh=17M2pG5LF+yTUT42vRyb2J9RQolF4UPApTsylmOgOqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VhKpZ6bMkrzIwnh96I+1vV0Y2OCIZV/ymzd7baK1mrWUah3lbAoHJjqI7MB/s3SRm Vl4hGgaRM7HzUXf8iw7IiZQTR7CQzPHnmb0NF2RrsVZY68DRUwdGsaX3fwKzgXd2zJ JKdR5UcjWAcNU3PFutjamQmTrdJ6ubvaKMJdHjtaw927MIKe9aFFER8GfR5+fqAqdJ s7YwuahFs/xFV/RUX/bvsLCDeKpZ+TG9cuTsIiDfGsdYKC8ihmdV605qwAcFRtmUXk FyPeza8fPKgHSCoeyAaBiwEjhicRI1nEZKg88Q61Hs5j/YhVbRf2K4ZkP0h16h6wGZ 5KsDwZJHvABfQ== From: Chao Yu To: jaegeuk@kernel.org Date: Sun, 10 Dec 2023 19:35:46 +0800 Message-Id: <20231210113547.3412782-5-chao@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231210113547.3412782-1-chao@kernel.org> References: <20231210113547.3412782-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1rCI6d-0000V5-KB Subject: [f2fs-dev] [PATCH 5/6] f2fs: fix to restrict condition of compress inode conversion X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This patch adds i_size check during compress inode conversion in order to avoid .page_mkwrite races w/ conversion. Fixes: 4c8ff7095bef ("f2fs: support data compression") Signed-off-by: Chao Yu --- fs/f2fs/f2fs.h | 8 +++++++- fs/f2fs/file.c | 5 ++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 65294e3b0bef..c9b8a1953913 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -4397,13 +4397,19 @@ static inline int set_compress_context(struct inode *inode) #endif } +static inline bool inode_has_data(struct inode *inode) +{ + return (S_ISREG(inode->i_mode) && + (F2FS_HAS_BLOCKS(inode) || i_size_read(inode))); +} + static inline bool f2fs_disable_compressed_file(struct inode *inode) { struct f2fs_inode_info *fi = F2FS_I(inode); if (!f2fs_compressed_file(inode)) return true; - if (S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode)) + if (inode_has_data(inode)) return false; fi->i_flags &= ~F2FS_COMPR_FL; diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 1a3c29a9a6a0..8af4b29c3e1a 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1922,8 +1922,7 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask) f2fs_down_write(&F2FS_I(inode)->i_sem); if (!f2fs_may_compress(inode) || - (S_ISREG(inode->i_mode) && - F2FS_HAS_BLOCKS(inode))) { + inode_has_data(inode)) { f2fs_up_write(&F2FS_I(inode)->i_sem); return -EINVAL; } @@ -3996,7 +3995,7 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg) goto out; } - if (F2FS_HAS_BLOCKS(inode)) { + if (inode_has_data(inode)) { ret = -EFBIG; goto out; } From patchwork Sun Dec 10 11:35:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13486386 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 57A57C4167B for ; Sun, 10 Dec 2023 11:36:28 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rCI6l-0007Av-Eb; Sun, 10 Dec 2023 11:36:28 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rCI6h-0007AP-Mn for linux-f2fs-devel@lists.sourceforge.net; Sun, 10 Dec 2023 11:36:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; 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:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=glIgoNkSYkwhi0PRsV07rpou1zBi+ZyTwk4LSDuCG/Y=; b=cIWjC9Hx6rJh+1LhPkJRmOGJnI 8S0yN+ca6g0G/B4Xym5WWoepAZn+di8ZIYfq5BN26rqoGDkkYktlayn00157EirQ+xD1ytrTW4noS 6DPZPJG41cAomyUS6xsAEClZ3jiExR6iSXdH9UXLAluWTngF3vyDVXXT5icuBtFgqkIc=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; 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:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=glIgoNkSYkwhi0PRsV07rpou1zBi+ZyTwk4LSDuCG/Y=; b=gLw1nHZ+HDVm/6XfS77el6UjHU ApZiDvItTNf+o7l48wKuKpisfILdtIt+unIBrqVanJ5UICzmGTVqel4dQDa7KsqVnL+DyxUUi/5nl /l1k1Hn2JairgvxccVpRDP/hOdlkCwB31Rv9H+5bxiYdc0jMfFoZLAA32K3hbHvGye44=; Received: from sin.source.kernel.org ([145.40.73.55]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rCI6h-0000VE-I4 for linux-f2fs-devel@lists.sourceforge.net; Sun, 10 Dec 2023 11:36:24 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id F1835CE09F1 for ; Sun, 10 Dec 2023 11:36:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8620BC433C8; Sun, 10 Dec 2023 11:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702208171; bh=Iri4gOpboj6iTV2Mhz6ZedWpHWCjZ25WFJYUfWjqqLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KbTG84Pgti9Rg9nuZefYagaar6MmND/pXxRIOKNqNqT7kT9DvjLj816128RaHnyWA 1t856A8+B9XNMgz1U6jkxsyJZfSbbXH5LsaHkzIxLMHS94A6dr2KUzJHxhqUCpESI6 2oifUZYES9vTPlrjTDMTkq8Xws9JxGq29abvtKfa+B84E/5BReFxri9KwO907sef/O YW7ozaSjlb5xmxfpYfqPd9dhbQJ2Nhwx6D+Gbcan9V3Pqy9AdGjLWVzv/dUHAtFEoq Auxeql1cK/woKVsSH7GMCnjm0ClHQnpn5xteCEPDbhx8FLCdeL+73O6coYb8KAqZsB awUKW8/7XI8QA== From: Chao Yu To: jaegeuk@kernel.org Date: Sun, 10 Dec 2023 19:35:47 +0800 Message-Id: <20231210113547.3412782-6-chao@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231210113547.3412782-1-chao@kernel.org> References: <20231210113547.3412782-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1rCI6h-0000VE-I4 Subject: [f2fs-dev] [PATCH 6/6] f2fs: fix to update iostat correctly in f2fs_filemap_fault() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net In f2fs_filemap_fault(), it fixes to update iostat info only if VM_FAULT_LOCKED is tagged in return value of filemap_fault(). Fixes: 8b83ac81f428 ("f2fs: support read iostat") Signed-off-by: Chao Yu --- fs/f2fs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 8af4b29c3e1a..0626da43fa84 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -42,7 +42,7 @@ static vm_fault_t f2fs_filemap_fault(struct vm_fault *vmf) vm_fault_t ret; ret = filemap_fault(vmf); - if (!ret) + if (ret & VM_FAULT_LOCKED) f2fs_update_iostat(F2FS_I_SB(inode), inode, APP_MAPPED_READ_IO, F2FS_BLKSIZE);