public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Chandra Seetharaman <sekharan@us.ibm.com>
To: Dave Chinner <david@fromorbit.com>
Cc: XFS mailing list <xfs@oss.sgi.com>
Subject: Re: [PATCH] xfs: Fix a deadlock in xfs_log_commit_cil() code path
Date: Wed, 17 Jul 2013 16:32:55 -0500	[thread overview]
Message-ID: <1374096775.8941.3.camel@chandra-dt.ibm.com> (raw)
In-Reply-To: <20130716005455.GC3920@dastard>

On Tue, 2013-07-16 at 10:54 +1000, Dave Chinner wrote:
> On Mon, Jul 15, 2013 at 05:52:34PM -0500, Chandra Seetharaman wrote:
> > While testing and rearranging my pquota/gquota code, I stumbled
> > on a xfs_shutdown() during a mount. But the mount just hung.
> > 
> > I debugged and found that there is a deadlock involving
> > &log->l_cilp->xc_ctx_lock.
> > 
> > It is in a code path where &log->l_cilp->xc_ctx_lock is first
> > acquired in read mode and some levels down the same semaphore
> > is being acquired in write mode causing a deadlock.
> > 
> > This is the stack:
> > xfs_log_commit_cil -> acquires &log->l_cilp->xc_ctx_lock in read mode
> >   xlog_print_tic_res
> >     xfs_force_shutdown
> >       xfs_log_force_umount
> >         xlog_cil_force
> >           xlog_cil_force_lsn
> >             xlog_cil_push_foreground
> >               xlog_cil_push - tries to acquire same semaphore in write mode
> > 
> > This patch fixes the deadlock by not calling xfs_force_shutdown() while
> > holding the semaphore, instead calling it after dropping teh semaphore.
> > 
> > Thanks to Dave for suggesting this solution.
> > 
> > Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
> > 
> > ---
> >  fs/xfs/xfs_log.c      |    6 +++---
> >  fs/xfs/xfs_log_cil.c  |   10 ++++++----
> >  fs/xfs/xfs_log_priv.h |    2 +-
> >  fs/xfs/xfs_trans.c    |    2 +-
> >  4 files changed, 11 insertions(+), 9 deletions(-)
> > 
> > diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> > index d852a2b..b9fa2da 100644
> > --- a/fs/xfs/xfs_log.c
> > +++ b/fs/xfs/xfs_log.c
> > @@ -1837,7 +1837,7 @@ xlog_state_finish_copy(
> >   * print out info relating to regions written which consume
> >   * the reservation
> >   */
> > -void
> > +int
> >  xlog_print_tic_res(
> >  	struct xfs_mount	*mp,
> >  	struct xlog_ticket	*ticket)
> > @@ -1941,7 +1941,7 @@ xlog_print_tic_res(
> >  
> >  	xfs_alert_tag(mp, XFS_PTAG_LOGRES,
> >  		"xlog_write: reservation ran out. Need to up reservation");
> > -	xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
> > +	return EFSCORRUPTED;
> 
> Note the "SHUTDOWN_CORRUPT_INCORE" reason given here....
> 
> > diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
> > index 35a2299..d96022f 100644
> > --- a/fs/xfs/xfs_trans.c
> > +++ b/fs/xfs/xfs_trans.c
> > @@ -1547,7 +1547,7 @@ xfs_trans_commit(
> >  	xfs_trans_apply_dquot_deltas(tp);
> >  
> >  	error = xfs_log_commit_cil(mp, tp, &commit_lsn, flags);
> > -	if (error == ENOMEM) {
> > +	if (error) {
> >  		xfs_force_shutdown(mp, SHUTDOWN_LOG_IO_ERROR);
> 
> Which is different to the reason given here. The shutdown reason
> should be maintained for this particular error....

I see.

Is it ok if the error reason is not propagated to the xlog_write() code
path ?

> 
> Cheers,
> 
> Dave.


_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2013-07-17 21:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-15 22:52 [PATCH] xfs: Fix a deadlock in xfs_log_commit_cil() code path Chandra Seetharaman
2013-07-16  0:54 ` Dave Chinner
2013-07-17 21:32   ` Chandra Seetharaman [this message]
2013-07-18  2:24     ` Dave Chinner
2013-07-18 19:54       ` Chandra Seetharaman
  -- strict thread matches above, loose matches on Subject: below --
2013-07-19 22:31 Chandra Seetharaman
2013-07-22 18:53 ` Ben Myers

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=1374096775.8941.3.camel@chandra-dt.ibm.com \
    --to=sekharan@us.ibm.com \
    --cc=david@fromorbit.com \
    --cc=xfs@oss.sgi.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox