OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [fs/] [ext/] [freelists.c] - Diff between revs 1765 and 1782

Only display areas with differences | Details | Blame | View Log

Rev 1765 Rev 1782
/*
/*
 *  linux/fs/ext/freelists.c
 *  linux/fs/ext/freelists.c
 *
 *
 *  Copyright (C) 1992  Remy Card (card@masi.ibp.fr)
 *  Copyright (C) 1992  Remy Card (card@masi.ibp.fr)
 *
 *
 */
 */
 
 
/* freelists.c contains the code that handles the inode and block free lists */
/* freelists.c contains the code that handles the inode and block free lists */
 
 
 
 
/*
/*
 
 
   The free blocks are managed by a linked list. The super block contains the
   The free blocks are managed by a linked list. The super block contains the
   number of the first free block. This block contains 254 numbers of other
   number of the first free block. This block contains 254 numbers of other
   free blocks and the number of the next block in the list.
   free blocks and the number of the next block in the list.
 
 
   When an ext fs is mounted, the number of the first free block is stored
   When an ext fs is mounted, the number of the first free block is stored
   in s->u.ext_sb.s_firstfreeblocknumber and the block header is stored in
   in s->u.ext_sb.s_firstfreeblocknumber and the block header is stored in
   s->u.ext_sb.s_firstfreeblock. u.ext_sb.s_freeblockscount contains the count
   s->u.ext_sb.s_firstfreeblock. u.ext_sb.s_freeblockscount contains the count
   of free blocks.
   of free blocks.
 
 
   The free inodes are also managed by a linked list in a similar way. The
   The free inodes are also managed by a linked list in a similar way. The
   super block contains the number of the first free inode. This inode contains
   super block contains the number of the first free inode. This inode contains
   14 numbers of other free inodes and the number of the next inode in the list.
   14 numbers of other free inodes and the number of the next inode in the list.
 
 
   The number of the first free inode is stored in
   The number of the first free inode is stored in
   s->u.ext_sb.s_firstfreeinodenumber and the header of the block containing
   s->u.ext_sb.s_firstfreeinodenumber and the header of the block containing
   the inode is stored in s->u.ext_sb.s_firstfreeinodeblock.
   the inode is stored in s->u.ext_sb.s_firstfreeinodeblock.
   u.ext_sb.s_freeinodescount contains the count of free inodes.
   u.ext_sb.s_freeinodescount contains the count of free inodes.
 
 
*/
*/
 
 
#include <linux/sched.h>
#include <linux/sched.h>
#include <linux/ext_fs.h>
#include <linux/ext_fs.h>
#include <linux/stat.h>
#include <linux/stat.h>
#include <linux/kernel.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/string.h>
#include <linux/locks.h>
#include <linux/locks.h>
 
 
void ext_free_block(struct super_block * sb, int block)
void ext_free_block(struct super_block * sb, int block)
{
{
        struct buffer_head * bh;
        struct buffer_head * bh;
        struct ext_free_block * efb;
        struct ext_free_block * efb;
 
 
        if (!sb) {
        if (!sb) {
                printk("trying to free block on non-existent device\n");
                printk("trying to free block on non-existent device\n");
                return;
                return;
        }
        }
        lock_super (sb);
        lock_super (sb);
        if (block < sb->u.ext_sb.s_firstdatazone ||
        if (block < sb->u.ext_sb.s_firstdatazone ||
            block >= sb->u.ext_sb.s_nzones) {
            block >= sb->u.ext_sb.s_nzones) {
                printk("trying to free block not in datazone\n");
                printk("trying to free block not in datazone\n");
                return;
                return;
        }
        }
        bh = get_hash_table(sb->s_dev, block, sb->s_blocksize);
        bh = get_hash_table(sb->s_dev, block, sb->s_blocksize);
        if (bh)
        if (bh)
                mark_buffer_clean(bh);
                mark_buffer_clean(bh);
        brelse(bh);
        brelse(bh);
        if (sb->u.ext_sb.s_firstfreeblock)
        if (sb->u.ext_sb.s_firstfreeblock)
                efb = (struct ext_free_block *) sb->u.ext_sb.s_firstfreeblock->b_data;
                efb = (struct ext_free_block *) sb->u.ext_sb.s_firstfreeblock->b_data;
        if (!sb->u.ext_sb.s_firstfreeblock || efb->count == 254) {
        if (!sb->u.ext_sb.s_firstfreeblock || efb->count == 254) {
#ifdef EXTFS_DEBUG
#ifdef EXTFS_DEBUG
printk("ext_free_block: block full, skipping to %d\n", block);
printk("ext_free_block: block full, skipping to %d\n", block);
#endif
#endif
                if (sb->u.ext_sb.s_firstfreeblock)
                if (sb->u.ext_sb.s_firstfreeblock)
                        brelse (sb->u.ext_sb.s_firstfreeblock);
                        brelse (sb->u.ext_sb.s_firstfreeblock);
                if (!(sb->u.ext_sb.s_firstfreeblock = bread (sb->s_dev,
                if (!(sb->u.ext_sb.s_firstfreeblock = bread (sb->s_dev,
                        block, sb->s_blocksize)))
                        block, sb->s_blocksize)))
                        panic ("ext_free_block: unable to read block to free\n");
                        panic ("ext_free_block: unable to read block to free\n");
                efb = (struct ext_free_block *) sb->u.ext_sb.s_firstfreeblock->b_data;
                efb = (struct ext_free_block *) sb->u.ext_sb.s_firstfreeblock->b_data;
                efb->next = sb->u.ext_sb.s_firstfreeblocknumber;
                efb->next = sb->u.ext_sb.s_firstfreeblocknumber;
                efb->count = 0;
                efb->count = 0;
                sb->u.ext_sb.s_firstfreeblocknumber = block;
                sb->u.ext_sb.s_firstfreeblocknumber = block;
        } else {
        } else {
                efb->free[efb->count++] = block;
                efb->free[efb->count++] = block;
        }
        }
        sb->u.ext_sb.s_freeblockscount ++;
        sb->u.ext_sb.s_freeblockscount ++;
        sb->s_dirt = 1;
        sb->s_dirt = 1;
        mark_buffer_dirty(sb->u.ext_sb.s_firstfreeblock, 1);
        mark_buffer_dirty(sb->u.ext_sb.s_firstfreeblock, 1);
        unlock_super (sb);
        unlock_super (sb);
        return;
        return;
}
}
 
 
int ext_new_block(struct super_block * sb)
int ext_new_block(struct super_block * sb)
{
{
        struct buffer_head * bh;
        struct buffer_head * bh;
        struct ext_free_block * efb;
        struct ext_free_block * efb;
        int j;
        int j;
 
 
        if (!sb) {
        if (!sb) {
                printk("trying to get new block from non-existent device\n");
                printk("trying to get new block from non-existent device\n");
                return 0;
                return 0;
        }
        }
        if (!sb->u.ext_sb.s_firstfreeblock)
        if (!sb->u.ext_sb.s_firstfreeblock)
                return 0;
                return 0;
        lock_super (sb);
        lock_super (sb);
        efb = (struct ext_free_block *) sb->u.ext_sb.s_firstfreeblock->b_data;
        efb = (struct ext_free_block *) sb->u.ext_sb.s_firstfreeblock->b_data;
        if (efb->count) {
        if (efb->count) {
                j = efb->free[--efb->count];
                j = efb->free[--efb->count];
                mark_buffer_dirty(sb->u.ext_sb.s_firstfreeblock, 1);
                mark_buffer_dirty(sb->u.ext_sb.s_firstfreeblock, 1);
        } else {
        } else {
#ifdef EXTFS_DEBUG
#ifdef EXTFS_DEBUG
printk("ext_new_block: block empty, skipping to %d\n", efb->next);
printk("ext_new_block: block empty, skipping to %d\n", efb->next);
#endif
#endif
                j = sb->u.ext_sb.s_firstfreeblocknumber;
                j = sb->u.ext_sb.s_firstfreeblocknumber;
                sb->u.ext_sb.s_firstfreeblocknumber = efb->next;
                sb->u.ext_sb.s_firstfreeblocknumber = efb->next;
                brelse (sb->u.ext_sb.s_firstfreeblock);
                brelse (sb->u.ext_sb.s_firstfreeblock);
                if (!sb->u.ext_sb.s_firstfreeblocknumber) {
                if (!sb->u.ext_sb.s_firstfreeblocknumber) {
                        sb->u.ext_sb.s_firstfreeblock = NULL;
                        sb->u.ext_sb.s_firstfreeblock = NULL;
                } else {
                } else {
                        if (!(sb->u.ext_sb.s_firstfreeblock = bread (sb->s_dev,
                        if (!(sb->u.ext_sb.s_firstfreeblock = bread (sb->s_dev,
                                sb->u.ext_sb.s_firstfreeblocknumber,
                                sb->u.ext_sb.s_firstfreeblocknumber,
                                sb->s_blocksize)))
                                sb->s_blocksize)))
                                panic ("ext_new_block: unable to read next free block\n");
                                panic ("ext_new_block: unable to read next free block\n");
                }
                }
        }
        }
        if (j < sb->u.ext_sb.s_firstdatazone || j > sb->u.ext_sb.s_nzones) {
        if (j < sb->u.ext_sb.s_firstdatazone || j > sb->u.ext_sb.s_nzones) {
                printk ("ext_new_block: blk = %d\n", j);
                printk ("ext_new_block: blk = %d\n", j);
                printk("allocating block not in data zone\n");
                printk("allocating block not in data zone\n");
                return 0;
                return 0;
        }
        }
        sb->u.ext_sb.s_freeblockscount --;
        sb->u.ext_sb.s_freeblockscount --;
        sb->s_dirt = 1;
        sb->s_dirt = 1;
 
 
        if (!(bh=getblk(sb->s_dev, j, sb->s_blocksize))) {
        if (!(bh=getblk(sb->s_dev, j, sb->s_blocksize))) {
                printk("new_block: cannot get block");
                printk("new_block: cannot get block");
                return 0;
                return 0;
        }
        }
        memset(bh->b_data, 0, BLOCK_SIZE);
        memset(bh->b_data, 0, BLOCK_SIZE);
        mark_buffer_uptodate(bh, 1);
        mark_buffer_uptodate(bh, 1);
        mark_buffer_dirty(bh, 1);
        mark_buffer_dirty(bh, 1);
        brelse(bh);
        brelse(bh);
#ifdef EXTFS_DEBUG
#ifdef EXTFS_DEBUG
printk("ext_new_block: allocating block %d\n", j);
printk("ext_new_block: allocating block %d\n", j);
#endif
#endif
        unlock_super (sb);
        unlock_super (sb);
        return j;
        return j;
}
}
 
 
unsigned long ext_count_free_blocks(struct super_block *sb)
unsigned long ext_count_free_blocks(struct super_block *sb)
{
{
#ifdef EXTFS_DEBUG
#ifdef EXTFS_DEBUG
        struct buffer_head * bh;
        struct buffer_head * bh;
        struct ext_free_block * efb;
        struct ext_free_block * efb;
        unsigned long count, block;
        unsigned long count, block;
 
 
        lock_super (sb);
        lock_super (sb);
        if (!sb->u.ext_sb.s_firstfreeblock)
        if (!sb->u.ext_sb.s_firstfreeblock)
                count = 0;
                count = 0;
        else {
        else {
                efb = (struct ext_free_block *) sb->u.ext_sb.s_firstfreeblock->b_data;
                efb = (struct ext_free_block *) sb->u.ext_sb.s_firstfreeblock->b_data;
                count = efb->count + 1;
                count = efb->count + 1;
                block = efb->next;
                block = efb->next;
                while (block) {
                while (block) {
                        if (!(bh = bread (sb->s_dev, block, sb->s_blocksize))) {
                        if (!(bh = bread (sb->s_dev, block, sb->s_blocksize))) {
                                printk ("ext_count_free: error while reading free blocks list\n");
                                printk ("ext_count_free: error while reading free blocks list\n");
                                block = 0;
                                block = 0;
                        } else {
                        } else {
                                efb = (struct ext_free_block *) bh->b_data;
                                efb = (struct ext_free_block *) bh->b_data;
                                count += efb->count + 1;
                                count += efb->count + 1;
                                block = efb->next;
                                block = efb->next;
                                brelse (bh);
                                brelse (bh);
                        }
                        }
                }
                }
        }
        }
printk("ext_count_free_blocks: stored = %d, computed = %d\n",
printk("ext_count_free_blocks: stored = %d, computed = %d\n",
        sb->u.ext_sb.s_freeblockscount, count);
        sb->u.ext_sb.s_freeblockscount, count);
        unlock_super (sb);
        unlock_super (sb);
        return count;
        return count;
#else
#else
        return sb->u.ext_sb.s_freeblockscount;
        return sb->u.ext_sb.s_freeblockscount;
#endif
#endif
}
}
 
 
void ext_free_inode(struct inode * inode)
void ext_free_inode(struct inode * inode)
{
{
        struct buffer_head * bh;
        struct buffer_head * bh;
        struct ext_free_inode * efi;
        struct ext_free_inode * efi;
        struct super_block * sb;
        struct super_block * sb;
        unsigned long block;
        unsigned long block;
        unsigned long ino;
        unsigned long ino;
        kdev_t dev;
        kdev_t dev;
 
 
        if (!inode)
        if (!inode)
                return;
                return;
        if (!inode->i_dev) {
        if (!inode->i_dev) {
                printk("free_inode: inode has no device\n");
                printk("free_inode: inode has no device\n");
                return;
                return;
        }
        }
        if (inode->i_count != 1) {
        if (inode->i_count != 1) {
                printk("free_inode: inode has count=%ld\n",inode->i_count);
                printk("free_inode: inode has count=%ld\n",inode->i_count);
                return;
                return;
        }
        }
        if (inode->i_nlink) {
        if (inode->i_nlink) {
                printk("free_inode: inode has nlink=%d\n",inode->i_nlink);
                printk("free_inode: inode has nlink=%d\n",inode->i_nlink);
                return;
                return;
        }
        }
        if (!inode->i_sb) {
        if (!inode->i_sb) {
                printk("free_inode: inode on non-existent device\n");
                printk("free_inode: inode on non-existent device\n");
                return;
                return;
        }
        }
        sb = inode->i_sb;
        sb = inode->i_sb;
        ino = inode->i_ino;
        ino = inode->i_ino;
        dev = inode->i_dev;
        dev = inode->i_dev;
        clear_inode(inode);
        clear_inode(inode);
        lock_super (sb);
        lock_super (sb);
        if (ino < 1 || ino > sb->u.ext_sb.s_ninodes) {
        if (ino < 1 || ino > sb->u.ext_sb.s_ninodes) {
                printk("free_inode: inode 0 or non-existent inode\n");
                printk("free_inode: inode 0 or non-existent inode\n");
                unlock_super (sb);
                unlock_super (sb);
                return;
                return;
        }
        }
        if (sb->u.ext_sb.s_firstfreeinodeblock)
        if (sb->u.ext_sb.s_firstfreeinodeblock)
                efi = ((struct ext_free_inode *) sb->u.ext_sb.s_firstfreeinodeblock->b_data) +
                efi = ((struct ext_free_inode *) sb->u.ext_sb.s_firstfreeinodeblock->b_data) +
                        (sb->u.ext_sb.s_firstfreeinodenumber-1)%EXT_INODES_PER_BLOCK;
                        (sb->u.ext_sb.s_firstfreeinodenumber-1)%EXT_INODES_PER_BLOCK;
        if (!sb->u.ext_sb.s_firstfreeinodeblock || efi->count == 14) {
        if (!sb->u.ext_sb.s_firstfreeinodeblock || efi->count == 14) {
#ifdef EXTFS_DEBUG
#ifdef EXTFS_DEBUG
printk("ext_free_inode: inode full, skipping to %d\n", ino);
printk("ext_free_inode: inode full, skipping to %d\n", ino);
#endif
#endif
                if (sb->u.ext_sb.s_firstfreeinodeblock)
                if (sb->u.ext_sb.s_firstfreeinodeblock)
                        brelse (sb->u.ext_sb.s_firstfreeinodeblock);
                        brelse (sb->u.ext_sb.s_firstfreeinodeblock);
                block = 2 + (ino - 1) / EXT_INODES_PER_BLOCK;
                block = 2 + (ino - 1) / EXT_INODES_PER_BLOCK;
                if (!(bh = bread(dev, block, sb->s_blocksize)))
                if (!(bh = bread(dev, block, sb->s_blocksize)))
                        panic("ext_free_inode: unable to read inode block\n");
                        panic("ext_free_inode: unable to read inode block\n");
                efi = ((struct ext_free_inode *) bh->b_data) +
                efi = ((struct ext_free_inode *) bh->b_data) +
                        (ino - 1) % EXT_INODES_PER_BLOCK;
                        (ino - 1) % EXT_INODES_PER_BLOCK;
                efi->next = sb->u.ext_sb.s_firstfreeinodenumber;
                efi->next = sb->u.ext_sb.s_firstfreeinodenumber;
                efi->count = 0;
                efi->count = 0;
                sb->u.ext_sb.s_firstfreeinodenumber = ino;
                sb->u.ext_sb.s_firstfreeinodenumber = ino;
                sb->u.ext_sb.s_firstfreeinodeblock = bh;
                sb->u.ext_sb.s_firstfreeinodeblock = bh;
        } else {
        } else {
                efi->free[efi->count++] = ino;
                efi->free[efi->count++] = ino;
        }
        }
        sb->u.ext_sb.s_freeinodescount ++;
        sb->u.ext_sb.s_freeinodescount ++;
        sb->s_dirt = 1;
        sb->s_dirt = 1;
        mark_buffer_dirty(sb->u.ext_sb.s_firstfreeinodeblock, 1);
        mark_buffer_dirty(sb->u.ext_sb.s_firstfreeinodeblock, 1);
        unlock_super (sb);
        unlock_super (sb);
}
}
 
 
struct inode * ext_new_inode(const struct inode * dir)
struct inode * ext_new_inode(const struct inode * dir)
{
{
        struct super_block * sb;
        struct super_block * sb;
        struct inode * inode;
        struct inode * inode;
        struct ext_free_inode * efi;
        struct ext_free_inode * efi;
        unsigned long block;
        unsigned long block;
        int j;
        int j;
 
 
        if (!dir || !(inode=get_empty_inode()))
        if (!dir || !(inode=get_empty_inode()))
                return NULL;
                return NULL;
        sb = dir->i_sb;
        sb = dir->i_sb;
        inode->i_sb = sb;
        inode->i_sb = sb;
        inode->i_flags = sb->s_flags;
        inode->i_flags = sb->s_flags;
        if (!sb->u.ext_sb.s_firstfreeinodeblock)
        if (!sb->u.ext_sb.s_firstfreeinodeblock)
                return 0;
                return 0;
        lock_super (sb);
        lock_super (sb);
        efi = ((struct ext_free_inode *) sb->u.ext_sb.s_firstfreeinodeblock->b_data) +
        efi = ((struct ext_free_inode *) sb->u.ext_sb.s_firstfreeinodeblock->b_data) +
                (sb->u.ext_sb.s_firstfreeinodenumber-1)%EXT_INODES_PER_BLOCK;
                (sb->u.ext_sb.s_firstfreeinodenumber-1)%EXT_INODES_PER_BLOCK;
        if (efi->count) {
        if (efi->count) {
                j = efi->free[--efi->count];
                j = efi->free[--efi->count];
                mark_buffer_dirty(sb->u.ext_sb.s_firstfreeinodeblock, 1);
                mark_buffer_dirty(sb->u.ext_sb.s_firstfreeinodeblock, 1);
        } else {
        } else {
#ifdef EXTFS_DEBUG
#ifdef EXTFS_DEBUG
printk("ext_free_inode: inode empty, skipping to %d\n", efi->next);
printk("ext_free_inode: inode empty, skipping to %d\n", efi->next);
#endif
#endif
                j = sb->u.ext_sb.s_firstfreeinodenumber;
                j = sb->u.ext_sb.s_firstfreeinodenumber;
                if (efi->next > sb->u.ext_sb.s_ninodes) {
                if (efi->next > sb->u.ext_sb.s_ninodes) {
                        printk ("efi->next = %ld\n", efi->next);
                        printk ("efi->next = %ld\n", efi->next);
                        panic ("ext_new_inode: bad inode number in free list\n");
                        panic ("ext_new_inode: bad inode number in free list\n");
                }
                }
                sb->u.ext_sb.s_firstfreeinodenumber = efi->next;
                sb->u.ext_sb.s_firstfreeinodenumber = efi->next;
                block = 2 + (((unsigned long) efi->next) - 1) / EXT_INODES_PER_BLOCK;
                block = 2 + (((unsigned long) efi->next) - 1) / EXT_INODES_PER_BLOCK;
                brelse (sb->u.ext_sb.s_firstfreeinodeblock);
                brelse (sb->u.ext_sb.s_firstfreeinodeblock);
                if (!sb->u.ext_sb.s_firstfreeinodenumber) {
                if (!sb->u.ext_sb.s_firstfreeinodenumber) {
                        sb->u.ext_sb.s_firstfreeinodeblock = NULL;
                        sb->u.ext_sb.s_firstfreeinodeblock = NULL;
                } else {
                } else {
                        if (!(sb->u.ext_sb.s_firstfreeinodeblock =
                        if (!(sb->u.ext_sb.s_firstfreeinodeblock =
                            bread(sb->s_dev, block, sb->s_blocksize)))
                            bread(sb->s_dev, block, sb->s_blocksize)))
                                panic ("ext_new_inode: unable to read next free inode block\n");
                                panic ("ext_new_inode: unable to read next free inode block\n");
                }
                }
        }
        }
        sb->u.ext_sb.s_freeinodescount --;
        sb->u.ext_sb.s_freeinodescount --;
        sb->s_dirt = 1;
        sb->s_dirt = 1;
        inode->i_count = 1;
        inode->i_count = 1;
        inode->i_nlink = 1;
        inode->i_nlink = 1;
        inode->i_dev = sb->s_dev;
        inode->i_dev = sb->s_dev;
        inode->i_uid = current->fsuid;
        inode->i_uid = current->fsuid;
        inode->i_gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid;
        inode->i_gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid;
        inode->i_dirt = 1;
        inode->i_dirt = 1;
        inode->i_ino = j;
        inode->i_ino = j;
        inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
        inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
        inode->i_op = NULL;
        inode->i_op = NULL;
        inode->i_blocks = inode->i_blksize = 0;
        inode->i_blocks = inode->i_blksize = 0;
        insert_inode_hash(inode);
        insert_inode_hash(inode);
#ifdef EXTFS_DEBUG
#ifdef EXTFS_DEBUG
printk("ext_new_inode : allocating inode %d\n", inode->i_ino);
printk("ext_new_inode : allocating inode %d\n", inode->i_ino);
#endif
#endif
        unlock_super (sb);
        unlock_super (sb);
        return inode;
        return inode;
}
}
 
 
unsigned long ext_count_free_inodes(struct super_block *sb)
unsigned long ext_count_free_inodes(struct super_block *sb)
{
{
#ifdef EXTFS_DEBUG
#ifdef EXTFS_DEBUG
        struct buffer_head * bh;
        struct buffer_head * bh;
        struct ext_free_inode * efi;
        struct ext_free_inode * efi;
        unsigned long count, block, ino;
        unsigned long count, block, ino;
 
 
        lock_super (sb);
        lock_super (sb);
        if (!sb->u.ext_sb.s_firstfreeinodeblock)
        if (!sb->u.ext_sb.s_firstfreeinodeblock)
                count = 0;
                count = 0;
        else {
        else {
                efi = ((struct ext_free_inode *) sb->u.ext_sb.s_firstfreeinodeblock->b_data) +
                efi = ((struct ext_free_inode *) sb->u.ext_sb.s_firstfreeinodeblock->b_data) +
                        ((sb->u.ext_sb.s_firstfreeinodenumber-1)%EXT_INODES_PER_BLOCK);
                        ((sb->u.ext_sb.s_firstfreeinodenumber-1)%EXT_INODES_PER_BLOCK);
                count = efi->count + 1;
                count = efi->count + 1;
                ino = efi->next;
                ino = efi->next;
                while (ino) {
                while (ino) {
                        if (ino < 1 || ino > sb->u.ext_sb.s_ninodes) {
                        if (ino < 1 || ino > sb->u.ext_sb.s_ninodes) {
                                printk ("u.ext_sb.s_firstfreeinodenumber = %d, ino = %d\n",
                                printk ("u.ext_sb.s_firstfreeinodenumber = %d, ino = %d\n",
                                        (int) sb->u.ext_sb.s_firstfreeinodenumber,ino);
                                        (int) sb->u.ext_sb.s_firstfreeinodenumber,ino);
                                panic ("ext_count_fre_inodes: bad inode number in free list\n");
                                panic ("ext_count_fre_inodes: bad inode number in free list\n");
                        }
                        }
                        block = 2 + ((ino - 1) / EXT_INODES_PER_BLOCK);
                        block = 2 + ((ino - 1) / EXT_INODES_PER_BLOCK);
                        if (!(bh = bread (sb->s_dev, block, sb->s_blocksize))) {
                        if (!(bh = bread (sb->s_dev, block, sb->s_blocksize))) {
                                printk ("ext_count_free_inodes: error while reading free inodes list\n");
                                printk ("ext_count_free_inodes: error while reading free inodes list\n");
                                block = 0;
                                block = 0;
                        } else {
                        } else {
                                efi = ((struct ext_free_inode *) bh->b_data) +
                                efi = ((struct ext_free_inode *) bh->b_data) +
                                        ((ino - 1) % EXT_INODES_PER_BLOCK);
                                        ((ino - 1) % EXT_INODES_PER_BLOCK);
                                count += efi->count + 1;
                                count += efi->count + 1;
                                ino = efi->next;
                                ino = efi->next;
                                brelse (bh);
                                brelse (bh);
                        }
                        }
                }
                }
        }
        }
printk("ext_count_free_inodes: stored = %d, computed = %d\n",
printk("ext_count_free_inodes: stored = %d, computed = %d\n",
        sb->u.ext_sb.s_freeinodescount, count);
        sb->u.ext_sb.s_freeinodescount, count);
        unlock_super (sb);
        unlock_super (sb);
        return count;
        return count;
#else
#else
        return sb->u.ext_sb.s_freeinodescount;
        return sb->u.ext_sb.s_freeinodescount;
#endif
#endif
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.