Hi.

This patch fixes reset_3rd_bitmap().

Thanks
Ken'ichi Ohmichi

diff -puN makedumpfile.org/makedumpfile.c makedumpfile/makedumpfile.c
--- makedumpfile.org/makedumpfile.c     2006-10-04 16:40:30.000000000 +0900
+++ makedumpfile/makedumpfile.c 2006-10-04 16:40:56.000000000 +0900
@@ -550,7 +550,7 @@ get_elf_info(struct DumpInfo *info)
        tmp = divideup(tmp, info->page_size);
        info->len_bitmap = tmp*info->page_size;
        if (info->flag_exclude_free)
-               info->len_3rd_bitmap = info->len_bitmap >> 1;
+               info->len_3rd_bitmap = info->len_bitmap / 2;
 
        if (elf_end(elfd) == 0)
                rc = TRUE;
@@ -1429,7 +1429,7 @@ is_on(char *bitmap, int i)
 }
 
 static inline int
-is_dumpable(struct dump_bitmap *bitmap, int pfn)
+is_dumpable(struct dump_bitmap *bitmap, unsigned int pfn)
 {
        off_t offset;
        if (pfn == 0 || bitmap->no_block != pfn/PFN_BUFBITMAP) {
@@ -1445,7 +1445,7 @@ is_dumpable(struct dump_bitmap *bitmap, 
 }
 
 static inline int
-is_memory_hole(struct dump_bitmap *bitmap, int pfn)
+is_memory_hole(struct dump_bitmap *bitmap, unsigned int pfn)
 {
        return !is_dumpable(bitmap, pfn);
 }
@@ -1788,45 +1788,30 @@ page_to_pfn(struct DumpInfo *info, unsig
 int
 reset_3rd_bitmap(struct DumpInfo *info, unsigned long pfn)
 {
-       unsigned long len, prev_offset;
-
-       if (info->start_pfn_3rd <= pfn && pfn <= info->end_pfn_3rd) {
-               set_bitmap(info->bm3->buf, pfn%PFN_BUFBITMAP, 0);
-               return TRUE;
+       off_t offset_pfn;
+       unsigned int buf_size;
+       struct cache_data *bm3 = info->bm3;
+
+       offset_pfn  = (pfn / PFN_BUFBITMAP) * BUFSIZE_BITMAP;
+       bm3->offset = offset_pfn;
+       buf_size    = info->len_3rd_bitmap - bm3->offset;
+       if (buf_size >= BUFSIZE_BITMAP) {
+               bm3->cache_size = BUFSIZE_BITMAP;
+               bm3->buf_size   = BUFSIZE_BITMAP;
        } else {
-               len = divideup(info->max_mapnr, BITPERBYTE)
-                       - round(info->bm3->offset, BUFSIZE_BITMAP);
-               if (len >= BUFSIZE_BITMAP) {
-                       /* not last */
-                       info->bm3->buf_size = BUFSIZE_BITMAP;
-               } else {
-                       /* last */
-                       info->bm3->buf_size = len;
-               }
-               /*
-                * Flush the 3rd cache.
-                */
-               if (!write_cache_bufsz(info->bm3))
-                       return FALSE;
-
-               info->bm3->offset = pfn / BITPERBYTE / BUFSIZE_BITMAP
-                       * BUFSIZE_BITMAP;
-               len = divideup(info->max_mapnr, BITPERBYTE)
-                       - round(info->bm3->offset, BUFSIZE_BITMAP);
-               if (len >= BUFSIZE_BITMAP) {
-                       info->bm3->cache_size = BUFSIZE_BITMAP;
-               } else {
-                       info->bm3->cache_size = len;
-               }
-               prev_offset = info->bm3->offset;
-               if (!read_cache(info->bm3))
-                       return FALSE;
-               info->bm3->buf_size = info->bm3->cache_size;
-               info->start_pfn_3rd = prev_offset * BITPERBYTE;
-               info->end_pfn_3rd = MIN((prev_offset + BUFSIZE_BITMAP) * 
BITPERBYTE - 1,
-                       info->max_mapnr);
-               set_bitmap(info->bm3->buf, pfn%PFN_BUFBITMAP, 0);
+               bm3->cache_size = buf_size;
+               bm3->buf_size   = buf_size;
        }
+
+       if (!read_cache(bm3))
+               return FALSE;
+
+       set_bitmap(bm3->buf, pfn%PFN_BUFBITMAP, 0);
+
+       bm3->offset = offset_pfn;
+       if (!write_cache_bufsz(bm3))
+               return FALSE;
+
        return TRUE;
 }
 
@@ -1977,29 +1962,26 @@ _exclude_free_page(struct DumpInfo *info
 }
 
 int
-cp_cache(struct cache_data *from, struct cache_data *to, int size,
-       off_t from_offset, off_t to_offset)
+cp_cache(struct cache_data *source, struct cache_data *dest, int size)
 {
-       from->offset = from_offset;
-       to->offset = to_offset;
        while (size > 0) {
                if (size >= BUFSIZE_BITMAP) {
-                       from->cache_size = BUFSIZE_BITMAP;
-                       to->cache_size = BUFSIZE_BITMAP;
+                       source->cache_size = BUFSIZE_BITMAP;
+                       dest->cache_size = BUFSIZE_BITMAP;
                } else {
-                       from->cache_size = size;
-                       to->cache_size = size;
+                       source->cache_size = size;
+                       dest->cache_size = size;
                }
-               to->buf_size = 0;
+               dest->buf_size = 0;
 
-               if(!read_cache(from)) {
+               if(!read_cache(source)) {
                        ERRMSG("Can't read the dump cache file(%s). %s\n",
-                           from->file_name, strerror(errno));
+                           source->file_name, strerror(errno));
                        return FALSE;
                }
-               if(!write_cache(to, from->buf, from->cache_size)) {
+               if(!write_cache(dest, source->buf, source->cache_size)) {
                        ERRMSG("Can't write the dump cache file(%s). %s\n",
-                           to->file_name, strerror(errno));
+                           dest->file_name, strerror(errno));
                        return FALSE;
                }
 
@@ -2039,7 +2021,9 @@ exclude_free_page(struct DumpInfo *info,
         * Copy bitmap2 to bitmap3.
         */
        info->bm3 = bm3;
-       if (!cp_cache(bm2, bm3, info->len_bitmap/2, info->len_bitmap / 2, 0))
+       bm2->offset = info->len_bitmap / 2;
+       bm3->offset = 0;
+       if (!cp_cache(bm2, bm3, info->len_bitmap / 2))
                return FALSE;
 
        /*
@@ -2051,7 +2035,9 @@ exclude_free_page(struct DumpInfo *info,
        /*
         * Write back bitmap3 to bitmap2.
         */
-       if (!cp_cache(bm3, bm2, info->len_bitmap/2, 0, info->len_bitmap / 2))
+       bm2->offset = info->len_bitmap / 2;
+       bm3->offset = 0;
+       if (!cp_cache(bm3, bm2, info->len_bitmap / 2))
                return FALSE;
        return TRUE;
 }
diff -puN makedumpfile.org/makedumpfile.h makedumpfile/makedumpfile.h
--- makedumpfile.org/makedumpfile.h     2006-10-04 16:40:30.000000000 +0900
+++ makedumpfile/makedumpfile.h 2006-10-04 16:40:56.000000000 +0900
@@ -461,8 +461,6 @@ struct DumpInfo {
        char                    *name_bitmap;
        char                    *name_3rd_bitmap;
        struct cache_data       *bm3;
-       unsigned long           start_pfn_3rd;
-       unsigned long           end_pfn_3rd;
        struct vm_table {                /* kernel VM-related data */
                ulong flags;
                int numnodes;
_
_______________________________________________
fastboot mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/fastboot

Reply via email to