Introduce the new option "--work-dir" to specify the directory
used to store the bitmap. This is the alternative to the combination
of --non-cyclic and TMPDIR.

Signed-off-by: Atsushi Kumagai <[email protected]>
---
 makedumpfile.8 | 13 +++++++++++++
 makedumpfile.c | 21 +++++++++++++++++++--
 makedumpfile.h |  2 ++
 print_info.c   |  7 +++++++
 4 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/makedumpfile.8 b/makedumpfile.8
index 9752671..b6055d8 100644
--- a/makedumpfile.8
+++ b/makedumpfile.8
@@ -421,6 +421,19 @@ If you feel the cyclic mode is too slow, please try this 
mode.
 # makedumpfile \-\-non\-cyclic \-d 31 \-x vmlinux /proc/vmcore dumpfile
 
 .TP
+\fB\-\-work\-dir\fR
+Specify the working directory for the temporary bitmap file.
+If this option isn't specified, the bitmap will be saved on memory.
+Filtering processing has to do 2 pass scanning to fix the memory consumption,
+but it can be avoided by using working directory on file system.
+So if you specify this option, the filtering speed may be bit faster.
+
+.br
+.B Example:
+.br
+# makedumpfile \-\-work\-dir /tmp \-d 31 \-x vmlinux /proc/vmcore dumpfile
+
+.TP
 \fB\-\-non\-mmap\fR
 Never use \fBmmap(2)\fR to read \fIVMCORE\fR even if it supports \fBmmap(2)\fR.
 Generally, reading \fIVMCORE\fR with \fBmmap(2)\fR is faster than without it,
diff --git a/makedumpfile.c b/makedumpfile.c
index 1192cfe..f0ec741 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -1033,8 +1033,14 @@ open_dump_bitmap(void)
        int i, fd;
        char *tmpname;
 
+       /* Unnecessary to open */
+       if (!info->working_dir)
+               return TRUE;
+
        tmpname = getenv("TMPDIR");
-       if (!tmpname)
+       if (info->working_dir)
+               tmpname = info->working_dir;
+       else if (!tmpname)
                tmpname = "/tmp";
 
        if ((info->name_bitmap = (char *)malloc(sizeof(FILENAME_BITMAP) +
@@ -3251,7 +3257,11 @@ out:
        if (!get_max_mapnr())
                return FALSE;
 
-       if (info->flag_cyclic) {
+       if (info->working_dir) {
+               /* Implemented as non-cyclic mode based on the file */
+               info->flag_cyclic = FALSE;
+               info->pfn_cyclic = info->max_mapnr;
+       } else {
                if (info->bufsize_cyclic == 0) {
                        if (!calculate_cyclic_buffer_size())
                                return FALSE;
@@ -7489,6 +7499,9 @@ close_dump_file(void)
 void
 close_dump_bitmap(void)
 {
+       if (!info->working_dir)
+               return;
+
        if ((info->fd_bitmap = close(info->fd_bitmap)) < 0)
                ERRMSG("Can't close the bitmap file(%s). %s\n",
                    info->name_bitmap, strerror(errno));
@@ -9832,6 +9845,7 @@ static struct option longopts[] = {
        {"non-mmap", no_argument, NULL, OPT_NON_MMAP},
        {"mem-usage", no_argument, NULL, OPT_MEM_USAGE},
        {"splitblock-size", required_argument, NULL, OPT_SPLITBLOCK_SIZE},
+       {"work-dir", required_argument, NULL, OPT_WORKING_DIR},
        {0, 0, 0, 0}
 };
 
@@ -9975,6 +9989,9 @@ main(int argc, char *argv[])
                case OPT_SPLITBLOCK_SIZE:
                        info->splitblock_size = atoi(optarg);
                        break;
+               case OPT_WORKING_DIR:
+                       info->working_dir = optarg;
+                       break;
                case '?':
                        MSG("Commandline parameter is invalid.\n");
                        MSG("Try `makedumpfile --help' for more 
information.\n");
diff --git a/makedumpfile.h b/makedumpfile.h
index 4beac65..990c76f 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -1151,6 +1151,7 @@ struct DumpInfo {
         */
        struct dump_bitmap *partial_bitmap1;
        struct dump_bitmap *partial_bitmap2;
+       char               *working_dir;             /* working directory for 
bitmap */
        mdf_pfn_t          num_dumpable;
        unsigned long      bufsize_cyclic;
        unsigned long      pfn_cyclic;
@@ -1897,6 +1898,7 @@ struct elf_prstatus {
 #define OPT_NON_MMAP            OPT_START+13
 #define OPT_MEM_USAGE            OPT_START+14
 #define OPT_SPLITBLOCK_SIZE    OPT_START+15
+#define OPT_WORKING_DIR         OPT_START+16
 
 /*
  * Function Prototype.
diff --git a/print_info.c b/print_info.c
index 9215e0f..6610e76 100644
--- a/print_info.c
+++ b/print_info.c
@@ -213,6 +213,13 @@ print_usage(void)
        MSG("      same as v1.4.4 or before.\n");
        MSG("      If you feel the cyclic mode is too slow, please try this 
mode.\n");
        MSG("\n");
+       MSG("  [--work-dir]:\n");
+       MSG("      Specify the working directory for the temporary bitmap 
file.\n");
+       MSG("      If this option isn't specified, the bitmap will be saved on 
memory.\n");
+       MSG("      Filtering processing has to do 2 pass scanning to fix the 
memory consumption,\n");
+       MSG("      but it can be avoided by using working directory on file 
system.\n");
+       MSG("      So if you specify this option, the filtering speed may be 
bit faster.\n");
+       MSG("\n");
        MSG("  [--non-mmap]:\n");
        MSG("      Never use mmap(2) to read VMCORE even if it supports 
mmap(2).\n");
        MSG("      Generally, reading VMCORE with mmap(2) is faster than 
without it,\n");
-- 
1.9.0

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Reply via email to