aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_fsops.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_fsops.c')
-rw-r--r--fs/xfs/xfs_fsops.c94
1 files changed, 44 insertions, 50 deletions
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 239e701e9822..0ca597b0ca79 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -191,28 +191,26 @@ xfs_growfs_data_private(
191 XFS_FSS_TO_BB(mp, 1), 0); 191 XFS_FSS_TO_BB(mp, 1), 0);
192 agf = XFS_BUF_TO_AGF(bp); 192 agf = XFS_BUF_TO_AGF(bp);
193 memset(agf, 0, mp->m_sb.sb_sectsize); 193 memset(agf, 0, mp->m_sb.sb_sectsize);
194 INT_SET(agf->agf_magicnum, ARCH_CONVERT, XFS_AGF_MAGIC); 194 agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC);
195 INT_SET(agf->agf_versionnum, ARCH_CONVERT, XFS_AGF_VERSION); 195 agf->agf_versionnum = cpu_to_be32(XFS_AGF_VERSION);
196 INT_SET(agf->agf_seqno, ARCH_CONVERT, agno); 196 agf->agf_seqno = cpu_to_be32(agno);
197 if (agno == nagcount - 1) 197 if (agno == nagcount - 1)
198 agsize = 198 agsize =
199 nb - 199 nb -
200 (agno * (xfs_rfsblock_t)mp->m_sb.sb_agblocks); 200 (agno * (xfs_rfsblock_t)mp->m_sb.sb_agblocks);
201 else 201 else
202 agsize = mp->m_sb.sb_agblocks; 202 agsize = mp->m_sb.sb_agblocks;
203 INT_SET(agf->agf_length, ARCH_CONVERT, agsize); 203 agf->agf_length = cpu_to_be32(agsize);
204 INT_SET(agf->agf_roots[XFS_BTNUM_BNOi], ARCH_CONVERT, 204 agf->agf_roots[XFS_BTNUM_BNOi] = cpu_to_be32(XFS_BNO_BLOCK(mp));
205 XFS_BNO_BLOCK(mp)); 205 agf->agf_roots[XFS_BTNUM_CNTi] = cpu_to_be32(XFS_CNT_BLOCK(mp));
206 INT_SET(agf->agf_roots[XFS_BTNUM_CNTi], ARCH_CONVERT, 206 agf->agf_levels[XFS_BTNUM_BNOi] = cpu_to_be32(1);
207 XFS_CNT_BLOCK(mp)); 207 agf->agf_levels[XFS_BTNUM_CNTi] = cpu_to_be32(1);
208 INT_SET(agf->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT, 1);
209 INT_SET(agf->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT, 1);
210 agf->agf_flfirst = 0; 208 agf->agf_flfirst = 0;
211 INT_SET(agf->agf_fllast, ARCH_CONVERT, XFS_AGFL_SIZE(mp) - 1); 209 agf->agf_fllast = cpu_to_be32(XFS_AGFL_SIZE(mp) - 1);
212 agf->agf_flcount = 0; 210 agf->agf_flcount = 0;
213 tmpsize = agsize - XFS_PREALLOC_BLOCKS(mp); 211 tmpsize = agsize - XFS_PREALLOC_BLOCKS(mp);
214 INT_SET(agf->agf_freeblks, ARCH_CONVERT, tmpsize); 212 agf->agf_freeblks = cpu_to_be32(tmpsize);
215 INT_SET(agf->agf_longest, ARCH_CONVERT, tmpsize); 213 agf->agf_longest = cpu_to_be32(tmpsize);
216 error = xfs_bwrite(mp, bp); 214 error = xfs_bwrite(mp, bp);
217 if (error) { 215 if (error) {
218 goto error0; 216 goto error0;
@@ -225,19 +223,18 @@ xfs_growfs_data_private(
225 XFS_FSS_TO_BB(mp, 1), 0); 223 XFS_FSS_TO_BB(mp, 1), 0);
226 agi = XFS_BUF_TO_AGI(bp); 224 agi = XFS_BUF_TO_AGI(bp);
227 memset(agi, 0, mp->m_sb.sb_sectsize); 225 memset(agi, 0, mp->m_sb.sb_sectsize);
228 INT_SET(agi->agi_magicnum, ARCH_CONVERT, XFS_AGI_MAGIC); 226 agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC);
229 INT_SET(agi->agi_versionnum, ARCH_CONVERT, XFS_AGI_VERSION); 227 agi->agi_versionnum = cpu_to_be32(XFS_AGI_VERSION);
230 INT_SET(agi->agi_seqno, ARCH_CONVERT, agno); 228 agi->agi_seqno = cpu_to_be32(agno);
231 INT_SET(agi->agi_length, ARCH_CONVERT, agsize); 229 agi->agi_length = cpu_to_be32(agsize);
232 agi->agi_count = 0; 230 agi->agi_count = 0;
233 INT_SET(agi->agi_root, ARCH_CONVERT, XFS_IBT_BLOCK(mp)); 231 agi->agi_root = cpu_to_be32(XFS_IBT_BLOCK(mp));
234 INT_SET(agi->agi_level, ARCH_CONVERT, 1); 232 agi->agi_level = cpu_to_be32(1);
235 agi->agi_freecount = 0; 233 agi->agi_freecount = 0;
236 INT_SET(agi->agi_newino, ARCH_CONVERT, NULLAGINO); 234 agi->agi_newino = cpu_to_be32(NULLAGINO);
237 INT_SET(agi->agi_dirino, ARCH_CONVERT, NULLAGINO); 235 agi->agi_dirino = cpu_to_be32(NULLAGINO);
238 for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) 236 for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++)
239 INT_SET(agi->agi_unlinked[bucket], ARCH_CONVERT, 237 agi->agi_unlinked[bucket] = cpu_to_be32(NULLAGINO);
240 NULLAGINO);
241 error = xfs_bwrite(mp, bp); 238 error = xfs_bwrite(mp, bp);
242 if (error) { 239 if (error) {
243 goto error0; 240 goto error0;
@@ -250,17 +247,16 @@ xfs_growfs_data_private(
250 BTOBB(mp->m_sb.sb_blocksize), 0); 247 BTOBB(mp->m_sb.sb_blocksize), 0);
251 block = XFS_BUF_TO_SBLOCK(bp); 248 block = XFS_BUF_TO_SBLOCK(bp);
252 memset(block, 0, mp->m_sb.sb_blocksize); 249 memset(block, 0, mp->m_sb.sb_blocksize);
253 INT_SET(block->bb_magic, ARCH_CONVERT, XFS_ABTB_MAGIC); 250 block->bb_magic = cpu_to_be32(XFS_ABTB_MAGIC);
254 block->bb_level = 0; 251 block->bb_level = 0;
255 INT_SET(block->bb_numrecs, ARCH_CONVERT, 1); 252 block->bb_numrecs = cpu_to_be16(1);
256 INT_SET(block->bb_leftsib, ARCH_CONVERT, NULLAGBLOCK); 253 block->bb_leftsib = cpu_to_be32(NULLAGBLOCK);
257 INT_SET(block->bb_rightsib, ARCH_CONVERT, NULLAGBLOCK); 254 block->bb_rightsib = cpu_to_be32(NULLAGBLOCK);
258 arec = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_alloc, 255 arec = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_alloc,
259 block, 1, mp->m_alloc_mxr[0]); 256 block, 1, mp->m_alloc_mxr[0]);
260 INT_SET(arec->ar_startblock, ARCH_CONVERT, 257 arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp));
261 XFS_PREALLOC_BLOCKS(mp)); 258 arec->ar_blockcount = cpu_to_be32(
262 INT_SET(arec->ar_blockcount, ARCH_CONVERT, 259 agsize - be32_to_cpu(arec->ar_startblock));
263 agsize - INT_GET(arec->ar_startblock, ARCH_CONVERT));
264 error = xfs_bwrite(mp, bp); 260 error = xfs_bwrite(mp, bp);
265 if (error) { 261 if (error) {
266 goto error0; 262 goto error0;
@@ -273,18 +269,17 @@ xfs_growfs_data_private(
273 BTOBB(mp->m_sb.sb_blocksize), 0); 269 BTOBB(mp->m_sb.sb_blocksize), 0);
274 block = XFS_BUF_TO_SBLOCK(bp); 270 block = XFS_BUF_TO_SBLOCK(bp);
275 memset(block, 0, mp->m_sb.sb_blocksize); 271 memset(block, 0, mp->m_sb.sb_blocksize);
276 INT_SET(block->bb_magic, ARCH_CONVERT, XFS_ABTC_MAGIC); 272 block->bb_magic = cpu_to_be32(XFS_ABTC_MAGIC);
277 block->bb_level = 0; 273 block->bb_level = 0;
278 INT_SET(block->bb_numrecs, ARCH_CONVERT, 1); 274 block->bb_numrecs = cpu_to_be16(1);
279 INT_SET(block->bb_leftsib, ARCH_CONVERT, NULLAGBLOCK); 275 block->bb_leftsib = cpu_to_be32(NULLAGBLOCK);
280 INT_SET(block->bb_rightsib, ARCH_CONVERT, NULLAGBLOCK); 276 block->bb_rightsib = cpu_to_be32(NULLAGBLOCK);
281 arec = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_alloc, 277 arec = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_alloc,
282 block, 1, mp->m_alloc_mxr[0]); 278 block, 1, mp->m_alloc_mxr[0]);
283 INT_SET(arec->ar_startblock, ARCH_CONVERT, 279 arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp));
284 XFS_PREALLOC_BLOCKS(mp)); 280 arec->ar_blockcount = cpu_to_be32(
285 INT_SET(arec->ar_blockcount, ARCH_CONVERT, 281 agsize - be32_to_cpu(arec->ar_startblock));
286 agsize - INT_GET(arec->ar_startblock, ARCH_CONVERT)); 282 nfree += be32_to_cpu(arec->ar_blockcount);
287 nfree += INT_GET(arec->ar_blockcount, ARCH_CONVERT);
288 error = xfs_bwrite(mp, bp); 283 error = xfs_bwrite(mp, bp);
289 if (error) { 284 if (error) {
290 goto error0; 285 goto error0;
@@ -297,11 +292,11 @@ xfs_growfs_data_private(
297 BTOBB(mp->m_sb.sb_blocksize), 0); 292 BTOBB(mp->m_sb.sb_blocksize), 0);
298 block = XFS_BUF_TO_SBLOCK(bp); 293 block = XFS_BUF_TO_SBLOCK(bp);
299 memset(block, 0, mp->m_sb.sb_blocksize); 294 memset(block, 0, mp->m_sb.sb_blocksize);
300 INT_SET(block->bb_magic, ARCH_CONVERT, XFS_IBT_MAGIC); 295 block->bb_magic = cpu_to_be32(XFS_IBT_MAGIC);
301 block->bb_level = 0; 296 block->bb_level = 0;
302 block->bb_numrecs = 0; 297 block->bb_numrecs = 0;
303 INT_SET(block->bb_leftsib, ARCH_CONVERT, NULLAGBLOCK); 298 block->bb_leftsib = cpu_to_be32(NULLAGBLOCK);
304 INT_SET(block->bb_rightsib, ARCH_CONVERT, NULLAGBLOCK); 299 block->bb_rightsib = cpu_to_be32(NULLAGBLOCK);
305 error = xfs_bwrite(mp, bp); 300 error = xfs_bwrite(mp, bp);
306 if (error) { 301 if (error) {
307 goto error0; 302 goto error0;
@@ -321,10 +316,9 @@ xfs_growfs_data_private(
321 } 316 }
322 ASSERT(bp); 317 ASSERT(bp);
323 agi = XFS_BUF_TO_AGI(bp); 318 agi = XFS_BUF_TO_AGI(bp);
324 INT_MOD(agi->agi_length, ARCH_CONVERT, new); 319 be32_add(&agi->agi_length, new);
325 ASSERT(nagcount == oagcount || 320 ASSERT(nagcount == oagcount ||
326 INT_GET(agi->agi_length, ARCH_CONVERT) == 321 be32_to_cpu(agi->agi_length) == mp->m_sb.sb_agblocks);
327 mp->m_sb.sb_agblocks);
328 xfs_ialloc_log_agi(tp, bp, XFS_AGI_LENGTH); 322 xfs_ialloc_log_agi(tp, bp, XFS_AGI_LENGTH);
329 /* 323 /*
330 * Change agf length. 324 * Change agf length.
@@ -335,14 +329,14 @@ xfs_growfs_data_private(
335 } 329 }
336 ASSERT(bp); 330 ASSERT(bp);
337 agf = XFS_BUF_TO_AGF(bp); 331 agf = XFS_BUF_TO_AGF(bp);
338 INT_MOD(agf->agf_length, ARCH_CONVERT, new); 332 be32_add(&agf->agf_length, new);
339 ASSERT(INT_GET(agf->agf_length, ARCH_CONVERT) == 333 ASSERT(be32_to_cpu(agf->agf_length) ==
340 INT_GET(agi->agi_length, ARCH_CONVERT)); 334 be32_to_cpu(agi->agi_length));
341 /* 335 /*
342 * Free the new space. 336 * Free the new space.
343 */ 337 */
344 error = xfs_free_extent(tp, XFS_AGB_TO_FSB(mp, agno, 338 error = xfs_free_extent(tp, XFS_AGB_TO_FSB(mp, agno,
345 INT_GET(agf->agf_length, ARCH_CONVERT) - new), new); 339 be32_to_cpu(agf->agf_length) - new), new);
346 if (error) { 340 if (error) {
347 goto error0; 341 goto error0;
348 } 342 }