2024-05-16 13:17:21

by Jeff Layton

[permalink] [raw]
Subject: usage of inotify in nfs-utils

Al was asking about inotify usage in the rpc_pipefs dir. If you want
to check further, all the binaries that operate under there are in
nfs-utils:

http://git.linux-nfs.org/?p=steved/nfs-utils.git;a=summary

I took a quick look, and cscope shows these watches being added (with a
little annotation):

mountd and exportd watch creates and deletes in the nfsdfs clients dir:

0 support/export/v4clients.c 40 if (inotify_add_watch(clients_fd, "/proc/fs/nfsd/clients", IN_CREATE | IN_DELETE) < 0) {

...if one of those directories is created, it watches for modifications
to the "info" file in there:

1 support/export/v4clients.c 117 key->wid = inotify_add_watch(clients_fd, path, IN_MODIFY);

...blkmapd watches for directories to show up in rpc_pipefs and in the
"nfs" directory below that:

2 utils/blkmapd/device-discovery.c 358 *wd = inotify_add_watch(bl_watch_fd, dir, IN_CREATE|IN_DELETE);

...gssd has a pretty complex set of watches. There is a comment at the
top of gssd.c that explains them, but it watches for directories to
show up under rpc_pipefs, and then sets watches on the files under
those dirs (I think):

3 utils/gssd/gssd.c 656 clp->wd = inotify_add_watch(inotify_fd, clp->relpath, IN_CREATE | IN_DELETE);
4 utils/gssd/gssd.c 765 tdi->wd = inotify_add_watch(inotify_fd, name, IN_CREATE);

idmapd watches for dirs to show up in rpc_pipefs/nfs, and then watches
for directories under that to be created:

5 utils/idmapd/idmapd.c 410 wd = inotify_add_watch(inotify_fd, pipefsdir, IN_CREATE | IN_DELETE);
6 utils/idmapd/idmapd.c 930 inotify_add_watch(inotify_fd, ic->ic_path, IN_CREATE | IN_ONLYDIR | IN_ONESHOT);

nfsdcld watches for entries to show up in rpc_pipefs/nfsd/cld:

7 utils/nfsdcld/nfsdcld.c 276 ret = inotify_add_watch(inotify_fd, dname, IN_CREATE);

Al, Let me know if you have more questions, but it may be simpler to
just look in the nfs-utils tree.

Cheers,
--
Jeff Layton <[email protected]>