~ubuntu-branches/ubuntu/edgy/xfsprogs/edgy

« back to all changes in this revision

Viewing changes to libxfs/xfs_ialloc.c

  • Committer: Bazaar Package Importer
  • Author(s): Nathan Scott
  • Date: 2004-07-28 21:11:38 UTC
  • Revision ID: james.westby@ubuntu.com-20040728211138-0v4pdnunnp7na5lm
Tags: 2.6.20-1
* New upstream release.
* Fix xfs_io segfault on non-XFS files.  (closes: #260470)
* Fix packaging botch, deleted files included.  (closes: #260491)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
3
 
 * 
 
2
 * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
 
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify it
5
5
 * under the terms of version 2 of the GNU General Public License as
6
6
 * published by the Free Software Foundation.
7
 
 * 
 
7
 *
8
8
 * This program is distributed in the hope that it would be useful, but
9
9
 * WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 
 * 
 
11
 *
12
12
 * Further, this software is distributed without any warranty that it is
13
13
 * free of the rightful claim of any third person regarding infringement
14
14
 * or the like.  Any license provided herein, whether implied or
15
15
 * otherwise, applies only to this software file.  Patent licenses, if
16
16
 * any, provided herein do not apply to combinations of this program with
17
17
 * other software, or any other product whatsoever.
18
 
 * 
 
18
 *
19
19
 * You should have received a copy of the GNU General Public License along
20
20
 * with this program; if not, write the Free Software Foundation, Inc., 59
21
21
 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22
 
 * 
 
22
 *
23
23
 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24
24
 * Mountain View, CA  94043, or:
25
 
 * 
26
 
 * http://www.sgi.com 
27
 
 * 
28
 
 * For further information regarding this notice, see: 
29
 
 * 
 
25
 *
 
26
 * http://www.sgi.com
 
27
 *
 
28
 * For further information regarding this notice, see:
 
29
 *
30
30
 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31
31
 */
32
32
 
81
81
                offsetof(xfs_dinode_t, di_a),
82
82
                sizeof(xfs_dinode_t)
83
83
        };
84
 
        
 
84
 
85
85
 
86
86
        ASSERT(offsetof(xfs_dinode_t, di_core) == 0);
87
87
        ASSERT((fields & (XFS_DI_U|XFS_DI_A)) == 0);
129
129
        int             ninodes;        /* num inodes per buf */
130
130
        xfs_agino_t     thisino;        /* current inode number, for loop */
131
131
        int             version;        /* inode version number to use */
132
 
        static xfs_timestamp_t ztime;   /* zero xfs timestamp */
133
132
        int             isaligned;      /* inode allocation at stripe unit */
134
133
                                        /* boundary */
135
 
        xfs_dinode_core_t dic;          /* a dinode_core to copy to new */
136
 
                                        /* inodes */
137
 
        
 
134
        xfs_dinode_core_t dic;          /* a dinode_core to copy to new */
 
135
                                        /* inodes */
 
136
 
138
137
        args.tp = tp;
139
138
        args.mp = tp->t_mountp;
140
139
 
151
150
         * Set the alignment for the allocation.
152
151
         * If stripe alignment is turned on then align at stripe unit
153
152
         * boundary.
154
 
         * If the cluster size is smaller than a filesystem block 
 
153
         * If the cluster size is smaller than a filesystem block
155
154
         * then we're doing I/O for inodes in filesystem block size pieces,
156
155
         * so don't need alignment anyway.
157
156
         */
161
160
                args.alignment = args.mp->m_dalign;
162
161
                isaligned = 1;
163
162
        } else if (XFS_SB_VERSION_HASALIGN(&args.mp->m_sb) &&
164
 
            args.mp->m_sb.sb_inoalignmt >= 
 
163
            args.mp->m_sb.sb_inoalignmt >=
165
164
            XFS_B_TO_FSBT(args.mp, XFS_INODE_CLUSTER_SIZE(args.mp)))
166
165
                args.alignment = args.mp->m_sb.sb_inoalignmt;
167
166
        else
179
178
         * Allocate a fixed-size extent of inodes.
180
179
         */
181
180
        args.type = XFS_ALLOCTYPE_NEAR_BNO;
182
 
        args.mod = args.total = args.wasdel = args.isfl = args.userdata = 
 
181
        args.mod = args.total = args.wasdel = args.isfl = args.userdata =
