From: Bart Van Assche <Bart.VanAssche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
To: "jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org"
<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Cc: "linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"noas-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org"
<noas-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
"benjamin.drung-EIkl63zCoXaH+58JC4qpiA@public.gmane.org"
<benjamin.drung-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>,
"leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org"
<leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"talatb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org"
<talatb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Subject: Re: rdma-core in Dabian
Date: Fri, 12 May 2017 18:24:35 +0000 [thread overview]
Message-ID: <1494613473.14477.12.camel@sandisk.com> (raw)
In-Reply-To: <20170509181807.GB9715-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 2132 bytes --]
On Tue, 2017-05-09 at 12:18 -0600, Jason Gunthorpe wrote:
> On Tue, May 09, 2017 at 05:54:33PM +0000, Bart Van Assche wrote:
> > > * Bonus points: consolidate the srp daemon. Debian ships a different
> > > service file than upstream, but I am against an additional layer
> > > introduced by srp_daemon.sh. It would also be nice to have a systemd
> > > service shipped by upstream (and not just in the redhat directory)
> >
> > I will have a look at this too.
>
> My thoughts..
>
> It looked to me like srp_daemon needed one process per port.
>
> The best path looked to me like using systemd templates (eg
> srp_daemon@mlx4_0/0) to allow systemd to directly manage the per port
> srp_daemon.
>
> Then the question is how to request the right templates are
> created.. Perhaps udev rules can do this directly, but I'm not sure
> about how to get the port #, perhaps an udev triggered script or
> something can do it.
>
> Perhaps there could be an inbetween progarm that took the udev events
> and asked systemd to make the right units.
>
> Another option is to have a srp_daemon 'runner' that monitors udev and
> actively manages a set of fork'd childern so that the children cover
> all required ports. But this is actually somewhat hard to do well..
>
> The big issue with the redhat script is that it is not hotplug safe,
> and needs special boot ordering, which we really need to get away from
> in general for robustness.
Hello Jason,
Thanks for having shared your thoughts.
When using systemd templates instead of the current approach it would
become cumbersome for users to stop and start the srp_daemon on all ports
simultaneously. Additionally, if an RDMA adapter is hot-added, should the
srp_daemon be started or should it not be started for the newly added ports?
An in-between program could indeed do the job of listening for udev events
and actively managing srp_daemon children. Since we already have an
in-between program, namely srp_daemon.sh, the simplest approach is to modify
that shell script. Can you have a look at the attached patch?
Thanks,
Bart.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-srp_daemon.service-Add-support-for-hotplugging.patch --]
[-- Type: text/x-patch; name="0001-srp_daemon.service-Add-support-for-hotplugging.patch", Size: 2836 bytes --]
From bec3884e36298ab2b6fb09c533b575fa95bd3378 Mon Sep 17 00:00:00 2001
From: Bart Van Assche <bart.vanassche@sandisk.com>
Date: Fri, 12 May 2017 10:24:44 -0700
Subject: [PATCH] srp_daemon.service: Add support for hotplugging
Instead of only starting srp_daemon.sh after the RDMA subsystem has
been initialized, make srp_daemon.sh scan periodically for RDMA ports.
An advantage of the new approach is that it supports hot-add of RDMA
adapters.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
redhat/srp_daemon.service | 4 ----
srp_daemon/srp_daemon.sh.in | 41 ++++++++++++++++++++++++++---------------
2 files changed, 26 insertions(+), 19 deletions(-)
diff --git a/redhat/srp_daemon.service b/redhat/srp_daemon.service
index 9510f5fb..cf98aa74 100644
--- a/redhat/srp_daemon.service
+++ b/redhat/srp_daemon.service
@@ -3,10 +3,6 @@ Description=Start or stop the daemon that attaches to SRP devices
Documentation=man:srp_daemon file:/etc/rdma/rdma.conf file:/etc/srp_daemon.conf
DefaultDependencies=false
Conflicts=emergency.target emergency.service
-Requires=rdma.service
-Wants=opensm.service
-After=rdma.service opensm.service
-After=network.target
Before=remote-fs-pre.target
[Service]
diff --git a/srp_daemon/srp_daemon.sh.in b/srp_daemon/srp_daemon.sh.in
index 75e8a31b..74c08d7a 100755
--- a/srp_daemon/srp_daemon.sh.in
+++ b/srp_daemon/srp_daemon.sh.in
@@ -37,6 +37,7 @@ rescan_interval=60
pids=()
pidfile="@CMAKE_INSTALL_FULL_RUNDIR@/srp_daemon.sh.pid"
mypid=$$
+umad_devs=()
trap_handler()
{
@@ -49,6 +50,17 @@ trap_handler()
exit 0
}
+# Check whether $1 is equal to one of $2..${$#}
+contains()
+{
+ local v
+
+ for v in "${@:2}"; do
+ [ "$v" = "$1" ] && return 0
+ done
+ return 1
+}
+
# Check if there is another copy running of srp_daemon.sh
if [ -f "$pidfile" ]; then
if [ -e "/proc/$(cat "$pidfile" 2>/dev/null)/status" ]; then
@@ -66,19 +78,18 @@ fi
trap 'trap_handler' 2 15
-while [ ! -d ${ibdir} ]
-do
- sleep 30
+while :; do
+ for d in ${ibdir}_mad/umad*; do
+ [ -e "$d" ] || continue
+ contains "$d" "${umad_devs[@]}" && continue
+ hca_id="$(<"$d/ibdev")"
+ port="$(<"$d/port")"
+ add_target="${ibdir}_srp/srp-${hca_id}-${port}/add_target"
+ if [ -e "${add_target}" ]; then
+ ${prog} -e -c -n -i "${hca_id}" -p "${port}" -R "${rescan_interval}" "${params[@]}" >/dev/null 2>&1 &
+ pids+=($!)
+ umad_dev+=($d)
+ fi
+ done
+ sleep $rescan_interval
done
-
-for d in ${ibdir}_mad/umad*; do
- hca_id="$(<"$d/ibdev")"
- port="$(<"$d/port")"
- add_target="${ibdir}_srp/srp-${hca_id}-${port}/add_target"
- if [ -e "${add_target}" ]; then
- ${prog} -e -c -n -i "${hca_id}" -p "${port}" -R "${rescan_interval}" "${params[@]}" >/dev/null 2>&1 &
- pids+=($!)
- fi
-done
-
-wait
--
2.12.2
next prev parent reply other threads:[~2017-05-12 18:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-07 6:43 rdma-core in Dabian Leon Romanovsky
[not found] ` <20170507064349.GM22833-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-05-09 17:43 ` Benjamin Drung
[not found] ` <1494351789.3752.5.camel-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
2017-05-09 17:54 ` Bart Van Assche
[not found] ` <1494352472.2518.10.camel-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-05-09 18:18 ` Jason Gunthorpe
[not found] ` <20170509181807.GB9715-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-05-12 18:24 ` Bart Van Assche [this message]
[not found] ` <1494613473.14477.12.camel-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-05-12 19:51 ` Jason Gunthorpe
2017-05-09 18:05 ` Jason Gunthorpe
[not found] ` <20170509180517.GA9715-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-05-10 9:35 ` Benjamin Drung
[not found] ` <1494408947.3739.2.camel-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
2017-05-10 15:50 ` Jason Gunthorpe
[not found] ` <20170510155005.GB1007-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-05-10 16:02 ` Leon Romanovsky
[not found] ` <20170510160201.GD1839-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-05-10 16:24 ` Benjamin Drung
2017-05-10 16:33 ` Jason Gunthorpe
[not found] ` <20170510163341.GA25041-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-05-10 16:50 ` Steve Wise
2017-05-10 16:58 ` Jason Gunthorpe
2017-05-10 16:58 ` Leon Romanovsky
[not found] ` <20170510165858.GG1839-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-05-10 18:47 ` Steve Wise
2017-05-10 16:19 ` Benjamin Drung
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1494613473.14477.12.camel@sandisk.com \
--to=bart.vanassche-xdaiopvojttbdgjk7y7tuq@public.gmane.org \
--cc=benjamin.drung-EIkl63zCoXaH+58JC4qpiA@public.gmane.org \
--cc=jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org \
--cc=leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=noas-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=talatb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).