Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1350280rdd; Wed, 10 Jan 2024 17:26:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZUShrEPBSt6yzhcDnKwMhLDbLahp/mt4RfJ35fKIrYq4oa0uLckHEPaJ/LzClJZjUmiLw X-Received: by 2002:a05:6808:300e:b0:3bd:4881:14e6 with SMTP id ay14-20020a056808300e00b003bd488114e6mr620302oib.9.1704936401310; Wed, 10 Jan 2024 17:26:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704936401; cv=none; d=google.com; s=arc-20160816; b=R+ylORqeyOYBNDfDL0KqPLCUIDJ+/P1+uUH5aLro0fH09y4Lz3W7k+grkZ7qdAsqZ9 T9Mvh+h8Ee5EERp/Wl7bGpVqPPdOtOwLDUVWAyCDVqeXGnBbbHu/8heDJBWe8LuB2cza 8Cz7NSPQ/wkWirrkjh90pKP8NxzpJoG3RpPON7cH86VspBKs/UNfWFWnI9OwEAiqlxzu PSS6lHtm+S0G0lkeYYNYF3NM7Yda0GvwY7wpznMS1JUJhzFNayoMWxOYgqXLr1N7HE7O nKbWFjjMP0B2o0Tw4tn0XhBhCHgFvytZwFHy98TmRr/kGOk3N5ap7Rvcm7CXr0ebiQzv zpkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=MfUr0p0eCPq9Mz+6tHI+M7YmY+VNgecUPZj/d/72S3E=; fh=CVABXt/2+I/w5TIrpoqOngQihKkOOcSQFZlYGDqF0qk=; b=o/5s+c8iQZl4+UGthvBqC1KQ2/sAs0JYsQi9wrM741UV8rIsXgyA0DXQ+bCJOIpA2S lRYB27wzvsnZND4lZTg7QsTdNWeEm+SX6cRaIAw4yNGuQZWKMotNcHggquz4NxQ7FKJ/ dI610tAWsp4PqOMJOHk3NljeX5hyk/ETyQrEWtAJweto5D82M6E+ySON/DxGMEHdq26w 3LMjr42eHCcxW6AMrzrbGZmQAKhhV3pasRqjOfd8lt181ugEcLtt29+FCxtVaus7E754 AwxMA9pFphVWjPozAyXNg4UID8FmlHGpa5tyyDFS1LPCdj/+m1aMOL6FBBqNwLQMaMFs ETjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="DcJQ9/Ck"; spf=pass (google.com: domain of linux-kernel+bounces-22925-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22925-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x64-20020a626343000000b006dad16516bfsi4827198pfb.148.2024.01.10.17.26.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 17:26:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22925-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="DcJQ9/Ck"; spf=pass (google.com: domain of linux-kernel+bounces-22925-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22925-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 37C4AB24523 for ; Thu, 11 Jan 2024 01:26:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EDE257ED; Thu, 11 Jan 2024 01:26:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DcJQ9/Ck" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA816394 for ; Thu, 11 Jan 2024 01:26:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53BC2C433C7; Thu, 11 Jan 2024 01:26:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704936388; bh=5R41srxwELgpcVkdWas/ZAU8OawuQEn8G6bkikiGVnU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=DcJQ9/Ckit2VZ2a96ohX0Wrz0cYJKkmSK8D2FMQVNEVyPeg7YzVhsIIKj+xIA/l3z ljREURXvQzyKmC3YPNMR3NzDhlOjLYkszJMCH5N5QVJmng1zJsu/3WLly5GIVPsRbt Syd+ZZRjXw1TxolfmgVKcrHbaRh72yCnq1IJ+TSqcHIjSfckOruoRRc5ukbsoMFFAU 3Uan/l8HaxyiBvcyJuw77NRxQdNqC1j9rGN1q9GUQIImFX2epfyMGXxFCA/2t++WI+ zt1PWYVEa10y3Pr+kCDazn6qLlEFchgDhkfq36xyxzPBhkKs1Uvluy4kxHQbWK1fZS fC7xRKLaMP91w== Message-ID: Date: Thu, 11 Jan 2024 09:26:31 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [f2fs-dev] [PATCH v3 1/6] f2fs: compress: fix to guarantee persisting compressed blocks by CP To: Daeho Jeong Cc: jaegeuk@kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net References: <20231228143152.1543509-1-chao@kernel.org> Content-Language: en-US From: Chao Yu Autocrypt: addr=chao@kernel.org; keydata= xsFNBFYs6bUBEADJuxYGZRMvAEySns+DKVtVQRKDYcHlmj+s9is35mtlhrLyjm35FWJY099R 6DL9bp8tAzLJOMBn9RuTsu7hbRDErCCTiyXWAsFsPkpt5jgTOy90OQVyTon1i/fDz4sgGOrL 1tUfcx4m5i5EICpdSuXm0dLsC5lFB2KffLNw/ZfRuS+nNlzUm9lomLXxOgAsOpuEVps7RdYy UEC81IYCAnweojFbbK8U6u4Xuu5DNlFqRFe/MBkpOwz4Nb+caCx4GICBjybG1qLl2vcGFNkh eV2i8XEdUS8CJP2rnp0D8DM0+Js+QmAi/kNHP8jzr7CdG5tje1WIVGH6ec8g8oo7kIuFFadO kwy6FSG1kRzkt4Ui2d0z3MF5SYgA1EWQfSqhCPzrTl4rJuZ72ZVirVxQi49Ei2BI+PQhraJ+ pVXd8SnIKpn8L2A/kFMCklYUaLT8kl6Bm+HhKP9xYMtDhgZatqOiyVV6HFewfb58HyUjxpza 1C35+tplQ9klsejuJA4Fw9y4lhdiFk8y2MppskaqKg950oHiqbJcDMEOfdo3NY6/tXHFaeN1 etzLc1N3Y0pG8qS/mehcIXa3Qs2fcurIuLBa+mFiFWrdfgUkvicSYqOimsrE/Ezw9hYhAHq4 KoW4LQoKyLbrdOBJFW0bn5FWBI4Jir1kIFHNgg3POH8EZZDWbQARAQABzRlDaGFvIFl1IDxj aGFvQGtlcm5lbC5vcmc+wsF3BBMBCgAhBQJWLOm1AhsDBQsJCAcDBRUKCQgLBRYCAwEAAh4B AheAAAoJEKTPgB1/p52Gm2MP/0zawCU6QN7TZuJ8R1yfdhYr0cholc8ZuPoGim69udQ3otet wkTNAR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/11 8:55, Daeho Jeong wrote: > On Thu, Dec 28, 2023 at 6:33 AM Chao Yu wrote: >> >> If data block in compressed cluster is not persisted with metadata >> during checkpoint, after SPOR, the data may be corrupted, let's >> guarantee to write compressed page by checkpoint. >> >> Fixes: 4c8ff7095bef ("f2fs: support data compression") >> Signed-off-by: Chao Yu >> --- >> v3: >> - treat compressed page as CP guaranteed data explictly. >> fs/f2fs/compress.c | 4 +++- >> fs/f2fs/data.c | 17 +++++++++-------- >> fs/f2fs/f2fs.h | 4 +++- >> 3 files changed, 15 insertions(+), 10 deletions(-) >> >> diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c >> index c5a4364c4482..9940b7886e5d 100644 >> --- a/fs/f2fs/compress.c >> +++ b/fs/f2fs/compress.c >> @@ -1418,6 +1418,8 @@ void f2fs_compress_write_end_io(struct bio *bio, struct page *page) >> struct f2fs_sb_info *sbi = bio->bi_private; >> struct compress_io_ctx *cic = >> (struct compress_io_ctx *)page_private(page); >> + enum count_type type = WB_DATA_TYPE(page, >> + f2fs_is_compressed_page(page)); >> int i; >> >> if (unlikely(bio->bi_status)) >> @@ -1425,7 +1427,7 @@ void f2fs_compress_write_end_io(struct bio *bio, struct page *page) >> >> f2fs_compress_free_page(page); >> >> - dec_page_count(sbi, F2FS_WB_DATA); >> + dec_page_count(sbi, type); >> >> if (atomic_dec_return(&cic->pending_pages)) >> return; >> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c >> index dce8defdf4c7..81f9e2cc49e2 100644 >> --- a/fs/f2fs/data.c >> +++ b/fs/f2fs/data.c >> @@ -48,7 +48,7 @@ void f2fs_destroy_bioset(void) >> bioset_exit(&f2fs_bioset); >> } >> >> -static bool __is_cp_guaranteed(struct page *page) >> +bool f2fs_is_cp_guaranteed(struct page *page) >> { >> struct address_space *mapping = page->mapping; >> struct inode *inode; >> @@ -65,8 +65,6 @@ static bool __is_cp_guaranteed(struct page *page) >> S_ISDIR(inode->i_mode)) >> return true; >> >> - if (f2fs_is_compressed_page(page)) >> - return false; > > Out of curiosity, why don't we simply change the above to "return true"? Daeho, I used the implementation, please check v1 and related comments from Jaegeuk and me, let me know if that was not clear enough. :) https://lore.kernel.org/linux-f2fs-devel/aae654e7-8a7e-478d-9f5a-65807a0e0343@kernel.org/ > >> if ((S_ISREG(inode->i_mode) && IS_NOQUOTA(inode)) || >> page_private_gcing(page)) >> return true; >> @@ -338,7 +336,7 @@ static void f2fs_write_end_io(struct bio *bio) >> >> bio_for_each_segment_all(bvec, bio, iter_all) { >> struct page *page = bvec->bv_page; >> - enum count_type type = WB_DATA_TYPE(page); >> + enum count_type type = WB_DATA_TYPE(page, false); >> >> if (page_private_dummy(page)) { >> clear_page_private_dummy(page); >> @@ -762,7 +760,7 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio) >> wbc_account_cgroup_owner(fio->io_wbc, fio->page, PAGE_SIZE); >> >> inc_page_count(fio->sbi, is_read_io(fio->op) ? >> - __read_io_type(page) : WB_DATA_TYPE(fio->page)); >> + __read_io_type(page) : WB_DATA_TYPE(fio->page, false)); >> >> if (is_read_io(bio_op(bio))) >> f2fs_submit_read_bio(fio->sbi, bio, fio->type); >> @@ -973,7 +971,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio) >> if (fio->io_wbc) >> wbc_account_cgroup_owner(fio->io_wbc, fio->page, PAGE_SIZE); >> >> - inc_page_count(fio->sbi, WB_DATA_TYPE(page)); >> + inc_page_count(fio->sbi, WB_DATA_TYPE(page, false)); >> >> *fio->last_block = fio->new_blkaddr; >> *fio->bio = bio; >> @@ -1007,6 +1005,7 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio) >> enum page_type btype = PAGE_TYPE_OF_BIO(fio->type); >> struct f2fs_bio_info *io = sbi->write_io[btype] + fio->temp; >> struct page *bio_page; >> + enum count_type type; >> >> f2fs_bug_on(sbi, is_read_io(fio->op)); >> >> @@ -1046,7 +1045,8 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio) >> /* set submitted = true as a return value */ >> fio->submitted = 1; >> >> - inc_page_count(sbi, WB_DATA_TYPE(bio_page)); >> + type = WB_DATA_TYPE(bio_page, fio->compressed_page); >> + inc_page_count(sbi, type); >> >> if (io->bio && >> (!io_is_mergeable(sbi, io->bio, io, fio, io->last_block_in_bio, >> @@ -1059,7 +1059,8 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio) >> if (F2FS_IO_ALIGNED(sbi) && >> (fio->type == DATA || fio->type == NODE) && >> fio->new_blkaddr & F2FS_IO_SIZE_MASK(sbi)) { >> - dec_page_count(sbi, WB_DATA_TYPE(bio_page)); >> + dec_page_count(sbi, WB_DATA_TYPE(bio_page, >> + fio->compressed_page)); >> fio->retry = 1; >> goto skip; >> } >> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h >> index 65294e3b0bef..50f3d546ded8 100644 >> --- a/fs/f2fs/f2fs.h >> +++ b/fs/f2fs/f2fs.h >> @@ -1080,7 +1080,8 @@ struct f2fs_sm_info { >> * f2fs monitors the number of several block types such as on-writeback, >> * dirty dentry blocks, dirty node blocks, and dirty meta blocks. >> */ >> -#define WB_DATA_TYPE(p) (__is_cp_guaranteed(p) ? F2FS_WB_CP_DATA : F2FS_WB_DATA) >> +#define WB_DATA_TYPE(p, f) \ >> + (f || f2fs_is_cp_guaranteed(p) ? F2FS_WB_CP_DATA : F2FS_WB_DATA) >> enum count_type { >> F2FS_DIRTY_DENTS, >> F2FS_DIRTY_DATA, >> @@ -3804,6 +3805,7 @@ void f2fs_init_ckpt_req_control(struct f2fs_sb_info *sbi); >> */ >> int __init f2fs_init_bioset(void); >> void f2fs_destroy_bioset(void); >> +bool f2fs_is_cp_guaranteed(struct page *page); >> int f2fs_init_bio_entry_cache(void); >> void f2fs_destroy_bio_entry_cache(void); >> void f2fs_submit_read_bio(struct f2fs_sb_info *sbi, struct bio *bio, >> -- >> 2.40.1 >> >> >> >> _______________________________________________ >> Linux-f2fs-devel mailing list >> Linux-f2fs-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel