Wrap these in preempt_disable/enable() to allow the function to be
called from any context?
Thanks.
--
tejun
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
09-21-2012, 12:09 AM
Kent Overstreet
block: Add bio_copy_data()
On Thu, Sep 20, 2012 at 05:06:32PM -0700, Tejun Heo wrote:
> Hello,
>
> On Mon, Sep 10, 2012 at 05:22:26PM -0700, Kent Overstreet wrote:
> > +void bio_copy_data(struct bio *dst, struct bio *src)
> > +{
> ...
> > + src_p = kmap_atomic(src_bv->bv_page);
> > + dst_p = kmap_atomic(dst_bv->bv_page);
> > +
> > + memcpy(dst_p + dst_bv->bv_offset,
> > + src_p + src_bv->bv_offset,
> > + bytes);
> > +
> > + kunmap_atomic(dst_p);
> > + kunmap_atomic(src_p);
>
> Wrap these in preempt_disable/enable() to allow the function to be
> called from any context?
I checked the implementation of kmap_atomic(), it already does
preempt_disable() so it's safe in process context - if I understand
correctly it needs local_irq_save()/restore() to be safe in any context
and I figured calling this from irq context is not the norm so that
should be the caller's responsibility.
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
09-21-2012, 12:09 AM
Tejun Heo
block: Add bio_copy_data()
On Thu, Sep 20, 2012 at 05:06:32PM -0700, Tejun Heo wrote:
> Hello,
>
> On Mon, Sep 10, 2012 at 05:22:26PM -0700, Kent Overstreet wrote:
> > +void bio_copy_data(struct bio *dst, struct bio *src)
> > +{
> ...
> > + src_p = kmap_atomic(src_bv->bv_page);
> > + dst_p = kmap_atomic(dst_bv->bv_page);
> > +
> > + memcpy(dst_p + dst_bv->bv_offset,
> > + src_p + src_bv->bv_offset,
> > + bytes);
> > +
> > + kunmap_atomic(dst_p);
> > + kunmap_atomic(src_p);
>
> Wrap these in preempt_disable/enable() to allow the function to be
> called from any context?
Ooh, and maybe return the amount of copied data?
--
tejun
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
09-21-2012, 12:13 AM
Kent Overstreet
block: Add bio_copy_data()
On Thu, Sep 20, 2012 at 05:09:47PM -0700, Tejun Heo wrote:
> On Thu, Sep 20, 2012 at 05:06:32PM -0700, Tejun Heo wrote:
> > Hello,
> >
> > On Mon, Sep 10, 2012 at 05:22:26PM -0700, Kent Overstreet wrote:
> > > +void bio_copy_data(struct bio *dst, struct bio *src)
> > > +{
> > ...
> > > + src_p = kmap_atomic(src_bv->bv_page);
> > > + dst_p = kmap_atomic(dst_bv->bv_page);
> > > +
> > > + memcpy(dst_p + dst_bv->bv_offset,
> > > + src_p + src_bv->bv_offset,
> > > + bytes);
> > > +
> > > + kunmap_atomic(dst_p);
> > > + kunmap_atomic(src_p);
> >
> > Wrap these in preempt_disable/enable() to allow the function to be
> > called from any context?
>
> Ooh, and maybe return the amount of copied data?
Possibly, but I think I want to wait until a user needs it before adding
something like that.
>From looking at other code that copies bio data, a parameter that
specifies the amount of data to be copied might be more useful.
I'm not sure I've seen all the places where bio data is copied yet, so
I've just been waiting until I find more uses to make it do more.
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
09-21-2012, 12:15 AM
Tejun Heo
block: Add bio_copy_data()
On Thu, Sep 20, 2012 at 05:09:45PM -0700, Kent Overstreet wrote:
> On Thu, Sep 20, 2012 at 05:06:32PM -0700, Tejun Heo wrote:
> > Hello,
> >
> > On Mon, Sep 10, 2012 at 05:22:26PM -0700, Kent Overstreet wrote:
> > > +void bio_copy_data(struct bio *dst, struct bio *src)
> > > +{
> > ...
> > > + src_p = kmap_atomic(src_bv->bv_page);
> > > + dst_p = kmap_atomic(dst_bv->bv_page);
> > > +
> > > + memcpy(dst_p + dst_bv->bv_offset,
> > > + src_p + src_bv->bv_offset,
> > > + bytes);
> > > +
> > > + kunmap_atomic(dst_p);
> > > + kunmap_atomic(src_p);
> >
> > Wrap these in preempt_disable/enable() to allow the function to be
> > called from any context?
>
> I checked the implementation of kmap_atomic(), it already does
> preempt_disable() so it's safe in process context - if I understand
> correctly it needs local_irq_save()/restore() to be safe in any context
> and I figured calling this from irq context is not the norm so that
> should be the caller's responsibility.
Ooh, that means the patch I just sent Andrew about sg_mapping_iter is
still too strict.
Thanks.
--
tejun
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
09-24-2012, 10:34 PM
Kent Overstreet
block: Add bio_copy_data()
This gets open coded quite a bit and it's tricky to get right, so make a
generic version and convert some existing users over to it instead.