Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp74166ybm; Wed, 27 May 2020 19:48:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxo72VxEreJp+chwP9bkRicRifOBVbjK5v9FXuLPOJbSGtJThoa/Z+Tvga65BXjcl9W06UP X-Received: by 2002:a17:906:2b4f:: with SMTP id b15mr1089432ejg.64.1590634101058; Wed, 27 May 2020 19:48:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590634101; cv=none; d=google.com; s=arc-20160816; b=B3SigmPJQy+ZJmVAx+zyNRk4x8Ecl0UxzN1XoreDqllCYY1tVskMhzPZf+98oQe1Du OjBxaEimdo385BOgaKbPa4Y7FTsunYHVTxojFaUmyDFAieqhvjtE0Z/W6Dbhiz/SnDEF AIiGyLM+CE8+1wYmt3SjyzCyVjPltqht2nU9no6wSM91rehZVMcON//G+X/1jLpLK9CH n0VsXUGUzXxKXGzCy/3srXwlpZkTA5bT88LeNv17Zbyqca5j9XwI25Cc0wpVyF3isIpB qdTNTcQ5R/PU3OHjjKHzD4A3aSoaqmrrKXXWO8AGMqzYB6VHulGNahPhSrmSXXr/tOaE Jkkg== 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:from:references:cc:to:subject; bh=3oTJSptdSvvoeQY5mD42IJeDgEwsqrFXgJNfZZESUqM=; b=grySRYPZacpMLp0nYgIYDNFGcAFx/sKlFesvEE5y0NKYGmQYeZT2SlD+y8DV4M/twj 0rjnNTgyzyQsGbcC5J4LQHhlAAayT9XgSDEpWIx6FcraTc3MWlwDAmLRDvmJzZEsiVqx GbXIQrEt5X5GfyzNmmtXTwJpKZbj9asRhBGKZk8DMa6rOy1RJpFo26uKT3CuTr6msOMc vgyBy2Jz9vWvr45bogAjnHHCW63HFXxEUDPXMU2wNm72a1xsjk8qRxfbjJkUrxiH08mT 6+V4fhsR1BJZ6JBxlSN82So1eC3RqADfvsik4HM7S+5QVu4buIug6L20QJLrM6DKRFx/ luJA== 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 k12si3114528ejx.675.2020.05.27.19.47.58; Wed, 27 May 2020 19:48:21 -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 S1726917AbgE1Cpv (ORCPT + 99 others); Wed, 27 May 2020 22:45:51 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:36074 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725896AbgE1Cpv (ORCPT ); Wed, 27 May 2020 22:45:51 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 9406C9FE465076B81F68; Thu, 28 May 2020 10:45:49 +0800 (CST) Received: from [10.134.22.195] (10.134.22.195) by smtp.huawei.com (10.3.19.202) with Microsoft SMTP Server (TLS) id 14.3.487.0; Thu, 28 May 2020 10:45:44 +0800 Subject: Re: [PATCH] f2fs: fix retry logic in f2fs_write_cache_pages() To: Sahitya Tummala , Jaegeuk Kim , CC: References: <1590546056-17871-1-git-send-email-stummala@codeaurora.org> From: Chao Yu Message-ID: <1d54379e-35c7-76e0-0c8a-d89bfcecb935@huawei.com> Date: Thu, 28 May 2020 10:45:43 +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: <1590546056-17871-1-git-send-email-stummala@codeaurora.org> 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/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; > + end = retry ? -1 : writeback_index - 1; > goto retry; > } > if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) >