WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xentrace: Add option to reserve disk spac

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xentrace: Add option to reserve disk space
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 26 Feb 2008 11:20:11 -0800
Delivery-date: Tue, 26 Feb 2008 11:20:22 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1204036737 0
# Node ID 803c964e3ede54264a63fa1ec3a59995d71a1f92
# Parent  644ddc6514b171c2827376e27ab582e23f09fb96
xentrace: Add option to reserve disk space
Before writing records, xentrace will check to make sure that there is
a minimum amount of space left on the output filesystem.
Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
---
 tools/xentrace/xentrace.c |   40 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 38 insertions(+), 2 deletions(-)

diff -r 644ddc6514b1 -r 803c964e3ede tools/xentrace/xentrace.c
--- a/tools/xentrace/xentrace.c Tue Feb 26 14:38:39 2008 +0000
+++ b/tools/xentrace/xentrace.c Tue Feb 26 14:38:57 2008 +0000
@@ -15,6 +15,7 @@
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <sys/vfs.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
@@ -53,6 +54,7 @@ typedef struct settings_st {
     uint32_t evt_mask;
     uint32_t cpu_mask;
     unsigned long tbuf_size;
+    unsigned long disk_rsvd;
     uint8_t discard:1;
 } settings_t;
 
@@ -83,8 +85,36 @@ void write_buffer(unsigned int cpu, unsi
 void write_buffer(unsigned int cpu, unsigned char *start, int size,
                int total_size, int outfd)
 {
+    struct statfs stat;
     size_t written = 0;
     
+    if ( opts.disk_rsvd != 0 )
+    {
+        unsigned long long freespace;
+
+        /* Check that filesystem has enough space. */
+        if ( fstatfs (outfd, &stat) )
+        {
+                fprintf(stderr, "Statfs failed!\n");
+                goto fail;
+        }
+
+        freespace = stat.f_bsize * (unsigned long long)stat.f_bfree;
+
+        if ( total_size )
+            freespace -= total_size;
+        else
+            freespace -= size;
+
+        freespace >>= 20; /* Convert to MB */
+
+        if ( freespace <= opts.disk_rsvd )
+        {
+                fprintf(stderr, "Disk space limit reached (free space: %lluMB, 
limit: %luMB).\n", freespace, opts.disk_rsvd);
+                exit (EXIT_FAILURE);
+        }
+    }
+
     /* Write a CPU_BUF record on each buffer "window" written.  Wrapped
      * windows may involve two writes, so only write the record on the
      * first write. */
@@ -541,6 +571,7 @@ void parse_args(int argc, char **argv)
         { "cpu-mask",       required_argument, 0, 'c' },
         { "evt-mask",       required_argument, 0, 'e' },
         { "trace-buf-size", required_argument, 0, 'S' },
+        { "reserve-disk-space", required_argument, 0, 'r' },
         { "discard-buffers", no_argument,      0, 'D' },
         { "help",           no_argument,       0, '?' },
         { "version",        no_argument,       0, 'V' },
@@ -572,11 +603,15 @@ void parse_args(int argc, char **argv)
             printf("%s\n", program_version);
             exit(EXIT_SUCCESS);
             break;
-            
+
         case 'D': /* Discard traces currently in buffer */
             opts.discard = 1;
             break;
- 
+
+        case 'r': /* Disk-space reservation */
+            opts.disk_rsvd = argtol(optarg, 0);
+            break;
+
         default:
             usage();
         }
@@ -604,6 +639,7 @@ int main(int argc, char **argv)
     opts.poll_sleep = POLL_SLEEP_MILLIS;
     opts.evt_mask = 0;
     opts.cpu_mask = 0;
+    opts.disk_rsvd = 0;
 
     parse_args(argc, argv);
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xentrace: Add option to reserve disk space, Xen patchbot-unstable <=