• Home
  • Raw
  • Download

Lines Matching refs:fs

36 int ext2fs_bg_has_super(ext2_filsys fs, dgrp_t group)  in ext2fs_bg_has_super()  argument
40 if (ext2fs_has_feature_sparse_super2(fs->super)) { in ext2fs_bg_has_super()
41 if (group == fs->super->s_backup_bgs[0] || in ext2fs_bg_has_super()
42 group == fs->super->s_backup_bgs[1]) in ext2fs_bg_has_super()
46 if ((group <= 1) || !ext2fs_has_feature_sparse_super(fs->super)) in ext2fs_bg_has_super()
71 errcode_t ext2fs_super_and_bgd_loc2(ext2_filsys fs, in ext2fs_super_and_bgd_loc2() argument
84 group_block = ext2fs_group_first_block2(fs, group); in ext2fs_super_and_bgd_loc2()
85 if (group_block == 0 && fs->blocksize == 1024) in ext2fs_super_and_bgd_loc2()
88 if (ext2fs_has_feature_meta_bg(fs->super)) in ext2fs_super_and_bgd_loc2()
89 old_desc_blocks = fs->super->s_first_meta_bg; in ext2fs_super_and_bgd_loc2()
92 fs->desc_blocks + fs->super->s_reserved_gdt_blocks; in ext2fs_super_and_bgd_loc2()
94 has_super = ext2fs_bg_has_super(fs, group); in ext2fs_super_and_bgd_loc2()
100 meta_bg_size = EXT2_DESC_PER_BLOCK(fs->super); in ext2fs_super_and_bgd_loc2()
103 if (!ext2fs_has_feature_meta_bg(fs->super) || in ext2fs_super_and_bgd_loc2()
104 (meta_bg < fs->super->s_first_meta_bg)) { in ext2fs_super_and_bgd_loc2()
145 int ext2fs_super_and_bgd_loc(ext2_filsys fs, in ext2fs_super_and_bgd_loc() argument
159 ext2fs_super_and_bgd_loc2(fs, group, &ret_super_blk2, in ext2fs_super_and_bgd_loc()
164 numblocks = ext2fs_group_blocks_count(fs, group); in ext2fs_super_and_bgd_loc()
173 meta_bg_size = EXT2_DESC_PER_BLOCK(fs->super); in ext2fs_super_and_bgd_loc()
177 numblocks -= 2 + fs->inode_blocks_per_group + ret_used_blks; in ext2fs_super_and_bgd_loc()
192 static errcode_t write_primary_superblock(ext2_filsys fs, in write_primary_superblock() argument
199 if (!fs->io->manager->write_byte || !fs->orig_super) { in write_primary_superblock()
201 io_channel_set_blksize(fs->io, SUPERBLOCK_OFFSET); in write_primary_superblock()
202 retval = io_channel_write_blk64(fs->io, 1, -SUPERBLOCK_SIZE, in write_primary_superblock()
204 io_channel_set_blksize(fs->io, fs->blocksize); in write_primary_superblock()
208 old_super = (__u16 *) fs->orig_super; in write_primary_superblock()
223 retval = io_channel_write_byte(fs->io, in write_primary_superblock()
231 memcpy(fs->orig_super, super, SUPERBLOCK_SIZE); in write_primary_superblock()
239 void ext2fs_update_dynamic_rev(ext2_filsys fs) in ext2fs_update_dynamic_rev() argument
241 struct ext2_super_block *sb = fs->super; in ext2fs_update_dynamic_rev()
253 static errcode_t write_backup_super(ext2_filsys fs, dgrp_t group, in write_backup_super() argument
265 retval = ext2fs_superblock_csum_set(fs, super_shadow); in write_backup_super()
269 return io_channel_write_blk64(fs->io, group_block, -SUPERBLOCK_SIZE, in write_backup_super()
273 errcode_t ext2fs_flush(ext2_filsys fs) in ext2fs_flush() argument
275 return ext2fs_flush2(fs, 0); in ext2fs_flush()
278 errcode_t ext2fs_flush2(ext2_filsys fs, int flags) in ext2fs_flush2() argument
294 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); in ext2fs_flush2()
296 fs_state = fs->super->s_state; in ext2fs_flush2()
297 feature_incompat = fs->super->s_feature_incompat; in ext2fs_flush2()
299 fs->super->s_wtime = fs->now ? fs->now : time(NULL); in ext2fs_flush2()
300 fs->super->s_block_group_nr = 0; in ext2fs_flush2()
311 if (fs->write_bitmaps) { in ext2fs_flush2()
312 retval = fs->write_bitmaps(fs); in ext2fs_flush2()
322 fs->super->s_state &= ~EXT2_VALID_FS; in ext2fs_flush2()
323 ext2fs_clear_feature_journal_needs_recovery(fs->super); in ext2fs_flush2()
331 retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize, in ext2fs_flush2()
335 memcpy(super_shadow, fs->super, sizeof(struct ext2_super_block)); in ext2fs_flush2()
336 memcpy(group_shadow, fs->group_desc, (size_t) fs->blocksize * in ext2fs_flush2()
337 fs->desc_blocks); in ext2fs_flush2()
340 for (j = 0; j < fs->group_desc_count; j++) { in ext2fs_flush2()
341 gdp = ext2fs_group_desc(fs, group_shadow, j); in ext2fs_flush2()
342 ext2fs_swap_group_desc2(fs, gdp); in ext2fs_flush2()
345 super_shadow = fs->super; in ext2fs_flush2()
346 group_shadow = fs->group_desc; in ext2fs_flush2()
353 if (ext2fs_has_feature_journal_dev(fs->super)) in ext2fs_flush2()
361 if (ext2fs_has_feature_meta_bg(fs->super)) { in ext2fs_flush2()
362 old_desc_blocks = fs->super->s_first_meta_bg; in ext2fs_flush2()
363 if (old_desc_blocks > fs->desc_blocks) in ext2fs_flush2()
364 old_desc_blocks = fs->desc_blocks; in ext2fs_flush2()
366 old_desc_blocks = fs->desc_blocks; in ext2fs_flush2()
368 if (fs->progress_ops && fs->progress_ops->init) in ext2fs_flush2()
369 (fs->progress_ops->init)(fs, &progress, NULL, in ext2fs_flush2()
370 fs->group_desc_count); in ext2fs_flush2()
373 for (i = 0; i < fs->group_desc_count; i++) { in ext2fs_flush2()
376 if (fs->progress_ops && fs->progress_ops->update) in ext2fs_flush2()
377 (fs->progress_ops->update)(fs, &progress, i); in ext2fs_flush2()
378 ext2fs_super_and_bgd_loc2(fs, i, &super_blk, &old_desc_blk, in ext2fs_flush2()
381 if (!(fs->flags & EXT2_FLAG_MASTER_SB_ONLY) &&i && super_blk) { in ext2fs_flush2()
382 retval = write_backup_super(fs, i, super_blk, in ext2fs_flush2()
387 if (fs->flags & EXT2_FLAG_SUPER_ONLY) in ext2fs_flush2()
390 (!(fs->flags & EXT2_FLAG_MASTER_SB_ONLY) || (i == 0))) { in ext2fs_flush2()
391 retval = io_channel_write_blk64(fs->io, in ext2fs_flush2()
397 int meta_bg = i / EXT2_DESC_PER_BLOCK(fs->super); in ext2fs_flush2()
399 retval = io_channel_write_blk64(fs->io, new_desc_blk, in ext2fs_flush2()
400 1, group_ptr + (meta_bg*fs->blocksize)); in ext2fs_flush2()
406 if (fs->progress_ops && fs->progress_ops->close) in ext2fs_flush2()
407 (fs->progress_ops->close)(fs, &progress, NULL); in ext2fs_flush2()
418 fs->super->s_block_group_nr = 0; in ext2fs_flush2()
419 fs->super->s_state = fs_state; in ext2fs_flush2()
420 fs->super->s_feature_incompat = feature_incompat; in ext2fs_flush2()
422 *super_shadow = *fs->super; in ext2fs_flush2()
426 retval = ext2fs_superblock_csum_set(fs, super_shadow); in ext2fs_flush2()
431 retval = io_channel_flush(fs->io); in ext2fs_flush2()
435 retval = write_primary_superblock(fs, super_shadow); in ext2fs_flush2()
439 fs->flags &= ~EXT2_FLAG_DIRTY; in ext2fs_flush2()
442 retval = io_channel_flush(fs->io); in ext2fs_flush2()
447 fs->super->s_state = fs_state; in ext2fs_flush2()
460 ext2_filsys fs = *fs_ptr; in ext2fs_close_free() local
462 ret = ext2fs_close2(fs, 0); in ext2fs_close_free()
464 ext2fs_free(fs); in ext2fs_close_free()
469 errcode_t ext2fs_close(ext2_filsys fs) in ext2fs_close() argument
471 return ext2fs_close2(fs, 0); in ext2fs_close()
474 errcode_t ext2fs_close2(ext2_filsys fs, int flags) in ext2fs_close2() argument
480 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); in ext2fs_close2()
482 if (fs->write_bitmaps) { in ext2fs_close2()
483 retval = fs->write_bitmaps(fs); in ext2fs_close2()
487 if (fs->super->s_kbytes_written && in ext2fs_close2()
488 fs->io->manager->get_stats) in ext2fs_close2()
489 fs->io->manager->get_stats(fs->io, &stats); in ext2fs_close2()
490 if (stats && stats->bytes_written && (fs->flags & EXT2_FLAG_RW)) { in ext2fs_close2()
491 fs->super->s_kbytes_written += stats->bytes_written >> 10; in ext2fs_close2()
492 meta_blks = fs->desc_blocks + 1; in ext2fs_close2()
493 if (!(fs->flags & EXT2_FLAG_SUPER_ONLY)) in ext2fs_close2()
494 fs->super->s_kbytes_written += meta_blks / in ext2fs_close2()
495 (fs->blocksize / 1024); in ext2fs_close2()
496 if ((fs->flags & EXT2_FLAG_DIRTY) == 0) in ext2fs_close2()
497 fs->flags |= EXT2_FLAG_SUPER_ONLY | EXT2_FLAG_DIRTY; in ext2fs_close2()
499 if (fs->flags & EXT2_FLAG_DIRTY) { in ext2fs_close2()
500 retval = ext2fs_flush2(fs, flags); in ext2fs_close2()
505 retval = ext2fs_mmp_stop(fs); in ext2fs_close2()
509 ext2fs_free(fs); in ext2fs_close2()