10 Star 3 Fork 40

src-openEuler/lvm2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0004-bugfix-add-timeout-when-fail-to-wait-udev.patch 2.75 KB
一键复制 编辑 原始数据 按行查看 历史
wguanghao 提交于 2022-09-16 14:56 . upgrade version to 2.03.16
diff --git a/libdm/dm-tools/dmsetup.c b/libdm/dm-tools/dmsetup.c
index d01b8f2..a5cb551 100644
--- a/libdm/dm-tools/dmsetup.c
+++ b/libdm/dm-tools/dmsetup.c
@@ -1130,6 +1130,7 @@ out:
static int _create_one_device(const char *name, const char *file)
{
int r = 0;
+ int udev_wait_r = 1;
struct dm_task *dmt;
uint32_t cookie = 0;
uint16_t udev_flags = 0;
@@ -1202,13 +1203,15 @@ static int _create_one_device(const char *name, const char *file)
out:
if (!_udev_cookie)
- (void) dm_udev_wait(cookie);
+ udev_wait_r = dm_udev_wait(cookie);
if (r && _switches[VERBOSE_ARG])
r = _display_info(dmt);
dm_task_destroy(dmt);
+ if (!udev_wait_r)
+ return 0;
return r;
}
@@ -1431,6 +1434,7 @@ static int _create(CMD_ARGS)
static int _do_rename(const char *name, const char *new_name, const char *new_uuid) {
int r = 0;
+ int udev_wait_r = 1;
struct dm_task *dmt;
uint32_t cookie = 0;
uint16_t udev_flags = 0;
@@ -1475,10 +1479,13 @@ static int _do_rename(const char *name, const char *new_name, const char *new_uu
out:
if (!_udev_cookie)
- (void) dm_udev_wait(cookie);
+ udev_wait_r = dm_udev_wait(cookie);
dm_task_destroy(dmt);
+ if (!udev_wait_r)
+ return 0;
+
return r;
}
@@ -1999,6 +2006,7 @@ static int _simple(int task, const char *name, uint32_t event_nr, int display)
int udev_wait_flag = task == DM_DEVICE_RESUME ||
task == DM_DEVICE_REMOVE;
int r = 0;
+ int udev_wait_r = 1;
struct dm_task *dmt;
@@ -2058,13 +2066,16 @@ static int _simple(int task, const char *name, uint32_t event_nr, int display)
out:
if (!_udev_cookie && udev_wait_flag)
- (void) dm_udev_wait(cookie);
+ udev_wait_r = dm_udev_wait(cookie);
if (r && display && _switches[VERBOSE_ARG])
r = _display_info(dmt);
dm_task_destroy(dmt);
+ if (!udev_wait_r)
+ return 0;
+
return r;
}
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index d75c704..e7c00f0 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -59,6 +59,7 @@ union semun
#endif
#endif
+#define UDEV_SEM_TIMEOUT 300
static char _dm_dir[PATH_MAX] = DEV_DIR DM_DIR;
static char _sysfs_dir[PATH_MAX] = "/sys/";
static char _path0[PATH_MAX]; /* path buffer, safe 4kB on stack */
@@ -2730,6 +2731,9 @@ static int _udev_wait(uint32_t cookie, int *nowait)
int semid;
struct sembuf sb = {0, 0, 0};
int val;
+ struct timespec timeout;
+ timeout.tv_sec = UDEV_SEM_TIMEOUT;
+ timeout.tv_nsec = 0;
if (!cookie || !dm_udev_get_sync_support())
return 1;
@@ -2765,7 +2769,7 @@ static int _udev_wait(uint32_t cookie, int *nowait)
cookie, semid);
repeat_wait:
- if (semop(semid, &sb, 1) < 0) {
+ if (semtimedop(semid, &sb, 1,&timeout) < 0) {
if (errno == EINTR)
goto repeat_wait;
else if (errno == EIDRM)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/lvm2.git
git@gitee.com:src-openeuler/lvm2.git
src-openeuler
lvm2
lvm2
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385