From: Joel Becker <Joel.Becker@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 3/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' for o2info ioctl.
Date: Mon, 6 Dec 2010 17:11:59 -0800 [thread overview]
Message-ID: <20101207011159.GN16687@mail.oracle.com> (raw)
In-Reply-To: <1289902422-3315-4-git-send-email-tristan.ye@oracle.com>
On Tue, Nov 16, 2010 at 06:13:42PM +0800, Tristan Ye wrote:
> +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 o2ffg_update_stats(struct ocfs2_info_freefrag_stats *stats,
> + unsigned int chunksize)
> +{
> + if (chunksize > stats->ffs_max)
> + stats->ffs_max = chunksize;
> +
> + if (chunksize < stats->ffs_min)
> + stats->ffs_min = chunksize;
> +
> + stats->ffs_avg += chunksize;
> + stats->ffs_free_chunks_real++;
> +}
MUCH more readable.
> +int ocfs2_info_freefrag_scan_bitmap(struct ocfs2_super *osb,
> + struct inode *gb_inode, u64 blkno,
> + 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;
> +
> + if (gb_inode)
> + mutex_lock(&gb_inode->i_mutex);
> +
> + if (o2info_coherent(*ffg)) {
> + status = ocfs2_inode_lock(gb_inode, &bh, 0);
> + if (status < 0) {
> + mlog_errno(status);
> + goto bail;
> + }
> + unlock = 1;
> + } else {
> + status = ocfs2_read_blocks_sync(osb, blkno, 1, &bh);
> + if (status < 0) {
> + mlog_errno(status);
> + goto bail;
> + }
> + }
> +
> + gb_dinode = (struct ocfs2_dinode *)bh->b_data;
> + cl = &(gb_dinode->id2.i_chain);
This is safe because we never remove a chain entry from an
inode. However, if we ever shrink disks, we'll need to coordinate with
this code. Perhaps we should comment that.
Joel
--
"Also, all of life's big problems include the words 'indictment' or
'inoperable.' Everything else is small stuff."
- Alton Brown
Joel Becker
Senior Development Manager
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
next prev parent reply other threads:[~2010-12-07 1:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-16 10:13 [Ocfs2-devel] [PATCH 0/3] Ocfs2: Adding new codes 'OCFS2_INFO_FREEINODE' and 'OCFS2_INFO_FREEFRAG' for o2info ioctl V2 Tristan Ye
2010-11-16 10:13 ` [Ocfs2-devel] [PATCH 1/3] Ocfs2: Using macro to set/clear *FILLED* flags in info handler Tristan Ye
2010-12-07 1:04 ` Joel Becker
2010-11-16 10:13 ` [Ocfs2-devel] [PATCH 2/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEINODE' for o2info ioctl Tristan Ye
2010-12-07 1:07 ` Joel Becker
2010-12-07 1:46 ` Tristan Ye
2010-11-16 10:13 ` [Ocfs2-devel] [PATCH 3/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' " Tristan Ye
2010-12-07 1:11 ` Joel Becker [this message]
2010-12-07 1:45 ` Tristan Ye
2010-12-07 3:36 ` Joel Becker
-- strict thread matches above, loose matches on Subject: below --
2011-01-30 6:25 [Ocfs2-devel] [PATCH 0/3] Ocfs2: Adding new codes 'OCFS2_INFO_FREEINODE' and 'OCFS2_INFO_FREEFRAG' for o2info ioctl V2 Tristan Ye
2011-01-30 6:26 ` [Ocfs2-devel] [PATCH 3/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' for o2info ioctl Tristan Ye
2011-02-18 4:26 [Ocfs2-devel] [PATCH 0/3] Ocfs2: Adding new codes 'OCFS2_INFO_FREEINODE' and 'OCFS2_INFO_FREEFRAG' for o2info ioctl V3 Tristan Ye
2011-02-18 4:26 ` [Ocfs2-devel] [PATCH 3/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' for o2info ioctl Tristan Ye
2011-02-22 4:59 [Ocfs2-devel] [PATCH 2/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEINODE' " Tristan Ye
2011-02-22 4:59 ` [Ocfs2-devel] [PATCH 3/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' " Tristan Ye
2011-03-29 2:11 [Ocfs2-devel] [PATCH 0/3] Ocfs2: Complete rest of o2info patches Tristan Ye
2011-03-29 2:11 ` [Ocfs2-devel] [PATCH 3/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' for o2info ioctl Tristan Ye
2011-05-24 10:07 [Ocfs2-devel] [PATCH 0/3] Ocfs2: Complete rest of o2info patches(v5) Tristan Ye
2011-05-24 10:07 ` [Ocfs2-devel] [PATCH 3/3] Ocfs2: Add a new code 'OCFS2_INFO_FREEFRAG' for o2info ioctl Tristan Ye
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=20101207011159.GN16687@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 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).