From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#66381: 29.1; Auto-revert not polling files when notifications are enabled Date: Sat, 07 Oct 2023 17:15:43 +0200 Message-ID: <87bkdaihuo.fsf@gmx.de> References: <83jzrz0xeq.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3203"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 66381@debbugs.gnu.org, Daniel Jacobowitz To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 07 17:17:03 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qp939-0000d4-2O for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 07 Oct 2023 17:17:03 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qp92v-0001Mg-MP; Sat, 07 Oct 2023 11:16:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qp92p-0001MC-8r for bug-gnu-emacs@gnu.org; Sat, 07 Oct 2023 11:16:47 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qp92o-0001pU-W5 for bug-gnu-emacs@gnu.org; Sat, 07 Oct 2023 11:16:43 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qp938-0000zz-Dg for bug-gnu-emacs@gnu.org; Sat, 07 Oct 2023 11:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 07 Oct 2023 15:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66381 X-GNU-PR-Package: emacs Original-Received: via spool by 66381-submit@debbugs.gnu.org id=B66381.16966917743747 (code B ref 66381); Sat, 07 Oct 2023 15:17:02 +0000 Original-Received: (at 66381) by debbugs.gnu.org; 7 Oct 2023 15:16:14 +0000 Original-Received: from localhost ([127.0.0.1]:55669 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qp92L-0000yM-JH for submit@debbugs.gnu.org; Sat, 07 Oct 2023 11:16:14 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:59455) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qp92J-0000y4-1q for 66381@debbugs.gnu.org; Sat, 07 Oct 2023 11:16:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1696691745; x=1697296545; i=michael.albinus@gmx.de; bh=SmszUgHvJT4hjZK0yDU3G9XC7eNBMIq01WI/glJJfFQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=r5g6X86CPfx5LWRJudC+VhzUh4WgHO+Ol0SzGKd0ZHYBLI3wBi5jwbb4c8qkg3IhxMtVkCbCSQw RsAzmvUFINcU5k/69ZaMhiw2XhMAdp8WPfHWf2yXq+YD2reqMst4lg6/9RE2+noVMXvOfWwD7R6ws tnp799X3Fpja+zok8W9oFq2/B9U55cGgjbbbRy6eLKkpFxsMkQjNSaTyD+77XfMd3zx49lK6HynNt GxvheRH/dIR+rlaYtys8rhSNsDmUhtnhFGgzESQY3Wm23QTzy/I0nmbkJWyWVoxcXbgi0kpioegtY sUWrkWakj2aAEYFHgEPtqrwWRmOTvIvwhjdA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from gandalf.gmx.de ([185.89.39.30]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N33Il-1raCtx2uCr-013LwT; Sat, 07 Oct 2023 17:15:44 +0200 In-Reply-To: <83jzrz0xeq.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 07 Oct 2023 09:17:01 +0300") X-Provags-ID: V03:K1:wywQQQnPsfaKr3eG1skB+jTa59SaCJcJx+/MRrsLABP+iBjSaZX sJPu/mKehJtvUqpMXM1e3zZhfXXbwB8zfmIKlr13PRCqChQLg+WktWkqzUEv10Pel93No/E utXI9S2PCF0lwvFwlfPse8GqyHGEN2QBUs+nb/nKMg0gQN8P0ilmOnZFpUv9foVkphH4ksd PoppZBs6vnBoXOxwfXmcw== UI-OutboundReport: notjunk:1;M01:P0:vwhMYFZs/Cw=;6mCNwFbMZkdDLM3PK5EtNIUjjXY /bsV+gGE4CE/AhAXhZHT/wCHfokzErZk56qCwemnQLT8UFnXBXzI51oFuAvqg6b52sp+5BeE8 v7Pe+rH3rl6MSqZRPZC2lB9PiWJTEdH/VAeS+Ti4nX0crOwc4LpW8esQ4K9Ls5N93G1iL54rA 8B+mEw/gDHVvj0tD9wiVSNb5BEHZVTzpKL0PjJiAggM0nPpeDA6SI5uiLgqO0LcvLVdQYCf+T QvD5C35IaMf5MoTp3vER2JqlZk9XcQDC2QS3JiIA5gbOxqlrffw1YUhDk7ZCtfR28Q0nIRrnU wO7q7buI7VPNWoaUF7VxyaHBJUGEYgiBpkyIRRkOwO/+qBlUWUDaEENcn4QRlWcaoIsc80+Qv EVheFdGrNsJw8WynWkow60Ane7yHGHpYAhvmAQemB2Unhp3wmcgj2OGnFkYMmHTx+LmlRs/d1 AJqzcQU5IHgqD/CEk9tR5zntkrmNA5J1h9wdOb0iWrC+CnBUVkrnNO/B2NsPC31bZymg8qiTt +AcjcHsuoV8FwFmqa3Lo1LRaiIbLWhUwcIfzUzs/S2g4axGNm0u3bZ/RwoXg0FaUUeNT2a0CN VENNS2VHCPtVIcmJEyBgjqnl7Xcp4aUTvdnfmD5iwvleJwhEDnwr1TZa8XZbHhBnqOfQpOe9s Eqh8WWv/YiC4OiJr2lP5KU2BV8vYbppNALhuBa0wcV5ONvpFnQiRik00/DpwceoTyOF1RXPrX f2uoRNpdinQ9APgRttnoVuVtlcYABqfT1QL7HFUykAN7bU45scNOMgT85Larf8sNgo4owSHA X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:272014 Archived-At: Eli Zaretskii 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. >>=20 >> 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 au= to=E2=80=90 matically (file was deleted, or filesystem was unmounte= d). 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.