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 2/2] ocfs2: Fix race between mount and	recovery
Date: Fri, 11 Jul 2008 16:52:00 -0700	[thread overview]
Message-ID: <20080711235200.GE22577@mail.oracle.com> (raw)
In-Reply-To: <1215818841-4097-3-git-send-email-sunil.mushran@oracle.com>

On Fri, Jul 11, 2008 at 04:27:21PM -0700, Sunil Mushran wrote:
> +	if (replayed)
> +		le32_add_cpu(&(fe->id1.journal1.ij_recovery_generation), 1);

	You're doing this a lot, and it's a bunch to read.  Can we have:

static void ocfs2_bump_recovery_generation(struct ocfs2_dinode *di)
{
	le32_add_cpu(&(di->id1.journal1.ij_recovery_generation), 1);
}

static u32 ocfs2_get_recovery_generation(struct ocfs2_dinode *di)
{
	return le32_to_cpu(di->id1.journal1.ij_recovery_generation);
}

I just think it'll read better.

> +static int ocfs2_read_journal_inode(struct ocfs2_super *osb,
> +				    int slot_num,
> +				    struct buffer_head **bh,
> +				    struct inode **ret_inode)

	Perhaps you want to make ret_inode optional?  It seems to be
there are a couple paths that are just iput()ing it.  So, you'd do:

> +{
> +	int status = -EACCES;
> +	struct inode *inode = NULL;
> +
> +	BUG_ON(slot_num >= osb->max_slots);
> +
- +	*ret_inode = NULL;
- +
> +	inode = ocfs2_get_system_file_inode(osb, JOURNAL_SYSTEM_INODE,
> +					    slot_num);
> +	if (!inode || is_bad_inode(inode)) {
> +		mlog_errno(status);
> +		goto bail;
> +	}
> +	SET_INODE_JOURNAL(inode);
> +
> +	status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, bh, 0, inode);
> +	if (status < 0) {
> +		mlog_errno(status);
> +		goto bail;
> +	}
> +
> +	status = 0;
> +
> +bail:
> +	if (inode) {
- +		if (status)
+ +		if (status || !ret_inode)
> +			iput(inode);
> +		else
> +			*ret_inode = inode;
> +	}
> +	return status;
> +}

<snip>

>  	flags = le32_to_cpu(fe->id1.journal1.ij_flags);
> +	slot_reco_gen = le32_to_cpu(fe->id1.journal1.ij_recovery_generation);

Wouldn't this be so much nicer?

+	slot_reco_gen = ocfs2_get_recovery_generation(fe);

> @@ -1190,14 +1263,35 @@ int ocfs2_mark_dead_nodes(struct ocfs2_super *osb)
>  {
>  	int status, i, node_num;
>  	struct ocfs2_slot_info *si = osb->slot_info;
> +	struct buffer_head *bh = NULL;
> +	struct ocfs2_dinode *fe;

	If you are adding new dinodes, can we call them 'di' instead of
'fe'?

>  	spin_lock(&si->si_lock);
>  	for(i = 0; i < si->si_num_slots; i++) {
> +		/* Read journal inode to get the recovery generation */
> +		status = ocfs2_read_journal_inode(osb, i, &bh, &inode);
> +		if (status) {
> +			mlog_errno(status);
> +			goto bail;
> +		}
> +		fe = (struct ocfs2_dinode *)bh->b_data;
> +		osb->slot_recovery_generation[i] =
> +			le32_to_cpu(fe->id1.journal1.ij_recovery_generation);
> +		brelse(bh);
> +		iput(inode);

	Here's a place you'd want to pass NULL instead of &inode to
ocfs2_read_journal_inode();

Joel

-- 

Life's Little Instruction Book #197

	"Don't forget, a person's greatest emotional need is to 
	 feel appreciated."

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

  reply	other threads:[~2008-07-11 23:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-11 23:27 [Ocfs2-devel] OCFS2 1.4: Proposed fix for mount/recovery race (Attempt 2) Sunil Mushran
2008-07-11 23:27 ` [Ocfs2-devel] [PATCH 1/2] ocfs2: Adds counter in struct ocfs2_dinode to track journal replays Sunil Mushran
2008-07-11 23:27 ` [Ocfs2-devel] [PATCH 2/2] ocfs2: Fix race between mount and recovery Sunil Mushran
2008-07-11 23:52   ` Joel Becker [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-07-15  0:31 [Ocfs2-devel] Recovery/mount fixes for mainline Sunil Mushran
2008-07-15  0:31 ` [Ocfs2-devel] [PATCH 2/2] ocfs2: Fix race between mount and recovery Sunil Mushran
2008-07-14 20:12 [Ocfs2-devel] OCFS2 1.4: Proposed fix for mount/recovery race (Attempt 4) Sunil Mushran
2008-07-14 20:12 ` [Ocfs2-devel] [PATCH 2/2] ocfs2: Fix race between mount and recovery Sunil Mushran
2008-07-14 20:25   ` Joel Becker
2008-07-12  0:25 [Ocfs2-devel] OCFS2 1.4: Proposed fix for mount/recovery race (Attempt 3) Sunil Mushran
2008-07-12  0:25 ` [Ocfs2-devel] [PATCH 2/2] ocfs2: Fix race between mount and recovery Sunil Mushran
2008-07-12  1:24   ` Joel Becker
2008-07-10 23:17 [Ocfs2-devel] OCFS2 1.4: Proposed fix for mount/recovery race Sunil Mushran
2008-07-10 23:17 ` [Ocfs2-devel] [PATCH 2/2] ocfs2: Fix race between mount and recovery Sunil Mushran
2008-07-11  0:36   ` Joel Becker

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=20080711235200.GE22577@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.