dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* Re: [dm-devel] [PATCH 0/2] block layer filter and block device snapshot module
       [not found]             ` <20201022151418.GR9832@magnolia>
@ 2020-10-22 17:54               ` Mike Snitzer
  2020-10-23  9:13                 ` hch
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Snitzer @ 2020-10-22 17:54 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: jack, gustavo, linux-mm, device-mapper development, pavel, steve,
	osandov, Alasdair G Kergon, bvanassche, hch, len.brown, linux-pm,
	ming.lei, linux-block, linux-fsdevel, Sergei Shtepa, koct9i,
	axboe, Damien Le Moal, Johannes Thumshirn, rjw, linux-kernel,
	linux-xfs, tj, akpm, viro

On Thu, Oct 22, 2020 at 11:14 AM Darrick J. Wong
<darrick.wong@oracle.com> wrote:
>
> On Thu, Oct 22, 2020 at 04:52:13PM +0300, Sergei Shtepa wrote:
> > The 10/22/2020 13:28, Damien Le Moal wrote:
> > > On 2020/10/22 18:43, Sergei Shtepa wrote:
> > > >
> > > > Maybe, but the problem is that I can't imagine how to implement
> > > > dm-intercept yet.
> > > > How to use dm to implement interception without changing the stack
> > > > of block devices. We'll have to make a hook somewhere, isn`t it?
> > >
> > > Once your dm-intercept target driver is inserted with "dmsetup" or any user land
> > > tool you implement using libdevicemapper, the "hooks" will naturally be in place
> > > since the dm infrastructure already does that: all submitted BIOs will be passed
> > > to dm-intercept through the "map" operation defined in the target_type
> > > descriptor. It is then that driver job to execute the BIOs as it sees fit.
> > >
> > > Look at simple device mappers like dm-linear or dm-flakey for hints of how
> > > things work (driver/md/dm-linear.c). More complex dm drivers like dm-crypt,
> > > dm-writecache or dm-thin can give you hints about more features of device mapper.
> > > Functions such as __map_bio() in drivers/md/dm.c are the core of DM and show
> > > what happens to BIOs depending on the the return value of the map operation.
> > > dm_submit_bio() and __split_and_process_bio() is the entry points for BIO
> > > processing in DM.
> > >
> >
> > Is there something I don't understand? Please correct me.
> >
> > Let me remind that by the condition of the problem, we can't change
> > the configuration of the block device stack.
> >
> > Let's imagine this configuration: /root mount point on ext filesystem
> > on /dev/sda1.
> > +---------------+
> > |               |
> > |  /root        |
> > |               |
> > +---------------+
> > |               |
> > | EXT FS        |
> > |               |
> > +---------------+
> > |               |
> > | block layer   |
> > |               |
> > | sda queue     |
> > |               |
> > +---------------+
> > |               |
> > | scsi driver   |
> > |               |
> > +---------------+
> >
> > We need to add change block tracking (CBT) and snapshot functionality for
> > incremental backup.
> >
> > With the DM we need to change the block device stack. Add device /dev/sda1
> > to LVM Volume group, create logical volume, change /etc/fstab and reboot.
> >
> > The new scheme will look like this:
> > +---------------+
> > |               |
> > |  /root        |
> > |               |
> > +---------------+
> > |               |
> > | EXT FS        |
> > |               |
> > +---------------+
> > |               |
> > | LV-root       |
> > |               |
> > +------------------+
> > |                  |
> > | dm-cbt & dm-snap |
> > |                  |
> > +------------------+
> > |               |
> > | sda queue     |
> > |               |
> > +---------------+
> > |               |
> > | scsi driver   |
> > |               |
> > +---------------+
> >
> > But I cannot change block device stack. And so I propose a scheme with
> > interception.
> > +---------------+
> > |               |
> > |  /root        |
> > |               |
> > +---------------+
> > |               |
> > | EXT FS        |
> > |               |
> > +---------------+   +-----------------+
> > |  |            |   |                 |
> > |  | blk-filter |-> | cbt & snapshot  |
> > |  |            |<- |                 |
> > |  +------------+   +-----------------+
> > |               |
> > | sda blk queue |
> > |               |
> > +---------------+
> > |               |
> > | scsi driver   |
> > |               |
> > +---------------+
> >
> > Perhaps I can make "cbt & snapshot" inside the DM, but without interception
> > in any case, it will not work. Isn't that right?
>
> Stupid question: Why don't you change the block layer to make it
> possible to insert device mapper devices after the blockdev has been set
> up?

