Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp972558pxy; Wed, 5 May 2021 19:47:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSM549/yZjkB4hkGwM5IouYpbIfnPcK4eXoMw8E+gc/NZfLpCwWzNE8rkZmXszrPP8B5YT X-Received: by 2002:a17:90b:88b:: with SMTP id bj11mr1983796pjb.224.1620269248153; Wed, 05 May 2021 19:47:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620269248; cv=none; d=google.com; s=arc-20160816; b=UBjmaswidr5yPdn0EIwXxWldjSJGW/FpBN0h2eDAuDa3esCOIM2JU2ec0iF0AMwQBN 2E0L65EoVfZYk8iUpMaj5fTt39YdxQEXMqMxHhvUKXv7keUAjvj7e95BeNcoQzExBF/S IVfLlYYAt5WmhMBIsF+QGtC6Osu9BP7d25PDNQGEFrOaRuGfaJHVpKhyNfVFacu8+RcU m8Lqv2RRKVsDXit0EdvcpGIyhaiB7o7pn1uMPUdxXiKsfy9JwVZceDgbBduMqYmZjOJz qwNwy2ASeSPmqIUHJV0rHOp90ZL72mNfVZcMS/VhMlMdAJVbWP0TKMJtWupp+K+XL/wS DzBw== 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 :to:subject; bh=imtkCkkG8FHkAGkMw04nanvHQ849et1kWazFQq0qZng=; b=VPQBy42I9Hk9M+AtkPyhMvdxkgMPufQnS1UKjKjIcnuoJSIUcBx5WZpsuq7ZH20DzB 3PTVDKXgrfZxGj+ZmHHht34KF8yNnZNqSle+2uXuWmLuYiNSAk4iuQ6p8UA4K6gLa06j MjxyV5xCNjNlTEQsLpq9rZvRe1KUyKZjKx7sj18gMmKCD3QGm77xiDkxhMJlCLgpml4O mZDJMI5e+AMpLhkzARPeZHc4TLWmp0u5on46vaEq/eFADlhn2s8wieH3jQnpnRB6T1R3 +3NA7feGPRUSDQejb0DB1VkEsiFAOQyODQWBDrwpOvSyBGF8i6+vrHKhmlrifZeK8oHX RCiA== 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 f11si1224595pju.22.2021.05.05.19.47.15; Wed, 05 May 2021 19:47:28 -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 S230468AbhEFCKT (ORCPT + 99 others); Wed, 5 May 2021 22:10:19 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:17466 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbhEFCKS (ORCPT ); Wed, 5 May 2021 22:10:18 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FbH510mBPzkWpY; Thu, 6 May 2021 10:06:45 +0800 (CST) Received: from [10.136.110.154] (10.136.110.154) by smtp.huawei.com (10.3.19.210) with Microsoft SMTP Server (TLS) id 14.3.498.0; Thu, 6 May 2021 10:09:18 +0800 Subject: Re: [PATCH] f2fs: set file as cold when file defragmentation To: , "jaegeuk@kernel.org" , "chao@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-f2fs-devel@lists.sourceforge.net" References: <20210429062005epcms2p352ef77f96ab66cbffe0c0ab6c1b62d8a@epcms2p3> From: Chao Yu Message-ID: <3a0ab201-9546-d523-abc7-79df5f637f14@huawei.com> Date: Thu, 6 May 2021 10:09:18 +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: <20210429062005epcms2p352ef77f96ab66cbffe0c0ab6c1b62d8a@epcms2p3> Content-Type: text/plain; charset="utf-8"; 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/29 14:20, Daejun Park wrote: > In file defragmentation by ioctl, all data blocks in the file are > re-written out-of-place. File defragmentation implies user will not update > and mostly read the file. So before the defragmentation, we set file > temperature as cold for better block allocation. I don't think all fragmented files are cold, e.g. db file. We have separated interface (via f2fs_xattr_advise_handler, e.g. setfattr -n "system.advise" -v value) to indicate this file is a hot/cold file, so my suggestion is after file defragmentation, if you think this file is cold, and use setxattr() to set it as cold. Thanks, > > Signed-off-by: Daejun Park > --- > fs/f2fs/file.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index d697c8900fa7..dcac965a05fe 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -2669,6 +2669,9 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi, > map.m_len = pg_end - pg_start; > total = 0; > > + if (!file_is_cold(inode)) > + file_set_cold(inode); > + > while (map.m_lblk < pg_end) { > pgoff_t idx; > int cnt = 0; >