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: 8611751 Return-Path: X-Original-To: patchwork-linux-fsdevel@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 5A611C0553 for ; Thu, 17 Mar 2016 14:30:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9F9FC20361 for ; Thu, 17 Mar 2016 14:30:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A5FB62021B for ; Thu, 17 Mar 2016 14:30:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935445AbcCQOam (ORCPT ); Thu, 17 Mar 2016 10:30:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49785 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934312AbcCQOaj (ORCPT ); Thu, 17 Mar 2016 10:30:39 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 15639711C9; 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-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 Cc: dm-devel@redhat.com, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [RFC PATCH 4/9] dm thin: update reserve space func to allow reduction 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-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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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 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;