From: Lee Duncan <lduncan@suse.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-scsi@vger.kernel.org, JBottomley@Parallels.com,
hare@suse.com, jthumshirn@suse.de
Subject: Re: [PATCHv3] Update scsi host to use ida for host number
Date: Thu, 3 Sep 2015 09:06:41 -0700 [thread overview]
Message-ID: <55E87011.2030401@suse.com> (raw)
In-Reply-To: <20150902064830.GA17978@infradead.org>
On 09/01/2015 11:48 PM, Christoph Hellwig wrote:
> On Tue, Sep 01, 2015 at 05:03:28PM -0700, Lee Duncan wrote:
>> +static int host_get_index(int *index)
>> +{
>> + int error = -ENOMEM;
>> +
>> + do {
>> + if (!ida_pre_get(&host_index_ida, GFP_KERNEL))
>> + break;
>> + spin_lock(&host_index_lock);
>> + error = ida_get_new(&host_index_ida, index);
>> + spin_unlock(&host_index_lock);
>> + } while (error == -EAGAIN);
>> +
>> + return error;
>> +}
>> +
>> +static inline void host_put_index(int index)
>> +{
>> + spin_lock(&host_index_lock);
>> + ida_remove(&host_index_ida, index);
>> + spin_unlock(&host_index_lock);
>> +}
>
> I really hate how this pattern (and the equivalent for IDA) are
> spread all over. Any chance to have some simple_ida/simple_idr helpers
> instead of duplicating it again an again.
>
> Besides that why aren't we using and idr here and use it for host lookup
> as well?
> .
>
Good question. My original goal was just to fix the host_no wrap-around
problem, but I agree, the hosts.c module could benefit from using idr,
making scsi_host_lookup(hostnum) much simpler, and possible faster.
I will submit another patch.
This means I won't need the sequence any longer that you wanted made
into helper functions, though I'd still be glad to create the helper
functions and convert some of the ida users, if you wish.
--
Lee Duncan
prev parent reply other threads:[~2015-09-03 16:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-02 0:03 [PATCHv3] Update scsi host to use ida for host number Lee Duncan
2015-09-02 6:48 ` Christoph Hellwig
2015-09-03 16:06 ` Lee Duncan [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=55E87011.2030401@suse.com \
--to=lduncan@suse.com \
--cc=JBottomley@Parallels.com \
--cc=hare@suse.com \
--cc=hch@infradead.org \
--cc=jthumshirn@suse.de \
--cc=linux-scsi@vger.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.