[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250710101404.362146-6-chentaotao@didiglobal.com>
Date: Thu, 10 Jul 2025 10:14:13 +0000
From: 陈涛涛 Taotao Chen <chentaotao@...iglobal.com>
To: "tytso@....edu" <tytso@....edu>, "hch@...radead.org" <hch@...radead.org>,
"adilger.kernel@...ger.ca" <adilger.kernel@...ger.ca>, "willy@...radead.org"
<willy@...radead.org>, "brauner@...nel.org" <brauner@...nel.org>,
"jani.nikula@...ux.intel.com" <jani.nikula@...ux.intel.com>,
"rodrigo.vivi@...el.com" <rodrigo.vivi@...el.com>, "tursulin@...ulin.net"
<tursulin@...ulin.net>, "airlied@...il.com" <airlied@...il.com>
CC: "linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
"linux-ext4@...r.kernel.org" <linux-ext4@...r.kernel.org>,
"linux-block@...r.kernel.org" <linux-block@...r.kernel.org>,
"intel-gfx@...ts.freedesktop.org" <intel-gfx@...ts.freedesktop.org>,
"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>, "linux-doc@...r.kernel.org"
<linux-doc@...r.kernel.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "chentao325@...com" <chentao325@...com>,
"frank.li@...o.com" <frank.li@...o.com>,
陈涛涛 Taotao Chen <chentaotao@...iglobal.com>
Subject: [PATCH v5 5/5] ext4: support uncached buffered I/O
From: Taotao Chen <chentaotao@...iglobal.com>
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 <chentaotao@...iglobal.com>
---
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 = {
.splice_write = iter_file_splice_write,
.fallocate = ext4_fallocate,
.fop_flags = FOP_MMAP_SYNC | FOP_BUFFER_RASYNC |
- FOP_DIO_PARALLEL_WRITE,
+ FOP_DIO_PARALLEL_WRITE |
+ FOP_DONTCACHE,
};
const struct inode_operations ext4_file_inode_operations = {
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 = FGP_WRITEBEGIN;
ret = ext4_emergency_state(inode->i_sb);
if (unlikely(ret))
@@ -1288,16 +1287,14 @@ static int ext4_write_begin(const struct kiocb *iocb,
}
/*
- * __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 |= fgf_set_order(len);
- folio = __filemap_get_folio(mapping, index, fgp,
- mapping_gfp_mask(mapping));
+ folio = write_begin_get_folio(iocb, mapping, index, len);
if (IS_ERR(folio))
return PTR_ERR(folio);
@@ -3046,7 +3043,6 @@ static int ext4_da_write_begin(const struct kiocb *iocb,
struct folio *folio;
pgoff_t index;
struct inode *inode = mapping->host;
- fgf_t fgp = FGP_WRITEBEGIN;
ret = ext4_emergency_state(inode->i_sb);
if (unlikely(ret))
@@ -3072,9 +3068,7 @@ static int ext4_da_write_begin(const struct kiocb *iocb,
}
retry:
- fgp |= fgf_set_order(len);
- folio = __filemap_get_folio(mapping, index, fgp,
- mapping_gfp_mask(mapping));
+ folio = write_begin_get_folio(iocb, mapping, index, len);
if (IS_ERR(folio))
return PTR_ERR(folio);
--
2.34.1
Powered by blists - more mailing lists