bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#66381: 29.1; Auto-revert not polling files when notifications are en


From: Michael Albinus
Subject: bug#66381: 29.1; Auto-revert not polling files when notifications are enabled
Date: Sat, 07 Oct 2023 17:15:43 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Eli Zaretskii <eliz@gnu.org> writes:

Hi Eli,

>> I use a network filesystem which sometimes has to restart, e.g.  for
>> updates or when credentials expire. Normally, file notifications work
>> fine on this filesystem, but after a restart the old notifications will
>> never fire. Documentation says "By default, Auto Revert mode will poll
>> files for changes periodically even when file notifications are used." -
>> experimentally the file is never polled.
>> 
>> Ideally the notification would be recreated, but falling back to
>> polling would be
>> an improvement.
>
> Michael, can we reliably know when the watch handles are stale?  If
> not, then users of such "restarting" network filesystems will need to
> disable auto-revert-use-notify.

We have `file-notify-valid-p'. It calls the backend specific funtion,
for example `inotify-valid-p' in the case of GNU/Linux using
inotify. The OP didn't tell us which backend he's using, so let's assume
inotify ATM.

This backend specific check does not ask the operating system, it checks
only some internal data structures. This isn't a robust check for a
stale watch handle.

However, inotify sends also an internal event IN_IGNORED, which is
raised according to inotify(7)

--8<---------------cut here---------------start------------->8---
           IN_IGNORED
                  Watch  was removed explicitly (inotify_rm_watch(2)) or auto‐
                  matically (file was deleted, or filesystem  was  unmounted).
                  See also BUGS.
--8<---------------cut here---------------end--------------->8---

filenotify.el translates this to the Emacs file-notify event `stopped',
and if this event arrives, the respective data structures are
updated. In case of a network filesystem unmount, everything shall work.

A recreation of file notification after a remount is not supported. This
would be a new feature.

However, the situation is more complex I fear. If I understand the OP
message correctly, file notification is used for auto-revert-mode. There
is the user option `auto-revert-notify-exclude-dir-regexp'. If a
directory located on a file name matching this regexp, file notification
is discarded. File names like  "/mnt", "/net/", or "/tmp_mnt/" match. So
in order to use file notification with auto-revert-mode on such a
location, this user option must be adapted.

I haven't tested the combination of watching a mounted file system, and
unmounting them, in autorevert.el. According to
`auto-revert-notify-handler', the file-notify event `stopped' is
handled, and auto-revert-mode continues with polling. I would test this
once I see a clear recipe (starting with

--8<---------------cut here---------------start------------->8---
emacs -Q --eval '(setq auto-revert-debug t file-notify-debug t)'
--8<---------------cut here---------------end--------------->8---

and telling all steps how to enable auto-revert-mode and how to unmount
the filesystem and what happens afterwards. The two debug options show
us the story in the *Messages* buffer.

Best regards, Michael.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]