From patchwork Thu Mar 17 14:30:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Foster X-Patchwork-Id: 8617711 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B00BEC0553 for ; Fri, 18 Mar 2016 10:04:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9C2F4202E9 for ; Fri, 18 Mar 2016 10:04:15 +0000 (UTC) Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 80592201C8 for ; Fri, 18 Mar 2016 10:04:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u2I9xWsw015761; Fri, 18 Mar 2016 05:59:32 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u2HEUdWo022695 for ; Thu, 17 Mar 2016 10:30:39 -0400 Received: from bfoster.bfoster (dhcp-41-24.bos.redhat.com [10.18.41.24]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2HEUcMP003130; Thu, 17 Mar 2016 10:30:38 -0400 Received: by bfoster.bfoster (Postfix, from userid 1000) id 8E69812504F; Thu, 17 Mar 2016 10:30:37 -0400 (EDT) From: Brian Foster To: xfs@oss.sgi.com Date: Thu, 17 Mar 2016 10:30:32 -0400 Message-Id: <1458225037-24155-5-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.24 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Fri, 18 Mar 2016 05:58:54 -0400 Cc: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, dm-devel@redhat.com Subject: [dm-devel] [RFC PATCH 4/9] dm thin: update reserve space func to allow reduction X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com 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 The dm-thin set_reserve_count() function is designed to control the current block reservation for a thin pool. It currently only provides the ability to increase the reservation. Clients such as XFS will rely on over-reservation and thus require the ability to release excess reservation back to the pool. Update set_reserve_count() to return reserved blocks back to the pool. Signed-off-by: Brian Foster --- drivers/md/dm-thin.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index 31d36da..ac770d89 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c @@ -1429,7 +1429,8 @@ static bool dec_reserve_count(struct thin_c *tc, dm_block_t free_blocks) static int set_reserve_count(struct thin_c *tc, dm_block_t count) { int r; - dm_block_t free_blocks, delta; + dm_block_t free_blocks; + int64_t delta; unsigned long flags; r = get_free_blocks(tc->pool, &free_blocks); @@ -1437,8 +1438,6 @@ static int set_reserve_count(struct thin_c *tc, dm_block_t count) return r; spin_lock_irqsave(&tc->pool->lock, flags); - if (count <= tc->reserve_count) - goto out_unlock; /* nothing to do */ delta = count - tc->reserve_count; if (tc->pool->reserve_count + delta > free_blocks) r = -ENOSPC; @@ -1446,7 +1445,6 @@ static int set_reserve_count(struct thin_c *tc, dm_block_t count) tc->reserve_count = count; tc->pool->reserve_count += delta; } -out_unlock: spin_unlock_irqrestore(&tc->pool->lock, flags); return r; @@ -4369,7 +4367,7 @@ static int thin_reserve_space(struct dm_target *ti, sector_t nr_sects) * @nr_sects must always be a factor of the pool's blocksize; * upper layers can rely on the bdev's minimum_io_size for this. */ - if (!nr_sects || !is_factor(nr_sects, pool->sectors_per_block)) + if (!is_factor(nr_sects, pool->sectors_per_block)) return -EINVAL; blocks = nr_sects;