183
182
                args.minalignslop = 0;
184
183
        args.prod = 1;
185
184
        /*
199
198
                args.fsbno = XFS_AGB_TO_FSB(args.mp,
200
199
                                INT_GET(agi->agi_seqno, ARCH_CONVERT), args.agbno);
201
200
                if (XFS_SB_VERSION_HASALIGN(&args.mp->m_sb) &&
202
 
                        args.mp->m_sb.sb_inoalignmt >= 
203
 
                        XFS_B_TO_FSBT(args.mp, XFS_INODE_CLUSTER_SIZE(args.mp)))
 
201
                        args.mp->m_sb.sb_inoalignmt >=
 
202
                        XFS_B_TO_FSBT(args.mp, XFS_INODE_CLUSTER_SIZE(args.mp)))
204
203
                                args.alignment = args.mp->m_sb.sb_inoalignmt;
205
204
                else
206
205
                        args.alignment = 1;
207
206
                if ((error = xfs_alloc_vextent(&args)))
208
 
                         return error;
 
207
                        return error;
209
208
        }
210
 
        
 
209
 
211
210
        if (args.fsbno == NULLFSBLOCK) {
212
211
                *alloc = 0;
213
212
                return 0;
228
227
                ninodes = args.mp->m_sb.sb_inopblock;
229
228
        } else {
230
229
                blks_per_cluster = XFS_INODE_CLUSTER_SIZE(args.mp) /
231
 
                                   args.mp->m_sb.sb_blocksize;
 
230
                                   args.mp->m_sb.sb_blocksize;
232
231
                nbufs = (int)args.len / blks_per_cluster;
233
232
                ninodes = blks_per_cluster * args.mp->m_sb.sb_inopblock;
234
233
        }
243
242
                version = XFS_DINODE_VERSION_2;
244
243
        else
245
244
                version = XFS_DINODE_VERSION_1;
 
245
 
 
246
        memset(&dic, 0, sizeof(xfs_dinode_core_t));
 
247
        INT_SET(dic.di_magic, ARCH_CONVERT, XFS_DINODE_MAGIC);
 
248
        INT_SET(dic.di_version, ARCH_CONVERT, version);
 
249
 
246
250
        for (j = 0; j < nbufs; j++) {
247
251
                /*
248
252
                 * Get the block.
253
257
                                         args.mp->m_bsize * blks_per_cluster,
254
258
                                         XFS_BUF_LOCK);
255
259
                ASSERT(fbuf);
256
 
                ASSERT(!XFS_BUF_GETERROR(fbuf));                
 
260
                ASSERT(!XFS_BUF_GETERROR(fbuf));
257
261
                /*
258
262
                 * Loop over the inodes in this buffer.
259
263
                 */
260
 
                INT_SET(dic.di_magic, ARCH_CONVERT, XFS_DINODE_MAGIC);
261
 
                INT_ZERO(dic.di_mode, ARCH_CONVERT);
262
 
                INT_SET(dic.di_version, ARCH_CONVERT, version);
263
 
                INT_ZERO(dic.di_format, ARCH_CONVERT);
264
 
                INT_ZERO(dic.di_onlink, ARCH_CONVERT);
265
 
                INT_ZERO(dic.di_uid, ARCH_CONVERT);
266
 
                INT_ZERO(dic.di_gid, ARCH_CONVERT);
267
 
                INT_ZERO(dic.di_nlink, ARCH_CONVERT);
268
 
                INT_ZERO(dic.di_projid, ARCH_CONVERT);
269
 
                bzero(&(dic.di_pad[0]),sizeof(dic.di_pad));
270
 
                INT_SET(dic.di_atime.t_sec, ARCH_CONVERT, ztime.t_sec);
271
 
                INT_SET(dic.di_atime.t_nsec, ARCH_CONVERT, ztime.t_nsec);
272
 
                
273
 
                INT_SET(dic.di_mtime.t_sec, ARCH_CONVERT, ztime.t_sec);
274
 
                INT_SET(dic.di_mtime.t_nsec, ARCH_CONVERT, ztime.t_nsec);
275
 
                
276
 
                INT_SET(dic.di_ctime.t_sec, ARCH_CONVERT, ztime.t_sec);
277
 
                INT_SET(dic.di_ctime.t_nsec, ARCH_CONVERT, ztime.t_nsec);
278
 
                
279
 
                INT_ZERO(dic.di_size, ARCH_CONVERT);
280
 
                INT_ZERO(dic.di_nblocks, ARCH_CONVERT);
281
 
                INT_ZERO(dic.di_extsize, ARCH_CONVERT);
282
 
                INT_ZERO(dic.di_nextents, ARCH_CONVERT);
283
 
                INT_ZERO(dic.di_anextents, ARCH_CONVERT);
284
 
                INT_ZERO(dic.di_forkoff, ARCH_CONVERT);
285
 
                INT_ZERO(dic.di_aformat, ARCH_CONVERT);
286
 
                INT_ZERO(dic.di_dmevmask, ARCH_CONVERT);
287
 
                INT_ZERO(dic.di_dmstate, ARCH_CONVERT);
288
 
                INT_ZERO(dic.di_flags, ARCH_CONVERT);
289
 
                INT_ZERO(dic.di_gen, ARCH_CONVERT);
290
 
                
 
264
 
291
265
                for (i = 0; i < ninodes; i++) {
292
266
                        free = XFS_MAKE_IPTR(args.mp, fbuf, i);
293
 
                        bcopy (&dic, &(free->di_core), sizeof(xfs_dinode_core_t));
294
 
                        INT_SET(free->di_next_unlinked, ARCH_CONVERT, NULLAGINO);
 
267
                        memcpy(&(free->di_core), &dic, sizeof(xfs_dinode_core_t));
 
268
                        INT_SET(free->di_next_unlinked, ARCH_CONVERT, NULLAGINO);
295
269
                        xfs_ialloc_log_di(tp, fbuf, i,
296
270
                                XFS_DI_CORE_BITS | XFS_DI_NEXT_UNLINKED);
297
271
                }
299
273
        }
300
274
        INT_MOD(agi->agi_count, ARCH_CONVERT, newlen);
301
275
        INT_MOD(agi->agi_freecount, ARCH_CONVERT, newlen);
302
 
        mraccess(&args.mp->m_peraglock);
 
276
        down_read(&args.mp->m_peraglock);
303
277
        args.mp->m_perag[INT_GET(agi->agi_seqno, ARCH_CONVERT)].pagi_freecount += newlen;
304
 
        mraccunlock(&args.mp->m_peraglock);
 
278
        up_read(&args.mp->m_peraglock);
305
279
        INT_SET(agi->agi_newino, ARCH_CONVERT, newino);
306
280
        /*
307
281
         * Insert records describing the new inode chunk into the btree.
339
313
        return 0;
340
314
}
341
315
 
 
316
STATIC __inline xfs_agnumber_t
 
317
xfs_ialloc_next_ag(
 
318
        xfs_mount_t     *mp)
 
319
{
 
320
        xfs_agnumber_t  agno;
 
321
 
 
322
        spin_lock(&mp->m_agirotor_lock);
 
323
        agno = mp->m_agirotor;
 
324
        if (++mp->m_agirotor == mp->m_maxagi)
 
325
                mp->m_agirotor = 0;
 
326
        spin_unlock(&mp->m_agirotor_lock);
 
327
 
 
328
        return agno;
 
329
}
 
330
 
342
331
/*
343
332
 * Select an allocation group to look for a free inode in, based on the parent
344
333
 * inode and then mode.  Return the allocation group buffer.
369
358
        mp = tp->t_mountp;
370
359
        agcount = mp->m_maxagi;
371
360
        if (S_ISDIR(mode))
372
 
                pagno = atomicIncWithWrap((int *)&mp->m_agirotor, agcount);
373
 
        else
 
361
                pagno = xfs_ialloc_next_ag(mp);
 
362
        else {
374
363
                pagno = XFS_INO_TO_AGNO(mp, parent);
 
364
                if (pagno >= agcount)
 
365
                        pagno = 0;
 
366
        }
375
367
        ASSERT(pagno < agcount);
376
368
        /*
377
369
         * Loop through allocation groups, looking for one with a little
378
370
         * free space in it.  Note we don't look for free inodes, exactly.
379
371
         * Instead, we include whether there is a need to allocate inodes
380
 
         * to mean that blocks must be allocated for them, 
 
372
         * to mean that blocks must be allocated for them,
381
373
         * if none are currently free.
382
374
         */
383
375
        agno = pagno;
384
376
        flags = XFS_ALLOC_FLAG_TRYLOCK;
 
377
        down_read(&mp->m_peraglock);
385
378
        for (;;) {
386
 
                mraccess(&mp->m_peraglock);
387
379
                pag = &mp->m_perag[agno];
388
380
                if (!pag->pagi_init) {
389
381
                        if (xfs_ialloc_read_agi(mp, tp, agno, &agbp)) {
390
382
                                agbp = NULL;
391
 
                                mraccunlock(&mp->m_peraglock);
392
383
                                goto nextag;
393
384
                        }
394
385
                } else
395
386
                        agbp = NULL;
396
387
 
397
388
                if (!pag->pagi_inodeok) {
398
 
                        atomicIncWithWrap((int *)&mp->m_agirotor, agcount);
 
389
                        xfs_ialloc_next_ag(mp);
399
390
                        goto unlock_nextag;
400
391
                }
401
392
 
408
399
                        if (agbp == NULL &&
409
400
                            xfs_ialloc_read_agi(mp, tp, agno, &agbp)) {
410
401
                                agbp = NULL;
411
 
                                mraccunlock(&mp->m_peraglock);
412
402
                                goto nextag;
413
403
                        }
414
404
                        (void)xfs_alloc_pagf_init(mp, tp, agno, flags);
423
413
                                if (agbp == NULL &&
424
414
                                    xfs_ialloc_read_agi(mp, tp, agno, &agbp)) {
425
415
                                        agbp = NULL;
426
 
                                        mraccunlock(&mp->m_peraglock);
427
416
                                        goto nextag;
428
417
                                }
429
 
                                mraccunlock(&mp->m_peraglock);
 
418
                                up_read(&mp->m_peraglock);
430
419
                                return agbp;
431
420
                        }
432
421
                }
433
422
unlock_nextag:
434
 
                mraccunlock(&mp->m_peraglock);
435
423
                if (agbp)
436
424
                        xfs_trans_brelse(tp, agbp);
437
 
nextag:         
438
 
                /*   
 
425
nextag:
 
426
                /*
439
427
                 * No point in iterating over the rest, if we're shutting
440
428
                 * down.
441
429
                 */
442
 
                if (XFS_FORCED_SHUTDOWN(mp))
 
430
                if (XFS_FORCED_SHUTDOWN(mp)) {
 
431
                        up_read(&mp->m_peraglock);
443
432
                        return (xfs_buf_t *)0;
 
433
                }
444
434
                agno++;
445
 
                if (agno == agcount)
 
435
                if (agno >= agcount)
446
436
                        agno = 0;
447
437
                if (agno == pagno) {
448
 
                        if (flags == 0)
 
438
                        if (flags == 0) {
 
439
                                up_read(&mp->m_peraglock);
449
440
                                return (xfs_buf_t *)0;
 
441
                        }
450
442
                        flags = 0;
451
443
                }
452
444
        }
453
445
}
454
446
 
455
 
/* 
 
447
/*
456
448
 * Visible inode allocation functions.
457
449
 */
458
450
 
467
459
 * allocation to make more free inodes.  On the first call,
468
460
 * IO_agbp should be set to NULL. If an inode is available,
469
461
 * i.e., xfs_dialloc() did not need to do an allocation, an inode
470
 
 * number is returned.  In this case, IO_agbp would be set to the 
 
462
 * number is returned.  In this case, IO_agbp would be set to the
471
463
 * current ag_buf and alloc_done set to false.
472
464
 * If an allocation needed to be done, xfs_dialloc would return
473
465
 * the current ag_buf in IO_agbp and set alloc_done to true.
521
513
                 */
522
514
                agbp = xfs_ialloc_ag_select(tp, parent, mode, okalloc);
523
515
                /*
524
 
                 * Couldn't find an allocation group satisfying the 
 
516
                 * Couldn't find an allocation group satisfying the
525
517
                 * criteria, give up.
526
518
                 */
527
519
                if (!agbp) {
532
524
                ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC);
