-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
WIP: mount: use libmount to monitor mountinfo+utab #194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The current systemd core uses inotify directly to monitor libmount-internal utab state. This is suboptimal as it relies on libmount internals which are not ABI. Since util-linux-2.26, libmount provides a monitor API to monitor both kernel and user-space mount state. Use this to replace our own hard-coded approach. This patch was originally written by: Karel Zak <kzak@redhat.com>
|
Semaphore currently fails because their build VMs are based on Ubuntu 14.04 which ship util-linux (at with it, libmount) in version 2.20. A PPA I found would give us version 2.25, but not 2.26. Why the version bump, and which minimum libmount requirement does the new code have? |
|
util-linux-2.26 is the version that introduced this monitor. This is still WIP, so no reason to worry about Semaphore. If we end up merging it, we can always provide the old code as workaround. |
|
@martinpitt : That would be great! But lets first figure out how to solve the libmount root-only restriction. If that requires util-linux changes, we have to wait for a new release, anyway. |
inotify_add_watch() requires that the file you want to monitor already exists, otherwise you need to monitor all directory for all IN_CREATE events. It's painful because you need to care about filenames on event etc. open(O_CREAT) is not problem for non-root user if the file already exists. So the question is why on "systemd --user" the file /run/mount/utab.lock does not exist if there is already running pid1 systemd that already monitoring the file. (or do you mix old pid1 systemd and new systemd --user? :-) |
|
@poettering I already had code to monitor all the directory, but it means that after each event you have to check filenames. The current implementation is simple and elegant, but unfortunately useless for non-root users :-( I'll try to improve it... |
|
@karelzak the commit i linked avoids having to check file names. It only looks for IN_ISDIR, that's all... |
|
@poettering I see, nice solution. Thanks. The libmount should be fixed now (util-linux/util-linux@7dc0f5c). I guess we can wait for util-linux v2.27 (Jul/Aug 2015) rather than try to backport etc... I'll send an updated version of the patch later (it's necessary to use mnt_monitor_next_change() to verify that an event is really about utab change). BTW, I think there is a bug in sd_network_monitor_flush(), the code assumes that inotify_add_watch() always allocates a new FD so it's safe to remove the old watch I guess that "mkdir /run/systemd/netif/FOO" in situation you monitor /run/systemd/netif/ will remove the watch of the directory at all. IMHO you need something like: karelzak@625671b (the patch is absolutely no tested, just my guess when I read the code :-)) |
|
@karelzak hmm, makes sense... Though I figure we can simplify the patch a bit by simply returning the wd from monitor_add_inotify_watch() as return value, under the assumption it is strictly positive, and thus no ambiguity is created between returning an error and a wd. @teg there's something to fix in sd-network! |
|
Please, close. Replaced by new version #986. |
Cc: @karelzak @poettering
This is a rebased and fixed version of Karel's original patch (see #53). It makes systemd use libmount to monitor utab and mountinfo files.
This is still not ready to be merged. It currently breaks
systemd --useras libmount requires you to be root to monitor 'utab'. Reason for this is "userspace_monitor_get_fd()" in libmount, which callsopen(O_CREAT)on the utab-lockfile (why?). Until this is fixed, I don't think we can merge this.One possible workaround in systemd is to call "mnt_monitor_get_fd()" early. Then call "mnt_monitor_enable_userspace()" afterwards, and ignore EPERM. However, this will disable 'utab' monitoring for non-root systemd. @karelzak, can you explain why that O_CREAT is needed?