Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A91FC64ED6 for ; Wed, 1 Mar 2023 07:45:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229751AbjCAHpI (ORCPT ); Wed, 1 Mar 2023 02:45:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229530AbjCAHpG (ORCPT ); Wed, 1 Mar 2023 02:45:06 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCD961EBE3 for ; Tue, 28 Feb 2023 23:44:43 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id oj5so8511028pjb.5 for ; Tue, 28 Feb 2023 23:44:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1677656683; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=jyS0C1HTG0tduNh0L7kbfvu/lzkj/LLnrbNqiht2ZzQ=; b=K9cAlseifIqk8MiACuzD0FGxhZR1aO2o9ZI8Os17fFA2mqSVr3dKiYJTt/IYZ7fl+u ph0RgCHRQsX5j+/PFetqA0UZzNvofS3/Dv1itfS9vNFho8Msr4EOmv5uvqKjH1sJFitg Ipq/ff3fRNu/rOEERARAji3c2kKrBUgRcEYBz7Buj0+tkckiZI7xOrVGkcLVAknLO40H vCCp4Z3R2BUOda+siG2WGrSE18a9VgvjpH5HfaXJ9eZppUpXcgb1JNeNbkPuxmKYXXhT 1EFNgd6CjRvv3aO7iChwxCFKN+F5lgSTXXEWRJ1vGeQLQJ9bSx29v/3TXgIrlKhQA3az sQrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677656683; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=jyS0C1HTG0tduNh0L7kbfvu/lzkj/LLnrbNqiht2ZzQ=; b=6px8W4WAJvPXB29ec1C34ptoSKfBM5frsN+urycjIOODaLtYc79J+4ZeSdz8burlc3 g0wsPqGcPVX8vORIR8zndy7nO6o/QpNnXrKXmcxWohyEsR/xZ6SuRqhQ9qllMxM2TvtK 4OANLEB6vObqv/A22ctSX+0rkcxp5Mop/y61s3oKp0N/5BU6/45xqpIknX2E8edM+JCd kfvVQRfTbgHxVdcAwpwp8AVqUH5nJY5PdhOH9lWJQfSMUkF9oTG+z0V1iH/y4YumH3dD HnlKu4AG6QKmP1n937HHdqI+bCB1KaID9EGJQvipmcuHiE5GYDKh4ANeDNy+BEAFcGnz QeHQ== X-Gm-Message-State: AO0yUKXVzkAfROav66ED9zwIFg3WBqVQZtlNjXKSKHXkehg5S/BYKvHQ Ta7N2xlgFcfncdDejCsIL0jhGA== X-Google-Smtp-Source: AK7set/RvUa8pCt4yFC8gzSIzxh9lcNDOWsMuNnBPKvNbcp5EZJSGPNF8q5pVqT9V7lAOUXoxsmxcQ== X-Received: by 2002:a17:903:2447:b0:19c:c9da:a62e with SMTP id l7-20020a170903244700b0019cc9daa62emr6447929pls.54.1677656683026; Tue, 28 Feb 2023 23:44:43 -0800 (PST) Received: from [10.3.144.50] ([61.213.176.8]) by smtp.gmail.com with ESMTPSA id p12-20020a170902eacc00b0019a6cce2060sm7663725pld.57.2023.02.28.23.44.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Feb 2023 23:44:42 -0800 (PST) Message-ID: <1c8b966e-8208-e9c9-c75b-9ebf2a138059@bytedance.com> Date: Wed, 1 Mar 2023 15:44:37 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: Re: Re: [PATCH] erofs: support for mounting a single block device with multiple devices To: Gao Xiang , xiang@kernel.org, chao@kernel.org, gerry@linux.alibaba.com, linux-erofs@lists.ozlabs.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, jefflexu@linux.alibaba.com, huyue2@coolpad.com, Xin Yin References: <20230301070417.13084-1-zhujia.zj@bytedance.com> From: Jia Zhu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2023/3/1 15:08, Gao Xiang 写道: > Hi Jia, > > On 2023/3/1 15:04, Jia Zhu wrote: >> In order to support mounting multi-layer container image as a block >> device, add single block device with multiple devices feature for EROFS. > > In order to support mounting multi-blob container image as a single > flattened block device, add flattened block device feature for EROFS. > Thanks, I would revise it. >> >> In this mode, all meta/data contents will be mapped into one block >> address. >> User could directly mount the block device by EROFS. >> >> Signed-off-by: Jia Zhu >> Reviewed-by: Xin Yin >> --- >>   fs/erofs/data.c  | 8 ++++++-- >>   fs/erofs/super.c | 5 +++++ >>   2 files changed, 11 insertions(+), 2 deletions(-) >> >> diff --git a/fs/erofs/data.c b/fs/erofs/data.c >> index e16545849ea7..870b1f7fe1d4 100644 >> --- a/fs/erofs/data.c >> +++ b/fs/erofs/data.c >> @@ -195,9 +195,9 @@ int erofs_map_dev(struct super_block *sb, struct >> erofs_map_dev *map) >>   { >>       struct erofs_dev_context *devs = EROFS_SB(sb)->devs; >>       struct erofs_device_info *dif; >> +    bool flatdev = !!sb->s_bdev; > > I'd like to land it in sbi and set it in advance? > I'll revise that in next version. > Also, did you test this patch? I've tested the patch using the following steps mentioned by https://github.com/dragonflyoss/image-service/pull/1111 1. Compose a (nbd)block device from an EROFS image. 2. mount -t erofs /dev/nbdx /mnt/ 3. compare the md5sum between source dir and /mnt dir. > > Thanks, > Gao Xiang > > >>       int id; >> -    /* primary device by default */ >>       map->m_bdev = sb->s_bdev; >>       map->m_daxdev = EROFS_SB(sb)->dax_dev; >>       map->m_dax_part_off = EROFS_SB(sb)->dax_part_off; >> @@ -210,12 +210,16 @@ int erofs_map_dev(struct super_block *sb, struct >> erofs_map_dev *map) >>               up_read(&devs->rwsem); >>               return -ENODEV; >>           } >> +        if (flatdev) { >> +            map->m_pa += blknr_to_addr(dif->mapped_blkaddr); >> +            map->m_deviceid = 0; >> +        } >>           map->m_bdev = dif->bdev; >>           map->m_daxdev = dif->dax_dev; >>           map->m_dax_part_off = dif->dax_part_off; >>           map->m_fscache = dif->fscache; >>           up_read(&devs->rwsem); >> -    } else if (devs->extra_devices) { >> +    } else if (devs->extra_devices && !flatdev) { >>           down_read(&devs->rwsem); >>           idr_for_each_entry(&devs->tree, dif, id) { >>               erofs_off_t startoff, length; >> diff --git a/fs/erofs/super.c b/fs/erofs/super.c >> index 19b1ae79cec4..4f9725b0950c 100644 >> --- a/fs/erofs/super.c >> +++ b/fs/erofs/super.c >> @@ -226,6 +226,7 @@ static int erofs_init_device(struct erofs_buf >> *buf, struct super_block *sb, >>       struct erofs_fscache *fscache; >>       struct erofs_deviceslot *dis; >>       struct block_device *bdev; >> +    bool flatdev = !!sb->s_bdev; >>       void *ptr; >>       ptr = erofs_read_metabuf(buf, sb, erofs_blknr(*pos), EROFS_KMAP); >> @@ -248,6 +249,10 @@ static int erofs_init_device(struct erofs_buf >> *buf, struct super_block *sb, >>           if (IS_ERR(fscache)) >>               return PTR_ERR(fscache); >>           dif->fscache = fscache; >> +    } else if (flatdev) { >> +        dif->bdev = sb->s_bdev; >> +        dif->dax_dev = EROFS_SB(sb)->dax_dev; >> +        dif->dax_part_off = sbi->dax_part_off; >>       } else { >>           bdev = blkdev_get_by_path(dif->path, FMODE_READ | FMODE_EXCL, >>                         sb->s_type);