Skip to content

Commit a752653

Browse files
mssolakdave
authored andcommitted
btrfs: don't commit the super block when unmounting a shutdown filesystem
When unmounting a filesystem we will try, among many other things, to commit the super block. On a filesystem that was shutdown, though, this will always fail with -EROFS as writes are forbidden on this context; and an error will be reported. Don't commit the super block on this situation, which should be fine as the filesystem is frozen before shutdown and, therefore, it should be at a consistent state. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com> Reviewed-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 3f50141 commit a752653

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

fs/btrfs/disk-io.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4397,9 +4397,17 @@ void __cold close_ctree(struct btrfs_fs_info *fs_info)
43974397
*/
43984398
btrfs_flush_workqueue(fs_info->delayed_workers);
43994399

4400-
ret = btrfs_commit_super(fs_info);
4401-
if (ret)
4402-
btrfs_err(fs_info, "commit super ret %d", ret);
4400+
/*
4401+
* If the filesystem is shutdown, then an attempt to commit the
4402+
* super block (or any write) will just fail. Since we freeze
4403+
* the filesystem before shutting it down, the filesystem is in
4404+
* a consistent state and we don't need to commit super blocks.
4405+
*/
4406+
if (!btrfs_is_shutdown(fs_info)) {
4407+
ret = btrfs_commit_super(fs_info);
4408+
if (ret)
4409+
btrfs_err(fs_info, "commit super block returned %d", ret);
4410+
}
44034411
}
44044412

44054413
kthread_stop(fs_info->transaction_kthread);

0 commit comments

Comments
 (0)