Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2777710ybd; Thu, 27 Jun 2019 19:42:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+7CtA6ex1fnvRiFIyvBcpcUiT5RhIBRFzYMrQWVuejpEvCkeGrEXApnAtI7MkJgx3crau X-Received: by 2002:a63:5151:: with SMTP id r17mr6841289pgl.34.1561689752848; Thu, 27 Jun 2019 19:42:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561689752; cv=none; d=google.com; s=arc-20160816; b=NyqYbxhX+zvhi//VCrR2RQVrA+/WVlLLHcEycwqHTU6mdvFRUWsV2VS0x/hgsVjj6W NIG+U3od4L64Qtm3ov4pZNt2VwFs9qr2H1tB5NvwJQnQw2UHrKHUYbnzeAgLNv0CGSBG 7sNbkNCpNo0rJXzzZycs7CacVAJ5drlZJyqa2guIUmMSj67PzUoPiwNYufolC3nQrzjd gYclBGB8iLacSAnbLJ+jQn41Hhu1mJajDAAhGbOCMXAOrJAkEIo69oWrrCYkeWTMwM46 gwtS++lZvLODCCkmTQfn5kp7lC9Lki+XzEJgfMw6bqsMOyCzfx2SzKR+a5wVQx04WE3i yC6w== 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=9fU6QeboAy4+SSh9x8Z7uk9RvdpaHAYUSw4uCz8j+To=; b=W9b90Q4DHmMPieuHu8ItZTrRKVQZ7WDqmckSLuhzE98NOM6L26AbLZGv3shzKaZx1K bqu1U7VQIkKam+nP/Vu5o0kkV8sCFKtqz+2iVsI/3qCiA4QCSJeb+5UWcYvL7LPQfs0D n92o5ZNVIimLsOrDMzSijQr6V037OUpOj/yHSQ7lbL7qfzit5Umz6pLKfs2yWeV/dIRb LErEtfK8B5QI+prKNrfZXE/BqnRPSO0rmwC48waT9rcSOBdm6uFoJ10ESCbrcNcMt2P4 /iJ/RNxUKOoudVveUHYCsCXFFqjpNfpnfgDYM5mGUfQ5C89CqbX16yglOA9JKzad0L5J Fbsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1si818481pld.278.2019.06.27.19.42.16; Thu, 27 Jun 2019 19:42:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726681AbfF1CmN (ORCPT + 99 others); Thu, 27 Jun 2019 22:42:13 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:59216 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726476AbfF1CmM (ORCPT ); Thu, 27 Jun 2019 22:42:12 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 5CDEC5EA8D2C2FE829FE; Fri, 28 Jun 2019 10:42:08 +0800 (CST) Received: from [10.134.22.195] (10.134.22.195) by smtp.huawei.com (10.3.19.213) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 28 Jun 2019 10:42:04 +0800 Subject: Re: [f2fs-dev] [PATCH] f2fs: allocate blocks for pinned file To: Jaegeuk Kim CC: , References: <20190627170504.71700-1-jaegeuk@kernel.org> <20190628021551.GA10489@jaegeuk-macbookpro.roam.corp.google.com> From: Chao Yu Message-ID: Date: Fri, 28 Jun 2019 10:42:01 +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: <20190628021551.GA10489@jaegeuk-macbookpro.roam.corp.google.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 2019/6/28 10:15, Jaegeuk Kim wrote: > On 06/28, Chao Yu wrote: >> Hi Jaegeuk, >> >> On 2019/6/28 1:05, Jaegeuk Kim wrote: >>> This patch allows fallocate to allocate physical blocks for pinned file. >> >> Quoted from manual of fallocate(2): >> " >> Any subregion within the range specified by offset and len that did not contain >> data before the call will be initialized to zero. >> >> If the FALLOC_FL_KEEP_SIZE flag is specified in mode .... Preallocating >> zeroed blocks beyond the end of the file in this manner is useful for optimizing >> append workloads. >> " >> >> As quoted description, our change may break the rule of fallocate(, mode = 0), >> because with after this change, we can't guarantee that preallocated physical >> block contains zeroed data >> >> Should we introduce an additional ioctl for this case? Or maybe add one more >> flag in fallocate() for unzeroed block preallocation, not sure. > > I thought like that, but this is a very corner case for the pinned file only in > f2fs. And, the pinned file is also indeed used by this purpose. Okay, I think we need to find one place to document such behavior that is not matching regular poxis fallocate's sematic, user should be noticed about it. Thanks, > > Thanks, > >> >> Thanks, >> >>> >>> Signed-off-by: Jaegeuk Kim >>> --- >>> fs/f2fs/file.c | 7 ++++++- >>> 1 file changed, 6 insertions(+), 1 deletion(-) >>> >>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c >>> index e7c368db8185..cdfd4338682d 100644 >>> --- a/fs/f2fs/file.c >>> +++ b/fs/f2fs/file.c >>> @@ -1528,7 +1528,12 @@ static int expand_inode_data(struct inode *inode, loff_t offset, >>> if (off_end) >>> map.m_len++; >>> >>> - err = f2fs_map_blocks(inode, &map, 1, F2FS_GET_BLOCK_PRE_AIO); >>> + if (f2fs_is_pinned_file(inode)) >>> + map.m_seg_type = CURSEG_COLD_DATA; >>> + >>> + err = f2fs_map_blocks(inode, &map, 1, (f2fs_is_pinned_file(inode) ? >>> + F2FS_GET_BLOCK_PRE_DIO : >>> + F2FS_GET_BLOCK_PRE_AIO)); >>> if (err) { >>> pgoff_t last_off; >>> >>> > . >