From: Christoph Hellwig <hch@infradead.org>
To: Dave Chinner <david@fromorbit.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 2/5] xfs: use generic percpu counters for inode counter
Date: Mon, 2 Feb 2015 08:44:09 -0800 [thread overview]
Message-ID: <20150202164409.GA695@infradead.org> (raw)
In-Reply-To: <1422826983-29570-3-git-send-email-david@fromorbit.com>
> diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
> index 4cf335b..7bfa527 100644
> --- a/fs/xfs/libxfs/xfs_sb.c
> +++ b/fs/xfs/libxfs/xfs_sb.c
> @@ -357,7 +357,8 @@ __xfs_sb_from_disk(
> to->sb_rextslog = from->sb_rextslog;
> to->sb_inprogress = from->sb_inprogress;
> to->sb_imax_pct = from->sb_imax_pct;
> - to->sb_icount = be64_to_cpu(from->sb_icount);
> + if (percpu_counter_initialized(&to->sb_icount))
> + percpu_counter_set(&to->sb_icount, be64_to_cpu(from->sb_icount));
Why would the percpu counter not be initialized here? Oh, I guess
this is for xfs_sb_verify(). But why can't xfs_mount_validate_sb simply
operate on the disk endian SB to avoid that whole issue?
> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> index 6015f54..df5ec55 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -1127,13 +1127,13 @@ xfs_mod_incore_sb_unlocked(
> */
> switch (field) {
> case XFS_SBS_ICOUNT:
> + /* deltas are +/-64, hence the large batch size of 128. */
> + __percpu_counter_add(&mp->m_sb.sb_icount, delta, 128);
> + if (percpu_counter_compare(&mp->m_sb.sb_icount, 0) < 0) {
> ASSERT(0);
> + percpu_counter_add(&mp->m_sb.sb_icount, -delta);
> return -EINVAL;
> }
> return 0;
> case XFS_SBS_IFREE:
> lcounter = (long long)mp->m_sb.sb_ifree;
> @@ -1288,8 +1288,11 @@ xfs_mod_incore_sb(
> int status;
>
> #ifdef HAVE_PERCPU_SB
> - ASSERT(field < XFS_SBS_ICOUNT || field > XFS_SBS_FDBLOCKS);
> + ASSERT(field < XFS_SBS_IFREE || field > XFS_SBS_FDBLOCKS);
> #endif
> + if (field == XFS_SBS_ICOUNT)
> + return xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd);
> +
Why is this multiplexd through xfs_mod_incore_sb_unlocked while needing
a different locking context? Shouldn't we simply use a different helper
for this case?
> xfs_icsb_cnts_t *cntp;
> int i;
>
> + i = percpu_counter_init(&mp->m_sb.sb_icount, 0, GFP_KERNEL);
> + if (i)
> + return ENOMEM;
> +
> mp->m_sb_cnts = alloc_percpu(xfs_icsb_cnts_t);
> - if (mp->m_sb_cnts == NULL)
> + if (!mp->m_sb_cnts) {
> + percpu_counter_destroy(&mp->m_sb.sb_icount);
> return -ENOMEM;
> + }
>
> for_each_online_cpu(i) {
Reusing a variable for both an errno value and a loop iterator is
not very readable, just add an additional "error" variabe.
Also percpu_counter_init returns a proper egative errno value, no need
to turn that into the incorrect postive ENOMEM.
Additionally should this use goto unwining?
> if (idelta) {
> - error = xfs_icsb_modify_counters(mp, XFS_SBS_ICOUNT,
> - idelta, rsvd);
> + error = xfs_mod_incore_sb(mp, XFS_SBS_ICOUNT, idelta, rsvd);
Why go through xfs_mod_incore_sb here instead of directly jumping to
the function that does the work?
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2015-02-02 16:44 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-01 21:42 [RFC PATCH 0/5] xfs: use generic percpu counters for icsb Dave Chinner
2015-02-01 21:42 ` [PATCH 1/5] xfs: struct xfs_sb is no longer tied to the on-disk format Dave Chinner
2015-02-02 8:41 ` Christoph Hellwig
2015-02-02 19:30 ` Dave Chinner
2015-02-03 21:37 ` Christoph Hellwig
2015-02-03 21:46 ` Dave Chinner
2015-02-03 23:34 ` Dave Chinner
2015-02-01 21:43 ` [PATCH 2/5] xfs: use generic percpu counters for inode counter Dave Chinner
2015-02-02 16:44 ` Christoph Hellwig [this message]
2015-02-02 19:33 ` Dave Chinner
2015-02-03 21:38 ` Christoph Hellwig
2015-02-01 21:43 ` [PATCH 3/5] xfs: use generic percpu counters for free " Dave Chinner
2015-02-02 17:10 ` Brian Foster
2015-02-01 21:43 ` [PATCH 4/5] xfs: use generic percpu counters for free block counter Dave Chinner
2015-02-02 16:48 ` Christoph Hellwig
2015-02-02 19:34 ` Dave Chinner
2015-02-02 17:11 ` Brian Foster
2015-02-02 19:39 ` Dave Chinner
2015-02-01 21:43 ` [PATCH 5/5] xfs: Remove icsb infrastructure Dave Chinner
2015-02-02 17:11 ` Brian Foster
2015-02-03 21:50 ` [RFC PATCH 0/5] xfs: use generic percpu counters for icsb Christoph Hellwig
2015-02-03 21:58 ` Dave Chinner
2015-02-03 22:02 ` Christoph Hellwig
2015-02-03 22:13 ` Dave Chinner
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=20150202164409.GA695@infradead.org \
--to=hch@infradead.org \
--cc=david@fromorbit.com \
--cc=xfs@oss.sgi.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.