linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: linux-raid@vger.kernel.org
Subject: [md PATCH 07/24] md/bitmap: store bytes in file rather than just in last page.
Date: Tue, 17 Apr 2012 18:43:40 +1000	[thread overview]
Message-ID: <20120417084340.6433.82130.stgit@notabene.brown> (raw)
In-Reply-To: <20120417084324.6433.68345.stgit@notabene.brown>

This number is more generally useful, and bytes-in-last-page is
easily extracted from it.

Signed-off-by: NeilBrown <neilb@suse.de>
---

 drivers/md/bitmap.c |   14 +++++++-------
 drivers/md/bitmap.h |    2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 614062a..9221f97 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -203,9 +203,11 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
 
 		bdev = (rdev->meta_bdev) ? rdev->meta_bdev : rdev->bdev;
 
-		if (page->index == store->file_pages-1)
-			size = roundup(store->last_page_size,
+		if (page->index == store->file_pages-1) {
+			int last_page_size = store->bytes & (PAGE_SIZE-1);
+			size = roundup(last_page_size,
 				       bdev_logical_block_size(bdev));
+		}
 		/* Just make sure we aren't corrupting data or
 		 * metadata
 		 */
@@ -973,6 +975,8 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
 	if (!bitmap->mddev->bitmap_info.external)
 		bytes += sizeof(bitmap_super_t);
 
+	store->bytes = bytes;
+
 	num_pages = DIV_ROUND_UP(bytes, PAGE_SIZE);
 
 	if (file && i_size_read(file->f_mapping->host) < bytes) {
@@ -1042,8 +1046,6 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
 
 			oldindex = index;
 
-			store->last_page_size = count;
-
 			if (outofdate) {
 				/*
 				 * if bitmap is out of date, dirty the
@@ -1966,9 +1968,7 @@ space_store(struct mddev *mddev, const char *buf, size_t len)
 		return -EINVAL;
 
 	if (mddev->bitmap &&
-	    sectors  < ((mddev->bitmap->storage.file_pages - 1)
-			      * PAGE_SIZE
-			+ mddev->bitmap->storage.last_page_size + 511) >> 9)
+	    sectors < (mddev->bitmap->storage.bytes + 511) >> 9)
 		return -EFBIG; /* Bitmap is too big for this small space */
 
 	/* could make sure it isn't too big, but that isn't really
diff --git a/drivers/md/bitmap.h b/drivers/md/bitmap.h
index 3cdea44..987ad3c 100644
--- a/drivers/md/bitmap.h
+++ b/drivers/md/bitmap.h
@@ -200,7 +200,7 @@ struct bitmap {
 		unsigned long *filemap_attr;	/* attributes associated
 						 * w/ filemap pages */
 		unsigned long file_pages;	/* number of pages in the file*/
-		int last_page_size;		/* bytes in the last page */
+		unsigned long bytes;		/* total bytes in the bitmap */
 	} storage;
 
 	unsigned long flags;



  parent reply	other threads:[~2012-04-17  8:43 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-17  8:43 [md PATCH 00/24] Allow bitmaps to be resized NeilBrown
2012-04-17  8:43 ` [md PATCH 02/24] md/bitmap: add new 'space' attribute for bitmaps NeilBrown
2012-04-17  8:43 ` [md PATCH 01/24] md/bitmap: disentangle two different 'pending' flags NeilBrown
2012-04-17  8:43 ` [md PATCH 05/24] md/bitmap: change *_page_attr() to take a page number, not a page NeilBrown
2012-04-17  8:43 ` [md PATCH 03/24] md/bitmap: allow a bitmap with no backing storage NeilBrown
2012-04-17  8:43 ` [md PATCH 06/24] md/bitmap: move some fields of 'struct bitmap' into a 'storage' substruct NeilBrown
2012-04-17  8:43 ` [md PATCH 08/24] md/bitmap: separate bitmap file allocation to its own function NeilBrown
2012-04-17  8:43 ` NeilBrown [this message]
2012-04-17  8:43 ` [md PATCH 09/24] md/bitmap: move storage allocation from bitmap_load to bitmap_create NeilBrown
2012-04-17  8:43 ` [md PATCH 04/24] md/bitmap: centralise allocation of bitmap file pages NeilBrown
2012-04-17  8:43 ` [md PATCH 13/24] md/bitmap: convert some spin_lock_irqsave to spin_lock_irq NeilBrown
2012-04-17  8:43 ` [md PATCH 10/24] md/bitmap: remove bitmap_mask_state NeilBrown
2012-04-17  8:43 ` [md PATCH 11/24] md/bitmap: remove single-bit manipulation on sb->state NeilBrown
2012-04-17  8:43 ` [md PATCH 16/24] md/bitmap: make _page_attr bitops atomic NeilBrown
2012-04-17  8:43 ` [md PATCH 15/24] md/bitmap: merge bitmap_file_unmap and bitmap_file_put NeilBrown
2012-04-17  8:43 ` [md PATCH 12/24] md/bitmap: use set_bit, test_bit, etc for operation on bitmap->flags NeilBrown
2012-04-17  8:43 ` [md PATCH 14/24] md/bitmap: remove async freeing of bitmap file NeilBrown
2012-04-17  8:43 ` [md PATCH 19/24] md/bitmap: use DIV_ROUND_UP instead of open-code NeilBrown
2012-04-17  8:43 ` [md PATCH 20/24] md/bitmap: add bitmap_resize function to allow bitmap resizing NeilBrown
2012-04-17  8:43 ` [md PATCH 18/24] md/bitmap: create a 'struct bitmap_counts' substructure of 'struct bitmap' NeilBrown
2012-04-17  8:43 ` [md PATCH 17/24] md/bitmap: make bitmap bitops atomic NeilBrown
2012-04-17  8:43 ` [md PATCH 23/24] md/raid10: resize bitmap when required during reshape NeilBrown
2012-04-17  8:43 ` [md PATCH 21/24] md/bitmap: make sure reshape request are reflected in superblock NeilBrown
2012-04-17  8:43 ` [md PATCH 22/24] md: allow array to be resized while bitmap is present NeilBrown
2012-04-17  8:43 ` [md PATCH 24/24] md/raid5: Allow reshape while a " NeilBrown
2012-04-18  2:07 ` [md PATCH 00/24] Allow bitmaps to be resized Jack Wang
2012-04-18  3:35   ` NeilBrown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120417084340.6433.82130.stgit@notabene.brown \
    --to=neilb@suse.de \
    --cc=linux-raid@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).