This adds a check when the pool is being resized that will warn
the user about possible resize failures if no swap space is
configured or swap is full.

Signed-off-by: Eric B Munson <ebmun...@us.ibm.com>
---
 hugeadm.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/hugeadm.c b/hugeadm.c
index 876ba55..55656ba 100644
--- a/hugeadm.c
+++ b/hugeadm.c
@@ -60,6 +60,8 @@ extern char *optarg;
 #define MAX_SIZE_MNTENT (64 + PATH_MAX + 32 + 128 + 2 * sizeof(int))
 #define FORMAT_LEN 20
 
+#define SWAP_FREE "SwapFree:"
+
 void print_usage()
 {
        fprintf(stderr, "hugeadm [options]\n");
@@ -418,6 +420,20 @@ void create_mounts(char *user, char *group, char *base, 
mode_t mode)
        }
 }
 
+/**
+ * check_swap shouldn't change the behavior of any of its
+ * callers, it only prints a message to the user if something
+ * is being done that might fail without swap available.  i.e.
+ * resizing a huge page pool
+ */
+void check_swap()
+{
+       /* TODO: Move these messages to an external resource. */
+       long swap_sz = read_meminfo(SWAP_FREE);
+       if (swap_sz <= 0)
+               WARNING("Swap is full or no swap space configured, resizing 
pool may fail.\n");
+}
+
 enum {
        POOL_MIN,
        POOL_MAX,
@@ -495,6 +511,8 @@ void pool_adjust(char *cmd, unsigned int counter)
                exit(EXIT_FAILURE);
        }
 
+       check_swap();
+
        min = pools[pos].minimum;
        max = pools[pos].maximum;
 
-- 
1.6.1.2


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to