533
525
        } else {
534
526
                /*
535
 
                 * Continue where we left off before.  In this case, we 
 
527
                 * Continue where we left off before.  In this case, we
536
528
                 * know that the allocation group has free inodes.
537
529
                 */
538
530
                agbp = *IO_agbp;
565
557
         * allocation groups upward, wrapping at the end.
566
558
         */
567
559
        *alloc_done = B_FALSE;
568
 
        while (INT_GET(agi->agi_freecount, ARCH_CONVERT) == 0) {
569
 
                /* 
 
560
        while (INT_ISZERO(agi->agi_freecount, ARCH_CONVERT)) {
 
561
                /*
570
562
                 * Don't do anything if we're not supposed to allocate
571
563
                 * any blocks, just go on to the next ag.
572
564
                 */
611
603
                        *inop = NULLFSINO;
612
604
                        return noroom ? ENOSPC : 0;
613
605
                }
614
 
                mraccess(&mp->m_peraglock);
 
606
                down_read(&mp->m_peraglock);
615
607
                if (mp->m_perag[tagno].pagi_inodeok == 0) {
616
 
                        mraccunlock(&mp->m_peraglock);
 
608
                        up_read(&mp->m_peraglock);
617
609
                        goto nextag;
618
610
                }
619
611
                error = xfs_ialloc_read_agi(mp, tp, tagno, &agbp);
620
 
                mraccunlock(&mp->m_peraglock);
 
612
                up_read(&mp->m_peraglock);
621
613
                if (error)
622
614
                        goto nextag;
623
615
                agi = XFS_BUF_TO_AGI(agbp);
706
698
                                        goto error1;
707
699
                                XFS_WANT_CORRUPTED_GOTO(i == 1, error1);
708
700
                        }
709
 
                        /* 
 
701
                        /*
710
702
                         * Search right with cur, go forward 1 record.
711
703
                         */
712
704
                        if ((error = xfs_inobt_increment(cur, 0, &i)))
865
857
                goto error0;
866
858
        INT_MOD(agi->agi_freecount, ARCH_CONVERT, -1);
867
859
        xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT);
868
 
        mraccess(&mp->m_peraglock);
 
860
        down_read(&mp->m_peraglock);
869
861
        mp->m_perag[tagno].pagi_freecount--;
870
 
        mraccunlock(&mp->m_peraglock);
 
862
        up_read(&mp->m_peraglock);
871
863
#ifdef DEBUG
872
864
        if (cur->bc_nlevels == 1) {
873
865
                int     freecount = 0;
911
903
        xfs_fsblock_t   *bno,   /* output: block containing inode */
912
904
        int             *len,   /* output: num blocks in inode cluster */
913
905
        int             *off,   /* output: index in block of inode */
914
 
        uint            flags)  /* flags concerning inode lookup */          
 
906
        uint            flags)  /* flags concerning inode lookup */
915
907
{
916
908
        xfs_agblock_t   agbno;  /* block number of inode in the alloc group */
917
909
        xfs_buf_t       *agbp;  /* agi buffer */
939
931
        if (agno >= mp->m_sb.sb_agcount || agbno >= mp->m_sb.sb_agblocks ||
940
932
            ino != XFS_AGINO_TO_INO(mp, agno, agino)) {
941
933
#ifdef DEBUG
942
 
                if (agno >= mp->m_sb.sb_agcount) {
 
934
                if (agno >= mp->m_sb.sb_agcount) {
943
935
                        xfs_fs_cmn_err(CE_ALERT, mp,
944
936
                                        "xfs_dilocate: agno (%d) >= "
945
937
                                        "mp->m_sb.sb_agcount (%d)",
985
977
                offset_agbno = agbno & mp->m_inoalign_mask;
986
978
                chunk_agbno = agbno - offset_agbno;
987
979
        } else {
988
 
                mraccess(&mp->m_peraglock);
 
980
                down_read(&mp->m_peraglock);
989
981
                error = xfs_ialloc_read_agi(mp, tp, agno, &agbp);
990
 
                mraccunlock(&mp->m_peraglock);
 
982
                up_read(&mp->m_peraglock);
991
983
                if (error) {
992
984
#ifdef DEBUG
993
985
                        xfs_fs_cmn_err(CE_ALERT, mp, "xfs_dilocate: "
1022
1014
                        error = XFS_ERROR(EINVAL);
1023
1015
                }
1024
1016
                xfs_trans_brelse(tp, agbp);
1025
 
                xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);           
 
1017
                xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
1026
1018
                if (error)
1027
1019
                        return error;
1028
1020
                chunk_agbno = XFS_AGINO_TO_AGBNO(mp, chunk_agino);
1096
1088
        xfs_agi_t               *agi;   /* allocation group header */
1097
1089
 
1098
1090
        agi = XFS_BUF_TO_AGI(bp);
1099
 
        ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) ==
1100
 
                XFS_AGI_MAGIC);
 
1091
        ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC);
1101
1092
#endif
1102
1093
        /*
1103
1094
         * Compute byte offsets for the first and last fields.
1122
1113
        xfs_agi_t       *agi;           /* allocation group header */
1123
1114
        int             agi_ok;         /* agi is consistent */
1124
1115
        xfs_buf_t       *bp;            /* allocation group hdr buf */
1125
 
    xfs_daddr_t         d;              /* disk block address */
 
1116
        xfs_perag_t     *pag;           /* per allocation group data */
1126
1117
        int             error;
1127
 
#ifdef DEBUG
1128
 
        int             i;
1129
 
#endif
1130
 
        xfs_perag_t     *pag;           /* per allocation group data */
1131
 
 
1132
1118
 
1133
1119
        ASSERT(agno != NULLAGNUMBER);
1134
 
        d = XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR);
1135
 
        if ((error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, d, 1, 0, &bp)))
 
