root/fs/ext2/ialloc.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. get_group_desc
  2. read_inode_bitmap
  3. load_inode_bitmap
  4. set_inode_dtime
  5. ext2_free_inode
  6. inc_inode_version
  7. ext2_new_inode
  8. ext2_count_free_inodes
  9. ext2_check_inodes_bitmap

   1 /*
   2  *  linux/fs/ext2/ialloc.c
   3  *
   4  * Copyright (C) 1992, 1993, 1994, 1995
   5  * Remy Card (card@masi.ibp.fr)
   6  * Laboratoire MASI - Institut Blaise Pascal
   7  * Universite Pierre et Marie Curie (Paris VI)
   8  *
   9  *  BSD ufs-inspired inode and directory allocation by 
  10  *  Stephen Tweedie (sct@dcs.ed.ac.uk), 1993
  11  */
  12 
  13 /*
  14  * ialloc.c contains the inodes allocation and deallocation routines
  15  */
  16 
  17 /*
  18  * The free inodes are managed by bitmaps.  A file system contains several
  19  * blocks groups.  Each group contains 1 bitmap block for blocks, 1 bitmap
  20  * block for inodes, N blocks for the inode table and data blocks.
  21  *
  22  * The file system contains group descriptors which are located after the
  23  * super block.  Each descriptor contains the number of the bitmap block and
  24  * the free blocks count in the block.  The descriptors are loaded in memory
  25  * when a file system is mounted (see ext2_read_super).
  26  */
  27 
  28 #include <linux/fs.h>
  29 #include <linux/ext2_fs.h>
  30 #include <linux/sched.h>
  31 #include <linux/stat.h>
  32 #include <linux/string.h>
  33 #include <linux/locks.h>
  34 
  35 #include <asm/bitops.h>
  36 
  37 static struct ext2_group_desc * get_group_desc (struct super_block * sb,
     /* [previous][next][first][last][top][bottom][index][help] */
  38                                                 unsigned int block_group,
  39                                                 struct buffer_head ** bh)
  40 {
  41         unsigned long group_desc;
  42         unsigned long desc;
  43         struct ext2_group_desc * gdp;
  44 
  45         if (block_group >= sb->u.ext2_sb.s_groups_count)
  46                 ext2_panic (sb, "get_group_desc",
  47                             "block_group >= groups_count - "
  48                             "block_group = %d, groups_count = %lu",
  49                             block_group, sb->u.ext2_sb.s_groups_count);
  50 
  51         group_desc = block_group / EXT2_DESC_PER_BLOCK(sb);
  52         desc = block_group % EXT2_DESC_PER_BLOCK(sb);
  53         if (!sb->u.ext2_sb.s_group_desc[group_desc])
  54                 ext2_panic (sb, "get_group_desc",
  55                             "Group descriptor not loaded - "
  56                             "block_group = %d, group_desc = %lu, desc = %lu",
  57                              block_group, group_desc, desc);
  58         gdp = (struct ext2_group_desc *) 
  59                 sb->u.ext2_sb.s_group_desc[group_desc]->b_data;
  60         if (bh)
  61                 *bh = sb->u.ext2_sb.s_group_desc[group_desc];
  62         return gdp + desc;
  63 }
  64 
  65 static void read_inode_bitmap (struct super_block * sb,
     /* [previous][next][first][last][top][bottom][index][help] */
  66                                unsigned long block_group,
  67                                unsigned int bitmap_nr)
  68 {
  69         struct ext2_group_desc * gdp;
  70         struct buffer_head * bh;
  71 
  72         gdp = get_group_desc (sb, block_group, NULL);
  73         bh = bread (sb->s_dev, gdp->bg_inode_bitmap, sb->s_blocksize);
  74         if (!bh)
  75                 ext2_panic (sb, "read_inode_bitmap",
  76                             "Cannot read inode bitmap - "
  77                             "block_group = %lu, inode_bitmap = %lu",
  78                             block_group, (unsigned long) gdp->bg_inode_bitmap);
  79         sb->u.ext2_sb.s_inode_bitmap_number[bitmap_nr] = block_group;
  80         sb->u.ext2_sb.s_inode_bitmap[bitmap_nr] = bh;
  81 }
  82 
  83 /*
  84  * load_inode_bitmap loads the inode bitmap for a blocks group
  85  *
  86  * It maintains a cache for the last bitmaps loaded.  This cache is managed
  87  * with a LRU algorithm.
  88  *
  89  * Notes:
  90  * 1/ There is one cache per mounted file system.
  91  * 2/ If the file system contains less than EXT2_MAX_GROUP_LOADED groups,
  92  *    this function reads the bitmap without maintaining a LRU cache.
  93  */
  94 static int load_inode_bitmap (struct super_block * sb,
     /* [previous][next][first][last][top][bottom][index][help] */
  95                               unsigned int block_group)
  96 {
  97         int i, j;
  98         unsigned long inode_bitmap_number;
  99         struct buffer_head * inode_bitmap;
 100 
 101         if (block_group >= sb->u.ext2_sb.s_groups_count)
 102                 ext2_panic (sb, "load_inode_bitmap",
 103                             "block_group >= groups_count - "
 104                             "block_group = %d, groups_count = %lu",
 105                              block_group, sb->u.ext2_sb.s_groups_count);
 106         if (sb->u.ext2_sb.s_loaded_inode_bitmaps > 0 &&
 107             sb->u.ext2_sb.s_inode_bitmap_number[0] == block_group)
 108                 return 0;
 109         if (sb->u.ext2_sb.s_groups_count <= EXT2_MAX_GROUP_LOADED) {
 110                 if (sb->u.ext2_sb.s_inode_bitmap[block_group]) {
 111                         if (sb->u.ext2_sb.s_inode_bitmap_number[block_group] != block_group)
 112                                 ext2_panic (sb, "load_inode_bitmap",
 113                                             "block_group != inode_bitmap_number");
 114                         else
 115                                 return block_group;
 116                 } else {
 117                         read_inode_bitmap (sb, block_group, block_group);
 118                         return block_group;
 119                 }
 120         }
 121 
 122         for (i = 0; i < sb->u.ext2_sb.s_loaded_inode_bitmaps &&
 123                     sb->u.ext2_sb.s_inode_bitmap_number[i] != block_group;
 124              i++)
 125                 ;
 126         if (i < sb->u.ext2_sb.s_loaded_inode_bitmaps &&
 127             sb->u.ext2_sb.s_inode_bitmap_number[i] == block_group) {
 128                 inode_bitmap_number = sb->u.ext2_sb.s_inode_bitmap_number[i];
 129                 inode_bitmap = sb->u.ext2_sb.s_inode_bitmap[i];
 130                 for (j = i; j > 0; j--) {
 131                         sb->u.ext2_sb.s_inode_bitmap_number[j] =
 132                                 sb->u.ext2_sb.s_inode_bitmap_number[j - 1];
 133                         sb->u.ext2_sb.s_inode_bitmap[j] =
 134                                 sb->u.ext2_sb.s_inode_bitmap[j - 1];
 135                 }
 136                 sb->u.ext2_sb.s_inode_bitmap_number[0] = inode_bitmap_number;
 137                 sb->u.ext2_sb.s_inode_bitmap[0] = inode_bitmap;
 138         } else {
 139                 if (sb->u.ext2_sb.s_loaded_inode_bitmaps < EXT2_MAX_GROUP_LOADED)
 140                         sb->u.ext2_sb.s_loaded_inode_bitmaps++;
 141                 else
 142                         brelse (sb->u.ext2_sb.s_inode_bitmap[EXT2_MAX_GROUP_LOADED - 1]);
 143                 for (j = sb->u.ext2_sb.s_loaded_inode_bitmaps - 1; j > 0; j--) {
 144                         sb->u.ext2_sb.s_inode_bitmap_number[j] =
 145                                 sb->u.ext2_sb.s_inode_bitmap_number[j - 1];
 146                         sb->u.ext2_sb.s_inode_bitmap[j] =
 147                                 sb->u.ext2_sb.s_inode_bitmap[j - 1];
 148                 }
 149                 read_inode_bitmap (sb, block_group, 0);
 150         }
 151         return 0;
 152 }
 153 
 154 /*
 155  * This function sets the deletion time for the inode
 156  *
 157  * This may be used one day by an 'undelete' program
 158  */
 159 static void set_inode_dtime (struct inode * inode,
     /* [previous][next][first][last][top][bottom][index][help] */
 160                              struct ext2_group_desc * gdp)
 161 {
 162         unsigned long inode_block;
 163         struct buffer_head * bh;
 164         struct ext2_inode * raw_inode;
 165 
 166         inode_block = gdp->bg_inode_table + (((inode->i_ino - 1) %
 167                         EXT2_INODES_PER_GROUP(inode->i_sb)) /
 168                         EXT2_INODES_PER_BLOCK(inode->i_sb));
 169         bh = bread (inode->i_sb->s_dev, inode_block, inode->i_sb->s_blocksize);
 170         if (!bh)
 171                 ext2_panic (inode->i_sb, "set_inode_dtime",
 172                             "Cannot load inode table block - "
 173                             "inode=%lu, inode_block=%lu",
 174                             inode->i_ino, inode_block);
 175         raw_inode = ((struct ext2_inode *) bh->b_data) +
 176                         (((inode->i_ino - 1) %
 177                         EXT2_INODES_PER_GROUP(inode->i_sb)) %
 178                         EXT2_INODES_PER_BLOCK(inode->i_sb));
 179         raw_inode->i_links_count = 0;
 180         raw_inode->i_dtime = CURRENT_TIME;
 181         mark_buffer_dirty(bh, 1);
 182         if (IS_SYNC(inode)) {
 183                 ll_rw_block (WRITE, 1, &bh);
 184                 wait_on_buffer (bh);
 185         }
 186         brelse (bh);
 187 }
 188 
 189 void ext2_free_inode (struct inode * inode)
     /* [previous][next][first][last][top][bottom][index][help] */
 190 {
 191         struct super_block * sb;
 192         struct buffer_head * bh;
 193         struct buffer_head * bh2;
 194         unsigned long block_group;
 195         unsigned long bit;
 196         int bitmap_nr;
 197         struct ext2_group_desc * gdp;
 198         struct ext2_super_block * es;
 199 
 200         if (!inode)
 201                 return;
 202         if (!inode->i_dev) {
 203                 printk ("ext2_free_inode: inode has no device\n");
 204                 return;
 205         }
 206         if (inode->i_count > 1) {
 207                 printk ("ext2_free_inode: inode has count=%d\n",
 208                         inode->i_count);
 209                 return;
 210         }
 211         if (inode->i_nlink) {
 212                 printk ("ext2_free_inode: inode has nlink=%d\n",
 213                         inode->i_nlink);
 214                 return;
 215         }
 216         if (!inode->i_sb) {
 217                 printk("ext2_free_inode: inode on nonexistent device\n");
 218                 return;
 219         }
 220 
 221         ext2_debug ("freeing inode %lu\n", inode->i_ino);
 222 
 223         sb = inode->i_sb;
 224         lock_super (sb);
 225         if (inode->i_ino < EXT2_FIRST_INO ||
 226             inode->i_ino > sb->u.ext2_sb.s_es->s_inodes_count) {
 227                 ext2_error (sb, "free_inode",
 228                             "reserved inode or nonexistent inode");
 229                 unlock_super (sb);
 230                 return;
 231         }
 232         es = sb->u.ext2_sb.s_es;
 233         block_group = (inode->i_ino - 1) / EXT2_INODES_PER_GROUP(sb);
 234         bit = (inode->i_ino - 1) % EXT2_INODES_PER_GROUP(sb);
 235         bitmap_nr = load_inode_bitmap (sb, block_group);
 236         bh = sb->u.ext2_sb.s_inode_bitmap[bitmap_nr];
 237         if (!clear_bit (bit, bh->b_data))
 238                 ext2_warning (sb, "ext2_free_inode",
 239                               "bit already cleared for inode %lu", inode->i_ino);
 240         else {
 241                 gdp = get_group_desc (sb, block_group, &bh2);
 242                 gdp->bg_free_inodes_count++;
 243                 if (S_ISDIR(inode->i_mode))
 244                         gdp->bg_used_dirs_count--;
 245                 mark_buffer_dirty(bh2, 1);
 246                 es->s_free_inodes_count++;
 247                 mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1);
 248                 set_inode_dtime (inode, gdp);
 249         }
 250         mark_buffer_dirty(bh, 1);
 251         if (sb->s_flags & MS_SYNCHRONOUS) {
 252                 ll_rw_block (WRITE, 1, &bh);
 253                 wait_on_buffer (bh);
 254         }
 255 
 256         sb->s_dirt = 1;
 257         clear_inode (inode);
 258         unlock_super (sb);
 259 }
 260 
 261 /*
 262  * This function increments the inode version number
 263  *
 264  * This may be used one day by the NFS server
 265  */
 266 static void inc_inode_version (struct inode * inode,
     /* [previous][next][first][last][top][bottom][index][help] */
 267                                struct ext2_group_desc *gdp,
 268                                int mode)
 269 {
 270         unsigned long inode_block;
 271         struct buffer_head * bh;
 272         struct ext2_inode * raw_inode;
 273 
 274         inode_block = gdp->bg_inode_table + (((inode->i_ino - 1) %
 275                         EXT2_INODES_PER_GROUP(inode->i_sb)) /
 276                         EXT2_INODES_PER_BLOCK(inode->i_sb));
 277         bh = bread (inode->i_sb->s_dev, inode_block, inode->i_sb->s_blocksize);
 278         if (!bh) {
 279                 ext2_error (inode->i_sb, "inc_inode_version",
 280                             "Cannot load inode table block - "
 281                             "inode=%lu, inode_block=%lu\n",
 282                             inode->i_ino, inode_block);
 283                 inode->u.ext2_i.i_version = 1;
 284                 return;
 285         }
 286         raw_inode = ((struct ext2_inode *) bh->b_data) +
 287                         (((inode->i_ino - 1) %
 288                         EXT2_INODES_PER_GROUP(inode->i_sb)) %
 289                         EXT2_INODES_PER_BLOCK(inode->i_sb));
 290         raw_inode->i_version++;
 291         inode->u.ext2_i.i_version = raw_inode->i_version;
 292         mark_buffer_dirty(bh, 1);
 293         brelse (bh);
 294 }
 295 
 296 /*
 297  * There are two policies for allocating an inode.  If the new inode is
 298  * a directory, then a forward search is made for a block group with both
 299  * free space and a low directory-to-inode ratio; if that fails, then of
 300  * the groups with above-average free space, that group with the fewest
 301  * directories already is chosen.
 302  *
 303  * For other inodes, search forward from the parent directory\'s block
 304  * group to find a free inode.
 305  */
 306 struct inode * ext2_new_inode (const struct inode * dir, int mode)
     /* [previous][next][first][last][top][bottom][index][help] */
 307 {
 308         struct super_block * sb;
 309         struct buffer_head * bh;
 310         struct buffer_head * bh2;
 311         int i, j, avefreei;
 312         struct inode * inode;
 313         int bitmap_nr;
 314         struct ext2_group_desc * gdp;
 315         struct ext2_group_desc * tmp;
 316         struct ext2_super_block * es;
 317 
 318         if (!dir || !(inode = get_empty_inode ()))
 319                 return NULL;
 320         sb = dir->i_sb;
 321         inode->i_sb = sb;
 322         inode->i_flags = sb->s_flags;
 323         lock_super (sb);
 324         es = sb->u.ext2_sb.s_es;
 325 repeat:
 326         gdp = NULL; i=0;
 327         
 328         if (S_ISDIR(mode)) {
 329                 avefreei = es->s_free_inodes_count /
 330                         sb->u.ext2_sb.s_groups_count;
 331 /* I am not yet convinced that this next bit is necessary.
 332                 i = dir->u.ext2_i.i_block_group;
 333                 for (j = 0; j < sb->u.ext2_sb.s_groups_count; j++) {
 334                         tmp = get_group_desc (sb, i, &bh2);
 335                         if ((tmp->bg_used_dirs_count << 8) < 
 336                             tmp->bg_free_inodes_count) {
 337                                 gdp = tmp;
 338                                 break;
 339                         }
 340                         else
 341                         i = ++i % sb->u.ext2_sb.s_groups_count;
 342                 }
 343 */
 344                 if (!gdp) {
 345                         for (j = 0; j < sb->u.ext2_sb.s_groups_count; j++) {
 346                                 tmp = get_group_desc (sb, j, &bh2);
 347                                 if (tmp->bg_free_inodes_count &&
 348                                         tmp->bg_free_inodes_count >= avefreei) {
 349                                         if (!gdp || 
 350                                             (tmp->bg_free_blocks_count >
 351                                              gdp->bg_free_blocks_count)) {
 352                                                 i = j;
 353                                                 gdp = tmp;
 354                                         }
 355                                 }
 356                         }
 357                 }
 358         }
 359         else 
 360         {
 361                 /*
 362                  * Try to place the inode in its parent directory
 363                  */
 364                 i = dir->u.ext2_i.i_block_group;
 365                 tmp = get_group_desc (sb, i, &bh2);
 366                 if (tmp->bg_free_inodes_count)
 367                         gdp = tmp;
 368                 else
 369                 {
 370                         /*
 371                          * Use a quadratic hash to find a group with a
 372                          * free inode
 373                          */
 374                         for (j = 1; j < sb->u.ext2_sb.s_groups_count; j <<= 1) {
 375                                 i += j;
 376                                 if (i >= sb->u.ext2_sb.s_groups_count)
 377                                         i -= sb->u.ext2_sb.s_groups_count;
 378                                 tmp = get_group_desc (sb, i, &bh2);
 379                                 if (tmp->bg_free_inodes_count) {
 380                                         gdp = tmp;
 381                                         break;
 382                                 }
 383                         }
 384                 }
 385                 if (!gdp) {
 386                         /*
 387                          * That failed: try linear search for a free inode
 388                          */
 389                         i = dir->u.ext2_i.i_block_group + 1;
 390                         for (j = 2; j < sb->u.ext2_sb.s_groups_count; j++) {
 391                                 if (++i >= sb->u.ext2_sb.s_groups_count)
 392                                         i = 0;
 393                                 tmp = get_group_desc (sb, i, &bh2);
 394                                 if (tmp->bg_free_inodes_count) {
 395                                         gdp = tmp;
 396                                         break;
 397                                 }
 398                         }
 399                 }
 400         }
 401 
 402         if (!gdp) {
 403                 unlock_super (sb);
 404                 iput(inode);
 405                 return NULL;
 406         }
 407         bitmap_nr = load_inode_bitmap (sb, i);
 408         bh = sb->u.ext2_sb.s_inode_bitmap[bitmap_nr];
 409         if ((j = find_first_zero_bit ((unsigned long *) bh->b_data,
 410                                       EXT2_INODES_PER_GROUP(sb))) <
 411             EXT2_INODES_PER_GROUP(sb)) {
 412                 if (set_bit (j, bh->b_data)) {
 413                         ext2_warning (sb, "ext2_new_inode",
 414                                       "bit already set for inode %d", j);
 415                         goto repeat;
 416                 }
 417                 mark_buffer_dirty(bh, 1);
 418                 if (sb->s_flags & MS_SYNCHRONOUS) {
 419                         ll_rw_block (WRITE, 1, &bh);
 420                         wait_on_buffer (bh);
 421                 }
 422         } else {
 423                 if (gdp->bg_free_inodes_count != 0) {
 424                         ext2_error (sb, "ext2_new_inode",
 425                                     "Free inodes count corrupted in group %d",
 426                                     i);
 427                         unlock_super (sb);
 428                         iput (inode);
 429                         return NULL;
 430                 }
 431                 goto repeat;
 432         }
 433         j += i * EXT2_INODES_PER_GROUP(sb) + 1;
 434         if (j < EXT2_FIRST_INO || j > es->s_inodes_count) {
 435                 ext2_error (sb, "ext2_new_inode",
 436                             "reserved inode or inode > inodes count - "
 437                             "block_group = %d,inode=%d", i, j);
 438                 unlock_super (sb);
 439                 iput (inode);
 440                 return NULL;
 441         }
 442         gdp->bg_free_inodes_count--;
 443         if (S_ISDIR(mode))
 444                 gdp->bg_used_dirs_count++;
 445         mark_buffer_dirty(bh2, 1);
 446         es->s_free_inodes_count--;
 447         mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1);
 448         sb->s_dirt = 1;
 449         inode->i_mode = mode;
 450         inode->i_sb = sb;
 451         inode->i_count = 1;
 452         inode->i_nlink = 1;
 453         inode->i_dev = sb->s_dev;
 454         inode->i_uid = current->fsuid;
 455         if (test_opt (sb, GRPID))
 456                 inode->i_gid = dir->i_gid;
 457         else if (dir->i_mode & S_ISGID) {
 458                 inode->i_gid = dir->i_gid;
 459                 if (S_ISDIR(mode))
 460                         mode |= S_ISGID;
 461         } else
 462                 inode->i_gid = current->fsgid;
 463         inode->i_dirt = 1;
 464         inode->i_ino = j;
 465         inode->i_blksize = sb->s_blocksize;
 466         inode->i_blocks = 0;
 467         inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
 468         inode->u.ext2_i.i_flags = dir->u.ext2_i.i_flags;
 469         if (S_ISLNK(mode))
 470                 inode->u.ext2_i.i_flags &= ~(EXT2_IMMUTABLE_FL | EXT2_APPEND_FL);
 471         inode->u.ext2_i.i_faddr = 0;
 472         inode->u.ext2_i.i_frag_no = 0;
 473         inode->u.ext2_i.i_frag_size = 0;
 474         inode->u.ext2_i.i_file_acl = 0;
 475         inode->u.ext2_i.i_dir_acl = 0;
 476         inode->u.ext2_i.i_dtime = 0;
 477         inode->u.ext2_i.i_block_group = i;
 478         inode->i_op = NULL;
 479         if (inode->u.ext2_i.i_flags & EXT2_SYNC_FL)
 480                 inode->i_flags |= MS_SYNCHRONOUS;
 481         insert_inode_hash(inode);
 482         inc_inode_version (inode, gdp, mode);
 483 
 484         ext2_debug ("allocating inode %lu\n", inode->i_ino);
 485 
 486         unlock_super (sb);
 487         return inode;
 488 }
 489 
 490 unsigned long ext2_count_free_inodes (struct super_block * sb)
     /* [previous][next][first][last][top][bottom][index][help] */
 491 {
 492 #ifdef EXT2FS_DEBUG
 493         struct ext2_super_block * es;
 494         unsigned long desc_count, bitmap_count, x;
 495         int bitmap_nr;
 496         struct ext2_group_desc * gdp;
 497         int i;
 498 
 499         lock_super (sb);
 500         es = sb->u.ext2_sb.s_es;
 501         desc_count = 0;
 502         bitmap_count = 0;
 503         gdp = NULL;
 504         for (i = 0; i < sb->u.ext2_sb.s_groups_count; i++) {
 505                 gdp = get_group_desc (sb, i, NULL);
 506                 desc_count += gdp->bg_free_inodes_count;
 507                 bitmap_nr = load_inode_bitmap (sb, i);
 508                 x = ext2_count_free (sb->u.ext2_sb.s_inode_bitmap[bitmap_nr],
 509                                      EXT2_INODES_PER_GROUP(sb) / 8);
 510                 printk ("group %d: stored = %d, counted = %lu\n",
 511                         i, gdp->bg_free_inodes_count, x);
 512                 bitmap_count += x;
 513         }
 514         printk("ext2_count_free_inodes: stored = %lu, computed = %lu, %lu\n",
 515                 es->s_free_inodes_count, desc_count, bitmap_count);
 516         unlock_super (sb);
 517         return desc_count;
 518 #else
 519         return sb->u.ext2_sb.s_es->s_free_inodes_count;
 520 #endif
 521 }
 522 
 523 void ext2_check_inodes_bitmap (struct super_block * sb)
     /* [previous][next][first][last][top][bottom][index][help] */
 524 {
 525         struct ext2_super_block * es;
 526         unsigned long desc_count, bitmap_count, x;
 527         int bitmap_nr;
 528         struct ext2_group_desc * gdp;
 529         int i;
 530 
 531         lock_super (sb);
 532         es = sb->u.ext2_sb.s_es;
 533         desc_count = 0;
 534         bitmap_count = 0;
 535         gdp = NULL;
 536         for (i = 0; i < sb->u.ext2_sb.s_groups_count; i++) {
 537                 gdp = get_group_desc (sb, i, NULL);
 538                 desc_count += gdp->bg_free_inodes_count;
 539                 bitmap_nr = load_inode_bitmap (sb, i);
 540                 x = ext2_count_free (sb->u.ext2_sb.s_inode_bitmap[bitmap_nr],
 541                                      EXT2_INODES_PER_GROUP(sb) / 8);
 542                 if (gdp->bg_free_inodes_count != x)
 543                         ext2_error (sb, "ext2_check_inodes_bitmap",
 544                                     "Wrong free inodes count in group %d, "
 545                                     "stored = %d, counted = %lu", i,
 546                                     gdp->bg_free_inodes_count, x);
 547                 bitmap_count += x;
 548         }
 549         if (es->s_free_inodes_count != bitmap_count)
 550                 ext2_error (sb, "ext2_check_inodes_bitmap",
 551                             "Wrong free inodes count in super block, "
 552                             "stored = %lu, counted = %lu",
 553                             (unsigned long) es->s_free_inodes_count, bitmap_count);
 554         unlock_super (sb);
 555 }

/* [previous][next][first][last][top][bottom][index][help] */