Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3089009pxj; Mon, 10 May 2021 18:32:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/KdGkTlJlgMfgyEDzYx6PXoXKXeJwPTuUvuf9mWmB2T6EkuE6DbKWdCEOyHE/Ak9i+VJX X-Received: by 2002:a92:c8d2:: with SMTP id c18mr24604721ilq.81.1620696741840; Mon, 10 May 2021 18:32:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620696741; cv=none; d=google.com; s=arc-20160816; b=UduMDL59AwqtQuaZd+kx9pabRRFEj2MfDJSfRtu9dGweMxoQVfUYFnDXTZ6pP5V4Yz yT6PoBZF8iAylIq3QGYqIm5QzCmwRw5q1anENFSrzhXoe81KIr8bE/iMnYMFa9AuD0i+ Yj2pKB56Trfeg3CeT0GycDhuWHVxC979U7xfPEijZuaip4YtWfE1xgZWFIqXu7IUBJXj MooyQYA1sdKkS6u3vBuffBMvLb7ttp/rzcWvcn4Csvsf9MAbTMa18NQQFqImlKzq4SCB /tgdqN3IMhTpW0x6HYf0KBzyUAER6prD7zBwZ3rn6eL3v2YoWcbKu+Fpwn/FjEm7xfAN 9pVA== 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=fJmsx/AB2ENMXxE6ja6cSm4Ny0xBDxq82ujJ/KhItd8=; b=zYf81fe2LuO/n7/mmOOrmlgb9GB+tqasNrBNmBeLEvDTmGHJO5GKarsIQKN6Ow0oBR 2K9k9YeflyU80R91Kc8wu9HdvKwnTMtPl1ed4i1L/R2OVEpC3+LrRYh9bJzhFBjpSG8t dP3/S0cOliwvKZ9kk/dBzkMWWKA3XyJziJCBx31fr2xp9oiE4FEecAnzNnCe9l5uIz1T WpOntD9F9rAv87UG5P7eEfUf3+MUTZUgXoDLCmLAHat2pcuZmTdnjN2x3q5g4Ny5GoOy TterAiQzmuYPMappxcWTkJfR/y/bokU9+dl913r+QyW7mO7ZTVQAH8PmHMzhwswLAdBW JYGw== 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 j14si17477773ils.113.2021.05.10.18.32.08; Mon, 10 May 2021 18:32: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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230103AbhEKBbe (ORCPT + 99 others); Mon, 10 May 2021 21:31:34 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2761 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbhEKBbd (ORCPT ); Mon, 10 May 2021 21:31:33 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FfKyx2KKCzmg1X; Tue, 11 May 2021 09:27:05 +0800 (CST) Received: from [10.136.110.154] (10.136.110.154) by smtp.huawei.com (10.3.19.202) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 11 May 2021 09:30:22 +0800 Subject: Re: [PATCH] f2fs: set file as cold when file defragmentation To: Jaegeuk Kim CC: , "chao@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-f2fs-devel@lists.sourceforge.net" References: <20210429062005epcms2p352ef77f96ab66cbffe0c0ab6c1b62d8a@epcms2p3> <3a0ab201-9546-d523-abc7-79df5f637f14@huawei.com> From: Chao Yu Message-ID: <6e95edca-4802-7650-4771-5389067935dc@huawei.com> Date: Tue, 11 May 2021 09:30:21 +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/5/10 22:47, Jaegeuk Kim wrote: > On 05/06, Chao Yu wrote: >> On 2021/5/6 12:46, Jaegeuk Kim wrote: >>> On 05/06, Chao Yu wrote: >>>> 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. >>> >>> I have a bit different opinion. I think one example would be users want to >>> defragment a file, when the they want to get higher read bandwidth for >> >> Multimedia file was already defined as cold file now via default extension >> list? > > I just gave an example. And default is default. > >> >>> usually multimedia files. That's likely to be cold files. Moreover, I don't >>> think they want to defragment db files which will be fragmented soon? >> >> I guess like db files have less update but more access? > > I think both, and we set it as hot. Then hot and cold bit will set to the same db file after defragmentation? Thanks, > >> >> Thanks, >> >>> >>>> >>>> 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; >>>>> >>> . >>> > . >