mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Wang Yu <wangyuict@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: about ext3_readpage
Date: Mon, 19 Nov 2007 16:14:52 +0100	[thread overview]
Message-ID: <20071119151452.GD14481@atrey.karlin.mff.cuni.cz> (raw)
In-Reply-To: <3182720c0711131934t328440aey6e42a400a1c73a51@mail.gmail.com>

  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

      reply	other threads:[~2007-11-19 15:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3182720c0711131917i1596e883qb27041d830ba39b3@mail.gmail.com>
2007-11-14  3:34 ` Wang Yu
2007-11-19 15:14   ` Jan Kara [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071119151452.GD14481@atrey.karlin.mff.cuni.cz \
    --to=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wangyuict@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®