Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* Re: [PATCH rdma-core 4/4] glue/redhat/spec: build split rpm packages
From: Jarod Wilson @ 2016-10-17 18:45 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20161014233904.GD16509-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

On Fri, Oct 14, 2016 at 05:39:04PM -0600, Jason Gunthorpe wrote:
> On Fri, Oct 14, 2016 at 03:21:36PM -0400, Jarod Wilson wrote:
> 
> > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/iwpmd-11-1.el7.x86_64.rpm
> 
> FC used to call this libiwpm for some reason..

Ah. I may need to add an Obsoletes: for that particular case then.

> > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libibcm-11-1.el7.x86_64.rpm
> 
> Do you want to try and do as I did with debian and put the SONAME data
> into the package version for the libraries? eg
> 
> libibcm1_1.0.11-1_amd64.deb

No, that's a debian-ism that Red Hat has never really followed. The soname
data is already captured in the rpm metadata.

> > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libcxgb3-11-1.el7.x86_64.rpm
> > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libcxgb4-11-1.el7.x86_64.rpm
> > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libhfi1-11-1.el7.x86_64.rpm
> > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libi40iw-11-1.el7.x86_64.rpm
> > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libipathverbs-11-1.el7.x86_64.rpm
> > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libmlx4-11-1.el7.x86_64.rpm
> > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libmlx5-11-1.el7.x86_64.rpm
> > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libmthca-11-1.el7.x86_64.rpm
> > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libnes-11-1.el7.x86_64.rpm
> > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libocrdma-11-1.el7.x86_64.rpm
> > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/librxe-11-1.el7.x86_64.rpm
> 
> Does this mean RH is not going to do a single package for the
> providers? You know another 5 or so are coming..

Putting all the providers in a single sub-package is certainly something
we could do. With rpm virtual Provides and Obsoletes, we could make the
upgrade path transparent to at least yum/dnf/rpm, but it might still
confuse people who go looking for the same package they've always had
installed, so it could be something we do in Fedora and the next RHEL
major release, rather than in a current RHEL minor update.

> Any feedback if things build on your supported arches? I'd be
> interested to see compiler log if it isn't silent.
> 
> > +install -D -m0644 Documentation/{ibacm,ibsrpdm,libibcm,libibverbs,librdmacm,rxe}.md %{buildroot}/%{_docdir}/%{name}-%{version}/
> > +install -D -m0644 README.md %{buildroot}/%{_docdir}/%{name}-%{version}/
> 
> I guess README should go in that patch I sent you..

D'oh, yeah, I'll mix that in here locally.

> > +%{buildroot}/%{_bindir}/ib_acme -D . -O
> > +# Fixup a multilib conflict in ibacm_opts.cfg:
> > +sed -i -e '/^# Specifies the directory of the provider libraries$/ a\
> > +# Use /usr/lib64/ibacm on 64bit, /usr/lib/libacm on 32bit.
> > +' -e 's%^\(# provider_lib_path
> > /usr/\)lib\(64\)\?/ibacm$%\1lib64/ibacm%' ibacm_opts.cfg
> 
> Hum? I'm pretty sure this is basically fixed in the code now, was done here
> 5eebdb9baaaae420a4bb16e586a96807823916a0
> 
> Adjusting the comment like that doesn't really make sense, the acm
> daemon has a fixed endianness and looks in a single place to load the
> plugin. If someone wants to use 32 bit plugins they have to install
> the 32 bit acm daemon, which would have the 32 bit path in the sample
> conf file...

This was just copy and paste from our existing libacm spec, might well be
something that was fixed and I just missed it.

