Btrfs: allow empty subvol= again
authorOmar Sandoval <osandov@fb.com>
Tue, 22 May 2018 00:07:19 +0000 (17:07 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 25 Jun 2018 23:51:22 +0000 (07:51 +0800)
commit 37becec95ac31b209eb1c8e096f1093a7db00f32 upstream.

I got a report that after upgrading to 4.16, someone's filesystems
weren't mounting:

[   23.845852] BTRFS info (device loop0): unrecognized mount option 'subvol='

Before 4.16, this mounted the default subvolume. It turns out that this
empty "subvol=" is actually an application bug, but it was causing the
application to fail, so it's an ABI break if you squint.

The generic parsing code we use for mount options (match_token())
doesn't match an empty string as "%s". Previously, setup_root_args()
removed the "subvol=" string, but the mount path was cleaned up to not
need that. Add a dummy Opt_subvol_empty to fix this.

The simple workaround is to use / or . for the value of 'subvol=' .

Fixes: 312c89fbca06 ("btrfs: cleanup btrfs_mount() using btrfs_mount_root()")
CC: stable@vger.kernel.org # 4.16+
Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/super.c

index 0628092b0b1bde633f9e2c0f6c339feda75013ec..f82152a0cb3814518cf7dd514d20df056d229ab4 100644 (file)
@@ -323,6 +323,7 @@ enum {
        Opt_ssd, Opt_nossd,
        Opt_ssd_spread, Opt_nossd_spread,
        Opt_subvol,
+       Opt_subvol_empty,
        Opt_subvolid,
        Opt_thread_pool,
        Opt_treelog, Opt_notreelog,
@@ -388,6 +389,7 @@ static const match_table_t tokens = {
        {Opt_ssd_spread, "ssd_spread"},
        {Opt_nossd_spread, "nossd_spread"},
        {Opt_subvol, "subvol=%s"},
+       {Opt_subvol_empty, "subvol="},
        {Opt_subvolid, "subvolid=%s"},
        {Opt_thread_pool, "thread_pool=%u"},
        {Opt_treelog, "treelog"},
@@ -461,6 +463,7 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
                        btrfs_set_opt(info->mount_opt, DEGRADED);
                        break;
                case Opt_subvol:
+               case Opt_subvol_empty:
                case Opt_subvolid:
                case Opt_subvolrootid:
                case Opt_device: