From patchwork Wed Mar 1 07:04:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia Zhu X-Patchwork-Id: 62772 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3479192wrd; Tue, 28 Feb 2023 23:05:31 -0800 (PST) X-Google-Smtp-Source: AK7set+p4EWA1E2ShYu3LA9HHGxdnynR8GRDseb9ai2z/Y04aLCPfwK/Lk/Xs8dUdBL+MhYzoQVv X-Received: by 2002:a05:6a20:841d:b0:cc:76ec:70dc with SMTP id c29-20020a056a20841d00b000cc76ec70dcmr8107342pzd.26.1677654331613; Tue, 28 Feb 2023 23:05:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677654331; cv=none; d=google.com; s=arc-20160816; b=C9wNN7E2tm9Es1KsdVchg6bpdUw3kECpHFQKoHkdG8VstTEFM7spiXa3wL//+UZuVQ iw3kBfOoprVCYlL5yn6Z/Ig+KuCwD2OTuzTPK6WDutEB5EcaKEttgvU7vYno9AsHOQhs tsm+C0XLAfrYSSwB4Iq4IDv0rUOCMvHGWyHoQ3JqsKXUYdPWI2p5UnfKZ2YUQj+3RZQq +o4kcKdtQoPftmSCg2fs1z5wQu0Qx3G8hBXQHDhW+mHuFzxBcLEWE8dIXydmdzFlSj99 jdC9A7xeC54/16ZKoTWX8wO4/4K+xfp61VxmblfnNpJLGZEAvMFZxfl4nCQfKFyXtgv3 Ophg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=/7MP/ejAI3sruq8iFOBWkRKcy/cVwRiQeeMY1HpYcV4=; b=czubbtG9hwN5yVXUyUvNbGk30jV4WRHYI+vYiDyz/das4ZLxI5uyDf1ISqiXlVwtBY WmTJ8U6S3JqG53RLbzTYloVG/nLD6AmF/2UB4GNeWEt0iAzUL/UDxvrYsEPs0E6tIOMq ltjf6leAbO6vX0mjM6yIKEpO8s6UTXFLZ/Sx91QKY6andzoZeJkNnAMp9P5LSdyQfB6a +5TAD4ZrisqbQyCVeXidA3JxNr4ocXtroNNc9snT5WzuRgVwZFPYzBPhK1W3VVcM6XBH C+t7mq7T+aYdkgp26LCM+KbTbhsLLwJKUvUsDbPigQdCyOuLJ+R9C+RAKCM8zx3ECGw0 mSUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="SJQ1r2P/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 82-20020a630055000000b00502e3fd615esi11762427pga.365.2023.02.28.23.05.17; Tue, 28 Feb 2023 23:05:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="SJQ1r2P/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229437AbjCAHFM (ORCPT + 99 others); Wed, 1 Mar 2023 02:05:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjCAHFK (ORCPT ); Wed, 1 Mar 2023 02:05:10 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4A813757B for ; Tue, 28 Feb 2023 23:04:45 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id bo22so823539pjb.4 for ; Tue, 28 Feb 2023 23:04:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1677654285; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/7MP/ejAI3sruq8iFOBWkRKcy/cVwRiQeeMY1HpYcV4=; b=SJQ1r2P/WYtOeX7MwiIFp3r8lUoIY4iCZ4Kh8f/qVe3/AEb21nYPjUH4Hv18AlxL6o nVT66J/R/ENNcfrWJal9Qz4w0cc+bslDOrJZdbPYNnVSnTgdbZTaJK9WHrZXQyp5esb5 5Yb5IfeL8mYmG7NirZaZnEAGLW3cOpU3SzqTbD2G1D2wcGOpHrMOGHukLzBrvcI2LfOK nyyyekRH4Vmof5eh3kwHztUg2NXk0tPlvHTc6LvetxHCdrpMGRsbCZszSca+yJa/vlTH m7gCcVmwIKNfkmga+j1x3I3yZL0OhUfNzvPCHP2joI67VeydZ+7WbSMdGDVFWXF8aWyA 5x9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677654285; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/7MP/ejAI3sruq8iFOBWkRKcy/cVwRiQeeMY1HpYcV4=; b=2WjPkeoYRpjVO9mQLQL29TspGcUDOLUkkkaYxGXTOIMnFZUaZdjdviVp8Rp2Qn1Q2p tSfcNveP3saaMQ6RnxUwmMYydiGcWAquFSKbZymKZv4JJux4AkPc8Qa+keY8FZwk0jhq Cu+6coL/sm0Y7U+HuCgojWpjTh/Lpq32xpBzbZ690+0oa03stEMw0m2AbNs1MeFhQbjn prPVWuZ7x9+JOiTQdxb7F08P+fmFxfBEotRzZ11GalyNfQMnoIQh616VnEY5G0AfK0fy RIwGV6m1v6vkc4NdzI5TKp8MvT8droFZugX4Lj0dWKJ2L4PMS9i0B3OhFBoZ07+Tk759 MQxQ== X-Gm-Message-State: AO0yUKV4NJ/mHTZEmaHhoxe5fPhdjGsOwJ8dd/dnYbdba2hcbxvEczX9 4uHJMpw+KC8lfvYIdbyEQc7SNL9UGzxIUtkM X-Received: by 2002:a05:6a20:4320:b0:cc:c557:9ce with SMTP id h32-20020a056a20432000b000ccc55709cemr7634102pzk.61.1677654285266; Tue, 28 Feb 2023 23:04:45 -0800 (PST) Received: from C02G705SMD6V.bytedance.net ([61.213.176.5]) by smtp.gmail.com with ESMTPSA id 4-20020a630104000000b004f27761a9e7sm6701485pgb.12.2023.02.28.23.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 23:04:44 -0800 (PST) From: Jia Zhu To: 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, Jia Zhu , Xin Yin Subject: [PATCH] erofs: support for mounting a single block device with multiple devices Date: Wed, 1 Mar 2023 15:04:17 +0800 Message-Id: <20230301070417.13084-1-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759148068706722652?= X-GMAIL-MSGID: =?utf-8?q?1759148068706722652?= In order to support mounting multi-layer container image as a block device, add single block device with multiple devices feature for EROFS. 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; 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);