Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp78634ybm; Wed, 27 May 2020 19:58:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTidWUBasN39eRMIpPU4DJqlQE0K083sFZkhk3g8pFDkHaDV3ao+Z2G5+ZW8evO+NPd5cO X-Received: by 2002:a17:906:bcf3:: with SMTP id op19mr1135374ejb.537.1590634716430; Wed, 27 May 2020 19:58:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590634716; cv=none; d=google.com; s=arc-20160816; b=QBvah6/hLzLVHs4lnTNEJTq8Rk4hBmDKRq2yjKyxEpIUL0l1Fz9MDWhhR9uQv/X/6L acZNCQNGdpVuRQsgZmJoWGZ2CLSm9cen1PJjMWVPNBNJSdmL0IlOMAlH+Ski/+rABT9z Z4XUgc1KBYBfMT6gytqf1bhUYINcx/zgylKu9+b2Af1eECH6YdkFSh7ijaxaeZ1c2wZU 65LXuuxv50MLjMuWPMvvk2ruubmRGqs8Svx47oHeBDLRjYRaGEfU4YkC6HUjH/FKkXHB cSyU9JQT8dvJUaAeKFwyDVKcW8Lo2ltXPcUS5Z2tr9HdwLbTsPNyeEK6rs8Hhn/zxYlE 1F2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject; bh=DmepWrEM0rtJG5jYLquiM1IElbwbvfa9moXh+zkMmiM=; b=YIPaqmOTCo1U7JMi+95ZLbS+rWn3hY8yo3dj9c7eccLHXzHYQ19ejj4xwOwFb87PC9 IP5zCSEe+cEyeWn7LPzhjew8ZtnUjeRt5Yb0ztqY2nUt8cMA3biQ6WZhWEBJ9cfgZjke ZBTPO6Duq+tGPQsijMOHnXS5sdm0l141Hazu1+7cTHVuWb3Fto9ihtuxwUF/905tit+n G9Es4N9pL0ZzVcCgK7kdBRTP25nASaLwUvzF5wmOncwD0oZUA9mquP2lt65hxvks/lX8 vuudhh7W3CVKWN5KlKEyAOgIKNaY5+0mQQmx00KDiM8i0OTV1dmiFvtIUhtsngSJV3sp OMlw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x8si2889502ejc.340.2020.05.27.19.58.06; Wed, 27 May 2020 19:58:36 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726932AbgE1Cz5 (ORCPT + 99 others); Wed, 27 May 2020 22:55:57 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:5296 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725896AbgE1Cz4 (ORCPT ); Wed, 27 May 2020 22:55:56 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 4CD5841269D84886E90E; Thu, 28 May 2020 10:55:55 +0800 (CST) Received: from [10.134.22.195] (10.134.22.195) by smtp.huawei.com (10.3.19.211) with Microsoft SMTP Server (TLS) id 14.3.487.0; Thu, 28 May 2020 10:55:52 +0800 Subject: Re: [f2fs-dev] [PATCH] f2fs: fix retry logic in f2fs_write_cache_pages() From: Chao Yu To: Sahitya Tummala , Jaegeuk Kim , CC: References: <1590546056-17871-1-git-send-email-stummala@codeaurora.org> <1d54379e-35c7-76e0-0c8a-d89bfcecb935@huawei.com> Message-ID: <78d2f29b-3ec0-39bc-46cf-88e82f1970c9@huawei.com> Date: Thu, 28 May 2020 10:55:50 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1d54379e-35c7-76e0-0c8a-d89bfcecb935@huawei.com> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.134.22.195] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/5/28 10:45, Chao Yu wrote: > On 2020/5/27 10:20, Sahitya Tummala wrote: >> In case a compressed file is getting overwritten, the current retry >> logic doesn't include the current page to be retried now as it sets >> the new start index as 0 and new end index as writeback_index - 1. >> This causes the corresponding cluster to be uncompressed and written >> as normal pages without compression. Fix this by allowing writeback to >> be retried for the current page as well (in case of compressed page >> getting retried due to index mismatch with cluster index). So that >> this cluster can be written compressed in case of overwrite. >> >> Signed-off-by: Sahitya Tummala >> --- >> fs/f2fs/data.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c >> index 4af5fcd..bfd1df4 100644 >> --- a/fs/f2fs/data.c >> +++ b/fs/f2fs/data.c >> @@ -3024,7 +3024,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping, >> if ((!cycled && !done) || retry) { > > IMO, we add retry logic in wrong place, you can see that cycled value is > zero only if wbc->range_cyclic is true, in that case writeback_index is valid. > > However if retry is true and wbc->range_cyclic is false, then writeback_index > would be uninitialized variable. > > Thoughts? > > Thanks, > >> cycled = 1; >> index = 0; >> - end = writeback_index - 1; BTW, I notice that range_cyclic writeback flow was refactored in below commit, and skeleton of f2fs.writepages was copied from mm/page-writeback.c::write_cache_pages(), I guess we need follow that change. 64081362e8ff ("mm/page-writeback.c: fix range_cyclic writeback vs writepages deadlock") Thanks, >> + end = retry ? -1 : writeback_index - 1; >> goto retry; >> } >> if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) >> > > > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel > . >