Re: block allocation for ext2_mkdir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Dec 20, 2008 at 3:18 AM, Rohit Sharma <imreckless@xxxxxxxxx> wrote:
> in ext2/balloc.c
> i saw a function ext2_new_blocks()
> its the core function to allocate blocks, it has been specified there.
>
> So all the blocks that are allocated in the file system is through
> this function only ,
> am i correct ?

In this ext2_new_blocks() function, between retry_alloc: and the
allocated: symbol:

retry_alloc:
        gdp = ext2_get_group_desc(sb, group_no, &gdp_bh);
        if (!gdp)
                goto io_error;

        free_blocks = le16_to_cpu(gdp->bg_free_blocks_count);
        /*
<snip>
<snip>

        /*
         * We may end up a bogus ealier ENOSPC error due to
         * filesystem is "full" of reservations, but
         * there maybe indeed free blocks avaliable on disk
         * In this case, we just forget about the reservations
         * just do block allocation as without reservations.
         */
        if (my_rsv) {
                my_rsv = NULL;
                windowsz = 0;
                group_no = goal_group;
                goto retry_alloc;
        }
        /* No space left on the device */
        *errp = -ENOSPC;
        goto out;

allocated:

It seemed that you can copy the chunk and modify it to your
requirement - which is to allocate only from a particular block group.
  And you have also to modify it so that if the group_no is not
available anymore than ENOSPC must be returned.

But then this is too low level.

Reading Documentation/filesystem/ext2.txt, it says that:

"The inode allocation code tries to assign inodes which are in the same
block group as the directory in which they are first created."

So if you create an API that create a directory in a particular block
group, and then let the file be created naturally, it should end up in
the same block group.   Just create the file, and check the inode
later.   If it is not in the same block group, most likely u have run
out of space within the block group.

Modify at the highest possible ext2 level (API specified in
ext2_file_operations, and ext2_dir_operations).

-- 
Regards,
Peter Teoh

Ernest Hemingway - "Never mistake motion for action."

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux