2024-02-29 14:31:50

by Ritesh Harjani

[permalink] [raw]
Subject: [PATCH 1/2] ext4: set FMODE_CAN_ODIRECT instead of a dummy direct_IO method

From: Christoph Hellwig <[email protected]>

Since commit a2ad63daa88b ("VFS: add FMODE_CAN_ODIRECT file flag") file
systems can just set the FMODE_CAN_ODIRECT flag at open time instead of
wiring up a dummy direct_IO method to indicate support for direct I/O.

Signed-off-by: Christoph Hellwig <[email protected]>
[RH: Rebased to upstream]
Signed-off-by: Ritesh Harjani (IBM) <[email protected]>
---
Stumbled upon [1], while I was trying to enable this flag in ext4_file_open().
Looks like it might have slipped through the cracks.
Hence sending this patch with Christoph as the author.
[1]: https://lore.kernel.org/linux-ext4/[email protected]/

fs/ext4/file.c | 2 +-
fs/ext4/inode.c | 4 ----
2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 54d6ff22585c..965febab1d04 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -886,7 +886,7 @@ static int ext4_file_open(struct inode *inode, struct file *filp)
}

filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC |
- FMODE_DIO_PARALLEL_WRITE;
+ FMODE_DIO_PARALLEL_WRITE | FMODE_CAN_ODIRECT;
return dquot_file_open(inode, filp);
}

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 2ccf3b5e3a7c..60a03b2ca178 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3530,7 +3530,6 @@ static const struct address_space_operations ext4_aops = {
.bmap = ext4_bmap,
.invalidate_folio = ext4_invalidate_folio,
.release_folio = ext4_release_folio,
- .direct_IO = noop_direct_IO,
.migrate_folio = buffer_migrate_folio,
.is_partially_uptodate = block_is_partially_uptodate,
.error_remove_folio = generic_error_remove_folio,
@@ -3547,7 +3546,6 @@ static const struct address_space_operations ext4_journalled_aops = {
.bmap = ext4_bmap,
.invalidate_folio = ext4_journalled_invalidate_folio,
.release_folio = ext4_release_folio,
- .direct_IO = noop_direct_IO,
.migrate_folio = buffer_migrate_folio_norefs,
.is_partially_uptodate = block_is_partially_uptodate,
.error_remove_folio = generic_error_remove_folio,
@@ -3564,7 +3562,6 @@ static const struct address_space_operations ext4_da_aops = {
.bmap = ext4_bmap,
.invalidate_folio = ext4_invalidate_folio,
.release_folio = ext4_release_folio,
- .direct_IO = noop_direct_IO,
.migrate_folio = buffer_migrate_folio,
.is_partially_uptodate = block_is_partially_uptodate,
.error_remove_folio = generic_error_remove_folio,
@@ -3573,7 +3570,6 @@ static const struct address_space_operations ext4_da_aops = {

static const struct address_space_operations ext4_dax_aops = {
.writepages = ext4_dax_writepages,
- .direct_IO = noop_direct_IO,
.dirty_folio = noop_dirty_folio,
.bmap = ext4_bmap,
.swap_activate = ext4_iomap_swap_activate,
--
2.39.2



2024-03-13 19:18:20

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH 1/2] ext4: set FMODE_CAN_ODIRECT instead of a dummy direct_IO method

On Thu 29-02-24 19:54:12, Ritesh Harjani (IBM) wrote:
> From: Christoph Hellwig <[email protected]>
>
> Since commit a2ad63daa88b ("VFS: add FMODE_CAN_ODIRECT file flag") file
> systems can just set the FMODE_CAN_ODIRECT flag at open time instead of
> wiring up a dummy direct_IO method to indicate support for direct I/O.
>
> Signed-off-by: Christoph Hellwig <[email protected]>
> [RH: Rebased to upstream]
> Signed-off-by: Ritesh Harjani (IBM) <[email protected]>

Looks good! Feel free to add:

Reviewed-by: Jan Kara <[email protected]>

Honza

> ---
> Stumbled upon [1], while I was trying to enable this flag in ext4_file_open().
> Looks like it might have slipped through the cracks.
> Hence sending this patch with Christoph as the author.
> [1]: https://lore.kernel.org/linux-ext4/[email protected]/
>
> fs/ext4/file.c | 2 +-
> fs/ext4/inode.c | 4 ----
> 2 files changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/fs/ext4/file.c b/fs/ext4/file.c
> index 54d6ff22585c..965febab1d04 100644
> --- a/fs/ext4/file.c
> +++ b/fs/ext4/file.c
> @@ -886,7 +886,7 @@ static int ext4_file_open(struct inode *inode, struct file *filp)
> }
>
> filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC |
> - FMODE_DIO_PARALLEL_WRITE;
> + FMODE_DIO_PARALLEL_WRITE | FMODE_CAN_ODIRECT;
> return dquot_file_open(inode, filp);
> }
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 2ccf3b5e3a7c..60a03b2ca178 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -3530,7 +3530,6 @@ static const struct address_space_operations ext4_aops = {
> .bmap = ext4_bmap,
> .invalidate_folio = ext4_invalidate_folio,
> .release_folio = ext4_release_folio,
> - .direct_IO = noop_direct_IO,
> .migrate_folio = buffer_migrate_folio,
> .is_partially_uptodate = block_is_partially_uptodate,
> .error_remove_folio = generic_error_remove_folio,
> @@ -3547,7 +3546,6 @@ static const struct address_space_operations ext4_journalled_aops = {
> .bmap = ext4_bmap,
> .invalidate_folio = ext4_journalled_invalidate_folio,
> .release_folio = ext4_release_folio,
> - .direct_IO = noop_direct_IO,
> .migrate_folio = buffer_migrate_folio_norefs,
> .is_partially_uptodate = block_is_partially_uptodate,
> .error_remove_folio = generic_error_remove_folio,
> @@ -3564,7 +3562,6 @@ static const struct address_space_operations ext4_da_aops = {
> .bmap = ext4_bmap,
> .invalidate_folio = ext4_invalidate_folio,
> .release_folio = ext4_release_folio,
> - .direct_IO = noop_direct_IO,
> .migrate_folio = buffer_migrate_folio,
> .is_partially_uptodate = block_is_partially_uptodate,
> .error_remove_folio = generic_error_remove_folio,
> @@ -3573,7 +3570,6 @@ static const struct address_space_operations ext4_da_aops = {
>
> static const struct address_space_operations ext4_dax_aops = {
> .writepages = ext4_dax_writepages,
> - .direct_IO = noop_direct_IO,
> .dirty_folio = noop_dirty_folio,
> .bmap = ext4_bmap,
> .swap_activate = ext4_iomap_swap_activate,
> --
> 2.39.2
>
--
Jan Kara <[email protected]>
SUSE Labs, CR