Commit 2ceb6786 authored by Pavel Emelyanov's avatar Pavel Emelyanov

fsnotify: Restore name-hinted marks

If we failed to open inode by handle, try doing the irmap
search. If that's successful, dump the "real" path for the
inode.
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 7c224226
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "log.h" #include "log.h"
#include "list.h" #include "list.h"
#include "lock.h" #include "lock.h"
#include "irmap.h"
#include "protobuf.h" #include "protobuf.h"
#include "protobuf/fsnotify.pb-c.h" #include "protobuf/fsnotify.pb-c.h"
...@@ -127,6 +128,7 @@ static int check_open_handle(unsigned int s_dev, unsigned long i_ino, ...@@ -127,6 +128,7 @@ static int check_open_handle(unsigned int s_dev, unsigned long i_ino,
FhEntry *f_handle) FhEntry *f_handle)
{ {
int fd; int fd;
char *path;
fd = open_handle(s_dev, i_ino, f_handle); fd = open_handle(s_dev, i_ino, f_handle);
if (fd >= 0) { if (fd >= 0) {
...@@ -135,8 +137,16 @@ static int check_open_handle(unsigned int s_dev, unsigned long i_ino, ...@@ -135,8 +137,16 @@ static int check_open_handle(unsigned int s_dev, unsigned long i_ino,
return 0; return 0;
} }
pr_err("\tHandle %x:%lx cannot be opened\n", s_dev, i_ino); pr_warn("\tHandle %x:%lx cannot be opened\n", s_dev, i_ino);
path = irmap_lookup(s_dev, i_ino);
if (!path) {
pr_err("\tCan't dump that handle\n");
return -1; return -1;
}
pr_debug("\tDumping %s as path for handle\n", path);
f_handle->path = path;
return 0;
} }
static int dump_inotify_entry(union fdinfo_entries *e, void *arg) static int dump_inotify_entry(union fdinfo_entries *e, void *arg)
...@@ -256,6 +266,11 @@ static char *get_mark_path(const char *who, struct file_remap *remap, ...@@ -256,6 +266,11 @@ static char *get_mark_path(const char *who, struct file_remap *remap,
return remap->path; return remap->path;
} }
if (f_handle->path) {
pr_debug("\t\tRestore with path hint %s\n", f_handle->path);
return f_handle->path;
}
*target = open_handle(s_dev, i_ino, f_handle); *target = open_handle(s_dev, i_ino, f_handle);
if (*target < 0) if (*target < 0)
goto err; goto err;
......
...@@ -8,4 +8,5 @@ message fh_entry { ...@@ -8,4 +8,5 @@ message fh_entry {
/* The minimum is fh_n_handle repetitions */ /* The minimum is fh_n_handle repetitions */
repeated uint64 handle = 3; repeated uint64 handle = 3;
optional string path = 4;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment