mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-01 14:55:39 +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);
|
fle, PB_FILE_LOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fill_flock_entry(FileLockEntry *fle, int fl_kind,
|
static void fill_flock_entry(FileLockEntry *fle, int fl_kind, int fl_ltype)
|
||||||
const char *fl_type, const char *fl_option)
|
|
||||||
{
|
{
|
||||||
fle->flag |= fl_kind;
|
fle->flag |= fl_kind;
|
||||||
|
fle->type = fl_ltype;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_fd_by_ino(unsigned long i_no, struct parasite_drain_fd *dfds,
|
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) {
|
list_for_each_entry(fl, &file_lock_list, list) {
|
||||||
if (fl->fl_owner != pid)
|
if (fl->fl_owner != pid)
|
||||||
continue;
|
continue;
|
||||||
pr_info("lockinfo: %lld:%d %s %s %d %02x:%02x:%ld %lld %s\n",
|
pr_info("lockinfo: %lld:%d %x %d %02x:%02x:%ld %lld %s\n",
|
||||||
fl->fl_id, fl->fl_kind, fl->fl_type, fl->fl_option,
|
fl->fl_id, fl->fl_kind, fl->fl_ltype,
|
||||||
fl->fl_owner, fl->maj, fl->min, fl->i_no,
|
fl->fl_owner, fl->maj, fl->min, fl->i_no,
|
||||||
fl->start, fl->end);
|
fl->start, fl->end);
|
||||||
|
|
||||||
file_lock_entry__init(&fle);
|
file_lock_entry__init(&fle);
|
||||||
fle.pid = ctl->pid.virt;
|
fle.pid = ctl->pid.virt;
|
||||||
|
fill_flock_entry(&fle, fl->fl_kind, fl->fl_ltype);
|
||||||
ret = fill_flock_entry(&fle, fl->fl_kind, fl->fl_type,
|
|
||||||
fl->fl_option);
|
|
||||||
if (ret)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
fle.fd = get_fd_by_ino(fl->i_no, dfds, pid);
|
fle.fd = get_fd_by_ino(fl->i_no, dfds, pid);
|
||||||
if (fle.fd < 0) {
|
if (fle.fd < 0) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
@@ -32,8 +32,7 @@
|
|||||||
struct file_lock {
|
struct file_lock {
|
||||||
long long fl_id;
|
long long fl_id;
|
||||||
int fl_kind;
|
int fl_kind;
|
||||||
char fl_type[15];
|
int fl_ltype;
|
||||||
char fl_option[10];
|
|
||||||
|
|
||||||
pid_t fl_owner;
|
pid_t fl_owner;
|
||||||
int maj, min;
|
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)
|
bool is_blocked)
|
||||||
{
|
{
|
||||||
int num;
|
int num;
|
||||||
char fl_flag[10];
|
char fl_flag[10], fl_type[15], fl_option[10];
|
||||||
|
|
||||||
if (is_blocked) {
|
if (is_blocked) {
|
||||||
num = sscanf(buf, "%lld: -> %s %s %s %d %x:%x:%ld %lld %s",
|
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->fl_owner, &fl->maj, &fl->min, &fl->i_no,
|
||||||
&fl->start, fl->end);
|
&fl->start, fl->end);
|
||||||
} else {
|
} else {
|
||||||
num = sscanf(buf, "%lld:%s %s %s %d %x:%x:%ld %lld %s",
|
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->fl_owner, &fl->maj, &fl->min, &fl->i_no,
|
||||||
&fl->start, fl->end);
|
&fl->start, fl->end);
|
||||||
}
|
}
|
||||||
@@ -1441,6 +1441,32 @@ static int parse_file_lock_buf(char *buf, struct file_lock *fl,
|
|||||||
else
|
else
|
||||||
fl->fl_kind = FL_UNKNOWN;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1506,8 +1532,8 @@ int parse_file_locks(void)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_info("lockinfo: %lld:%d %s %s %d %02x:%02x:%ld %lld %s\n",
|
pr_info("lockinfo: %lld:%d %x %d %02x:%02x:%ld %lld %s\n",
|
||||||
fl->fl_id, fl->fl_kind, fl->fl_type, fl->fl_option,
|
fl->fl_id, fl->fl_kind, fl->fl_ltype,
|
||||||
fl->fl_owner, fl->maj, fl->min, fl->i_no,
|
fl->fl_owner, fl->maj, fl->min, fl->i_no,
|
||||||
fl->start, fl->end);
|
fl->start, fl->end);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user