From: Christoph Hellwig <hch@lst.de>
To: darrick.wong@oracle.com
Cc: xfs@oss.sgi.com
Subject: [PATCH 2/3] xfs: refactor xfs_refcountbt_alloc_block
Date: Thu, 2 Jun 2016 16:19:09 +0200 [thread overview]
Message-ID: <1464877150-20457-3-git-send-email-hch@lst.de> (raw)
In-Reply-To: <1464877150-20457-1-git-send-email-hch@lst.de>
Split out a low level helper that we can use for enabling the reflink
btree at mount time.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/libxfs/xfs_refcount_btree.c | 54 +++++++++++++++++++++++---------------
1 file changed, 33 insertions(+), 21 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_refcount_btree.c b/fs/xfs/libxfs/xfs_refcount_btree.c
index f83cb4b..7ae3ad7 100644
--- a/fs/xfs/libxfs/xfs_refcount_btree.c
+++ b/fs/xfs/libxfs/xfs_refcount_btree.c
@@ -66,49 +66,61 @@ xfs_refcountbt_set_root(
}
STATIC int
-xfs_refcountbt_alloc_block(
- struct xfs_btree_cur *cur,
- union xfs_btree_ptr *start,
- union xfs_btree_ptr *new,
+__xfs_refcountbt_alloc_block(
+ struct xfs_trans *tp,
+ xfs_agnumber_t agno,
+ enum xfs_ag_resv_type resv,
+ __be32 *agbno,
int *stat)
{
+ struct xfs_mount *mp = tp->t_mountp;
struct xfs_alloc_arg args; /* block allocation args */
int error; /* error return value */
- XFS_BTREE_TRACE_CURSOR(cur, XBT_ENTRY);
-
memset(&args, 0, sizeof(args));
- args.tp = cur->bc_tp;
- args.mp = cur->bc_mp;
+ args.tp = tp;
+ args.mp = mp;
args.type = XFS_ALLOCTYPE_NEAR_BNO;
- args.fsbno = XFS_AGB_TO_FSB(cur->bc_mp, cur->bc_private.a.agno,
- xfs_refc_block(args.mp));
+ args.fsbno = XFS_AGB_TO_FSB(mp, agno, xfs_refc_block(mp));
args.firstblock = args.fsbno;
xfs_rmap_ag_owner(&args.oinfo, XFS_RMAP_OWN_REFC);
args.minlen = args.maxlen = args.prod = 1;
- args.resv = XFS_AG_RESV_METADATA;
+ args.resv = resv;
error = xfs_alloc_vextent(&args);
if (error)
- goto out_error;
- trace_xfs_refcountbt_alloc_block(cur->bc_mp, cur->bc_private.a.agno,
- args.agbno, 1);
+ return error;
+ trace_xfs_refcountbt_alloc_block(mp, agno, args.agbno, 1);
if (args.fsbno == NULLFSBLOCK) {
- XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT);
*stat = 0;
return 0;
}
- ASSERT(args.agno == cur->bc_private.a.agno);
+ ASSERT(args.agno == agno);
ASSERT(args.len == 1);
- new->s = cpu_to_be32(args.agbno);
-
- XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT);
+ *agbno = cpu_to_be32(args.agbno);
*stat = 1;
return 0;
+}
+
+STATIC int
+xfs_refcountbt_alloc_block(
+ struct xfs_btree_cur *cur,
+ union xfs_btree_ptr *start,
+ union xfs_btree_ptr *new,
+ int *stat)
+{
+ int error;
+
+ XFS_BTREE_TRACE_CURSOR(cur, XBT_ENTRY);
+
+ error = __xfs_refcountbt_alloc_block(cur->bc_tp, cur->bc_private.a.agno,
+ XFS_AG_RESV_METADATA, &new->s, stat);
+ if (error)
+ XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
+ else
+ XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT);
-out_error:
- XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
return error;
}
--
2.1.4
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2016-06-02 14:19 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-02 14:19 [RFC] allow enabling reflinks at runtime Christoph Hellwig
2016-06-02 14:19 ` [PATCH 1/3] xfs: add xfs_mp_hasreflink Christoph Hellwig
2016-06-02 14:19 ` Christoph Hellwig [this message]
2016-06-02 14:19 ` [PATCH 3/3] xfs: add an option to enable reflinks at mount time Christoph Hellwig
2016-06-06 11:23 ` Carlos Maiolino
2016-06-06 11:29 ` Carlos Maiolino
2016-06-06 16:52 ` Darrick J. Wong
2016-06-08 7:04 ` Christoph Hellwig
2016-06-08 8:07 ` Carlos Maiolino
2016-06-08 8:10 ` Carlos Maiolino
2016-06-09 22:57 ` Dave Chinner
2016-06-02 22:54 ` [RFC] allow enabling reflinks at runtime Dave Chinner
2016-06-03 1:58 ` Darrick J. Wong
2016-06-06 18:52 ` Darrick J. Wong
2016-06-08 7:10 ` Christoph Hellwig
2016-06-08 7:11 ` Christoph Hellwig
2016-06-09 17:45 ` Darrick J. Wong
2016-06-09 23:33 ` Dave Chinner
2016-07-13 5:36 ` Darrick J. Wong
2016-10-26 20:49 ` Darrick J. Wong
2016-11-03 16:10 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1464877150-20457-3-git-send-email-hch@lst.de \
--to=hch@lst.de \
--cc=darrick.wong@oracle.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).