mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: Vladislav Bolkhovitin <vst@vlnb.net>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	scst-devel@lists.sourceforge.net, Tejun Heo <tj@kernel.org>,
	Boaz Harrosh <bharrosh@panasas.com>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
	Joe Eykholt <jeykholt@cisco.com>
Subject: Re: [PATCH]: Implementation of blk_rq_map_kern_sg() (aka New implementation  of scsi_execute_async() v3)
Date: Sat, 15 Aug 2009 10:22:20 +0200	[thread overview]
Message-ID: <20090815082220.GJ12579@kernel.dk> (raw)
In-Reply-To: <4A830016.5020304@vlnb.net>

On Wed, Aug 12 2009, Vladislav Bolkhovitin wrote:
> This patch implements function blk_rq_map_kern_sg(), which allows to map
> a kernel-originated SG vector to a block request. It is necessary to execute
> SCSI commands with from kernel going SG buffer. At the moment SCST is the only
> user of this functionality. It needs it, because its target drivers, which
> are, basically, SCSI drivers, can deal only with SGs, not with BIOs. But,
> according to the latest discussions, there can be other potential users for of
> this functionality, so I'm sending this patch in a hope that it will be
> also useful for them and eventually will be merged in the mainline kernel.
> 
> In the previous submissions this patch was called "New implementation of
> scsi_execute_async()", but since in this version scsi_execute_async() was
> removed from it by request of Boaz Harrosh the name was changed accordingly.

Generally this patch looks great, I just have one little thing I'd like
to point out:

> +	while (hbio != NULL) {
> +		bio = hbio;
> +		hbio = hbio->bi_next;
> +		bio->bi_next = NULL;
> +
> +		blk_queue_bounce(q, &bio);
> +
> +		res = blk_rq_append_bio(q, rq, bio);
> +		if (unlikely(res != 0)) {
> +			bio->bi_next = hbio;
> +			hbio = bio;
> +			/* We can have one or more bios bounced */
> +			goto out_unmap_bios;
> +		}
> +	}

Constructs like this are always dangerous, because of how mempools work.
__blk_queue_bounce() will internally do:

        bio = bio_alloc(GFP_NOIO, cnt);

so you could potentially enter a deadlock if a) you are the only one
allocating a bio currently, and b) the alloc fails and we wait for a bio
to be returned to the pool. This is highly unlikely and requires other
conditions to be dire, but it is a problem. This is not restricted to
the swap out path, the problem is purely lack of progress. So the golden
rule is always that you either allocate these units from a private pool
(which is hard for bouncing, since it does both page and bio allocations
from a mempool), or that you always ensure that a previously allocated
bio is in flight before attempting a new alloc.

-- 
Jens Axboe


  reply	other threads:[~2009-08-15  8:22 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-09 18:14 [PATCH]: New implementation of scsi_execute_async() Vladislav Bolkhovitin
2009-07-09 19:35 ` Joe Eykholt
2009-07-10 10:59   ` Joe Eykholt
2009-07-14 16:16     ` Vladislav Bolkhovitin
2009-07-12 13:03 ` Boaz Harrosh
2009-07-14 16:16   ` Vladislav Bolkhovitin
2009-07-15  8:19     ` Boaz Harrosh
2009-07-16 18:13       ` Vladislav Bolkhovitin
2009-07-19 11:34         ` Boaz Harrosh
2009-07-20 17:54           ` Vladislav Bolkhovitin
2009-07-21  8:03             ` Boaz Harrosh
2009-07-21 18:26               ` Vladislav Bolkhovitin
2009-07-14 16:17 ` [PATCH v2]: " Vladislav Bolkhovitin
2009-07-14 18:24   ` Vladislav Bolkhovitin
2009-07-15  9:07   ` Boaz Harrosh
2009-07-15 17:48     ` Joe Eykholt
2009-07-16 18:15       ` Vladislav Bolkhovitin
2009-07-16  7:54     ` Tejun Heo
2009-07-16 18:15     ` Vladislav Bolkhovitin
2009-07-19 11:35       ` Boaz Harrosh
2009-07-20 17:56         ` Vladislav Bolkhovitin
2009-07-16  7:52   ` Tejun Heo
2009-07-16 18:17     ` Vladislav Bolkhovitin
2009-08-12 17:47 ` [PATCH]: Implementation of blk_rq_map_kern_sg() (aka New implementation of scsi_execute_async() v3) Vladislav Bolkhovitin
2009-08-15  8:22   ` Jens Axboe [this message]
2009-09-03 16:34     ` Vladislav Bolkhovitin

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=20090815082220.GJ12579@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=bharrosh@panasas.com \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=jeykholt@cisco.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=scst-devel@lists.sourceforge.net \
    --cc=tj@kernel.org \
    --cc=vst@vlnb.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome