* [PATCH 1/2] ext4: Fixes len calculation in mpage_journal_page_buffers
@ 2024-02-29 6:10 Ritesh Harjani (IBM)
2024-02-29 6:10 ` [PATCH 2/2] ext4: Remove PAGE_MASK dependency on mpage_submit_folio Ritesh Harjani (IBM)
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Ritesh Harjani (IBM) @ 2024-02-29 6:10 UTC (permalink / raw)
To: linux-ext4; +Cc: Jan Kara, Ritesh Harjani (IBM), stable
Truncate operation can race with writeback, in which inode->i_size can get
truncated and therefore size - folio_pos() can be negative. This fixes the
len calculation. However this path doesn't get easily triggered even
with data journaling.
Cc: <stable@kernel.org> # v6.5
Fixes: 80be8c5cc925 ("Fixes: ext4: Make mpage_journal_page_buffers use folio")
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
fs/ext4/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 537803250ca9..bab9223d94ac 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2334,7 +2334,7 @@ static int mpage_journal_page_buffers(handle_t *handle,
if (folio_pos(folio) + len > size &&
!ext4_verity_in_progress(inode))
- len = size - folio_pos(folio);
+ len = size & (len - 1);
return ext4_journal_folio_buffers(handle, folio, len);
}
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] ext4: Remove PAGE_MASK dependency on mpage_submit_folio
2024-02-29 6:10 [PATCH 1/2] ext4: Fixes len calculation in mpage_journal_page_buffers Ritesh Harjani (IBM)
@ 2024-02-29 6:10 ` Ritesh Harjani (IBM)
2024-03-11 18:46 ` Jan Kara
2024-03-11 18:45 ` [PATCH 1/2] ext4: Fixes len calculation in mpage_journal_page_buffers Jan Kara
2024-05-02 14:51 ` Theodore Ts'o
2 siblings, 1 reply; 5+ messages in thread
From: Ritesh Harjani (IBM) @ 2024-02-29 6:10 UTC (permalink / raw)
To: linux-ext4; +Cc: Jan Kara, Ritesh Harjani (IBM)
This patch simply removes the PAGE_MASK dependency since
mpage_submit_folio() is already converted to work with folio.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
fs/ext4/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index bab9223d94ac..e8b0773e5d2d 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1865,7 +1865,7 @@ static int mpage_submit_folio(struct mpage_da_data *mpd, struct folio *folio)
len = folio_size(folio);
if (folio_pos(folio) + len > size &&
!ext4_verity_in_progress(mpd->inode))
- len = size & ~PAGE_MASK;
+ len = size & (len - 1);
err = ext4_bio_write_folio(&mpd->io_submit, folio, len);
if (!err)
mpd->wbc->nr_to_write--;
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] ext4: Fixes len calculation in mpage_journal_page_buffers
2024-02-29 6:10 [PATCH 1/2] ext4: Fixes len calculation in mpage_journal_page_buffers Ritesh Harjani (IBM)
2024-02-29 6:10 ` [PATCH 2/2] ext4: Remove PAGE_MASK dependency on mpage_submit_folio Ritesh Harjani (IBM)
@ 2024-03-11 18:45 ` Jan Kara
2024-05-02 14:51 ` Theodore Ts'o
2 siblings, 0 replies; 5+ messages in thread
From: Jan Kara @ 2024-03-11 18:45 UTC (permalink / raw)
To: Ritesh Harjani (IBM); +Cc: linux-ext4, Jan Kara, stable
On Thu 29-02-24 11:40:13, Ritesh Harjani (IBM) wrote:
> Truncate operation can race with writeback, in which inode->i_size can get
> truncated and therefore size - folio_pos() can be negative. This fixes the
> len calculation. However this path doesn't get easily triggered even
> with data journaling.
>
> Cc: <stable@kernel.org> # v6.5
> Fixes: 80be8c5cc925 ("Fixes: ext4: Make mpage_journal_page_buffers use folio")
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ext4/inode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 537803250ca9..bab9223d94ac 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -2334,7 +2334,7 @@ static int mpage_journal_page_buffers(handle_t *handle,
>
> if (folio_pos(folio) + len > size &&
> !ext4_verity_in_progress(inode))
> - len = size - folio_pos(folio);
> + len = size & (len - 1);
>
> return ext4_journal_folio_buffers(handle, folio, len);
> }
> --
> 2.39.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] ext4: Remove PAGE_MASK dependency on mpage_submit_folio
2024-02-29 6:10 ` [PATCH 2/2] ext4: Remove PAGE_MASK dependency on mpage_submit_folio Ritesh Harjani (IBM)
@ 2024-03-11 18:46 ` Jan Kara
0 siblings, 0 replies; 5+ messages in thread
From: Jan Kara @ 2024-03-11 18:46 UTC (permalink / raw)
To: Ritesh Harjani (IBM); +Cc: linux-ext4, Jan Kara
On Thu 29-02-24 11:40:14, Ritesh Harjani (IBM) wrote:
> This patch simply removes the PAGE_MASK dependency since
> mpage_submit_folio() is already converted to work with folio.
>
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ext4/inode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index bab9223d94ac..e8b0773e5d2d 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -1865,7 +1865,7 @@ static int mpage_submit_folio(struct mpage_da_data *mpd, struct folio *folio)
> len = folio_size(folio);
> if (folio_pos(folio) + len > size &&
> !ext4_verity_in_progress(mpd->inode))
> - len = size & ~PAGE_MASK;
> + len = size & (len - 1);
> err = ext4_bio_write_folio(&mpd->io_submit, folio, len);
> if (!err)
> mpd->wbc->nr_to_write--;
> --
> 2.39.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] ext4: Fixes len calculation in mpage_journal_page_buffers
2024-02-29 6:10 [PATCH 1/2] ext4: Fixes len calculation in mpage_journal_page_buffers Ritesh Harjani (IBM)
2024-02-29 6:10 ` [PATCH 2/2] ext4: Remove PAGE_MASK dependency on mpage_submit_folio Ritesh Harjani (IBM)
2024-03-11 18:45 ` [PATCH 1/2] ext4: Fixes len calculation in mpage_journal_page_buffers Jan Kara
@ 2024-05-02 14:51 ` Theodore Ts'o
2 siblings, 0 replies; 5+ messages in thread
From: Theodore Ts'o @ 2024-05-02 14:51 UTC (permalink / raw)
To: linux-ext4, Ritesh Harjani (IBM); +Cc: Theodore Ts'o, Jan Kara, stable
On Thu, 29 Feb 2024 11:40:13 +0530, Ritesh Harjani (IBM) wrote:
> Truncate operation can race with writeback, in which inode->i_size can get
> truncated and therefore size - folio_pos() can be negative. This fixes the
> len calculation. However this path doesn't get easily triggered even
> with data journaling.
>
>
Applied, thanks!
[1/2] ext4: Fixes len calculation in mpage_journal_page_buffers
commit: c2a09f3d782de952f09a3962d03b939e7fa7ffa4
[2/2] ext4: Remove PAGE_MASK dependency on mpage_submit_folio
commit: 53c17fe55a06cbb405b94d96759611d725d2c47a
Best regards,
--
Theodore Ts'o <tytso@mit.edu>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-05-02 14:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-29 6:10 [PATCH 1/2] ext4: Fixes len calculation in mpage_journal_page_buffers Ritesh Harjani (IBM)
2024-02-29 6:10 ` [PATCH 2/2] ext4: Remove PAGE_MASK dependency on mpage_submit_folio Ritesh Harjani (IBM)
2024-03-11 18:46 ` Jan Kara
2024-03-11 18:45 ` [PATCH 1/2] ext4: Fixes len calculation in mpage_journal_page_buffers Jan Kara
2024-05-02 14:51 ` Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox