mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
locks: Parse lock type earlier
Same reason as for previous patch. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
45
file-lock.c
45
file-lock.c
@@ -72,40 +72,10 @@ static int dump_one_file_lock(FileLockEntry *fle)
|
||||
fle, PB_FILE_LOCK);
|
||||
}
|
||||
|
||||
static int fill_flock_entry(FileLockEntry *fle, int fl_kind,
|
||||
const char *fl_type, const char *fl_option)
|
||||
static void fill_flock_entry(FileLockEntry *fle, int fl_kind, int fl_ltype)
|
||||
{
|
||||
fle->flag |= fl_kind;
|
||||
|
||||
if (!strcmp(fl_type, "MSNFS")) {
|
||||
fle->type |= LOCK_MAND;
|
||||
|
||||
if (!strcmp(fl_option, "READ")) {
|
||||
fle->type |= LOCK_READ;
|
||||
} else if (!strcmp(fl_option, "RW")) {
|
||||
fle->type |= LOCK_RW;
|
||||
} else if (!strcmp(fl_option, "WRITE")) {
|
||||
fle->type |= LOCK_WRITE;
|
||||
} else {
|
||||
pr_err("Unknown lock option!\n");
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
if (!strcmp(fl_option, "UNLCK")) {
|
||||
fle->type |= F_UNLCK;
|
||||
} else if (!strcmp(fl_option, "WRITE")) {
|
||||
fle->type |= F_WRLCK;
|
||||
} else if (!strcmp(fl_option, "READ")) {
|
||||
fle->type |= F_RDLCK;
|
||||
} else {
|
||||
pr_err("Unknown lock option!\n");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
err:
|
||||
return -1;
|
||||
fle->type = fl_ltype;
|
||||
}
|
||||
|
||||
static int get_fd_by_ino(unsigned long i_no, struct parasite_drain_fd *dfds,
|
||||
@@ -143,19 +113,14 @@ int dump_task_file_locks(struct parasite_ctl *ctl,
|
||||
list_for_each_entry(fl, &file_lock_list, list) {
|
||||
if (fl->fl_owner != pid)
|
||||
continue;
|
||||
pr_info("lockinfo: %lld:%d %s %s %d %02x:%02x:%ld %lld %s\n",
|
||||
fl->fl_id, fl->fl_kind, fl->fl_type, fl->fl_option,
|
||||
pr_info("lockinfo: %lld:%d %x %d %02x:%02x:%ld %lld %s\n",
|
||||
fl->fl_id, fl->fl_kind, fl->fl_ltype,
|
||||
fl->fl_owner, fl->maj, fl->min, fl->i_no,
|
||||
fl->start, fl->end);
|
||||
|
||||
file_lock_entry__init(&fle);
|
||||
fle.pid = ctl->pid.virt;
|
||||
|
||||
ret = fill_flock_entry(&fle, fl->fl_kind, fl->fl_type,
|
||||
fl->fl_option);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
fill_flock_entry(&fle, fl->fl_kind, fl->fl_ltype);
|
||||
fle.fd = get_fd_by_ino(fl->i_no, dfds, pid);
|
||||
if (fle.fd < 0) {
|
||||
ret = -1;
|
||||
|
@@ -32,8 +32,7 @@
|
||||
struct file_lock {
|
||||
long long fl_id;
|
||||
int fl_kind;
|
||||
char fl_type[15];
|
||||
char fl_option[10];
|
||||
int fl_ltype;
|
||||
|
||||
pid_t fl_owner;
|
||||
int maj, min;
|
||||
|
36
proc_parse.c
36
proc_parse.c
@@ -1415,16 +1415,16 @@ static int parse_file_lock_buf(char *buf, struct file_lock *fl,
|
||||
bool is_blocked)
|
||||
{
|
||||
int num;
|
||||
char fl_flag[10];
|
||||
char fl_flag[10], fl_type[15], fl_option[10];
|
||||
|
||||
if (is_blocked) {
|
||||
num = sscanf(buf, "%lld: -> %s %s %s %d %x:%x:%ld %lld %s",
|
||||
&fl->fl_id, fl_flag, fl->fl_type, fl->fl_option,
|
||||
&fl->fl_id, fl_flag, fl_type, fl_option,
|
||||
&fl->fl_owner, &fl->maj, &fl->min, &fl->i_no,
|
||||
&fl->start, fl->end);
|
||||
} else {
|
||||
num = sscanf(buf, "%lld:%s %s %s %d %x:%x:%ld %lld %s",
|
||||
&fl->fl_id, fl_flag, fl->fl_type, fl->fl_option,
|
||||
&fl->fl_id, fl_flag, fl_type, fl_option,
|
||||
&fl->fl_owner, &fl->maj, &fl->min, &fl->i_no,
|
||||
&fl->start, fl->end);
|
||||
}
|
||||
@@ -1441,6 +1441,32 @@ static int parse_file_lock_buf(char *buf, struct file_lock *fl,
|
||||
else
|
||||
fl->fl_kind = FL_UNKNOWN;
|
||||
|
||||
if (!strcmp(fl_type, "MSNFS")) {
|
||||
fl->fl_ltype |= LOCK_MAND;
|
||||
|
||||
if (!strcmp(fl_option, "READ")) {
|
||||
fl->fl_ltype |= LOCK_READ;
|
||||
} else if (!strcmp(fl_option, "RW")) {
|
||||
fl->fl_ltype |= LOCK_RW;
|
||||
} else if (!strcmp(fl_option, "WRITE")) {
|
||||
fl->fl_ltype |= LOCK_WRITE;
|
||||
} else {
|
||||
pr_err("Unknown lock option!\n");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (!strcmp(fl_option, "UNLCK")) {
|
||||
fl->fl_ltype |= F_UNLCK;
|
||||
} else if (!strcmp(fl_option, "WRITE")) {
|
||||
fl->fl_ltype |= F_WRLCK;
|
||||
} else if (!strcmp(fl_option, "READ")) {
|
||||
fl->fl_ltype |= F_RDLCK;
|
||||
} else {
|
||||
pr_err("Unknown lock option!\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1506,8 +1532,8 @@ int parse_file_locks(void)
|
||||
goto err;
|
||||
}
|
||||
|
||||
pr_info("lockinfo: %lld:%d %s %s %d %02x:%02x:%ld %lld %s\n",
|
||||
fl->fl_id, fl->fl_kind, fl->fl_type, fl->fl_option,
|
||||
pr_info("lockinfo: %lld:%d %x %d %02x:%02x:%ld %lld %s\n",
|
||||
fl->fl_id, fl->fl_kind, fl->fl_ltype,
|
||||
fl->fl_owner, fl->maj, fl->min, fl->i_no,
|
||||
fl->start, fl->end);
|
||||
|
||||
|
Reference in New Issue
Block a user