1 Star 0 Fork 50

zhongling.h/systemd

forked from src-anolis-os/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0212-mount-simplify-proc-self-mountinfo-handler.patch 3.04 KB
一键复制 编辑 原始数据 按行查看 历史
张彬琛 提交于 2021-01-20 13:59 . import systemd-239-29.el8.src.rpm
From daf63a3c6c6cd241017bdf9a26c7b1caf744e69b Mon Sep 17 00:00:00 2001
From: Lennart Poettering <[email protected]>
Date: Wed, 17 Jul 2019 14:53:07 +0200
Subject: [PATCH] mount: simplify /proc/self/mountinfo handler
Our IO handler is only installed for one fd, hence there's no reason to
conditionalize on it again.
Also, split out the draining into a helper function of its own.
(cherry picked from commit fcd8e119c28be19ffbc5227089cf4d3b8ba60238)
Conflicts:
src/core/mount.c
Related: #1696178
---
src/core/mount.c | 48 ++++++++++++++++++++++++++----------------------
1 file changed, 26 insertions(+), 22 deletions(-)
diff --git a/src/core/mount.c b/src/core/mount.c
index 16229d4af1..85b07375e2 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -1758,6 +1758,29 @@ fail:
mount_shutdown(m);
}
+static int drain_libmount(Manager *m) {
+ bool rescan = false;
+ int r;
+
+ assert(m);
+
+ /* Drain all events and verify that the event is valid.
+ *
+ * Note that libmount also monitors /run/mount mkdir if the directory does not exist yet. The mkdir
+ * may generate event which is irrelevant for us.
+ *
+ * error: r < 0; valid: r == 0, false positive: r == 1 */
+ do {
+ r = mnt_monitor_next_change(m->mount_monitor, NULL, NULL);
+ if (r < 0)
+ return log_error_errno(r, "Failed to drain libmount events: %m");
+ if (r == 0)
+ rescan = true;
+ } while (r == 0);
+
+ return rescan;
+}
+
static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
_cleanup_set_free_ Set *around = NULL, *gone = NULL;
Manager *m = userdata;
@@ -1769,28 +1792,9 @@ static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
assert(m);
assert(revents & EPOLLIN);
- if (fd == mnt_monitor_get_fd(m->mount_monitor)) {
- bool rescan = false;
-
- /* Drain all events and verify that the event is valid.
- *
- * Note that libmount also monitors /run/mount mkdir if the
- * directory does not exist yet. The mkdir may generate event
- * which is irrelevant for us.
- *
- * error: r < 0; valid: r == 0, false positive: rc == 1 */
- do {
- r = mnt_monitor_next_change(m->mount_monitor, NULL, NULL);
- if (r == 0)
- rescan = true;
- else if (r < 0)
- return log_error_errno(r, "Failed to drain libmount events");
- } while (r == 0);
-
- log_debug("libmount event [rescan: %s]", yes_no(rescan));
- if (!rescan)
- return 0;
- }
+ r = drain_libmount(m);
+ if (r <= 0)
+ return r;
r = mount_load_proc_self_mountinfo(m, true);
if (r < 0) {
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhonglingh/systemd.git
[email protected]:zhonglingh/systemd.git
zhonglingh
systemd
systemd
a8

搜索帮助