On Wed, Jul 30, 2008 at 1:05 AM, Rohit Sharma <[EMAIL PROTECTED]> wrote:
> I was going through the function "ext2_find_near" in inode.c and could not
> interpret the meaning of the last part of this code :
>
> static ext2_fsblk_t ext2_find_near(struct inode *inode, Indirect *ind)
> {
>        struct ext2_inode_info *ei = EXT2_I(inode);
>        __le32 *start = ind->bh ? (__le32 *) ind->bh->b_data : ei->i_data;
>        __le32 *p;
>        ext2_fsblk_t bg_start;
>        ext2_fsblk_t colour;
>
>        /* Try to find previous block */
>       for (p = ind->p - 1; p >= start; p--)
>                if (*p)
>                        return le32_to_cpu(*p);
>
>        /* No such thing, so let's try location of indirect block */
>       if (ind->bh)
>                return ind->bh->b_blocknr;
>
>        /*
>         * It is going to be refered from inode itself? OK, just put it into
>         * the same cylinder group then.
>         */
>
>        bg_start = ext2_group_first_block_no(inode->i_sb, ei->i_block_group);
>
>        //what does the code below do?? why its is using pid of
> current process??

If I understand correctly, it is to allocate all the blocks of the
same pid near to each other. Total blocks per group is logically
divided into 16 and based on the pid one of the groups is chosen to
look for empty blocks.

Though I always felt it should be tgid :-) ... See the previous post

http://mail.nl.linux.org/kernelnewbies/2008-04/msg00497.html


Thanks -
Manish


>
>        colour = (current->pid % 16) *
>                        (EXT2_BLOCKS_PER_GROUP(inode->i_sb) / 16);
>       return bg_start + colour;
> }
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to [EMAIL PROTECTED]
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [EMAIL PROTECTED]
Please read the FAQ at http://kernelnewbies.org/FAQ

Reply via email to