From patchwork Thu Mar 17 14:30:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Foster X-Patchwork-Id: 8611831 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 274619FC32 for ; Thu, 17 Mar 2016 14:31:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5F856201ED for ; Thu, 17 Mar 2016 14:31:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 74A472021B for ; Thu, 17 Mar 2016 14:31:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965702AbcCQOaq (ORCPT ); Thu, 17 Mar 2016 10:30:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49791 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934723AbcCQOaj (ORCPT ); Thu, 17 Mar 2016 10:30:39 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 6DE58711E1; Thu, 17 Mar 2016 14:30:39 +0000 (UTC) Received: from bfoster.bfoster (dhcp-41-24.bos.redhat.com [10.18.41.24]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2HEUdtT026362; Thu, 17 Mar 2016 10:30:39 -0400 Received: by bfoster.bfoster (Postfix, from userid 1000) id A517912505D; Thu, 17 Mar 2016 10:30:37 -0400 (EDT) From: Brian Foster To: xfs@oss.sgi.com Cc: dm-devel@redhat.com, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [RFC PATCH 6/9] dm: add method to provision space Date: Thu, 17 Mar 2016 10:30:34 -0400 Message-Id: <1458225037-24155-7-git-send-email-bfoster@redhat.com> In-Reply-To: <1458225037-24155-1-git-send-email-bfoster@redhat.com> References: <1458225037-24155-1-git-send-email-bfoster@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 17 Mar 2016 14:30:39 +0000 (UTC) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Brian Foster --- drivers/md/dm.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/device-mapper.h | 2 ++ 2 files changed, 37 insertions(+) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 4da5d3e..e1aec28 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -737,6 +737,40 @@ out: return r; } +static int dm_blk_provision_space(struct block_device *bdev, + sector_t offset, sector_t len) +{ + struct mapped_device *md = bdev->bd_disk->private_data; + int srcu_idx; + struct dm_table *map; + struct dm_target *tgt; + int r = -EINVAL; + + map = dm_get_live_table(md, &srcu_idx); + + if (!map || !dm_table_get_size(map)) + goto out; + + /* We only support devices that have a single target */ + if (dm_table_get_num_targets(map) != 1) + goto out; + + tgt = dm_table_get_target(map, 0); + if (!tgt->type->provision_space) + goto out; + + if (dm_suspended_md(md)) { + r = -EAGAIN; + goto out; + } + + r = tgt->type->provision_space(tgt, offset, len); +out: + dm_put_live_table(md, srcu_idx); + + return r; +} + static struct dm_io *alloc_io(struct mapped_device *md) { return mempool_alloc(md->io_pool, GFP_NOIO); @@ -3798,6 +3832,7 @@ static const struct block_device_operations dm_blk_dops = { .pr_ops = &dm_pr_ops, .reserve_space = dm_blk_reserve_space, .get_reserved_space = dm_blk_get_reserved_space, + .provision_space = dm_blk_provision_space, .owner = THIS_MODULE }; diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 540c772..0ebf172 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -118,6 +118,7 @@ typedef int (*dm_busy_fn) (struct dm_target *ti); typedef int (*dm_reserve_space_fn) (struct dm_target *ti, sector_t nr_sects); typedef int (*dm_get_reserved_space_fn) (struct dm_target *ti, sector_t *nr_sects); +typedef int (*dm_provision_space_fn) (struct dm_target *ti, sector_t offset, sector_t len); void dm_error(const char *message); @@ -167,6 +168,7 @@ struct target_type { dm_io_hints_fn io_hints; dm_reserve_space_fn reserve_space; dm_get_reserved_space_fn get_reserved_space; + dm_provision_space_fn provision_space; /* For internal device-mapper use. */ struct list_head list;