aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2017-06-16 14:00:08 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2017-06-19 17:11:34 -0400
commite936945ee49693f40217db82a7db55c94e34ce4c (patch)
treed6c75fe16688ae714e40368a74b4e9c859f3d737
parent118bb47e281cde728608633f1a358fb9f2ac0adc (diff)
xfs: export _inobt_btrec_to_irec and _ialloc_cluster_alignment for scrub
Create a function to extract an in-core inobt record from a generic btree_rec union so that scrub will be able to check inobt records and check inode block alignment. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com>
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.c44
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.h5
2 files changed, 32 insertions, 17 deletions
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 1e5ed940b84d..c514fe98bbab 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -46,7 +46,7 @@
46/* 46/*
47 * Allocation group level functions. 47 * Allocation group level functions.
48 */ 48 */
49static inline int 49int
50xfs_ialloc_cluster_alignment( 50xfs_ialloc_cluster_alignment(
51 struct xfs_mount *mp) 51 struct xfs_mount *mp)
52{ 52{
@@ -98,24 +98,15 @@ xfs_inobt_update(
98 return xfs_btree_update(cur, &rec); 98 return xfs_btree_update(cur, &rec);
99} 99}
100 100
101/* 101/* Convert on-disk btree record to incore inobt record. */
102 * Get the data from the pointed-to record. 102void
103 */ 103xfs_inobt_btrec_to_irec(
104int /* error */ 104 struct xfs_mount *mp,
105xfs_inobt_get_rec( 105 union xfs_btree_rec *rec,
106 struct xfs_btree_cur *cur, /* btree cursor */ 106 struct xfs_inobt_rec_incore *irec)
107 xfs_inobt_rec_incore_t *irec, /* btree record */
108 int *stat) /* output: success/failure */
109{ 107{
110 union xfs_btree_rec *rec;
111 int error;
112
113 error = xfs_btree_get_rec(cur, &rec, stat);
114 if (error || *stat == 0)
115 return error;
116
117 irec->ir_startino = be32_to_cpu(rec->inobt.ir_startino); 108 irec->ir_startino = be32_to_cpu(rec->inobt.ir_startino);
118 if (xfs_sb_version_hassparseinodes(&cur->bc_mp->m_sb)) { 109 if (xfs_sb_version_hassparseinodes(&mp->m_sb)) {
119 irec->ir_holemask = be16_to_cpu(rec->inobt.ir_u.sp.ir_holemask); 110 irec->ir_holemask = be16_to_cpu(rec->inobt.ir_u.sp.ir_holemask);
120 irec->ir_count = rec->inobt.ir_u.sp.ir_count; 111 irec->ir_count = rec->inobt.ir_u.sp.ir_count;
121 irec->ir_freecount = rec->inobt.ir_u.sp.ir_freecount; 112 irec->ir_freecount = rec->inobt.ir_u.sp.ir_freecount;
@@ -130,6 +121,25 @@ xfs_inobt_get_rec(
130 be32_to_cpu(rec->inobt.ir_u.f.ir_freecount); 121 be32_to_cpu(rec->inobt.ir_u.f.ir_freecount);
131 } 122 }
132 irec->ir_free = be64_to_cpu(rec->inobt.ir_free); 123 irec->ir_free = be64_to_cpu(rec->inobt.ir_free);
124}
125
126/*
127 * Get the data from the pointed-to record.
128 */
129int
130xfs_inobt_get_rec(
131 struct xfs_btree_cur *cur,
132 struct xfs_inobt_rec_incore *irec,
133 int *stat)
134{
135 union xfs_btree_rec *rec;
136 int error;
137
138 error = xfs_btree_get_rec(cur, &rec, stat);
139 if (error || *stat == 0)
140 return error;
141
142 xfs_inobt_btrec_to_irec(cur->bc_mp, rec, irec);
133 143
134 return 0; 144 return 0;
135} 145}
diff --git a/fs/xfs/libxfs/xfs_ialloc.h b/fs/xfs/libxfs/xfs_ialloc.h
index 0bb89669fc07..b32cfb5aeb5b 100644
--- a/fs/xfs/libxfs/xfs_ialloc.h
+++ b/fs/xfs/libxfs/xfs_ialloc.h
@@ -168,5 +168,10 @@ int xfs_ialloc_inode_init(struct xfs_mount *mp, struct xfs_trans *tp,
168int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp, 168int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp,
169 xfs_agnumber_t agno, struct xfs_buf **bpp); 169 xfs_agnumber_t agno, struct xfs_buf **bpp);
170 170
171union xfs_btree_rec;
172void xfs_inobt_btrec_to_irec(struct xfs_mount *mp, union xfs_btree_rec *rec,
173 struct xfs_inobt_rec_incore *irec);
174
175int xfs_ialloc_cluster_alignment(struct xfs_mount *mp);
171 176
172#endif /* __XFS_IALLOC_H__ */ 177#endif /* __XFS_IALLOC_H__ */