Skip to content

Commit 5fbb115

Browse files
committed
Merge pull request #147 from ElNounch/attach_nbd
Fixing attach_nbd_device() captures of @xnbd-client PIDs
2 parents 10291f8 + a6adb30 commit 5fbb115

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

Linux/tree-common/functions

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -243,22 +243,22 @@ attach_nbd_device() {
243243
fi
244244

245245
# Connecting the device
246-
(
247-
export PATH=$(dirname $NBD_CLIENT)
246+
PATH="$(dirname $NBD_CLIENT):$PATH" \
248247
run $(basename $NBD_CLIENT) \
249-
--blocksize 4096 \
250-
--retry=$retries \
251-
$nbd_host $nbd_port \
252-
/dev/nbd${device} 2>/dev/null
253-
)
254-
local nbd_pid=$$
255-
run sh -ec "echo -1000 > /proc/$nbd_pid/oom_score_adj"
256-
run mkdir -p /run/sendsigs.omit.d
257-
run sh -ec "echo {$nbd_pid} > /run/sendsigs.omit.d/nbd{$device}"
248+
--blocksize 4096 \
249+
--retry=$retries \
250+
${nbd_host} ${nbd_port} \
251+
/dev/nbd${device}
252+
253+
# Checking device connection
254+
local nbd_pid=$($NBD_CLIENT --check /dev/nbd${device} 2>/dev/null)
255+
if [ $? -ne 0 ]; then
256+
log_fatal_msg "Device connection failed." && return;
257+
fi
258258

259-
# Checking if device is already attached
260-
run $NBD_CLIENT -c /dev/nbd${device} >/dev/null 2>/dev/null || \
261-
log_fatal_msg "Device connection failed."
259+
run sh -ec "echo -1000 > /proc/${nbd_pid}/oom_score_adj"
260+
run mkdir -p /run/sendsigs.omit.d
261+
run sh -ec "echo ${nbd_pid} > /run/sendsigs.omit.d/nbd${device}.pid"
262262

263263
# Fixing IO scheduler
264264
if grep -q '\[cfq\]' /sys/block/nbd${device}/queue/scheduler

0 commit comments

Comments
 (0)