This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC][PATCH 5/5][flight-recorder] Largefile support


This patch enables stpd to write logs into largefile (over 2GB).
This patch covers not only temporary file but also merged output file.

-- 
Masami HIRAMATSU
2nd Research Dept.
Hitachi, Ltd., Systems Development Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com

 main.cxx                |    4 ++--
 runtime/stpd/librelay.c |   20 ++++++++++++--------
 runtime/stpd/stpd.c     |   16 +++++++++-------
 3 files changed, 23 insertions(+), 17 deletions(-)
Index: src/runtime/stpd/librelay.c
===================================================================
--- src.orig/runtime/stpd/librelay.c	2006-08-25 19:12:09.000000000 +0900
+++ src/runtime/stpd/librelay.c	2006-08-25 19:17:33.000000000 +0900
@@ -20,6 +20,9 @@
  *
  */

+#define _FILE_OFFSET_BITS 64
+#define _LARGEFILE64_SOURCE
+
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -76,7 +79,7 @@
 static FILE *percpu_tmpfile[NR_CPUS];
 static char *relay_buffer[NR_CPUS];
 static pthread_t reader[NR_CPUS];
-static long percpu_fptr[NR_CPUS];
+static off_t percpu_fptr[NR_CPUS];

 /* control channel */
 static int control_channel;
@@ -84,7 +87,7 @@
 /* flags */
 extern int print_only, quiet, merge, verbose, background;
 extern unsigned int buffer_size;
-extern long log_size;
+extern int64_t log_size;
 extern char *modname;
 extern char *modpath;
 extern char *modoptions[];
@@ -578,7 +581,7 @@
 		}
 		stat(tmp, &fst);
 		if (fst.st_size != percpu_fptr[i]) {
-			fseek (fp[i], percpu_fptr[i], SEEK_SET);
+			fseeko (fp[i], percpu_fptr[i], SEEK_SET);
 		} else {
 			percpu_fptr[i] = 0;
 		}
@@ -627,8 +630,8 @@
 			dropped++ ;
 		}
 		if (remains[j] == 0) {
-			fseek (fp[j], padding[j], SEEK_CUR);/* skip padding */
-			if (ftell(fp[j]) == percpu_fptr[j])
+			fseeko (fp[j], (off_t)padding[j], SEEK_CUR);/* skip padding */
+			if (ftello(fp[j]) == percpu_fptr[j])
 				goto eof;
 retry:
 			if (fread (&padding[j], sizeof(unsigned), 1, fp[j])) {
@@ -669,7 +672,7 @@
 	int i;
 	FILE *fp;
 	char tmp[PATH_MAX];
-	long starting;
+	int64_t starting, bufsize;

 	for (i = 0; i < ncpus; i++) {
 		struct stat fst;
@@ -685,8 +688,9 @@
 		} else {
 			starting = percpu_fptr[i];
 		}
-		fwrite(&starting, sizeof(long), 1, fp);
-		fwrite(&params.subbuf_size, sizeof(unsigned), 1, fp);
+		bufsize = params.subbuf_size;
+		fwrite(&starting, sizeof(int64_t), 1, fp);
+		fwrite(&bufsize, sizeof(int64_t), 1, fp);
 		fclose(fp);
 	}
 	return 0;
Index: src/runtime/stpd/stpd.c
===================================================================
--- src.orig/runtime/stpd/stpd.c	2006-08-25 19:12:09.000000000 +0900
+++ src/runtime/stpd/stpd.c	2006-08-25 19:13:37.000000000 +0900
@@ -47,7 +47,9 @@
 int driver_pid = 0;
 int background = 0;
 unsigned int buffer_size = 0;
-long log_size = 0;
+/* logical limit of file size in MB */
+#define MAXFILESIZE (int64_t)(1LL<<(63-20))
+int64_t log_size = 0;
 char *modname = NULL;
 char *modpath = NULL;
 #define MAXMODOPTIONS 64
@@ -178,14 +180,14 @@
 		}
 		case 'l':
 		{
-			unsigned size = (unsigned)atoi(optarg);
-			if (!size)
+			int64_t size = strtoll(optarg, NULL, 10);
+			if (size <= 0)
 				usage(argv[0]);
-			if (size > 2048) {
-			  fprintf(stderr, "Maximum log size is 2048 (MB)\n");
+			if (size > MAXFILESIZE) {
+			  fprintf(stderr, "Maximum log size is %lld (MB)\n", MAXFILESIZE);
 			  exit(1);
 			}
-			log_size = (long)((size << 20) - 1);
+			log_size = size << 20;
 			break;
 		}
 		case 't':
@@ -212,7 +214,7 @@
 		if (buffer_size)
 			printf ("Using a buffer of %u Mbytes.\n", buffer_size);
 		if (log_size)
-			printf ("Using logfiles of %ld Mbytes.\n", log_size);
+			printf ("Using logfiles of %lld Mbytes.\n", log_size);
 	}

 	if (optind < argc)
Index: src/main.cxx
===================================================================
--- src.orig/main.cxx	2006-08-25 19:12:09.000000000 +0900
+++ src/main.cxx	2006-08-25 19:13:37.000000000 +0900
@@ -256,9 +256,9 @@

         case 'S':
           s.logfile_size = atoi (optarg);
-          if (s.logfile_size < 1 || s.logfile_size > 2048)
+          if (s.logfile_size < 1)
             {
-              cerr << "Invalid buffer size (should be 1-2048)." << endl;
+              cerr << "Invalid buffer size (should be 1)." << endl;
 	      usage (s, 1);
             }
           break;




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]