16 #include <linux/random.h>
43 static struct buffer_head *
47 struct buffer_head *bh =
NULL;
56 "Cannot read inode bitmap - "
57 "block_group = %lu, inode_bitmap = %u",
84 struct buffer_head *bitmap_bh =
NULL;
85 struct buffer_head *bh2;
94 printk (
"ext3_free_inode: inode has count=%d\n",
99 printk (
"ext3_free_inode: inode has nlink=%d\n",
104 printk(
"ext3_free_inode: inode on nonexistent device\n");
111 trace_ext3_free_inode(inode);
115 es = EXT3_SB(sb)->s_es;
118 "reserved or nonexistent inode %lu", ino);
123 bitmap_bh = read_inode_bitmap(sb, block_group);
127 BUFFER_TRACE(bitmap_bh,
"get_write_access");
134 bit, bitmap_bh->b_data))
136 "bit already cleared for inode %lu", ino);
140 BUFFER_TRACE(bh2,
"get_write_access");
142 if (fatal)
goto error_return;
145 spin_lock(sb_bgl_lock(sbi, block_group));
149 spin_unlock(sb_bgl_lock(sbi, block_group));
155 BUFFER_TRACE(bh2,
"call ext3_journal_dirty_metadata");
157 if (!fatal) fatal =
err;
159 BUFFER_TRACE(bitmap_bh,
"call ext3_journal_dirty_metadata");
195 int parent_group = EXT3_I(parent)->i_block_group;
199 unsigned int freei, avefreei;
202 int max_dirs, min_inodes;
208 avefreei = freei / ngroups;
210 avefreeb = freeb / ngroups;
213 if ((parent == sb->
s_root->d_inode) ||
215 int best_ndir = inodes_per_group;
219 parent_group = (unsigned)group % ngroups;
220 for (
i = 0;
i < ngroups;
i++) {
221 group = (parent_group +
i) % ngroups;
239 max_dirs = ndirs / ngroups + inodes_per_group / 16;
240 min_inodes = avefreei - inodes_per_group / 4;
243 for (
i = 0;
i < ngroups;
i++) {
244 group = (parent_group +
i) % ngroups;
258 for (
i = 0;
i < ngroups;
i++) {
259 group = (parent_group +
i) % ngroups;
281 int parent_group = EXT3_I(parent)->i_block_group;
282 int ngroups = EXT3_SB(sb)->s_groups_count;
289 group = parent_group;
304 group = (group + parent->
i_ino) % ngroups;
310 for (i = 1; i < ngroups; i <<= 1) {
312 if (group >= ngroups)
324 group = parent_group;
325 for (i = 0; i < ngroups; i++) {
326 if (++group >= ngroups)
350 struct buffer_head *bitmap_bh =
NULL;
351 struct buffer_head *bh2;
353 unsigned long ino = 0;
365 return ERR_PTR(-
EPERM);
368 trace_ext3_request_inode(dir, mode);
377 group = find_group_orlov(sb, dir);
379 group = find_group_other(sb, dir);
393 bitmap_bh = read_inode_bitmap(sb, group);
399 repeat_in_this_group:
404 BUFFER_TRACE(bitmap_bh,
"get_write_access");
410 ino, bitmap_bh->b_data)) {
412 BUFFER_TRACE(bitmap_bh,
413 "call ext3_journal_dirty_metadata");
424 goto repeat_in_this_group;
444 "reserved inode or inode > inodes count - "
445 "block_group = %d, inode=%lu", group, ino);
450 BUFFER_TRACE(bh2,
"get_write_access");
453 spin_lock(sb_bgl_lock(sbi, group));
458 spin_unlock(sb_bgl_lock(sbi, group));
459 BUFFER_TRACE(bh2,
"call ext3_journal_dirty_metadata");
486 #ifdef EXT3_FRAGMENTS
519 sizeof(
struct ext3_inode) - EXT3_GOOD_OLD_INODE_SIZE;
545 trace_ext3_allocate_inode(inode, dir, mode);
572 unsigned long max_ino =
le32_to_cpu(EXT3_SB(sb)->s_es->s_inodes_count);
575 struct buffer_head *bitmap_bh;
582 "bad orphan ino %lu! e2fsck was run?", ino);
588 bitmap_bh = read_inode_bitmap(sb, block_group);
591 "inode bitmap error for orphan %lu", ino);
620 err = PTR_ERR(inode);
624 "bad orphan inode %lu! e2fsck was run?", ino);
626 bit, (
unsigned long long)bitmap_bh->b_blocknr,
653 unsigned long bitmap_count,
x;
654 struct buffer_head *bitmap_bh =
NULL;
656 es = EXT3_SB(sb)->s_es;
660 for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) {
666 bitmap_bh = read_inode_bitmap(sb, i);
671 printk(
"group %d: stored = %d, counted = %lu\n",
676 printk(
"ext3_count_free_inodes: stored = %u, computed = %lu, %lu\n",
681 for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) {
695 unsigned long count = 0;
698 for (i = 0; i < EXT3_SB(sb)->s_groups_count; i++) {