[PATCH 7/7] ext4: show 'shutdown' hint when ext4 is forced to shutdown

libaokun@huaweicloud.com posted 7 patches 1 year ago
There is a newer version of this series
[PATCH 7/7] ext4: show 'shutdown' hint when ext4 is forced to shutdown
Posted by libaokun@huaweicloud.com 1 year ago
From: Baokun Li <libaokun1@huawei.com>

Now, if dmesg is cleared, we have no way of knowing if the file system has
been shutdown. Moreover, ext4 allows directory reads even after the file
system has been shutdown, so when reading a file returns -EIO, we cannot
determine whether this is a hardware issue or if the file system has been
shutdown.

Therefore, when ext4 file system is shutdown, we're adding a 'shutdown'
hint to commands like mount so users can easily check the file system's
status.

Signed-off-by: Baokun Li <libaokun1@huawei.com>
---
 fs/ext4/super.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 2377ebf0aff1..b15c36df934c 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3032,6 +3032,9 @@ static int _ext4_show_options(struct seq_file *seq, struct super_block *sb,
 	if (ext4_emergency_ro(sb))
 		SEQ_OPTS_PUTS("emergency_ro");
 
+	if (ext4_forced_shutdown(sb))
+		SEQ_OPTS_PUTS("shutdown");
+
 	ext4_show_quota_options(seq, sb);
 	return 0;
 }
-- 
2.39.2
Re: [PATCH 7/7] ext4: show 'shutdown' hint when ext4 is forced to shutdown
Posted by Jan Kara 1 year ago
On Fri 17-01-25 16:23:15, libaokun@huaweicloud.com wrote:
> From: Baokun Li <libaokun1@huawei.com>
> 
> Now, if dmesg is cleared, we have no way of knowing if the file system has
> been shutdown. Moreover, ext4 allows directory reads even after the file
> system has been shutdown, so when reading a file returns -EIO, we cannot
> determine whether this is a hardware issue or if the file system has been
> shutdown.
> 
> Therefore, when ext4 file system is shutdown, we're adding a 'shutdown'
> hint to commands like mount so users can easily check the file system's
> status.
> 
> Signed-off-by: Baokun Li <libaokun1@huawei.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ext4/super.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 2377ebf0aff1..b15c36df934c 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -3032,6 +3032,9 @@ static int _ext4_show_options(struct seq_file *seq, struct super_block *sb,
>  	if (ext4_emergency_ro(sb))
>  		SEQ_OPTS_PUTS("emergency_ro");
>  
> +	if (ext4_forced_shutdown(sb))
> +		SEQ_OPTS_PUTS("shutdown");
> +
>  	ext4_show_quota_options(seq, sb);
>  	return 0;
>  }
> -- 
> 2.39.2
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR