Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Miquel Sabaté Solà and committed by
David Sterba
a7526533 3f501412

+11 -3
+11 -3
fs/btrfs/disk-io.c
··· 4397 4397 */ 4398 4398 btrfs_flush_workqueue(fs_info->delayed_workers); 4399 4399 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 + } 4403 4411 } 4404 4412 4405 4413 kthread_stop(fs_info->transaction_kthread);