Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3438997ybd; Fri, 28 Jun 2019 08:37:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfLzFk6ZiluNoBqZCDXU29eEunFuzzsJ6r7yHAS9l+NrhUMGj2SE+5vrXHvevWx8J2ZiYO X-Received: by 2002:a17:902:6947:: with SMTP id k7mr12455120plt.321.1561736271900; Fri, 28 Jun 2019 08:37:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561736271; cv=none; d=google.com; s=arc-20160816; b=0Vx9VUuoPirtSoCuOQ9zkGyTcNQiUNVIQ/yAALtT7HZvIm9H2c1AfnNUZGSLB5ZlwF wgydRhZv430s7G4ve67vsw3FrR5rCAfYXATKwGbWeqGFREGpeP/shfsGqLzaMUxu6yU3 RXdbOxXdsxlHLeaFFmkWUyboWQFxECdZwGH9FncqcfJkIx/VicSXGOmTqEp5YUXbgpFS T67LkH1BZhQFZAPJNY7PkNyEpGlV54xjWPfOR8u4GqYkYsDXnFOSgczcDJmMJ5hkniNX A5kCEZjjw/sCB6QRJN92vPRMxJ43juj81hYoL0oeFxQDvoUfQ17dVCVZOB2kqIR96fTW sj1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:to :from:date:dkim-signature; bh=ZO0t80w6A1R/mX8epE11x2cvUuEgx0HyjIG6JTEgols=; b=tAOZJJoPmTDlqEG/5yxD/IbMJ0fRWnsGy6BsB6A2XPL7SjZtmp/KguRhonqri88qd8 DMDDbMANPzgTEbSnIO+KfKkaN6KNUsv7nrR2Faqm3zwPfJif74vuG0NxHofAUdS/wVsy ODpiSCZCBtMjPJIM65dr1tbDjfZNQ+as/59TRxaAuLGafrgmSeWmfg86YXOQ8qIBhq54 vpXoNp/HmEQKOksLqVCoWFN0hGSe7iACukL+Nx4CznzpTRAyoR5NkijIjaURmRjZcLfD 4tmXk07CbR76nUOoJt+NGG0ycPKFBRQOcQI6aiT/o1g5Yw5S+UJZc+BZu2LAb5C8HT8V +VxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="oB4/J5uQ"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v16si2798994pfe.39.2019.06.28.08.37.36; Fri, 28 Jun 2019 08:37:51 -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; dkim=pass header.i=@kernel.org header.s=default header.b="oB4/J5uQ"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726832AbfF1PgR (ORCPT + 99 others); Fri, 28 Jun 2019 11:36:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:50592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726657AbfF1PgQ (ORCPT ); Fri, 28 Jun 2019 11:36:16 -0400 Received: from localhost (unknown [104.132.1.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BB1382064A; Fri, 28 Jun 2019 15:36:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561736175; bh=P0q2UFfbUHYwfmb/JPMOVIIGnfRXLzPGQwS42qAp73E=; h=Date:From:To:Subject:References:In-Reply-To:From; b=oB4/J5uQ6yewdmYk+br86w41GP1WQTpsf2PaBQOoAi77xF3vRmADerGce75ZFraW0 Mv5T+Mv2+7JvafZ9aUZR4H0ItKvrAuRPK03eM35tvB7q6YygbSvsxzFeCJN10n6F9X aitDnPmM6nF16a/1eFVrKJlpIYQGcfVmmZIoMAno= Date: Fri, 28 Jun 2019 08:36:14 -0700 From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [PATCH v2] f2fs: allocate blocks for pinned file Message-ID: <20190628153614.GA27114@jaegeuk-macbookpro.roam.corp.google.com> References: <20190627170504.71700-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190627170504.71700-1-jaegeuk@kernel.org> User-Agent: Mutt/1.8.2 (2017-04-18) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch allows fallocate to allocate physical blocks for pinned file. Signed-off-by: Jaegeuk Kim --- Documentation/filesystems/f2fs.txt | 25 +++++++++++++++++++++++++ fs/f2fs/file.c | 7 ++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Documentation/filesystems/f2fs.txt b/Documentation/filesystems/f2fs.txt index bebd1be3ba49..496fa28b2492 100644 --- a/Documentation/filesystems/f2fs.txt +++ b/Documentation/filesystems/f2fs.txt @@ -804,3 +804,28 @@ WRITE_LIFE_NOT_SET WARM_DATA WRITE_LIFE_NOT_SET WRITE_LIFE_NONE " WRITE_LIFE_NONE WRITE_LIFE_MEDIUM " WRITE_LIFE_MEDIUM WRITE_LIFE_LONG " WRITE_LIFE_LONG + +Fallocate(2) Policy +------------------- + +The default policy follows the below posix rule. + +Allocating disk space + The default operation (i.e., mode is zero) of fallocate() allocates + the disk space within the range specified by offset and len. The + file size (as reported by stat(2)) will be changed if offset+len is + greater than the file size. Any subregion within the range specified + by offset and len that did not contain data before the call will be + initialized to zero. This default behavior closely resembles the + behavior of the posix_fallocate(3) library function, and is intended + as a method of optimally implementing that function. + +However, once F2FS receives ioctl(fd, F2FS_IOC_SET_PIN_FILE) in prior to +fallocate(fd, DEFAULT_MODE), it allocates on-disk blocks addressess having +zero or random data, which is useful to the below scenario where: + 1. create(fd) + 2. ioctl(fd, F2FS_IOC_SET_PIN_FILE) + 3. fallocate(fd, 0, 0, size) + 4. address = fibmap(fd, offset) + 5. open(blkdev) + 6. write(blkdev, address) 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; -- 2.19.0.605.g01d371f741-goog