public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: report filesystem shutdown via fserror
@ 2026-02-16  0:28 Miquel Sabaté Solà
  2026-02-18 11:54 ` Filipe Manana
  0 siblings, 1 reply; 4+ messages in thread
From: Miquel Sabaté Solà @ 2026-02-16  0:28 UTC (permalink / raw)
  To: dsterba; +Cc: clm, linux-btrfs, linux-kernel, Miquel Sabaté Solà

Commit 347b7042fb26 ("Merge patch series "fs: generic file IO error
reporting"") has introduced a common framework for reporting errors to
fsnotify in a standard way.

One of the functions being introduced is 'fserror_report_shutdown' that,
when combined with the experimental support for shutdown in btrfs, it
means that user-space can also easily detect whenever a btrfs filesystem
has been marked as shutdown.

Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
---
Note that the for-next branch does not include the mentioned commit. I've
built and tested this patch on top of current Linus' tree.

 fs/btrfs/fs.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/fs.h b/fs/btrfs/fs.h
index 3de3b517810e..92fcebf5766e 100644
--- a/fs/btrfs/fs.h
+++ b/fs/btrfs/fs.h
@@ -33,6 +33,7 @@
 #include "async-thread.h"
 #include "block-rsv.h"
 #include "messages.h"
+#include <linux/fserror.h>

 struct inode;
 struct super_block;
@@ -1199,8 +1200,10 @@ static inline void btrfs_force_shutdown(struct btrfs_fs_info *fs_info)
 	 * So here we only mark the fs error without flipping it RO.
 	 */
 	WRITE_ONCE(fs_info->fs_error, -EIO);
-	if (!test_and_set_bit(BTRFS_FS_STATE_EMERGENCY_SHUTDOWN, &fs_info->fs_state))
+	if (!test_and_set_bit(BTRFS_FS_STATE_EMERGENCY_SHUTDOWN, &fs_info->fs_state)) {
 		btrfs_crit(fs_info, "emergency shutdown");
+		fserror_report_shutdown(fs_info->sb, GFP_KERNEL);
+	}
 }

 /*
--
2.53.0

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

* Re: [PATCH] btrfs: report filesystem shutdown via fserror
  2026-02-16  0:28 [PATCH] btrfs: report filesystem shutdown via fserror Miquel Sabaté Solà
@ 2026-02-18 11:54 ` Filipe Manana
  2026-02-18 11:58   ` Miquel Sabaté Solà
       [not found]   ` <6995a98f.170a0220.4341d.d20aSMTPIN_ADDED_BROKEN@mx.google.com>
  0 siblings, 2 replies; 4+ messages in thread
From: Filipe Manana @ 2026-02-18 11:54 UTC (permalink / raw)
  To: Miquel Sabaté Solà; +Cc: dsterba, clm, linux-btrfs, linux-kernel

On Mon, Feb 16, 2026 at 3:01 AM Miquel Sabaté Solà <mssola@mssola.com> wrote:
>
> Commit 347b7042fb26 ("Merge patch series "fs: generic file IO error
> reporting"") has introduced a common framework for reporting errors to
> fsnotify in a standard way.
>
> One of the functions being introduced is 'fserror_report_shutdown' that,
> when combined with the experimental support for shutdown in btrfs, it
> means that user-space can also easily detect whenever a btrfs filesystem
> has been marked as shutdown.
>
> Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>

Reviewed-by: Filipe Manana <fdmanana@suse.com>

Once the for-next branch is based on the next kernel rc that includes
the new function, I can push the patch there.

Thanks.

