public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: Mingming Cao <cmm@us.ibm.com>
Cc: linux-ext4@vger.kernel.org
Subject: Re: [RFC][PATCH 3/6] delalloc ENOSPC: reserve blocks
Date: Mon, 2 Jun 2008 12:25:14 +0530	[thread overview]
Message-ID: <20080602065514.GD26379@skywalker> (raw)
In-Reply-To: <20080602064433.GB26379@skywalker>

On Mon, Jun 02, 2008 at 12:14:33PM +0530, Aneesh Kumar K.V wrote:
> On Sun, Jun 01, 2008 at 04:35:55PM -0700, Mingming Cao wrote:
> > ext4: delalloc ENOSPC handling core
> > 
> > From: Mingming cao <cmm@us.ibm.com>
> > 
> > Core part of delaloc ENOSPC (block reservation.) 
> > data/meta blocks are reserved on write_begin(), and per-inode reserved counters
> > are updated  after block allocation.
> > 
> > Signed-off-by: Mingming cao <cmm@us.ibm.com>
> > 
> > ---
> >  fs/ext4/inode.c |   69 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
> >  1 file changed, 66 insertions(+), 3 deletions(-)
> > 
> > Index: linux-2.6.26-rc4/fs/ext4/inode.c
> > ===================================================================
> > --- linux-2.6.26-rc4.orig/fs/ext4/inode.c	2008-06-01 14:26:13.000000000 -0700
> > +++ linux-2.6.26-rc4/fs/ext4/inode.c	2008-06-01 15:04:06.000000000 -0700
> > @@ -38,6 +38,7 @@
> >  #include "ext4_jbd2.h"
> >  #include "xattr.h"
> >  #include "acl.h"
> > +#include "ext4_extents.h"
> > 
> >  static void ext4_invalidatepage(struct page *page, unsigned long offset);
> > 
> > @@ -1410,6 +1411,61 @@ static int ext4_journalled_write_end(str
> >  	return ret ? ret : copied;
> >  }
> > 
> > +static int ext4_da_reserve_space(struct inode *inode, int nrblocks)
> > +{
> > +       struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
> > +       unsigned long md_needed, mdblocks, total = 0;
> > +
> > +       /*
> > +        * calculate the amount of metadata blocks to reserve
> 
> 	 recalculate the amount of metadata blocks to reserve.
> 
> 
> 
> 
> > +	* in order to allocate nrblocks
> > +	* worse case is one extent per block
> > +	*/
> > +	total = EXT4_I(inode)->i_reserved_data_blocks + nrblocks;
> > +	mdblocks = ext4_ext_calc_metadata_amount(inode, total);
> > +	BUG_ON(mdblocks < EXT4_I(inode)->i_reserved_meta_blocks);
> > +
> > +	md_needed = mdblocks - EXT4_I(inode)->i_reserved_meta_blocks;
> > +	total = md_needed + nrblocks;
> > +
> > +	if (ext4_has_free_blocks(sbi, total) < total)
> > +		return -ENOSPC;
> > +
> > +	/* reduce fs free blocks counter */
> > +	percpu_counter_sub(&sbi->s_freeblocks_counter, total);
> > +
> > +	EXT4_I(inode)->i_reserved_data_blocks += nrblocks;
> > +	EXT4_I(inode)->i_reserved_meta_blocks += md_needed;
> 
> Better written as
> 	EXT4_I(inode)->i_reserved_meta_blocks += mdblocks;
> 
> 
	EXT4_I(inode)->i_reserved_meta_blocks = mdblocks;

-aneesh

  reply	other threads:[~2008-06-02  6:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-01 23:35 [RFC][PATCH 3/6] delalloc ENOSPC: reserve blocks Mingming Cao
2008-06-02  6:44 ` Aneesh Kumar K.V
2008-06-02  6:55   ` Aneesh Kumar K.V [this message]
2008-06-02  8:32 ` Aneesh Kumar K.V

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=20080602065514.GD26379@skywalker \
    --to=aneesh.kumar@linux.vnet.ibm.com \
    --cc=cmm@us.ibm.com \
    --cc=linux-ext4@vger.kernel.org \
    /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