md/bitmap: move printing of bitmap status to bitmap.c
authorNeilBrown <neilb@suse.de>
Mon, 19 Mar 2012 01:46:40 +0000 (12:46 +1100)
committerNeilBrown <neilb@suse.de>
Mon, 19 Mar 2012 01:46:40 +0000 (12:46 +1100)
The part of /proc/mdstat which describes the bitmap should really
be generated by code in bitmap.c.  So move it there.

Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/bitmap.c
drivers/md/bitmap.h
drivers/md/md.c

index 2c5dbc6248d3ae530bc297631f5f933305036b6d..04df18e8885fc129a1c9ec13f76665737ea71faa 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/file.h>
 #include <linux/mount.h>
 #include <linux/buffer_head.h>
+#include <linux/seq_file.h>
 #include "md.h"
 #include "bitmap.h"
 
@@ -1836,6 +1837,33 @@ out:
 }
 EXPORT_SYMBOL_GPL(bitmap_load);
 
+void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
+{
+       unsigned long chunk_kb;
+       unsigned long flags;
+
+       if (!bitmap)
+               return;
+
+       spin_lock_irqsave(&bitmap->lock, flags);
+       chunk_kb = bitmap->mddev->bitmap_info.chunksize >> 10;
+       seq_printf(seq, "bitmap: %lu/%lu pages [%luKB], "
+                  "%lu%s chunk",
+                  bitmap->pages - bitmap->missing_pages,
+                  bitmap->pages,
+                  (bitmap->pages - bitmap->missing_pages)
+                  << (PAGE_SHIFT - 10),
+                  chunk_kb ? chunk_kb : bitmap->mddev->bitmap_info.chunksize,
+                  chunk_kb ? "KB" : "B");
+       if (bitmap->file) {
+               seq_printf(seq, ", file: ");
+               seq_path(seq, &bitmap->file->f_path, " \t\n");
+       }
+
+       seq_printf(seq, "\n");
+       spin_unlock_irqrestore(&bitmap->lock, flags);
+}
+
 static ssize_t
 location_show(struct mddev *mddev, char *page)
 {
index 557e3e8ea73b5a7841419ea5da826cf8bd3c618b..e196e6a560e8dd53a548d246fa70373ae29e9842 100644 (file)
@@ -227,6 +227,7 @@ void bitmap_destroy(struct mddev *mddev);
 
 void bitmap_print_sb(struct bitmap *bitmap);
 void bitmap_update_sb(struct bitmap *bitmap);
+void bitmap_status(struct seq_file *seq, struct bitmap *bitmap);
 
 int  bitmap_setallbits(struct bitmap *bitmap);
 void bitmap_write_all(struct bitmap *bitmap);
index 4566b61373d50d9841337e9649869c7b9232b6d2..26591cc8ee874559426eeaa83f75eee0bbf01293 100644 (file)
@@ -6725,7 +6725,6 @@ static int md_seq_show(struct seq_file *seq, void *v)
        struct mddev *mddev = v;
        sector_t sectors;
        struct md_rdev *rdev;
-       struct bitmap *bitmap;
 
        if (v == (void*)1) {
                struct md_personality *pers;
@@ -6813,27 +6812,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
                } else
                        seq_printf(seq, "\n       ");
 
-               if ((bitmap = mddev->bitmap)) {
-                       unsigned long chunk_kb;
-                       unsigned long flags;
-                       spin_lock_irqsave(&bitmap->lock, flags);
-                       chunk_kb = mddev->bitmap_info.chunksize >> 10;
-                       seq_printf(seq, "bitmap: %lu/%lu pages [%luKB], "
-                               "%lu%s chunk",
-                               bitmap->pages - bitmap->missing_pages,
-                               bitmap->pages,
-                               (bitmap->pages - bitmap->missing_pages)
-                                       << (PAGE_SHIFT - 10),
-                               chunk_kb ? chunk_kb : mddev->bitmap_info.chunksize,
-                               chunk_kb ? "KB" : "B");
-                       if (bitmap->file) {
-                               seq_printf(seq, ", file: ");
-                               seq_path(seq, &bitmap->file->f_path, " \t\n");
-                       }
-
-                       seq_printf(seq, "\n");
-                       spin_unlock_irqrestore(&bitmap->lock, flags);
-               }
+               bitmap_status(seq, mddev->bitmap);
 
                seq_printf(seq, "\n");
        }