diff mbox series

[v3,5/6] mm/migrate: fail MIGRATE_SYNC for folios under writeback with AS_WRITEBACK_MAY_BLOCK mappings

Message ID 20241107191618.2011146-6-joannelkoong@gmail.com (mailing list archive)
State New
Headers show
Series fuse: remove temp page copies in writeback | expand

Commit Message

Joanne Koong Nov. 7, 2024, 7:16 p.m. UTC
For folios with mappings that have the AS_WRITEBACK_MAY_BLOCK flag set
on it, fail MIGRATE_SYNC mode migration with -EBUSY if the folio is
currently under writeback. If the AS_WRITEBACK_MAY_BLOCK flag is set on
the mapping, the writeback may take an indeterminate amount of time to
complete, so we cannot wait on writeback.

Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
---
 mm/migrate.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Joanne Koong Nov. 7, 2024, 7:22 p.m. UTC | #1
On Thu, Nov 7, 2024 at 11:17 AM Joanne Koong <joannelkoong@gmail.com> wrote:
>
> For folios with mappings that have the AS_WRITEBACK_MAY_BLOCK flag set
> on it, fail MIGRATE_SYNC mode migration with -EBUSY if the folio is
> currently under writeback. If the AS_WRITEBACK_MAY_BLOCK flag is set on
> the mapping, the writeback may take an indeterminate amount of time to
> complete, so we cannot wait on writeback.

Please ignore this patch (i meant to delete it from my local repo but
forgot before submitting) - it is superseded by
https://lore.kernel.org/linux-fsdevel/20241107191618.2011146-7-joannelkoong@gmail.com/T/#u,
which is the same change but has a more correct commit message. The
migration is skipped (see migrate_pages_batch() logic), not failed.


Thanks,
Joanne

>
> Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
> ---
>  mm/migrate.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/mm/migrate.c b/mm/migrate.c
> index df91248755e4..1d038a4202ae 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -1260,7 +1260,10 @@ static int migrate_folio_unmap(new_folio_t get_new_folio,
>                  */
>                 switch (mode) {
>                 case MIGRATE_SYNC:
> -                       break;
> +                       if (!src->mapping ||
> +                           !mapping_writeback_may_block(src->mapping))
> +                               break;
> +                       fallthrough;
>                 default:
>                         rc = -EBUSY;
>                         goto out;
> --
> 2.43.5
>
diff mbox series

Patch

diff --git a/mm/migrate.c b/mm/migrate.c
index df91248755e4..1d038a4202ae 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1260,7 +1260,10 @@  static int migrate_folio_unmap(new_folio_t get_new_folio,
 		 */
 		switch (mode) {
 		case MIGRATE_SYNC:
-			break;
+			if (!src->mapping ||
+			    !mapping_writeback_may_block(src->mapping))
+				break;
+			fallthrough;
 		default:
 			rc = -EBUSY;
 			goto out;