linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@us.ibm.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: linux-ext4 <linux-ext4@vger.kernel.org>,
	Keith Mannthey <kmannth@us.ibm.com>,
	Mingming Cao <mcao@us.ibm.com>
Subject: Re: [PATCH] fix up flex groups used_dirs manipulation
Date: Mon, 22 Mar 2010 22:13:19 -0700	[thread overview]
Message-ID: <20100323051319.GR29604@tux1.beaverton.ibm.com> (raw)
In-Reply-To: <4BA836C9.1050104@redhat.com>

On Mon, Mar 22, 2010 at 10:34:33PM -0500, Eric Sandeen wrote:
> Darrick J. Wong wrote:
> 
> ...
> > Unfortunately, this second behavior means that the "find the least full
> > blockgroup" code can use stale data in its comparisons.  Am I correct that
> > something is wrong here, or have I misinterpreted the code?  Is it /supposed/
> > to be the case that used_dirs reflects the number of directories in the
> > blockgroup at *mount time* and not at the current time?
> >   
> This does seem weird; the flex_group dir counters are indeed only updated
> at mount time:
> 
> ext4_fill_super
>         ext4_fill_flex_info
>                 atomic_add(ext4_used_dirs_count(sb, gdp),
>                            &sbi->s_flex_groups[flex_group].used_dirs);
> 
> and yet it's read repeatedly in get_orlov_stats:
> 
> 2 ialloc.c get_orlov_stats      430 stats->used_dirs = atomic_read(&flex_group[g].used_dirs);
> 
> I think this patch:
> 
> commit 7d39db14a42cbd719c7515b9da8f85a2eb6a0633
> [PATCH] ext4: Use struct flex_groups to calculate get_orlov_stats()
> 
> "missed" a bit, maybe a cut and paste error:
> 
>  @@ -267,6 +267,13 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
>                         if (is_directory) {
>                                 count = ext4_used_dirs_count(sb, gdp) - 1;
>                                 ext4_used_dirs_set(sb, gdp, count);
> +                               if (sbi->s_log_groups_per_flex) {
> +                                       ext4_group_t f;
> +
> +                                       f = ext4_flex_group(sbi, block_group);
> +                                       atomic_dec(&sbi->s_flex_groups[f].free_inodes);
> +                               }
> 
> why would we be decremeting free inodes in free_inode?  And then later
> in the function we atomic_inc it again.  Very odd, and likely a thinko.
> 
> I think the following patch fixes it up, although it seems like we should
> probably introduce (another) wrapper to set these counts in the gdp as
> well as the flex groups if they are present, so we don't always have
> to remember to manually hit both.
> 
> There also seems to be some inconsistency about when we update the flex
> grp vs the group descriptor, but I may be reading things wrong; ext4_new_inode
> decrements the flex group free inode count, but ext4_claim_inode decrements
> the gdp free inode count?  I may be missing something there.
> 
> Anyway - does this make things behave more as expected?

Offhand, it looks like this works, so:
Acked-By: Darrick J. Wong <djwong@us.ibm.com>

--D
> 
> -------- patch follows ----------
> 
> When used_dirs was introduced for the flex_groups struct, it looks
> like the accounting was not put into place properly, in some places
> manipulating free_inodes rather than used_dirs.
> 
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
> index f3624ea..3a5c7ec 100644
> --- a/fs/ext4/ialloc.c
> +++ b/fs/ext4/ialloc.c
> @@ -268,7 +268,7 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
>  					ext4_group_t f;
> 
>  					f = ext4_flex_group(sbi, block_group);
> -					atomic_dec(&sbi->s_flex_groups[f].free_inodes);
> +					atomic_dec(&sbi->s_flex_groups[f].used_dirs);
>  				}
> 
>  			}
> @@ -779,7 +779,7 @@ static int ext4_claim_inode(struct super_block *sb,
>  		if (sbi->s_log_groups_per_flex) {
>  			ext4_group_t f = ext4_flex_group(sbi, group);
> 
> -			atomic_inc(&sbi->s_flex_groups[f].free_inodes);
> +			atomic_inc(&sbi->s_flex_groups[f].used_dirs);
>  		}
>  	}
> 
>  	gdp->bg_checksum = ext4_group_desc_csum(sbi, group, gdp);
> 
> --
> 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

  reply	other threads:[~2010-03-23  5:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-23  0:21 bug in inode allocator? Darrick J. Wong
2010-03-23  3:34 ` [PATCH] fix up flex groups used_dirs manipulation Eric Sandeen
2010-03-23  5:13   ` Darrick J. Wong [this message]
2010-03-24  0:37   ` tytso
2010-03-24 13:57     ` Eric Sandeen

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=20100323051319.GR29604@tux1.beaverton.ibm.com \
    --to=djwong@us.ibm.com \
    --cc=kmannth@us.ibm.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=mcao@us.ibm.com \
    --cc=sandeen@redhat.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;
as well as URLs for NNTP newsgroup(s).