> > +install -D -m0644 ibacm/man/*.1 %{buildroot}/%{_mandir}/man1/
> > +install -D -m0644 ibacm/man/*.7 %{buildroot}/%{_mandir}/man7/
> > +sed -e 's|@ACM_PROVIDER_DIR@|%{libdir}/%{name}/|g' -e 's|@CMAKE_INSTALL_FULL_LOCALSTATEDIR@|%{_localstatedir}|g' ibacm/man/ibacm_prov.7.in > %{buildroot}/%{_mandir}/man7/ibacm_prov.7
> 
> ?? cmake is supposed to install these.. Looks like it works. What did
> you need done here to open code it?

They weren't getting installed, so I threw that hack in, meant to
actually say something about that, got lost in the shuffle. I'll
double-check if they're still not getting installed... Okay, they're
getting installed now. May have just been a transient error with an
earlier tarball, or something else I did wrong. I'll drop that bit.

-- 
Jarod Wilson
jarod-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH rdma-core 2/4] glue/redhat: add udev/systemd/etc infrastructure bits
From: Doug Ledford @ 2016-10-17 18:56 UTC (permalink / raw)
  To: Jarod Wilson, Jason Gunthorpe; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20161017182037.GK14983-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 4362 bytes --]

On 10/17/2016 2:20 PM, Jarod Wilson wrote:
> On Mon, Oct 17, 2016 at 11:46:11AM -0600, Jason Gunthorpe wrote:
>> On Mon, Oct 17, 2016 at 12:22:21PM -0400, Jarod Wilson wrote:

>>>>> diff --git a/glue/redhat/ibacm.service b/glue/redhat/ibacm.service
>>>>> new file mode 100644
>>>>> index 0000000..1cd031a
>>>>> +++ b/glue/redhat/ibacm.service
>>>>
>>>> Can we just put this in ibacm/ ?
>>>
>>> Probably.
>>
>> Okay, the only thing I really don't like being upstream is the
>> opensm.service..
>>
>> Do you know why acm needs that?
> 
> I think Doug already attempted to address this elsewhere in the thread,
> and he'd know better than me.

Since it got snipped, I'm pretty sure it just lists opensm in the Wants=
tag.  With systemd, that's a soft dependency.  Only if opensm is
installed and configured to start anyway does systemd then order this
item after opensm.  Since you need opensm for links to come up anyway,
it makes sense for the order of startup for RDMA related items to be:

rdma-core
\-opensm
  \-Everything else

Because of that, I think I had opensm listed as a want in pretty much
everything, but as already stated, it's a soft dependency and systemd
ignores it if you don't have opensm configured to run on that machine.


>>>>> +SUBSYSTEM=="module", KERNEL=="cxgb*", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service"
>>>>> +SUBSYSTEM=="module", KERNEL=="ib_*", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service"
>>>>> +SUBSYSTEM=="module", KERNEL=="mlx*", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service"
>>>>> +SUBSYSTEM=="module", KERNEL=="iw_*", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service"
>>>>> +SUBSYSTEM=="module", KERNEL=="be2net", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service"
>>>>> +SUBSYSTEM=="module", KERNEL=="enic", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="rdma.service"
>>>>
>>>> Also cross distro
>>>
>>> Yeah, these are definitely prime candidates for being cross-distro. And
>>> really, I was thinking maybe these should be part of the core upstream
>>> udev/systemd rules set, rather than something we ship here.
>>
>> Okay. The trick will be to standardize the systemd_wants name ..
> 
> Perhaps rdma-core should go with rdma-core.service? We were shipping a
> package called 'rdma' that carried that.

Whatever the service file is, that's what the name is.  I'm partial to
just leaving it as rdma.service.  The -core suffix doesn't add anything
of value IMO, and we really are initializing the entire rdma stack minus
just those upper layer protocols that have their own setup.

>>>>> +# When we detect a new verbs device is added to the system, set the node
>>>>> +# description on that device
>>>>> +# If rdma-ndd is installed, defer the setting of the node description to it.
>>>>> +SUBSYSTEM=="infiniband", KERNEL=="*", ACTION=="add", TEST!="/usr/sbin/rdma-ndd", RUN+="/bin/bash -c 'sleep 1; echo -n `hostname -s` %k > /sys/class/infiniband/%k/node_desc'"
>>>>
>>>> Shouldn't this udev drop-in by in the rdma-ndd package?
>>>
>>> Honestly don't even have a clue what rdma-ndd is. :) Don't remember what
>>> Doug said about this one...
>>
>> Guess I didn't read closely enough, this is used if rdma-ndd is not
>> installed..

A bit of a chicken and egg issue here isn't there?  Wasn't rdma-ndd part
of ibutils?  And since ibutils isn't in rdma-core, how do we know if
it's installed?

>> So something like that should be upstream, but the 'sleep 1' is ugly -
>> this should probably be a systemd service that runs after
>> network-online.target not as a script run from udev?
>>
>> rdma-ndd dynamically sets the NodeDescription to the hostname in the
>> adaptor for the subnet manager/tools to ready. I guess this hunk is
>> setting the NodeDescription one-shot at boot..
> 
> Rather than having this janky udev rule, what if we simply made rdma-ndd
> part of what's installed with rdma-core, rather than something found in
> yet another infiniband package? (Looks like it's in infiniband-diags,
> wasn't even aware rdma-ndd existed until looking at this here).

It's probably a good candidate to be pulled back to rdma-core.  Ira?

-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
    GPG Key ID: 0E572FDD


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

^ permalink raw reply

* Re: [PATCH rdma-core 2/4] glue/redhat: add udev/systemd/etc infrastructure bits
From: Jason Gunthorpe @ 2016-10-17 18:56 UTC (permalink / raw)
  To: Jarod Wilson
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Doug Ledford, Weiny, Ira,
	Hefty, Sean
In-Reply-To: <20161017182037.GK14983-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

On Mon, Oct 17, 2016 at 02:20:37PM -0400, Jarod Wilson wrote:

> > > > > diff --git a/glue/redhat/ibacm.service b/glue/redhat/ibacm.service
> > > > > new file mode 100644
> > > > > index 0000000..1cd031a
> > > > > +++ b/glue/redhat/ibacm.service
> > > > 
> > > > Can we just put this in ibacm/ ?
> > > 
> > > Probably.
> > 
> > Okay, the only thing I really don't like being upstream is the
> > opensm.service..
> > 
> > Do you know why acm needs that?
> 
> I think Doug already attempted to address this elsewhere in the thread,
> and he'd know better than me.

srp_daemon not being able to handle a change in prefix makes sense.

But that doesn't explain what problem ibacm has..

To my mind, depending on something like opensm indicates the daemon
has a bug - eg it cannot handle dynamic subnet changes. So lets at
least be clear on what the bugs we are working around are, ask if they
have been fixed, etc.

Sean, do you know why ibacm would need to be started after opensm?

> > Okay. The trick will be to standardize the systemd_wants name ..
> 
> Perhaps rdma-core should go with rdma-core.service? We were shipping a
> package called 'rdma' that carried that.

Maybe, but I'd like to have an overall systemd plan..

If we can't have a .target then sure, this is probably the best
way..

> > rdma-ndd dynamically sets the NodeDescription to the hostname in the
> > adaptor for the subnet manager/tools to ready. I guess this hunk is
> > setting the NodeDescription one-shot at boot..
> 
> Rather than having this janky udev rule, what if we simply made rdma-ndd
> part of what's installed with rdma-core, rather than something found in
> yet another infiniband package? (Looks like it's in infiniband-diags,
> wasn't even aware rdma-ndd existed until looking at this here).

Yep, very good idea.

Ira? What do you think?

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: iscsi_trx going into D state
From: Robert LeBlanc @ 2016-10-17 19:03 UTC (permalink / raw)
  To: Zhu Lingshan
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-scsi-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <CAANLjFobXiBO2tXxTBB-8BQjM8FC0wmxdxQvEd6Rp=1LZkrvpA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

In addition, on the client we see:

----------------
Robert LeBlanc
PGP Fingerprint 79A2 9CA4 6CC4 45DD A904  C70E E654 3BB2 FA62 B9F1


On Mon, Oct 17, 2016 at 10:32 AM, Robert LeBlanc <robert-4JaGZRWAfWbajFs6igw21g@public.gmane.org> wrote:
> Some more info as we hit this this morning. We have volumes mirrored
> between two targets and we had one target on the kernel with the three
> patches mentioned in this thread [0][1][2] and the other was on a
> kernel without the patches. We decided that after a week and a half we
> wanted to get both targets on the same kernel so we rebooted the
> non-patched target. Within an hour we saw iSCSI in D state with the
> same stack trace so it seems that we are not hitting any of the
> WARN_ON lines. We are getting both iscsi_trx and iscsi_np both in D
> state, this time we have two iscsi_trx processes in D state. I don't
> know if stale sessions on the clients could be contributing to this
> issue (the target trying to close non-existent sessions??). This is on
> 4.4.23. Any more debug info we can throw at this problem to help?
>
> Thank you,
> Robert LeBlanc
>
> # ps aux | grep D | grep iscsi
> root     16525  0.0  0.0      0     0 ?        D    08:50   0:00 [iscsi_np]
> root     16614  0.0  0.0      0     0 ?        D    08:50   0:00 [iscsi_trx]
> root     16674  0.0  0.0      0     0 ?        D    08:50   0:00 [iscsi_trx]
>
> # for i in 16525 16614 16674; do echo $i; cat /proc/$i/stack; done
> 16525
> [<ffffffff814f0d5f>] iscsit_stop_session+0x19f/0x1d0
> [<ffffffff814e2516>] iscsi_check_for_session_reinstatement+0x1e6/0x270
> [<ffffffff814e4ed0>] iscsi_target_check_for_existing_instances+0x30/0x40
> [<ffffffff814e5020>] iscsi_target_do_login+0x140/0x640
> [<ffffffff814e63bc>] iscsi_target_start_negotiation+0x1c/0xb0
> [<ffffffff814e410b>] iscsi_target_login_thread+0xa9b/0xfc0
> [<ffffffff8109c748>] kthread+0xd8/0xf0
> [<ffffffff8172018f>] ret_from_fork+0x3f/0x70
> [<ffffffffffffffff>] 0xffffffffffffffff
> 16614
> [<ffffffff814cca79>] target_wait_for_sess_cmds+0x49/0x1a0
> [<ffffffffa064692b>] isert_wait_conn+0x1ab/0x2f0 [ib_isert]
> [<ffffffff814f0ef2>] iscsit_close_connection+0x162/0x870
> [<ffffffff814df9bf>] iscsit_take_action_for_connection_exit+0x7f/0x100
> [<ffffffff814f00a0>] iscsi_target_rx_thread+0x5a0/0xe80
> [<ffffffff8109c748>] kthread+0xd8/0xf0
> [<ffffffff8172018f>] ret_from_fork+0x3f/0x70
> [<ffffffffffffffff>] 0xffffffffffffffff
> 16674
> [<ffffffff814cca79>] target_wait_for_sess_cmds+0x49/0x1a0
> [<ffffffffa064692b>] isert_wait_conn+0x1ab/0x2f0 [ib_isert]
> [<ffffffff814f0ef2>] iscsit_close_connection+0x162/0x870
> [<ffffffff814df9bf>] iscsit_take_action_for_connection_exit+0x7f/0x100
> [<ffffffff814f00a0>] iscsi_target_rx_thread+0x5a0/0xe80
> [<ffffffff8109c748>] kthread+0xd8/0xf0
> [<ffffffff8172018f>] ret_from_fork+0x3f/0x70
> [<ffffffffffffffff>] 0xffffffffffffffff
>
>
> [0] https://www.spinics.net/lists/target-devel/msg13463.html
> [1] http://marc.info/?l=linux-scsi&m=147282568910535&w=2
> [2] http://www.spinics.net/lists/linux-scsi/msg100221.html
> ----------------
> Robert LeBlanc
> PGP Fingerprint 79A2 9CA4 6CC4 45DD A904  C70E E654 3BB2 FA62 B9F1
>
>
> On Fri, Oct 7, 2016 at 8:59 PM, Zhu Lingshan <lszhu-IBi9RG/b67k@public.gmane.org> wrote:
>> Hi Robert,
>>
>> I also see this issue, but this is not the only code path can trigger this
>> problem, I think you may also see iscsi_np in D status. I fixed one code
>> path whitch still not merged to mainline. I will forward you my patch later.
>> Note: my patch only fixed one code path, you may see other call statck with
>> D status.
>>
>> Thanks,
>> BR
>> Zhu Lingshan
>>
>>
>> 在 2016/10/1 1:14, Robert LeBlanc 写道:
>>>
>>> We are having a reoccurring problem where iscsi_trx is going into D
>>> state. It seems like it is waiting for a session tear down to happen
>>> or something, but keeps waiting. We have to reboot these targets on
>>> occasion. This is running the 4.4.12 kernel and we have seen it on
>>> several previous 4.4.x and 4.2.x kernels. There is no message in dmesg
>>> or /var/log/messages. This seems to happen with increased frequency
>>> when we have a disruption in our Infiniband fabric, but can happen
>>> without any changes to the fabric (other than hosts rebooting).
>>>
>>> # ps aux | grep iscsi | grep D
>>> root      4185  0.0  0.0      0     0 ?        D    Sep29   0:00
>>> [iscsi_trx]
>>> root     18505  0.0  0.0      0     0 ?        D    Sep29   0:00
>>> [iscsi_np]
>>>
>>> # cat /proc/4185/stack
>>> [<ffffffff814cc999>] target_wait_for_sess_cmds+0x49/0x1a0
>>> [<ffffffffa087292b>] isert_wait_conn+0x1ab/0x2f0 [ib_isert]
>>> [<ffffffff814f0de2>] iscsit_close_connection+0x162/0x840
>>> [<ffffffff814df8df>] iscsit_take_action_for_connection_exit+0x7f/0x100
>>> [<ffffffff814effc0>] iscsi_target_rx_thread+0x5a0/0xe80
>>> [<ffffffff8109c6f8>] kthread+0xd8/0xf0
>>> [<ffffffff8172004f>] ret_from_fork+0x3f/0x70
>>> [<ffffffffffffffff>] 0xffffffffffffffff
>>>
>>> # cat /proc/18505/stack
>>> [<ffffffff814f0c71>] iscsit_stop_session+0x1b1/0x1c0
>>> [<ffffffff814e2436>] iscsi_check_for_session_reinstatement+0x1e6/0x270
>>> [<ffffffff814e4df0>] iscsi_target_check_for_existing_instances+0x30/0x40
>>> [<ffffffff814e4f40>] iscsi_target_do_login+0x140/0x640
>>> [<ffffffff814e62dc>] iscsi_target_start_negotiation+0x1c/0xb0
>>> [<ffffffff814e402b>] iscsi_target_login_thread+0xa9b/0xfc0
>>> [<ffffffff8109c6f8>] kthread+0xd8/0xf0
>>> [<ffffffff8172004f>] ret_from_fork+0x3f/0x70
>>> [<ffffffffffffffff>] 0xffffffffffffffff
>>>
>>> What can we do to help get this resolved?
>>>
>>> Thanks,
>>>
>>> ----------------
>>> Robert LeBlanc
>>> PGP Fingerprint 79A2 9CA4 6CC4 45DD A904  C70E E654 3BB2 FA62 B9F1
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>>> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH rdma-core 4/4] glue/redhat/spec: build split rpm packages
From: Jason Gunthorpe @ 2016-10-17 19:07 UTC (permalink / raw)
  To: Jarod Wilson; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20161017184506.GL14983-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

On Mon, Oct 17, 2016 at 02:45:06PM -0400, Jarod Wilson wrote:

> > > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libcxgb3-11-1.el7.x86_64.rpm
> > > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libcxgb4-11-1.el7.x86_64.rpm
> > > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libhfi1-11-1.el7.x86_64.rpm
> > > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libi40iw-11-1.el7.x86_64.rpm
> > > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libipathverbs-11-1.el7.x86_64.rpm
> > > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libmlx4-11-1.el7.x86_64.rpm
> > > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libmlx5-11-1.el7.x86_64.rpm
> > > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libmthca-11-1.el7.x86_64.rpm
> > > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libnes-11-1.el7.x86_64.rpm
> > > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/libocrdma-11-1.el7.x86_64.rpm
> > > Wrote: /home/jwilson/rpmbuild/RPMS/x86_64/librxe-11-1.el7.x86_64.rpm
> > 
> > Does this mean RH is not going to do a single package for the
> > providers? You know another 5 or so are coming..
> 
> Putting all the providers in a single sub-package is certainly something
> we could do. With rpm virtual Provides and Obsoletes, we could make the
> upgrade path transparent to at least yum/dnf/rpm, but it might still
> confuse people who go looking for the same package they've always had
> installed, so it could be something we do in Fedora and the next RHEL
> major release, rather than in a current RHEL minor update.

I would strongly encoruage this - the current scheme is silly, you
need to know to look for the right provider to get things working
(which is very much unlike the way the kernel modules work).

Suggest to dump the providers in libiverbs or add a ibverbs-providers
package..

Or at least start adding new providers (Eg rxe,hfi) to a -providers package.

> > > +install -D -m0644 Documentation/{ibacm,ibsrpdm,libibcm,libibverbs,librdmacm,rxe}.md %{buildroot}/%{_docdir}/%{name}-%{version}/
> > > +install -D -m0644 README.md %{buildroot}/%{_docdir}/%{name}-%{version}/
> > 
> > I guess README should go in that patch I sent you..
> 
> D'oh, yeah, I'll mix that in here locally.

I think you can just add ../README.md to the
Documentation/CMakeFile.txt

> > > +%{buildroot}/%{_bindir}/ib_acme -D . -O
> > > +# Fixup a multilib conflict in ibacm_opts.cfg:
> > > +sed -i -e '/^# Specifies the directory of the provider libraries$/ a\
> > > +# Use /usr/lib64/ibacm on 64bit, /usr/lib/libacm on 32bit.
> > > +' -e 's%^\(# provider_lib_path
> > > /usr/\)lib\(64\)\?/ibacm$%\1lib64/ibacm%' ibacm_opts.cfg
> > 
> > Hum? I'm pretty sure this is basically fixed in the code now, was done here
> > 5eebdb9baaaae420a4bb16e586a96807823916a0
> > 
> > Adjusting the comment like that doesn't really make sense, the acm
> > daemon has a fixed endianness and looks in a single place to load the
> > plugin. If someone wants to use 32 bit plugins they have to install
> > the 32 bit acm daemon, which would have the 32 bit path in the sample
> > conf file...
> 
> This was just copy and paste from our existing libacm spec, might well be
> something that was fixed and I just missed it.

It looks OK as-is to me, I'd drop it now.

> They weren't getting installed, so I threw that hack in, meant to
> actually say something about that, got lost in the shuffle. I'll
> double-check if they're still not getting installed... Okay, they're
> getting installed now. May have just been a transient error with an
> earlier tarball, or something else I did wrong. I'll drop that bit.

How strange.. FWIW, the tarball should be built with git-archive ..

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* RE: [PATCH rdma-core 2/4] glue/redhat: add udev/systemd/etc infrastructure bits
From: Weiny, Ira @ 2016-10-17 19:10 UTC (permalink / raw)
  To: Jason Gunthorpe, Jarod Wilson
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Doug Ledford,
	Hefty, Sean
In-Reply-To: <20161017185657.GA8122-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

 
> > > rdma-ndd dynamically sets the NodeDescription to the hostname in the
> > > adaptor for the subnet manager/tools to ready. I guess this hunk is
> > > setting the NodeDescription one-shot at boot..
> >
> > Rather than having this janky udev rule, what if we simply made
> > rdma-ndd part of what's installed with rdma-core, rather than
> > something found in yet another infiniband package? (Looks like it's in
> > infiniband-diags, wasn't even aware rdma-ndd existed until looking at this
> here).
> 
> Yep, very good idea.

Yep, very good idea...

> 
> Ira? What do you think?

Yes, I've been trying to find time to make a patch which adds rdma-ndd into the rdma-core.  I absolutely agree it should be part of rdma-core as it is much better than the 1 time shot of the start up scripts.

What I have been worried about is conflicts between infiniband-diags and the new rdma-core.  RH made a separate package out of rdma-ndd so that would be easy but I don't think other distros have.

So how do you obsolete "part" of a package?

Ira

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* ibacm cleanups
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA

This series fixed various sparse issues in ibacm, makes it use
the common list helpers and removes various cruft.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH 01/13] ibacm: remove HAVE_NETLINK
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>

We now always require netlink support

Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
 buildlib/config.h.in |  3 ---
 ibacm/src/acm.c      | 25 +------------------------
 2 files changed, 1 insertion(+), 27 deletions(-)

diff --git a/buildlib/config.h.in b/buildlib/config.h.in
index 2378180..e4e7b9e 100644
--- a/buildlib/config.h.in
+++ b/buildlib/config.h.in
@@ -6,9 +6,6 @@
 #define HAVE_TYPEOF 1
 #define HAVE_ISBLANK 1
 
-// FIXME: Remove this, we provide the netlink kernel headers ibacm needs
-#define HAVE_NETLINK 1
-
 // FIXME: Remove this, The cmake version hard-requires new style CLOEXEC support
 #define STREAM_CLOEXEC "e"
 
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index befe942..01ba4e1 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -44,10 +44,8 @@
 #include <infiniband/acm_prov.h>
 #include <infiniband/umad.h>
 #include <infiniband/verbs.h>
-#ifdef HAVE_NETLINK
 #include <infiniband/umad_types.h>
 #include <infiniband/umad_sa.h>
-#endif
 #include <dlist.h>
 #include <dlfcn.h> 
 #include <search.h>
@@ -57,19 +55,15 @@
 #include <netinet/in.h>
 #include <linux/netlink.h>
 #include <linux/rtnetlink.h>
-#ifdef HAVE_NETLINK
 #include <rdma/rdma_netlink.h>
 #include <rdma/ib_user_sa.h>
-#endif
 #include <poll.h>
 #include <inttypes.h>
 #include "acm_mad.h"
 #include "acm_util.h"
-#ifdef HAVE_NETLINK
 #if !defined(RDMA_NL_LS_F_ERR)
 	#include "acm_netlink.h"
 #endif
-#endif
 
 #define src_out     data[0]
 #define src_index   data[1]
@@ -78,9 +72,7 @@
 #define MAX_EP_ADDR 4
 #define NL_MSG_BUF_SIZE 4096
 #define ACM_PROV_NAME_SIZE 64
-#ifdef HAVE_NETLINK
 #define NL_CLIENT_INDEX 0
-#endif
 
 struct acmc_subnet {
 	DLIST_ENTRY            entry;
@@ -167,7 +159,6 @@ struct acmc_sa_req {
 	struct acm_sa_mad	mad;
 };
 
-#ifdef HAVE_NETLINK
 struct acm_nl_path {
 	struct nlattr			attr_hdr;
 	struct ib_path_rec_data		rec;
@@ -182,7 +173,6 @@ struct acm_nl_msg {
 		struct acm_nl_path		path[0];
 	};
 };
-#endif
 
 static char def_prov_name[ACM_PROV_NAME_SIZE] = "ibacmp";
 static DLIST_ENTRY provider_list;
@@ -205,9 +195,7 @@ static struct acmc_ep *acm_find_ep(struct acmc_port *port, uint16_t pkey);
 static int acm_ep_insert_addr(struct acmc_ep *ep, const char *name, uint8_t *addr,
 			      size_t addr_len, uint8_t addr_type);
 static void acm_event_handler(struct acmc_device *dev);
-#ifdef HAVE_NETLINK
 static int acm_nl_send(SOCKET sock, struct acm_msg *msg);
-#endif
 
 static struct sa_data {
 	int		timeout;
@@ -502,11 +490,9 @@ int acm_resolve_response(uint64_t id, struct acm_msg *msg)
 		goto release;
 	}
 
-#ifdef HAVE_NETLINK
 	if (id == NL_CLIENT_INDEX)
 		ret = acm_nl_send(client->sock, msg);
 	else
-#endif
 		ret = send(client->sock, (char *) msg, msg->hdr.length, 0);
 
 	if (ret != msg->hdr.length)
@@ -639,10 +625,8 @@ static void acm_svr_accept(void)
 	}
 
 	for (i = 0; i < FD_SETSIZE - 1; i++) {
-	#ifdef HAVE_NETLINK
 		if (i == NL_CLIENT_INDEX)
 			continue;
-	#endif
 		if (!atomic_get(&client_array[i].refcnt))
 			break;
 	}
@@ -1392,7 +1376,6 @@ static void acm_ipnl_handler(void)
 	}
 }
 
-#ifdef HAVE_NETLINK
 static int acm_nl_send(SOCKET sock, struct acm_msg *msg)
 {
 	struct sockaddr_nl dst_addr;
@@ -1714,7 +1697,6 @@ static int acm_init_nl(void)
 	client_array[NL_CLIENT_INDEX].sock = nl_rcv_socket;
 	return 0;
 }
-#endif
 
 static void acm_server(void)
 {
@@ -1730,11 +1712,10 @@ static void acm_server(void)
 		acm_log(0, "ERROR - server listen failed\n");
 		return;
 	}
-#ifdef HAVE_NETLINK
+
 	ret = acm_init_nl();
 	if (ret)
 		acm_log(1, "Warn - Netlink init failed\n");
-#endif
 
 	while (1) {
 		n = (int) listen_socket;
@@ -1773,11 +1754,9 @@ static void acm_server(void)
 			if (client_array[i].sock != INVALID_SOCKET &&
 				FD_ISSET(client_array[i].sock, &readfds)) {
 				acm_log(2, "receiving from client %d\n", i);
-			#ifdef HAVE_NETLINK
 				if (i == NL_CLIENT_INDEX)
 					acm_nl_receive(&client_array[i]);
 				else
-			#endif
 					acm_svr_receive(&client_array[i]);
 			}
 		}
@@ -3143,10 +3122,8 @@ int CDECL_FUNC main(int argc, char **argv)
 	acm_server();
 
 	acm_log(0, "shutting down\n");
-#ifdef HAVE_NETLINK
 	if (client_array[NL_CLIENT_INDEX].sock != INVALID_SOCKET)
 		close(client_array[NL_CLIENT_INDEX].sock);
-#endif
 	acm_close_providers();
 	acm_stop_sa_handler();
 	umad_done();
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 02/13] ibacm: use pthread_mutex_t directly
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>

Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
 ibacm/linux/libacm_linux.c |   4 +-
 ibacm/linux/osd.h          |   5 --
 ibacm/prov/acmp/src/acmp.c | 132 ++++++++++++++++++++++-----------------------
 ibacm/src/acm.c            |  42 +++++++--------
 ibacm/src/libacm.c         |  22 ++++----
 5 files changed, 100 insertions(+), 105 deletions(-)

diff --git a/ibacm/linux/libacm_linux.c b/ibacm/linux/libacm_linux.c
index a3f6715..2b8a910 100644
--- a/ibacm/linux/libacm_linux.c
+++ b/ibacm/linux/libacm_linux.c
@@ -29,9 +29,9 @@
 
 #include <osd.h>
 
-lock_t lock;
+pthread_mutex_t lock;
 
 static void __attribute__((constructor)) lib_init(void)
 {
-	lock_init(&lock);
+	pthread_mutex_init(&lock, NULL);
 }
diff --git a/ibacm/linux/osd.h b/ibacm/linux/osd.h
index c1e7d99..3580cc3 100644
--- a/ibacm/linux/osd.h
+++ b/ibacm/linux/osd.h
@@ -115,11 +115,6 @@ static inline int event_wait(event_t *e, int timeout)
 	return ret;
 }
 
-#define lock_t       pthread_mutex_t
-#define lock_init(x) pthread_mutex_init(x, NULL)
-#define lock_acquire pthread_mutex_lock
-#define lock_release pthread_mutex_unlock
-
 #define osd_init()  0
 #define osd_close()
 
diff --git a/ibacm/prov/acmp/src/acmp.c b/ibacm/prov/acmp/src/acmp.c
index 806320f..24d2b70 100644
--- a/ibacm/prov/acmp/src/acmp.c
+++ b/ibacm/prov/acmp/src/acmp.c
@@ -115,7 +115,7 @@ struct acmp_dest {
 	uint64_t               req_id;
 	DLIST_ENTRY            req_queue;
 	uint32_t               remote_qpn;
-	lock_t                 lock;
+	pthread_mutex_t        lock;
 	enum acmp_state        state;
 	atomic_t               refcnt;
 	uint64_t	       addr_timeout;
@@ -130,7 +130,7 @@ struct acmp_port {
 	struct acmp_device  *dev;
 	const struct acm_port *port;
 	DLIST_ENTRY         ep_list;
-	lock_t              lock;
+	pthread_mutex_t     lock;
 	struct acmp_dest    sa_dest;
 	enum ibv_port_state state;
 	enum ibv_mtu        mtu;
@@ -181,7 +181,7 @@ struct acmp_ep {
 	uint16_t              pkey_index;
 	uint16_t	      pkey;
 	const struct acm_endpoint *endpoint;
-	lock_t                lock;
+	pthread_mutex_t       lock;
 	struct acmp_send_queue resolve_queue;
 	struct acmp_send_queue resp_queue;
 	DLIST_ENTRY           active_queue;
@@ -250,7 +250,7 @@ static struct acm_provider def_prov = {
 };
 
 static DLIST_ENTRY acmp_dev_list;
-static lock_t acmp_dev_lock;
+static pthread_mutex_t acmp_dev_lock;
 
 static atomic_t g_tid;
 static DLIST_ENTRY timeout_list;
@@ -304,7 +304,7 @@ acmp_init_dest(struct acmp_dest *dest, uint8_t addr_type,
 	DListInit(&dest->req_queue);
 	atomic_init(&dest->refcnt);
 	atomic_set(&dest->refcnt, 1);
-	lock_init(&dest->lock);
+	pthread_mutex_init(&dest->lock, NULL);
 	if (size)
 		acmp_set_dest_addr(dest, addr_type, addr, size);
 	dest->state = ACMP_INIT;
@@ -374,7 +374,7 @@ acmp_acquire_dest(struct acmp_ep *ep, uint8_t addr_type, const uint8_t *addr)
 	acm_format_name(2, log_data, sizeof log_data,
 			addr_type, addr, ACM_MAX_ADDRESS);
 	acm_log(2, "%s\n", log_data);
-	lock_acquire(&ep->lock);
+	pthread_mutex_lock(&ep->lock);
 	dest = acmp_get_dest(ep, addr_type, addr);
 	if (dest && dest->state == ACMP_READY &&
 	    dest->addr_timeout != (uint64_t)~0ULL) {
@@ -396,7 +396,7 @@ acmp_acquire_dest(struct acmp_ep *ep, uint8_t addr_type, const uint8_t *addr)
 			(void) atomic_inc(&dest->refcnt);
 		}
 	}
-	lock_release(&ep->lock);
+	pthread_mutex_unlock(&ep->lock);
 	return dest;
 }
 
@@ -504,7 +504,7 @@ static void acmp_post_send(struct acmp_send_queue *queue, struct acmp_send_msg *
 	struct ibv_send_wr *bad_wr;
 
 	msg->req_queue = queue;
-	lock_acquire(&ep->lock);
+	pthread_mutex_lock(&ep->lock);
 	if (queue->credits) {
 		acm_log(2, "posting send to QP\n");
 		queue->credits--;
@@ -514,7 +514,7 @@ static void acmp_post_send(struct acmp_send_queue *queue, struct acmp_send_msg *
 		acm_log(2, "no sends available, queuing message\n");
 		DListInsertTail(&msg->entry, &queue->pending);
 	}
-	lock_release(&ep->lock);
+	pthread_mutex_unlock(&ep->lock);
 }
 
 static void acmp_post_recv(struct acmp_ep *ep, uint64_t address)
@@ -557,7 +557,7 @@ static void acmp_complete_send(struct acmp_send_msg *msg)
 {
 	struct acmp_ep *ep = msg->ep;
 
-	lock_acquire(&ep->lock);
+	pthread_mutex_lock(&ep->lock);
 	DListRemove(&msg->entry);
 	if (msg->tries) {
 		acm_log(2, "waiting for response\n");
@@ -570,7 +570,7 @@ static void acmp_complete_send(struct acmp_send_msg *msg)
 		acmp_send_available(ep, msg->req_queue);
 		acmp_free_send(msg);
 	}
-	lock_release(&ep->lock);
+	pthread_mutex_unlock(&ep->lock);
 }
 
 static struct acmp_send_msg *acmp_get_request(struct acmp_ep *ep, uint64_t tid, int *free)
@@ -580,7 +580,7 @@ static struct acmp_send_msg *acmp_get_request(struct acmp_ep *ep, uint64_t tid,
 	DLIST_ENTRY *entry, *next;
 
 	acm_log(2, "\n");
-	lock_acquire(&ep->lock);
+	pthread_mutex_lock(&ep->lock);
 	for (entry = ep->wait_queue.Next; entry != &ep->wait_queue; entry = next) {
 		next = entry->Next;
 		msg = container_of(entry, struct acmp_send_msg, entry);
@@ -608,7 +608,7 @@ static struct acmp_send_msg *acmp_get_request(struct acmp_ep *ep, uint64_t tid,
 		}
 	}
 unlock:
-	lock_release(&ep->lock);
+	pthread_mutex_unlock(&ep->lock);
 	return req;
 }
 
@@ -688,13 +688,13 @@ acmp_init_path_av(struct acmp_port *port, struct acmp_dest *dest)
 	flow_hop = ntohl(dest->path.flowlabel_hoplimit);
 	dest->av.is_global = 1;
 	dest->av.grh.flow_label = (flow_hop >> 8) & 0xFFFFF;
-	lock_acquire(&port->lock);
+	pthread_mutex_lock(&port->lock);
 	if (port->port) 
 		dest->av.grh.sgid_index = acm_gid_index(
 		   (struct acm_port *) port->port, &dest->path.sgid);
 	else
 		dest->av.grh.sgid_index = 0;
-	lock_release(&port->lock);
+	pthread_mutex_unlock(&port->lock);
 	dest->av.grh.hop_limit = (uint8_t) flow_hop;
 	dest->av.grh.traffic_class = dest->path.tclass;
 }
@@ -710,7 +710,7 @@ static void acmp_process_join_resp(struct acm_sa_mad *sa_mad)
 	mad = (struct ib_sa_mad *) &sa_mad->sa_mad;
 	acm_log(1, "response status: 0x%x, mad status: 0x%x\n",
 		sa_mad->umad.status, mad->status);
-	lock_acquire(&ep->lock);
+	pthread_mutex_lock(&ep->lock);
 	if (sa_mad->umad.status) {
 		acm_log(0, "ERROR - send join failed 0x%x\n", sa_mad->umad.status);
 		goto out;
@@ -753,7 +753,7 @@ static void acmp_process_join_resp(struct acm_sa_mad *sa_mad)
 	acm_log(1, "join successful\n");
 out:
 	acm_free_sa_mad(sa_mad);
-	lock_release(&ep->lock);
+	pthread_mutex_unlock(&ep->lock);
 }
 
 static uint8_t
@@ -975,20 +975,20 @@ acmp_complete_queued_req(struct acmp_dest *dest, uint8_t status)
 	DLIST_ENTRY *entry;
 
 	acm_log(2, "status %d\n", status);
-	lock_acquire(&dest->lock);
+	pthread_mutex_lock(&dest->lock);
 	while (!DListEmpty(&dest->req_queue)) {
 		entry = dest->req_queue.Next;
 		DListRemove(entry);
 		req = container_of(entry, struct acmp_request, entry);
-		lock_release(&dest->lock);
+		pthread_mutex_unlock(&dest->lock);
 
 		acm_log(2, "completing request, client %" PRIu64 "\n", req->id);
 		acmp_resolve_response(req->id, &req->msg, dest, status);
 		acmp_free_req(req);
 
-		lock_acquire(&dest->lock);
+		pthread_mutex_lock(&dest->lock);
 	}
-	lock_release(&dest->lock);
+	pthread_mutex_unlock(&dest->lock);
 }
 
 static void
@@ -1005,10 +1005,10 @@ acmp_dest_sa_resp(struct acm_sa_mad *mad)
 	}
 	acm_log(2, "%s status=0x%x\n", dest->name, status);
 
-	lock_acquire(&dest->lock);
+	pthread_mutex_lock(&dest->lock);
 	if (dest->state != ACMP_QUERY_ROUTE) {
 		acm_log(1, "notice - discarding SA response\n");
-		lock_release(&dest->lock);
+		pthread_mutex_unlock(&dest->lock);
 		goto out;
 	}
 
@@ -1023,7 +1023,7 @@ acmp_dest_sa_resp(struct acm_sa_mad *mad)
 	} else {
 		dest->state = ACMP_INIT;
 	}
-	lock_release(&dest->lock);
+	pthread_mutex_unlock(&dest->lock);
 
 	acmp_complete_queued_req(dest, status);
 out:
@@ -1039,9 +1039,9 @@ acmp_resolve_sa_resp(struct acm_sa_mad *mad)
 	acm_log(2, "\n");
 	acmp_dest_sa_resp(mad);
 
-	lock_acquire(&dest->lock);
+	pthread_mutex_lock(&dest->lock);
 	send_resp = (dest->state == ACMP_READY);
-	lock_release(&dest->lock);
+	pthread_mutex_unlock(&dest->lock);
 
 	if (send_resp)
 		acmp_send_addr_resp(dest->ep, dest);
@@ -1093,7 +1093,7 @@ acmp_process_addr_req(struct acmp_ep *ep, struct ibv_wc *wc, struct acm_mad *mad
 	if (addr)
 		dest->req_id = mad->tid;
 
-	lock_acquire(&dest->lock);
+	pthread_mutex_lock(&dest->lock);
 	acm_log(2, "dest state %d\n", dest->state);
 	switch (dest->state) {
 	case ACMP_READY:
@@ -1120,11 +1120,11 @@ acmp_process_addr_req(struct acmp_ep *ep, struct ibv_wc *wc, struct acm_mad *mad
 		}
 		/* fall through */
 	default:
