From: Tao Ma <tao.ma@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 13/15] Enable xattr set in index btree. v3
Date: Tue, 12 Aug 2008 09:09:49 +0800 [thread overview]
Message-ID: <48A0E2DD.2020607@oracle.com> (raw)
In-Reply-To: <20080812001110.GF21187@wotan.suse.de>
Mark Fasheh wrote:
> On Thu, Aug 07, 2008 at 06:31:33AM +0800, Tao Ma wrote:
>> +/*
>> + * Add a new cluster for xattr storage.
>> + *
>> + * If the new cluster is contiguous with the previous one, it will be
>> + * appended to the same extent record, and num_clusters will be updated.
>> + * If not, we will insert a new extent for it and move some xattrs in
>> + * the last cluster into the new allocated one.
>> + * We also need to limit the maximum size of a btree leaf, otherwise we'll
>> + * lose the benefits of hashing because we'll have to search large leaves.
>> + * So now the maximum size is OCFS2_MAX_XATTR_TREE_LEAF_SIZE(or clustersize,
>> + * if it's bigger).
>> + *
>> + * first_bh is the first block of the previous extent rec and header_bh
>> + * indicates the bucket we will insert the new xattrs. They will be updated
>> + * when the header_bh is moved into the new cluster.
>> + */
>> +static int ocfs2_add_new_xattr_cluster(struct inode *inode,
>> + struct buffer_head *root_bh,
>> + struct buffer_head **first_bh,
>> + struct buffer_head **header_bh,
>> + u32 *num_clusters,
>> + u32 prev_cpos,
>> + u64 prev_blkno,
>> + int *extend)
>> +{
>> + int ret, credits;
>> + u16 bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1);
>> + u32 prev_clusters = *num_clusters;
>> + u32 clusters_to_add = 1, bit_off, num_bits, v_start = 0;
>> + u64 block;
>> + handle_t *handle = NULL;
>> + struct ocfs2_alloc_context *data_ac = NULL;
>> + struct ocfs2_alloc_context *meta_ac = NULL;
>> + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
>> + struct ocfs2_xattr_block *xb =
>> + (struct ocfs2_xattr_block *)root_bh->b_data;
>> + struct ocfs2_xattr_tree_root *xb_root = &xb->xb_attrs.xb_root;
>> + struct ocfs2_extent_list *root_el = &xb_root->xt_list;
>> + enum ocfs2_extent_tree_type type = OCFS2_XATTR_TREE_EXTENT;
>> +
>> + mlog(0, "Add new xattr cluster for %llu, previous xattr hash = %u, "
>> + "previous xattr blkno = %llu\n",
>> + (unsigned long long)OCFS2_I(inode)->ip_blkno,
>> + prev_cpos, prev_blkno);
>> +
>> + ret = ocfs2_lock_allocators(inode, root_bh, root_el,
>> + clusters_to_add, 0, &data_ac,
>> + &meta_ac, type, NULL);
>> + if (ret) {
>> + mlog_errno(ret);
>> + goto leave;
>> + }
>> +
>> + credits = ocfs2_calc_extend_credits(osb->sb, root_el, clusters_to_add);
>> + handle = ocfs2_start_trans(osb, credits);
>> + if (IS_ERR(handle)) {
>> + ret = PTR_ERR(handle);
>> + handle = NULL;
>> + mlog_errno(ret);
>> + goto leave;
>> + }
>> +
>> + ret = ocfs2_journal_access(handle, inode, root_bh,
>> + OCFS2_JOURNAL_ACCESS_WRITE);
>> + if (ret < 0) {
>> + mlog_errno(ret);
>> + goto leave;
>> + }
>> +
>> + ret = __ocfs2_claim_clusters(osb, handle, data_ac, 1,
>> + clusters_to_add, &bit_off, &num_bits);
>> + if (ret < 0) {
>> + if (ret != -ENOSPC)
>> + mlog_errno(ret);
>> + goto leave;
>> + }
>> +
>> + BUG_ON(num_bits > clusters_to_add);
>> +
>> + block = ocfs2_clusters_to_blocks(osb->sb, bit_off);
>> + mlog(0, "Allocating %u clusters at block %u for xattr in inode %llu\n",
>> + num_bits, bit_off, (unsigned long long)OCFS2_I(inode)->ip_blkno);
>> +
>> + if (prev_blkno + prev_clusters * bpc == block &&
>> + (prev_clusters + num_bits) << osb->s_clustersize_bits <=
>> + OCFS2_MAX_XATTR_TREE_LEAF_SIZE) {
>> + /*
>> + * If this cluster is contiguous with the old one and
>> + * adding this new cluster, we don't surpass the limit of
>> + * OCFS2_MAX_XATTR_TREE_LEAF_SIZE, cool. We will let it be
>> + * initialized and used like other buckets in the previous
>> + * cluster.
>> + * So add it as a contiguous one. The caller will handle
>> + * its init process.
>> + */
>> + v_start = prev_cpos + prev_clusters;
>> + *num_clusters = prev_clusters + num_bits;
>> + mlog(0, "Add contiguous %u clusters to previous extent rec.\n",
>> + num_bits);
>> + } else {
>> + ret = ocfs2_adjust_xattr_cross_cluster(inode,
>> + handle,
>> + first_bh,
>> + header_bh,
>> + block,
>> + prev_blkno,
>> + prev_clusters,
>> + &v_start,
>> + extend);
>> + if (ret) {
>> + mlog_errno(ret);
>> + goto leave;
>> + }
>> + }
>> +
>> + mlog(0, "Insert %u clusters at block %llu for xattr at %u\n",
>> + num_bits, block, v_start);
>> + ret = ocfs2_xattr_tree_insert_extent(osb, handle, inode, root_bh,
>> + v_start, block, num_bits,
>> + 0, meta_ac);
>
> I think we need to do something down in the extent insertion code to prevent
> merging in the OCFS2_MAX_XATTR_TREE_LEAF_SIZE cases - what's preventing it
> from appending that allocation to the end of an extent (any extent) in the
> btree?
We don't need to do that. You see, in ocfs2_adjust_xattr_corss_cluster I
have adjusted v_start(v_start now indicates the first name hash of the
xattrs in the new cluster), so now they will not be contiguous now. ;)
We only allow xattr hashes to be the same in one bucket(4K) size, so
with 64K as our leaf size, even if the cluster is contiguous, we will
not have contiguous name hash. so it is safe to say here v_start can
never be old_v_start+1.
Regards,
Tao
next prev parent reply other threads:[~2008-08-12 1:09 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-07 6:23 [Ocfs2-devel] [PATCH 0/15] ocfs2: Add extended attributes for ocfs2. V3 Tao Ma
2008-08-06 22:31 ` [Ocfs2-devel] [PATCH 01/15] Modify ocfs2_num_free_extents for future xattr usage Tao Ma
2008-08-06 22:31 ` [Ocfs2-devel] [PATCH 02/15] Use ocfs2_extent_list instead of ocfs2_dinode Tao Ma
2008-08-06 22:31 ` [Ocfs2-devel] [PATCH 03/15] Abstract ocfs2_extent_tree in b-tree operations Tao Ma
2008-08-14 19:55 ` Joel Becker
2008-08-15 7:17 ` Tao Ma
2008-08-06 22:31 ` [Ocfs2-devel] [PATCH 04/15] Make extend allocation generic Tao Ma
2008-08-14 20:01 ` Joel Becker
2008-08-15 7:14 ` Tao Ma
2008-08-14 23:47 ` Joel Becker
2008-08-15 8:44 ` Tao Ma
2008-08-15 6:26 ` Joel Becker
2008-08-15 15:43 ` Tao Ma
2008-08-15 17:59 ` Mark Fasheh
2008-08-15 19:18 ` Joel Becker
2008-08-16 9:39 ` Tao Ma
2008-08-15 19:23 ` Joel Becker
2008-08-16 9:49 ` Tao Ma
2008-08-06 22:31 ` [Ocfs2-devel] [PATCH 05/15] Add xattr header in ocfs2. v3 Tao Ma
2008-08-11 0:03 ` Mark Fasheh
2008-08-10 16:49 ` [Ocfs2-devel] [PATCH 05/15] Add xattr header in ocfs2.v3 revised Tao Ma
2008-08-11 1:23 ` Mark Fasheh
2008-08-06 22:31 ` [Ocfs2-devel] [PATCH 06/15] Add helper function in uptodate for removing xattr clusters.V3 Tao Ma
2008-08-11 1:22 ` Mark Fasheh
2008-08-06 22:31 ` [Ocfs2-devel] [PATCH 07/15] Add extent tree operation for xattr value.v3 Tao Ma
2008-08-16 2:18 ` Joel Becker
2008-08-16 3:29 ` Joel Becker
2008-08-18 12:52 ` TaoMa
2008-08-16 10:40 ` TaoMa
2008-08-06 22:31 ` [Ocfs2-devel] [PATCH 10/15] Add xattr tree operations in ocfs2_extent_tree.v3 Tao Ma
2008-08-06 22:31 ` [Ocfs2-devel] [PATCH 11/15] Add xattr bucket iteration for large numbers of EAs.v11 Tao Ma
2008-08-12 21:22 ` Mark Fasheh
2008-08-06 22:31 ` [Ocfs2-devel] [PATCH 12/15] Add xattr find process for xattr index btree.v3 Tao Ma
2008-08-12 21:42 ` Mark Fasheh
2008-08-13 17:28 ` Tao Ma
2008-08-13 18:11 ` Mark Fasheh
2008-08-06 22:31 ` [Ocfs2-devel] [PATCH 13/15] Enable xattr set in index btree. v3 Tao Ma
2008-08-12 0:11 ` Mark Fasheh
2008-08-12 1:09 ` Tao Ma [this message]
2008-08-12 20:52 ` Mark Fasheh
2008-08-13 17:33 ` [Ocfs2-devel] [PATCH] Refactor ocfs2_insert_extent for not-merging Tao Ma
2008-08-13 20:32 ` Mark Fasheh
2008-08-14 1:13 ` Tao Ma
2008-08-14 2:04 ` Mark Fasheh
2008-08-14 16:22 ` [Ocfs2-devel] [PATCH] Refactor ocfs2_insert_extent for not-merging. Revised Tao Ma
2008-08-15 3:09 ` Mark Fasheh
2008-08-12 23:17 ` [Ocfs2-devel] [PATCH 13/15] Enable xattr set in index btree. v3 Mark Fasheh
2008-08-13 0:13 ` Tao Ma
2008-08-13 0:30 ` Mark Fasheh
2008-08-06 22:31 ` [Ocfs2-devel] [PATCH 14/15] Delete all xattr buckets in inode removal.v3 Tao Ma
2008-08-07 7:11 ` [Ocfs2-devel] [PATCH 08/15] ocfs2: reserve inline space for extended attribute Tiger Yang
2008-08-11 1:18 ` Mark Fasheh
2008-08-11 2:15 ` Tiger Yang
2008-08-07 7:11 ` [Ocfs2-devel] [PATCH 09/15] ocfs2: Add extended attribute support v3 Tiger Yang
2008-08-12 0:19 ` Mark Fasheh
2008-08-07 7:12 ` [Ocfs2-devel] [PATCH 15/15] ocfs2: Add incompatible flag for extended attribute v3 Tiger Yang
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=48A0E2DD.2020607@oracle.com \
--to=tao.ma@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.