[openib-general] [PATCH] opensm: truncate log file when fs is overflowed

Sasha Khapyorsky sashak at voltaire.com
Tue Aug 29 14:59:35 PDT 2006


On 17:03 Tue 29 Aug     , Hal Rosenstock wrote:
> On Tue, 2006-08-29 at 15:01, Sasha Khapyorsky wrote:
> 
> > > I'd prefer an incremental one off the last patch related to this if that
> > > isn't too much work as I'm close to committing the previous one now (and
> > > it'd be more work to start over on this).
> > 
> > Ok. There is:
> > 
> > 
> > Optional log file truncating upon ENOSPC errors.
> > 
> > Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
> 
> Thanks. Applied (to trunk and 1.1)

Thanks. And there is more - this will not reset error counter, and the
error messages will be cleaner.


Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>

diff --git a/osm/opensm/osm_log.c b/osm/opensm/osm_log.c
index 05b1185..a5dac10 100644
--- a/osm/opensm/osm_log.c
+++ b/osm/opensm/osm_log.c
@@ -173,20 +173,21 @@ #endif
         fflush( p_log->out_port ) < 0)
       ret = -1;
 
-    if (ret < 0 && errno == ENOSPC && log_exit_count < 3)
+    if (ret >= 0)
+    {
+      log_exit_count = 0;
+      p_log->count += ret;
+    }
+    else if (log_exit_count < 3)
     {
-      fprintf(stderr, "osm_log: write failed: %s. Truncating log file.\n",
-              strerror(errno));
       log_exit_count++;
-      if (p_log->max_size) {
+      if (errno == ENOSPC && p_log->max_size) {
+        fprintf(stderr, "osm_log: write failed: %s. Truncating log file.\n",
+                strerror(errno));
         truncate_log_file(p_log);
         goto _retry;
       }
-    }
-    else
-    {
-      log_exit_count = 0;
-      p_log->count += ret;
+      fprintf(stderr, "osm_log: write failed: %s\n", strerror(errno));
     }
 
     cl_spinlock_release( &p_log->lock );




More information about the general mailing list