All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joel Becker <Joel.Becker@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 2/2] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' for o2info ioctl.
Date: Wed, 3 Nov 2010 18:29:50 -0700	[thread overview]
Message-ID: <20101104012949.GB14640@mail.oracle.com> (raw)
In-Reply-To: <1288782126-13007-2-git-send-email-tristan.ye@oracle.com>

On Wed, Nov 03, 2010 at 07:02:06PM +0800, Tristan Ye wrote:
> This new code is a bit more complicated than former ones, the goal is to
> show user all statistics required to take a deep insight into filesystem
> on how the disk is being fragmentaed.
> 
> The goal is achieved by scaning global bitmap from (cluster)group to group
> to figure out following factors in the filesystem:
> 
> 	- How many free chunks in a fixed size as user requested.
> 	- How many real free chunks in all size.

	Let me see if I understand the above requirements.  In the same
call, you are going build a list of free chunk sizes.  Then you will
also count how many chunks of a user-specified size.  Why can't the user
just take the list and look at the size they want?  What do they get
from specifying a size to the ioctl(2)?

  
> +void ocfs2_info_update_ffg(struct ocfs2_info_freefrag *ffg, __u32 chunksize)
> +{
> +	int index;
> +
> +	index = __ilog2_u32(chunksize);
> +	if (index >= OCFS2_INFO_MAX_HIST)
> +		index = OCFS2_INFO_MAX_HIST - 1;
> +
> +	ffg->iff_ffs.ffs_fc_hist.fc_chunks[index]++;
> +	ffg->iff_ffs.ffs_fc_hist.fc_clusters[index] += chunksize;
> +
> +	if (chunksize > ffg->iff_ffs.ffs_max)
> +		ffg->iff_ffs.ffs_max = chunksize;
> +
> +	if (chunksize < ffg->iff_ffs.ffs_min)
> +		ffg->iff_ffs.ffs_min = chunksize;
> +
> +	ffg->iff_ffs.ffs_avg += chunksize;
> +	ffg->iff_ffs.ffs_free_chunks_real++;
> +}

	I'm sorry, but this is just unreadable.  I get that we can only
abbreviate 'free-frag-scan' so many ways, but there is no way people
will understand this.
	I don't think renaming helps too much.  These names are always
going to be bad.  I think we *can* reduce the long structure strings,
mostly with helper functions.
	For example, here we could have:

static void o2ffg_update_histogram(struct ocfs2_info_free_chunk_list *hist,
                                   unsigned int chunksize)
{
	int index;

	index = __ilog2_u32(chunksize);
	if (index >= OCFS2_INFO_MAX_HIST)
		index = OCFS2_INFO_MAX_HIST - 1;

	hist->fc_chunks[index]++;
	hist->fc_clusters[index] += chunksize;
}

static void ocfs2_info_update_ffg(struct ocfs2_info_freefrag *ffg,
                                  unsigned int chunksize)
{
	o2ffg_update_histogram(&ffg->iff_ffs.ffs_fc_hist, chunksize);

 	...
}

and so on.  Btw, the chunksize can be an unsigned int, as the calling
function uses that type and not the more specific __u32.

> +int ocfs2_info_freefrag_scan_bitmap(struct inode *gb_inode,
> +				    struct ocfs2_info_freefrag *ffg)
> +{
> +	__u32 chunks_in_group;
> +	int status = 0, unlock = 0, i;
> +
> +	struct buffer_head *bh = NULL;
> +	struct ocfs2_chain_list *cl = NULL;
> +	struct ocfs2_chain_rec *rec = NULL;
> +	struct ocfs2_dinode *gb_dinode = NULL;
> +
> +	mutex_lock(&gb_inode->i_mutex);
> +
> +	if (!(ffg->iff_req.ir_flags & OCFS2_INFO_FL_NON_COHERENT)) {
> +		status = ocfs2_inode_lock(gb_inode, &bh, 0);
> +		if (status < 0) {
> +			mlog_errno(status);
> +			goto bail;
> +		}
> +		unlock = 1;
> +	} else {
> +		status = ocfs2_read_inode_block(gb_inode, &bh);
> +		if (status < 0) {
> +			mlog_errno(status);
> +			goto bail;
> +		}
> +	}

	Same thoughts about ocfs2_ilookup() here.

Joel

-- 

Life's Little Instruction Book #347

	"Never waste the oppourtunity to tell someone you love them."

Joel Becker
Senior Development Manager
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127

  reply	other threads:[~2010-11-04  1:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-03 11:02 [Ocfs2-devel] [PATCH 1/2] Ocfs2: Add a new code 'OCFS2_INFO_FREEINODE' for o2info ioctl Tristan Ye
2010-11-03 11:02 ` [Ocfs2-devel] [PATCH 2/2] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' " Tristan Ye
2010-11-04  1:29   ` Joel Becker [this message]
2010-11-04  2:56     ` tristan
2010-11-04  4:47       ` tristan
2010-11-04  6:32       ` Joel Becker
2010-11-04  7:05         ` tristan
2010-12-07  0:46           ` Joel Becker
2010-11-04  1:18 ` [Ocfs2-devel] [PATCH 1/2] Ocfs2: Add a new code 'OCFS2_INFO_FREEINODE' " Joel Becker
2010-11-04  2:27   ` tristan
2010-11-04  6:28     ` Joel Becker
2010-11-04  8:10       ` tristan
2010-11-04 21:24         ` Joel Becker

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=20101104012949.GB14640@mail.oracle.com \
    --to=joel.becker@oracle.com \
    --cc=ocfs2-devel@oss.oracle.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.