lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 8 Sep 2018 09:34:32 +0200
From:   Valentin Vidic <Valentin.Vidic@...Net.hr>
To:     drbd-user@...ts.linbit.com
Cc:     Jens Axboe <axboe@...nel.dk>,
        Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
        linux-kernel@...r.kernel.org, stable@...r.kernel.org,
        linux-block@...r.kernel.org, xen-devel@...ts.xenproject.org,
        Roger Pau Monné <roger.pau@...rix.com>
Subject: Re: [DRBD-user] [PATCH] xen-blkback: Switch to closed state after
 releasing the backing device

On Fri, Sep 07, 2018 at 07:14:59PM +0200, Valentin Vidic wrote:
> In fact the first one is the original code path before I modified
> blkback.  The problem is it gets executed async from workqueue so
> it might not always run before the call to drbdadm secondary.

As the DRBD device gets released only when the last IO request
has finished, I found a way to check and wait for this in the
block-drbd script:

--- block-drbd.orig     2018-09-08 09:07:23.499648515 +0200
+++ block-drbd  2018-09-08 09:28:12.892193649 +0200
@@ -230,6 +230,24 @@
 and so cannot be mounted ${m2}${when}."
 }
 
+wait_for_inflight()
+{
+  local dev="$1"
+  local inflight="/sys/block/${dev#/dev/}/inflight"
+  local rd wr
+
+  if ! [ -f "$inflight" ]; then
+    return
+  fi
+
+  while true; do
+    read rd wr < $inflight
+    if [ "$rd" = "0" -a "$wr" = "0" ]; then
+      return
+    fi
+    sleep 1
+  done
+}
 
 t=$(xenstore_read_default "$XENBUS_PATH/type" 'MISSING')
 
@@ -285,6 +303,8 @@
         drbd_lrole="${drbd_role%%/*}"
         drbd_dev="$(drbdadm sh-dev $drbd_resource)"
 
+        wait_for_inflight $drbd_dev
+
         if [ "$drbd_lrole" != 'Secondary' ]; then
           drbdadm secondary $drbd_resource
         fi

-- 
Valentin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