-		lock_release(&dest->lock);
+		pthread_mutex_unlock(&dest->lock);
 		acmp_put_dest(dest);
 		return;
 	}
-	lock_release(&dest->lock);
+	pthread_mutex_unlock(&dest->lock);
 	acmp_complete_queued_req(dest, status);
 
 	if (addr && !status) {
@@ -1149,9 +1149,9 @@ acmp_process_addr_resp(struct acmp_send_msg *msg, struct ibv_wc *wc, struct acm_
 	}
 	acm_log(2, "resp status 0x%x\n", status);
 
-	lock_acquire(&dest->lock);
+	pthread_mutex_lock(&dest->lock);
 	if (dest->state != ACMP_QUERY_ADDR) {
-		lock_release(&dest->lock);
+		pthread_mutex_unlock(&dest->lock);
 		goto put;
 	}
 
@@ -1163,7 +1163,7 @@ acmp_process_addr_resp(struct acmp_send_msg *msg, struct ibv_wc *wc, struct acm_
 			} else {
 				status = acmp_resolve_path_sa(msg->ep, dest, acmp_dest_sa_resp);
 				if (!status) {
-					lock_release(&dest->lock);
+					pthread_mutex_unlock(&dest->lock);
 					goto put;
 				}
 			}
@@ -1171,7 +1171,7 @@ acmp_process_addr_resp(struct acmp_send_msg *msg, struct ibv_wc *wc, struct acm_
 	} else {
 		dest->state = ACMP_INIT;
 	}
-	lock_release(&dest->lock);
+	pthread_mutex_unlock(&dest->lock);
 
 	acmp_complete_queued_req(dest, status);
 put:
@@ -1578,34 +1578,34 @@ static void *acmp_retry_handler(void *context)
 		}
 
 		next_expire = -1;
-		lock_acquire(&acmp_dev_lock);
+		pthread_mutex_lock(&acmp_dev_lock);
 		for (dev_entry = acmp_dev_list.Next; dev_entry != &acmp_dev_list;
 		     dev_entry = dev_entry->Next) {
 
 			dev = container_of(dev_entry, struct acmp_device, entry);
-			lock_release(&acmp_dev_lock);
+			pthread_mutex_unlock(&acmp_dev_lock);
 
 			for (i = 0; i < dev->port_cnt; i++) {
 				port = &dev->port[i];
 
-				lock_acquire(&port->lock);
+				pthread_mutex_lock(&port->lock);
 				for (ep_entry = port->ep_list.Next;
 				     ep_entry != &port->ep_list;
 				     ep_entry = ep_entry->Next) {
 
 					ep = container_of(ep_entry, struct acmp_ep, entry);
-					lock_release(&port->lock);
-					lock_acquire(&ep->lock);
+					pthread_mutex_unlock(&port->lock);
+					pthread_mutex_lock(&ep->lock);
 					if (!DListEmpty(&ep->wait_queue))
 						acmp_process_wait_queue(ep, &next_expire);
-					lock_release(&ep->lock);
-					lock_acquire(&port->lock);
+					pthread_mutex_unlock(&ep->lock);
+					pthread_mutex_lock(&port->lock);
 				}
-				lock_release(&port->lock);
+				pthread_mutex_unlock(&port->lock);
 			}
-			lock_acquire(&acmp_dev_lock);
+			pthread_mutex_lock(&acmp_dev_lock);
 		}
-		lock_release(&acmp_dev_lock);
+		pthread_mutex_unlock(&acmp_dev_lock);
 
 		acmp_process_timeouts();
 		wait = (int) (next_expire - time_stamp_ms());
@@ -1844,7 +1844,7 @@ acmp_resolve_dest(struct acmp_ep *ep, struct acm_msg *msg, uint64_t id)
 		return acmp_resolve_response(id, msg, NULL, ACM_STATUS_ENOMEM);
 	}
 
-	lock_acquire(&dest->lock);
+	pthread_mutex_lock(&dest->lock);
 test:
 	switch (dest->state) {
 	case ACMP_READY:
@@ -1885,10 +1885,10 @@ queue:
 			break;
 		}
 		ret = 0;
-		lock_release(&dest->lock);
+		pthread_mutex_unlock(&dest->lock);
 		goto put;
 	}
-	lock_release(&dest->lock);
+	pthread_mutex_unlock(&dest->lock);
 	ret = acmp_resolve_response(id, msg, dest, status);
 put:
 	acmp_put_dest(dest);
@@ -1920,7 +1920,7 @@ acmp_resolve_path(struct acmp_ep *ep, struct acm_msg *msg, uint64_t id)
 		return acmp_resolve_response(id, msg, NULL, ACM_STATUS_ENOMEM);
 	}
 
-	lock_acquire(&dest->lock);
+	pthread_mutex_lock(&dest->lock);
 test:
 	switch (dest->state) {
 	case ACMP_READY:
@@ -1953,10 +1953,10 @@ test:
 			break;
 		}
 		ret = 0;
-		lock_release(&dest->lock);
+		pthread_mutex_unlock(&dest->lock);
 		goto put;
 	}
-	lock_release(&dest->lock);
+	pthread_mutex_unlock(&dest->lock);
 	ret = acmp_resolve_response(id, msg, dest, status);
 put:
 	acmp_put_dest(dest);
@@ -2530,7 +2530,7 @@ acmp_alloc_ep(struct acmp_port *port, struct acm_endpoint *endpoint)
 	DListInit(&ep->resp_queue.pending);
 	DListInit(&ep->active_queue);
 	DListInit(&ep->wait_queue);
-	lock_init(&ep->lock);
+	pthread_mutex_init(&ep->lock, NULL);
 	sprintf(ep->id_string, "%s-%d-0x%x", port->dev->verbs->device->name,
 		port->port_num, endpoint->pkey);
 	for (i = 0; i < ACM_MAX_COUNTER; i++) 
@@ -2551,9 +2551,9 @@ static int acmp_open_endpoint(const struct acm_endpoint *endpoint,
 	ep = acmp_get_ep(port,  (struct acm_endpoint *) endpoint);
 	if (ep) {
 		acm_log(2, "endpoint for pkey 0x%x already exists\n", endpoint->pkey);
-		lock_acquire(&ep->lock);
+		pthread_mutex_lock(&ep->lock);
 		ep->endpoint =  (struct acm_endpoint *) endpoint;
-		lock_release(&ep->lock);
+		pthread_mutex_unlock(&ep->lock);
 		*ep_context = (void *) ep;
 		return 0;
 	}
@@ -2627,9 +2627,9 @@ static int acmp_open_endpoint(const struct acm_endpoint *endpoint,
 	if (ret)
 		goto err2;
 
-	lock_acquire(&port->lock);
+	pthread_mutex_lock(&port->lock);
 	DListInsertHead(&ep->entry, &port->ep_list);
-	lock_release(&port->lock);
+	pthread_mutex_unlock(&port->lock);
 	acmp_ep_preload(ep);
 	acmp_ep_join(ep);
 	*ep_context = (void *) ep;
@@ -2700,9 +2700,9 @@ static void acmp_port_up(struct acmp_port *port)
 static void acmp_port_down(struct acmp_port *port)
 {
 	acm_log(1, "%s %d\n", port->dev->verbs->device->name, port->port_num);
-	lock_acquire(&port->lock);
+	pthread_mutex_lock(&port->lock);
 	port->state = IBV_PORT_DOWN;
-	lock_release(&port->lock);
+	pthread_mutex_unlock(&port->lock);
 
 	/*
 	 * We wait for the SA destination to be released.  We could use an
@@ -2712,9 +2712,9 @@ static void acmp_port_down(struct acmp_port *port)
 	atomic_dec(&port->sa_dest.refcnt);
 	while (atomic_get(&port->sa_dest.refcnt))
 		sleep(0);
-	lock_acquire(&port->sa_dest.lock);
+	pthread_mutex_lock(&port->sa_dest.lock);
 	port->sa_dest.state = ACMP_INIT;
-	lock_release(&port->sa_dest.lock);
+	pthread_mutex_unlock(&port->sa_dest.lock);
 	acm_log(1, "%s %d is down\n", port->dev->verbs->device->name, port->port_num);
 }
 
@@ -2731,10 +2731,10 @@ static int acmp_open_port(const struct acm_port *cport, void *dev_context,
 	}
 
 	port = &dev->port[cport->port_num - 1];
-	lock_acquire(&port->lock);
+	pthread_mutex_lock(&port->lock);
 	port->port = cport;
 	port->state = IBV_PORT_DOWN;
-	lock_release(&port->lock);
+	pthread_mutex_unlock(&port->lock);
 	acmp_port_up(port);
 	*port_context = port;
 	return 0;
@@ -2745,9 +2745,9 @@ static void acmp_close_port(void *port_context)
 	struct acmp_port *port = port_context;
 
 	acmp_port_down(port);
-	lock_acquire(&port->lock);
+	pthread_mutex_lock(&port->lock);
 	port->port = NULL;
-	lock_release(&port->lock);
+	pthread_mutex_unlock(&port->lock);
 }
 
 static void acmp_init_port(struct acmp_port *port, struct acmp_device *dev, 
@@ -2756,7 +2756,7 @@ static void acmp_init_port(struct acmp_port *port, struct acmp_device *dev,
 	acm_log(1, "%s %d\n", dev->verbs->device->name, port_num);
 	port->dev = dev;
 	port->port_num = port_num;
-	lock_init(&port->lock);
+	pthread_mutex_init(&port->lock, NULL);
 	DListInit(&port->ep_list);
 	acmp_init_dest(&port->sa_dest, ACM_ADDRESS_LID, NULL, 0);
 	port->state = IBV_PORT_DOWN;
@@ -2838,9 +2838,9 @@ static int acmp_open_dev(const struct acm_device *device, void **dev_context)
 		goto err3;
 	}
 
-	lock_acquire(&acmp_dev_lock);
+	pthread_mutex_lock(&acmp_dev_lock);
 	DListInsertHead(&dev->entry, &acmp_dev_list);
-	lock_release(&acmp_dev_lock);
+	pthread_mutex_unlock(&acmp_dev_lock);
 	dev->guid = device->dev_guid;
 	*dev_context = dev;
 
@@ -2951,7 +2951,7 @@ static void __attribute__((constructor)) acmp_init(void)
 	atomic_init(&g_tid);
 	atomic_init(&wait_cnt);
 	DListInit(&acmp_dev_list);
-	lock_init(&acmp_dev_lock);
+	pthread_mutex_init(&acmp_dev_lock, NULL);
 	DListInit(&timeout_list);
 	event_init(&timeout_event);
 
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index 01ba4e1..d40aa71 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -106,7 +106,7 @@ struct acmc_port {
 	DLIST_ENTRY         sa_pending;
 	DLIST_ENTRY	    sa_wait;
 	int		    sa_credits;
-	lock_t              lock;
+	pthread_mutex_t     lock;
 	DLIST_ENTRY         ep_list;
 	enum ibv_port_state state;
 	int                 gid_cnt;
@@ -140,7 +140,7 @@ struct acmc_ep {
 };
 
 struct acmc_client {
-	lock_t   lock;   /* acquire ep lock first */
+	pthread_mutex_t lock;   /* acquire ep lock first */
 	SOCKET   sock;
 	int      index;
 	atomic_t refcnt;
@@ -185,7 +185,7 @@ static SOCKET ip_mon_socket;
 static struct acmc_client client_array[FD_SETSIZE - 1];
 
 static FILE *flog;
-static lock_t log_lock;
+static pthread_mutex_t log_lock;
 PER_THREAD char log_data[ACM_MAX_ADDRESS];
 static atomic_t counter[ACM_MAX_COUNTER];
 
@@ -230,11 +230,11 @@ void acm_write(int level, const char *format, ...)
 
 	gettimeofday(&tv, NULL);
 	va_start(args, format);
-	lock_acquire(&log_lock);
+	pthread_mutex_lock(&log_lock);
 	fprintf(flog, "%u.%03u: ", (unsigned) tv.tv_sec, (unsigned) (tv.tv_usec / 1000));
 	vfprintf(flog, format, args);
 	fflush(flog);
-	lock_release(&log_lock);
+	pthread_mutex_unlock(&log_lock);
 	va_end(args);
 }
 
@@ -483,7 +483,7 @@ int acm_resolve_response(uint64_t id, struct acm_msg *msg)
 	else if (msg->hdr.status)
 		atomic_inc(&counter[ACM_CNTR_ERROR]);
 
-	lock_acquire(&client->lock);
+	pthread_mutex_lock(&client->lock);
 	if (client->sock == INVALID_SOCKET) {
 		acm_log(0, "ERROR - connection lost\n");
 		ret = ACM_STATUS_ENOTCONN;
@@ -501,7 +501,7 @@ int acm_resolve_response(uint64_t id, struct acm_msg *msg)
 		ret = 0;
 
 release:
-	lock_release(&client->lock);
+	pthread_mutex_unlock(&client->lock);
 	(void) atomic_dec(&client->refcnt);
 	return ret;
 }
@@ -524,7 +524,7 @@ int acm_query_response(uint64_t id, struct acm_msg *msg)
 	int ret;
 
 	acm_log(2, "status 0x%x\n", msg->hdr.status);
-	lock_acquire(&client->lock);
+	pthread_mutex_lock(&client->lock);
 	if (client->sock == INVALID_SOCKET) {
 		acm_log(0, "ERROR - connection lost\n");
 		ret = ACM_STATUS_ENOTCONN;
@@ -538,7 +538,7 @@ int acm_query_response(uint64_t id, struct acm_msg *msg)
 		ret = 0;
 
 release:
-	lock_release(&client->lock);
+	pthread_mutex_unlock(&client->lock);
 	(void) atomic_dec(&client->refcnt);
 	return ret;
 }
@@ -557,7 +557,7 @@ static void acm_init_server(void)
 	int i;
 
 	for (i = 0; i < FD_SETSIZE - 1; i++) {
-		lock_init(&client_array[i].lock);
+		pthread_mutex_init(&client_array[i].lock, NULL);
 		client_array[i].index = i;
 		client_array[i].sock = INVALID_SOCKET;
 		atomic_init(&client_array[i].refcnt);
@@ -604,11 +604,11 @@ static int acm_listen(void)
 
 static void acm_disconnect_client(struct acmc_client *client)
 {
-	lock_acquire(&client->lock);
+	pthread_mutex_lock(&client->lock);
 	shutdown(client->sock, SHUT_RDWR);
 	closesocket(client->sock);
 	client->sock = INVALID_SOCKET;
-	lock_release(&client->lock);
+	pthread_mutex_unlock(&client->lock);
 	(void) atomic_dec(&client->refcnt);
 }
 
@@ -2425,7 +2425,7 @@ acm_open_port(struct acmc_port *port, struct acmc_device *dev, uint8_t port_num)
 	port->dev = dev;
 	port->port.dev = &dev->device;
 	port->port.port_num = port_num;
-	lock_init(&port->lock);
+	pthread_mutex_init(&port->lock, NULL);
 	DListInit(&port->ep_list);
 	DListInit(&port->sa_pending);
 	DListInit(&port->sa_wait);
@@ -2783,7 +2783,7 @@ int acm_send_sa_mad(struct acm_sa_mad *mad)
 	mad->umad.addr.sl = port->sa_addr.sl;
 	mad->umad.addr.pkey_index = req->ep->port->sa_pkey_index;
 
-	lock_acquire(&port->lock);
+	pthread_mutex_lock(&port->lock);
 	if (port->sa_credits && DListEmpty(&port->sa_wait)) {
 		ret = umad_send(port->mad_portid, port->mad_agentid, &mad->umad,
 				sizeof mad->sa_mad, sa.timeout, sa.retries);
@@ -2795,7 +2795,7 @@ int acm_send_sa_mad(struct acm_sa_mad *mad)
 		ret = 0;
 		DListInsertTail(&req->entry, &port->sa_wait);
 	}
-	lock_release(&port->lock);
+	pthread_mutex_unlock(&port->lock);
 	return ret;
 }
 
@@ -2804,9 +2804,9 @@ static void acmc_send_queued_req(struct acmc_port *port)
 	struct acmc_sa_req *req;
 	int ret;
 
-	lock_acquire(&port->lock);
+	pthread_mutex_lock(&port->lock);
 	if (DListEmpty(&port->sa_wait) || !port->sa_credits) {
-		lock_release(&port->lock);
+		pthread_mutex_unlock(&port->lock);
 		return;
 	}
 
@@ -2818,7 +2818,7 @@ static void acmc_send_queued_req(struct acmc_port *port)
 		port->sa_credits--;
 		DListInsertTail(&req->entry, &port->sa_pending);
 	}
-	lock_release(&port->lock);
+	pthread_mutex_unlock(&port->lock);
 
 	if (ret) {
 		req->mad.umad.status = -ret;
@@ -2847,7 +2847,7 @@ static void acmc_recv_mad(struct acmc_port *port)
 		hdr->base_version, hdr->mgmt_class, hdr->class_version,
 		hdr->method, hdr->status, hdr->tid, hdr->attr_id, hdr->attr_mod);
 	found = 0;
-	lock_acquire(&port->lock);
+	pthread_mutex_lock(&port->lock);
 	for (entry = port->sa_pending.Next; entry != &port->sa_pending;
 	     entry = entry->Next) {
 		req = container_of(entry, struct acmc_sa_req, entry);
@@ -2859,7 +2859,7 @@ static void acmc_recv_mad(struct acmc_port *port)
 			break;
 		}
 	}
-	lock_release(&port->lock);
+	pthread_mutex_unlock(&port->lock);
 
 	if (found) {
 		memcpy(&req->mad.umad, &resp.umad, sizeof(resp.umad) + len);
@@ -3083,7 +3083,7 @@ int CDECL_FUNC main(int argc, char **argv)
 	if (acm_open_lock_file())
 		return -1;
 
-	lock_init(&log_lock);
+	pthread_mutex_init(&log_lock, NULL);
 	flog = acm_open_log();
 
 	acm_log(0, "Assistant to the InfiniBand Communication Manager\n");
diff --git a/ibacm/src/libacm.c b/ibacm/src/libacm.c
index def5b2c..0f45469 100644
--- a/ibacm/src/libacm.c
+++ b/ibacm/src/libacm.c
@@ -38,7 +38,7 @@
 #include <netdb.h>
 #include <arpa/inet.h>
 
-extern lock_t lock;
+extern pthread_mutex_t lock;
 static SOCKET sock = INVALID_SOCKET;
 static short server_port = 6125;
 
@@ -212,7 +212,7 @@ static int acm_resolve(uint8_t *src, uint8_t *dest, uint8_t type,
 	struct acm_msg msg;
 	int ret, cnt = 0;
 
-	lock_acquire(&lock);
+	pthread_mutex_lock(&lock);
 	memset(&msg, 0, sizeof msg);
 	msg.hdr.version = ACM_VERSION;
 	msg.hdr.opcode = ACM_OP_RESOLVE;
@@ -246,7 +246,7 @@ static int acm_resolve(uint8_t *src, uint8_t *dest, uint8_t type,
 
 	ret = acm_format_resp(&msg, paths, count, print);
 out:
-	lock_release(&lock);
+	pthread_mutex_unlock(&lock);
 	return ret;
 }
 
@@ -275,7 +275,7 @@ int ib_acm_resolve_path(struct ibv_path_record *path, uint32_t flags)
 	struct acm_ep_addr_data *data;
 	int ret;
 
-	lock_acquire(&lock);
+	pthread_mutex_lock(&lock);
 	memset(&msg, 0, sizeof msg);
 	msg.hdr.version = ACM_VERSION;
 	msg.hdr.opcode = ACM_OP_RESOLVE;
@@ -299,7 +299,7 @@ int ib_acm_resolve_path(struct ibv_path_record *path, uint32_t flags)
 		*path = data->info.path;
 
 out:
-	lock_release(&lock);
+	pthread_mutex_unlock(&lock);
 	return ret;
 }
 
@@ -308,7 +308,7 @@ int ib_acm_query_perf(int index, uint64_t **counters, int *count)
 	struct acm_msg msg;
 	int ret, i;
 
-	lock_acquire(&lock);
+	pthread_mutex_lock(&lock);
 	memset(&msg, 0, sizeof msg);
 	msg.hdr.version = ACM_VERSION;
 	msg.hdr.opcode = ACM_OP_PERF_QUERY;
@@ -341,7 +341,7 @@ int ib_acm_query_perf(int index, uint64_t **counters, int *count)
 		(*counters)[i] = ntohll(msg.perf_data[i]);
 	ret = 0;
 out:
-	lock_release(&lock);
+	pthread_mutex_unlock(&lock);
 	return ret;
 }
 
