All of lore.kernel.org
 help / color / mirror / Atom feed
* [filesystem] struct of m_inode
@ 2013-03-02  2:28 lx
  2013-03-02  2:46 ` Valdis.Kletnieks at vt.edu
  0 siblings, 1 reply; 2+ messages in thread
From: lx @ 2013-03-02  2:28 UTC (permalink / raw)
  To: kernelnewbies

Hi, I'm learning the kernel of 0.12, and the function in inode.c:
####################################################################
static int _bmap(struct m_inode * inode,int block,int create)
{
struct buffer_head * bh;
int i;

if (block<0)
panic("_bmap: block<0");
if (block >= 7+512+512*512)
panic("_bmap: block>big");
if (block<7) {
if (create && !inode->i_zone[block])
if (inode->i_zone[block]=new_block(inode->i_dev)) {
inode->i_ctime=CURRENT_TIME;
inode->i_dirt=1;
}
return inode->i_zone[block];
}
block -= 7;
if (block<512) {
if (create && !inode->i_zone[7])
if (inode->i_zone[7]=new_block(inode->i_dev)) {
inode->i_dirt=1;
inode->i_ctime=CURRENT_TIME;
}
if (!inode->i_zone[7])
return 0;
if (!(bh = bread(inode->i_dev,inode->i_zone[7])))
return 0;
i = ((unsigned short *) (bh->b_data))[block];
if (create && !i)
if (i=new_block(inode->i_dev)) {
((unsigned short *) (bh->b_data))[block]=i;
bh->b_dirt=1;
}
brelse(bh);
return i;
}
block -= 512;
if (create && !inode->i_zone[8])
if (inode->i_zone[8]=new_block(inode->i_dev)) {
inode->i_dirt=1;
inode->i_ctime=CURRENT_TIME;
}
if (!inode->i_zone[8])
return 0;
if (!(bh=bread(inode->i_dev,inode->i_zone[8])))
return 0;
i = ((unsigned short *)bh->b_data)[block>>9];
if (create && !i)
if (i=new_block(inode->i_dev)) {
((unsigned short *) (bh->b_data))[block>>9]=i;
bh->b_dirt=1;
}
brelse(bh);
if (!i)
return 0;
if (!(bh=bread(inode->i_dev,i)))
return 0;
i = ((unsigned short *)bh->b_data)[block&511];
if (create && !i)
if (i=new_block(inode->i_dev)) {
((unsigned short *) (bh->b_data))[block&511]=i;
bh->b_dirt=1;
}
brelse(bh);
return i;
}

########################################################################
"if (block >= 7+512+512*512)" because the i_zone[9].
But the question is why the i_zone[7] can repesent 512 , and i_zone[8] can
repesent 512*512 ?

Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130302/9220e3ef/attachment.html 

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

* [filesystem] struct of m_inode
  2013-03-02  2:28 [filesystem] struct of m_inode lx
@ 2013-03-02  2:46 ` Valdis.Kletnieks at vt.edu
  0 siblings, 0 replies; 2+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2013-03-02  2:46 UTC (permalink / raw)
  To: kernelnewbies

On Sat, 02 Mar 2013 10:28:26 +0800, lx said:

> "if (block >= 7+512+512*512)" because the i_zone[9].
> But the question is why the i_zone[7] can repesent 512 , and i_zone[8] can
> repesent 512*512 ?


Sngle, double, and triple indirect blocks...

http://en.wikipedia.org/wiki/Inode_pointer_structure
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130301/c5f1a7e5/attachment.bin 

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

end of thread, other threads:[~2013-03-02  2:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-02  2:28 [filesystem] struct of m_inode lx
2013-03-02  2:46 ` Valdis.Kletnieks at vt.edu

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.