public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Jeff Liu <jeff.liu@oracle.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	"xfs@oss.sgi.com" <xfs@oss.sgi.com>
Subject: Re: [RFC PATCH 1/4] xfs: introduce a new helper xfs_inobt_reada_chunk()
Date: Mon, 18 Nov 2013 03:01:13 -0800	[thread overview]
Message-ID: <20131118110113.GA1304@infradead.org> (raw)
In-Reply-To: <5288B58D.5030609@oracle.com>

> > I'd prefer to factor this out even further. xfs_ialloc_inode_init and
> > xfs_ifree_cluster already have two pieces of code that calculate these
> > two (with more readable names) and an additional nuber buffers counter
> > we won't need here, it might make most sense to factor that into a
> > single common helper.
> Yup, I also thought this can be factored out, however, I can not figure out
> a meaningful function name at that time due to my poor skill...
> 
> How about if we introduce an inline helper to xfs_ialloc.h as below?
> 
> /* Helper function to extract the # of blocks/inodes/buffers hint per cluster */
> static inline void
> xfs_ialloc_get_cluster_hints(
> 	struct xfs_mount	*mp,
> 	int			*nblks;
> 	int			*ninodes;
> 	int			*nbufs)
> {
> 	....
> }

Probably fine to make it an inline.  I don't think we need the nbufs
parameter, as it requires the length to calculate, and it's a trivial
length / blks_per_cluster.

Similarly the ninodes value is trivially calculatable, so it might be
as easy as:

static inline int
xfs_ialloc_blks_per_cluster(struct xfs_mount *mp)
{
	if (mp->m_sb.sb_blocksize >= XFS_INODE_CLUSTER_SIZE(mp))
		return 1;
	return XFS_INODE_CLUSTER_SIZE(mp) / mp->m_sb.sb_blocksize;
}


...

	blks_per_cluster = xfs_ialloc_blks_per_cluster(mp);
	nbufs = length / blks_per_cluster;
	ninodes = blks_per_cluster * mp->m_sb.sb_inopblock;

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2013-11-18 11:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-12  9:29 [RFC PATCH 1/4] xfs: introduce a new helper xfs_inobt_reada_chunk() Jeff Liu
2013-11-15 17:03 ` Christoph Hellwig
2013-11-17 12:24   ` Jeff Liu
2013-11-18 11:01     ` Christoph Hellwig [this message]
2013-11-18 12:21       ` Jeff Liu

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=20131118110113.GA1304@infradead.org \
    --to=hch@infradead.org \
    --cc=jeff.liu@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox