From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F742C432BE for ; Wed, 1 Sep 2021 11:28:42 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 474C861026 for ; Wed, 1 Sep 2021 11:28:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 474C861026 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0B0ED8349C; Wed, 1 Sep 2021 13:28:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dmEzNtE+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D34BC834A8; Wed, 1 Sep 2021 13:28:36 +0200 (CEST) Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 176EF832A1 for ; Wed, 1 Sep 2021 13:28:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=matthias.bgg@gmail.com Received: by mail-wm1-x32e.google.com with SMTP id l7-20020a1c2507000000b002e6be5d86b3so1680565wml.3 for ; Wed, 01 Sep 2021 04:28:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=TtXx9rz0Q/JDuNUzfRRvVP/KTimU+ovvjm/WdA0+1MA=; b=dmEzNtE+K9Tj/eDjeeEo3fZhdih5zsZPkic6soaTrJYIOIWeCjZlMCSQfzrmU+Qthm ZT+dd9XXXynmpZair2RH/smgLmvNgTd18qfAANM36veHGSqIwcNZqEULO1ePHiYkRYgI KvoSJMXBcXQZ4lCMI7g4OGh+H3qF/N81/3LiQel6M/F+4s6SiVoJsbiCqtVFIuzaXQIy o4yLSNSjDMyB/XfOeYHHV3pJmmnY85qWzDATZkhV/7ae/TCegKkvZG+Mgl1M5AQvLLNt v64bwbQe+JSpvJDpMhBpsblyrv+NkOXRCLWAVagHsnTBOShKZzlMd3tCuqTH6pK/b1jK PLWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=TtXx9rz0Q/JDuNUzfRRvVP/KTimU+ovvjm/WdA0+1MA=; b=iNJhwVggq/h95wB/gPYX1fhK1VdB/+yuK4KGVZ+g/PrW+0/2AlrawKdpYofgZ+X3dz XSjPhLwAaIH2GXCGX0ZWGH8awxKjMaJIWEUUiLR6/sc4Wo8YdjCkh9dFnbtiYf2AJHcb dYjauAJLQ1QdZM3RXgNouzvRz+7MmLG2jfGwbBK7FN38X1Z6MOmNgwK57demdSJ/HzTI kDxoQ3RPwWqdDwPn96cs031CoZz96gOI4OKiA24KBrCNZi3TfRK0KhhTBcqS7N54v8mL NpfOwcNoNHBhNKMy5sefLLNTsd5BNaHwbza3BYWqFsqfV49UhnTPJDcQ4UgaMHg0IX3A RwqQ== X-Gm-Message-State: AOAM533xLRhp20ECjbeDdraC0ECgpBRH4BST35q36rVIAGF3k92n2V/T MVrMRV6FON266zYGxWjKyfQAzOws0KY= X-Google-Smtp-Source: ABdhPJyXmfdGYzqFY7DbyPU9ABkffVZVzDw7OHawnr2mEYUh+Y5gFn8Y7Lxi16AHUcpTzdZlYp+pFg== X-Received: by 2002:a1c:f414:: with SMTP id z20mr9369211wma.94.1630495711584; Wed, 01 Sep 2021 04:28:31 -0700 (PDT) Received: from ziggy.stardust ([37.223.140.66]) by smtp.gmail.com with ESMTPSA id n5sm5038999wmd.29.2021.09.01.04.28.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Sep 2021 04:28:30 -0700 (PDT) Subject: Re: [PATCH] btrfs: Use default subvolume as filesystem root To: Qu Wenruo , "Matwey V. Kornilov" , marek.behun@nic.cz, Tom Rini Cc: u-boot@lists.denx.de References: <20210801205216.22639-1-matwey.kornilov@gmail.com> <474eac73-5765-5bfe-acf0-03510f1ad04f@suse.com> From: Matthias Brugger Message-ID: <94e2a6c0-3aa6-9b4c-0459-07a7db14ee95@gmail.com> Date: Wed, 1 Sep 2021 13:28:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <474eac73-5765-5bfe-acf0-03510f1ad04f@suse.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hi Tom, On 02/08/2021 01:06, Qu Wenruo wrote: > > > On 2021/8/2 上午4:52, Matwey V. Kornilov wrote: >> BTRFS volume consists of a number of subvolumes which can be mounted separately >> from each other. The top-level subvolume always exists even if no subvolumes >> were created manually. A subvolume can be denoted as the default subvolume i.e. >> the subvolume which is mounted by default. >> >> The default "default subvolume" is the top-level one, but this is far from the >> common practices used in the wild. For instance, openSUSE provides an OS >> snapshot/rollback feature based on BTRFS. To achieve this, the actual OS root >> filesystem is located into a separate subvolume which is "default" but not >> "top-level". That means that the /boot/dtb/ directory is also located inside >> this default subvolume instead of top-level one. >> >> However, the existing btrfs u-boot driver always uses the top-level subvolume >> as the filesystem root. This behaviour 1) is inconsistent with >> >>      mount /dev/sda1 /target >> >> command, which mount the default subvolume 2) leads to the issues when >> /boot/dtb cannot be found properly (see the reference). > > I also noticed the problem in the past, but forgot to fix it.... > >> >> This patch uses the default subvolume as the filesystem root to overcome >> mentioned issues. >> >> Reference: https://bugzilla.suse.com/show_bug.cgi?id=1185656 >> Signed-off-by: Matwey V. Kornilov > > Reviewed-by: Qu Wenruo > I can see that this patch is marked in your patchwork queue as "Need Review / ACK". Qu is one of our core btrfs developer who reviewed the patch. Apart from that we have it running on openSUSE on top of v2021.07 for some time without any issues. Would it be possible to merge this for v2021.10 or do you see any blocker here? Regards, Matthias > Thanks, > Qu > >> --- >>   fs/btrfs/disk-io.c | 38 +++++++++++++++++++++++++++++++++++--- >>   1 file changed, 35 insertions(+), 3 deletions(-) >> >> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c >> index 349411c3cc..12f9579fcf 100644 >> --- a/fs/btrfs/disk-io.c >> +++ b/fs/btrfs/disk-io.c >> @@ -804,6 +804,30 @@ static int setup_root_or_create_block(struct >> btrfs_fs_info *fs_info, >>       return 0; >>   } >>   +static int get_default_subvolume(struct btrfs_fs_info *fs_info, >> +                 struct btrfs_key *key_ret) >> +{ >> +    struct btrfs_root *root = fs_info->tree_root; >> +    struct btrfs_dir_item *dir_item; >> +    struct btrfs_path path; >> +    int ret = 0; >> + >> +    btrfs_init_path(&path); >> + >> +    dir_item = btrfs_lookup_dir_item(NULL, root, &path, >> +                     BTRFS_ROOT_TREE_DIR_OBJECTID, >> +                     "default", 7, 0); >> +    if (IS_ERR(dir_item)) { >> +        ret = PTR_ERR(dir_item); >> +        goto out; >> +    } >> + >> +    btrfs_dir_item_key_to_cpu(path.nodes[0], dir_item, key_ret); >> +out: >> +    btrfs_release_path(&path); >> +    return ret; >> +} >> + >>   int btrfs_setup_all_roots(struct btrfs_fs_info *fs_info) >>   { >>       struct btrfs_super_block *sb = fs_info->super_copy; >> @@ -833,9 +857,17 @@ int btrfs_setup_all_roots(struct btrfs_fs_info *fs_info) >>         fs_info->last_trans_committed = generation; >>   -    key.objectid = BTRFS_FS_TREE_OBJECTID; >> -    key.type = BTRFS_ROOT_ITEM_KEY; >> -    key.offset = (u64)-1; >> +    ret = get_default_subvolume(fs_info, &key); >> +    if (ret) { >> +        /* >> +         * The default dir item isn't there. Linux kernel behaviour is >> +         * to silently use the top-level subvolume in this case. >> +         */ >> +        key.objectid = BTRFS_FS_TREE_OBJECTID; >> +        key.type = BTRFS_ROOT_ITEM_KEY; >> +        key.offset = (u64)-1; >> +    } >> + >>       fs_info->fs_root = btrfs_read_fs_root(fs_info, &key); >>         if (IS_ERR(fs_info->fs_root)) >> >