From: Brian Foster <bfoster@redhat.com>
To: xfs@oss.sgi.com
Cc: dm-devel@redhat.com, linux-block@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: [RFC PATCH 7/9] dm thin: add method to provision space
Date: Thu, 17 Mar 2016 10:30:35 -0400 [thread overview]
Message-ID: <1458225037-24155-8-git-send-email-bfoster@redhat.com> (raw)
In-Reply-To: <1458225037-24155-1-git-send-email-bfoster@redhat.com>
This is a hacky interface added to support the filesystem experiment for
reserving blocks out of thin pools. The XFS POC uses this method
provision space in the pool when blocks are allocated. The number of
actual blocks allocated is returned, which is used to update the
filesystem accounting.
Signed-off-by: Brian Foster <bfoster@redhat.com>
---
drivers/md/dm-thin.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index ac770d89..00b7322 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -4389,6 +4389,52 @@ static int thin_get_reserved_space(struct dm_target *ti, sector_t *nr_sects)
return 0;
}
+static int thin_provision_space(struct dm_target *ti, sector_t offset, sector_t len)
+{
+ struct thin_c *tc = ti->private;
+ struct pool *pool = tc->pool;
+ sector_t end;
+ dm_block_t pblock;
+ dm_block_t vblock;
+ int error;
+ struct dm_thin_lookup_result lookup;
+ sector_t count;
+
+ if (!is_factor(offset, pool->sectors_per_block))
+ return -EINVAL;
+
+ if (!len || !is_factor(len, pool->sectors_per_block))
+ return -EINVAL;
+
+ end = offset + len;
+
+ count = 0;
+ while (offset < end) {
+ vblock = offset / pool->sectors_per_block;
+
+ error = dm_thin_find_block(tc->td, vblock, true, &lookup);
+ if (error == 0)
+ goto next;
+ if (error != -ENODATA)
+ return error;
+
+ error = alloc_data_block(tc, &pblock);
+ if (error)
+ return error;
+
+ error = dm_thin_insert_block(tc->td, vblock, pblock);
+ if (error)
+ return error;
+
+ count += pool->sectors_per_block;
+next:
+ offset += pool->sectors_per_block;
+ }
+
+ /* XXX: int -> sector_t ! */
+ return count;
+}
+
static struct target_type thin_target = {
.name = "thin",
.version = {1, 18, 0},
@@ -4405,6 +4451,7 @@ static struct target_type thin_target = {
.io_hints = thin_io_hints,
.reserve_space = thin_reserve_space,
.get_reserved_space = thin_get_reserved_space,
+ .provision_space = thin_provision_space,
};
/*----------------------------------------------------------------*/
--
2.4.3
next prev parent reply other threads:[~2016-03-17 14:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-17 14:30 [RFC PATCH 0/9] dm-thin/xfs: prototype a block reservation allocation model Brian Foster
2016-03-17 14:30 ` [RFC PATCH 1/9] block: add block_device_operations methods to set and get reserved space Brian Foster
2016-03-21 12:08 ` Carlos Maiolino
2016-03-21 21:53 ` Dave Chinner
2016-03-22 12:05 ` Brian Foster
2016-03-17 14:30 ` [RFC PATCH 2/9] dm: add " Brian Foster
2016-03-21 12:17 ` Carlos Maiolino
2016-03-17 14:30 ` [RFC PATCH 3/9] dm thin: " Brian Foster
2016-03-17 14:30 ` [RFC PATCH 4/9] dm thin: update reserve space func to allow reduction Brian Foster
2016-03-17 14:30 ` [RFC PATCH 5/9] block: add a block_device_operations method to provision space Brian Foster
2016-03-17 14:30 ` [RFC PATCH 6/9] dm: add " Brian Foster
2016-03-17 14:30 ` Brian Foster [this message]
2016-03-17 14:30 ` [RFC PATCH 8/9] xfs: thin block device reservation mechanism Brian Foster
2016-03-17 14:30 ` [RFC PATCH 9/9] xfs: adopt a reserved allocation model on dm-thin devices Brian Foster
2016-03-21 13:33 ` [RFC PATCH 0/9] dm-thin/xfs: prototype a block reservation allocation model Carlos Maiolino
2016-03-21 22:36 ` Dave Chinner
2016-03-22 12:06 ` Brian Foster
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=1458225037-24155-8-git-send-email-bfoster@redhat.com \
--to=bfoster@redhat.com \
--cc=dm-devel@redhat.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=xfs@oss.sgi.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;
as well as URLs for NNTP newsgroup(s).