All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: doug@easyco.com, device-mapper development <dm-devel@redhat.com>
Subject: Re: Newbie device mapper questions
Date: Mon, 15 Jun 2015 18:20:18 -0400	[thread overview]
Message-ID: <20150615222018.GA29625@redhat.com> (raw)
In-Reply-To: <CAFx4rwQ0ganzZn5FjQZTVtk1DK1Qr1pmMCTxRCwxd793+-anHg@mail.gmail.com>

On Mon, Jun 15, 2015 at 12:52:57PM -0700, Doug Dumitru wrote:

[..]
> >
> > In map() I actually do the switching operation. I've looked at how
> > dm-linear implements this and copied a lot of information. Currently I
> > do static switching (fixed block size, ingoring the meta device). Here
> > are my questions:
> >
> > - How can I read within the kernel from the block device lc->meta->bdev?
> > If I call "read_dev_sector" from "map" this results in a deadlock, I'm
> > guessing this is now how it's supposed to work. The bcache module must
> > perform something similar (because it also reads and writes metadata,
> > only much more complex), but I'll be damned but couldn't find out where
> > the actual reading/writing is performed in the code. What are things
> > that I should look at?
> >
> 
> ​You have to allocate a bio, populate it, allocate pages for buffer,
> populate the bvec, and call make_request (or generic make request).  You
> will get the completion from the bio on the bottom half of the interrupt
> handler, so how much work you can do there is debatable.  You cannot start
> an new IO from there, which you need to.  You will probably want to start a
> helper thread and have the completion routine schedule itself onto your
> thread.  Once you are back on your thread, you can do just about anything.
> 
> Because you need to do IO, you will not be able to do a simple bio "bounce
> redirect".  You will need to do the IO youself (ie, call another make
> request), but you can use the callers bvec for this, so there is no data
> copy required.  Once the request completes, you can then fin the caller.
> ​

Above sounds right.


[..]
> >
> > - Is i_size_read(lc->src1dev->bdev->bd_inode) the correct way of
> > determining the size of the underlying block device? If not, which
> > function is?
> >

I believe that's correct. Look at block/blk-core.c

handle_bad_sector(struct bio *bio) 
{
}

> 
> ​... I am happy to leave out answers that I don't know ...​
> 
> 
> >
> > - Can I safely assume the logical sector size is fixed to be 512 bytes
> > in all cases?
> >
> 
> ​Probably not, but maybe.  You are in control of the hardware.​

You mean block size or sector size? I think sector sizes can vary and
targets can allow user space to specify one. Typically metadata is per
block can lead to smaller metadata foot print.

> 
> 
> >
> > - In the dm-linear example, bio_sectors(bio) is checked. This gives, if
> > I understand it correctly, the size in sectors of the BIO (usually this
> > is 8). What I don't understand is in which cases this can become zero
> > (dm-linear has a if that checks for bio_sectors(bio) != 0).
> >
> 
> ​.. just a sanity check.  If you get a call of zero size, it means
> something else is broken.​
> 
> 
> >
> > - Can I determine the size the bio in map() will have already in ctr()
> > somehow? Can I assume it will never change if it was once determined?
> > The reason is that for my example I need to make sure the chunk size is
> > a integer multiple of the bio size and I would only like to check this
> > once (in ctr) and not every time (in map).
> >

I think size of bio can change and it depends on the submitter. Targets
can specify maximum size of bio and upper layers will adhere to it. So
I don't think you can fix the size of bio in constructor. I guess you will
have to check incoming bio in map().

Thanks
Vivek

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

  reply	other threads:[~2015-06-15 22:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-15 18:39 Newbie device mapper questions Johannes Bauer
2015-06-15 19:52 ` Doug Dumitru
2015-06-15 22:20   ` Vivek Goyal [this message]
2015-06-16  0:55     ` Minfei Huang
2015-06-16  1:18       ` Minfei Huang
2015-06-16 18:54   ` Johannes Bauer
2015-06-16 19:37     ` Alasdair G Kergon
2015-06-16 21:05     ` Doug Dumitru
2015-06-16 19:46 ` Alasdair G Kergon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150615222018.GA29625@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=doug@easyco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.