public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Mingming <cmm@us.ibm.com>
To: Dmitry Monakhov <dmonakhov@openvz.org>
Cc: linux-ext4@vger.kernel.org, Jan Kara <jack@suse.cz>
Subject: Re: [PATCH 3/4] ext4: quota macros cleanup
Date: Mon, 07 Dec 2009 16:59:31 -0800	[thread overview]
Message-ID: <1260233971.4206.142.camel@mingming-laptop> (raw)
In-Reply-To: <1259132261-16785-3-git-send-email-dmonakhov@openvz.org>

On Wed, 2009-11-25 at 09:57 +0300, Dmitry Monakhov wrote:
> Currently all quota block reservation macros contains hard-coded "2"
> aka MAXQUOTAS value. This is no good because in some places it is not
> obvious to understand what does this digit represent. Let's introduce
> new macro with self descriptive name.
> 
> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
looks sane, MAXQUOTAS is either user or group quota.

Acked-by: Mingming Cao <cmm@us.ibm.com>

> ---
>  fs/ext4/ext4_jbd2.h |    8 ++++++--
>  fs/ext4/extents.c   |    2 +-
>  fs/ext4/inode.c     |    2 +-
>  fs/ext4/migrate.c   |    4 ++--
>  fs/ext4/namei.c     |    8 ++++----
>  5 files changed, 14 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h
> index a286598..404ab6c 100644
> --- a/fs/ext4/ext4_jbd2.h
> +++ b/fs/ext4/ext4_jbd2.h
> @@ -49,7 +49,7 @@
> 
>  #define EXT4_DATA_TRANS_BLOCKS(sb)	(EXT4_SINGLEDATA_TRANS_BLOCKS(sb) + \
>  					 EXT4_XATTR_TRANS_BLOCKS - 2 + \
> -					 2*EXT4_QUOTA_TRANS_BLOCKS(sb))
> +					 EXT4_MAXQUOTAS_TRANS_BLOCKS(sb))
> 
>  /*
>   * Define the number of metadata blocks we need to account to modify data.
> @@ -57,7 +57,7 @@
>   * This include super block, inode block, quota blocks and xattr blocks
>   */
>  #define EXT4_META_TRANS_BLOCKS(sb)	(EXT4_XATTR_TRANS_BLOCKS + \
> -					2*EXT4_QUOTA_TRANS_BLOCKS(sb))
> +					EXT4_MAXQUOTAS_TRANS_BLOCKS(sb))
> 
>  /* Delete operations potentially hit one directory's namespace plus an
>   * entire inode, plus arbitrary amounts of bitmap/indirection data.  Be
> @@ -92,6 +92,7 @@
>   * but inode, sb and group updates are done only once */
>  #define EXT4_QUOTA_INIT_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_INIT_ALLOC*\
>  		(EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)+3+DQUOT_INIT_REWRITE) : 0)
> +
>  #define EXT4_QUOTA_DEL_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_DEL_ALLOC*\
>  		(EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)+3+DQUOT_DEL_REWRITE) : 0)
>  #else
> @@ -99,6 +100,9 @@
>  #define EXT4_QUOTA_INIT_BLOCKS(sb) 0
>  #define EXT4_QUOTA_DEL_BLOCKS(sb) 0
>  #endif
> +#define EXT4_MAXQUOTAS_TRANS_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_TRANS_BLOCKS(sb))
> +#define EXT4_MAXQUOTAS_INIT_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_INIT_BLOCKS(sb))
> +#define EXT4_MAXQUOTAS_DEL_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_DEL_BLOCKS(sb))
> 
>  int
>  ext4_mark_iloc_dirty(handle_t *handle,
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 715264b..f73c3ff 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -2167,7 +2167,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
>  			correct_index = 1;
>  			credits += (ext_depth(inode)) + 1;
>  		}
> -		credits += 2 * EXT4_QUOTA_TRANS_BLOCKS(inode->i_sb);
> +		credits += EXT4_MAXQUOTAS_TRANS_BLOCKS(inode->i_sb);
> 
>  		err = ext4_ext_truncate_extend_restart(handle, inode, credits);
>  		if (err)
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 979362d..211722b 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -5438,7 +5438,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
> 
>  		/* (user+group)*(old+new) structure, inode write (sb,
>  		 * inode block, ? - but truncate inode update has it) */
> -		handle = ext4_journal_start(inode, 2*(EXT4_QUOTA_INIT_BLOCKS(inode->i_sb)+
> +		handle = ext4_journal_start(inode, (EXT4_MAXQUOTAS_INIT_BLOCKS(inode->i_sb)+
>  					EXT4_QUOTA_DEL_BLOCKS(inode->i_sb))+3);
>  		if (IS_ERR(handle)) {
>  			error = PTR_ERR(handle);
> diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
> index a93d5b8..8646149 100644
> --- a/fs/ext4/migrate.c
> +++ b/fs/ext4/migrate.c
> @@ -238,7 +238,7 @@ static int extend_credit_for_blkdel(handle_t *handle, struct inode *inode)
>  	 * So allocate a credit of 3. We may update
>  	 * quota (user and group).
>  	 */
> -	needed = 3 + 2*EXT4_QUOTA_TRANS_BLOCKS(inode->i_sb);
> +	needed = 3 + EXT4_MAXQUOTAS_TRANS_BLOCKS(inode->i_sb);
> 
>  	if (ext4_journal_extend(handle, needed) != 0)
>  		retval = ext4_journal_restart(handle, needed);
> @@ -477,7 +477,7 @@ int ext4_ext_migrate(struct inode *inode)
>  	handle = ext4_journal_start(inode,
>  					EXT4_DATA_TRANS_BLOCKS(inode->i_sb) +
>  					EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
> -					2 * EXT4_QUOTA_INIT_BLOCKS(inode->i_sb)
> +					EXT4_MAXQUOTAS_INIT_BLOCKS(inode->i_sb)
>  					+ 1);
>  	if (IS_ERR(handle)) {
>  		retval = PTR_ERR(handle);
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index fde08c9..17a17e1 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -1769,7 +1769,7 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, int mode,
>  retry:
>  	handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
>  					EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
> -					2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb));
> +					EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
>  	if (IS_ERR(handle))
>  		return PTR_ERR(handle);
> 
> @@ -1803,7 +1803,7 @@ static int ext4_mknod(struct inode *dir, struct dentry *dentry,
>  retry:
>  	handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
>  					EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
> -					2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb));
> +					EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
>  	if (IS_ERR(handle))
>  		return PTR_ERR(handle);
> 
> @@ -1840,7 +1840,7 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode)
>  retry:
>  	handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
>  					EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
> -					2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb));
> +					EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
>  	if (IS_ERR(handle))
>  		return PTR_ERR(handle);
> 
> @@ -2253,7 +2253,7 @@ static int ext4_symlink(struct inode *dir,
>  retry:
>  	handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
>  					EXT4_INDEX_EXTRA_TRANS_BLOCKS + 5 +
> -					2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb));
> +					EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
>  	if (IS_ERR(handle))
>  		return PTR_ERR(handle);
> 



  parent reply	other threads:[~2009-12-08  0:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-25  6:57 [PATCH 1/4] ext4: ext4_get_reserved_space() must return bytes instead of blocks Dmitry Monakhov
2009-11-25  6:57 ` [PATCH 2/4] ext4: fix reserved space transferring on chown() [V2] Dmitry Monakhov
2009-11-25  6:57   ` [PATCH 3/4] ext4: quota macros cleanup Dmitry Monakhov
2009-11-25  6:57     ` [PATCH 4/4] ext4: fix incorrect block reservation on quota transfer Dmitry Monakhov
2009-12-08  1:02       ` Mingming
2009-12-08  6:48         ` Dmitry Monakhov
2009-12-08  0:59     ` Mingming [this message]
2009-12-07 17:18   ` [PATCH 2/4] ext4: fix reserved space transferring on chown() [V2] Aneesh Kumar K.V
2009-12-07 19:41     ` Dmitry Monakhov
2009-12-09  1:42       ` tytso
2009-12-09  2:03         ` Dmitry Monakhov
2009-12-08 23:06   ` Mingming
2009-11-25 16:32 ` [PATCH 1/4] ext4: ext4_get_reserved_space() must return bytes instead of blocks Eric Sandeen
2009-12-08  1:04 ` Mingming
  -- strict thread matches above, loose matches on Subject: below --
2009-11-23 18:30 [PATCH 1/4] ext4: delalloc quota fixes Dmitry Monakhov
2009-11-23 22:58 ` Dmitry Monakhov
2009-11-23 22:58   ` [PATCH 2/4] ext4: fix race chown vs truncate Dmitry Monakhov
2009-11-23 22:58     ` [PATCH 3/4] ext4: quota macros cleanup Dmitry Monakhov
2009-11-23 18:13 ext4+quota patch series Dmitry Monakhov
2009-11-23 18:33 ` [PATCH 3/4] ext4: quota macros cleanup Dmitry Monakhov

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=1260233971.4206.142.camel@mingming-laptop \
    --to=cmm@us.ibm.com \
    --cc=dmonakhov@openvz.org \
    --cc=jack@suse.cz \
    --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