Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3050438rwb; Mon, 5 Sep 2022 05:51:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR57re+zprA7V8CQKon9At6UQbyO5WwNJzOH3YZetBmyCp4S+Hh8rEj9SIywMxpTOnubz3zs X-Received: by 2002:a17:902:ec8a:b0:172:f018:4b46 with SMTP id x10-20020a170902ec8a00b00172f0184b46mr48415141plg.12.1662382317905; Mon, 05 Sep 2022 05:51:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662382317; cv=none; d=google.com; s=arc-20160816; b=ssNt/31GEs6pQFgTaq875T7dnvNucol/I8pNwJxSvUS0WbZC4+/jzYrMaCULKGYT0p c7T2WDpEDJBlrT7rVL6ia5yrQVeuk8djbLruPuz9RVv25hwGdDgczcQZiY4Vy/pt8Jxc 4wvCLbQYqI0awoV72Qng5Asl2Xb8dBwaMWQXuT9Dxa28UAIl+9g5TieeDeNbGlOiKBlz llgzD0ICtIT20GIeUDuD6390vnNaalmN+4FndcSVkiTNxa6S6d+1kqBbpR6qTJcVkTeI OnGofNA/qCFca76zX8FLySBzWiAikOcjQOB9DGQqhirImbpgTTDXp2+PqkuQ8NzF5Uh4 UY4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :in-reply-to:from:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature:dkim-filter; bh=PF4oHLzqZh/YHdKNpdK5/2LeWbEyKKWZ2jrg1+aNG8s=; b=KrF6Yw//A9/5lSdDY+5nwAoorJnY5/NOBnB6Nrv/pL/E5skEJgX3BWAdnuEvSqORav 1B7skvlJgCqxQSiBhCn+8MhUdGb+aCr/Qnc9EpaTuqcgIN7nVUXhfpqvnMinj4MQWZXn KLg0ckYh91xRX17qZB0GvVBhD0I4mOBwxjkjwwDfrOkhUrBDP+TRrAIySAc8cpMFOuO3 Jq99XvrQ7eHXqlh9GOXIwz6oR2pNoif05zBRIa7EG8qtRWjOCvdq8LySNNBMNynIgAZK Q8HLHLV1LPfIX4CWTNQJgjQqpDKOMnY+09JVD+Ri3kV4Ir77S33Xv5COHxVb6qAPVSPx w8lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=E2ZwD1O0; 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=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a71-20020a63904a000000b0042bcf82ec48si8391994pge.300.2022.09.05.05.51.46; Mon, 05 Sep 2022 05:51:57 -0700 (PDT) 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=@samsung.com header.s=mail20170921 header.b=E2ZwD1O0; 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=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237772AbiIEMtf (ORCPT + 99 others); Mon, 5 Sep 2022 08:49:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237006AbiIEMtW (ORCPT ); Mon, 5 Sep 2022 08:49:22 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02221FD4 for ; Mon, 5 Sep 2022 05:49:15 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220905124903euoutp0189b0e6f3930ab2f7517a07a5ae439b14~R98CCS5s-2548725487euoutp01c for ; Mon, 5 Sep 2022 12:49:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220905124903euoutp0189b0e6f3930ab2f7517a07a5ae439b14~R98CCS5s-2548725487euoutp01c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662382143; bh=PF4oHLzqZh/YHdKNpdK5/2LeWbEyKKWZ2jrg1+aNG8s=; h=Date:Subject:To:CC:From:In-Reply-To:References:From; b=E2ZwD1O0fOWh69ZAATRgk9L4xaHixrML9qlbRBYLAqA7BFQKa8K9UnArYN0pZKHdy EaIY45Awjpm4lUUve+q8NBnxe2NvTs4s/St6CN4O6LuQFUD8Bdg23Eq+GUT5knfKHH TFX3bvRL/ojRyPq3YZp2O7nQbMxEfJYwpZuJlGhg= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220905124903eucas1p28ce03c18a615c26f6e946b15a149b325~R98BqlOKd0854408544eucas1p2x; Mon, 5 Sep 2022 12:49:03 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 7E.D4.29727.F30F5136; Mon, 5 Sep 2022 13:49:03 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220905124902eucas1p2ac0553ea1fe86340b5dbae2b66c22214~R98BE7RpE2754227542eucas1p2E; Mon, 5 Sep 2022 12:49:02 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220905124902eusmtrp2cc0a2e78a6eab472d306af045c0da798~R98BDlBjY0389703897eusmtrp2D; Mon, 5 Sep 2022 12:49:02 +0000 (GMT) X-AuditID: cbfec7f2-205ff7000001741f-a7-6315f03f882d Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id C0.47.07473.E30F5136; Mon, 5 Sep 2022 13:49:02 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220905124902eusmtip1f3535df1f02cd6b0b6a8939f6c046456~R98A2TTJK2174421744eusmtip1l; Mon, 5 Sep 2022 12:49:02 +0000 (GMT) Received: from [106.110.32.100] (106.110.32.100) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 5 Sep 2022 13:49:01 +0100 Message-ID: <1ed819b5-924d-6a87-1978-1457061e2647@samsung.com> Date: Mon, 5 Sep 2022 14:48:59 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v12 13/13] dm: add power-of-2 target for zoned devices with non power-of-2 zone sizes Content-Language: en-US To: Mike Snitzer CC: , , , , , Damien Le Moal , , , Johannes Thumshirn , , , , , , , From: Pankaj Raghav In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [106.110.32.100] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrDKsWRmVeSWpSXmKPExsWy7djP87r2H0STDc7N47RYf+oYs8Xqu/1s FtM+/GS2+H32PLNFa/s3Jou972azWqxcfZTJ4sn6WcwWf7vuAcVuaVtc3jWHzWL+sqfsFhPa vjJbrLn5lMXixC1pi7aNXxkdBDwuX/H22DnrLrvH5bOlHptWdbJ5bF5S77H7ZgObx87W+6we 7/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ck GmoxFxUnAgBNDRd8pwMAAA== X-CMS-MailID: 20220905124902eucas1p2ac0553ea1fe86340b5dbae2b66c22214 X-Msg-Generator: CA X-RootMTR: 20220823121915eucas1p10296d6a2ab00de5e73791a7d6b8e39de X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220823121915eucas1p10296d6a2ab00de5e73791a7d6b8e39de References: <20220823121859.163903-1-p.raghav@samsung.com> <20220823121859.163903-14-p.raghav@samsung.com> X-Spam-Status: No, score=-8.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Hi Mike, >> Note that the target does not support partial mapping of the underlying >> device. >> >> Signed-off-by: Pankaj Raghav >> Suggested-by: Johannes Thumshirn >> Suggested-by: Damien Le Moal >> Suggested-by: Hannes Reinecke > > > This target needs more review from those who Suggested-by it. > > And the header and docs needs to address: > > 1) why is a partial mapping of the underlying device disallowed? While it is technically possible, I don't see any use-case to do so for this target. I can mention it in the documentation as well. > 2) why is it assumed all IO is read-only? (talk to me and others like > we don't know the inherent limitations of this class of zoned hw) > TL;DR: no, we don't assume all IO to be read-only. All operations all allowed until the zone capacity, and only reads are permitted in the emulated gap area. A bit of context about Zoned HW(especially ZNS SSD): Zone: A contiguous range of logical block addresses managed as a single unit. Zoned Block Device: A block device that consists of multiple zones. Zone size: Size of a zone Zone capacity: Usable logical blocks in a zone According to ZNS spec, the LBAs from zone capacity to zone size behave like deallocated blocks when read and are not allowed to be written. Until now, zone capacity can be any value, but zone size needed to be a power-of-2 to work in Linux (More information about this is also in my cover letter). This patch series aims to allow non-po2 zone size devices with zone capacity == zone size to work in Linux. A non-po2 zone size device might not work correctly in filesystems that support zoned devices such as btrfs and f2fs as they assume po2 zone sizes. Therefore, this target is created to enable these filesystems to work with non-po2 zone sizes until native support is added. This target's zone capacity will be the same as the underlying device, but the target's zone size will be the nearest po2 value of its zone capacity. Furthermore, the area between the zone capacity and zone size of the target (emulated gap area) will resemble the spec behavior: behave like the deallocated blocks when read (we fill zeroes in the bio) and are not allowed to write. Does that clarify your question? > On a code level: > 1) are you certain you're properly failing all writes? > - are writes allowed to the "zone capacity area" but _not_ > allowed to the "emulated zone area"? (if yes, _please document_). I have already documented in Documentation: A simple remap is performed for all the BIOs that do not cross the emulation gap area, i.e., the area between the zone capacity and size. If a BIO lies in the emulation gap area, the following operations are performed: Read: - If the BIO lies entirely in the emulation gap area, then zero out the BIO and complete it. - If the BIO spans the emulation gap area, split the BIO across the zone capacity boundary and remap only the BIO within the zone capacity boundary. The other part of the split BIO will be zeroed out. Other operations: - Return an error Maybe it is not clear enough?? Let me know. > 2) yes, you absolutely need to implement the .status target_type hook > (for both STATUS and TABLE). I already queued this change locally. I will send it as a part of the next rev. > 3) really not loving the nested return (of DM_MAPIO_SUBMITTED or > DM_MAPIO_REMAPPED) from methods called from dm_po2z_map(). Would > prefer to not have to do a depth-first search to see where and when > dm_po2z_map() returns a DM_MAPIO_XXX unless there is a solid > justification for it. To me it just obfuscates the DM interface a > bit too much. > Got it. Do you prefer having the return statements in the dm_po2z_map itself instead of returning a helper function, which in return returns the status code? What about something like this: static inline void dm_po2z_read_zeroes(struct bio *bio) { zero_fill_bio(bio); bio_endio(bio); } static int dm_po2z_map(struct dm_target *ti, struct bio *bio) { struct dm_po2z_target *dmh = ti->private; int split_io_pos; bio_set_dev(bio, dmh->dev->bdev); if (op_is_zone_mgmt(bio_op(bio))) goto remap_sector; if (!bio_sectors(bio)) return DM_MAPIO_REMAPPED; if (!dm_po2z_bio_in_emulated_zone_area(dmh, bio, &split_io_pos)) goto remap_sector; /* * Read operation on the emulated zone area (between zone capacity * and zone size) will fill the bio with zeroes.Any other operation * in the emulated area should return an error. */ if (bio_op(bio) == REQ_OP_READ) { /* * If the bio is across emulated zone boundary, split * the bio at * the boundary. */ if (split_io_pos > 0) { dm_accept_partial_bio(bio, split_io_pos); goto remap_sector; } dm_po2z_read_zeroes(bio); return DM_MAPIO_SUBMITTED; } return DM_MAPIO_KILL; remap_sector: bio->bi_iter.bi_sector = target_to_device_sect(dmh, bio->bi_iter.bi_sector); return DM_MAPIO_REMAPPED; } > Otherwise, pretty clean code and nothing weird going on. > > I look forward to seeing your next (final?) revision of this patchset. > > Thanks, > Mike >