summaryrefslogtreecommitdiff
path: root/blockd.c
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2018-12-06 09:13:39 +0100
committerRafał Miłecki <rafal@milecki.pl>2018-12-06 09:13:39 +0100
commitf6a96865da9162f45ea1d482c794fe14b26ecfe1 (patch)
tree6cdb4a412a0151c81dfafb41dfae3cc39666182e /blockd.c
parent1913feacb1ad1fb6433d316d81e2e3bee365ec19 (diff)
downloadfstools-f6a96865da9162f45ea1d482c794fe14b26ecfe1.tar.gz
blockd: don't unmount device when removing it from the list
Device gets removed from the list (vlist_delete()) when block calls "hotplug" method of blockd using ubus. Right after that block unmounts that device on its own. blockd shouldn't care about unmounting on its own for following reasons: 1) To avoid code/behavior duplication with block 2) To keep behavior consistent with mounting (blockd doesn't mount) 3) To allow implementing more features in block (e.g. hotplug.d events) To make unmounting the most reliable the plan is to have: 1) block receiving hotplug.d "block" subsystem events "remove" 2) blockd stopping reporting device (so we avoid new users & let existing ones realize mount can't be used anymore) 3) block notifying (through hotplug.d "mount" subsystem) all users about device being unmounted - that should stop all apps accessing it 4) block unmount device That should allow storage users stop accessing mount point & let block unmount device cleanly. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Acked-by: John Crispin <john@phrozen.org>
Diffstat (limited to 'blockd.c')
-rw-r--r--blockd.c26
1 files changed, 2 insertions, 24 deletions
diff --git a/blockd.c b/blockd.c
index a5da32c..1379635 100644
--- a/blockd.c
+++ b/blockd.c
@@ -112,34 +112,12 @@ static void
device_free(struct device *device)
{
struct blob_attr *data[__MOUNT_MAX];
- char *target = NULL;
- char *path = NULL, _path[64], *mp;
blobmsg_parse(mount_policy, __MOUNT_MAX, data,
blob_data(device->msg), blob_len(device->msg));
- if (data[MOUNT_AUTOFS]) {
- target = device->target;
- snprintf(_path, sizeof(_path), "/tmp/run/blockd/%s",
- blobmsg_get_string(data[MOUNT_DEVICE]));
- path = _path;
- } else {
- path = target = device->target;
- }
-
- mp = _find_mount_point(device->name);
- if (path && mp)
- if (umount2(path, MNT_DETACH))
- ULOG_ERR("failed to unmount %s\n", path);
- free(mp);
-
- if (!target)
- return;
-
- if (data[MOUNT_AUTOFS])
- unlink(target);
- else
- rmdir(target);
+ if (data[MOUNT_AUTOFS] && device->target)
+ unlink(device->target);
}
static void