From mboxrd@z Thu Jan 1 00:00:00 1970 From: abhi.c.pawar@gmail.com (Abhijit Pawar) Date: Thu, 15 Nov 2012 12:30:36 +0530 Subject: ext2_find_near() In-Reply-To: <1352864697.60457.YahooMailNeo@web164601.mail.gq1.yahoo.com> References: <1352864697.60457.YahooMailNeo@web164601.mail.gq1.yahoo.com> Message-ID: <50A49314.4080804@gmail.com> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org 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