Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp208038pxf; Wed, 10 Mar 2021 04:37:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRFCCxgiEJAQAJQiynFiSTeKOcd1wR6rN3o+cm/Y5jEr61aeLaWEqxUNFBGnTzSddiYRXw X-Received: by 2002:a17:907:2661:: with SMTP id ci1mr3357180ejc.403.1615379840161; Wed, 10 Mar 2021 04:37:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615379840; cv=none; d=google.com; s=arc-20160816; b=xLZtVVw51xZpRmdhEfWjLrAHEcIn4xa15OK79VRk/GflsZTRFlM8xX9Ndb5unyWl3i zWulf/VAmIVXfSSVWOTtuUqr8WhfVm9hEZVjAxKN05wIllFlmwVDJjsKe+Xd8q85dcXt UfSFj0AHrnpeRUCK90DWPmVPkluyRL/MKPRg0QKkHlw486ip10X+H9ImwoOBM4FYVHLr 2R8og92gbUsymjJrbzfeQ58l0BLvfLkLcprLXILXcV7Eur1Den34HIllm0b1OMDkAxlY DMFTcNYLeqpnOCOdMIbygfl/V4EJbQYpG3wERN+KQNFNFlfYdTQidnxZIm5/nKQ41pqK jj9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gI+fVKwWNdRCMXLSxBhBb6g0npcADtH3Xd9db2ybLVU=; b=LjdWEyA2M3zndq+6+Tvi/kD8dg71k8cVoCsOVXK7pJYhrnvWfKjuVFSsvfa5i40CHI PqBN5Wnr0L785lc7uKLIFAUwkE9rTTE8Uruw8qo4LJw/387CSvZb7A6Jnq03gIMzust4 PPpHCuQRA+E2KNVvjtl1chQBWKRxuJ0NFYEOGGosoxbLFSgk0sfEwngGlCbZFO+Yw9LY OcFoDniR90zeYnW16lRPwtsVzasrqmYlv44Kl2QrNdiSBdmzU5YdLzwBAz0rz60uwV2f wJJM2s5PAa/VMhJMfoN+e2WvIwzI02W3T5Bv17zVRm7AZFcTUBZiROs8Tefq8ZQSDj9I V3mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=W6bUKRZI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si11249373ejv.34.2021.03.10.04.36.57; Wed, 10 Mar 2021 04:37:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=W6bUKRZI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231666AbhCJMfw (ORCPT + 99 others); Wed, 10 Mar 2021 07:35:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbhCJMf0 (ORCPT ); Wed, 10 Mar 2021 07:35:26 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35A01C061760; Wed, 10 Mar 2021 04:35:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=gI+fVKwWNdRCMXLSxBhBb6g0npcADtH3Xd9db2ybLVU=; b=W6bUKRZIT5KWYpA2Tcf98R55Li rdV7pccBhtX/KUEPjKSP+gJVp7A5ngj21LOhWjri3WGIAUHm7+fZ9BGTPyZlpTc35Tfb2GMPa+FJY Wr8nhkqe5owRjRQ3ujRu4q4NLgUK+cgUzXcfpSU8xlopjR8uUBFmf8owkXYSs9uLN0KF13GAFWiGX VGEtWIl82UpTCEv9b9eBE0fDpqyQ6ENW7K3H60Lhix9ElTsGXgzNyLUJNHQkfXkAMn07xHAogAGpo jOdS6/FjHx7+vlm1v+MG/4A5E2AX4GPhfMWveJIYb4gEoNSv4npdzLzRTsPWA6eKYksmRKDP4nEmh NKS17l/A==; Received: from hch by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lJy3E-003O6D-2z; Wed, 10 Mar 2021 12:34:59 +0000 Date: Wed, 10 Mar 2021 12:34:56 +0000 From: Christoph Hellwig To: Sergei Shtepa Cc: Christoph Hellwig , "snitzer@redhat.com" , "agk@redhat.com" , "hare@suse.de" , "song@kernel.org" , "axboe@kernel.dk" , "dm-devel@redhat.com" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-raid@vger.kernel.org" , "linux-api@vger.kernel.org" , Pavel Tide Subject: Re: [PATCH v6 4/4] dm: add DM_INTERPOSED_FLAG Message-ID: <20210310123456.GA758100@infradead.org> References: <1614774618-22410-1-git-send-email-sergei.shtepa@veeam.com> <1614774618-22410-5-git-send-email-sergei.shtepa@veeam.com> <20210309173555.GC201344@infradead.org> <20210310052812.GB26929@veeam.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210310052812.GB26929@veeam.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 10, 2021 at 08:28:12AM +0300, Sergei Shtepa wrote: > > So instead of doing this shoudn't the interposer just always submit to the > > whole device? But if we keep it, the logic in this funtion should go > > into a block layer helper, passing a block device instead of the > > device-mapper allows to create devices of any size using only part of > the underlying device. Therefore, it is not possible to apply the > interposer to the whole block device. > Perhaps it makes sense to put the blk_partition_unremap() function in the > block layer? I'm not sure that's a good thing. I suspect the answer is to not remap bios that are going to be handled by the interposer. In fact much of submit_bio_checks as-is is a bad idea for interposed devices. I think what we need to do instead is to pass an explicit bdev to submit_bio_checks and use that everywhere, including in the subfunctions. With that we might also be able to remove the separate interpose hook and thus struct bdev_interposer entirely as now ->submit_bio of the interposer could do all the work: static noinline blk_qc_t submit_bio_interposed(struct bio *bio) { struct block_device *orig_bdev = bio->bi_bdev, *interposer; struct bio_list bio_list[2] = { }; blk_qc_t ret = BLK_QC_T_NONE; if (current->bio_list) { bio_list_add(¤t->bio_list[0], bio); return BLK_QC_T_NONE; } if (unlikely(bio_queue_enter(bio))) return BLK_QC_T_NONE; interposer = orig_bdev->bd_interposer; if (unlikely(!interposer)) { /* interposer was removed */ bio_list_add(¤t->bio_list[0], bio); goto queue_exit; } if (!submit_bio_checks(bio, interposer)) goto queue_exit; bio_set_flag(bio, BIO_INTERPOSED); current->bio_list = bio_list; ret = interposer->bd_disk->fops->submit_bio(bio); current->bio_list = NULL; queue_exit: blk_queue_exit(bdev->bd_disk->queue); /* Resubmit remaining bios */ while ((bio = bio_list_pop(&bio_list[0]))) ret = submit_bio_noacct(bio); return ret; } blk_qc_t submit_bio_noacct(struct bio *bio) { if (bio->bi_bdev->bd_interposer && !bio_flagged(bio, BIO_INTERPOSED) return submit_bio_interposed(bio); ... } Note that both with this and your original code the interposer must never resubmit I/O to itself. Is that actually the case for DM? I'm trying to think of a good debug check for that, but right now I can't think of something that doesn't cause any overhead for n