From nobody Tue Oct 7 21:42:02 2025 Received: from mx10.didiglobal.com (mx10.didiglobal.com [111.202.70.125]) by smtp.subspace.kernel.org (Postfix) with SMTP id 1C2F5286880; Mon, 7 Jul 2025 07:00:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=111.202.70.125 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751871664; cv=none; b=VWljvhlXnCDzp7Ua3G4+Upbay0kYltzEvLGiBxwdfbp+6oFdVeuQNru1reToWoRGKb9LSV0yqH3EZ82qvz/2f07W5N/QNMpYTmdIcLxuLzOoR/mxXVFED0rj7Jid8uStTVRLs/eA6DGC5YEX4CRNpOTrnBbJ7mVOURW0cEn/kYI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751871664; c=relaxed/simple; bh=7NwIqzCgC1RdJfhixz5bD3co5fgHiYbQk2Lmr3rknQE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version; b=XToypAMyACjeqjn1i2FuxjW43AzLT8Pt/2shnoKl5YUie2yD0gBx8nGu07nEJbEM8UGgkeLM6U2pORTZI9nzft42KNVu7RRz4rlDpvSY6y7dZjB/AJVnkKW2QBoMEt0wMiyOQuDGsopmZt77F9KWC6Tvm8EsIUHAP5g2r6oLhv8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=didiglobal.com; spf=pass smtp.mailfrom=didiglobal.com; dkim=pass (1024-bit key) header.d=didiglobal.com header.i=@didiglobal.com header.b=GqNI3vpl; arc=none smtp.client-ip=111.202.70.125 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=didiglobal.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=didiglobal.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=didiglobal.com header.i=@didiglobal.com header.b="GqNI3vpl" Received: from mail.didiglobal.com (unknown [10.79.65.20]) by mx10.didiglobal.com (MailData Gateway V2.8.8) with ESMTPS id F34CA188C74229; Mon, 7 Jul 2025 14:59:50 +0800 (CST) Received: from BJ03-ACTMBX-09.didichuxing.com (10.79.71.36) by BJ02-ACTMBX-02.didichuxing.com (10.79.65.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Mon, 7 Jul 2025 15:00:35 +0800 Received: from BJ03-ACTMBX-07.didichuxing.com (10.79.71.34) by BJ03-ACTMBX-09.didichuxing.com (10.79.71.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Mon, 7 Jul 2025 15:00:34 +0800 Received: from BJ03-ACTMBX-07.didichuxing.com ([fe80::2e1a:dd47:6d25:287e]) by BJ03-ACTMBX-07.didichuxing.com ([fe80::2e1a:dd47:6d25:287e%7]) with mapi id 15.02.1748.010; Mon, 7 Jul 2025 15:00:34 +0800 X-MD-Sfrom: chentaotao@didiglobal.com X-MD-SrcIP: 10.79.65.20 From: =?gb2312?B?s8LMzszOIFRhb3RhbyBDaGVu?= To: "tytso@mit.edu" , "hch@infradead.org" , "adilger.kernel@dilger.ca" , "willy@infradead.org" , "brauner@kernel.org" , "jani.nikula@linux.intel.com" , "rodrigo.vivi@intel.com" , "tursulin@ursulin.net" , "airlied@gmail.com" CC: "linux-fsdevel@vger.kernel.org" , "linux-ext4@vger.kernel.org" , "linux-block@vger.kernel.org" , "intel-gfx@lists.freedesktop.org" , "dri-devel@lists.freedesktop.org" , "linux-mm@kvack.org" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "chentao325@qq.com" , "frank.li@vivo.com" , =?gb2312?B?s8LMzszOIFRhb3RhbyBDaGVu?= Subject: [PATCH v4 5/5] ext4: support uncached buffered I/O Thread-Topic: [PATCH v4 5/5] ext4: support uncached buffered I/O Thread-Index: AQHb7wzVwHDyJpOeWECj7YO1Y+Mm6Q== Date: Mon, 7 Jul 2025 07:00:34 +0000 Message-ID: <20250707070023.206725-6-chentaotao@didiglobal.com> In-Reply-To: <20250707070023.206725-1-chentaotao@didiglobal.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=didiglobal.com; s=2025; t=1751871613; bh=7NwIqzCgC1RdJfhixz5bD3co5fgHiYbQk2Lmr3rknQE=; h=From:To:CC:Subject:Date:Message-ID:Content-Type; b=GqNI3vpldugsvZfWl52mz/qjKRMeDae+SorQJkIbBjy8E5gGrjYe+qlSd9Q3yuWmZ MjMVxlYW7HIy/iqpSQW4n7lpWzjMpr+KYHMBuyGh9uG0W2Z1wW0JTnrrnQ8/CmpoD5 Tl0aOs/To2S0asmzu6yUcY01uUy8g8KbCiU3a4M8= Content-Type: text/plain; charset="utf-8" From: Taotao Chen Set FOP_DONTCACHE in ext4_file_operations to declare support for uncached buffered I/O. To handle this flag, update ext4_write_begin() and ext4_da_write_begin() to use write_begin_get_folio(), which encapsulates FGP_DONTCACHE logic based on iocb->ki_flags. Part of a series refactoring address_space_operations write_begin and write_end callbacks to use struct kiocb for passing write context and flags. Signed-off-by: Taotao Chen --- fs/ext4/file.c | 3 ++- fs/ext4/inode.c | 12 +++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 21df81347147..274b41a476c8 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -977,7 +977,8 @@ const struct file_operations ext4_file_operations =3D { .splice_write =3D iter_file_splice_write, .fallocate =3D ext4_fallocate, .fop_flags =3D FOP_MMAP_SYNC | FOP_BUFFER_RASYNC | - FOP_DIO_PARALLEL_WRITE, + FOP_DIO_PARALLEL_WRITE | + FOP_DONTCACHE, }; =20 const struct inode_operations ext4_file_inode_operations =3D { diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 9a16efd072bb..5c7024051f1e 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -1264,7 +1264,6 @@ static int ext4_write_begin(const struct kiocb *iocb, struct folio *folio; pgoff_t index; unsigned from, to; - fgf_t fgp =3D FGP_WRITEBEGIN; =20 ret =3D ext4_emergency_state(inode->i_sb); if (unlikely(ret)) @@ -1288,16 +1287,14 @@ static int ext4_write_begin(const struct kiocb *ioc= b, } =20 /* - * __filemap_get_folio() can take a long time if the + * write_begin_get_folio() can take a long time if the * system is thrashing due to memory pressure, or if the folio * is being written back. So grab it first before we start * the transaction handle. This also allows us to allocate * the folio (if needed) without using GFP_NOFS. */ retry_grab: - fgp |=3D fgf_set_order(len); - folio =3D __filemap_get_folio(mapping, index, fgp, - mapping_gfp_mask(mapping)); + folio =3D write_begin_get_folio(iocb, mapping, index, len); if (IS_ERR(folio)) return PTR_ERR(folio); =20 @@ -3046,7 +3043,6 @@ static int ext4_da_write_begin(const struct kiocb *io= cb, struct folio *folio; pgoff_t index; struct inode *inode =3D mapping->host; - fgf_t fgp =3D FGP_WRITEBEGIN; =20 ret =3D ext4_emergency_state(inode->i_sb); if (unlikely(ret)) @@ -3072,9 +3068,7 @@ static int ext4_da_write_begin(const struct kiocb *io= cb, } =20 retry: - fgp |=3D fgf_set_order(len); - folio =3D __filemap_get_folio(mapping, index, fgp, - mapping_gfp_mask(mapping)); + folio =3D write_begin_get_folio(iocb, mapping, index, len); if (IS_ERR(folio)) return PTR_ERR(folio); =20 --=20 2.34.1