]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
libafs: Rate-limit hard-mount waiting messages
authorAndrew Deason <adeason@sinenomine.net>
Wed, 20 Jul 2011 21:50:52 +0000 (16:50 -0500)
committerDerrick Brashear <shadow@dementix.org>
Sat, 17 Dec 2011 00:30:46 +0000 (16:30 -0800)
Limit how often we log "hard-mount waiting for XXX" messages. Without
this, it is possible for a client with hard-mounts enabled to spam the
kernel log rather excessively (in extreme cases this can even panic
the machine on at least some Linux).

To keep things simple, just log approximately one message per volume
per hard-mount interval.

Reviewed-on: http://gerrit.openafs.org/5060
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit 530b5ecac51cc7ce61ccddd50868c632c4a47298)

Change-Id: I566aa3d411ff100ccc6afa9a5273fb84e6172dd0
Reviewed-on: http://gerrit.openafs.org/6347
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
src/afs/afs.h
src/afs/afs_analyze.c

index 861421385981163d56be5c0282e677fc885f0b2a..e726c7d83434e1b1c718608ebde570ebfb77b9d6 100644 (file)
@@ -521,6 +521,7 @@ struct chservinfo {
 #define VRecheck               2       /* recheck volume info with server */
 #define VBackup                        4       /* is this a backup volume? */
 #define VForeign               8       /* this is a non-afs volume */
+#define VHardMount             16      /* we are hard-mount waiting for the vol */
 
 enum repstate { not_busy, end_not_busy = 6, rd_busy, rdwr_busy, offline };
 
index 4defe46852f7681b587ecc88e8ac7dab8f420141..33c962758f137a346a30c83875355a29c03aa5f0 100644 (file)
@@ -393,26 +393,72 @@ afs_Analyze(struct afs_conn *aconn, struct rx_connection *rxconn,
                ((afid && afs_IsPrimaryCellNum(afid->Cell))
                 || (cellp && afs_IsPrimaryCell(cellp)))) {
                if (!afid) {
-                   afs_warnuser
-                       ("afs: hard-mount waiting for a vlserver to return to service\n");
+                   static int afs_vl_hm = 0;
+                   int warn = 0;
+                   if (!afs_vl_hm) {
+                       afs_vl_hm = warn = 1;
+                   }
+                   if (warn) {
+                       afs_warnuser
+                           ("afs: hard-mount waiting for a vlserver to return to service\n");
+                   }
                    VSleep(hm_retry_int);
                    afs_CheckServers(1, cellp);
                    shouldRetry = 1;
+
+                   if (warn) {
+                       afs_vl_hm = 0;
+                   }
                } else {
+                   static int afs_unknown_vhm = 0;
+                   int warn = 0, vp_vhm = 0;
+
                    tvp = afs_FindVolume(afid, READ_LOCK);
                    if (!tvp || (tvp->states & VRO)) {
                        shouldRetry = hm_retry_RO;
                    } else {
                        shouldRetry = hm_retry_RW;
                    }
+
+                   /* Set 'warn' if we should afs_warnuser. Only let one
+                    * caller call afs_warnuser per hm_retry_int interval per
+                    * volume. */
+                   if (shouldRetry) {
+                       if (tvp) {
+                           if (!(tvp->states & VHardMount)) {
+                               tvp->states |= VHardMount;
+                               warn = vp_vhm = 1;
+                           }
+                       } else {
+                           if (!afs_unknown_vhm) {
+                               afs_unknown_vhm = 1;
+                               warn = 1;
+                           }
+                       }
+                   }
+
                    if (tvp)
                        afs_PutVolume(tvp, READ_LOCK);
+
                    if (shouldRetry) {
-                       afs_warnuser
-                           ("afs: hard-mount waiting for volume %u\n",
-                            afid->Fid.Volume);
+                       if (warn) {
+                           afs_warnuser
+                               ("afs: hard-mount waiting for volume %u\n",
+                                afid->Fid.Volume);
+                       }
+
                        VSleep(hm_retry_int);
                        afs_CheckServers(1, cellp);
+
+                       if (vp_vhm) {
+                           tvp = afs_FindVolume(afid, READ_LOCK);
+                           if (tvp) {
+                               tvp->states &= ~VHardMount;
+                               afs_PutVolume(tvp, READ_LOCK);
+                           }
+                       } else if (warn) {
+                           afs_unknown_vhm = 0;
+                       }
                    }
                }
            } /* if (hm_retry_int ... */