From: Mingming Cao <cmm@us.ibm.com>
To: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: tytso@mit.edu, sandeen@redhat.com, linux-ext4@vger.kernel.org
Subject: Re: [PATCH] ext4: limit nrblocks properly with non extent format
Date: Tue, 19 Aug 2008 11:07:30 -0700 [thread overview]
Message-ID: <1219169250.6416.0.camel@mingming-laptop> (raw)
In-Reply-To: <1219128494-10402-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
在 2008-08-19二的 12:18 +0530,Aneesh Kumar K.V写道:
> We need to make sure adding new buffer_head to the
> contiguous block extent doesn't result in nrblocks
> greater than EXT4_MAX_TRANS_DATA. We only have
> enought credit to insert EXT4_MAX_TRANS_DATA blocks.
>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Reviewed-by: Mingming Cao <cmm@us.ibm.com>
> ---
> fs/ext4/inode.c | 38 +++++++++++++++++++++++++-------------
> 1 files changed, 25 insertions(+), 13 deletions(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index dcd1337..a10f8e5 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -1909,27 +1909,39 @@ static int mpage_da_map_blocks(struct mpage_da_data *mpd)
> static void mpage_add_bh_to_extent(struct mpage_da_data *mpd,
> sector_t logical, struct buffer_head *bh)
> {
> - struct buffer_head *lbh = &mpd->lbh;
> sector_t next;
> + size_t b_size = bh->b_size;
> + struct buffer_head *lbh = &mpd->lbh;
> int nrblocks = lbh->b_size >> mpd->inode->i_blkbits;
>
> /* check if thereserved journal credits might overflow */
> - if (!(EXT4_I(mpd->inode)->i_flags & EXT4_EXTENTS_FL) &&
> - (nrblocks >= EXT4_MAX_TRANS_DATA))
> - /*
> - * With noextent format we are limited by the journal
> - * credit available. Total credit needed to insert
> - * nrblocks contiguous blocks is dependent on the
> - * nrblocks. So limit nrblocks.
> - */
> - goto flush_it;
> -
> + if (!(EXT4_I(mpd->inode)->i_flags & EXT4_EXTENTS_FL)) {
> + if (nrblocks >= EXT4_MAX_TRANS_DATA) {
> + /*
> + * With noextent format we are limited by the journal
> + * credit available. Total credit needed to insert
> + * nrblocks contiguous blocks is dependent on the
> + * nrblocks. So limit nrblocks.
> + */
> + goto flush_it;
> + } else if ((nrblocks + (b_size >> mpd->inode->i_blkbits)) >
> + EXT4_MAX_TRANS_DATA) {
> + /*
> + * Adding the new buffer_head would make it cross the
> + * allowed limit for which we have journal credit
> + * reserved. So limit the new bh->b_size
> + */
> + b_size = (EXT4_MAX_TRANS_DATA - nrblocks) <<
> + mpd->inode->i_blkbits;
> + /* we will do mpage_da_submit_io in the next loop */
> + }
> + }
> /*
> * First block in the extent
> */
> if (lbh->b_size == 0) {
> lbh->b_blocknr = logical;
> - lbh->b_size = bh->b_size;
> + lbh->b_size = b_size;
> lbh->b_state = bh->b_state & BH_FLAGS;
> return;
> }
> @@ -1939,7 +1951,7 @@ static void mpage_add_bh_to_extent(struct mpage_da_data *mpd,
> * Can we merge the block to our big extent?
> */
> if (logical == next && (bh->b_state & BH_FLAGS) == lbh->b_state) {
> - lbh->b_size += bh->b_size;
> + lbh->b_size += b_size;
> return;
> }
>
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2008-08-19 18:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-19 6:48 [PATCH] ext4: limit nrblocks properly with non extent format Aneesh Kumar K.V
2008-08-19 6:48 ` [PATCH] ext4: Code cleanups Aneesh Kumar K.V
2008-08-19 18:29 ` Mingming Cao
2008-08-19 18:07 ` Mingming Cao [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=1219169250.6416.0.camel@mingming-laptop \
--to=cmm@us.ibm.com \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=linux-ext4@vger.kernel.org \
--cc=sandeen@redhat.com \
--cc=tytso@mit.edu \
/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;
as well as URLs for NNTP newsgroup(s).