Not a stupid question.  Definitely something that us DM developers
have wanted to do for a while.  Devil is in the details but it is the
right way forward.

Otherwise, this intercept is really just a DM-lite remapping layer
without any of DM's well established capabilities.  Encouragingly, all
of the replies have effectively echoed this point.  (amusingly, seems
every mailing list under the sun is on the cc except dm-devel... now
rectified)

Alasdair has some concrete ideas on this line of work; I'm trying to
encourage him to reply ;)

Mike

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dm-devel] [PATCH 0/2] block layer filter and block device snapshot module
       [not found] <1603271049-20681-1-git-send-email-sergei.shtepa@veeam.com>
       [not found] ` <71926887-5707-04a5-78a2-ffa2ee32bd68@suse.de>
@ 2020-10-22 18:35 ` Mike Snitzer
  1 sibling, 0 replies; 6+ messages in thread
From: Mike Snitzer @ 2020-10-22 18:35 UTC (permalink / raw)
  To: Sergei Shtepa
  Cc: Jan Kara, gustavo, linux-mm, device-mapper development,
	Pavel Machek, steve, osandov, Bart Van Assche, Darrick J. Wong,
	Christoph Hellwig, len.brown, linux-pm, Ming Lei, linux-block,
	linux-fsdevel, Alexander Viro, koct9i, Jens Axboe,
	Damien Le Moal, johannes.thumshirn, rjw, linux-kernel, linux-xfs,
	Tejun Heo, Andrew Morton

On Wed, Oct 21, 2020 at 5:04 AM Sergei Shtepa <sergei.shtepa@veeam.com> wrote:
>
> Hello everyone! Requesting for your comments and suggestions.
>
> # blk-filter
>
> Block layer filter allows to intercept BIO requests to a block device.
>
> Interception is performed at the very beginning of the BIO request
> processing, and therefore does not affect the operation of the request
> processing queue. This also makes it possible to intercept requests from
> a specific block device, rather than from the entire disk.
>
> The logic of the submit_bio function has been changed - since the
> function execution results are not processed anywhere (except for swap
> and direct-io) the function won't return a value anymore.

Your desire to switch to a void return comes exactly when I've noticed
we need it.

->submit_bio's blk_qc_t return is the cookie assigned by blk-mq.  Up
to this point we haven't actually used it for bio-based devices but it
seems clear we'll soon need for bio-based IO polling support.

Just today, I've been auditing drivers/md/dm.c with an eye toward
properly handling the blk_qc_t return (or lack thereof) from various
DM methods.

It could easily be that __submit_bio_noacct and __submit_bio_noacct_mq
will be updated to do something meaningful with the returned cookie
(or that DM will) to facilitate proper IO polling.

Mike

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dm-devel] [PATCH 0/2] block layer filter and block device snapshot module
  2020-10-22 17:54               ` [dm-devel] [PATCH 0/2] block layer filter and block device snapshot module Mike Snitzer
@ 2020-10-23  9:13                 ` hch
  2020-10-23 10:31                   ` Hannes Reinecke
  0 siblings, 1 reply; 6+ messages in thread
From: hch @ 2020-10-23  9:13 UTC (permalink / raw)
  To: Mike Snitzer
  Cc: jack, gustavo, linux-mm, device-mapper development, pavel, steve,
	osandov, Alasdair G Kergon, bvanassche, Darrick J. Wong, hch,
	len.brown, linux-pm, ming.lei, linux-block, linux-fsdevel, viro,
	Sergei Shtepa, koct9i, axboe, Damien Le Moal, Johannes Thumshirn,
	rjw, linux-kernel, linux-xfs, tj, akpm

On Thu, Oct 22, 2020 at 01:54:16PM -0400, Mike Snitzer wrote:
> On Thu, Oct 22, 2020 at 11:14 AM Darrick J. Wong
> > Stupid question: Why don't you change the block layer to make it
> > possible to insert device mapper devices after the blockdev has been set
> > up?
> 
> Not a stupid question.  Definitely something that us DM developers
> have wanted to do for a while.  Devil is in the details but it is the
> right way forward.
> 

Yes, I think that is the right thing to do.  And I don't think it should
be all that hard.  All we'd need in the I/O path is something like the
pseudo-patch below, which will allow the interposer driver to resubmit
bios using submit_bio_noacct as long as the driver sets BIO_INTERPOSED.

diff --git a/block/blk-core.c b/block/blk-core.c
index ac00d2fa4eb48d..3f6f1eb565e0a8 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1051,6 +1051,9 @@ blk_qc_t submit_bio_noacct(struct bio *bio)
 		return BLK_QC_T_NONE;
 	}
 
+	if (blk_has_interposer(bio->bi_disk) &&
+	    !(bio->bi_flags & BIO_INTERPOSED))
+		return __submit_bio_interposed(bio);
 	if (!bio->bi_disk->fops->submit_bio)
 		return __submit_bio_noacct_mq(bio);
 	return __submit_bio_noacct(bio);

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [dm-devel] [PATCH 0/2] block layer filter and block device snapshot module
  2020-10-23  9:13                 ` hch
