Lines Matching full: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()
59 * @fs: ext2 fs pointer
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 if ((fs->flags & EXT2_FLAG_SUPER_ONLY) == 0 && in ext2fs_flush2()
297 !ext2fs_has_feature_journal_dev(fs->super) && in ext2fs_flush2()
298 fs->group_desc == NULL) in ext2fs_flush2()
301 fs_state = fs->super->s_state; in ext2fs_flush2()
302 feature_incompat = fs->super->s_feature_incompat; in ext2fs_flush2()
304 fs->super->s_wtime = fs->now ? fs->now : time(NULL); in ext2fs_flush2()
305 fs->super->s_block_group_nr = 0; in ext2fs_flush2()
316 if (fs->write_bitmaps) { in ext2fs_flush2()
317 retval = fs->write_bitmaps(fs); in ext2fs_flush2()
323 * Set the state of the FS to be non-valid. (The state has in ext2fs_flush2()
327 fs->super->s_state &= ~EXT2_VALID_FS; in ext2fs_flush2()
328 ext2fs_clear_feature_journal_needs_recovery(fs->super); in ext2fs_flush2()
336 memcpy(super_shadow, fs->super, sizeof(struct ext2_super_block)); in ext2fs_flush2()
339 if (((fs->flags & EXT2_FLAG_SUPER_ONLY) == 0) && in ext2fs_flush2()
340 !ext2fs_has_feature_journal_dev(fs->super)) { in ext2fs_flush2()
341 retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize, in ext2fs_flush2()
345 memcpy(group_shadow, fs->group_desc, (size_t) fs->blocksize * in ext2fs_flush2()
346 fs->desc_blocks); in ext2fs_flush2()
348 for (j = 0; j < fs->group_desc_count; j++) { in ext2fs_flush2()
349 gdp = ext2fs_group_desc(fs, group_shadow, j); in ext2fs_flush2()
350 ext2fs_swap_group_desc2(fs, gdp); in ext2fs_flush2()
354 super_shadow = fs->super; in ext2fs_flush2()
355 group_shadow = fs->group_desc; in ext2fs_flush2()
362 if (ext2fs_has_feature_journal_dev(fs->super)) in ext2fs_flush2()
370 if (ext2fs_has_feature_meta_bg(fs->super)) { in ext2fs_flush2()
371 old_desc_blocks = fs->super->s_first_meta_bg; in ext2fs_flush2()
372 if (old_desc_blocks > fs->desc_blocks) in ext2fs_flush2()
373 old_desc_blocks = fs->desc_blocks; in ext2fs_flush2()
375 old_desc_blocks = fs->desc_blocks; in ext2fs_flush2()
377 if (fs->progress_ops && fs->progress_ops->init) in ext2fs_flush2()
378 (fs->progress_ops->init)(fs, &progress, NULL, in ext2fs_flush2()
379 fs->group_desc_count); in ext2fs_flush2()
382 for (i = 0; i < fs->group_desc_count; i++) { in ext2fs_flush2()
385 if (fs->progress_ops && fs->progress_ops->update) in ext2fs_flush2()
386 (fs->progress_ops->update)(fs, &progress, i); in ext2fs_flush2()
387 ext2fs_super_and_bgd_loc2(fs, i, &super_blk, &old_desc_blk, in ext2fs_flush2()
390 if (!(fs->flags & EXT2_FLAG_MASTER_SB_ONLY) &&i && super_blk) { in ext2fs_flush2()
391 retval = write_backup_super(fs, i, super_blk, in ext2fs_flush2()
396 if (fs->flags & EXT2_FLAG_SUPER_ONLY) in ext2fs_flush2()
399 (!(fs->flags & EXT2_FLAG_MASTER_SB_ONLY) || (i == 0))) { in ext2fs_flush2()
400 retval = io_channel_write_blk64(fs->io, in ext2fs_flush2()
406 int meta_bg = i / EXT2_DESC_PER_BLOCK(fs->super); in ext2fs_flush2()
408 retval = io_channel_write_blk64(fs->io, new_desc_blk, in ext2fs_flush2()
409 1, group_ptr + (meta_bg*fs->blocksize)); in ext2fs_flush2()
415 if (fs->progress_ops && fs->progress_ops->close) in ext2fs_flush2()
416 (fs->progress_ops->close)(fs, &progress, NULL); in ext2fs_flush2()
427 fs->super->s_block_group_nr = 0; in ext2fs_flush2()
428 fs->super->s_state = fs_state; in ext2fs_flush2()
429 fs->super->s_feature_incompat = feature_incompat; in ext2fs_flush2()
431 *super_shadow = *fs->super; in ext2fs_flush2()
435 retval = ext2fs_superblock_csum_set(fs, super_shadow); in ext2fs_flush2()
440 retval = io_channel_flush(fs->io); in ext2fs_flush2()
444 retval = write_primary_superblock(fs, super_shadow); in ext2fs_flush2()
448 fs->flags &= ~EXT2_FLAG_DIRTY; in ext2fs_flush2()
451 retval = io_channel_flush(fs->io); in ext2fs_flush2()
456 fs->super->s_state = fs_state; in ext2fs_flush2()
469 ext2_filsys fs = *fs_ptr; in ext2fs_close_free() local
471 ret = ext2fs_close2(fs, 0); in ext2fs_close_free()
473 ext2fs_free(fs); in ext2fs_close_free()
478 errcode_t ext2fs_close(ext2_filsys fs) in ext2fs_close() argument
480 return ext2fs_close2(fs, 0); in ext2fs_close()
483 errcode_t ext2fs_close2(ext2_filsys fs, int flags) in ext2fs_close2() argument
489 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); in ext2fs_close2()
491 if (fs->write_bitmaps) { in ext2fs_close2()
492 retval = fs->write_bitmaps(fs); in ext2fs_close2()
496 if (fs->super->s_kbytes_written && in ext2fs_close2()
497 fs->io->manager->get_stats) in ext2fs_close2()
498 fs->io->manager->get_stats(fs->io, &stats); in ext2fs_close2()
499 if (stats && stats->bytes_written && (fs->flags & EXT2_FLAG_RW)) { in ext2fs_close2()
500 fs->super->s_kbytes_written += stats->bytes_written >> 10; in ext2fs_close2()
501 meta_blks = fs->desc_blocks + 1; in ext2fs_close2()
502 if (!(fs->flags & EXT2_FLAG_SUPER_ONLY)) in ext2fs_close2()
503 fs->super->s_kbytes_written += meta_blks / in ext2fs_close2()
504 (fs->blocksize / 1024); in ext2fs_close2()
505 if ((fs->flags & EXT2_FLAG_DIRTY) == 0) in ext2fs_close2()
506 fs->flags |= EXT2_FLAG_SUPER_ONLY | EXT2_FLAG_DIRTY; in ext2fs_close2()
508 if (fs->flags & EXT2_FLAG_DIRTY) { in ext2fs_close2()
509 retval = ext2fs_flush2(fs, flags); in ext2fs_close2()
514 retval = ext2fs_mmp_stop(fs); in ext2fs_close2()
518 ext2fs_free(fs); in ext2fs_close2()