3 static inline unsigned int
4 __ext2_global_slot_alloc(struct v_superblock* vsb, int type_sel,
5 struct ext2_gdesc** gd_out)
7 struct ext2_sbinfo* sb;
8 struct ext2_gdesc *pos;
9 struct llist_header *header;
12 header = &sb->free_list_sel[type_sel];
14 if (type_sel == GDESC_INO_SEL) {
15 pos = list_entry(header->next, struct ext2_gdesc, free_grps_ino);
18 pos = list_entry(header->next, struct ext2_gdesc, free_grps_blk);
21 int alloc = ext2gd_alloc_slot(pos, type_sel);
23 if (valid_bmp_slot(alloc)) {
31 ext2ino_alloc_slot(struct v_superblock* vsb, struct ext2_gdesc** gd_out)
33 return __ext2_global_slot_alloc(vsb, GDESC_INO_SEL, gd_out);
37 ext2db_alloc_slot(struct v_superblock* vsb, struct ext2_gdesc** gd_out)
39 return __ext2_global_slot_alloc(vsb, GDESC_BLK_SEL, gd_out);
43 ext2gd_alloc_slot(struct ext2_gdesc* gd, int type_sel)
46 struct ext2_sbinfo *sb;
50 bmp = &gd->bmps[type_sel];
51 alloc = ext2bmp_alloc_one(bmp);
57 if (!ext2bmp_check_free(bmp)) {
58 llist_delete(&gd->free_list_sel[type_sel]);
61 if (type_sel == GDESC_INO_SEL) {
62 gd->info->bg_free_ino_cnt--;
63 sb->raw->s_free_ino_cnt--;
65 gd->info->bg_free_blk_cnt--;
66 sb->raw->s_free_blk_cnt--;
69 fsblock_dirty(gd->buf);
70 fsblock_dirty(sb->buf);
75 ext2gd_free_slot(struct ext2_gdesc* gd, int type_sel, int slot)
77 struct llist_header *free_ent, *free_list;
78 struct ext2_sbinfo *sb;
80 ext2bmp_free_one(&gd->bmps[type_sel], slot);
83 free_ent = &gd->free_list_sel[slot];
84 free_list = &gd->sb->free_list_sel[slot];
85 if (llist_empty(free_ent)) {
86 llist_append(free_list, free_ent);
89 if (type_sel == GDESC_INO_SEL) {
90 gd->info->bg_free_ino_cnt++;
91 sb->raw->s_free_ino_cnt++;
93 gd->info->bg_free_blk_cnt++;
94 sb->raw->s_free_blk_cnt++;
97 fsblock_dirty(gd->buf);
98 fsblock_dirty(sb->buf);