Skip to content

Commit ae21c0c

Browse files
Taotao Chenbrauner
authored andcommitted
ext4: support uncached buffered I/O
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@didiglobal.com> Link: https://lore.kernel.org/20250716093559.217344-6-chentaotao@didiglobal.com Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent b799474 commit ae21c0c

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

fs/ext4/file.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,8 @@ const struct file_operations ext4_file_operations = {
977977
.splice_write = iter_file_splice_write,
978978
.fallocate = ext4_fallocate,
979979
.fop_flags = FOP_MMAP_SYNC | FOP_BUFFER_RASYNC |
980-
FOP_DIO_PARALLEL_WRITE,
980+
FOP_DIO_PARALLEL_WRITE |
981+
FOP_DONTCACHE,
981982
};
982983

983984
const struct inode_operations ext4_file_inode_operations = {

fs/ext4/inode.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,6 @@ static int ext4_write_begin(const struct kiocb *iocb,
12641264
struct folio *folio;
12651265
pgoff_t index;
12661266
unsigned from, to;
1267-
fgf_t fgp = FGP_WRITEBEGIN;
12681267

12691268
ret = ext4_emergency_state(inode->i_sb);
12701269
if (unlikely(ret))
@@ -1288,16 +1287,14 @@ static int ext4_write_begin(const struct kiocb *iocb,
12881287
}
12891288

12901289
/*
1291-
* __filemap_get_folio() can take a long time if the
1290+
* write_begin_get_folio() can take a long time if the
12921291
* system is thrashing due to memory pressure, or if the folio
12931292
* is being written back. So grab it first before we start
12941293
* the transaction handle. This also allows us to allocate
12951294
* the folio (if needed) without using GFP_NOFS.
12961295
*/
12971296
retry_grab:
1298-
fgp |= fgf_set_order(len);
1299-
folio = __filemap_get_folio(mapping, index, fgp,
1300-
mapping_gfp_mask(mapping));
1297+
folio = write_begin_get_folio(iocb, mapping, index, len);
13011298
if (IS_ERR(folio))
13021299
return PTR_ERR(folio);
13031300

@@ -3046,7 +3043,6 @@ static int ext4_da_write_begin(const struct kiocb *iocb,
30463043
struct folio *folio;
30473044
pgoff_t index;
30483045
struct inode *inode = mapping->host;
3049-
fgf_t fgp = FGP_WRITEBEGIN;
30503046

30513047
ret = ext4_emergency_state(inode->i_sb);
30523048
if (unlikely(ret))
@@ -3072,9 +3068,7 @@ static int ext4_da_write_begin(const struct kiocb *iocb,
30723068
}
30733069

30743070
retry:
3075-
fgp |= fgf_set_order(len);
3076-
folio = __filemap_get_folio(mapping, index, fgp,
3077-
mapping_gfp_mask(mapping));
3071+
folio = write_begin_get_folio(iocb, mapping, index, len);
30783072
if (IS_ERR(folio))
30793073
return PTR_ERR(folio);
30803074

0 commit comments

Comments
 (0)