Re: [PATCH v2] inotify: Extend ioctl to allow to request id of new watch descriptor

From
Stef Bon <hidden>
Date
2018-02-11 11:30:22
Also in
linux-fsdevel
Reply to
Kirill Tkhai, 2018-02-09
2018-02-09 23:45 GMT+01:00 Kirill Tkhai [off-list ref]:
On 09.02.2018 23:56, Andrew Morton wrote:
quoted
On Fri, 9 Feb 2018 18:04:54 +0300 Kirill Tkhai [off-list ref] wrote:
quoted
Watch descriptor is id of the watch created by inotify_add_watch().
It is allocated in inotify_add_to_idr(), and takes the numbers
starting from 1. Every new inotify watch obtains next available
number (usually, old + 1), as served by idr_alloc_cyclic().

CRIU (Checkpoint/Restore In Userspace) project supports inotify
files, and restores watched descriptors with the same numbers,
they had before dump. Since there was no kernel support, we
had to use cycle to add a watch with specific descriptor id:

     while (1) {
             int wd;

             wd = inotify_add_watch(inotify_fd, path, mask);
             if (wd < 0) {
                     break;
             } else if (wd == desired_wd_id) {
                     ret = 0;
                     break;
             }

             inotify_rm_watch(inotify_fd, wd);
     }

(You may find the actual code at the below link:
 https://github.com/checkpoint-restore/criu/blob/v3.7/criu/fsnotify.c#L577)
Well using a ioctl command to force a specific wd is possible, but
isn't it also possible
to do a "freeze" of all (inotify) watches which are involved, and
"unfreeze" when restoring?

Stef
Thread (7 messages) 7 messages, 5 authors, last reply 2018-02-14
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help