diff options
author | Theodore Ts'o <tytso@mit.edu> | 2004-12-15 18:06:52 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2004-12-15 18:06:52 -0500 |
commit | 1b4cd9c7464d5bd0f5b416c7303bcc827e312473 (patch) | |
tree | fce84c641673240e056128698d94c098d8177200 /lib/ext2fs/res_gdt.c | |
parent | f581372280214bd494f4876ab39e559f3ef9f60b (diff) | |
download | e2fsprogs-1b4cd9c7464d5bd0f5b416c7303bcc827e312473.tar.gz |
sparse.c (ext2fs_list_backups, ext2fs_bg_has_super),
res_gdt.c (list_backups), closefs.c (ext2fs_bg_has_super),
ext2fs.h: Move ext2fs_list_backups() to res_gdt.c, and
ext2fs_bg_has_super() back to closefs.c. There's no
reason for the new file, since list_backups() isn't being
used by any other functions, and can be made static, and
all users of the ext2fs filesystem will have to call
ext2fs_close() anyway.
Diffstat (limited to 'lib/ext2fs/res_gdt.c')
-rw-r--r-- | lib/ext2fs/res_gdt.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/lib/ext2fs/res_gdt.c b/lib/ext2fs/res_gdt.c index 727b8267..e9262429 100644 --- a/lib/ext2fs/res_gdt.c +++ b/lib/ext2fs/res_gdt.c @@ -1,5 +1,5 @@ /* - * res_gdt.h --- reserve blocks for growing the group descriptor table + * res_gdt.c --- reserve blocks for growing the group descriptor table * during online resizing. * * Copyright (C) 2002 Andreas Dilger @@ -17,6 +17,42 @@ #include "ext2fs.h" /* + * Iterate through the groups which hold BACKUP superblock/GDT copies in an + * ext3 filesystem. The counters should be initialized to 1, 5, and 7 before + * calling this for the first time. In a sparse filesystem it will be the + * sequence of powers of 3, 5, and 7: 1, 3, 5, 7, 9, 25, 27, 49, 81, ... + * For a non-sparse filesystem it will be every group: 1, 2, 3, 4, ... + */ +static unsigned int list_backups(ext2_filsys fs, unsigned int *three, + unsigned int *five, unsigned int *seven) +{ + unsigned int *min = three; + int mult = 3; + unsigned int ret; + + if (!(fs->super->s_feature_ro_compat & + EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)) { + ret = *min; + *min += 1; + return ret; + } + + if (*five < *min) { + min = five; + mult = 5; + } + if (*seven < *min) { + min = seven; + mult = 7; + } + + ret = *min; + *min *= mult; + + return ret; +} + +/* * This code assumes that the reserved blocks have already been marked in-use * during ext2fs_initialize(), so that they are not allocated for other * uses before we can add them to the resize inode (which has to come @@ -124,7 +160,7 @@ errcode_t ext2fs_create_resize_inode(ext2_filsys fs) goto out_dindir; } - while ((grp = ext2fs_list_backups(fs, &three, &five, &seven)) < + while ((grp = list_backups(fs, &three, &five, &seven)) < fs->group_desc_count) { blk_t expect = gdt_blk + grp * sb->s_blocks_per_group; |