aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2016-08-02 22:03:58 -0400
committerDave Chinner <david@fromorbit.com>2016-08-02 22:03:58 -0400
commitabf09233817b5ea1241db0c187136d3b4738d218 (patch)
treeadd4550028cc917c301fe3239789edcc472cd73b /fs
parentfb7d9267692a5cdc01648bf4c8fdca51054bc0f2 (diff)
xfs: add rmap btree insert and delete helpers
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> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/libxfs/xfs_rmap.c47
-rw-r--r--fs/xfs/libxfs/xfs_rmap.h3
2 files changed, 49 insertions, 1 deletions
diff --git a/fs/xfs/libxfs/xfs_rmap.c b/fs/xfs/libxfs/xfs_rmap.c
index 743927238bdc..e8ce97fd0608 100644
--- a/fs/xfs/libxfs/xfs_rmap.c
+++ b/fs/xfs/libxfs/xfs_rmap.c
@@ -92,13 +92,58 @@ xfs_rmap_update(
92 struct xfs_rmap_irec *irec) 92 struct xfs_rmap_irec *irec)
93{ 93{
94 union xfs_btree_rec rec; 94 union xfs_btree_rec rec;
95 int error;
96
97 trace_xfs_rmap_update(cur->bc_mp, cur->bc_private.a.agno,
98 irec->rm_startblock, irec->rm_blockcount,
99 irec->rm_owner, irec->rm_offset, irec->rm_flags);
95 100
96 rec.rmap.rm_startblock = cpu_to_be32(irec->rm_startblock); 101 rec.rmap.rm_startblock = cpu_to_be32(irec->rm_startblock);
97 rec.rmap.rm_blockcount = cpu_to_be32(irec->rm_blockcount); 102 rec.rmap.rm_blockcount = cpu_to_be32(irec->rm_blockcount);
98 rec.rmap.rm_owner = cpu_to_be64(irec->rm_owner); 103 rec.rmap.rm_owner = cpu_to_be64(irec->rm_owner);
99 rec.rmap.rm_offset = cpu_to_be64( 104 rec.rmap.rm_offset = cpu_to_be64(
100 xfs_rmap_irec_offset_pack(irec)); 105 xfs_rmap_irec_offset_pack(irec));
101 return xfs_btree_update(cur, &rec); 106 error = xfs_btree_update(cur, &rec);
107 if (error)
108 trace_xfs_rmap_update_error(cur->bc_mp,
109 cur->bc_private.a.agno, error, _RET_IP_);
110 return error;
111}
112
113int
114xfs_rmap_insert(
115 struct xfs_btree_cur *rcur,
116 xfs_agblock_t agbno,
117 xfs_extlen_t len,
118 uint64_t owner,
119 uint64_t offset,
120 unsigned int flags)
121{
122 int i;
123 int error;
124
125 trace_xfs_rmap_insert(rcur->bc_mp, rcur->bc_private.a.agno, agbno,
126 len, owner, offset, flags);
127
128 error = xfs_rmap_lookup_eq(rcur, agbno, len, owner, offset, flags, &i);
129 if (error)
130 goto done;
131 XFS_WANT_CORRUPTED_GOTO(rcur->bc_mp, i == 0, done);
132
133 rcur->bc_rec.r.rm_startblock = agbno;
134 rcur->bc_rec.r.rm_blockcount = len;
135 rcur->bc_rec.r.rm_owner = owner;
136 rcur->bc_rec.r.rm_offset = offset;
137 rcur->bc_rec.r.rm_flags = flags;
138 error = xfs_btree_insert(rcur, &i);
139 if (error)
140 goto done;
141 XFS_WANT_CORRUPTED_GOTO(rcur->bc_mp, i == 1, done);
142done:
143 if (error)
144 trace_xfs_rmap_insert_error(rcur->bc_mp,
145 rcur->bc_private.a.agno, error, _RET_IP_);
146 return error;
102} 147}
103 148
104static int 149static int
diff --git a/fs/xfs/libxfs/xfs_rmap.h b/fs/xfs/libxfs/xfs_rmap.h
index 34c811a2dacc..92ac067da7dd 100644
--- a/fs/xfs/libxfs/xfs_rmap.h
+++ b/fs/xfs/libxfs/xfs_rmap.h
@@ -148,6 +148,9 @@ int xfs_rmap_lookup_le(struct xfs_btree_cur *cur, xfs_agblock_t bno,
148int xfs_rmap_lookup_eq(struct xfs_btree_cur *cur, xfs_agblock_t bno, 148int xfs_rmap_lookup_eq(struct xfs_btree_cur *cur, xfs_agblock_t bno,
149 xfs_extlen_t len, uint64_t owner, uint64_t offset, 149 xfs_extlen_t len, uint64_t owner, uint64_t offset,
150 unsigned int flags, int *stat); 150 unsigned int flags, int *stat);
151int xfs_rmap_insert(struct xfs_btree_cur *rcur, xfs_agblock_t agbno,
152 xfs_extlen_t len, uint64_t owner, uint64_t offset,
153 unsigned int flags);
151int xfs_rmap_get_rec(struct xfs_btree_cur *cur, struct xfs_rmap_irec *irec, 154int xfs_rmap_get_rec(struct xfs_btree_cur *cur, struct xfs_rmap_irec *irec,
152 int *stat); 155 int *stat);
153 156