All of lore.kernel.org
 help / color / mirror / Atom feed
* ext2_find_near()
@ 2012-11-14  3:44 Anders Lind
  2012-11-15  7:00 ` ext2_find_near() Abhijit Pawar
  0 siblings, 1 reply; 2+ messages in thread
From: Anders Lind @ 2012-11-14  3:44 UTC (permalink / raw)
  To: kernelnewbies

Hi all,

Sorry to bother.
for ext2_find_near(), why we tro to find near block by tring priveous block? Why not forward?


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;






Thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20121113/8ef82d62/attachment.html 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* ext2_find_near()
  2012-11-14  3:44 ext2_find_near() Anders Lind
@ 2012-11-15  7:00 ` Abhijit Pawar
  0 siblings, 0 replies; 2+ messages in thread
From: Abhijit Pawar @ 2012-11-15  7:00 UTC (permalink / raw)
  To: kernelnewbies

On 11/14/2012 09:14 AM, Anders Lind wrote:
> Hi all,
> 
> Sorry to bother.
> for ext2_find_near(), why we tro to find near block by tring priveous block? Why not forward?
> 
> 
> 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;
> 
> 
> 
> 
> 
> 
> Thank you!
> 
> 
To reduce the file fragmentation problem, EXT2 tries to get the block
near the block which is already allocated. So we backtrack to see if we
have any block free which is already there in our list instead of
allocating a new block in some other group.

> 
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> 


-- 
-
Abhijit

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-11-15  7:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-14  3:44 ext2_find_near() Anders Lind
2012-11-15  7:00 ` ext2_find_near() Abhijit Pawar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.