diff mbox series

blockd: restore device_move semantics

Message ID YlYXtvX0a1r4cRgY@makrotopia.org
State Accepted
Delegated to: Daniel Golle
Headers show
Series blockd: restore device_move semantics | expand

Commit Message

Daniel Golle April 13, 2022, 12:22 a.m. UTC
Before commit 4963db4 block device were only removed and re-added in
case of device_move() returning a non-zero value. Commit 4963db4 then
(supposedly) accidentally inverted that logic and also (probably to
work-around the problems resulting from the now inverted logic) limited
this behavior to autofs mounts, leaving the autofs codepath in a semi-
broken state.
Restore the original semantics as of before commit 4963db4 to fully
restore functionality for autofs mounts.

Fixes: 4963db4 ("blockd: use uloop_process for calling /sbin/hotplug-call mount")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 blockd.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/blockd.c b/blockd.c
index 8bb5005..9572fd0 100644
--- a/blockd.c
+++ b/blockd.c
@@ -349,13 +349,11 @@  block_hotplug(struct ubus_context *ctx, struct ubus_object *obj,
 
 		vlist_add(&devices, &device->node, device->name);
 
-		if (old && !device_move(old, device)) {
-			if (device->autofs) {
-				device_mount_remove(ctx, old);
-				device_mount_add(ctx, device);
-			} else {
+		if (old && device_move(old, device)) {
+			device_mount_remove(ctx, old);
+			device_mount_add(ctx, device);
+			if (!device->autofs)
 				block("mount", NULL, NULL, 0, NULL);
-			}
 		} else if (device->autofs) {
 			device_mount_add(ctx, device);
 		}