From: Joel Becker <Joel.Becker@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 04/39] ocfs2: Basic tree root operation.
Date: Fri, 1 May 2009 20:55:55 -0700 [thread overview]
Message-ID: <20090502035555.GD17236@mail.oracle.com> (raw)
In-Reply-To: <1241045931-24607-4-git-send-email-tao.ma@oracle.com>
On Thu, Apr 30, 2009 at 06:58:16AM +0800, Tao Ma wrote:
> +int ocfs2_create_refcount_tree(struct inode *inode, struct buffer_head *di_bh)
> +{
> + int ret;
> + handle_t *handle = NULL;
> + struct ocfs2_alloc_context *meta_ac = NULL;
> + struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
> + struct ocfs2_inode_info *oi = OCFS2_I(inode);
> + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
> + struct buffer_head *new_bh = NULL;
> + struct ocfs2_refcount_block *rb;
> + u16 suballoc_bit_start;
> + u32 num_got;
> + u64 first_blkno;
> +
> + BUG_ON(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL);
> + BUG_ON(di->i_refcount_loc);
> +
> + mlog(0, "create tree for inode %lu\n", inode->i_ino);
> +
> + ret = ocfs2_reserve_new_metadata_blocks(osb, 1, &meta_ac);
> + if (ret) {
> + mlog_errno(ret);
> + goto out;
> + }
> +
> + handle = ocfs2_start_trans(osb, OCFS2_REFCOUNT_TREE_CREATE_CREDITS);
> + if (IS_ERR(handle)) {
> + ret = PTR_ERR(handle);
> + mlog_errno(ret);
> + goto out;
> + }
> +
> + ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh,
> + OCFS2_JOURNAL_ACCESS_WRITE);
> + if (ret) {
> + mlog_errno(ret);
> + goto out_commit;
> + }
> +
> + ret = ocfs2_claim_metadata(osb, handle, meta_ac, 1,
> + &suballoc_bit_start, &num_got,
> + &first_blkno);
> + if (ret) {
> + mlog_errno(ret);
> + goto out_commit;
> + }
> +
> + new_bh = sb_getblk(inode->i_sb, first_blkno);
> + ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), new_bh);
> +
> + ret = ocfs2_journal_access_rb(handle, INODE_CACHE(inode), new_bh,
> + OCFS2_JOURNAL_ACCESS_CREATE);
> + if (ret) {
> + mlog_errno(ret);
> + goto out_commit;
> + }
> +
> + /* Initialize ocfs2_refcount_block. */
> + rb = (struct ocfs2_refcount_block *)new_bh->b_data;
> + memset(rb, 0, inode->i_sb->s_blocksize);
> + strcpy((void *)rb, OCFS2_REFCOUNT_BLOCK_SIGNATURE);
> + rb->rf_suballoc_slot = cpu_to_le16(osb->slot_num);
> + rb->rf_suballoc_bit = cpu_to_le16(suballoc_bit_start);
> + rb->rf_fs_generation = cpu_to_le32(osb->fs_generation);
> + rb->rf_blkno = cpu_to_le64(first_blkno);
> + rb->rf_count = cpu_to_le32(1);
> + rb->rf_flags = cpu_to_le32(OCFS2_REFCOUNT_LEAF_FL);
> + rb->rf_records.rl_count =
> + cpu_to_le16(ocfs2_refcount_recs_per_rb(osb->sb));
Ouch, I missed this the first pass. The root of the tree is not
a LEAF, so it should have flags==0. OCFS2_REFCOUNT_LEAF_FL does not
mean "I have refcount records". It means "I am hanging off of a btree
and rf_parent points to the top of my btree". To determine whether
rf_records is valid, you check OCFS2_REFCOUNT_TREE_FL. If not set,
rf_records is valid.
Joel
--
"Always give your best, never get discouraged, never be petty; always
remember, others may hate you. Those who hate you don't win unless
you hate them. And then you destroy yourself."
- Richard M. Nixon
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
next prev parent reply other threads:[~2009-05-02 3:55 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-30 7:59 [Ocfs2-devel] [PATCH 00/39] ocfs2: Add reflink file support. V3 Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 01/39] ocfs2: Define refcount tree structure Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 02/39] ocfs2: Add metaecc for ocfs2_refcount_block Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 03/39] ocfs2: Add ocfs2_read_refcount_block Tao Ma
2009-04-30 23:17 ` Joel Becker
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 04/39] ocfs2: Basic tree root operation Tao Ma
2009-04-30 23:33 ` Joel Becker
2009-05-01 6:47 ` Tao Ma
2009-05-02 3:55 ` Joel Becker [this message]
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 05/39] ocfs2: hook remove refcount tree into truncate Tao Ma
2009-04-30 23:35 ` Joel Becker
2009-05-01 6:48 ` Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 06/39] ocfs2: Wrap ocfs2_extent_contig in ocfs2_extent_tree Tao Ma
2009-04-30 23:43 ` Joel Becker
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 07/39] ocfs2: Abstract extent split process Tao Ma
2009-04-30 23:57 ` Joel Becker
2009-05-05 6:35 ` Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 08/39] ocfs2: Add refcount b-tree as a new extent tree Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 09/39] ocfs2: export tree operation functions Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 10/39] ocfs2: Add support for incrementing refcount in the tree Tao Ma
2009-05-02 3:53 ` Joel Becker
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 11/39] ocfs2: Add support of decrementing refcount for delete Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 12/39] ocfs2: Add functions for extents refcounted Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 13/39] ocfs2: Hook 'Decrement refcount for delete' Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 14/39] ocfs2: Add CoW support Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 15/39] ocfs2: CoW refcount tree improvement Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 16/39] ocfs2: Add __ocfs2_reflink Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 17/39] ocfs2: Add ioctl for reflink Tao Ma
2009-05-01 7:34 ` Christoph Hellwig
2009-05-01 11:19 ` Joel Becker
2009-05-02 14:14 ` Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 18/39] ocfs2: Use proper parameter for some inode operation Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 19/39] ocfs2: Create reflinked file in orphan dir Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 20/39] ocfs2: Abstract caching info checkpoint Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 21/39] ocfs2: Add new refcount tree lock resource Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 22/39] ocfs2: Add refcount tree lock mechanism Tao Ma
2009-05-08 1:17 ` Joel Becker
2009-05-08 1:41 ` Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 23/39] ocfs2: lock refcount tree if needed Tao Ma
2009-05-08 1:30 ` Joel Becker
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 24/39] ocfs2: Add caching info for refcount tree Tao Ma
2009-05-08 1:32 ` Joel Becker
2009-05-08 1:50 ` Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 25/39] ocfs2: Add refcount tree find mechanism from an inode Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 26/39] ocfs2: Return extent flags for xattr value tree Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 27/39] ocfs2: Abstract duplicate clusters process in CoW Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 28/39] ocfs2: Add CoW support for xattr Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 29/39] ocfs2: Remove inode from ocfs2_xattr_bucket_get_name_value Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 30/39] ocfs2: Abstract the creation of xattr block Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 31/39] ocfs2: Abstract ocfs2 xattr tree extend rec iteration process Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 32/39] ocfs2: Attach xattr clusters to refcount tree Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 33/39] ocfs2: Call refcount tree remove process properly Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 34/39] ocfs2: Create an xattr indexed block if needed Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 35/39] ocfs2: Add reflink support for xattr Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 36/39] ocfs2: Modify removing xattr process for refcount Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 37/39] ocfs2: Don't merge in 1st refcount ops of reflink Tao Ma
2009-05-08 1:38 ` Joel Becker
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 38/39] ocfs2: Make transaction extend more efficient Tao Ma
2009-04-29 22:58 ` [Ocfs2-devel] [PATCH 39/39] ocfs2: Enable refcount tree support Tao Ma
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=20090502035555.GD17236@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.