[Top] [All Lists]

Re: [RFC PATCH 1/4] xfs: introduce a new helper xfs_inobt_reada_chunk()

To: Jeff Liu <jeff.liu@xxxxxxxxxx>
Subject: Re: [RFC PATCH 1/4] xfs: introduce a new helper xfs_inobt_reada_chunk()
From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Date: Mon, 18 Nov 2013 03:01:13 -0800
Cc: Christoph Hellwig <hch@xxxxxxxxxxxxx>, "xfs@xxxxxxxxxxx" <xfs@xxxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <5288B58D.5030609@xxxxxxxxxx>
References: <5281F509.7020105@xxxxxxxxxx> <20131115170325.GA16942@xxxxxxxxxxxxx> <5288B58D.5030609@xxxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
> > 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;

<Prev in Thread] Current Thread [Next in Thread>