@ 2020-10-23 10:31                   ` Hannes Reinecke
  2020-10-23 11:04                     ` Sergei Shtepa
  2020-10-23 11:12                     ` hch
  0 siblings, 2 replies; 6+ messages in thread
From: Hannes Reinecke @ 2020-10-23 10:31 UTC (permalink / raw)
  To: hch, Mike Snitzer
  Cc: jack, gustavo, linux-mm, device-mapper development, pavel, steve,
	osandov, Alasdair G Kergon, bvanassche, Darrick J. Wong,
	len.brown, linux-pm, ming.lei, linux-block, linux-fsdevel, viro,
	Sergei Shtepa, koct9i, axboe, Damien Le Moal, Johannes Thumshirn,
	rjw, linux-kernel, linux-xfs, tj, akpm

On 10/23/20 11:13 AM, hch@infradead.org wrote:
> On Thu, Oct 22, 2020 at 01:54:16PM -0400, Mike Snitzer wrote:
>> On Thu, Oct 22, 2020 at 11:14 AM Darrick J. Wong
>>> Stupid question: Why don't you change the block layer to make it
>>> possible to insert device mapper devices after the blockdev has been set
>>> up?
>>
>> Not a stupid question.  Definitely something that us DM developers
>> have wanted to do for a while.  Devil is in the details but it is the
>> right way forward.
>>
> 
> Yes, I think that is the right thing to do.  And I don't think it should
> be all that hard.  All we'd need in the I/O path is something like the
> pseudo-patch below, which will allow the interposer driver to resubmit
> bios using submit_bio_noacct as long as the driver sets BIO_INTERPOSED.
> 
> diff --git a/block/blk-core.c b/block/blk-core.c
> index ac00d2fa4eb48d..3f6f1eb565e0a8 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -1051,6 +1051,9 @@ blk_qc_t submit_bio_noacct(struct bio *bio)
>   		return BLK_QC_T_NONE;
>   	}
>   
> +	if (blk_has_interposer(bio->bi_disk) &&
> +	    !(bio->bi_flags & BIO_INTERPOSED))
> +		return __submit_bio_interposed(bio);
>   	if (!bio->bi_disk->fops->submit_bio)
>   		return __submit_bio_noacct_mq(bio);
>   	return __submit_bio_noacct(bio);
> 
My thoughts went more into the direction of hooking into ->submit_bio, 
seeing that it's a NULL pointer for most (all?) block drivers.

But sure, I'll check how the interposer approach would turn out.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dm-devel] [PATCH 0/2] block layer filter and block device snapshot module
  2020-10-23 10:31                   ` Hannes Reinecke
@ 2020-10-23 11:04                     ` Sergei Shtepa
  2020-10-23 11:12                     ` hch
  1 sibling, 0 replies; 6+ messages in thread
From: Sergei Shtepa @ 2020-10-23 11:04 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: jack, Mike Snitzer, gustavo, linux-mm, device-mapper development,
	pavel, steve, osandov, Alasdair G Kergon, bvanassche,
	Darrick J. Wong, hch, len.brown, linux-pm, ming.lei, linux-block,
	linux-fsdevel, viro, koct9i, axboe, Damien Le Moal,
	Johannes Thumshirn, rjw, linux-kernel, linux-xfs, tj, akpm

The 10/23/2020 13:31, Hannes Reinecke wrote:
> On 10/23/20 11:13 AM, hch@infradead.org wrote:
> > On Thu, Oct 22, 2020 at 01:54:16PM -0400, Mike Snitzer wrote:
> >> On Thu, Oct 22, 2020 at 11:14 AM Darrick J. Wong
> >>> Stupid question: Why don't you change the block layer to make it
> >>> possible to insert device mapper devices after the blockdev has been set
> >>> up?
> >>
> >> Not a stupid question.  Definitely something that us DM developers
> >> have wanted to do for a while.  Devil is in the details but it is the
> >> right way forward.
> >>
> > 
> > Yes, I think that is the right thing to do.  And I don't think it should
> > be all that hard.  All we'd need in the I/O path is something like the
> > pseudo-patch below, which will allow the interposer driver to resubmit
> > bios using submit_bio_noacct as long as the driver sets BIO_INTERPOSED.
> > 
> > diff --git a/block/blk-core.c b/block/blk-core.c
> > index ac00d2fa4eb48d..3f6f1eb565e0a8 100644
> > --- a/block/blk-core.c
> > +++ b/block/blk-core.c
> > @@ -1051,6 +1051,9 @@ blk_qc_t submit_bio_noacct(struct bio *bio)
> >   		return BLK_QC_T_NONE;
> >   	}
> >   
> > +	if (blk_has_interposer(bio->bi_disk) &&
> > +	    !(bio->bi_flags & BIO_INTERPOSED))
> > +		return __submit_bio_interposed(bio);
> >   	if (!bio->bi_disk->fops->submit_bio)
> >   		return __submit_bio_noacct_mq(bio);
> >   	return __submit_bio_noacct(bio);
> > 

It`s will be great! Approximately this interception capability is not
enough now.

> My thoughts went more into the direction of hooking into ->submit_bio, 
> seeing that it's a NULL pointer for most (all?) block drivers.
> 
> But sure, I'll check how the interposer approach would turn out.

If anyone will do the patch blk-interposer, please add me to CC.
I will try to offer my module that will use blk-interposer.

-- 
Sergei Shtepa
Veeam Software developer.

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dm-devel] [PATCH 0/2] block layer filter and block device snapshot module
  2020-10-23 10:31                   ` Hannes Reinecke
  2020-10-23 11:04                     ` Sergei Shtepa
@ 2020-10-23 11:12                     ` hch
  1 sibling, 0 replies; 6+ messages in thread
From: hch @ 2020-10-23 11:12 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: jack, Mike Snitzer, gustavo, linux-mm, device-mapper development,
	pavel, steve, osandov, Alasdair G Kergon, bvanassche,
	Darrick J. Wong, hch, len.brown, linux-pm, ming.lei, linux-block,
	tj, viro, Sergei Shtepa, koct9i, axboe, Damien Le Moal,
	Johannes Thumshirn, rjw, linux-kernel, linux-xfs, linux-fsdevel,
	akpm

On Fri, Oct 23, 2020 at 12:31:05PM +0200, Hannes Reinecke wrote:
> My thoughts went more into the direction of hooking into ->submit_bio,
> seeing that it's a NULL pointer for most (all?) block drivers.
> 
> But sure, I'll check how the interposer approach would turn out.

submit_bio is owned by the underlying device, and for a good reason
stored in a const struct..

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-10-26  7:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1603271049-20681-1-git-send-email-sergei.shtepa@veeam.com>
     [not found] ` <71926887-5707-04a5-78a2-ffa2ee32bd68@suse.de>
     [not found]   ` <20201021141044.GF20749@veeam.com>
     [not found]     ` <ca8eaa40-b422-2272-1fd9-1d0a354c42bf@suse.de>
     [not found]       ` <20201022094402.GA21466@veeam.com>
     [not found]         ` <BL0PR04MB6514AC1B1FF313E6A14D122CE71D0@BL0PR04MB6514.namprd04.prod.outlook.com>
     [not found]           ` <20201022135213.GB21466@veeam.com>
     [not found]             ` <20201022151418.GR9832@magnolia>
2020-10-22 17:54               ` [dm-devel] [PATCH 0/2] block layer filter and block device snapshot module Mike Snitzer
2020-10-23  9:13                 ` hch
2020-10-23 10:31                   ` Hannes Reinecke
2020-10-23 11:04                     ` Sergei Shtepa
2020-10-23 11:12                     ` hch
2020-10-22 18:35 ` Mike Snitzer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).