| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
| |
Fixes Coverity CID 1463265
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
|
| |
Useful to start/stop services triggered by mountpoints.
See procd.sh procd_add_mount_trigger to make use of that.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
|
|
|
|
|
| |
Don't wait for calls to 'block' to complete unless it's for an
autofs event (which cannot be handled async).
Use uloop for 'mount.ready' notificaion when startup has completed
to avoid blocking in waitpid() while the 'block' process is calling
back via ubus.
This greatly reduces the amount of time blockd needs on boot.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
| |
Emmit mount.ready notification when 'block autofs start' has completed.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
|
|
| |
AUTOFS_IOC_SETTIMEOUT expects a pointer to an 'unsigned long' which
will result in out-of-bounds access when passing a pointer to an 'int'.
Change type of timeout to 'unsigned long'.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
| |
This reverts commit 4d4dcfb33c5d9fa31c9916e106bee309ec7b4b01.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
| |
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
|
|
|
|
| |
Not to be confused with cgroups, there are also POSIX process groups.
They do matter when it comes to autofs, as all requests coming from the
process group of the automounter itself will be ignored.
Hence, if blockd runs in the same process group as init and all
services, requests from services will be ignored.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
|
| |
Make it 'mount.add' instead of just 'add' which is more obvious when
used with procd_add_raw_trigger.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
|
|
|
|
| |
Also sending a ubus notification on mount hotplug provides a useful
shortcut for procd service triggers.
As the /etc/hotplug.d/mount API for now doesn't have any users and also
makes it hard to aggregate hotplug calls, we should consider removing it
in favor of only using triggers on the block notifications in future.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
| |
If a device cannot be found in /dev, also try /dev/mapper.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
| |
asprintf requires _GNU_SOURCE to be defined. Set it.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
|
|
|
| |
device names can be pretty long when using LVM2, mount targets are
user defined and can potentially also be of PATH_MAX length.
Replace static buffers with dynamically allocated strings to avoid
buffer overflow with too long device names or mount targets.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
|
| |
It allows getting info about specified device.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This resolves problem on boot with "mount" scripts being called too
early to get blockd info. With this change "mount" scripts won't get
called until blockd starts. On startup it requests all devices info and
calls relevant scripts.
This fixes samba36-hotplug package hotplug.d script.
One downside of this change is handling "mount" evens on block restart
or crash. On restart "add" actions will get executed for mounted /
available (autofs) devices. On crash no events will be generated.
Ref: http://lists.infradead.org/pipermail/openwrt-devel/2019-December/020886.html
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As blockd uses uloop calling any script and using waitpid() can easily
result in a lock. It's enough for script to use /bin/ubus to cause that.
It's not an option to drop waitpid() as it's important to e.g. call
mount scripts with ACTION=remove before unmounting devices. So solving
this problem requires using uloop_process.
Unfortunately this means:
1. Using callbacks making code slightly more complex
2. Dropping that nice devices_update_cb()
With this change however hotplug.d "mount" scripts can safely call
"ubus".
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
| |
Files like that can remain from using non-autofs mounting and can cause
mounting errors after switching to autofs:
blockd: failed to symlink /mnt/sda1->/tmp/run/blockd/sda1
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
| |
Devices handled with autofs should be seen as available even if
currently unmounted. Mounting is handled on demand and transparently for
users.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
| |
It may help understanding failure reason, e.g.:
blockd: failed to symlink /mnt/sda1->/tmp/run/blockd/sda1 (17) - File exists
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
| |
The point of "hotplug" call is to add or remove a single entry to/from
devices list. Using vlist_update() and vlist_flush() was clearing whole
list (and leaving the last entry in case of adding a device).
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
|
| |
vlist_add() expects key to point a persistent memory as it doesn't make
its copy. Passing blob_attr of current message was resulting in
undefined/random behavior including list corruption and possible
crashes.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
So far - when using autofs - "add" and "remove" action events were
triggered on every (un)mount. It wasn't very helpful when using autofs
due to its nature.
The point of blockd & autofs is to have block devices mounted on an
access request. Its users should not care / know if it's currently
mounted or not. Mounting should be handled transparently.
To make that work it requires informing listeners whenever device:
1) Becomes *ready* for mounting (by triggering "add" action)
2) Becomes *unavailable* (by triggering "remove" action)
The current mounting state is something that autofs & blockd should
handle internally and should not notify listeners about.
This is implemented by:
1) block generating events for non-autofs cases only (when (un)mounting)
2) blockd informing block when autofs resource becomes (un)available
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
|
|
|
|
| |
To keep autofs behavior consistent blockd should request both: mounting
and unmounting when needed. It's important as autofs-related actions may
require slightly different handling.
Without this patch:
1) autofs mounts were handled using TYPE_AUTOFS
2) autofs unmounts were handled using TYPE_HOTPLUG
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
|
|
|
|
|
|
|
|
|
|
| |
ubus message is parsed in the block_hotplug() which fills all the struct
device fields. Once that is done there is no need to parse original
message again - it's enough to get required data from the struct.
This also fixes handling messages with "autofs" set to 0. They were
incorrectly interpreted due to the missing blobmsg_get_u32().
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: John Crispin <john@phrozen.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
According to man page, using the EXIT_* macros is more portable than using
plain integer values.
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
|
|
Signed-off-by: John Crispin <john@phrozen.org>
|