@@ -353,7 +353,7 @@ int ib_acm_enum_ep(int index, struct acm_ep_config_data **data)
 	int cnt;
 	struct acm_ep_config_data *edata;
 
-	lock_acquire(&lock);
+	pthread_mutex_lock(&lock);
 	memset(&msg, 0, sizeof msg);
 	msg.hdr.version = ACM_VERSION;
 	msg.hdr.opcode = ACM_OP_EP_QUERY;
@@ -391,7 +391,7 @@ int ib_acm_enum_ep(int index, struct acm_ep_config_data **data)
 	*data = edata;
 	ret = 0;
 out:
-	lock_release(&lock);
+	pthread_mutex_unlock(&lock);
 	return ret;
 }
 
@@ -404,7 +404,7 @@ int ib_acm_query_perf_ep_addr(uint8_t *src, uint8_t type,
 	if (!src) 
 		return -1;
 
-	lock_acquire(&lock);
+	pthread_mutex_lock(&lock);
 	memset(&msg, 0, sizeof msg);
 	msg.hdr.version = ACM_VERSION;
 	msg.hdr.opcode = ACM_OP_PERF_QUERY;
@@ -444,7 +444,7 @@ int ib_acm_query_perf_ep_addr(uint8_t *src, uint8_t type,
 
 	ret = 0;
 out:
-	lock_release(&lock);
+	pthread_mutex_unlock(&lock);
 	return ret;
 }
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 03/13] ibacm: use __thread directly
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>

Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
 ibacm/linux/osd.h          | 1 -
 ibacm/prov/acmp/src/acmp.c | 2 +-
 ibacm/src/acm.c            | 2 +-
 3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/ibacm/linux/osd.h b/ibacm/linux/osd.h
index 3580cc3..31a7044 100644
--- a/ibacm/linux/osd.h
+++ b/ibacm/linux/osd.h
@@ -136,7 +136,6 @@ static inline uint64_t time_stamp_us(void)
 #define time_stamp_sec() (time_stamp_ms() / (uint64_t) 1000)
 #define time_stamp_min() (time_stamp_sec() / (uint64_t) 60)
 
-#define PER_THREAD __thread
 static inline int beginthread(void (*func)(void *), void *arg)
 {
 	pthread_t thread;
diff --git a/ibacm/prov/acmp/src/acmp.c b/ibacm/prov/acmp/src/acmp.c
index 24d2b70..1f3aeef 100644
--- a/ibacm/prov/acmp/src/acmp.c
+++ b/ibacm/prov/acmp/src/acmp.c
@@ -259,7 +259,7 @@ static atomic_t wait_cnt;
 static pthread_t retry_thread_id;
 static int retry_thread_started = 0;
 
-PER_THREAD char log_data[ACM_MAX_ADDRESS];
+__thread char log_data[ACM_MAX_ADDRESS];
 
 /*
  * Service options - may be set through ibacm_opts.cfg file.
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index d40aa71..33fc044 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -186,7 +186,7 @@ static struct acmc_client client_array[FD_SETSIZE - 1];
 
 static FILE *flog;
 static pthread_mutex_t log_lock;
-PER_THREAD char log_data[ACM_MAX_ADDRESS];
+__thread char log_data[ACM_MAX_ADDRESS];
 static atomic_t counter[ACM_MAX_COUNTER];
 
 static struct acmc_device *
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 04/13] ibacm: use the unix socket API directly
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>

Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
 ibacm/linux/osd.h  |  6 -----
 ibacm/src/acm.c    | 66 +++++++++++++++++++++++++++---------------------------
 ibacm/src/libacm.c | 16 ++++++-------
 3 files changed, 41 insertions(+), 47 deletions(-)

diff --git a/ibacm/linux/osd.h b/ibacm/linux/osd.h
index 31a7044..7ce52e6 100644
--- a/ibacm/linux/osd.h
+++ b/ibacm/linux/osd.h
@@ -118,12 +118,6 @@ static inline int event_wait(event_t *e, int timeout)
 #define osd_init()  0
 #define osd_close()
 
-#define SOCKET         int
-#define SOCKET_ERROR   -1
-#define INVALID_SOCKET -1
-#define socket_errno() errno
-#define closesocket    close
-
 static inline uint64_t time_stamp_us(void)
 {
 	struct timeval curtime;
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index 33fc044..508148a 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -141,7 +141,7 @@ struct acmc_ep {
 
 struct acmc_client {
 	pthread_mutex_t lock;   /* acquire ep lock first */
-	SOCKET   sock;
+	int      sock;
 	int      index;
 	atomic_t refcnt;
 };
@@ -180,8 +180,8 @@ static struct acmc_prov *def_provider = NULL;
 
 static DLIST_ENTRY dev_list;
 
-static SOCKET listen_socket;
-static SOCKET ip_mon_socket;
+static int listen_socket;
+static int ip_mon_socket;
 static struct acmc_client client_array[FD_SETSIZE - 1];
 
 static FILE *flog;
@@ -195,7 +195,7 @@ static struct acmc_ep *acm_find_ep(struct acmc_port *port, uint16_t pkey);
 static int acm_ep_insert_addr(struct acmc_ep *ep, const char *name, uint8_t *addr,
 			      size_t addr_len, uint8_t addr_type);
 static void acm_event_handler(struct acmc_device *dev);
