From: Jens Axboe <jens.axboe@oracle.com>
To: Boaz Harrosh <bharrosh@panasas.com>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
linux-scsi <linux-scsi@vger.kernel.org>,
James Bottomley <James.Bottomley@HansenPartnership.com>,
Tejun Heo <tj@kernel.org>,
open-osd mailing-list <osd-dev@open-osd.org>
Subject: Re: [PATCHSET 0/2] Don't let blk_put_request leak BIOs
Date: Thu, 19 Mar 2009 15:24:19 +0100 [thread overview]
Message-ID: <20090319142419.GS27476@kernel.dk> (raw)
In-Reply-To: <49C2542B.70604@panasas.com>
On Thu, Mar 19 2009, Boaz Harrosh wrote:
> Jens Axboe wrote:
> > On Thu, Mar 19 2009, Boaz Harrosh wrote:
> >> Jens Axboe wrote:
> >>> On Thu, Mar 19 2009, Boaz Harrosh wrote:
> >>>> Jens Axboe wrote:
> >>>>> On Thu, Mar 19 2009, Boaz Harrosh wrote:
> >>>>>> Hi Jens
> >>>>>>
> >>>>>> You never commented on these patches. Please have a look?
> >>>>>>
> >>>>>> The issue is that if we map some memory into a request but then
> >>>>>> do not execute it. Then calling blk_put_request() will leak the bio(s)
> >>>>>> unless one does an ugly code like:
> >>>>>> - struct bio *bio;
> >>>>>> -
> >>>>>> - while ((bio = rq->bio) != NULL) {
> >>>>>> - rq->bio = bio->bi_next;
> >>>>>> - bio_endio(bio, 0);
> >>>>>> - }
> >>>> This is the code I have today in osd_initiator.c (In scsi-misc tree)
> >>>>
> >>>>> Sorry, I think this is a horrible design. blk_put_request() doesn't care
> >>>>> about any data attachments, in fact (if possible) it should go BUG() if
> >>>>> the request hasn't been completed in some way or other. It deals with
> >>>>> the deallocation part, blk_get_request() doesn't attach any data. The
> >>>>> end result with code like the above is an assymmetric API.
> >>>>>
> >>>>>> This problem arise in OSD when we can fail to setup the write
> >>>>>> or the read side and then we must cleanup the other half.
> >>>>>> Same problem exist in bsg, on bidi commands. But there the bio
> >>>>>> is just leaked on the error path, it does not do the ugly loop above.
> >>>>> These drivers should just be fixed, then.
> >>>>>
> >>>>> So if you have spotted this problem in eg bsg, then please send a patch
> >>>>> for that to Tomo!
> >>>>>
> >>>> Then the above code taken from today's osd_initiator is good? People where
> >>>> complaining that it is not good, because it is messing up with internal
> >>>> block structures.
> >>>>
> >>>> What about just exporting an blk_rq_abort(struct request *req) that is
> >>>> the same as PATCH 1/2. But is not called from blk_put_request ?
> >>> Well no, the approach isn't that good either. How did you map these
> >>> request? Most logical API would have something to unmap them again.
> >>>
> >> I'm not sure I understand.
> >> I use a combination of map functions to build a complex bio. But more
> >> specifically I do not want to use any unmap function because I do not
> >> want to call the end_bio() function I want to not allow any bouncing
> >> unmapping or hooking to occur. "Abort" is the only write name for it.
> >
> > I'm not sure I understand what you are saying here either. So if you
> > build these bios up manually, then you will need to tear them down
> > manually as well.
> >
> > Doing panic style cleanup at blk_put_request() time is definitely not
> > the right approach. And you can't just export a blk_rq_abort() type
> > functionality, since you don't don't know what you are trying to abort.
> > You assume that bio_endio() will always do the right thing, that may not
> > be enough. Hence you need the caller to cleanup after themselves.
> >
>
> So current (above) code in osd_initiator.c is correct and should stay
> as it is? that's fine by me.
It's still not pretty, any reason you can't just use blk_end_request()?
Why do you need to unroll the bios manually?
--
Jens Axboe
next prev parent reply other threads:[~2009-03-19 14:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-19 10:20 [PATCHSET 0/2] Don't let blk_put_request leak BIOs Boaz Harrosh
2009-03-19 10:24 ` [PATCH 1/2] TESTING: " Boaz Harrosh
2009-03-19 10:26 ` [PATCH 2/2] libosd: Don't let osd abuse block internals, now that it's fixed Boaz Harrosh
2009-03-19 11:33 ` [PATCHSET 0/2] Don't let blk_put_request leak BIOs Jens Axboe
2009-03-19 13:40 ` Boaz Harrosh
2009-03-19 13:45 ` Jens Axboe
2009-03-19 13:48 ` Boaz Harrosh
2009-03-19 13:56 ` Jens Axboe
2009-03-19 14:18 ` Boaz Harrosh
2009-03-19 14:24 ` Jens Axboe [this message]
2009-03-19 14:50 ` Boaz Harrosh
2009-03-19 16:29 ` [PATCH] WARN_ON if blk_put_request leaks BIOs Boaz Harrosh
2009-03-20 20:45 ` Jens Axboe
2009-03-22 8:51 ` Boaz Harrosh
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=20090319142419.GS27476@kernel.dk \
--to=jens.axboe@oracle.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=bharrosh@panasas.com \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=linux-scsi@vger.kernel.org \
--cc=osd-dev@open-osd.org \
--cc=tj@kernel.org \
/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.