From: Tristan Ye <tristan.ye@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 06/14] Ocfs2/move_extents: move a range of extent.
Date: Fri, 28 Jan 2011 09:51:35 +0800 [thread overview]
Message-ID: <4D422127.9090907@oracle.com> (raw)
In-Reply-To: <20110128011002.GE23899@wotan.suse.de>
Mark Fasheh wrote:
> On Fri, Jan 21, 2011 at 06:20:23PM +0800, Tristan Ye wrote:
>> The moving range of __ocfs2_move_extent() was within one extent always, it
>> consists following parts:
>>
>> 1. Duplicates the clusters in pages to new_blkoffset, where extent to be moved.
>>
>> 2. Split the original extent with new extent, coalecse the nearby extents if possible.
>>
>> 3. Append old clusters to truncate log, or decrease_refcount if the extent was refcounted.
>>
>> Signed-off-by: Tristan Ye <tristan.ye@oracle.com>
>> ---
>> fs/ocfs2/move_extents.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++
>> 1 files changed, 104 insertions(+), 0 deletions(-)
>>
>> diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
>> index 9b30636..e28bd7d 100644
>> --- a/fs/ocfs2/move_extents.c
>> +++ b/fs/ocfs2/move_extents.c
>> @@ -56,6 +56,110 @@ struct ocfs2_move_extents_context {
>> struct ocfs2_cached_dealloc_ctxt dealloc;
>> };
>>
>> +static int __ocfs2_move_extent(handle_t *handle,
>> + struct ocfs2_move_extents_context *context,
>> + u32 cpos, u32 len, u32 p_cpos, u32 new_p_cpos,
>> + int ext_flags)
>> +{
>> + int ret = 0, index;
>> + struct inode *inode = context->inode;
>> + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
>> + struct ocfs2_extent_rec *rec, replace_rec;
>> + struct ocfs2_path *path = NULL;
>> + struct ocfs2_extent_list *el;
>> + u64 ino = ocfs2_metadata_cache_owner(context->et.et_ci);
>> + u64 old_blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cpos);
>> +
>> + ret = ocfs2_duplicate_clusters_by_page(handle, context->file, cpos,
>> + p_cpos, new_p_cpos, len);
>> + if (ret) {
>> + mlog_errno(ret);
>> + goto out;
>> + }
>> +
>> + memset(&replace_rec, 0, sizeof(replace_rec));
>> + replace_rec.e_cpos = cpu_to_le32(cpos);
>> + replace_rec.e_leaf_clusters = cpu_to_le16(len);
>> + replace_rec.e_blkno = cpu_to_le64(ocfs2_clusters_to_blocks(inode->i_sb,
>> + new_p_cpos));
>> +
>> + path = ocfs2_new_path_from_et(&context->et);
>> + if (!path) {
>> + ret = -ENOMEM;
>> + mlog_errno(ret);
>> + goto out;
>> + }
>> +
>> + ret = ocfs2_find_path(INODE_CACHE(inode), path, cpos);
>> + if (ret) {
>> + mlog_errno(ret);
>> + goto out;
>> + }
>> +
>> + el = path_leaf_el(path);
>> +
>> + index = ocfs2_search_extent_list(el, cpos);
>> + if (index == -1 || index >= le16_to_cpu(el->l_next_free_rec)) {
>> + ocfs2_error(inode->i_sb,
>> + "Inode %llu has an extent at cpos %u which can no "
>> + "longer be found.\n",
>> + (unsigned long long)ino, cpos);
>> + ret = -EROFS;
>> + goto out;
>> + }
>> +
>> + rec = &el->l_recs[index];
>> +
>> + BUG_ON(ext_flags != rec->e_flags);
>> + /*
>> + * after moving/defraging to new location, the extent is not going
>> + * to be refcounted anymore.
>> + */
>> + if (ext_flags & OCFS2_EXT_REFCOUNTED)
>> + replace_rec.e_flags = ext_flags & ~OCFS2_EXT_REFCOUNTED;
>> + else
>> + replace_rec.e_flags = ext_flags;
>
> You can remove the if statement here and just leave it as:
>
> replace_rec.e_flags = ext_flags & ~OCFS2_EXT_REFCOUNTED;
Definitely, I loved this optimization;-)
>
> which will do the same thing.
> --Mark
>
> --
> Mark Fasheh
next prev parent reply other threads:[~2011-01-28 1:51 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-21 10:20 [Ocfs2-devel] [PATCH 0/14] Ocfs2: Online defragmentaion V3 Tristan Ye
2011-01-21 10:20 ` [Ocfs2-devel] [PATCH 01/14] Ocfs2/refcounttree: Fix a bug for refcounttree to writeback clusters in a right number Tristan Ye
2011-01-27 23:29 ` Mark Fasheh
2011-01-28 1:43 ` Tristan Ye
2011-02-20 10:40 ` Joel Becker
2011-01-21 10:20 ` [Ocfs2-devel] [PATCH 02/14] Ocfs2/refcounttree: Publicate couple of funcs from refcounttree.c Tristan Ye
2011-01-28 0:05 ` Mark Fasheh
2011-01-28 1:46 ` Tristan Ye
2011-01-21 10:20 ` [Ocfs2-devel] [PATCH 03/14] Ocfs2/move_extents: Adding new ioctl code 'OCFS2_IOC_MOVE_EXT' to ocfs2 Tristan Ye
2011-01-21 10:20 ` [Ocfs2-devel] [PATCH 04/14] Ocfs2/move_extents: Add basic framework and source files for extent moving Tristan Ye
2011-01-21 10:20 ` [Ocfs2-devel] [PATCH 05/14] Ocfs2/move_extents: lock allocators and reserve metadata blocks and data clusters for extents moving Tristan Ye
2011-01-21 10:20 ` [Ocfs2-devel] [PATCH 06/14] Ocfs2/move_extents: move a range of extent Tristan Ye
2011-01-28 1:10 ` Mark Fasheh
2011-01-28 1:51 ` Tristan Ye [this message]
2011-01-21 10:20 ` [Ocfs2-devel] [PATCH 07/14] Ocfs2/move_extents: defrag " Tristan Ye
2011-01-21 10:20 ` [Ocfs2-devel] [PATCH 08/14] Ocfs2/move_extents: find the victim alloc group, where the given #blk fits Tristan Ye
2011-01-21 10:20 ` [Ocfs2-devel] [PATCH 09/14] Ocfs2/move_extents: helper to validate and adjust moving goal Tristan Ye
2011-01-21 10:20 ` [Ocfs2-devel] [PATCH 10/14] Ocfs2/move_extents: helper to probe a proper region to move in an alloc group Tristan Ye
2011-01-21 10:20 ` [Ocfs2-devel] [PATCH 11/14] Ocfs2/move_extents: helpers to update the group descriptor and global bitmap inode Tristan Ye
2011-01-21 10:20 ` [Ocfs2-devel] [PATCH 12/14] Ocfs2/move_extents: move entire/partial extent Tristan Ye
2011-01-21 10:20 ` [Ocfs2-devel] [PATCH 13/14] Ocfs2/move_extents: helper to calculate the defraging length in one run Tristan Ye
2011-01-21 10:20 ` [Ocfs2-devel] [PATCH 14/14] Ocfs2/move_extents: move/defrag extents within a certain range 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=4D422127.9090907@oracle.com \
--to=tristan.ye@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.