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 3/7] ocfs2: Store dir index records inline
Date: Fri, 30 Jan 2009 17:09:40 -0800	[thread overview]
Message-ID: <20090131010940.GC6155@mail.oracle.com> (raw)
In-Reply-To: <1233351753-14640-4-git-send-email-mfasheh@suse.com>

On Fri, Jan 30, 2009 at 01:42:29PM -0800, Mark Fasheh wrote:
> Allow us to store a small number of directory index records in the
> ocfs2_dx_root_block. This saves us a disk read on small to medium sized
> directories (less than about 250 entries). The inline root is automatically
> turned into a root block with extents if the directory size increases beyond
> it's capacity.
> 
> Signed-off-by: Mark Fasheh <mfasheh@suse.com>

Two tiny comments, but otherwise
Signed-off-by: Joel Becker <joel.becker@oracle.com>

> @@ -1407,14 +1498,14 @@ int __ocfs2_add_entry(handle_t *handle,
>  			else {
>  				status = ocfs2_journal_access_db(handle, dir,
>  								 insert_bh,
> -								 OCFS2_JOURNAL_ACCESS_WRITE);
> -				if (ocfs2_dir_indexed(dir)) {
> -					status = ocfs2_dx_dir_leaf_insert(dir,
> -									handle,
> -									lookup);
> -					if (status) {
> -						mlog_errno(status);
> -						goto bail;
> +					      OCFS2_JOURNAL_ACCESS_WRITE);
> +
> +			if (ocfs2_dir_indexed(dir)) {
> +				status = ocfs2_dx_dir_insert(dir, handle,
> +							     lookup);
> +				if (status) {
> +					mlog_errno(status);
> +					goto bail;

	This hunk looks indented wrong.  I think it's all inside the
else{, and should be indented the same as the journal_access_db() call.

> @@ -3504,6 +3644,133 @@ out:
>  	return ret;
>  }
>  
> +static int ocfs2_expand_inline_dx_root(struct inode *dir,
> +				       struct buffer_head *dx_root_bh)
> +{
> +	int ret, num_dx_leaves, i, j, did_quota = 0;
> +	struct buffer_head **dx_leaves = NULL;
> +	struct ocfs2_extent_tree et;
> +	u64 insert_blkno;
> +	struct ocfs2_alloc_context *data_ac = NULL;
> +	struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
> +	handle_t *handle = NULL;
> +	struct ocfs2_dx_root_block *dx_root;
> +	struct ocfs2_dx_entry_list *entry_list;
> +	struct ocfs2_dx_entry *dx_entry;
> +	struct ocfs2_dx_leaf *target_leaf;
> +
> +	ret = ocfs2_reserve_clusters(osb, 1, &data_ac);
> +	if (ret) {
> +		mlog_errno(ret);
> +		goto out;
> +	}
> +
> +	dx_leaves = ocfs2_dx_dir_kmalloc_leaves(osb->sb, &num_dx_leaves);
> +	if (!dx_leaves) {
> +		ret = -ENOMEM;
> +		mlog_errno(ret);
> +		goto out;
> +	}
> +
> +	handle = ocfs2_start_trans(osb, ocfs2_calc_dxi_expand_credits(osb->sb));
> +	if (IS_ERR(handle)) {
> +		ret = PTR_ERR(handle);
> +		mlog_errno(ret);
> +		goto out;
> +	}
> +
> +	if (vfs_dq_alloc_space_nodirty(dir,
> +				       ocfs2_clusters_to_bytes(osb->sb, 1))) {
> +		ret = -EDQUOT;
> +		goto out_commit;
> +	}
> +	did_quota = 1;
> +
> +	ret = __ocfs2_dx_dir_new_cluster(dir, 0, handle, data_ac, dx_leaves,
> +					 num_dx_leaves, &insert_blkno);
> +	if (ret) {
> +		mlog_errno(ret);
> +		goto out_commit;
> +	}
> +
> +	/*
> +	 * Transfer the entries from our dx_root into the appropriate
> +	 * block
> +	 */
> +	dx_root = (struct ocfs2_dx_root_block *) dx_root_bh->b_data;
> +	entry_list = &dx_root->dr_entries;
> +
> +	for (i = 0; i < le16_to_cpu(entry_list->de_num_used); i++) {
> +		dx_entry = &entry_list->de_entries[i];
> +
> +		j = __ocfs2_dx_dir_hash_idx(osb,
> +					    le32_to_cpu(dx_entry->dx_minor_hash));
> +		target_leaf = (struct ocfs2_dx_leaf *)dx_leaves[j]->b_data;
> +
> +		ocfs2_dx_dir_leaf_insert_tail(target_leaf, dx_entry);
> +
> +		/* Each leaf has been passed to the journal already
> +		 * via __ocfs2_dx_dir_new_cluster() */
> +	}
> +
> +	ret = ocfs2_journal_access_dr(handle, dir, dx_root_bh,
> +				      OCFS2_JOURNAL_ACCESS_WRITE);
> +	if (ret) {
> +		mlog_errno(ret);
> +		goto out_commit;
> +	}

	Why wnot journal_access the dr before you claim the leaf
clusters, so that failure to get journal_access on the dr doesn't force
a commit of the allocated clusters?  Maybe I'm missing something.

Joel

-- 

"When choosing between two evils, I always like to try the one
 I've never tried before."
        - Mae West

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127

  reply	other threads:[~2009-01-31  1:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-30 21:42 [Ocfs2-devel] [PATCH 0/7] ocfs2: Directory indexing support Mark Fasheh
2009-01-30 21:42 ` [Ocfs2-devel] [PATCH 1/7] ocfs2: Introduce dir lookup helper struct Mark Fasheh
2009-01-30 22:22   ` Joel Becker
2009-01-30 21:42 ` [Ocfs2-devel] [PATCH 2/7] ocfs2: Add a name indexed b-tree to directory inodes Mark Fasheh
2009-01-31  0:54   ` Joel Becker
2009-01-30 21:42 ` [Ocfs2-devel] [PATCH 3/7] ocfs2: Store dir index records inline Mark Fasheh
2009-01-31  1:09   ` Joel Becker [this message]
2009-01-30 21:42 ` [Ocfs2-devel] [PATCH 4/7] ocfs2: Introduce dir free space list Mark Fasheh
2009-01-31  1:29   ` Joel Becker
2009-01-30 21:42 ` [Ocfs2-devel] [PATCH 5/7] ocfs2: Increase max links count Mark Fasheh
2009-01-31  1:36   ` Joel Becker
2009-01-30 21:42 ` [Ocfs2-devel] [PATCH 6/7] ocfs2: Enable indexed directories Mark Fasheh
2009-01-31  1:36   ` Joel Becker
2009-01-30 21:42 ` [Ocfs2-devel] [PATCH 7/7] ocfs2: add quota call to ocfs2_remove_btree_range() Mark Fasheh
2009-01-31  1:37   ` Joel Becker
2009-02-02 10:05   ` Jan Kara

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=20090131010940.GC6155@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.