-static int acm_nl_send(SOCKET sock, struct acm_msg *msg);
+static int acm_nl_send(int sock, struct acm_msg *msg);
 
 static struct sa_data {
 	int		timeout;
@@ -484,7 +484,7 @@ int acm_resolve_response(uint64_t id, struct acm_msg *msg)
 		atomic_inc(&counter[ACM_CNTR_ERROR]);
 
 	pthread_mutex_lock(&client->lock);
-	if (client->sock == INVALID_SOCKET) {
+	if (client->sock == -1) {
 		acm_log(0, "ERROR - connection lost\n");
 		ret = ACM_STATUS_ENOTCONN;
 		goto release;
@@ -525,7 +525,7 @@ int acm_query_response(uint64_t id, struct acm_msg *msg)
 
 	acm_log(2, "status 0x%x\n", msg->hdr.status);
 	pthread_mutex_lock(&client->lock);
-	if (client->sock == INVALID_SOCKET) {
+	if (client->sock == -1) {
 		acm_log(0, "ERROR - connection lost\n");
 		ret = ACM_STATUS_ENOTCONN;
 		goto release;
@@ -559,7 +559,7 @@ static void acm_init_server(void)
 	for (i = 0; i < FD_SETSIZE - 1; i++) {
 		pthread_mutex_init(&client_array[i].lock, NULL);
 		client_array[i].index = i;
-		client_array[i].sock = INVALID_SOCKET;
+		client_array[i].sock = -1;
 		atomic_init(&client_array[i].refcnt);
 	}
 
@@ -578,24 +578,24 @@ static int acm_listen(void)
 
 	acm_log(2, "\n");
 	listen_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
-	if (listen_socket == INVALID_SOCKET) {
+	if (listen_socket == -1) {
 		acm_log(0, "ERROR - unable to allocate listen socket\n");
-		return socket_errno();
+		return errno;
 	}
 
 	memset(&addr, 0, sizeof addr);
 	addr.sin_family = AF_INET;
 	addr.sin_port = htons(server_port);
 	ret = bind(listen_socket, (struct sockaddr *) &addr, sizeof addr);
-	if (ret == SOCKET_ERROR) {
+	if (ret == -1) {
 		acm_log(0, "ERROR - unable to bind listen socket\n");
-		return socket_errno();
+		return errno;
 	}
 	
 	ret = listen(listen_socket, 0);
-	if (ret == SOCKET_ERROR) {
+	if (ret == -1) {
 		acm_log(0, "ERROR - unable to start listen\n");
-		return socket_errno();
+		return errno;
 	}
 
 	acm_log(2, "listen active\n");
@@ -606,20 +606,20 @@ static void acm_disconnect_client(struct acmc_client *client)
 {
 	pthread_mutex_lock(&client->lock);
 	shutdown(client->sock, SHUT_RDWR);
-	closesocket(client->sock);
-	client->sock = INVALID_SOCKET;
+	close(client->sock);
+	client->sock = -1;
 	pthread_mutex_unlock(&client->lock);
 	(void) atomic_dec(&client->refcnt);
 }
 
 static void acm_svr_accept(void)
 {
-	SOCKET s;
+	int s;
 	int i;
 
 	acm_log(2, "\n");
 	s = accept(listen_socket, NULL, NULL);
-	if (s == INVALID_SOCKET) {
+	if (s == -1) {
 		acm_log(0, "ERROR - failed to accept connection\n");
 		return;
 	}
@@ -633,7 +633,7 @@ static void acm_svr_accept(void)
 
 	if (i == FD_SETSIZE - 1) {
 		acm_log(0, "ERROR - all connections busy - rejecting\n");
-		closesocket(s);
+		close(s);
 		return;
 	}
 
@@ -797,7 +797,7 @@ static int acm_svr_select_src(struct acm_ep_addr_data *src, struct acm_ep_addr_d
 	union socket_addr addr;
 	socklen_t len;
 	int ret;
-	SOCKET s;
+	int s;
 
 	acm_log(2, "selecting source address\n");
 	memset(&addr, 0, sizeof addr);
@@ -818,22 +818,22 @@ static int acm_svr_select_src(struct acm_ep_addr_data *src, struct acm_ep_addr_d
 	}
 
 	s = socket(addr.sa.sa_family, SOCK_DGRAM, IPPROTO_UDP);
-	if (s == INVALID_SOCKET) {
+	if (s == -1) {
 		acm_log(0, "ERROR - unable to allocate socket\n");
-		return socket_errno();
+		return errno;
 	}
 
 	ret = connect(s, &addr.sa, len);
 	if (ret) {
 		acm_log(0, "ERROR - unable to connect socket\n");
-		ret = socket_errno();
+		ret = errno;
 		goto out;
 	}
 
 	ret = getsockname(s, &addr.sa, &len);
 	if (ret) {
 		acm_log(0, "ERROR - failed to get socket address\n");
-		ret = socket_errno();
+		ret = errno;
 		goto out;
 	}
 
@@ -1376,7 +1376,7 @@ static void acm_ipnl_handler(void)
 	}
 }
 
-static int acm_nl_send(SOCKET sock, struct acm_msg *msg)
+static int acm_nl_send(int sock, struct acm_msg *msg)
 {
 	struct sockaddr_nl dst_addr;
 	struct acm_nl_msg acmnlmsg;
@@ -1672,12 +1672,12 @@ static int acm_init_nl(void)
 {
 	struct sockaddr_nl src_addr;
 	int ret;
-	SOCKET nl_rcv_socket;
+	int nl_rcv_socket;
 
 	nl_rcv_socket = socket(PF_NETLINK, SOCK_RAW, NETLINK_RDMA);
-	if (nl_rcv_socket == INVALID_SOCKET) {
+	if (nl_rcv_socket == -1) {
 		acm_log(0, "ERROR - unable to allocate netlink recv socket\n");
-		return socket_errno();
+		return errno;
 	}
 
 	memset(&src_addr, 0, sizeof(src_addr));
@@ -1687,10 +1687,10 @@ static int acm_init_nl(void)
 
 	ret = bind(nl_rcv_socket, (struct sockaddr *)&src_addr,
 		   sizeof(src_addr));
-	if (ret == SOCKET_ERROR) {
+	if (ret == -1) {
 		acm_log(0, "ERROR - unable to bind netlink socket\n");
 		close(nl_rcv_socket);
-		return socket_errno();
+		return errno;
 	}
 
 	/* init nl client structure */
@@ -1725,7 +1725,7 @@ static void acm_server(void)
 		FD_SET(ip_mon_socket, &readfds);
 
 		for (i = 0; i < FD_SETSIZE - 1; i++) {
-			if (client_array[i].sock != INVALID_SOCKET) {
+			if (client_array[i].sock != -1) {
 				FD_SET(client_array[i].sock, &readfds);
 				n = max(n, (int) client_array[i].sock);
 			}
@@ -1739,7 +1739,7 @@ static void acm_server(void)
 		}
 
 		ret = select(n + 1, &readfds, NULL, NULL, NULL);
-		if (ret == SOCKET_ERROR) {
+		if (ret == -1) {
 			acm_log(0, "ERROR - server select error\n");
 			continue;
 		}
@@ -1751,7 +1751,7 @@ static void acm_server(void)
 			acm_ipnl_handler();
 
 		for (i = 0; i < FD_SETSIZE - 1; i++) {
-			if (client_array[i].sock != INVALID_SOCKET &&
+			if (client_array[i].sock != -1 &&
 				FD_ISSET(client_array[i].sock, &readfds)) {
 				acm_log(2, "receiving from client %d\n", i);
 				if (i == NL_CLIENT_INDEX)
@@ -3122,7 +3122,7 @@ int CDECL_FUNC main(int argc, char **argv)
 	acm_server();
 
 	acm_log(0, "shutting down\n");
-	if (client_array[NL_CLIENT_INDEX].sock != INVALID_SOCKET)
+	if (client_array[NL_CLIENT_INDEX].sock != -1)
 		close(client_array[NL_CLIENT_INDEX].sock);
 	acm_close_providers();
 	acm_stop_sa_handler();
diff --git a/ibacm/src/libacm.c b/ibacm/src/libacm.c
index 0f45469..4273dfe 100644
--- a/ibacm/src/libacm.c
+++ b/ibacm/src/libacm.c
@@ -39,7 +39,7 @@
 #include <arpa/inet.h>
 
 extern pthread_mutex_t lock;
-static SOCKET sock = INVALID_SOCKET;
+static int sock = -1;
 static short server_port = 6125;
 
 static void acm_set_server_port(void)
@@ -67,8 +67,8 @@ int ib_acm_connect(char *dest)
 		return ret;
 
 	sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
-	if (sock == INVALID_SOCKET) {
-		ret = socket_errno();
+	if (sock == -1) {
+		ret = errno;
 		goto err1;
 	}
 
@@ -81,8 +81,8 @@ int ib_acm_connect(char *dest)
 	return 0;
 
 err2:
-	closesocket(sock);
-	sock = INVALID_SOCKET;
+	close(sock);
+	sock = -1;
 err1:
 	freeaddrinfo(res);
 	return ret;
@@ -90,10 +90,10 @@ err1:
 
 void ib_acm_disconnect(void)
 {
-	if (sock != INVALID_SOCKET) {
+	if (sock != -1) {
 		shutdown(sock, SHUT_RDWR);
-		closesocket(sock);
-		sock = INVALID_SOCKET;
+		close(sock);
+		sock = -1;
 	}
 }
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 05/13] ibacm: remove unused helper beginthread
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>

Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
 ibacm/linux/osd.h | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/ibacm/linux/osd.h b/ibacm/linux/osd.h
index 7ce52e6..00a5084 100644
--- a/ibacm/linux/osd.h
+++ b/ibacm/linux/osd.h
@@ -130,10 +130,4 @@ static inline uint64_t time_stamp_us(void)
 #define time_stamp_sec() (time_stamp_ms() / (uint64_t) 1000)
 #define time_stamp_min() (time_stamp_sec() / (uint64_t) 60)
 
-static inline int beginthread(void (*func)(void *), void *arg)
-{
-	pthread_t thread;
-	return pthread_create(&thread, NULL, (void *(*)(void*)) func, arg);
-}
-
 #endif /* OSD_H */
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 06/13] ibacm: remove unused LIB_DESTRUCTOR define
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>

Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
 ibacm/linux/osd.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ibacm/linux/osd.h b/ibacm/linux/osd.h
index 00a5084..5fafd4d 100644
--- a/ibacm/linux/osd.h
+++ b/ibacm/linux/osd.h
@@ -53,7 +53,6 @@
 #define ACM_ADDR_FILE "ibacm_addr.cfg"
 #define ACM_OPTS_FILE "ibacm_opts.cfg"
 
-#define LIB_DESTRUCTOR __attribute__((destructor))
 #define CDECL_FUNC
 
 #if DEFINE_ATOMICS
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 07/13] ibacm: remove CDECL_FUNC
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>

Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
 ibacm/linux/osd.h | 2 --
 ibacm/src/acm.c   | 2 +-
 ibacm/src/acme.c  | 2 +-
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/ibacm/linux/osd.h b/ibacm/linux/osd.h
index 5fafd4d..12877f4 100644
--- a/ibacm/linux/osd.h
+++ b/ibacm/linux/osd.h
@@ -53,8 +53,6 @@
 #define ACM_ADDR_FILE "ibacm_addr.cfg"
 #define ACM_OPTS_FILE "ibacm_opts.cfg"
 
-#define CDECL_FUNC
-
 #if DEFINE_ATOMICS
 typedef struct { pthread_mutex_t mut; int val; } atomic_t;
 static inline int atomic_inc(atomic_t *atomic)
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index 508148a..056824d 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -3049,7 +3049,7 @@ static void show_usage(char *program)
 	printf("                      (default %s/%s)\n", ACM_CONF_DIR, ACM_OPTS_FILE);
 }
 
-int CDECL_FUNC main(int argc, char **argv)
+int main(int argc, char **argv)
 {
 	int i, op, daemon = 1;
 
diff --git a/ibacm/src/acme.c b/ibacm/src/acme.c
index a924dad..c5be0a3 100644
--- a/ibacm/src/acme.c
+++ b/ibacm/src/acme.c
@@ -983,7 +983,7 @@ static void parse_perf_arg(char *arg)
 	}
 }
 
-int CDECL_FUNC main(int argc, char **argv)
+int main(int argc, char **argv)
 {
 	int op, ret;
 	int make_addr = 0;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 08/13] ibacm: remove no-op osd_init/osd_close macros
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>

Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
 ibacm/linux/osd.h          | 3 ---
 ibacm/prov/acmp/src/acmp.c | 3 ---
 ibacm/src/acm.c            | 3 ---
 ibacm/src/acme.c           | 8 +-------
 4 files changed, 1 insertion(+), 16 deletions(-)

diff --git a/ibacm/linux/osd.h b/ibacm/linux/osd.h
index 12877f4..ee582bb 100644
--- a/ibacm/linux/osd.h
+++ b/ibacm/linux/osd.h
@@ -112,9 +112,6 @@ static inline int event_wait(event_t *e, int timeout)
 	return ret;
 }
 
-#define osd_init()  0
-#define osd_close()
-
 static inline uint64_t time_stamp_us(void)
 {
 	struct timeval curtime;
diff --git a/ibacm/prov/acmp/src/acmp.c b/ibacm/prov/acmp/src/acmp.c
index 1f3aeef..4cda359 100644
--- a/ibacm/prov/acmp/src/acmp.c
+++ b/ibacm/prov/acmp/src/acmp.c
@@ -2941,9 +2941,6 @@ static void acmp_log_options(void)
 
 static void __attribute__((constructor)) acmp_init(void)
 {
-	if (osd_init())
-		return;
-
 	acmp_set_options();
 
 	acmp_log_options();
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index 056824d..912d563 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -3076,9 +3076,6 @@ int main(int argc, char **argv)
 	if (daemon)
 		daemonize();
 
-	if (osd_init())
-		return -1;
-
 	acm_set_options();
 	if (acm_open_lock_file())
 		return -1;
diff --git a/ibacm/src/acme.c b/ibacm/src/acme.c
index c5be0a3..f2c9348 100644
--- a/ibacm/src/acme.c
+++ b/ibacm/src/acme.c
@@ -985,14 +985,10 @@ static void parse_perf_arg(char *arg)
 
 int main(int argc, char **argv)
 {
-	int op, ret;
+	int op, ret = 0;
 	int make_addr = 0;
 	int make_opts = 0;
 
-	ret = osd_init();
-	if (ret)
-		goto out;
-
 	while ((op = getopt(argc, argv, "e::f:s:d:vcA::O::D:P::S:C:V")) != -1) {
 		switch (op) {
 		case 'e':
@@ -1068,8 +1064,6 @@ int main(int argc, char **argv)
 	if (!ret && make_opts)
 		ret = gen_opts();
 
-	osd_close();
-out:
 	if (verbose || !(make_addr || make_opts) || ret)
 		printf("return status 0x%x\n", ret);
 	return ret;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 09/13] ibacm: remove e stricmp and strnicmp
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>

Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
 ibacm/linux/osd.h          |  3 ---
 ibacm/prov/acmp/src/acmp.c | 50 +++++++++++++++++++++++-----------------------
 ibacm/src/acm.c            | 30 ++++++++++++++--------------
 ibacm/src/acme.c           |  4 ++--
 4 files changed, 42 insertions(+), 45 deletions(-)

diff --git a/ibacm/linux/osd.h b/ibacm/linux/osd.h
index ee582bb..6e408f7 100644
--- a/ibacm/linux/osd.h
+++ b/ibacm/linux/osd.h
@@ -87,9 +87,6 @@ typedef struct { volatile int val; } atomic_t;
 #define atomic_get(v) ((v)->val)
 #define atomic_set(v, s) ((v)->val = s)
 
-#define stricmp strcasecmp
-#define strnicmp strncasecmp
-
 typedef struct { pthread_cond_t cond; pthread_mutex_t mutex; } event_t;
 static inline void event_init(event_t *e)
 {
diff --git a/ibacm/prov/acmp/src/acmp.c b/ibacm/prov/acmp/src/acmp.c
index 4cda359..1cb14e1 100644
--- a/ibacm/prov/acmp/src/acmp.c
+++ b/ibacm/prov/acmp/src/acmp.c
@@ -1057,7 +1057,7 @@ acmp_addr_lookup(struct acmp_ep *ep, uint8_t *addr, uint16_t type)
 			continue;
 
 		if ((type == ACM_ADDRESS_NAME &&
-		    !strnicmp((char *) ep->addr_info[i].info.name,
+		    !strncasecmp((char *) ep->addr_info[i].info.name,
 			      (char *) addr, ACM_MAX_ADDRESS)) ||
 		    !memcmp(ep->addr_info[i].info.addr, addr, 
 			    ACM_MAX_ADDRESS)) {
@@ -1993,7 +1993,7 @@ static void acmp_query_perf(void *ep_context, uint64_t *values, uint8_t *cnt)
 
 static enum acmp_addr_prot acmp_convert_addr_prot(char *param)
 {
-	if (!stricmp("acm", param))
+	if (!strcasecmp("acm", param))
 		return ACMP_ADDR_PROT_ACM;
 
 	return addr_prot;
@@ -2001,9 +2001,9 @@ static enum acmp_addr_prot acmp_convert_addr_prot(char *param)
 
 static enum acmp_route_prot acmp_convert_route_prot(char *param)
 {
-	if (!stricmp("acm", param))
+	if (!strcasecmp("acm", param))
 		return ACMP_ROUTE_PROT_ACM;
-	else if (!stricmp("sa", param))
+	else if (!strcasecmp("sa", param))
 		return ACMP_ROUTE_PROT_SA;
 
 	return route_prot;
@@ -2011,9 +2011,9 @@ static enum acmp_route_prot acmp_convert_route_prot(char *param)
 
 static enum acmp_loopback_prot acmp_convert_loopback_prot(char *param)
 {
-	if (!stricmp("none", param))
+	if (!strcasecmp("none", param))
 		return ACMP_LOOPBACK_PROT_NONE;
-	else if (!stricmp("local", param))
+	else if (!strcasecmp("local", param))
 		return ACMP_LOOPBACK_PROT_LOCAL;
 
 	return loopback_prot;
@@ -2021,9 +2021,9 @@ static enum acmp_loopback_prot acmp_convert_loopback_prot(char *param)
 
 static enum acmp_route_preload acmp_convert_route_preload(char *param)
 {
-	if (!stricmp("none", param) || !stricmp("no", param))
+	if (!strcasecmp("none", param) || !strcasecmp("no", param))
 		return ACMP_ROUTE_PRELOAD_NONE;
-	else if (!stricmp("opensm_full_v1", param))
+	else if (!strcasecmp("opensm_full_v1", param))
 		return ACMP_ROUTE_PRELOAD_OSM_FULL_V1;
 
 	return route_preload;
@@ -2031,9 +2031,9 @@ static enum acmp_route_preload acmp_convert_route_preload(char *param)
 
 static enum acmp_addr_preload acmp_convert_addr_preload(char *param)
 {
-	if (!stricmp("none", param) || !stricmp("no", param))
+	if (!strcasecmp("none", param) || !strcasecmp("no", param))
 		return ACMP_ADDR_PRELOAD_NONE;
-	else if (!stricmp("acm_hosts", param))
+	else if (!strcasecmp("acm_hosts", param))
 		return ACMP_ADDR_PRELOAD_HOSTS;
 
 	return addr_preload;
@@ -2882,37 +2882,37 @@ static void acmp_set_options(void)
 		if (sscanf(s, "%31s%255s", opt, value) != 2)
 			continue;
 
-		if (!stricmp("addr_prot", opt))
+		if (!strcasecmp("addr_prot", opt))
 			addr_prot = acmp_convert_addr_prot(value);
-		else if (!stricmp("addr_timeout", opt))
+		else if (!strcasecmp("addr_timeout", opt))
 			addr_timeout = atoi(value);
-		else if (!stricmp("route_prot", opt))
+		else if (!strcasecmp("route_prot", opt))
 			route_prot = acmp_convert_route_prot(value);
 		else if (!strcmp("route_timeout", opt))
 			route_timeout = atoi(value);
-		else if (!stricmp("loopback_prot", opt))
+		else if (!strcasecmp("loopback_prot", opt))
 			loopback_prot = acmp_convert_loopback_prot(value);
-		else if (!stricmp("timeout", opt))
+		else if (!strcasecmp("timeout", opt))
 			timeout = atoi(value);
-		else if (!stricmp("retries", opt))
+		else if (!strcasecmp("retries", opt))
 			retries = atoi(value);
-		else if (!stricmp("resolve_depth", opt))
+		else if (!strcasecmp("resolve_depth", opt))
 			resolve_depth = atoi(value);
-		else if (!stricmp("send_depth", opt))
+		else if (!strcasecmp("send_depth", opt))
 			send_depth = atoi(value);
-		else if (!stricmp("recv_depth", opt))
+		else if (!strcasecmp("recv_depth", opt))
 			recv_depth = atoi(value);
-		else if (!stricmp("min_mtu", opt))
+		else if (!strcasecmp("min_mtu", opt))
 			min_mtu = acm_convert_mtu(atoi(value));
-		else if (!stricmp("min_rate", opt))
+		else if (!strcasecmp("min_rate", opt))
 			min_rate = acm_convert_rate(atoi(value));
-		else if (!stricmp("route_preload", opt))
+		else if (!strcasecmp("route_preload", opt))
 			route_preload = acmp_convert_route_preload(value);
-		else if (!stricmp("route_data_file", opt))
+		else if (!strcasecmp("route_data_file", opt))
 			strcpy(route_data_file, value);
-		else if (!stricmp("addr_preload", opt))
+		else if (!strcasecmp("addr_preload", opt))
 			addr_preload = acmp_convert_addr_preload(value);
-		else if (!stricmp("addr_data_file", opt))
+		else if (!strcasecmp("addr_data_file", opt))
 			strcpy(addr_data_file, value);
 	}
 
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index 912d563..37bbbe7 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -388,7 +388,7 @@ static void acm_mark_addr_invalid(struct acmc_ep *ep,
 			continue;
 
 		if ((data->type == ACM_ADDRESS_NAME &&
-		    !strnicmp((char *) ep->addr_info[i].addr.info.name,
+		    !strncasecmp((char *) ep->addr_info[i].addr.info.name,
 			      (char *) data->info.addr, ACM_MAX_ADDRESS)) ||
 		     !memcmp(ep->addr_info[i].addr.info.addr, data->info.addr,
 			     ACM_MAX_ADDRESS)) {
@@ -410,7 +410,7 @@ acm_addr_lookup(const struct acm_endpoint *endpoint, uint8_t *addr, uint8_t addr
 			continue;
 
 		if ((addr_type == ACM_ADDRESS_NAME &&
-			!strnicmp((char *) ep->addr_info[i].addr.info.name,
+			!strncasecmp((char *) ep->addr_info[i].addr.info.name,
 				(char *) addr, ACM_MAX_ADDRESS)) ||
 			!memcmp(ep->addr_info[i].addr.info.addr, addr, ACM_MAX_ADDRESS))
 			return &ep->addr_info[i].addr;
@@ -2004,7 +2004,7 @@ static int acm_assign_ep_names(struct acmc_ep *ep)
 			memcpy(addr, name, addr_len);
 		}
 
-		if (stricmp(pkey_str, "default")) {
+		if (strcasecmp(pkey_str, "default")) {
 			if (sscanf(pkey_str, "%hx", &pkey) != 1) {
 				acm_log(0, "ERROR - bad pkey format %s\n", pkey_str);
 				continue;
@@ -2013,7 +2013,7 @@ static int acm_assign_ep_names(struct acmc_ep *ep)
 			pkey = ep->port->def_acm_pkey;
 		}
 
-		if (!stricmp(dev_name, dev) &&
+		if (!strcasecmp(dev_name, dev) &&
 		    (ep->port->port.port_num == (uint8_t) port) &&
 		    (ep->endpoint.pkey == pkey)) {
 			acm_log(1, "assigning %s\n", name);
@@ -2939,23 +2939,23 @@ static void acm_set_options(void)
 		if (sscanf(s, "%32s%256s", opt, value) != 2)
 			continue;
 
-		if (!stricmp("log_file", opt))
+		if (!strcasecmp("log_file", opt))
 			strcpy(log_file, value);
-		else if (!stricmp("log_level", opt))
+		else if (!strcasecmp("log_level", opt))
 			log_level = atoi(value);
-		else if (!stricmp("lock_file", opt))
+		else if (!strcasecmp("lock_file", opt))
 			strcpy(lock_file, value);
-		else if (!stricmp("server_port", opt))
+		else if (!strcasecmp("server_port", opt))
 			server_port = (short) atoi(value);
-		else if (!stricmp("provider_lib_path", opt))
+		else if (!strcasecmp("provider_lib_path", opt))
 			strcpy(prov_lib_path, value);
-		else if (!stricmp("support_ips_in_addr_cfg", opt))
+		else if (!strcasecmp("support_ips_in_addr_cfg", opt))
 			support_ips_in_addr_cfg = atoi(value);
-		else if (!stricmp("timeout", opt))
+		else if (!strcasecmp("timeout", opt))
 			sa.timeout = atoi(value);
-		else if (!stricmp("retries", opt))
+		else if (!strcasecmp("retries", opt))
 			sa.retries = atoi(value);
-		else if (!stricmp("sa_depth", opt))
+		else if (!strcasecmp("sa_depth", opt))
 			sa.depth = atoi(value);
 	}
 
@@ -2981,10 +2981,10 @@ static FILE *acm_open_log(void)
 {
 	FILE *f;
 
-	if (!stricmp(log_file, "stdout"))
+	if (!strcasecmp(log_file, "stdout"))
 		return stdout;
 
-	if (!stricmp(log_file, "stderr"))
+	if (!strcasecmp(log_file, "stderr"))
 		return stderr;
 
 	if (!(f = fopen(log_file, "w")))
diff --git a/ibacm/src/acme.c b/ibacm/src/acme.c
index f2c9348..5a571cf 100644
--- a/ibacm/src/acme.c
+++ b/ibacm/src/acme.c
@@ -968,9 +968,9 @@ static char *opt_arg(int argc, char **argv)
 
 static void parse_perf_arg(char *arg)
 {
-	if (!strnicmp("col", arg, 3)) {
+	if (!strncasecmp("col", arg, 3)) {
 		perf_query = PERF_QUERY_COL;
-	} else if (!strnicmp("all", arg, 3)) {
+	} else if (!strncasecmp("all", arg, 3)) {
 		perf_query = PERF_QUERY_EP_ALL;
 	} else if (!strcmp("s", arg)) {
 		perf_query = PERF_QUERY_EP_ADDR;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 10/13] ibacm: cleanup "lock"
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>

Make it static to libacm.c, give it a more reasonable name and initialize
it at compile time.

Note tha the critical sections for this lock could be reduced easily, but
that's a different project if someone cares enough..

Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
 ibacm/CMakeLists.txt       |  1 -
 ibacm/linux/libacm_linux.c | 37 -------------------------------------
 ibacm/src/libacm.c         | 22 +++++++++++-----------
 3 files changed, 11 insertions(+), 49 deletions(-)
 delete mode 100644 ibacm/linux/libacm_linux.c

diff --git a/ibacm/CMakeLists.txt b/ibacm/CMakeLists.txt
index 7ed8fd5..505fba3 100644
--- a/ibacm/CMakeLists.txt
+++ b/ibacm/CMakeLists.txt
@@ -38,7 +38,6 @@ set_target_properties(ibacmp PROPERTIES
 install(TARGETS ibacmp DESTINATION "${ACM_PROVIDER_DIR}")
 
 rdma_executable(ib_acme
-  linux/libacm_linux.c
   src/acme.c
   src/libacm.c
   src/parse.c
diff --git a/ibacm/linux/libacm_linux.c b/ibacm/linux/libacm_linux.c
deleted file mode 100644
index 2b8a910..0000000
--- a/ibacm/linux/libacm_linux.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2009 Intel Corporation. All rights reserved.
- *
- * This software is available to you under the OpenIB.org BSD license
- * below:
- *
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- *
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- *
- *      - Redistributions in binary form must reproduce the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer in the documentation and/or other materials
- *        provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <osd.h>
-
-pthread_mutex_t lock;
-
-static void __attribute__((constructor)) lib_init(void)
-{
-	pthread_mutex_init(&lock, NULL);
-}
diff --git a/ibacm/src/libacm.c b/ibacm/src/libacm.c
index 4273dfe..1980919 100644
--- a/ibacm/src/libacm.c
+++ b/ibacm/src/libacm.c
@@ -38,7 +38,7 @@
 #include <netdb.h>
 #include <arpa/inet.h>
 
-extern pthread_mutex_t lock;
+static pthread_mutex_t acm_lock = PTHREAD_MUTEX_INITIALIZER;
 static int sock = -1;
 static short server_port = 6125;
 
@@ -212,7 +212,7 @@ static int acm_resolve(uint8_t *src, uint8_t *dest, uint8_t type,
 	struct acm_msg msg;
 	int ret, cnt = 0;
 
-	pthread_mutex_lock(&lock);
+	pthread_mutex_lock(&acm_lock);
 	memset(&msg, 0, sizeof msg);
 	msg.hdr.version = ACM_VERSION;
 	msg.hdr.opcode = ACM_OP_RESOLVE;
@@ -246,7 +246,7 @@ static int acm_resolve(uint8_t *src, uint8_t *dest, uint8_t type,
 
 	ret = acm_format_resp(&msg, paths, count, print);
 out:
-	pthread_mutex_unlock(&lock);
+	pthread_mutex_unlock(&acm_lock);
 	return ret;
 }
 
@@ -275,7 +275,7 @@ int ib_acm_resolve_path(struct ibv_path_record *path, uint32_t flags)
 	struct acm_ep_addr_data *data;
 	int ret;
 
-	pthread_mutex_lock(&lock);
+	pthread_mutex_lock(&acm_lock);
 	memset(&msg, 0, sizeof msg);
 	msg.hdr.version = ACM_VERSION;
 	msg.hdr.opcode = ACM_OP_RESOLVE;
@@ -299,7 +299,7 @@ int ib_acm_resolve_path(struct ibv_path_record *path, uint32_t flags)
 		*path = data->info.path;
 
 out:
-	pthread_mutex_unlock(&lock);
+	pthread_mutex_unlock(&acm_lock);
 	return ret;
 }
 
@@ -308,7 +308,7 @@ int ib_acm_query_perf(int index, uint64_t **counters, int *count)
 	struct acm_msg msg;
 	int ret, i;
 
-	pthread_mutex_lock(&lock);
+	pthread_mutex_lock(&acm_lock);
 	memset(&msg, 0, sizeof msg);
 	msg.hdr.version = ACM_VERSION;
 	msg.hdr.opcode = ACM_OP_PERF_QUERY;
@@ -341,7 +341,7 @@ int ib_acm_query_perf(int index, uint64_t **counters, int *count)
 		(*counters)[i] = ntohll(msg.perf_data[i]);
 	ret = 0;
 out:
-	pthread_mutex_unlock(&lock);
+	pthread_mutex_unlock(&acm_lock);
 	return ret;
 }
 
@@ -353,7 +353,7 @@ int ib_acm_enum_ep(int index, struct acm_ep_config_data **data)
 	int cnt;
 	struct acm_ep_config_data *edata;
 
-	pthread_mutex_lock(&lock);
+	pthread_mutex_lock(&acm_lock);
 	memset(&msg, 0, sizeof msg);
 	msg.hdr.version = ACM_VERSION;
 	msg.hdr.opcode = ACM_OP_EP_QUERY;
@@ -391,7 +391,7 @@ int ib_acm_enum_ep(int index, struct acm_ep_config_data **data)
 	*data = edata;
 	ret = 0;
 out:
-	pthread_mutex_unlock(&lock);
+	pthread_mutex_unlock(&acm_lock);
 	return ret;
 }
 
@@ -404,7 +404,7 @@ int ib_acm_query_perf_ep_addr(uint8_t *src, uint8_t type,
 	if (!src) 
 		return -1;
 
-	pthread_mutex_lock(&lock);
+	pthread_mutex_lock(&acm_lock);
 	memset(&msg, 0, sizeof msg);
 	msg.hdr.version = ACM_VERSION;
 	msg.hdr.opcode = ACM_OP_PERF_QUERY;
@@ -444,7 +444,7 @@ int ib_acm_query_perf_ep_addr(uint8_t *src, uint8_t type,
 
 	ret = 0;
 out:
-	pthread_mutex_unlock(&lock);
+	pthread_mutex_unlock(&acm_lock);
 	return ret;
 }
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 11/13] ibacm: use ccan/list.h
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>

Trivial conversion, aided by the additional type safety and helpers.

Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
 ibacm/linux/dlist.h        |  80 ------------------
 ibacm/prov/acmp/src/acmp.c | 141 +++++++++++--------------------
 ibacm/src/acm.c            | 206 ++++++++++++++-------------------------------
 3 files changed, 112 insertions(+), 315 deletions(-)
 delete mode 100644 ibacm/linux/dlist.h

diff --git a/ibacm/linux/dlist.h b/ibacm/linux/dlist.h
deleted file mode 100644
index 89f5af3..0000000
--- a/ibacm/linux/dlist.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2009 Intel Corporation. All rights reserved.
- *
- * This software is available to you under the OpenIB.org BSD license
- * below:
- *
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- *
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- *
- *      - Redistributions in binary form must reproduce the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer in the documentation and/or other materials
- *        provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef _DLIST_H_
-#define _DLIST_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct _DLIST_ENTRY {
-	struct _DLIST_ENTRY	*Next;
-	struct _DLIST_ENTRY	*Prev;
-
-}	DLIST_ENTRY;
-
-static void DListInit(DLIST_ENTRY *pHead)
-{
-	pHead->Next = pHead;
-	pHead->Prev = pHead;
-}
-
-static int DListEmpty(DLIST_ENTRY *pHead)
-{
-	return pHead->Next == pHead;
-}
-
-static void DListInsertAfter(DLIST_ENTRY *pNew, DLIST_ENTRY *pHead)
-{
-	pNew->Next = pHead->Next;
-	pNew->Prev = pHead;
-	pHead->Next->Prev = pNew;
-	pHead->Next = pNew;
-}
-
-static void DListInsertBefore(DLIST_ENTRY *pNew, DLIST_ENTRY *pHead)
-{
-	DListInsertAfter(pNew, pHead->Prev);
-}
-
-#define DListInsertHead DListInsertAfter
-#define DListInsertTail DListInsertBefore
-
-static void DListRemove(DLIST_ENTRY *pEntry)
-{
-	pEntry->Prev->Next = pEntry->Next;
-	pEntry->Next->Prev = pEntry->Prev;
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _DLIST_H_
diff --git a/ibacm/prov/acmp/src/acmp.c b/ibacm/prov/acmp/src/acmp.c
index 1cb14e1..1e37ee4 100644
--- a/ibacm/prov/acmp/src/acmp.c
+++ b/ibacm/prov/acmp/src/acmp.c
@@ -45,7 +45,6 @@
 #include <infiniband/umad.h>
 #include <infiniband/verbs.h>
 #include <ifaddrs.h>
-#include <dlist.h>
 #include <dlfcn.h> 
 #include <search.h>
 #include <netdb.h>
@@ -56,6 +55,7 @@
 #include <linux/netlink.h>
 #include <linux/rtnetlink.h>
 #include <inttypes.h>
+#include <ccan/list.h>
 #include "acm_util.h"
 #include "acm_mad.h"
 
@@ -113,7 +113,7 @@ struct acmp_dest {
 	struct ibv_path_record path;
 	union ibv_gid          mgid;
 	uint64_t               req_id;
-	DLIST_ENTRY            req_queue;
+	struct list_head       req_queue;
 	uint32_t               remote_qpn;
 	pthread_mutex_t        lock;
 	enum acmp_state        state;
@@ -129,7 +129,7 @@ struct acmp_device;
 struct acmp_port {
 	struct acmp_device  *dev;
 	const struct acm_port *port;
-	DLIST_ENTRY         ep_list;
+	struct list_head    ep_list;
 	pthread_mutex_t     lock;
 	struct acmp_dest    sa_dest;
 	enum ibv_port_state state;
@@ -148,7 +148,7 @@ struct acmp_device {
 	struct ibv_comp_channel *channel;
 	struct ibv_pd           *pd;
 	uint64_t                guid;
-	DLIST_ENTRY             entry;
+	struct list_node        entry;
 	pthread_t               comp_thread_id;
 	int                     port_cnt;
 	struct acmp_port        port[0];
@@ -157,7 +157,7 @@ struct acmp_device {
 /* Maintain separate virtual send queues to avoid deadlock */
 struct acmp_send_queue {
 	int                   credits;
-	DLIST_ENTRY           pending;
+	struct list_head      pending;
 };
 
 struct acmp_addr {
@@ -173,7 +173,7 @@ struct acmp_ep {
 	struct ibv_qp         *qp;
 	struct ibv_mr         *mr;
 	uint8_t               *recv_bufs;
-	DLIST_ENTRY           entry;
+	struct list_node      entry;
 	char		      id_string[ACM_MAX_ADDRESS];
 	void                  *dest_map[ACM_ADDRESS_RESERVED - 1];
 	struct acmp_dest      mc_dest[MAX_EP_MC];
@@ -184,15 +184,15 @@ struct acmp_ep {
 	pthread_mutex_t       lock;
 	struct acmp_send_queue resolve_queue;
 	struct acmp_send_queue resp_queue;
-	DLIST_ENTRY           active_queue;
-	DLIST_ENTRY           wait_queue;
+	struct list_head      active_queue;
+	struct list_head      wait_queue;
 	enum acmp_state       state;
 	struct acmp_addr      addr_info[MAX_EP_ADDR];
 	atomic_t              counters[ACM_MAX_COUNTER];
 };
 
 struct acmp_send_msg {
-	DLIST_ENTRY          entry;
+	struct list_node     entry;
 	struct acmp_ep       *ep;
 	struct acmp_dest     *dest;
 	struct ibv_ah        *ah;
@@ -210,7 +210,7 @@ struct acmp_send_msg {
 
 struct acmp_request {
 	uint64_t	id;
-	DLIST_ENTRY	entry;
+	struct list_node entry;
 	struct acm_msg	msg;
 	struct acmp_ep	*ep;
 };
@@ -249,11 +249,11 @@ static struct acm_provider def_prov = {
 	.query_perf = acmp_query_perf,
 };
 
-static DLIST_ENTRY acmp_dev_list;
+static LIST_HEAD(acmp_dev_list);
 static pthread_mutex_t acmp_dev_lock;
 
 static atomic_t g_tid;
-static DLIST_ENTRY timeout_list;
+static LIST_HEAD(timeout_list);
 static event_t timeout_event;
 static atomic_t wait_cnt;
 static pthread_t retry_thread_id;
@@ -301,7 +301,7 @@ static void
 acmp_init_dest(struct acmp_dest *dest, uint8_t addr_type,
 	       const uint8_t *addr, size_t size)
 {
-	DListInit(&dest->req_queue);
+	list_head_init(&dest->req_queue);
 	atomic_init(&dest->refcnt);
 	atomic_set(&dest->refcnt, 1);
 	pthread_mutex_init(&dest->lock, NULL);
@@ -508,11 +508,11 @@ static void acmp_post_send(struct acmp_send_queue *queue, struct acmp_send_msg *
 	if (queue->credits) {
 		acm_log(2, "posting send to QP\n");
 		queue->credits--;
-		DListInsertTail(&msg->entry, &ep->active_queue);
+		list_add_tail(&ep->active_queue, &msg->entry);
 		ibv_post_send(ep->qp, &msg->wr, &bad_wr);
 	} else {
 		acm_log(2, "no sends available, queuing message\n");
-		DListInsertTail(&msg->entry, &queue->pending);
+		list_add_tail(&queue->pending, &msg->entry);
 	}
 	pthread_mutex_unlock(&ep->lock);
 }
@@ -539,17 +539,14 @@ static void acmp_send_available(struct acmp_ep *ep, struct acmp_send_queue *queu
 {
 	struct acmp_send_msg *msg;
 	struct ibv_send_wr *bad_wr;
-	DLIST_ENTRY *entry;
 
-	if (DListEmpty(&queue->pending)) {
-		queue->credits++;
-	} else {
+	msg = list_pop(&queue->pending, struct acmp_send_msg, entry);
+	if (msg) {
 		acm_log(2, "posting queued send message\n");
-		entry = queue->pending.Next;
-		DListRemove(entry);
-		msg = container_of(entry, struct acmp_send_msg, entry);
-		DListInsertTail(&msg->entry, &ep->active_queue);
+		list_add_tail(&ep->active_queue, &msg->entry);
 		ibv_post_send(ep->qp, &msg->wr, &bad_wr);
+	} else {
+		queue->credits++;
 	}
 }
 
@@ -558,11 +555,11 @@ static void acmp_complete_send(struct acmp_send_msg *msg)
 	struct acmp_ep *ep = msg->ep;
 
 	pthread_mutex_lock(&ep->lock);
-	DListRemove(&msg->entry);
+	list_del(&msg->entry);
 	if (msg->tries) {
 		acm_log(2, "waiting for response\n");
 		msg->expires = time_stamp_ms() + ep->port->subnet_timeout + timeout;
-		DListInsertTail(&msg->entry, &ep->wait_queue);
+		list_add_tail(&ep->wait_queue, &msg->entry);
 		if (atomic_inc(&wait_cnt) == 1)
 			event_signal(&timeout_event);
 	} else {
@@ -575,20 +572,17 @@ static void acmp_complete_send(struct acmp_send_msg *msg)
 
 static struct acmp_send_msg *acmp_get_request(struct acmp_ep *ep, uint64_t tid, int *free)
 {
-	struct acmp_send_msg *msg, *req = NULL;
+	struct acmp_send_msg *msg, *next, *req = NULL;
 	struct acm_mad *mad;
-	DLIST_ENTRY *entry, *next;
 
 	acm_log(2, "\n");
 	pthread_mutex_lock(&ep->lock);
-	for (entry = ep->wait_queue.Next; entry != &ep->wait_queue; entry = next) {
-		next = entry->Next;
-		msg = container_of(entry, struct acmp_send_msg, entry);
+	list_for_each_safe(&ep->wait_queue, msg, next, entry) {
 		mad = (struct acm_mad *) msg->data;
 		if (mad->tid == tid) {
 			acm_log(2, "match found in wait queue\n");
 			req = msg;
-			DListRemove(entry);
+			list_del(&msg->entry);
 			(void) atomic_dec(&wait_cnt);
 			acmp_send_available(ep, msg->req_queue);
 			*free = 1;
@@ -596,8 +590,7 @@ static struct acmp_send_msg *acmp_get_request(struct acmp_ep *ep, uint64_t tid,
 		}
 	}
 
-	for (entry = ep->active_queue.Next; entry != &ep->active_queue; entry = entry->Next) {
-		msg = container_of(entry, struct acmp_send_msg, entry);
+	list_for_each(&ep->active_queue, msg, entry) {
 		mad = (struct acm_mad *) msg->data;
 		if (mad->tid == tid && msg->tries) {
 			acm_log(2, "match found in active queue\n");
@@ -972,14 +965,10 @@ static void
 acmp_complete_queued_req(struct acmp_dest *dest, uint8_t status)
 {
 	struct acmp_request *req;
-	DLIST_ENTRY *entry;
 
 	acm_log(2, "status %d\n", status);
 	pthread_mutex_lock(&dest->lock);
-	while (!DListEmpty(&dest->req_queue)) {
-		entry = dest->req_queue.Next;
-		DListRemove(entry);
-		req = container_of(entry, struct acmp_request, entry);
+	while ((req = list_pop(&dest->req_queue, struct acmp_request, entry))) {
 		pthread_mutex_unlock(&dest->lock);
 
 		acm_log(2, "completing request, client %" PRIu64 "\n", req->id);
@@ -1113,7 +1102,7 @@ acmp_process_addr_req(struct acmp_ep *ep, struct ibv_wc *wc, struct acm_mad *mad
 			status = acmp_record_acm_route(ep, dest);
 			break;
 		}
-		if (addr || !DListEmpty(&dest->req_queue)) {
+		if (addr || !list_empty(&dest->req_queue)) {
 			status = acmp_resolve_path_sa(ep, dest, acmp_resolve_sa_resp);
 			if (status)
 				break;
@@ -1458,15 +1447,12 @@ static void acmp_ep_join(struct acmp_ep *ep)
 static int acmp_port_join(void *port_context)
 {
 	struct acmp_ep *ep;
-	DLIST_ENTRY *ep_entry;
 	struct acmp_port *port = port_context;
 
 	acm_log(1, "device %s port %d\n", port->dev->verbs->device->name,
 		port->port_num);
 
-	for (ep_entry = port->ep_list.Next; ep_entry != &port->ep_list;
-		 ep_entry = ep_entry->Next) {
-		ep = container_of(ep_entry, struct acmp_ep, entry);
+	list_for_each(&port->ep_list, ep, entry) {
 		if (!ep->endpoint) {
 			/* Stale endpoint */
 			continue;
@@ -1497,16 +1483,11 @@ static int acmp_handle_event(void *port_context, enum ibv_event_type type)
 
 static void acmp_process_timeouts(void)
 {
-	DLIST_ENTRY *entry;
 	struct acmp_send_msg *msg;
 	struct acm_resolve_rec *rec;
 	struct acm_mad *mad;
-	
-	while (!DListEmpty(&timeout_list)) {
-		entry = timeout_list.Next;
-		DListRemove(entry);
 
-		msg = container_of(entry, struct acmp_send_msg, entry);
+	while ((msg = list_pop(&timeout_list, struct acmp_send_msg, entry))) {
 		mad = (struct acm_mad *) &msg->data[0];
 		rec = (struct acm_resolve_rec *) mad->data;
 
@@ -1521,24 +1502,21 @@ static void acmp_process_timeouts(void)
 
 static void acmp_process_wait_queue(struct acmp_ep *ep, uint64_t *next_expire)
 {
-	struct acmp_send_msg *msg;
-	DLIST_ENTRY *entry, *next;
+	struct acmp_send_msg *msg, *next;
 	struct ibv_send_wr *bad_wr;
 
-	for (entry = ep->wait_queue.Next; entry != &ep->wait_queue; entry = next) {
-		next = entry->Next;
-		msg = container_of(entry, struct acmp_send_msg, entry);
+	list_for_each_safe(&ep->wait_queue, msg, next, entry) {
 		if (msg->expires < time_stamp_ms()) {
-			DListRemove(entry);
+			list_del(&msg->entry);
 			(void) atomic_dec(&wait_cnt);
 			if (--msg->tries) {
 				acm_log(1, "notice - retrying request\n");
-				DListInsertTail(&msg->entry, &ep->active_queue);
+				list_add_tail(&ep->active_queue, &msg->entry);
 				ibv_post_send(ep->qp, &msg->wr, &bad_wr);
 			} else {
 				acm_log(0, "notice - failing request\n");
 				acmp_send_available(ep, msg->req_queue);
-				DListInsertTail(&msg->entry, &timeout_list);
+				list_add_tail(&timeout_list, &msg->entry);
 			}
 		} else {
 			*next_expire = min(*next_expire, msg->expires);
@@ -1556,7 +1534,6 @@ static void *acmp_retry_handler(void *context)
 	struct acmp_device *dev;
 	struct acmp_port *port;
 	struct acmp_ep *ep;
-	DLIST_ENTRY *dev_entry, *ep_entry;
 	uint64_t next_expire;
 	int i, wait;
 
@@ -1579,24 +1556,17 @@ static void *acmp_retry_handler(void *context)
 
 		next_expire = -1;
 		pthread_mutex_lock(&acmp_dev_lock);
-		for (dev_entry = acmp_dev_list.Next; dev_entry != &acmp_dev_list;
-		     dev_entry = dev_entry->Next) {
-
-			dev = container_of(dev_entry, struct acmp_device, entry);
+		list_for_each(&acmp_dev_list, dev, entry) {
 			pthread_mutex_unlock(&acmp_dev_lock);
 
 			for (i = 0; i < dev->port_cnt; i++) {
 				port = &dev->port[i];
 
 				pthread_mutex_lock(&port->lock);
-				for (ep_entry = port->ep_list.Next;
-				     ep_entry != &port->ep_list;
-				     ep_entry = ep_entry->Next) {
-
-					ep = container_of(ep_entry, struct acmp_ep, entry);
+				list_for_each(&port->ep_list, ep, entry) {
 					pthread_mutex_unlock(&port->lock);
 					pthread_mutex_lock(&ep->lock);
-					if (!DListEmpty(&ep->wait_queue))
+					if (!list_empty(&ep->wait_queue))
 						acmp_process_wait_queue(ep, &next_expire);
 					pthread_mutex_unlock(&ep->lock);
 					pthread_mutex_lock(&port->lock);
@@ -1735,7 +1705,7 @@ static uint8_t acmp_queue_req(struct acmp_dest *dest, uint64_t id, struct acm_ms
 	}
 	req->ep = dest->ep;
 
-	DListInsertTail(&req->entry, &dest->req_queue);
+	list_add_tail(&dest->req_queue, &req->entry);
 	return ACM_STATUS_SUCCESS;
 }
 
@@ -2446,15 +2416,12 @@ static void acmp_remove_addr(void *addr_context)
 static struct acmp_port *acmp_get_port(struct acm_endpoint *endpoint)
 {
 	struct acmp_device *dev;
-	DLIST_ENTRY *dev_entry;
 
 	acm_log(1, "dev 0x%" PRIx64 " port %d pkey 0x%x\n",
 		endpoint->port->dev->dev_guid, endpoint->port->port_num,
 		endpoint->pkey);
-	for (dev_entry = acmp_dev_list.Next; dev_entry != &acmp_dev_list;
-	     dev_entry = dev_entry->Next) {
 
-		dev = container_of(dev_entry, struct acmp_device, entry);
+	list_for_each(&acmp_dev_list, dev, entry) {
 		if (dev->guid == endpoint->port->dev->dev_guid)
 			return &dev->port[endpoint->port->port_num - 1];
 	}
@@ -2466,13 +2433,11 @@ static struct acmp_ep *
 acmp_get_ep(struct acmp_port *port, struct acm_endpoint *endpoint)
 {
 	struct acmp_ep *ep;
-	DLIST_ENTRY *entry;
 
 	acm_log(1, "dev 0x%" PRIx64 " port %d pkey 0x%x\n",
 		endpoint->port->dev->dev_guid, endpoint->port->port_num, endpoint->pkey);
-	for (entry = port->ep_list.Next; entry != &port->ep_list;
-	     entry = entry->Next) {
-		ep = container_of(entry, struct acmp_ep, entry);
+
+	list_for_each(&port->ep_list, ep, entry) {
 		if (ep->pkey == endpoint->pkey)
 			return ep;
 	}
@@ -2526,10 +2491,10 @@ acmp_alloc_ep(struct acmp_port *port, struct acm_endpoint *endpoint)
 	ep->pkey = endpoint->pkey;
 	ep->resolve_queue.credits = resolve_depth;
 	ep->resp_queue.credits = send_depth;
-	DListInit(&ep->resolve_queue.pending);
-	DListInit(&ep->resp_queue.pending);
-	DListInit(&ep->active_queue);
-	DListInit(&ep->wait_queue);
+	list_head_init(&ep->resolve_queue.pending);
+	list_head_init(&ep->resp_queue.pending);
+	list_head_init(&ep->active_queue);
+	list_head_init(&ep->wait_queue);
 	pthread_mutex_init(&ep->lock, NULL);
 	sprintf(ep->id_string, "%s-%d-0x%x", port->dev->verbs->device->name,
 		port->port_num, endpoint->pkey);
@@ -2628,7 +2593,7 @@ static int acmp_open_endpoint(const struct acm_endpoint *endpoint,
 		goto err2;
 
 	pthread_mutex_lock(&port->lock);
-	DListInsertHead(&ep->entry, &port->ep_list);
+	list_add(&port->ep_list, &ep->entry);
 	pthread_mutex_unlock(&port->lock);
 	acmp_ep_preload(ep);
 	acmp_ep_join(ep);
@@ -2757,7 +2722,7 @@ static void acmp_init_port(struct acmp_port *port, struct acmp_device *dev,
 	port->dev = dev;
 	port->port_num = port_num;
 	pthread_mutex_init(&port->lock, NULL);
-	DListInit(&port->ep_list);
+	list_head_init(&port->ep_list);
 	acmp_init_dest(&port->sa_dest, ACM_ADDRESS_LID, NULL, 0);
 	port->state = IBV_PORT_DOWN;
 }
@@ -2768,16 +2733,12 @@ static int acmp_open_dev(const struct acm_device *device, void **dev_context)
 	size_t size;
 	struct ibv_device_attr attr;
 	int i, ret;
-	DLIST_ENTRY *dev_entry;
 	struct ibv_context *verbs;
 
 	acm_log(1, "dev_guid 0x%" PRIx64 " %s\n", device->dev_guid,
 		device->verbs->device->name);
 
-	for (dev_entry = acmp_dev_list.Next; dev_entry != &acmp_dev_list;
-	     dev_entry = dev_entry->Next) {
-		dev = container_of(dev_entry, struct acmp_device, entry);
-
+	list_for_each(&acmp_dev_list, dev, entry) {
 		if (dev->guid == device->dev_guid) {
 			acm_log(2, "dev_guid 0x%" PRIx64 " already exits\n",
 				device->dev_guid);
@@ -2839,7 +2800,7 @@ static int acmp_open_dev(const struct acm_device *device, void **dev_context)
 	}
 
 	pthread_mutex_lock(&acmp_dev_lock);
-	DListInsertHead(&dev->entry, &acmp_dev_list);
+	list_add(&acmp_dev_list, &dev->entry);
 	pthread_mutex_unlock(&acmp_dev_lock);
 	dev->guid = device->dev_guid;
 	*dev_context = dev;
@@ -2947,9 +2908,7 @@ static void __attribute__((constructor)) acmp_init(void)
 
 	atomic_init(&g_tid);
 	atomic_init(&wait_cnt);
-	DListInit(&acmp_dev_list);
 	pthread_mutex_init(&acmp_dev_lock, NULL);
-	DListInit(&timeout_list);
 	event_init(&timeout_event);
 
 	umad_init();
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index 37bbbe7..0571363 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -46,7 +46,6 @@
 #include <infiniband/verbs.h>
 #include <infiniband/umad_types.h>
 #include <infiniband/umad_sa.h>
-#include <dlist.h>
 #include <dlfcn.h> 
 #include <search.h>
 #include <net/if.h>
@@ -59,6 +58,7 @@
 #include <rdma/ib_user_sa.h>
 #include <poll.h>
 #include <inttypes.h>
+#include <ccan/list.h>
 #include "acm_mad.h"
 #include "acm_util.h"
 #if !defined(RDMA_NL_LS_F_ERR)
@@ -75,19 +75,19 @@
 #define NL_CLIENT_INDEX 0
 
 struct acmc_subnet {
-	DLIST_ENTRY            entry;
+	struct list_node       entry;
 	uint64_t               subnet_prefix;
 };
 
 struct acmc_prov {
 	struct acm_provider    *prov;
 	void                   *handle; 
-	DLIST_ENTRY            entry;   
-	DLIST_ENTRY            subnet_list;
+	struct list_node       entry;   
+	struct list_head       subnet_list;
 };
 
 struct acmc_prov_context {
-	DLIST_ENTRY             entry;
+	struct list_node        entry;
 	atomic_t                refcnt;
 	struct acm_provider     *prov;
 	void                    *context;
@@ -103,11 +103,11 @@ struct acmc_port {
 	int		    mad_portid;
 	int		    mad_agentid;
 	struct ib_mad_addr  sa_addr;
-	DLIST_ENTRY         sa_pending;
-	DLIST_ENTRY	    sa_wait;
+	struct list_head    sa_pending;
+	struct list_head    sa_wait;
 	int		    sa_credits;
 	pthread_mutex_t     lock;
-	DLIST_ENTRY         ep_list;
+	struct list_head    ep_list;
 	enum ibv_port_state state;
 	int                 gid_cnt;
 	union ibv_gid       *gid_tbl;
@@ -119,8 +119,8 @@ struct acmc_port {
 
 struct acmc_device {
 	struct acm_device       device;
-	DLIST_ENTRY             entry;
-	DLIST_ENTRY             prov_dev_context_list;
+	struct list_node        entry;
+	struct list_head        prov_dev_context_list;
 	int                     port_cnt;
 	struct acmc_port        port[0];
 };
@@ -136,7 +136,7 @@ struct acmc_ep {
 	struct acm_endpoint   endpoint;
 	void                  *prov_ep_context;
 	struct acmc_addr      addr_info[MAX_EP_ADDR];
-	DLIST_ENTRY	      entry;
+	struct list_node      entry;
 };
 
 struct acmc_client {
@@ -153,7 +153,7 @@ union socket_addr {
 };
 
 struct acmc_sa_req {
-	DLIST_ENTRY		entry;
+	struct list_node	entry;
 	struct acmc_ep		*ep;
 	void			(*resp_handler)(struct acm_sa_mad *);
 	struct acm_sa_mad	mad;
@@ -175,10 +175,10 @@ struct acm_nl_msg {
 };
 
 static char def_prov_name[ACM_PROV_NAME_SIZE] = "ibacmp";
-static DLIST_ENTRY provider_list;
+static LIST_HEAD(provider_list);
 static struct acmc_prov *def_provider = NULL;
 
-static DLIST_ENTRY dev_list;
+static LIST_HEAD(dev_list);
 
 static int listen_socket;
 static int ip_mon_socket;
@@ -308,13 +308,11 @@ acm_alloc_prov_context(struct acm_provider *prov)
 }
 
 static struct acmc_prov_context * 
-acm_get_prov_context(DLIST_ENTRY *list, struct acm_provider *prov)
+acm_get_prov_context(struct list_head *list, struct acm_provider *prov)
 {
-	DLIST_ENTRY *entry;
 	struct acmc_prov_context *ctx;
 
-	for (entry = list->Next; entry != list; entry = entry->Next) {
-		ctx = container_of(entry, struct acmc_prov_context, entry);
+	list_for_each(list, ctx, entry) {
 		if (ctx->prov == prov) {
 			return ctx;
 		}
@@ -324,7 +322,7 @@ acm_get_prov_context(DLIST_ENTRY *list, struct acm_provider *prov)
 }
 
 static struct acmc_prov_context *
-acm_acquire_prov_context(DLIST_ENTRY *list, struct acm_provider *prov)
+acm_acquire_prov_context(struct list_head *list, struct acm_provider *prov)
 {
 	struct acmc_prov_context *ctx;
 
@@ -335,7 +333,7 @@ acm_acquire_prov_context(DLIST_ENTRY *list, struct acm_provider *prov)
 			acm_log(0, "Error -- failed to allocate provider context\n");
 			return NULL;
 		}
-		DListInsertTail(&ctx->entry, list);
+		list_add_tail(list, &ctx->entry);
 	} else {
 		atomic_inc(&ctx->refcnt);
 	}
@@ -347,7 +345,7 @@ static void
 acm_release_prov_context(struct acmc_prov_context *ctx)
 {
 	if (atomic_dec(&ctx->refcnt) <= 0) {
-		DListRemove(&ctx->entry);
+		list_del(&ctx->entry);
 		free(ctx);
 	}
 }
@@ -679,7 +677,6 @@ acm_get_port_ep_address(struct acmc_port *port, struct acm_ep_addr_data *data)
 {
 	struct acmc_ep *ep;
 	struct acm_address *addr;
-	DLIST_ENTRY *ep_entry;
 	int i;
 
 	if (port->state != IBV_PORT_ACTIVE)
@@ -689,10 +686,7 @@ acm_get_port_ep_address(struct acmc_port *port, struct acm_ep_addr_data *data)
 	    !acm_is_path_from_port(port, &data->info.path))
 		return NULL;
 
-	for (ep_entry = port->ep_list.Next; ep_entry != &port->ep_list;
-	     ep_entry = ep_entry->Next) {
-
-		ep = container_of(ep_entry, struct acmc_ep, entry);
+	list_for_each(&port->ep_list, ep, entry) {
 		if ((data->type == ACM_EP_INFO_PATH) &&
 		    (!data->info.path.pkey ||
 		     (ntohs(data->info.path.pkey) == ep->endpoint.pkey))) {
@@ -715,16 +709,12 @@ static struct acmc_addr *acm_get_ep_address(struct acm_ep_addr_data *data)
 {
 	struct acmc_device *dev;
 	struct acmc_addr *addr;
-	DLIST_ENTRY *dev_entry;
 	int i;
 
 	acm_format_name(2, log_data, sizeof log_data,
 			data->type, data->info.addr, sizeof data->info.addr);
 	acm_log(2, "%s\n", log_data);
-	for (dev_entry = dev_list.Next; dev_entry != &dev_list;
-		 dev_entry = dev_entry->Next) {
-
-		dev = container_of(dev_entry, struct acmc_device, entry);
+	list_for_each(&dev_list, dev, entry) {
 		for (i = 0; i < dev->port_cnt; i++) {
 			addr = acm_get_port_ep_address(&dev->port[i], data);
 			if (addr)
@@ -741,27 +731,17 @@ static struct acmc_addr *acm_get_ep_address(struct acm_ep_addr_data *data)
 static struct acmc_ep *acm_get_ep(int index)
 {
 	struct acmc_device *dev;
-	DLIST_ENTRY *dev_entry;
 	struct acmc_ep *ep;
-	DLIST_ENTRY *ep_entry;
 	int i, inx = 0;
 
 	acm_log(2, "ep index %d\n", index);
-	for (dev_entry = dev_list.Next; dev_entry != &dev_list;
-	     dev_entry = dev_entry->Next) {
-		dev = container_of(dev_entry, struct acmc_device, entry);
+	list_for_each(&dev_list, dev, entry) {
 		for (i = 0; i < dev->port_cnt; i++) {
 			if (dev->port[i].state != IBV_PORT_ACTIVE)
 				continue;
-			for (ep_entry = dev->port[i].ep_list.Next; 
-			     ep_entry != &dev->port[i].ep_list;
-			     ep_entry = ep_entry->Next, inx++) {
-				if (index == inx) {
-					ep = container_of(ep_entry, 
-							  struct acmc_ep, 
-							  entry);
+			list_for_each(&dev->port[i].ep_list, ep, entry) {
+				if (index == inx)
 					return ep;
-				}
 			}
 		}
 	}
@@ -1271,27 +1251,19 @@ static void acm_ip_iter_cb(char *ifname, union ibv_gid *gid, uint16_t pkey,
  */
 static int resync_system_ips(void)
 {
-	DLIST_ENTRY *dev_entry;
 	struct acmc_device *dev;
 	struct acmc_port *port;
 	struct acmc_ep *ep;
-	DLIST_ENTRY *entry;
 	int i, cnt;
 
 	acm_log(0, "Resyncing all IP's\n");
 
 	/* mark all IP's invalid */
-	for (dev_entry = dev_list.Next; dev_entry != &dev_list;
-	     dev_entry = dev_entry->Next) {
-		dev = container_of(dev_entry, struct acmc_device, entry);
-
+	list_for_each(&dev_list, dev, entry) {
 		for (cnt = 0; cnt < dev->port_cnt; cnt++) {
 			port = &dev->port[cnt];
 
-			for (entry = port->ep_list.Next; entry != &port->ep_list;
-			     entry = entry->Next) {
-				ep = container_of(entry, struct acmc_ep, entry);
-
+			list_for_each(&port->ep_list, ep, entry) {
 				for (i = 0; i < MAX_EP_ADDR; i++) {
 					if (ep->addr_info[i].addr.type == ACM_ADDRESS_IP ||
 					    ep->addr_info[i].addr.type == ACM_ADDRESS_IP6)
@@ -1703,7 +1675,6 @@ static void acm_server(void)
 	fd_set readfds;
 	int i, n, ret;
 	struct acmc_device *dev;
-	DLIST_ENTRY *dev_entry;
 
 	acm_log(0, "started\n");
 	acm_init_server();
@@ -1731,9 +1702,7 @@ static void acm_server(void)
 			}
 		}
 
-		for (dev_entry = dev_list.Next; dev_entry != &dev_list;
-		     dev_entry = dev_entry->Next) {
-			dev = container_of(dev_entry, struct acmc_device, entry);
+		list_for_each(&dev_list, dev, entry) {
 			FD_SET(dev->device.verbs->async_fd, &readfds);
 			n = max(n, (int) dev->device.verbs->async_fd);
 		}
@@ -1761,9 +1730,7 @@ static void acm_server(void)
 			}
 		}
 
-		for (dev_entry = dev_list.Next; dev_entry != &dev_list;
-		     dev_entry = dev_entry->Next) {
-			dev = container_of(dev_entry, struct acmc_device, entry);
+		list_for_each(&dev_list, dev, entry) {
 			if (FD_ISSET(dev->device.verbs->async_fd, &readfds)) {
 				acm_log(2, "handling event from %s\n", 
 					dev->device.verbs->device->name);
@@ -1907,15 +1874,10 @@ out:
 static struct acmc_device *
 acm_get_device_from_gid(union ibv_gid *sgid, uint8_t *port)
 {
-	DLIST_ENTRY *dev_entry;
 	struct acmc_device *dev;
 	int i;
 
-	for (dev_entry = dev_list.Next; dev_entry != &dev_list;
-		 dev_entry = dev_entry->Next) {
-
-		dev = container_of(dev_entry, struct acmc_device, entry);
-
+	list_for_each(&dev_list, dev, entry) {
 		for (*port = 1; *port <= dev->port_cnt; (*port)++) {
 
 			for (i = 0; i < dev->port[*port - 1].gid_cnt; i++) {
@@ -2032,12 +1994,10 @@ out:
 static struct acmc_ep *acm_find_ep(struct acmc_port *port, uint16_t pkey)
 {
 	struct acmc_ep *ep, *res = NULL;
-	DLIST_ENTRY *entry;
 
 	acm_log(2, "pkey 0x%x\n", pkey);
 
-	for (entry = port->ep_list.Next; entry != &port->ep_list; entry = entry->Next) {
-		ep = container_of(entry, struct acmc_ep, entry);
+	list_for_each(&port->ep_list, ep, entry) {
 		if (ep->endpoint.pkey == pkey) {
 			res = ep;
 			break;
@@ -2111,7 +2071,7 @@ static void acm_ep_up(struct acmc_port *port, uint16_t pkey)
 		goto ep_close;
 	}
 
-	DListInsertHead(&ep->entry, &port->ep_list);
+	list_add(&port->ep_list, &ep->entry);
 	return;
 
 ep_close:
@@ -2123,22 +2083,13 @@ ep_close:
 
 static void acm_assign_provider(struct acmc_port *port)
 {
-	DLIST_ENTRY *entry;
 	struct acmc_prov *prov;
-	DLIST_ENTRY *sub_entry;
 	struct acmc_subnet *subnet;
 
 	acm_log(2, "port %s/%d\n", port->port.dev->verbs->device->name, 
 		port->port.port_num);
-	for (entry = provider_list.Next; entry != &provider_list; 
-	     entry = entry->Next) {
-		prov = container_of(entry, struct acmc_prov, entry);
-
-		for (sub_entry = prov->subnet_list.Next; 
-		     sub_entry != &prov->subnet_list; 
-		     sub_entry = sub_entry->Next) {
-			subnet = container_of(sub_entry, struct acmc_subnet,
-					      entry);
+	list_for_each(&provider_list, prov, entry) {
+		list_for_each(&prov->subnet_list, subnet, entry) {
 			if (subnet->subnet_prefix == 
 			    port->gid_tbl[0].global.subnet_prefix) {
 				acm_log(2, "Found provider %s for port %s/%d\n",
@@ -2291,16 +2242,11 @@ err1:
 
 static void acm_shutdown_port(struct acmc_port *port)
 {
-	DLIST_ENTRY *entry;
 	struct acmc_ep *ep;
 	struct acmc_prov_context *dev_ctx;
 
-	while (!DListEmpty(&port->ep_list)) {
-		entry = port->ep_list.Next;
-		DListRemove(entry);
-		ep = container_of(entry, struct acmc_ep, entry);
+	while ((ep = list_pop(&port->ep_list, struct acmc_ep, entry)))
 		acm_ep_down(ep);
-	}
 
 	if (port->prov_port_context) {
 		port->prov->close_port(port->prov_port_context);
@@ -2404,14 +2350,10 @@ static void acm_event_handler(struct acmc_device *dev)
 static void acm_activate_devices(void)
 {
 	struct acmc_device *dev;
-	DLIST_ENTRY *dev_entry;
 	int i;
 
 	acm_log(1, "\n");
-	for (dev_entry = dev_list.Next; dev_entry != &dev_list;
-		dev_entry = dev_entry->Next) {
-
-		dev = container_of(dev_entry, struct acmc_device, entry);
+	list_for_each(&dev_list, dev, entry) {
 		for (i = 0; i < dev->port_cnt; i++) {
 			acm_port_up(&dev->port[i]);
 		}
@@ -2426,9 +2368,9 @@ acm_open_port(struct acmc_port *port, struct acmc_device *dev, uint8_t port_num)
 	port->port.dev = &dev->device;
 	port->port.port_num = port_num;
 	pthread_mutex_init(&port->lock, NULL);
-	DListInit(&port->ep_list);
-	DListInit(&port->sa_pending);
-	DListInit(&port->sa_wait);
+	list_head_init(&port->ep_list);
+	list_head_init(&port->sa_pending);
+	list_head_init(&port->sa_wait);
 	port->sa_credits = sa.depth;
 	port->sa_addr.qpn = htonl(1);
 	port->sa_addr.qkey = htonl(ACM_QKEY);
@@ -2475,13 +2417,13 @@ static void acm_open_dev(struct ibv_device *ibdev)
 	dev->device.verbs = verbs;
 	dev->device.dev_guid = ibv_get_device_guid(ibdev);
 	dev->port_cnt = attr.phys_port_cnt;
-	DListInit(&dev->prov_dev_context_list);
+	list_head_init(&dev->prov_dev_context_list);
 
 	for (i = 0; i < dev->port_cnt; i++) {
 		acm_open_port(&dev->port[i], dev, i + 1);
 	}
 
-	DListInsertHead(&dev->entry, &dev_list);
+	list_add(&dev_list, &dev->entry);
 
 	acm_log(1, "%s opened\n", ibdev->name);
 	return;
@@ -2507,7 +2449,7 @@ static int acm_open_devices(void)
 		acm_open_dev(ibdev[i]);
 
 	ibv_free_device_list(ibdev);
-	if (DListEmpty(&dev_list)) {
+	if (list_empty(&dev_list)) {
 		acm_log(0, "ERROR - no devices\n");
 		return -1;
 	}
@@ -2523,7 +2465,6 @@ static void acm_load_prov_config(void)
 	char prov_name[ACM_PROV_NAME_SIZE];
 	uint64_t prefix;
 	struct acmc_prov *prov;
-	DLIST_ENTRY *entry;
 	struct acmc_subnet *subnet;
 
 	if (!(fd = fopen(opts_file, "r")))
@@ -2562,9 +2503,7 @@ static void acm_load_prov_config(void)
 		/* Convert it into network byte order */
 		prefix = htonll(prefix);
 
-		for (entry = provider_list.Next; entry != &provider_list; 
-		     entry = entry->Next) {
-			prov = container_of(entry, struct acmc_prov, entry);
+		list_for_each(&provider_list, prov, entry) {
 			if (!strcasecmp(prov->prov->name, prov_name)) {
 				subnet = calloc(1, sizeof (*subnet));
 				if (!subnet) {
@@ -2572,17 +2511,15 @@ static void acm_load_prov_config(void)
 					return;
 				}
 				subnet->subnet_prefix = prefix;
-				DListInsertTail(&subnet->entry, 
-						&prov->subnet_list);
+				list_add_after(&provider_list, &prov->entry,
+						&subnet->entry);
 			}
 		}
 	}
 
 	fclose(fd);
 
-	for (entry = provider_list.Next; entry != &provider_list; 
-	     entry = entry->Next) {
-		prov = container_of(entry, struct acmc_prov, entry);
+	list_for_each(&provider_list, prov, entry) {
 		if (!strcasecmp(prov->prov->name, def_prov_name)) {
 			def_provider = prov;
 			break;
@@ -2665,8 +2602,8 @@ static int acm_open_providers(void)
 
 		prov->prov = provider;
 		prov->handle = handle;
-		DListInit(&prov->subnet_list);
-		DListInsertTail(&prov->entry, &provider_list);
+		list_head_init(&prov->subnet_list);
+		list_add_tail(&provider_list, &prov->entry);
 		if (!strcasecmp(provider->name, def_prov_name)) 
 			def_provider = prov;
 	}
@@ -2679,23 +2616,15 @@ static int acm_open_providers(void)
 static void acm_close_providers(void)
 {
 	struct acmc_prov *prov;
-	DLIST_ENTRY *entry;
-	DLIST_ENTRY *sub_entry;
 	struct acmc_subnet *subnet;
 
 	acm_log(1, "\n");
 	def_provider = NULL;
-	while (!DListEmpty(&provider_list)) {
-		entry = provider_list.Next;
-		DListRemove(entry);
-		prov = container_of(entry, struct acmc_prov, entry);
-		while (!DListEmpty(&prov->subnet_list)) {
-			sub_entry = prov->subnet_list.Next;
-			DListRemove(sub_entry);
-			subnet = container_of(sub_entry, struct acmc_subnet,
-					      entry);
+
+	while ((prov = list_pop(&provider_list, struct acmc_prov, entry))) {
+		while ((subnet = list_pop(&prov->subnet_list,
+				struct acmc_subnet, entry)))
 			free(subnet);
-		}
 		dlclose(prov->handle);
 		free(prov);
 	}
@@ -2704,23 +2633,17 @@ static void acm_close_providers(void)
 static int acmc_init_sa_fds(void)
 {
 	struct acmc_device *dev;
-	DLIST_ENTRY *dev_entry;
 	int ret, p, i = 0;
 
-	for (dev_entry = dev_list.Next; dev_entry != &dev_list;
-	     dev_entry = dev_entry->Next) {
-		dev = container_of(dev_entry, struct acmc_device, entry);
+	list_for_each(&dev_list, dev, entry)
 		sa.nfds += dev->port_cnt;
-	}
 
 	sa.fds = calloc(sa.nfds, sizeof(*sa.fds));
 	sa.ports = calloc(sa.nfds, sizeof(*sa.ports));
 	if (!sa.fds || !sa.ports)
 		return -ENOMEM;
 
-	for (dev_entry = dev_list.Next; dev_entry != &dev_list;
-	     dev_entry = dev_entry->Next) {
-		dev = container_of(dev_entry, struct acmc_device, entry);
+	list_for_each(&dev_list, dev, entry) {
 		for (p = 0; p < dev->port_cnt; p++) {
 			sa.fds[i].fd = umad_get_fd(dev->port[p].mad_portid);
 			sa.fds[i].events = POLLIN;
@@ -2784,16 +2707,16 @@ int acm_send_sa_mad(struct acm_sa_mad *mad)
 	mad->umad.addr.pkey_index = req->ep->port->sa_pkey_index;
 
 	pthread_mutex_lock(&port->lock);
-	if (port->sa_credits && DListEmpty(&port->sa_wait)) {
+	if (port->sa_credits && list_empty(&port->sa_wait)) {
 		ret = umad_send(port->mad_portid, port->mad_agentid, &mad->umad,
 				sizeof mad->sa_mad, sa.timeout, sa.retries);
 		if (!ret) {
 			port->sa_credits--;
-			DListInsertTail(&req->entry, &port->sa_pending);
+			list_add_tail(&port->sa_pending, &req->entry);
 		}
 	} else {
 		ret = 0;
-		DListInsertTail(&req->entry, &port->sa_wait);
+		list_add_tail(&port->sa_wait, &req->entry);
 	}
 	pthread_mutex_unlock(&port->lock);
 	return ret;
@@ -2805,18 +2728,18 @@ static void acmc_send_queued_req(struct acmc_port *port)
 	int ret;
 
 	pthread_mutex_lock(&port->lock);
-	if (DListEmpty(&port->sa_wait) || !port->sa_credits) {
+	if (list_empty(&port->sa_wait) || !port->sa_credits) {
 		pthread_mutex_unlock(&port->lock);
 		return;
 	}
 
-	req = container_of(port->sa_wait.Next, struct acmc_sa_req, entry);
-	DListRemove(&req->entry);
+	req = list_pop(&port->sa_wait, struct acmc_sa_req, entry);
+
 	ret = umad_send(port->mad_portid, port->mad_agentid, &req->mad.umad,
 			sizeof req->mad.sa_mad, sa.timeout, sa.retries);
 	if (!ret) {
 		port->sa_credits--;
-		DListInsertTail(&req->entry, &port->sa_pending);
+		list_add_tail(&port->sa_pending, &req->entry);
 	}
 	pthread_mutex_unlock(&port->lock);
 
@@ -2830,7 +2753,6 @@ static void acmc_recv_mad(struct acmc_port *port)
 {
 	struct acmc_sa_req *req;
 	struct acm_sa_mad resp;
-	DLIST_ENTRY *entry;
 	int ret, len, found;
 	struct umad_hdr *hdr;
 
@@ -2848,13 +2770,11 @@ static void acmc_recv_mad(struct acmc_port *port)
 		hdr->method, hdr->status, hdr->tid, hdr->attr_id, hdr->attr_mod);
 	found = 0;
 	pthread_mutex_lock(&port->lock);
-	for (entry = port->sa_pending.Next; entry != &port->sa_pending;
-	     entry = entry->Next) {
-		req = container_of(entry, struct acmc_sa_req, entry);
+	list_for_each(&port->sa_pending, req, entry) {
 		/* The lower 32-bit of the tid is used for agentid in umad */
 		if (req->mad.sa_mad.mad_hdr.tid == (hdr->tid & 0xFFFFFFFF00000000)) {
 			found = 1;
-			DListRemove(entry);
+			list_del(&req->entry);
 			port->sa_credits++;
 			break;
 		}
@@ -3086,8 +3006,6 @@ int main(int argc, char **argv)
 	acm_log(0, "Assistant to the InfiniBand Communication Manager\n");
 	acm_log_options();
 
-	DListInit(&provider_list);
-	DListInit(&dev_list);
 	for (i = 0; i < ACM_MAX_COUNTER; i++)
 		atomic_init(&counter[i]);
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 12/13] ibacm: mark symbols static where possible
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>

Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
 ibacm/prov/acmp/src/acmp.c | 2 +-
 ibacm/src/acm.c            | 2 +-
 ibacm/src/acme.c           | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ibacm/prov/acmp/src/acmp.c b/ibacm/prov/acmp/src/acmp.c
index 1e37ee4..2ca0bf5 100644
--- a/ibacm/prov/acmp/src/acmp.c
+++ b/ibacm/prov/acmp/src/acmp.c
@@ -259,7 +259,7 @@ static atomic_t wait_cnt;
 static pthread_t retry_thread_id;
 static int retry_thread_started = 0;
 
-__thread char log_data[ACM_MAX_ADDRESS];
+static __thread char log_data[ACM_MAX_ADDRESS];
 
 /*
  * Service options - may be set through ibacm_opts.cfg file.
diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index 0571363..b7f1dc0 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -186,7 +186,7 @@ static struct acmc_client client_array[FD_SETSIZE - 1];
 
 static FILE *flog;
 static pthread_mutex_t log_lock;
-__thread char log_data[ACM_MAX_ADDRESS];
+static __thread char log_data[ACM_MAX_ADDRESS];
 static atomic_t counter[ACM_MAX_COUNTER];
 
 static struct acmc_device *
diff --git a/ibacm/src/acme.c b/ibacm/src/acme.c
index 5a571cf..36221f4 100644
--- a/ibacm/src/acme.c
+++ b/ibacm/src/acme.c
@@ -69,10 +69,10 @@ enum perf_query_output {
 	PERF_QUERY_EP_ADDR
 };
 static enum perf_query_output perf_query;
-int verbose;
+static int verbose;
 
-struct ibv_context **verbs;
-int dev_cnt;
+static struct ibv_context **verbs;
+static int dev_cnt;
 
 #define VPRINT(format, ...) do { if (verbose) printf(format, ## __VA_ARGS__ ); } while (0)
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 13/13] ibacm: mark large integer constant as unsigned long long
From: Christoph Hellwig @ 2016-10-17 19:11 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>

Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
 ibacm/src/acm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c
index b7f1dc0..2d0d1d4 100644
--- a/ibacm/src/acm.c
+++ b/ibacm/src/acm.c
@@ -2772,7 +2772,7 @@ static void acmc_recv_mad(struct acmc_port *port)
 	pthread_mutex_lock(&port->lock);
 	list_for_each(&port->sa_pending, req, entry) {
 		/* The lower 32-bit of the tid is used for agentid in umad */
-		if (req->mad.sa_mad.mad_hdr.tid == (hdr->tid & 0xFFFFFFFF00000000)) {
+		if (req->mad.sa_mad.mad_hdr.tid == (hdr->tid & 0xFFFFFFFF00000000ULL)) {
 			found = 1;
 			list_del(&req->entry);
 			port->sa_credits++;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* Re: iscsi_trx going into D state
From: Robert LeBlanc @ 2016-10-17 19:11 UTC (permalink / raw)
  To: Zhu Lingshan
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-scsi-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <CAANLjFobXiBO2tXxTBB-8BQjM8FC0wmxdxQvEd6Rp=1LZkrvpA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Sorry hit send too soon.

In addition, on the client we see:
# ps -aux | grep D | grep kworker
root      5583  0.0  0.0      0     0 ?        D    11:55   0:03 [kworker/11:0]
root      7721  0.1  0.0      0     0 ?        D    12:00   0:04 [kworker/4:25]
root     10877  0.0  0.0      0     0 ?        D    09:27   0:00 [kworker/22:1]
root     11246  0.0  0.0      0     0 ?        D    10:28   0:00 [kworker/30:2]
root     14034  0.0  0.0      0     0 ?        D    12:20   0:02 [kworker/19:15]
root     14048  0.0  0.0      0     0 ?        D    12:20   0:00 [kworker/16:0]
root     15871  0.0  0.0      0     0 ?        D    12:25   0:00 [kworker/13:0]
root     17442  0.0  0.0      0     0 ?        D    12:28   0:00 [kworker/9:1]
root     17816  0.0  0.0      0     0 ?        D    12:30   0:00 [kworker/11:1]
root     18744  0.0  0.0      0     0 ?        D    12:32   0:00 [kworker/10:2]
root     19060  0.0  0.0      0     0 ?        D    12:32   0:00 [kworker/29:0]
root     21748  0.0  0.0      0     0 ?        D    12:40   0:00 [kworker/21:0]
root     21967  0.0  0.0      0     0 ?        D    12:40   0:00 [kworker/22:0]
root     21978  0.0  0.0      0     0 ?        D    12:40   0:00 [kworker/22:2]
root     22024  0.0  0.0      0     0 ?        D    12:40   0:00 [kworker/22:4]
root     22035  0.0  0.0      0     0 ?        D    12:40   0:00 [kworker/22:5]
root     22060  0.0  0.0      0     0 ?        D    12:40   0:00 [kworker/16:1]
root     22282  0.0  0.0      0     0 ?        D    12:41   0:00 [kworker/26:0]
root     22362  0.0  0.0      0     0 ?        D    12:42   0:00 [kworker/18:9]
root     22426  0.0  0.0      0     0 ?        D    12:42   0:00 [kworker/16:3]
root     23298  0.0  0.0      0     0 ?        D    12:43   0:00 [kworker/12:1]
root     23302  0.0  0.0      0     0 ?        D    12:43   0:00 [kworker/12:5]
root     24264  0.0  0.0      0     0 ?        D    12:46   0:00 [kworker/30:1]
root     24271  0.0  0.0      0     0 ?        D    12:46   0:00 [kworker/14:8]
root     24441  0.0  0.0      0     0 ?        D    12:47   0:00 [kworker/9:7]
root     24443  0.0  0.0      0     0 ?        D    12:47   0:00 [kworker/9:9]
root     25005  0.0  0.0      0     0 ?        D    12:48   0:00 [kworker/30:3]
root     25158  0.0  0.0      0     0 ?        D    12:49   0:00 [kworker/9:12]
root     26382  0.0  0.0      0     0 ?        D    12:52   0:00 [kworker/13:2]
root     26453  0.0  0.0      0     0 ?        D    12:52   0:00 [kworker/21:2]
root     26724  0.0  0.0      0     0 ?        D    12:53   0:00 [kworker/19:1]
root     28400  0.0  0.0      0     0 ?        D    05:20   0:00 [kworker/25:1]
root     29552  0.0  0.0      0     0 ?        D    11:40   0:00 [kworker/17:1]
root     29811  0.0  0.0      0     0 ?        D    11:40   0:00 [kworker/7:10]
root     31903  0.0  0.0      0     0 ?        D    11:43   0:00 [kworker/26:1]

And all of the processes have this stack:
[<ffffffffa0727ed5>] iser_release_work+0x25/0x60 [ib_iser]
[<ffffffff8109633f>] process_one_work+0x14f/0x400
[<ffffffff81096bb4>] worker_thread+0x114/0x470
[<ffffffff8109c6f8>] kthread+0xd8/0xf0
[<ffffffff8172004f>] ret_from_fork+0x3f/0x70
[<ffffffffffffffff>] 0xffffffffffffffff

We are not able to log out of the sessions in all cases. And have to
restart the box.

iscsiadm -m session will show messages like:
iscsiadm: could not read session targetname: 5
iscsiadm: could not find session info for session100
iscsiadm: could not read session targetname: 5
iscsiadm: could not find session info for session101
iscsiadm: could not read session targetname: 5
iscsiadm: could not find session info for session103
...

I can't find any way to force iscsiadm to clean up these sessions
possibly due to tasks in D state.
----------------
Robert LeBlanc
PGP Fingerprint 79A2 9CA4 6CC4 45DD A904  C70E E654 3BB2 FA62 B9F1


On Mon, Oct 17, 2016 at 10:32 AM, Robert LeBlanc <robert-4JaGZRWAfWbajFs6igw21g@public.gmane.org> wrote:
> Some more info as we hit this this morning. We have volumes mirrored
> between two targets and we had one target on the kernel with the three
> patches mentioned in this thread [0][1][2] and the other was on a
> kernel without the patches. We decided that after a week and a half we
> wanted to get both targets on the same kernel so we rebooted the
> non-patched target. Within an hour we saw iSCSI in D state with the
> same stack trace so it seems that we are not hitting any of the
> WARN_ON lines. We are getting both iscsi_trx and iscsi_np both in D
> state, this time we have two iscsi_trx processes in D state. I don't
> know if stale sessions on the clients could be contributing to this
> issue (the target trying to close non-existent sessions??). This is on
> 4.4.23. Any more debug info we can throw at this problem to help?
>
> Thank you,
> Robert LeBlanc
>
> # ps aux | grep D | grep iscsi
> root     16525  0.0  0.0      0     0 ?        D    08:50   0:00 [iscsi_np]
> root     16614  0.0  0.0      0     0 ?        D    08:50   0:00 [iscsi_trx]
> root     16674  0.0  0.0      0     0 ?        D    08:50   0:00 [iscsi_trx]
>
> # for i in 16525 16614 16674; do echo $i; cat /proc/$i/stack; done
> 16525
> [<ffffffff814f0d5f>] iscsit_stop_session+0x19f/0x1d0
> [<ffffffff814e2516>] iscsi_check_for_session_reinstatement+0x1e6/0x270
> [<ffffffff814e4ed0>] iscsi_target_check_for_existing_instances+0x30/0x40
> [<ffffffff814e5020>] iscsi_target_do_login+0x140/0x640
> [<ffffffff814e63bc>] iscsi_target_start_negotiation+0x1c/0xb0
> [<ffffffff814e410b>] iscsi_target_login_thread+0xa9b/0xfc0
> [<ffffffff8109c748>] kthread+0xd8/0xf0
> [<ffffffff8172018f>] ret_from_fork+0x3f/0x70
> [<ffffffffffffffff>] 0xffffffffffffffff
> 16614
> [<ffffffff814cca79>] target_wait_for_sess_cmds+0x49/0x1a0
> [<ffffffffa064692b>] isert_wait_conn+0x1ab/0x2f0 [ib_isert]
> [<ffffffff814f0ef2>] iscsit_close_connection+0x162/0x870
> [<ffffffff814df9bf>] iscsit_take_action_for_connection_exit+0x7f/0x100
> [<ffffffff814f00a0>] iscsi_target_rx_thread+0x5a0/0xe80
> [<ffffffff8109c748>] kthread+0xd8/0xf0
> [<ffffffff8172018f>] ret_from_fork+0x3f/0x70
> [<ffffffffffffffff>] 0xffffffffffffffff
> 16674
> [<ffffffff814cca79>] target_wait_for_sess_cmds+0x49/0x1a0
> [<ffffffffa064692b>] isert_wait_conn+0x1ab/0x2f0 [ib_isert]
> [<ffffffff814f0ef2>] iscsit_close_connection+0x162/0x870
> [<ffffffff814df9bf>] iscsit_take_action_for_connection_exit+0x7f/0x100
> [<ffffffff814f00a0>] iscsi_target_rx_thread+0x5a0/0xe80
> [<ffffffff8109c748>] kthread+0xd8/0xf0
> [<ffffffff8172018f>] ret_from_fork+0x3f/0x70
> [<ffffffffffffffff>] 0xffffffffffffffff
>
>
> [0] https://www.spinics.net/lists/target-devel/msg13463.html
> [1] http://marc.info/?l=linux-scsi&m=147282568910535&w=2
> [2] http://www.spinics.net/lists/linux-scsi/msg100221.html
> ----------------
> Robert LeBlanc
> PGP Fingerprint 79A2 9CA4 6CC4 45DD A904  C70E E654 3BB2 FA62 B9F1
>
>
> On Fri, Oct 7, 2016 at 8:59 PM, Zhu Lingshan <lszhu-IBi9RG/b67k@public.gmane.org> wrote:
>> Hi Robert,
>>
>> I also see this issue, but this is not the only code path can trigger this
>> problem, I think you may also see iscsi_np in D status. I fixed one code
>> path whitch still not merged to mainline. I will forward you my patch later.
>> Note: my patch only fixed one code path, you may see other call statck with
>> D status.
>>
>> Thanks,
>> BR
>> Zhu Lingshan
>>
>>
>> 在 2016/10/1 1:14, Robert LeBlanc 写道:
>>>
>>> We are having a reoccurring problem where iscsi_trx is going into D
>>> state. It seems like it is waiting for a session tear down to happen
>>> or something, but keeps waiting. We have to reboot these targets on
>>> occasion. This is running the 4.4.12 kernel and we have seen it on
>>> several previous 4.4.x and 4.2.x kernels. There is no message in dmesg
>>> or /var/log/messages. This seems to happen with increased frequency
>>> when we have a disruption in our Infiniband fabric, but can happen
>>> without any changes to the fabric (other than hosts rebooting).
>>>
>>> # ps aux | grep iscsi | grep D
>>> root      4185  0.0  0.0      0     0 ?        D    Sep29   0:00
>>> [iscsi_trx]
>>> root     18505  0.0  0.0      0     0 ?        D    Sep29   0:00
>>> [iscsi_np]
>>>
>>> # cat /proc/4185/stack
>>> [<ffffffff814cc999>] target_wait_for_sess_cmds+0x49/0x1a0
>>> [<ffffffffa087292b>] isert_wait_conn+0x1ab/0x2f0 [ib_isert]
>>> [<ffffffff814f0de2>] iscsit_close_connection+0x162/0x840
>>> [<ffffffff814df8df>] iscsit_take_action_for_connection_exit+0x7f/0x100
>>> [<ffffffff814effc0>] iscsi_target_rx_thread+0x5a0/0xe80
>>> [<ffffffff8109c6f8>] kthread+0xd8/0xf0
>>> [<ffffffff8172004f>] ret_from_fork+0x3f/0x70
>>> [<ffffffffffffffff>] 0xffffffffffffffff
>>>
>>> # cat /proc/18505/stack
>>> [<ffffffff814f0c71>] iscsit_stop_session+0x1b1/0x1c0
>>> [<ffffffff814e2436>] iscsi_check_for_session_reinstatement+0x1e6/0x270
>>> [<ffffffff814e4df0>] iscsi_target_check_for_existing_instances+0x30/0x40
>>> [<ffffffff814e4f40>] iscsi_target_do_login+0x140/0x640
>>> [<ffffffff814e62dc>] iscsi_target_start_negotiation+0x1c/0xb0
>>> [<ffffffff814e402b>] iscsi_target_login_thread+0xa9b/0xfc0
>>> [<ffffffff8109c6f8>] kthread+0xd8/0xf0
>>> [<ffffffff8172004f>] ret_from_fork+0x3f/0x70
>>> [<ffffffffffffffff>] 0xffffffffffffffff
>>>
>>> What can we do to help get this resolved?
>>>
>>> Thanks,
>>>
>>> ----------------
>>> Robert LeBlanc
>>> PGP Fingerprint 79A2 9CA4 6CC4 45DD A904  C70E E654 3BB2 FA62 B9F1
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>>> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH rdma-core 2/4] glue/redhat: add udev/systemd/etc infrastructure bits
From: Jason Gunthorpe @ 2016-10-17 19:14 UTC (permalink / raw)
  To: Doug Ledford; +Cc: Jarod Wilson, linux-rdma-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <a6c8091e-fe83-8413-77d7-4aac053b8e62-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

On Mon, Oct 17, 2016 at 02:56:37PM -0400, Doug Ledford wrote:
 
> Since it got snipped, I'm pretty sure it just lists opensm in the Wants=
> tag.  With systemd, that's a soft dependency.  Only if opensm is
> installed and configured to start anyway does systemd then order this
> item after opensm.  Since you need opensm for links to come up anyway,
> it makes sense for the order of startup for RDMA related items to be:

Daemons should not require opensm to be started to operate
correctly.

If they do we surely have a boot race bug that should be fixed,
because we cannot rely on a remote SM to have configured the port the
time window betweeen rdma.service completion and dependent service
start.

So I view every use of a opensm dependent in a unit file as either
unnecessary or working around a bug.. Lets ID the bugs so we at least
know where we stand..

Plus, there are more SM's than opensm, so we really should not
hardwire a single SM in the service files upstream, but try and work
with all the SMs...

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH 0/8] infiniband: Remove semaphores
From: Arnd Bergmann @ 2016-10-17 20:06 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Binoy Jayan, Doug Ledford, Sean Hefty, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <216461f1-3070-c93a-a560-7560a727cb8d-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>

On Monday, October 17, 2016 9:57:34 AM CEST Bart Van Assche wrote:
> On 10/17/2016 09:30 AM, Binoy Jayan wrote:
> > These are a set of patches which removes semaphores from infiniband.
> > These are part of a bigger effort to eliminate all semaphores from the
> > linux kernel.
> 
> Hello Binoy,
> 
> Why do you think it would be a good idea to eliminate all semaphores 
> from the Linux kernel? I don't know anyone who doesn't consider 
> semaphores a useful abstraction.

There are a several reasons why the semaphores as defined in the
kernel are bad and we should get rid of them:

- semaphores cannot be analysed using lockdep, since they don't
  always fit in the simpler 'mutex' semantics

- those that are basically mutexes should be converted to mutexes
  for efficiency and consistency anyway

- the semaphores that are not just used as mutexes are typically
  used as completions and should just be converted to completions
  for simplicity

- when running a preempt-rt kernel, semaphores suffer from priority
  inversion problems, while mutexes use use priority inheritance
  as a countermeasure

There are very few remaining semaphores in the kernel and generally
speaking we'd be better off removing them all so no new users
show up in the future. Most of them are trivial to replace with
mutexes or completions. For the ones that are not trivially replaced,
we have to look at each one and decide what to do about them,
there usually is some solution that actually improves the code.

Using an open-coded semaphore as a replacement is probably just
the last resort that we can consider once we are down to the
last handful of users. I haven't looked at drivers/infiniband/
yet for this, but I believe that drivers/acpi/ is a case for
which I see no better alternative (the AML bytecode requires
counting semaphore semantics).

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH rdma-core 2/4] glue/redhat: add udev/systemd/etc infrastructure bits
From: Jason Gunthorpe @ 2016-10-17 20:13 UTC (permalink / raw)
  To: Weiny, Ira
  Cc: Jarod Wilson, linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Doug Ledford, Hefty, Sean
In-Reply-To: <2807E5FD2F6FDA4886F6618EAC48510E24F0A408-8k97q/ur5Z2krb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>

On Mon, Oct 17, 2016 at 07:10:46PM +0000, Weiny, Ira wrote:

> What I have been worried about is conflicts between infiniband-diags
> and the new rdma-core.  RH made a separate package out of rdma-ndd
> so that would be easy but I don't think other distros have.

> So how do you obsolete "part" of a package?

The distros know how to do this, they just conflict with the old
version of infiniband-diags.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* RE: ibacm cleanups
From: Hefty, Sean @ 2016-10-17 20:27 UTC (permalink / raw)
  To: Christoph Hellwig,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <1476731482-26491-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>

> This series fixed various sparse issues in ibacm, makes it use
> the common list helpers and removes various cruft.

Thanks - series looks good to me.

Acked-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox