mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-01 06:45:35 +00:00
locks: Parse lock kind earlier
Currently we keep the lock type (posix/flock) till the time we dump it, then "decode" it into binary value. I will need the easy-to-check one early, so parse the kind in proc_parse. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
17
file-lock.c
17
file-lock.c
@@ -72,17 +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, const char *fl_flag,
|
static int fill_flock_entry(FileLockEntry *fle, int fl_kind,
|
||||||
const char *fl_type, const char *fl_option)
|
const char *fl_type, const char *fl_option)
|
||||||
{
|
{
|
||||||
if (!strcmp(fl_flag, "POSIX")) {
|
fle->flag |= fl_kind;
|
||||||
fle->flag |= FL_POSIX;
|
|
||||||
} else if (!strcmp(fl_flag, "FLOCK")) {
|
|
||||||
fle->flag |= FL_FLOCK;
|
|
||||||
} else {
|
|
||||||
pr_err("Unknown file lock!\n");
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(fl_type, "MSNFS")) {
|
if (!strcmp(fl_type, "MSNFS")) {
|
||||||
fle->type |= LOCK_MAND;
|
fle->type |= LOCK_MAND;
|
||||||
@@ -150,15 +143,15 @@ 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:%s %s %s %d %02x:%02x:%ld %lld %s\n",
|
pr_info("lockinfo: %lld:%d %s %s %d %02x:%02x:%ld %lld %s\n",
|
||||||
fl->fl_id, fl->fl_flag, fl->fl_type, fl->fl_option,
|
fl->fl_id, fl->fl_kind, fl->fl_type, fl->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);
|
||||||
|
|
||||||
file_lock_entry__init(&fle);
|
file_lock_entry__init(&fle);
|
||||||
fle.pid = ctl->pid.virt;
|
fle.pid = ctl->pid.virt;
|
||||||
|
|
||||||
ret = fill_flock_entry(&fle, fl->fl_flag, fl->fl_type,
|
ret = fill_flock_entry(&fle, fl->fl_kind, fl->fl_type,
|
||||||
fl->fl_option);
|
fl->fl_option);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
#include "protobuf.h"
|
#include "protobuf.h"
|
||||||
#include "protobuf/file-lock.pb-c.h"
|
#include "protobuf/file-lock.pb-c.h"
|
||||||
|
|
||||||
|
#define FL_UNKNOWN -1
|
||||||
#define FL_POSIX 1
|
#define FL_POSIX 1
|
||||||
#define FL_FLOCK 2
|
#define FL_FLOCK 2
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@
|
|||||||
|
|
||||||
struct file_lock {
|
struct file_lock {
|
||||||
long long fl_id;
|
long long fl_id;
|
||||||
char fl_flag[10];
|
int fl_kind;
|
||||||
char fl_type[15];
|
char fl_type[15];
|
||||||
char fl_option[10];
|
char fl_option[10];
|
||||||
|
|
||||||
|
23
proc_parse.c
23
proc_parse.c
@@ -1415,15 +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];
|
||||||
|
|
||||||
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->fl_flag, fl->fl_type, fl->fl_option,
|
&fl->fl_id, fl_flag, fl->fl_type, fl->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->fl_flag, fl->fl_type, fl->fl_option,
|
&fl->fl_id, fl_flag, fl->fl_type, fl->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);
|
||||||
}
|
}
|
||||||
@@ -1433,6 +1434,13 @@ static int parse_file_lock_buf(char *buf, struct file_lock *fl,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strcmp(fl_flag, "POSIX"))
|
||||||
|
fl->fl_kind = FL_POSIX;
|
||||||
|
else if (!strcmp(fl_flag, "FLOCK"))
|
||||||
|
fl->fl_kind = FL_FLOCK;
|
||||||
|
else
|
||||||
|
fl->fl_kind = FL_UNKNOWN;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1476,6 +1484,13 @@ int parse_file_locks(void)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fl->fl_kind == FL_UNKNOWN) {
|
||||||
|
pr_err("Unknown file lock!\n");
|
||||||
|
ret = -1;
|
||||||
|
xfree(fl);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_blocked) {
|
if (is_blocked) {
|
||||||
/*
|
/*
|
||||||
* Here the task is in the pstree.
|
* Here the task is in the pstree.
|
||||||
@@ -1491,8 +1506,8 @@ int parse_file_locks(void)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_info("lockinfo: %lld:%s %s %s %d %02x:%02x:%ld %lld %s\n",
|
pr_info("lockinfo: %lld:%d %s %s %d %02x:%02x:%ld %lld %s\n",
|
||||||
fl->fl_id, fl->fl_flag, fl->fl_type, fl->fl_option,
|
fl->fl_id, fl->fl_kind, fl->fl_type, fl->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);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user