1120
        error = xfs_trans_read_buf(
 
1121
                        mp, tp, mp->m_ddev_targp,
 
1122
                        XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)),
 
1123
                        XFS_FSS_TO_BB(mp, 1), 0, &bp);
 
1124
        if (error)
1136
1125
                return error;
1137
1126
        ASSERT(bp && !XFS_BUF_GETERROR(bp));
 
1127
 
1138
1128
        /*
1139
1129
         * Validate the magic number of the agi block.
1140
1130
         */
1141
1131
        agi = XFS_BUF_TO_AGI(bp);
1142
1132
        agi_ok =
1143
1133
                INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC &&
1144
 
                XFS_AGI_GOOD_VERSION(INT_GET(agi->agi_versionnum, ARCH_CONVERT));
1145
 
        if (XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IALLOC_READ_AGI,
1146
 
                        XFS_RANDOM_IALLOC_READ_AGI)) {
 
1134
                XFS_AGI_GOOD_VERSION(
 
1135
                        INT_GET(agi->agi_versionnum, ARCH_CONVERT));
 
1136
        if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IALLOC_READ_AGI,
 
1137
                        XFS_RANDOM_IALLOC_READ_AGI))) {
 
1138
                XFS_CORRUPTION_ERROR("xfs_ialloc_read_agi", XFS_ERRLEVEL_LOW,
 
1139
                                     mp, agi);
1147
1140
                xfs_trans_brelse(tp, bp);
1148
 
#ifdef __KERNEL__       /* additional, temporary, debugging code */
1149
 
                cmn_err(CE_NOTE,
1150
 
                        "EFSCORRUPTED returned from file %s line %d",
1151
 
                        __FILE__, __LINE__);
1152
 
#endif
1153
1141
                return XFS_ERROR(EFSCORRUPTED);
1154
1142
        }
1155
1143
        pag = &mp->m_perag[agno];
1161
1149
                 * It's possible for these to be out of sync if
1162
1150
                 * we are in the middle of a forced shutdown.
1163
1151
                 */
1164
 
                ASSERT(pag->pagi_freecount == INT_GET(agi->agi_freecount, ARCH_CONVERT)
 
1152
                ASSERT(pag->pagi_freecount ==
 
1153
                                INT_GET(agi->agi_freecount, ARCH_CONVERT)
1165
1154
                        || XFS_FORCED_SHUTDOWN(mp));
1166
1155
        }
 
1156
 
1167
1157
#ifdef DEBUG
1168
 
        for (i = 0; i < XFS_AGI_UNLINKED_BUCKETS; i++)
1169
 
                ASSERT(INT_GET(agi->agi_unlinked[i], ARCH_CONVERT) != 0);
 
1158
        {
 
1159
                int     i;
 
1160
 
 
1161
                for (i = 0; i < XFS_AGI_UNLINKED_BUCKETS; i++)
 
1162
                        ASSERT(!INT_ISZERO(agi->agi_unlinked[i], ARCH_CONVERT));
 
1163
        }
1170
1164
#endif
 
1165
 
1171
1166
        XFS_BUF_SET_VTYPE_REF(bp, B_FS_AGI, XFS_AGI_REF);
1172
1167
        *bpp = bp;
1173
1168
        return 0;