LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* about ext3_readpage
       [not found] <3182720c0711131917i1596e883qb27041d830ba39b3@mail.gmail.com>
@ 2007-11-14  3:34 ` Wang Yu
  2007-11-19 15:14   ` Jan Kara
  0 siblings, 1 reply; 2+ messages in thread
From: Wang Yu @ 2007-11-14  3:34 UTC (permalink / raw)
  To: linux-kernel

Hi, all
when I read ext3_readpage function following
ext3_readpage->mpage_readpage->do_mpage_readpage, there are:

nblocks = map_bh->b_size >> blkbits;
        if (buffer_mapped(map_bh) && block_in_file > *first_logical_block &&
                        block_in_file < (*first_logical_block + nblocks)) {
                unsigned map_offset = block_in_file - *first_logical_block;
                unsigned last = nblocks - map_offset;

                for (relative_block = 0; ; relative_block++) {
                        if (relative_block == last) {
                                clear_buffer_mapped(map_bh);
                                break;
                        }
                        if (page_block == blocks_per_page)
                                break;
                        blocks[page_block] = map_bh->b_blocknr + map_offset +
                                                relative_block;
                        page_block++;
                        block_in_file++;
                }
                bdev = map_bh->b_bdev;
        }

Since map_bh->b_size is the size of the block buffer, and blkbits is
associated with the block in inode, why does he do the operation >> ?
And what is the meaning and usage of  first_logical_block? the initial
value of it is 0.

Hope someone will help me!
Thanks!

-- 
National Research Center for Intelligent Computing Systems
Institute of Computing Technology, Chinese Academy of Sciences

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

* Re: about ext3_readpage
  2007-11-14  3:34 ` about ext3_readpage Wang Yu
@ 2007-11-19 15:14   ` Jan Kara
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2007-11-19 15:14 UTC (permalink / raw)
  To: Wang Yu; +Cc: linux-kernel

  Hi,

> when I read ext3_readpage function following
> ext3_readpage->mpage_readpage->do_mpage_readpage, there are:
> 
> nblocks = map_bh->b_size >> blkbits;
>         if (buffer_mapped(map_bh) && block_in_file > *first_logical_block &&
>                         block_in_file < (*first_logical_block + nblocks)) {
>                 unsigned map_offset = block_in_file - *first_logical_block;
>                 unsigned last = nblocks - map_offset;
> 
>                 for (relative_block = 0; ; relative_block++) {
>                         if (relative_block == last) {
>                                 clear_buffer_mapped(map_bh);
>                                 break;
>                         }
>                         if (page_block == blocks_per_page)
>                                 break;
>                         blocks[page_block] = map_bh->b_blocknr + map_offset +
>                                                 relative_block;
>                         page_block++;
>                         block_in_file++;
>                 }
>                 bdev = map_bh->b_bdev;
>         }
> 
> Since map_bh->b_size is the size of the block buffer, and blkbits is
> associated with the block in inode, why does he do the operation >> ?
> And what is the meaning and usage of  first_logical_block? the initial
> value of it is 0.
  Hmm, the code is quite "inventive" in the way it uses struct
buffer_head - does anybody know if we have this documented anywhere BTW?
  In b_size it keeps the size of area it would like to map, filesystem
on the other hand returns in it how much it managed to map from the
required area. This number is in bytes, thus it has to be divided by the
size of the block ( >>blkbits is just a more effective way to code
division). Variable first_logical_block keeps offset (in blocks) at
which the last call to get_block() happened.

								Honza
-- 
Jan Kara <jack@suse.cz>
SuSE CR Labs

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

end of thread, other threads:[~2007-11-19 15:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <3182720c0711131917i1596e883qb27041d830ba39b3@mail.gmail.com>
2007-11-14  3:34 ` about ext3_readpage Wang Yu
2007-11-19 15:14   ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).