Subject: Re: bug#10349: tail: fix --follow on FhGFS remote file systems

From: Jim Meyering <[email-masked]>
Date: Thu, 22 Dec 2011 11:01:34 +0100

Sven Breuner wrote:
> can you please add the FhGFS remote file system magic "0x19830326" to
> the inotify blacklist of the src/tail.c:fremote function.

Thanks for the report.
I've attached the expected patch below.

> We currently receive lots of problem reports regarding this issue.
>
> In general, I would also like to suggest changing from the current
> inotify blacklist to using an inotify whitelist (containing file
> systems that are known to support inotify, such as xfs, ext2/3/4,
> ...). This would allow setting the default for unknown file system to
> disabled inotify.
> Currently, the inotify mechanism is assumed to be working for all
> unknown file systems, which probably causes trouble for a lot of the
> different network file systems out there.

We have a mechanism in place already to ensure that all file system
types listed in /usr/include/linux/magic.h are known to stat -f.
I see that FhGFS is not listed there.  If it had been listed a few
months ago, coreutils-8.14 would now support it.

In your situation (a new remote FS for which GNU tail does not
yet know its status as a remote FS), there are two ways to work
around the problem (that inotify failing makes tail -f fail):

  - use the deliberately undocumented tail option, ---disable-inotify
  - add an argument of "-", telling tail -f to read stdin, which
      never works with inotify, so tail reverts to polling here, too.
      E.g., if you run this,

        tail -f your-usual-files - < /dev/null

      that "-" makes tail do what you want: skip the attempt to use inotify
      and revert to the tried-and-true (but more CPU-intensive, less-responsive)
      polling method.

Are there so many new remote file systems coming into use now?
That are not listed in /usr/include/linux/magic.h?

If anyone knows of a better definitive list of file system magic
numbers than that, please let us know.

>From 896529709230021ba3d2b0000b28a6c4af13970a Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email-masked]>
Date: Thu, 22 Dec 2011 09:26:31 +0100
Subject: [PATCH] tail,stat: add support for FhGFS

* src/stat.c (human_fstype): Add a case: fhgfs, 0x19830326.
* src/tail.c (fremote): Add S_MAGIC_FHGFS.
* NEWS (Bug fixes): Update the entry for GPFS to mention FhGFS, too.
Reported by Sven Breuner.
---
 NEWS       |    4 ++--
 THANKS.in  |    1 +
 src/stat.c |    2 ++
 src/tail.c |    1 +
 4 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 51c44c7..80b6c9a 100644
--- a/NEWS
+++ b/NEWS
@@ -28,9 +28,9 @@ GNU coreutils NEWS                                    -*- outline -*-
   tac no longer fails to handle two or more non-seekable inputs
   [bug introduced in coreutils-5.3.0]

-  tail -f no longer tries to use inotify on GPFS file systems
+  tail -f no longer tries to use inotify on GPFS or FhGFS file systems
   [you might say this was introduced in coreutils-7.5, along with inotify
-   support, but the GPFS magic number wasn't in the usual places then.]
+   support, but the new magic numbers weren't in the usual places then.]

 * Noteworthy changes in release 8.14 (2011-10-12) [stable]
diff --git a/THANKS.in b/THANKS.in
index 3541c6f..44a617f 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -553,6 +553,7 @@ Steven P Watson                     [email-masked]
 Stuart Citrin                       [email-masked]
 Stuart Kemp                         [email-masked]
 Stuart Shelton                      [email-masked]
+Sven Breuner                        [email-masked]
 Szakacsits Szabolcs                 [email-masked]
 Tadayoshi Funaba                    [email-masked]
 TAKAI Kousuke                       [email-masked]
diff --git a/src/stat.c b/src/stat.c
index 0f87dfd..801073b 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -285,6 +285,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
       return "ext2";
     case S_MAGIC_FAT: /* 0x4006 */
       return "fat";
+    case S_MAGIC_FHGFS: /* 0x19830326 */
+      return "fhgfs";
     case S_MAGIC_FUSEBLK: /* 0x65735546 */
       return "fuseblk";
     case S_MAGIC_FUSECTL: /* 0x65735543 */
diff --git a/src/tail.c b/src/tail.c
index 1641a12..1f619f3 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -905,6 +905,7 @@ fremote (int fd, const char *name)
         case S_MAGIC_FUSECTL:
         case S_MAGIC_GFS:
         case S_MAGIC_GPFS:
+        case S_MAGIC_FHGFS:
         case S_MAGIC_KAFS:
         case S_MAGIC_LUSTRE:
         case S_MAGIC_NCP:
--
1.7.8.385.g1d1cb