Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp4137007pxy; Mon, 26 Apr 2021 19:44:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwvnkWjR0jZA4uHyArRETCtcY8XRbBSi1fajqotrTRmK2YJhuJUdvgajB7X1VyUYkPn2nr X-Received: by 2002:a63:eb10:: with SMTP id t16mr20090056pgh.393.1619491467290; Mon, 26 Apr 2021 19:44:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619491467; cv=none; d=google.com; s=arc-20160816; b=pnXwNYp1H5viXGCJJsp8k2xnZ0YHXJWSPKdrrMbGZC8cLuct7C8kq2bWy09mChkqjw xFbI1/mvPBLihIrCYPjMc1QzWTBKuT2G4C6yp7iS7rm0C4VE/ug+GzlqRbl3hEwLmX2/ YRiW4ZagrqN96avyMWUupvXlkuSdbA9UZrV/n5f8EDH4gdJ3TXnRTW1NujPMBpFestro 7Ao4AwT3QcUGvOSFAF1F026opr8ulT/AZLckA939Jw1lN99nqq0LReZ1sH5deX1BThwg ynbLJpWh8p+5vs40kgKatFEMmMoQAFdnk6kkwbthKewwf5LiavioC9gwqkHB7tP0qPKq GkHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=q+r8tY/t4fpBtUDlPPssGUrKItks2GlOICFcjUWgb2I=; b=TBqUgXME+zSsiEdZrX8Jtx8zUIWcNR6kokVs4YJPlpESOySKbmWmpLNDg7S1DkgwWf 7UODfiX5rbguUaGOdh3oGnlVvOxERbuxaLM0g5bkzxXCGYEwMVSVKtxi38iK/7qKpIEo KgwUm+EADnGKo9x8UgPFxq0/GQg1HAQE1RL3D9VkxqD5LfOYbU0k5UqunBUwrdInKhss Mak+FS+0oarae/dkFpjgyeP/kCtbumslgOmnjTlqCCzgs180yUxu+AwpOJki3DEfvxCT kYsnGxeXV5pmhPr20dFR27AE0skvnu7ZErz+96AuIPsZ0DY/zkYj5tOOAOLc1JrT4ccj IyQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h9si21999050pls.194.2021.04.26.19.44.13; Mon, 26 Apr 2021 19:44:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233361AbhD0CoU (ORCPT + 99 others); Mon, 26 Apr 2021 22:44:20 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:16159 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230516AbhD0CoU (ORCPT ); Mon, 26 Apr 2021 22:44:20 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FTmG55rt0zmdtg; Tue, 27 Apr 2021 10:40:29 +0800 (CST) Received: from [10.136.110.154] (10.136.110.154) by smtp.huawei.com (10.3.19.214) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 27 Apr 2021 10:43:34 +0800 Subject: Re: [PATCH] f2fs: compress: remove unneed check condition To: Jaegeuk Kim CC: , , References: <20210421083941.66371-1-yuchao0@huawei.com> <2c6f17e6-ef23-f313-5df2-6bd63d7df2b1@huawei.com> <5d7de7c7-5cc5-c342-3652-ab904b3e43b2@huawei.com> From: Chao Yu Message-ID: <5d7fcb3c-b0a7-178c-0f5c-5b12e21cb5f0@huawei.com> Date: Tue, 27 Apr 2021 10:43:34 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.136.110.154] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/4/27 1:05, Jaegeuk Kim wrote: > On 04/25, Chao Yu wrote: >> On 2021/4/25 8:47, Jaegeuk Kim wrote: >>> On 04/22, Chao Yu wrote: >>>> On 2021/4/22 12:04, Jaegeuk Kim wrote: >>>>> On 04/21, Chao Yu wrote: >>>>>> In only call path of __cluster_may_compress(), __f2fs_write_data_pages() >>>>>> has checked SBI_POR_DOING condition, and also cluster_may_compress() >>>>>> has checked CP_ERROR_FLAG condition, so remove redundant check condition >>>>>> in __cluster_may_compress() for cleanup. >>>>> >>>>> I think cp_error can get any time without synchronization. Is it safe to say >>>>> it's redundant? >>>> >>>> Yes, >>>> >>>> But no matter how late we check cp_error, cp_error can happen after our >>>> check points, it won't cause regression if we remove cp_error check there, >>>> because for compress write, it uses OPU, it won't overwrite any existed data >>>> in device. >>>> >>>> Seems it will be more appropriate to check cp_error in >>>> f2fs_write_compressed_pages() like we did in f2fs_write_single_data_page() >>>> rather than in __cluster_may_compress(). >>>> >>>> BTW, shouldn't we rename __cluster_may_compress() to >>>> cluster_beyond_filesize() for better readability? >>> >>> f2fs_cluster_has_data()? >> >> Maybe cluster_has_invalid_data()? which indicates there is invalid data >> beyond filesize. > > BTW, we can compress it with zero data? I doubt it will cause unnecessary overhead for below condition? - write 1GB data into file - truncate file to 0 - writeback 1GB compressed cluster contains zero data Thanks, > >> >> Thanks, >> >>> >>>> >>>> Thanks, >>>> >>>>> >>>>>> >>>>>> Signed-off-by: Chao Yu >>>>>> --- >>>>>> fs/f2fs/compress.c | 5 ----- >>>>>> 1 file changed, 5 deletions(-) >>>>>> >>>>>> diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c >>>>>> index 3c9d797dbdd6..532c311e3a89 100644 >>>>>> --- a/fs/f2fs/compress.c >>>>>> +++ b/fs/f2fs/compress.c >>>>>> @@ -906,11 +906,6 @@ static bool __cluster_may_compress(struct compress_ctx *cc) >>>>>> f2fs_bug_on(sbi, !page); >>>>>> - if (unlikely(f2fs_cp_error(sbi))) >>>>>> - return false; >>>>>> - if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING))) >>>>>> - return false; >>>>>> - >>>>>> /* beyond EOF */ >>>>>> if (page->index >= nr_pages) >>>>>> return false; >>>>>> -- >>>>>> 2.29.2 >>>>> . >>>>> >>> . >>> > . >