aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2008-10-30 01:58:11 -0400
committerLachlan McIlroy <lachlan@sgi.com>2008-10-30 01:58:11 -0400
commit8cc938fe4237e50bea4aa557ed53b06de2319d49 (patch)
tree1b9dd352d423a573d96d5b1b311286a39232ef5b /fs
parent91cca5df9bc85efdabfa645f51d54259ed09f4bf (diff)
[XFS] implement generic xfs_btree_get_rec
Not really much reason to make it generic given that it's so small, but this is the last non-method in xfs_alloc_btree.c and xfs_ialloc_btree.c, so it makes the whole btree implementation more structured. SGI-PV: 985583 SGI-Modid: xfs-linux-melb:xfs-kern:32206a Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com> Signed-off-by: Bill O'Donnell <billodo@sgi.com> Signed-off-by: David Chinner <david@fromorbit.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_alloc.c21
-rw-r--r--fs/xfs/xfs_alloc_btree.c44
-rw-r--r--fs/xfs/xfs_alloc_btree.h6
-rw-r--r--fs/xfs/xfs_btree.c41
-rw-r--r--fs/xfs/xfs_btree.h1
-rw-r--r--fs/xfs/xfs_ialloc.c23
-rw-r--r--fs/xfs/xfs_ialloc.h5
-rw-r--r--fs/xfs/xfs_ialloc_btree.c44
-rw-r--r--fs/xfs/xfs_ialloc_btree.h7
9 files changed, 91 insertions, 101 deletions
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c
index e9c70249d2c5..54fa69e27761 100644
--- a/fs/xfs/xfs_alloc.c
+++ b/fs/xfs/xfs_alloc.c
@@ -155,6 +155,27 @@ xfs_alloc_update(
155} 155}
156 156
157/* 157/*
158 * Get the data from the pointed-to record.
159 */
160STATIC int /* error */
161xfs_alloc_get_rec(
162 struct xfs_btree_cur *cur, /* btree cursor */
163 xfs_agblock_t *bno, /* output: starting block of extent */
164 xfs_extlen_t *len, /* output: length of extent */
165 int *stat) /* output: success/failure */
166{
167 union xfs_btree_rec *rec;
168 int error;
169
170 error = xfs_btree_get_rec(cur, &rec, stat);
171 if (!error && *stat == 1) {
172 *bno = be32_to_cpu(rec->alloc.ar_startblock);
173 *len = be32_to_cpu(rec->alloc.ar_blockcount);
174 }
175 return error;
176}
177
178/*
158 * Compute aligned version of the found extent. 179 * Compute aligned version of the found extent.
159 * Takes alignment and min length into account. 180 * Takes alignment and min length into account.
160 */ 181 */
diff --git a/fs/xfs/xfs_alloc_btree.c b/fs/xfs/xfs_alloc_btree.c
index d256b51f913d..4d44f03858b0 100644
--- a/fs/xfs/xfs_alloc_btree.c
+++ b/fs/xfs/xfs_alloc_btree.c
@@ -41,50 +41,6 @@
41#include "xfs_error.h" 41#include "xfs_error.h"
42 42
43 43
44/*
45 * Get the data from the pointed-to record.
46 */
47int /* error */
48xfs_alloc_get_rec(
49 xfs_btree_cur_t *cur, /* btree cursor */
50 xfs_agblock_t *bno, /* output: starting block of extent */
51 xfs_extlen_t *len, /* output: length of extent */
52 int *stat) /* output: success/failure */
53{
54 xfs_alloc_block_t *block; /* btree block */
55#ifdef DEBUG
56 int error; /* error return value */
57#endif
58 int ptr; /* record number */
59
60 ptr = cur->bc_ptrs[0];
61 block = XFS_BUF_TO_ALLOC_BLOCK(cur->bc_bufs[0]);
62#ifdef DEBUG
63 if ((error = xfs_btree_check_sblock(cur, block, 0, cur->bc_bufs[0])))
64 return error;
65#endif
66 /*
67 * Off the right end or left end, return failure.
68 */
69 if (ptr > be16_to_cpu(block->bb_numrecs) || ptr <= 0) {
70 *stat = 0;
71 return 0;
72 }
73 /*
74 * Point to the record and extract its data.
75 */
76 {
77 xfs_alloc_rec_t *rec; /* record data */
78
79 rec = XFS_ALLOC_REC_ADDR(block, ptr, cur);
80 *bno = be32_to_cpu(rec->ar_startblock);
81 *len = be32_to_cpu(rec->ar_blockcount);
82 }
83 *stat = 1;
84 return 0;
85}
86
87
88STATIC struct xfs_btree_cur * 44STATIC struct xfs_btree_cur *
89xfs_allocbt_dup_cursor( 45xfs_allocbt_dup_cursor(
90 struct xfs_btree_cur *cur) 46 struct xfs_btree_cur *cur)
diff --git a/fs/xfs/xfs_alloc_btree.h b/fs/xfs/xfs_alloc_btree.h
index 8d2e3ec21fd0..22f1d709af7b 100644
--- a/fs/xfs/xfs_alloc_btree.h
+++ b/fs/xfs/xfs_alloc_btree.h
@@ -94,12 +94,6 @@ typedef struct xfs_btree_sblock xfs_alloc_block_t;
94#define XFS_ALLOC_PTR_ADDR(bb,i,cur) \ 94#define XFS_ALLOC_PTR_ADDR(bb,i,cur) \
95 XFS_BTREE_PTR_ADDR(xfs_alloc, bb, i, XFS_ALLOC_BLOCK_MAXRECS(1, cur)) 95 XFS_BTREE_PTR_ADDR(xfs_alloc, bb, i, XFS_ALLOC_BLOCK_MAXRECS(1, cur))
96 96
97/*
98 * Get the data from the pointed-to record.
99 */
100extern int xfs_alloc_get_rec(struct xfs_btree_cur *cur, xfs_agblock_t *bno,
101 xfs_extlen_t *len, int *stat);
102
103 97
104extern struct xfs_btree_cur *xfs_allocbt_init_cursor(struct xfs_mount *, 98extern struct xfs_btree_cur *xfs_allocbt_init_cursor(struct xfs_mount *,
105 struct xfs_trans *, struct xfs_buf *, 99 struct xfs_trans *, struct xfs_buf *,
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c
index 28cc76818343..8503ed5d10a0 100644
--- a/fs/xfs/xfs_btree.c
+++ b/fs/xfs/xfs_btree.c
@@ -3764,3 +3764,44 @@ error0:
3764 XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR); 3764 XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
3765 return error; 3765 return error;
3766} 3766}
3767
3768/*
3769 * Get the data from the pointed-to record.
3770 */
3771int /* error */
3772xfs_btree_get_rec(
3773 struct xfs_btree_cur *cur, /* btree cursor */
3774 union xfs_btree_rec **recp, /* output: btree record */
3775 int *stat) /* output: success/failure */
3776{
3777 struct xfs_btree_block *block; /* btree block */
3778 struct xfs_buf *bp; /* buffer pointer */
3779 int ptr; /* record number */
3780#ifdef DEBUG
3781 int error; /* error return value */
3782#endif
3783
3784 ptr = cur->bc_ptrs[0];
3785 block = xfs_btree_get_block(cur, 0, &bp);
3786
3787#ifdef DEBUG
3788 error = xfs_btree_check_block(cur, block, 0, bp);
3789 if (error)
3790 return error;
3791#endif
3792
3793 /*
3794 * Off the right end or left end, return failure.
3795 */
3796 if (ptr > xfs_btree_get_numrecs(block) || ptr <= 0) {
3797 *stat = 0;
3798 return 0;
3799 }
3800
3801 /*
3802 * Point to the record and extract its data.
3803 */
3804 *recp = xfs_btree_rec_addr(cur, ptr, block);
3805 *stat = 1;
3806 return 0;
3807}
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h
index 06ef792e0aac..cee3684d871e 100644
--- a/fs/xfs/xfs_btree.h
+++ b/fs/xfs/xfs_btree.h
@@ -567,6 +567,7 @@ int xfs_btree_new_iroot(struct xfs_btree_cur *, int *, int *);
567int xfs_btree_kill_iroot(struct xfs_btree_cur *); 567int xfs_btree_kill_iroot(struct xfs_btree_cur *);
568int xfs_btree_insert(struct xfs_btree_cur *, int *); 568int xfs_btree_insert(struct xfs_btree_cur *, int *);
569int xfs_btree_delete(struct xfs_btree_cur *, int *); 569int xfs_btree_delete(struct xfs_btree_cur *, int *);
570int xfs_btree_get_rec(struct xfs_btree_cur *, union xfs_btree_rec **, int *);
570 571
571/* 572/*
572 * Helpers. 573 * Helpers.
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index f13f59b13cc8..c8a56c529642 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -192,6 +192,29 @@ xfs_inobt_update(
192} 192}
193 193
194/* 194/*
195 * Get the data from the pointed-to record.
196 */
197int /* error */
198xfs_inobt_get_rec(
199 struct xfs_btree_cur *cur, /* btree cursor */
200 xfs_agino_t *ino, /* output: starting inode of chunk */
201 __int32_t *fcnt, /* output: number of free inodes */
202 xfs_inofree_t *free, /* output: free inode mask */
203 int *stat) /* output: success/failure */
204{
205 union xfs_btree_rec *rec;
206 int error;
207
208 error = xfs_btree_get_rec(cur, &rec, stat);
209 if (!error && *stat == 1) {
210 *ino = be32_to_cpu(rec->inobt.ir_startino);
211 *fcnt = be32_to_cpu(rec->inobt.ir_freecount);
212 *free = be64_to_cpu(rec->inobt.ir_free);
213 }
214 return error;
215}
216
217/*
195 * Allocate new inodes in the allocation group specified by agbp. 218 * Allocate new inodes in the allocation group specified by agbp.
196 * Return 0 for success, else error code. 219 * Return 0 for success, else error code.
197 */ 220 */
diff --git a/fs/xfs/xfs_ialloc.h b/fs/xfs/xfs_ialloc.h
index 4026578bc264..c5745f6d94ec 100644
--- a/fs/xfs/xfs_ialloc.h
+++ b/fs/xfs/xfs_ialloc.h
@@ -168,6 +168,11 @@ int xfs_inobt_lookup_ge(struct xfs_btree_cur *cur, xfs_agino_t ino,
168int xfs_inobt_lookup_le(struct xfs_btree_cur *cur, xfs_agino_t ino, 168int xfs_inobt_lookup_le(struct xfs_btree_cur *cur, xfs_agino_t ino,
169 __int32_t fcnt, xfs_inofree_t free, int *stat); 169 __int32_t fcnt, xfs_inofree_t free, int *stat);
170 170
171/*
172 * Get the data from the pointed-to record.
173 */
174extern int xfs_inobt_get_rec(struct xfs_btree_cur *cur, xfs_agino_t *ino,
175 __int32_t *fcnt, xfs_inofree_t *free, int *stat);
171 176
172#endif /* __KERNEL__ */ 177#endif /* __KERNEL__ */
173 178
diff --git a/fs/xfs/xfs_ialloc_btree.c b/fs/xfs/xfs_ialloc_btree.c
index 6c0a07d1fed3..9f4e33c945c2 100644
--- a/fs/xfs/xfs_ialloc_btree.c
+++ b/fs/xfs/xfs_ialloc_btree.c
@@ -41,50 +41,6 @@
41#include "xfs_error.h" 41#include "xfs_error.h"
42 42
43 43
44/*
45 * Get the data from the pointed-to record.
46 */
47int /* error */
48xfs_inobt_get_rec(
49 xfs_btree_cur_t *cur, /* btree cursor */
50 xfs_agino_t *ino, /* output: starting inode of chunk */
51 __int32_t *fcnt, /* output: number of free inodes */
52 xfs_inofree_t *free, /* output: free inode mask */
53 int *stat) /* output: success/failure */
54{
55 xfs_inobt_block_t *block; /* btree block */
56 xfs_buf_t *bp; /* buffer containing btree block */
57#ifdef DEBUG
58 int error; /* error return value */
59#endif
60 int ptr; /* record number */
61 xfs_inobt_rec_t *rec; /* record data */
62
63 bp = cur->bc_bufs[0];
64 ptr = cur->bc_ptrs[0];
65 block = XFS_BUF_TO_INOBT_BLOCK(bp);
66#ifdef DEBUG
67 if ((error = xfs_btree_check_sblock(cur, block, 0, bp)))
68 return error;
69#endif
70 /*
71 * Off the right end or left end, return failure.
72 */
73 if (ptr > be16_to_cpu(block->bb_numrecs) || ptr <= 0) {
74 *stat = 0;
75 return 0;
76 }
77 /*
78 * Point to the record and extract its data.
79 */
80 rec = XFS_INOBT_REC_ADDR(block, ptr, cur);
81 *ino = be32_to_cpu(rec->ir_startino);
82 *fcnt = be32_to_cpu(rec->ir_freecount);
83 *free = be64_to_cpu(rec->ir_free);
84 *stat = 1;
85 return 0;
86}
87
88STATIC int 44STATIC int
89xfs_inobt_get_minrecs( 45xfs_inobt_get_minrecs(
90 struct xfs_btree_cur *cur, 46 struct xfs_btree_cur *cur,
diff --git a/fs/xfs/xfs_ialloc_btree.h b/fs/xfs/xfs_ialloc_btree.h
index 3eff3b6e5fa4..ff7406b4bac3 100644
--- a/fs/xfs/xfs_ialloc_btree.h
+++ b/fs/xfs/xfs_ialloc_btree.h
@@ -116,13 +116,6 @@ typedef struct xfs_btree_sblock xfs_inobt_block_t;
116 (XFS_BTREE_PTR_ADDR(xfs_inobt, bb, \ 116 (XFS_BTREE_PTR_ADDR(xfs_inobt, bb, \
117 i, XFS_INOBT_BLOCK_MAXRECS(1, cur))) 117 i, XFS_INOBT_BLOCK_MAXRECS(1, cur)))
118 118
119/*
120 * Get the data from the pointed-to record.
121 */
122extern int xfs_inobt_get_rec(struct xfs_btree_cur *cur, xfs_agino_t *ino,
123 __int32_t *fcnt, xfs_inofree_t *free, int *stat);
124
125
126extern struct xfs_btree_cur *xfs_inobt_init_cursor(struct xfs_mount *, 119extern struct xfs_btree_cur *xfs_inobt_init_cursor(struct xfs_mount *,
127 struct xfs_trans *, struct xfs_buf *, xfs_agnumber_t); 120 struct xfs_trans *, struct xfs_buf *, xfs_agnumber_t);
128 121