From patchwork Tue Apr 12 16:42:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Foster X-Patchwork-Id: 8814011 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Original-To: patchwork-dm-devel@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 392489F54F for ; Tue, 12 Apr 2016 18:22:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5EEF62034C for ; Tue, 12 Apr 2016 18:22:19 +0000 (UTC) Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 82136201BB for ; Tue, 12 Apr 2016 18:22:18 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3CIJc3e049649; Tue, 12 Apr 2016 14:19:38 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u3CGgtkg005731 for ; Tue, 12 Apr 2016 12:42:55 -0400 Received: from bfoster.bfoster (dhcp-41-153.bos.redhat.com [10.18.41.153]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3CGgtZP024201; Tue, 12 Apr 2016 12:42:55 -0400 Received: by bfoster.bfoster (Postfix, from userid 1000) id A41B3125487; Tue, 12 Apr 2016 12:42:53 -0400 (EDT) From: Brian Foster To: xfs@oss.sgi.com Date: Tue, 12 Apr 2016 12:42:52 -0400 Message-Id: <1460479373-63317-10-git-send-email-bfoster@redhat.com> In-Reply-To: <1460479373-63317-1-git-send-email-bfoster@redhat.com> References: <1460479373-63317-1-git-send-email-bfoster@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Tue, 12 Apr 2016 14:18:51 -0400 Cc: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, dm-devel@redhat.com Subject: [dm-devel] [RFC v2 PATCH 09/10] xfs: support no block reservation transaction mode 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=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 block device reservation mechanism is tied into the transaction reservation mechanism and assumes the worst case scenario of a 1-1 mapping between filesystem blocks and dm blocks. This might be overkill for certain codepaths that have enough context to not require a worst-case reservation. Define an optional transaction flag to disable block reservation on a per-transaction basis. This allows any particular operation to open code a block device reservation and potentially use a more optimal reservation value. Signed-off-by: Brian Foster --- fs/xfs/libxfs/xfs_shared.h | 2 ++ fs/xfs/xfs_trans.c | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h index 81ac870..ba79373 100644 --- a/fs/xfs/libxfs/xfs_shared.h +++ b/fs/xfs/libxfs/xfs_shared.h @@ -183,6 +183,8 @@ int xfs_log_calc_minimum_size(struct xfs_mount *); #define XFS_TRANS_RESERVE 0x20 /* OK to use reserved data blocks */ #define XFS_TRANS_FREEZE_PROT 0x40 /* Transaction has elevated writer count in superblock */ +#define XFS_TRANS_NOBLKRES 0x100 /* do not attempt blkdev reservation */ + /* * Field values for xfs_trans_mod_sb. */ diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 26e6288..343e435 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -174,11 +174,13 @@ xfs_trans_reserve( uint rtextents) { int error = 0; - int flags = 0; + int flags = XFS_BLK_RES; struct xfs_mount *mp = tp->t_mountp; if (tp->t_flags & XFS_TRANS_RESERVE) flags |= XFS_FDBLOCKS_RSVD; + if (tp->t_flags & XFS_TRANS_NOBLKRES) + flags &= ~XFS_BLK_RES; /* Mark this thread as being in a transaction */ current_set_flags_nested(&tp->t_pflags, PF_FSTRANS); @@ -189,13 +191,13 @@ xfs_trans_reserve( * fail if the count would go below zero. */ if (blocks > 0) { - error = xfs_mod_fdblocks(mp, -((int64_t)blocks), flags); + error = __xfs_mod_fdblocks(mp, -((int64_t)blocks), flags); if (error != 0) { current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); return -ENOSPC; } tp->t_blk_res += blocks; - if (mp->m_thin_res) + if (mp->m_thin_res && (flags & XFS_BLK_RES)) tp->t_blk_thin_res += xfs_fsb_res(mp, blocks, false); } @@ -266,7 +268,7 @@ undo_log: undo_blocks: if (blocks > 0) { - xfs_mod_fdblocks(tp->t_mountp, -((int64_t)blocks), flags); + __xfs_mod_fdblocks(tp->t_mountp, -((int64_t)blocks), flags); tp->t_blk_res = 0; if (tp->t_blk_thin_res) tp->t_blk_thin_res = 0;