public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: dm-devel@redhat.com
Cc: linux-kernel@vger.kernel.org, Mikulas Patocka <mpatocka@redhat.com>
Subject: [PATCH v4 04/13] dm exception store: snapshot-merge usage accounting
Date: Fri, 20 Nov 2009 15:27:44 -0500	[thread overview]
Message-ID: <1258748873-24185-5-git-send-email-snitzer@redhat.com> (raw)
In-Reply-To: <1258748873-24185-1-git-send-email-snitzer@redhat.com>

Conditionally adjust snapshot usage accounting if snapshot-merge is in
progress.  Care is taken to preserve the established kernel<->userspace
interface.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: Mikulas Patocka <mpatocka@redhat.com>
---
 drivers/md/dm-snap-persistent.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c
index 1f5752e..3cb609b 100644
--- a/drivers/md/dm-snap-persistent.c
+++ b/drivers/md/dm-snap-persistent.c
@@ -91,6 +91,7 @@ struct pstore {
 	struct dm_exception_store *store;
 	int version;
 	int valid;
+	int merging;	/* 1 if there is merging going on */
 	uint32_t exceptions_per_area;
 
 	/*
@@ -506,7 +507,20 @@ static void persistent_usage(struct dm_exception_store *store,
 {
 	struct pstore *ps = get_info(store);
 
-	*sectors_allocated = ps->next_free * store->chunk_size;
+	/*
+	 * Must maintain the fact that DM reports all metadata chunks
+	 * in 'sectors_allocated'
+	 * - preserves the established kernel<->userspace interface
+	 * - snapshot-merge must account for the first two metadata
+	 *   chunks in its 'sectors_allocated'
+	 */
+	if (!ps->merging) {
+		*sectors_allocated = ps->next_free * store->chunk_size;
+	} else {
+		*sectors_allocated =
+			(area_location(ps, ps->current_area) - 1 +
+			 ps->current_committed + 2) * store->chunk_size;
+	}
 	*total_sectors = get_dev_size(dm_snap_cow(store->snap)->bdev);
 
 	/*
@@ -608,6 +622,8 @@ static int persistent_prepare_exception(struct dm_exception_store *store,
 	chunk_t next_free;
 	sector_t size = get_dev_size(dm_snap_cow(store->snap)->bdev);
 
+	ps->merging = 0;
+
 	/* Is there enough room ? */
 	if (size < ((ps->next_free + 1) * store->chunk_size))
 		return -ENOSPC;
@@ -696,6 +712,8 @@ static int persistent_prepare_merge(struct dm_exception_store *store,
 	struct pstore *ps = get_info(store);
 	struct disk_exception de;
 
+	ps->merging = 1;
+
 	if (!ps->current_committed) {
 		if (!ps->current_area)
 			return 0;
@@ -767,6 +785,7 @@ static int persistent_ctr(struct dm_exception_store *store,
 
 	ps->store = store;
 	ps->valid = 1;
+	ps->merging = 0;
 	ps->version = SNAPSHOT_DISK_VERSION;
 	ps->area = NULL;
 	ps->zero_area = NULL;
-- 
1.6.5.2


  parent reply	other threads:[~2009-11-20 20:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-20 20:27 [PATCH v4 00/13] snapshot-merge target Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 01/13] dm snapshot: allow live exception store handover between tables Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 02/13] dm snapshot: rework writing to snapshot origin Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 03/13] dm exception store: add snapshot-merge specific methods Mike Snitzer
2009-11-20 20:27 ` Mike Snitzer [this message]
2009-11-20 20:27 ` [PATCH v4 05/13] dm snapshot: add snapshot-merge target Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 06/13] dm snapshot: merge target should not allocate new exceptions Mike Snitzer
2009-11-20 20:54   ` Mike Snitzer
2009-11-20 21:02   ` Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 07/13] dm snapshot: do not allow more than one merging snapshot Mike Snitzer
2009-11-20 21:04   ` Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 08/13] dm snapshot: the merge procedure Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 09/13] dm snapshot: queue writes to an area that is actively being merged Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 10/13] dm snapshot: do not merge a chunk until active writes to it finish Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 11/13] dm snapshot: make exceptions in other snapshots when merging Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 12/13] dm snapshot: redirect accesses to origin if merging snap invalidated Mike Snitzer
2009-11-20 20:27 ` [PATCH v4 13/13] dm snapshot: merge a linear region of chunks using one large IO Mike Snitzer

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=1258748873-24185-5-git-send-email-snitzer@redhat.com \
    --to=snitzer@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    /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