From patchwork Tue Apr 12 16:42:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Foster X-Patchwork-Id: 8814031 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 7E284C0553 for ; Tue, 12 Apr 2016 18:22:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7A430202D1 for ; Tue, 12 Apr 2016 18:22:37 +0000 (UTC) Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) (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 71604201BB for ; Tue, 12 Apr 2016 18:22:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3CIJwGj058654; Tue, 12 Apr 2016 14:19:58 -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 u3CGgsgh005712 for ; Tue, 12 Apr 2016 12:42:54 -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 u3CGgs6h024193; Tue, 12 Apr 2016 12:42:54 -0400 Received: by bfoster.bfoster (Postfix, from userid 1000) id 44503125439; Tue, 12 Apr 2016 12:42:53 -0400 (EDT) From: Brian Foster To: xfs@oss.sgi.com Date: Tue, 12 Apr 2016 12:42:45 -0400 Message-Id: <1460479373-63317-3-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 02/10] xfs: replace xfs_mod_fdblocks() bool param with flags 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 xfs_mod_fdblocks() takes a boolean parameter to indicate whether the requested allocation can dip into the XFS reserve block pool, if necessary, to satisfy the allocation. This function will also require caller control over block device reservation. In preparation, convert the bool parameter to a flags parameter and update all callers to use the appropriate reserved pool flag as appropriate. Signed-off-by: Brian Foster --- fs/xfs/libxfs/xfs_bmap.c | 17 ++++++++--------- fs/xfs/xfs_mount.c | 3 ++- fs/xfs/xfs_mount.h | 4 +++- fs/xfs/xfs_trans.c | 21 ++++++++++++++------- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index ce41d7f..1a805b0 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -2186,7 +2186,7 @@ xfs_bmap_add_extent_delay_real( (bma->cur ? bma->cur->bc_private.b.allocated : 0)); if (diff > 0) { error = xfs_mod_fdblocks(bma->ip->i_mount, - -((int64_t)diff), false); + -((int64_t)diff), 0); ASSERT(!error); if (error) goto done; @@ -2238,7 +2238,7 @@ xfs_bmap_add_extent_delay_real( ASSERT(temp <= da_old); if (temp < da_old) xfs_mod_fdblocks(bma->ip->i_mount, - (int64_t)(da_old - temp), false); + (int64_t)(da_old - temp), 0); } /* clear out the allocated field, done with it now in any case. */ @@ -2916,8 +2916,7 @@ xfs_bmap_add_extent_hole_delay( } if (oldlen != newlen) { ASSERT(oldlen > newlen); - xfs_mod_fdblocks(ip->i_mount, (int64_t)(oldlen - newlen), - false); + xfs_mod_fdblocks(ip->i_mount, (int64_t)(oldlen - newlen), 0); /* * Nothing to do for disk quota accounting here. */ @@ -4149,13 +4148,13 @@ xfs_bmapi_reserve_delalloc( if (rt) { error = xfs_mod_frextents(mp, -((int64_t)extsz)); } else { - error = xfs_mod_fdblocks(mp, -((int64_t)alen), false); + error = xfs_mod_fdblocks(mp, -((int64_t)alen), 0); } if (error) goto out_unreserve_quota; - error = xfs_mod_fdblocks(mp, -((int64_t)indlen), false); + error = xfs_mod_fdblocks(mp, -((int64_t)indlen), 0); if (error) goto out_unreserve_blocks; @@ -4184,7 +4183,7 @@ out_unreserve_blocks: if (rt) xfs_mod_frextents(mp, extsz); else - xfs_mod_fdblocks(mp, alen, false); + xfs_mod_fdblocks(mp, alen, 0); out_unreserve_quota: if (XFS_IS_QUOTA_ON(mp)) xfs_trans_unreserve_quota_nblks(NULL, ip, (long)alen, 0, rt ? @@ -5093,7 +5092,7 @@ xfs_bmap_del_extent( */ ASSERT(da_old >= da_new); if (da_old > da_new) - xfs_mod_fdblocks(mp, (int64_t)(da_old - da_new), false); + xfs_mod_fdblocks(mp, (int64_t)(da_old - da_new), 0); done: *logflagsp = flags; return error; @@ -5413,7 +5412,7 @@ xfs_bunmapi( goto error0; if (!isrt && wasdel) - xfs_mod_fdblocks(mp, (int64_t)del.br_blockcount, false); + xfs_mod_fdblocks(mp, (int64_t)del.br_blockcount, 0); bno = del.br_startoff - 1; nodelete: diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index cfd4210..50a6ccc 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -1150,11 +1150,12 @@ int xfs_mod_fdblocks( struct xfs_mount *mp, int64_t delta, - bool rsvd) + uint32_t flags) { int64_t lcounter; long long res_used; s32 batch; + bool rsvd = (flags & XFS_FDBLOCKS_RSVD); if (delta > 0) { /* diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index eafe257..bd1043f 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -347,8 +347,10 @@ extern void xfs_unmountfs(xfs_mount_t *); extern int xfs_mod_icount(struct xfs_mount *mp, int64_t delta); extern int xfs_mod_ifree(struct xfs_mount *mp, int64_t delta); + +#define XFS_FDBLOCKS_RSVD (1 << 0) extern int xfs_mod_fdblocks(struct xfs_mount *mp, int64_t delta, - bool reserved); + uint32_t flags); extern int xfs_mod_frextents(struct xfs_mount *mp, int64_t delta); extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int); diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 20c5366..8aa9d9a 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -172,8 +172,11 @@ xfs_trans_reserve( uint blocks, uint rtextents) { - int error = 0; - bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; + int error = 0; + int flags = 0; + + if (tp->t_flags & XFS_TRANS_RESERVE) + flags |= XFS_FDBLOCKS_RSVD; /* Mark this thread as being in a transaction */ current_set_flags_nested(&tp->t_pflags, PF_FSTRANS); @@ -184,7 +187,8 @@ xfs_trans_reserve( * fail if the count would go below zero. */ if (blocks > 0) { - error = xfs_mod_fdblocks(tp->t_mountp, -((int64_t)blocks), rsvd); + error = xfs_mod_fdblocks(tp->t_mountp, -((int64_t)blocks), + flags); if (error != 0) { current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS); return -ENOSPC; @@ -259,7 +263,7 @@ undo_log: undo_blocks: if (blocks > 0) { - xfs_mod_fdblocks(tp->t_mountp, -((int64_t)blocks), rsvd); + xfs_mod_fdblocks(tp->t_mountp, -((int64_t)blocks), flags); tp->t_blk_res = 0; } @@ -543,12 +547,15 @@ xfs_trans_unreserve_and_mod_sb( struct xfs_trans *tp) { struct xfs_mount *mp = tp->t_mountp; - bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; int64_t blkdelta = 0; int64_t rtxdelta = 0; int64_t idelta = 0; int64_t ifreedelta = 0; int error; + int flags = 0; + + if (tp->t_flags & XFS_TRANS_RESERVE) + flags |= XFS_FDBLOCKS_RSVD; /* calculate deltas */ if (tp->t_blk_res > 0) @@ -572,7 +579,7 @@ xfs_trans_unreserve_and_mod_sb( /* apply the per-cpu counters */ if (blkdelta) { - error = xfs_mod_fdblocks(mp, blkdelta, rsvd); + error = xfs_mod_fdblocks(mp, blkdelta, flags); if (error) goto out; } @@ -680,7 +687,7 @@ out_undo_icount: xfs_mod_icount(mp, -idelta); out_undo_fdblocks: if (blkdelta) - xfs_mod_fdblocks(mp, -blkdelta, rsvd); + xfs_mod_fdblocks(mp, -blkdelta, flags); out: ASSERT(error == 0); return;