Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp786573lql; Mon, 11 Mar 2024 18:50:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVNSHuxS019/U3Hq8Wylz3ADWQYob5yM9DeTurwzdyDDqjyk+AKqHH2nx8xvHNsJ6SPss0yFA+bI4IJwGsMDd1Tl2fTgFCiCDwc/9F1GQ== X-Google-Smtp-Source: AGHT+IH4l3wFIbKrU2SINHpVwlWSe2gmrbz1tf3VInraiPjQiLgkX0hbc4q+CunZ2qh2fn0VIsXv X-Received: by 2002:a17:907:a801:b0:a45:fa86:dddb with SMTP id vo1-20020a170907a80100b00a45fa86dddbmr1895759ejc.12.1710208254966; Mon, 11 Mar 2024 18:50:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710208254; cv=pass; d=google.com; s=arc-20160816; b=J67XGu1s0oaiOCUoWz49UGkvCH8YGrzGJW7Nk2JVoQys7lT2v0ir7LtDA0gA6T3KpP IeOh9riksPVumaZEBG2OjPAP3uivJITTsN2DhYAg0pCH7K7L1NSwvqQdMyJxt64b/+wH sAxdu7GlqWkSG2kI9yJMtkecBXimAlJI15mYg8IIUwXaxZpHSOVLzSXnVXauXx8T0a6Z HPRqv64V8R1GL22TbPaL/RJyliXmQM0YXc/2BLEq2xU6epTVa7i1gYD4UcZfxYrqVYYT uJ404fi0PsaezJCjdy8vqqweHWM0+fOujQF1QPGXXaayFQq+pcuennn/+j6YynzZgTX1 LMhw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=Glbkd3TT4MotuckgLaUR/n3NtObJrFPGC/f6XXhf4Vw=; fh=G4Pxduviz9cgWyQEq1k2zqRNcx1tgxoAEtGH9VlDFJM=; b=OlcSDOBkpkcsMbQELSHWwzBJhAfAUuxRNWJK3KAx5ozZAXx6g5E2mS95aZn5HOzgf/ J33zsjVleRuR6LNNN6IJfpJbnLykHUnXDsFVyYHliCaczurFpxpDmr+xXZy+sBdiCI11 LaI/1yK9x2vpdJDewDfhkcCKWZfuE7IhZ8pa3YbXNKd3LluPlY8WStUClcJgxeX5VO9s F0ivKIvQ0rB2I8HajO5f+SbxpkpNZo/Tvm28vRmw2bFwZ36mtL6FEkGHYHFgHNVl8vOg m2isInwGi3oZWapZ0iJG7pry9WD+rvjCu0IEBYH/CR4xTCQNRk00ZGKiyZGAik9a8nxj qIGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gBC17MX9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-99744-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99744-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ec10-20020a170906b6ca00b00a463eed3673si289444ejb.956.2024.03.11.18.50.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 18:50:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99744-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gBC17MX9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-99744-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99744-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AFE881F21C23 for ; Tue, 12 Mar 2024 01:50:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B91D613C; Tue, 12 Mar 2024 01:50:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gBC17MX9" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B546B524F for ; Tue, 12 Mar 2024 01:50:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710208246; cv=none; b=BJrbZtGiJSxQWAHs0dry9aaW2fpxrTwhXLt8Vu3m3ziI2dvAIq3yj3YDb+yFVVwtnKOHrvpqo5xiOaEm0uz8zXNRjsLOxK2jgMQ9MfHYEX/FaCbFPhfUdVPLrzeRbcBVyl249QwcQcMxtMN6ZJUZhQPpxCezRldA86/iBtFeXjY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710208246; c=relaxed/simple; bh=5Vj2yV+2iZB9axYtdEYLw/0P7M4zjDA+EOXF1F8+bj8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=nFhSJ7HyXR3KzR20MRfL1/w/IUDeCO7P+ABYr1waE3Feu6nZFCB9voUR3FG/6/wZy5RPHY1JeS5psYRt/fCE1u9la0eb/obt6CjY9RZ2BRwXXAHwv6mBteLxBeiYRvV5cfJVMUAIgnNQCd3FaQM9wLhMyOibVJoX4w8LgI71mu8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gBC17MX9; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4002C433F1; Tue, 12 Mar 2024 01:50:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710208246; bh=5Vj2yV+2iZB9axYtdEYLw/0P7M4zjDA+EOXF1F8+bj8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=gBC17MX9N5hKrFKfv+SDVlZvZk2vy+HU8nJNig+SsIOQVL7pFiDqvb1Qs6t8Q5URP Hlo1RL0Mb1wdqFc8fWfFKvMrzwDpSaiKsCnFFR3iFoxTVyrjKSx37AaBO+TGKXV2OI PPU0/WOy4nAZTGU0It8k/dTKj0Iv6jUdp6expw+6iN/qgYakVdtnmkpm78IhyFj35K WD5QhLWjCAwdLWbwRQ4ffqozgIFInGJv0TxaTqzDx/Uc0g0sSS30siRhOrSfrX/Ar+ Bu/jkV7ydVjIiQyCffeG+bPcOn60HE5Vin0gahBOfEyDjMgQt8yVE+BEF0so3M9UX1 60SZl+Cj2FZBQ== Message-ID: Date: Tue, 12 Mar 2024 09:50:39 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [f2fs-dev] [PATCH 2/2] f2fs: prevent writing without fallocate() for pinned files Content-Language: en-US To: Daeho Jeong , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Cc: Daeho Jeong References: <20240311235921.1832684-1-daeho43@gmail.com> <20240311235921.1832684-2-daeho43@gmail.com> From: Chao Yu In-Reply-To: <20240311235921.1832684-2-daeho43@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/3/12 7:59, Daeho Jeong wrote: > From: Daeho Jeong > > In a case writing without fallocate(), we can't guarantee it's allocated > in the conventional area for zoned stroage. > > Signed-off-by: Daeho Jeong > --- > fs/f2fs/data.c | 7 +++++++ > fs/f2fs/file.c | 4 ++++ > 2 files changed, 11 insertions(+) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index c21b92f18463..5e4c11a719a0 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -3378,6 +3378,8 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi, > f2fs_map_lock(sbi, flag); > locked = true; > } else if ((pos & PAGE_MASK) >= i_size_read(inode)) { > + if (f2fs_is_pinned_file(inode)) > + return -EIO; > f2fs_map_lock(sbi, flag); > locked = true; > } > @@ -3407,6 +3409,11 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi, > > if (!f2fs_lookup_read_extent_cache_block(inode, index, > &dn.data_blkaddr)) { > + if (f2fs_is_pinned_file(inode)) { > + err = -EIO; > + goto out; > + } Daeho, Do we need to check in DIO path as well? Thanks, > + > if (locked) { > err = f2fs_reserve_block(&dn, index); > goto out; > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index 82277e95c88f..f98730932fc4 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -4611,6 +4611,10 @@ static int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *iter, > return ret; > } > > + /* For pinned files, it should be fallocate()-ed in advance. */ > + if (f2fs_is_pinned_file(inode)) > + return 0; > + > /* Do not preallocate blocks that will be written partially in 4KB. */ > map.m_lblk = F2FS_BLK_ALIGN(pos); > map.m_len = F2FS_BYTES_TO_BLK(pos + count);