~ubuntu-branches/ubuntu/trusty/xfsdump/trusty-proposed

« back to all changes in this revision

Viewing changes to dump/inomap.c

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2008-04-23 22:06:34 UTC
  • mfrom: (0.1.1 upstream) (3.1.1 gutsy)
  • Revision ID: james.westby@ubuntu.com-20080423220634-7m8953nknbpz1nsv
Tags: 2.2.48-1
* New upstream release
* xfsdump depends on ${misc:Depends}
* Add debian/watch
* Add homepage control header
* Fix the following lintian issues:
  W: xfsdump source: package-uses-deprecated-debhelper-compat-version 1
  W: xfsdump source: ancient-standards-version 3.5.9 (current is 3.7.3)

Show diffs side-by-side

added added

removed removed

Lines of Context:
162
162
        intgen_t stat;
163
163
        intgen_t rval;
164
164
 
 
165
        /* do a sync so that bulkstat will pick up inode changes
 
166
         * that are currently in the inode cache. this is necessary
 
167
         * for incremental dumps in order to have the dump time
 
168
         * accurately reflect what inodes were included in this dump.
 
169
         * (PV 881455)
 
170
         */
 
171
        sync();
 
172
 
165
173
        /* copy stat ptrs
166
174
         */
167
175
        inomap_statphasep = statphasep;
251
259
                                     ( xfs_ino_t )0,
252
260
                                     cb_add,
253
261
                                     NULL,
 
262
                                     NULL,
 
263
                                     NULL,
254
264
                                     &stat,
255
265
                                     preemptchk,
256
266
                                     bstatbufp,
329
339
                             BIGSTAT_ITER_NONDIR,
330
340
                             ( xfs_ino_t )0,
331
341
                             cb_startpt,
332
 
                             0,
 
342
                             NULL,
 
343
                             inomap_next_nondir,
 
344
                             inomap_alloc_context(),
333
345
                             &stat,
334
346
                             preemptchk,
335
347
                             bstatbufp,
969
981
typedef struct seg_addr {
970
982
        intgen_t hnkoff;
971
983
        intgen_t segoff;
 
984
        intgen_t inooff;
972
985
} seg_addr_t;
973
986
 
974
987
static struct inomap {
1118
1131
        return ( addrp->hnkoff * SEGPERHNK ) + addrp->segoff;
1119
1132
}
1120
1133
 
 
1134
static inline intgen_t
 
1135
inomap_lastseg( intgen_t hnkoff )
 
1136
{
 
1137
        if ( hnkoff == inomap.lastseg.hnkoff )
 
1138
                return inomap.lastseg.segoff;
 
1139
        else
 
1140
                return SEGPERHNK - 1;
 
1141
}
 
1142
 
1121
1143
/* called for every inode group in the filesystem in increasing inode
1122
1144
 * order. adds a new segment to the inomap and ino-to-gen map.
1123
1145
 */
1191
1213
}
1192
1214
 
1193
1215
void
 
1216
inomap_reset_context( void *p )
 
1217
{
 
1218
        memset( p, 0, sizeof(seg_addr_t) );
 
1219
}
 
1220
 
 
1221
void
1194
1222
inomap_free_context( void *p )
1195
1223
{
1196
1224
        free( p );
1239
1267
        intgen_t upper;
1240
1268
 
1241
1269
        if ( !inomap_validaddr( addrp ) ) {
1242
 
                memset( addrp, 0, sizeof(seg_addr_t) );
 
1270
                inomap_reset_context( addrp );
1243
1271
        }
1244
1272
 
1245
1273
        if ( !inomap_find_hnk( addrp, ino ) )
1247
1275
 
1248
1276
        /* find the correct segment */
1249
1277
        lower = 0;
1250
 
        upper = ( addrp->hnkoff == inomap.lastseg.hnkoff ) ?
1251
 
                        inomap.lastseg.segoff : SEGPERHNK - 1;
 
1278
        upper = inomap_lastseg(addrp->hnkoff);
1252
1279
 
1253
1280
        while ( upper >= lower ) {
1254
1281
                segp = inomap_addr2seg( addrp );
1267
1294
        return BOOL_FALSE;
1268
1295
}
1269
1296
 
 
1297
static xfs_ino_t
 
1298
inomap_iter( void *contextp, intgen_t statemask )
 
1299
{
 
1300
        xfs_ino_t ino, endino;
 
1301
        seg_t *segp;
 
1302
        seg_addr_t *addrp = (seg_addr_t *)contextp;
 
1303
 
 
1304
        for ( ;
 
1305
              addrp->hnkoff <= inomap.lastseg.hnkoff;
 
1306
              addrp->hnkoff++, addrp->segoff = 0, addrp->inooff = 0 ) {
 
1307
 
 
1308
                for ( ;
 
1309
                      addrp->segoff <= inomap_lastseg(addrp->hnkoff);
 
1310
                      addrp->segoff++, addrp->inooff = 0 ) {
 
1311
 
 
1312
                        segp = inomap_addr2seg( addrp );
 
1313
 
 
1314
                        ino = segp->base + addrp->inooff;
 
1315
                        endino = segp->base + INOPERSEG;
 
1316
                        for ( ; ino < endino ; ino++, addrp->inooff++ ) {
 
1317
                                intgen_t st;
 
1318
                                st = SEG_GET_BITS( segp, ino );
 
1319
                                if ( statemask & ( 1 << st )) {
 
1320
                                        addrp->inooff++; /* for next call */
 
1321
                                        return ino;
 
1322
                                }
 
1323
                        }
 
1324
                }
 
1325
        }
 
1326
 
 
1327
        return INO64MAX;
 
1328
}
 
1329
 
 
1330
xfs_ino_t
 
1331
inomap_next_nondir(void *contextp, xfs_ino_t lastino)
 
1332
{
 
1333
        intgen_t state = 1 << MAP_NDR_CHANGE;
 
1334
        xfs_ino_t nextino;
 
1335
 
 
1336
        do {
 
1337
                nextino = inomap_iter(contextp, state);
 
1338
        } while (nextino <= lastino);
 
1339
 
 
1340
        return nextino;
 
1341
}
 
1342
 
 
1343
xfs_ino_t
 
1344
inomap_next_dir(void *contextp, xfs_ino_t lastino)
 
1345
{
 
1346
        intgen_t state = (1 << MAP_DIR_CHANGE) | (1 << MAP_DIR_SUPPRT);
 
1347
        xfs_ino_t nextino;
 
1348
 
 
1349
        do {
 
1350
                nextino = inomap_iter(contextp, state);
 
1351
        } while (nextino <= lastino);
 
1352
 
 
1353
        return nextino;
 
1354
}
 
1355
 
1270
1356
static intgen_t
1271
1357
inomap_set_state( void *contextp, xfs_ino_t ino, intgen_t state )
1272
1358
{
1433
1519
        return RV_OK;
1434
1520
}
1435
1521
 
1436
 
#ifdef NOTUSED
1437
 
bool_t
1438
 
inomap_iter_cb( void *contextp,
1439
 
                intgen_t statemask,
1440
 
                bool_t ( *funcp )( void *contextp,
1441
 
                                  xfs_ino_t ino,
1442
 
                                  intgen_t state ))
1443
 
{
1444
 
        hnk_t *hnkp;
1445
 
 
1446
 
        ASSERT( ! ( statemask & ( 1 << MAP_INO_UNUSED )));
1447
 
 
1448
 
        for ( hnkp = roothnkp ; hnkp != 0 ; hnkp = hnkp->nextp ) {
1449
 
                seg_t *segp = hnkp->seg;
1450
 
                seg_t *endsegp = hnkp->seg + SEGPERHNK;
1451
 
                for ( ; segp < endsegp ; segp++ ) {
1452
 
                        xfs_ino_t ino;
1453
 
                        xfs_ino_t endino;
1454
 
 
1455
 
                        if ( hnkp == tailhnkp && segp > lastsegp ) {
1456
 
                                return BOOL_TRUE;
1457
 
                        }
1458
 
                        ino = segp->base;
1459
 
                        endino = segp->base + INOPERSEG;
1460
 
                        for ( ; ino < endino ; ino++ ) {
1461
 
                                intgen_t st;
1462
 
                                st = SEG_GET_BITS( segp, ino );
1463
 
                                if ( statemask & ( 1 << st )) {
1464
 
                                        bool_t ok;
1465
 
                                        ok = ( * funcp )( contextp, ino, st );
1466
 
                                        if ( ! ok ) {
1467
 
                                                return BOOL_FALSE;
1468
 
                                        }
1469
 
                                }
1470
 
                        }
1471
 
                }
1472
 
        }
1473
 
 
1474
 
        /* should not get here
1475
 
         */
1476
 
        ASSERT( 0 );
1477
 
        return BOOL_FALSE;
1478
 
}
1479
 
#endif /* NOTUSED */
1480
 
 
1481
1522
static intgen_t
1482
1523
subtreelist_parse( jdm_fshandle_t *fshandlep,
1483
1524
                   intgen_t fsfd,
1717
1758
                 */
1718
1759
                if (hsm_fs_ctxtp) {
1719
1760
                        off64_t bytes;
1720
 
 
1721
 
                        if (HsmEstimateFileSpace(hsm_fs_ctxtp, statp, &bytes))
 
1761
                        int accurate;
 
1762
 
 
1763
                        /* if -z or multiple streams are being used,
 
1764
                         * we need an accurate estimate. otherwise a
 
1765
                         * quick estimate will do.
 
1766
                         */
 
1767
                        accurate = maxdumpfilesize || drivecnt > 1;
 
1768
 
 
1769
                        if (HsmEstimateFileSpace(hsm_fs_ctxtp, NULL, statp, &bytes, accurate))
1722
1770
                                return bytes;
1723
1771
                }
1724
1772
                return statp->bs_blocks * ( off64_t )statp->bs_blksize;