From: Christoph Hellwig <hch@infradead.org>
To: Matthew Wilcox <matthew@wil.cx>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [RFC 1/2] scsi core: alloc_cmnd
Date: Tue, 23 Oct 2007 21:24:11 +0100 [thread overview]
Message-ID: <20071023202411.GB23558@infradead.org> (raw)
In-Reply-To: <20071019183331.GC30807@parisc-linux.org>
On Fri, Oct 19, 2007 at 12:33:31PM -0600, Matthew Wilcox wrote:
>
> This fairly naive patch introduces alloc_cmnd and destroy_cmnd. I'm not
> exactly happy about passing down the gfp_mask -- I'd prefer to be able
> to allocate scsi_cmnds before we grab the queue_lock (and hence get
> rid of the possibility we might need to GFP_ATOMIC), but I don't see
> anywhere to do that. Maybe there's a simple change we can make to the
> block layer to allow it.
This looks fine to. It might be nice to factor the code out into
a few more helpers:
static struct scsi_cmnd *scsi_alloc_cmnd(struct Scsi_Host *shost, gfp_t mask)
{
if (shost->hostt->alloc_cmnd)
return shost->hostt->alloc_cmnd(shost, mask);
else
return kmem_cache_alloc(shost->cmd_pool->slab,
mask | shost->cmd_pool->gfp_mask);
}
static struct scsi_cmnd *scsi_destroy_cmnd(struct Scsi_Host *shost,
struct scsi_cmnd *cmd)
{
if (likely(cmd != NULL)) {
if (shost->hostt->destroy_cmnd)
shost->hostt->destroy_cmnd(cmd);
else
kmem_cache_free(shost->cmd_pool->slab, cmd);
}
}
plus helper to setup/teardown the pools if nessecary so that the code
flow is easier to read. Also maybe a s/destroy/free/. The VFS uses
destroy for inodes, but I'd personally prefer free.
prev parent reply other threads:[~2007-10-23 20:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-19 18:33 [RFC 1/2] scsi core: alloc_cmnd Matthew Wilcox
2007-10-23 16:49 ` Boaz Harrosh
2007-10-23 17:48 ` Matthew Wilcox
2007-10-23 18:46 ` Boaz Harrosh
2007-10-23 19:15 ` Matthew Wilcox
2007-10-23 19:49 ` Boaz Harrosh
2007-10-23 19:27 ` Christoph Hellwig
2007-10-23 20:24 ` Christoph Hellwig [this message]
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=20071023202411.GB23558@infradead.org \
--to=hch@infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=matthew@wil.cx \
/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