Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4990440pxb; Tue, 28 Sep 2021 08:21:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwk1FWoXkaTwIW6gsO/U8cHUboVPvQxDe+rVB+hErudt4Xltj+YS7CfzjTMoVej5wCWcaao X-Received: by 2002:a17:90a:1c96:: with SMTP id t22mr525835pjt.20.1632842500667; Tue, 28 Sep 2021 08:21:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632842500; cv=none; d=google.com; s=arc-20160816; b=KT9j6v8JVn5FjVBe9SUop4QWxpu3OcNkNphZSZFlB+1v/WGcbV2R4eFc0LW+xCLqZA IfNODHVsf/9Lys4P4DgmBf6Za6iorvBmAsDKyXm+nlfPWvTr0FrnAxbIx9XoArE6oHAw YTcQWkXnVKpS6TR1eUwqBuPqG0jWyC1uN7pJi9gCLyKZgBd/kfGywdVqK3TosdhzKwsg /ORcqfYjAqmtvQ6+YLi/zyfMVng7d6qDwPLlsnjv/SOcXtPzwbBwgnV3xr+W0tlpOoy9 +/oZb79AdZcor4Vl8aHa64QQ60sIwymJDQe69RzysYDtF3yJSuA1IYz1Afzc75/rb2/P 2CEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=02n7f9iuL2lbjRwGbk1PeKunSACcTSHzDY22tSuclmw=; b=gFRcwn1kdvJX/Gj+LsIV4VUE/yuXJ7RKPBq689aLehVPr9dosJQ8VbyztDTP2EUaj/ bFq9GS/KO6SrcegTupZpD19r1GB9wZRu6SeYqUgyg4FDKRwmtFQ0gYDkl0+HQ/9LkcXJ ZQotGQg6/oab4Q9HfSgk3X5Irwp52D7offxyAmoZiVZ1uemSj7qi+ikm26mOHjm7zT09 8arpXj8EofDC7HYmvCrXXRZPK2//kQliEWzP8Pf0VSb+ZFDGtD75tOAFx16oMYSOE+Ux LqdsscDKRl5DhzLqfcLSQQrDx9aiBD2hBlF78WChO+AIquaw/+7CHIn+vzoXdjjuR7vh uBsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Gk6Cm1Nd; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f22si23984249pgv.464.2021.09.28.08.21.26; Tue, 28 Sep 2021 08:21:40 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Gk6Cm1Nd; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241514AbhI1PVH (ORCPT + 99 others); Tue, 28 Sep 2021 11:21:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:48824 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241405AbhI1PVG (ORCPT ); Tue, 28 Sep 2021 11:21:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A8CBE61213; Tue, 28 Sep 2021 15:19:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632842366; bh=bycBfj7a7y99K5/y/PMobW5rEQpsQjstRkBVVLsg87A=; h=From:To:Cc:Subject:Date:From; b=Gk6Cm1NdPgAYBtNQQcgvZOeOqFNgX2Rq/ZDqcIBit5BqcgE5nJFu/usr7Cejuz8Yv f2wiClv1fwCiKdp1BXpGVk9lXtCftKtafwET6KX/9O30VwRlrduaXn/xWN/VPoq8ie ffMFGvWxlRfhlPGZNAFbuEv8htFkKTafxNyPP0Q51j54LPUxbjQabJar3i226mfo5W ixoFHf9NsjGfhO6y+Ohg9cfPPCIam86Ep+LXnKopMXH4M1vsLtm5CUl1MzpsadoHJy FBpeCkEccqeCTnBb5qasiK1Mm5DP1BPb1yO4bhtP/O5Ueo3bTzcrkic5mhzaMXDNdK vQuzrIo0H2+yQ== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH] f2fs: skip f2fs_preallocate_blocks() for overwrite case Date: Tue, 28 Sep 2021 23:19:11 +0800 Message-Id: <20210928151911.11189-1-chao@kernel.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In f2fs_file_write_iter(), let's use f2fs_overwrite_io() to check whethere it is overwrite case, for such case, we can skip f2fs_preallocate_blocks() in order to avoid f2fs_do_map_lock(), which may be blocked by checkpoint() potentially. Signed-off-by: Chao Yu --- fs/f2fs/file.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 13deae03df06..51fecb2f4db5 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4321,6 +4321,10 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) preallocated = true; target_size = iocb->ki_pos + iov_iter_count(from); + if (f2fs_overwrite_io(inode, iocb->ki_pos, + iov_iter_count(from))) + goto write; + err = f2fs_preallocate_blocks(iocb, from); if (err) { out_err: -- 2.32.0