> ---
> Note that the for-next branch does not include the mentioned commit. I've
> built and tested this patch on top of current Linus' tree.
>
>  fs/btrfs/fs.h | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/fs.h b/fs/btrfs/fs.h
> index 3de3b517810e..92fcebf5766e 100644
> --- a/fs/btrfs/fs.h
> +++ b/fs/btrfs/fs.h
> @@ -33,6 +33,7 @@
>  #include "async-thread.h"
>  #include "block-rsv.h"
>  #include "messages.h"
> +#include <linux/fserror.h>
>
>  struct inode;
>  struct super_block;
> @@ -1199,8 +1200,10 @@ static inline void btrfs_force_shutdown(struct btrfs_fs_info *fs_info)
>          * So here we only mark the fs error without flipping it RO.
>          */
>         WRITE_ONCE(fs_info->fs_error, -EIO);
> -       if (!test_and_set_bit(BTRFS_FS_STATE_EMERGENCY_SHUTDOWN, &fs_info->fs_state))
> +       if (!test_and_set_bit(BTRFS_FS_STATE_EMERGENCY_SHUTDOWN, &fs_info->fs_state)) {
>                 btrfs_crit(fs_info, "emergency shutdown");
> +               fserror_report_shutdown(fs_info->sb, GFP_KERNEL);
> +       }
>  }
>
>  /*
> --
> 2.53.0
>

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

* Re: [PATCH] btrfs: report filesystem shutdown via fserror
  2026-02-18 11:54 ` Filipe Manana
@ 2026-02-18 11:58   ` Miquel Sabaté Solà
       [not found]   ` <6995a98f.170a0220.4341d.d20aSMTPIN_ADDED_BROKEN@mx.google.com>
  1 sibling, 0 replies; 4+ messages in thread
From: Miquel Sabaté Solà @ 2026-02-18 11:58 UTC (permalink / raw)
  To: Filipe Manana; +Cc: dsterba, clm, linux-btrfs, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2041 bytes --]

Filipe Manana @ 2026-02-18 11:54 GMT:

> On Mon, Feb 16, 2026 at 3:01 AM Miquel Sabaté Solà <mssola@mssola.com> wrote:
>>
>> Commit 347b7042fb26 ("Merge patch series "fs: generic file IO error
>> reporting"") has introduced a common framework for reporting errors to
>> fsnotify in a standard way.
>>
>> One of the functions being introduced is 'fserror_report_shutdown' that,
>> when combined with the experimental support for shutdown in btrfs, it
>> means that user-space can also easily detect whenever a btrfs filesystem
>> has been marked as shutdown.
>>
>> Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
>
> Reviewed-by: Filipe Manana <fdmanana@suse.com>
>
> Once the for-next branch is based on the next kernel rc that includes
> the new function, I can push the patch there.

Thanks for taking care of this!

>
> Thanks.
>
>> ---
>> Note that the for-next branch does not include the mentioned commit. I've
>> built and tested this patch on top of current Linus' tree.
>>
>>  fs/btrfs/fs.h | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/btrfs/fs.h b/fs/btrfs/fs.h
>> index 3de3b517810e..92fcebf5766e 100644
>> --- a/fs/btrfs/fs.h
>> +++ b/fs/btrfs/fs.h
>> @@ -33,6 +33,7 @@
>>  #include "async-thread.h"
>>  #include "block-rsv.h"
>>  #include "messages.h"
>> +#include <linux/fserror.h>
>>
>>  struct inode;
>>  struct super_block;
>> @@ -1199,8 +1200,10 @@ static inline void btrfs_force_shutdown(struct btrfs_fs_info *fs_info)
>>          * So here we only mark the fs error without flipping it RO.
>>          */
>>         WRITE_ONCE(fs_info->fs_error, -EIO);
>> -       if (!test_and_set_bit(BTRFS_FS_STATE_EMERGENCY_SHUTDOWN, &fs_info->fs_state))
>> +       if (!test_and_set_bit(BTRFS_FS_STATE_EMERGENCY_SHUTDOWN, &fs_info->fs_state)) {
>>                 btrfs_crit(fs_info, "emergency shutdown");
>> +               fserror_report_shutdown(fs_info->sb, GFP_KERNEL);
>> +       }
>>  }
>>
>>  /*
>> --
>> 2.53.0
>>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 897 bytes --]

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

* Re: [PATCH] btrfs: report filesystem shutdown via fserror
       [not found]   ` <6995a98f.170a0220.4341d.d20aSMTPIN_ADDED_BROKEN@mx.google.com>
@ 2026-02-27  9:29     ` Filipe Manana
  0 siblings, 0 replies; 4+ messages in thread
From: Filipe Manana @ 2026-02-27  9:29 UTC (permalink / raw)
  To: Miquel Sabaté Solà; +Cc: dsterba, clm, linux-btrfs, linux-kernel

On Wed, Feb 18, 2026 at 11:59 AM Miquel Sabaté Solà <mssola@mssola.com> wrote:
>
> Filipe Manana @ 2026-02-18 11:54 GMT:
>
> > On Mon, Feb 16, 2026 at 3:01 AM Miquel Sabaté Solà <mssola@mssola.com> wrote:
> >>
> >> Commit 347b7042fb26 ("Merge patch series "fs: generic file IO error
> >> reporting"") has introduced a common framework for reporting errors to
> >> fsnotify in a standard way.
> >>
> >> One of the functions being introduced is 'fserror_report_shutdown' that,
> >> when combined with the experimental support for shutdown in btrfs, it
> >> means that user-space can also easily detect whenever a btrfs filesystem
> >> has been marked as shutdown.
> >>
> >> Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
> >
> > Reviewed-by: Filipe Manana <fdmanana@suse.com>
> >
> > Once the for-next branch is based on the next kernel rc that includes
> > the new function, I can push the patch there.

Now pushed into the for-next github branch.

>
> Thanks for taking care of this!
>
> >
> > Thanks.
> >
> >> ---
> >> Note that the for-next branch does not include the mentioned commit. I've
> >> built and tested this patch on top of current Linus' tree.
> >>
> >>  fs/btrfs/fs.h | 5 ++++-
> >>  1 file changed, 4 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/fs/btrfs/fs.h b/fs/btrfs/fs.h
> >> index 3de3b517810e..92fcebf5766e 100644
> >> --- a/fs/btrfs/fs.h
> >> +++ b/fs/btrfs/fs.h
> >> @@ -33,6 +33,7 @@
> >>  #include "async-thread.h"
> >>  #include "block-rsv.h"
> >>  #include "messages.h"
> >> +#include <linux/fserror.h>
> >>
> >>  struct inode;
> >>  struct super_block;
> >> @@ -1199,8 +1200,10 @@ static inline void btrfs_force_shutdown(struct btrfs_fs_info *fs_info)
> >>          * So here we only mark the fs error without flipping it RO.
> >>          */
> >>         WRITE_ONCE(fs_info->fs_error, -EIO);
> >> -       if (!test_and_set_bit(BTRFS_FS_STATE_EMERGENCY_SHUTDOWN, &fs_info->fs_state))
> >> +       if (!test_and_set_bit(BTRFS_FS_STATE_EMERGENCY_SHUTDOWN, &fs_info->fs_state)) {
> >>                 btrfs_crit(fs_info, "emergency shutdown");
> >> +               fserror_report_shutdown(fs_info->sb, GFP_KERNEL);
> >> +       }
> >>  }
> >>
> >>  /*
> >> --
> >> 2.53.0
> >>

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

end of thread, other threads:[~2026-02-27  9:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-16  0:28 [PATCH] btrfs: report filesystem shutdown via fserror Miquel Sabaté Solà
2026-02-18 11:54 ` Filipe Manana
2026-02-18 11:58   ` Miquel Sabaté Solà
     [not found]   ` <6995a98f.170a0220.4341d.d20aSMTPIN_ADDED_BROKEN@mx.google.com>
2026-02-27  9:29     ` Filipe Manana

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