mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] exfat: drain dirty pages after forced shutdown
@ 2026-10-26  9:15 Chi Zhiling
  2026-10-26 10:59 ` Namjae Jeon
  0 siblings, 1 reply; 3+ messages in thread
From: Chi Zhiling @ 2026-10-26  9:15 UTC (permalink / raw)
  To: linux-kernel, exfat; +Cc: Namjae Jeon, Sungjong Seo, Yuezhang Mo, Chi Zhiling

From: Chi Zhiling <chizhiling@kylinos.cn>

A forced shutdown sets EXFAT_FLAGS_SHUTDOWN, after which
exfat_writepages() returns -EIO.  Pages dirtied before the shutdown can
then never be written back, so a writer throttled in
balance_dirty_pages() while extending valid_size sleeps forever.

Stuck stack:

  balance_dirty_pages+0x4f0/0xb40
  exfat_prepare_valid_range+0x43/0x140
  exfat_file_write_iter+0x413/0x520
  iter_file_splice_write+0x32d/0x5a0
  direct_splice_actor+0x51/0x270
  splice_direct_to_actor+0xf5/0x270
  do_splice_direct+0x76/0xc0
  vfs_copy_file_range+0x244/0x710
  __do_sys_copy_file_range+0xe6/0x240
  do_syscall_64+0x106/0x5f0
  entry_SYSCALL_64_after_hwframe+0x77/0x7f

Allow writeback of pages dirtied before the shutdown to drain.  New
writes are still rejected in exfat_write_iomap_begin() and
exfat_prepare_valid_range().

Fixes: f761fcdd289d0 ("exfat: Implement sops->shutdown and ioctl")
Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
---
 fs/exfat/file.c  | 3 +++
 fs/exfat/inode.c | 3 ---
 fs/exfat/iomap.c | 3 +++
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/exfat/file.c b/fs/exfat/file.c
index 1386149916bb..8b9fadba363f 100644
--- a/fs/exfat/file.c
+++ b/fs/exfat/file.c
@@ -735,6 +735,9 @@ static int exfat_prepare_valid_range(struct inode *inode, loff_t start,
 		index = pos >> PAGE_SHIFT;
 		next = min(((loff_t)index + 1) << PAGE_SHIFT, end);
 
+		if (exfat_forced_shutdown(inode->i_sb))
+			return -EIO;
+
 		balance_dirty_pages_ratelimited(mapping);
 
 		folio = read_mapping_folio(mapping, index, NULL);
diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c
index 5129df1e79b4..4bea9e9deb94 100644
--- a/fs/exfat/inode.c
+++ b/fs/exfat/inode.c
@@ -283,9 +283,6 @@ static int exfat_writepages(struct address_space *mapping,
 		.ops		= &exfat_writeback_ops,
 	};
 
-	if (unlikely(exfat_forced_shutdown(mapping->host->i_sb)))
-		return -EIO;
-
 	return iomap_writepages(&wpc);
 }
 
diff --git a/fs/exfat/iomap.c b/fs/exfat/iomap.c
index e50ecbfbfbe0..6383739f5700 100644
--- a/fs/exfat/iomap.c
+++ b/fs/exfat/iomap.c
@@ -165,6 +165,9 @@ static int exfat_write_iomap_begin(struct inode *inode, loff_t offset, loff_t le
 	loff_t end;
 	int err;
 
+	if (exfat_forced_shutdown(inode->i_sb))
+		return -EIO;
+
 	err = __exfat_iomap_begin(inode, offset, length, flags, iomap, true);
 	if (err || flags & (IOMAP_DIRECT | IOMAP_FAULT) ||
 	    iomap->flags & IOMAP_F_NEW)
-- 
2.53.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] exfat: drain dirty pages after forced shutdown
  2026-10-26  9:15 [PATCH] exfat: drain dirty pages after forced shutdown Chi Zhiling
@ 2026-10-26 10:59 ` Namjae Jeon
  2026-10-26 14:41   ` Chi Zhiling
  0 siblings, 1 reply; 3+ messages in thread
From: Namjae Jeon @ 2026-10-26 10:59 UTC (permalink / raw)
  To: Chi Zhiling; +Cc: linux-kernel, exfat, Sungjong Seo, Yuezhang Mo, Chi Zhiling

> @@ -283,9 +283,6 @@ static int exfat_writepages(struct address_space *mapping,
>                 .ops            = &exfat_writeback_ops,
>         };
>
> -       if (unlikely(exfat_forced_shutdown(mapping->host->i_sb)))
> -               return -EIO;
Please move this check to exfat_writeback_range(). Returning -EIO
there lets iomap clear dirty state without writing data after
shutdown.

> -
>         return iomap_writepages(&wpc);
>  }
>
> diff --git a/fs/exfat/iomap.c b/fs/exfat/iomap.c
> index e50ecbfbfbe0..6383739f5700 100644
> --- a/fs/exfat/iomap.c
> +++ b/fs/exfat/iomap.c
> @@ -165,6 +165,9 @@ static int exfat_write_iomap_begin(struct inode *inode, loff_t offset, loff_t le
>         loff_t end;
>         int err;
>
> +       if (exfat_forced_shutdown(inode->i_sb))
> +               return -EIO;
This check is not needed for this hang fix. exfat_file_write_iter()
already checks new writes after shutdown.
It also misses existing mmap writes, which use exfat_iomap_ops. We
need to add a shutdown check to exfat_page_mkwrite() also.
Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] exfat: drain dirty pages after forced shutdown
  2026-10-26 10:59 ` Namjae Jeon
@ 2026-10-26 14:41   ` Chi Zhiling
  0 siblings, 0 replies; 3+ messages in thread
From: Chi Zhiling @ 2026-10-26 14:41 UTC (permalink / raw)
  To: Namjae Jeon; +Cc: linux-kernel, exfat, Sungjong Seo, Yuezhang Mo, Chi Zhiling

On 10/26/26 6:59 PM, Namjae Jeon wrote:
>> @@ -283,9 +283,6 @@ static int exfat_writepages(struct address_space *mapping,
>>                  .ops            = &exfat_writeback_ops,
>>          };
>>
>> -       if (unlikely(exfat_forced_shutdown(mapping->host->i_sb)))
>> -               return -EIO;
> Please move this check to exfat_writeback_range(). Returning -EIO
> there lets iomap clear dirty state without writing data after
> shutdown.

Okay,

> 
>> -
>>          return iomap_writepages(&wpc);
>>   }
>>
>> diff --git a/fs/exfat/iomap.c b/fs/exfat/iomap.c
>> index e50ecbfbfbe0..6383739f5700 100644
>> --- a/fs/exfat/iomap.c
>> +++ b/fs/exfat/iomap.c
>> @@ -165,6 +165,9 @@ static int exfat_write_iomap_begin(struct inode *inode, loff_t offset, loff_t le
>>          loff_t end;
>>          int err;
>>
>> +       if (exfat_forced_shutdown(inode->i_sb))
>> +               return -EIO;
> This check is not needed for this hang fix. exfat_file_write_iter()
> already checks new writes after shutdown.
> It also misses existing mmap writes, which use exfat_iomap_ops. We
> need to add a shutdown check to exfat_page_mkwrite() also.

Okay,

Thanks.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-26 14:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26  9:15 [PATCH] exfat: drain dirty pages after forced shutdown Chi Zhiling
2026-10-26 10:59 ` Namjae Jeon
2026-10-26 14:41   ` Chi Zhiling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®