From nobody Wed Oct 8 22:35:38 2025 Received: from mx9.didiglobal.com (mx9.didiglobal.com [111.202.70.124]) by smtp.subspace.kernel.org (Postfix) with SMTP id E5E1D2C159D; Tue, 24 Jun 2025 12:15:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=111.202.70.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750767343; cv=none; b=N6/XtD50NlefIPqY3rzSp5B52evU2W60+bY9oxu5uQJ1YQRyRjv3qE8ErXa2ALYdfSqp2VYrSrkmhiGX2YsIuj9Zspz7xidx6KWANwCVpVfVzBFWot837mMKmV/VMfJSQ93TFPeOSVmaVQqbf1QajBXDLkKPujRaRU6glbbUSI0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750767343; c=relaxed/simple; bh=UUOG9CnjyAD4jWpFLTC0doAjRjHNZAiWQCI/Hwlwayg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version; b=R+9PkCRo2qa2LnOOyOA13b5xHrD+HdJeXC1UZJDAvFqQt5Tr6d4IdA95PdseZpfCk/2dNp7usfud/8dU5aABVxRGxu/XBRI9w6Dld6c/K/y0JtZF6EpAuaIVqNnQtT0Och64MDsQxknDnNR4ty/i2LVq2kYwrcOMN3H1D3OTlN8= 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=aA5b0ent; arc=none smtp.client-ip=111.202.70.124 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="aA5b0ent" Received: from mail.didiglobal.com (unknown [10.79.64.20]) by mx9.didiglobal.com (MailData Gateway V2.8.8) with ESMTPS id 06118187957BCC; Tue, 24 Jun 2025 20:11:31 +0800 (CST) Received: from BJ01-ACTMBX-07.didichuxing.com (10.79.64.14) by BJ01-ACTMBX-01.didichuxing.com (10.79.64.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Tue, 24 Jun 2025 20:12:10 +0800 Received: from BJ03-ACTMBX-07.didichuxing.com (10.79.71.34) by BJ01-ACTMBX-07.didichuxing.com (10.79.64.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Tue, 24 Jun 2025 20:12:09 +0800 Received: from BJ03-ACTMBX-07.didichuxing.com ([fe80::b00b:de35:2067:9787]) by BJ03-ACTMBX-07.didichuxing.com ([fe80::b00b:de35:2067:9787%7]) with mapi id 15.02.1748.010; Tue, 24 Jun 2025 20:12:09 +0800 X-MD-Sfrom: chentaotao@didiglobal.com X-MD-SrcIP: 10.79.64.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" , =?gb2312?B?s8LMzszOIFRhb3RhbyBDaGVu?= Subject: [PATCH v2 4/5] ext4: handle IOCB_DONTCACHE in buffered write path Thread-Topic: [PATCH v2 4/5] ext4: handle IOCB_DONTCACHE in buffered write path Thread-Index: AQHb5QE1yGRcX3naAEuwD6HzjMhP6Q== Date: Tue, 24 Jun 2025 12:12:09 +0000 Message-ID: <20250624121149.2927-5-chentaotao@didiglobal.com> In-Reply-To: <20250624121149.2927-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=1750767112; bh=UUOG9CnjyAD4jWpFLTC0doAjRjHNZAiWQCI/Hwlwayg=; h=From:To:CC:Subject:Date:Message-ID:Content-Type; b=aA5b0entemeSUTUM68+duldd0xmEU+TuNweqA1Zwyg6zKSSslLqekm1ZTqq53Py+k QXFs+50AmoUq8r/dLYGr5rk5tV2ZPkhF2JdL23bTlKZgWiS64ttVhcPjfpB7waWey7 oOfmLnJpgrV4Epk/UiDqQZqbbMuQqN7PuMSRXEZM= Content-Type: text/plain; charset="utf-8" From: Taotao Chen Add support for the IOCB_DONTCACHE flag in ext4_write_begin() and ext4_da_write_begin(). When set in the kiocb, the FGP_DONTCACHE bit is passed to the page cache lookup, preventing written pages from being retained in the cache. Only the handling logic is implemented here; the behavior remains inactive until ext4 advertises support via FOP_DONTCACHE. This change relies on prior patches that refactor the write_begin interface to use struct kiocb and introduce DONTCACHE handling in ext4. 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 Acked-by: Theodore Ts'o --- fs/ext4/inode.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 7ff7009f9799..3a82b52565cc 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -1269,6 +1269,9 @@ static int ext4_write_begin(struct kiocb *iocb, struc= t address_space *mapping, if (unlikely(ret)) return ret; =20 + if (iocb->ki_flags & IOCB_DONTCACHE) + fgp |=3D FGP_DONTCACHE; + trace_ext4_write_begin(inode, pos, len); /* * Reserve one block more for addition to orphan list in case @@ -3066,6 +3069,9 @@ static int ext4_da_write_begin(struct kiocb *iocb, st= ruct address_space *mapping return 0; } =20 + if (iocb->ki_flags & IOCB_DONTCACHE) + fgp |=3D FGP_DONTCACHE; + retry: fgp |=3D fgf_set_order(len); folio =3D __filemap_get_folio(mapping, index, fgp, --=20 2.34.1