From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 15/16] xfs: add rmap btree insert and delete helpers
Date: Tue, 8 Mar 2016 15:16:17 +1100 [thread overview]
Message-ID: <1457410578-30233-16-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1457410578-30233-1-git-send-email-david@fromorbit.com>
From: "Darrick J. Wong" <darrick.wong@oracle.com>
Add a couple of helper functions to encapsulate rmap btree insert and
delete operations. Add tracepoints to the update function.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
fs/xfs/libxfs/xfs_rmap.c | 62 ++++++++++++++++++++++++++++++++++++++++++
fs/xfs/libxfs/xfs_rmap_btree.h | 2 ++
2 files changed, 64 insertions(+)
diff --git a/fs/xfs/libxfs/xfs_rmap.c b/fs/xfs/libxfs/xfs_rmap.c
index d2e01b2..479cb73 100644
--- a/fs/xfs/libxfs/xfs_rmap.c
+++ b/fs/xfs/libxfs/xfs_rmap.c
@@ -88,6 +88,10 @@ xfs_rmap_update(
{
union xfs_btree_rec rec;
+ trace_xfs_rmapbt_update(cur->bc_mp, cur->bc_private.a.agno,
+ irec->rm_startblock, irec->rm_blockcount,
+ irec->rm_owner, irec->rm_offset);
+
rec.rmap.rm_startblock = cpu_to_be32(irec->rm_startblock);
rec.rmap.rm_blockcount = cpu_to_be32(irec->rm_blockcount);
rec.rmap.rm_owner = cpu_to_be64(irec->rm_owner);
@@ -95,6 +99,64 @@ xfs_rmap_update(
return xfs_btree_update(cur, &rec);
}
+int
+xfs_rmapbt_insert(
+ struct xfs_btree_cur *rcur,
+ xfs_agblock_t agbno,
+ xfs_extlen_t len,
+ uint64_t owner,
+ uint64_t offset)
+{
+ int i;
+ int error;
+
+ trace_xfs_rmapbt_insert(rcur->bc_mp, rcur->bc_private.a.agno, agbno,
+ len, owner, offset);
+
+ error = xfs_rmap_lookup_eq(rcur, agbno, len, owner, offset, &i);
+ if (error)
+ goto done;
+ XFS_WANT_CORRUPTED_GOTO(rcur->bc_mp, i == 0, done);
+
+ rcur->bc_rec.r.rm_startblock = agbno;
+ rcur->bc_rec.r.rm_blockcount = len;
+ rcur->bc_rec.r.rm_owner = owner;
+ rcur->bc_rec.r.rm_offset = offset;
+ error = xfs_btree_insert(rcur, &i);
+ if (error)
+ goto done;
+ XFS_WANT_CORRUPTED_GOTO(rcur->bc_mp, i == 1, done);
+done:
+ return error;
+}
+
+STATIC int
+xfs_rmapbt_delete(
+ struct xfs_btree_cur *rcur,
+ xfs_agblock_t agbno,
+ xfs_extlen_t len,
+ uint64_t owner,
+ uint64_t offset)
+{
+ int i;
+ int error;
+
+ trace_xfs_rmapbt_delete(rcur->bc_mp, rcur->bc_private.a.agno, agbno,
+ len, owner, offset);
+
+ error = xfs_rmap_lookup_eq(rcur, agbno, len, owner, offset, &i);
+ if (error)
+ goto done;
+ XFS_WANT_CORRUPTED_GOTO(rcur->bc_mp, i == 1, done);
+
+ error = xfs_btree_delete(rcur, &i);
+ if (error)
+ goto done;
+ XFS_WANT_CORRUPTED_GOTO(rcur->bc_mp, i == 1, done);
+done:
+ return error;
+}
+
/*
* Get the data from the pointed-to record.
*/
diff --git a/fs/xfs/libxfs/xfs_rmap_btree.h b/fs/xfs/libxfs/xfs_rmap_btree.h
index 0dfc151..d7c9722 100644
--- a/fs/xfs/libxfs/xfs_rmap_btree.h
+++ b/fs/xfs/libxfs/xfs_rmap_btree.h
@@ -55,6 +55,8 @@ int xfs_rmap_lookup_le(struct xfs_btree_cur *cur, xfs_agblock_t bno,
xfs_extlen_t len, uint64_t owner, uint64_t offset, int *stat);
int xfs_rmap_lookup_eq(struct xfs_btree_cur *cur, xfs_agblock_t bno,
xfs_extlen_t len, uint64_t owner, uint64_t offset, int *stat);
+int xfs_rmapbt_insert(struct xfs_btree_cur *rcur, xfs_agblock_t agbno,
+ xfs_extlen_t len, uint64_t owner, uint64_t offset);
int xfs_rmap_get_rec(struct xfs_btree_cur *cur, struct xfs_rmap_irec *irec,
int *stat);
--
2.7.0
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2016-03-08 4:17 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-08 4:16 [PATCH 0/16] xfs: first part of rmapbt functionality Dave Chinner
2016-03-08 4:16 ` [PATCH 01/16] xfs: introduce rmap btree definitions Dave Chinner
2016-03-08 4:16 ` [PATCH 02/16] xfs: add rmap btree stats infrastructure Dave Chinner
2016-03-08 4:16 ` [PATCH 03/16] xfs: rmap btree add more reserved blocks Dave Chinner
2016-03-10 14:16 ` Christoph Hellwig
2016-03-10 14:22 ` Christoph Hellwig
2016-03-10 22:09 ` Dave Chinner
2016-03-11 7:32 ` Christoph Hellwig
2016-03-08 4:16 ` [PATCH 04/16] libxfs: rearrange xfs_bmap_add_free parameters Dave Chinner
2016-03-08 17:18 ` Christoph Hellwig
2016-03-08 4:16 ` [PATCH 05/16] xfs: add owner field to extent allocation and freeing Dave Chinner
2016-03-10 14:19 ` Christoph Hellwig
2016-03-28 22:05 ` Darrick J. Wong
2016-03-08 4:16 ` [PATCH 06/16] xfs: introduce rmap extent operation stubs Dave Chinner
2016-03-08 4:16 ` [PATCH 07/16] xfs: define the on-disk rmap btree format Dave Chinner
2016-03-08 4:16 ` [PATCH 08/16] xfs: add rmap btree growfs support Dave Chinner
2016-03-08 4:16 ` [PATCH 09/16] xfs: rmap btree transaction reservations Dave Chinner
2016-03-08 4:16 ` [PATCH 10/16] xfs: rmap btree requires more reserved free space Dave Chinner
2016-03-08 4:16 ` [PATCH 11/16] xfs: add rmap btree operations Dave Chinner
2016-03-08 4:16 ` [PATCH 12/16] xfs: add tracepoints for the rmap-mirrors-bmbt functions Dave Chinner
2016-03-08 4:16 ` [PATCH 13/16] xfs: add an extent to the rmap btree Dave Chinner
2016-03-08 4:16 ` [PATCH 14/16] xfs: remove an extent from " Dave Chinner
2016-03-08 4:16 ` Dave Chinner [this message]
2016-03-08 4:16 ` [PATCH 16/16] xfs: piggyback rmapbt update intents in the bmap free structure Dave Chinner
2016-04-11 23:23 ` Darrick J. Wong
2016-03-10 14:14 ` [PATCH 0/16] xfs: first part of rmapbt functionality Christoph Hellwig
2016-03-10 16:57 ` Darrick J. Wong
2016-03-10 21:44 ` Dave Chinner
2016-03-25 23:00 ` Darrick J. Wong
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=1457410578-30233-16-git-send-email-david@fromorbit.com \
--to=david@fromorbit.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