NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/52301: lfs deadlock between lfs_fsync and lfs_create



The following reply was made to PR kern/52301; it has been noted by GNATS.

From: coypu%sdf.org@localhost
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/52301: lfs deadlock between lfs_fsync and lfs_create
Date: Thu, 15 Jun 2017 14:20:29 +0000

 --bg08WKrSYDhXBjb5
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 I am torture testing the following diff.
 It boots, let's see how it holds up :-)
 
 --bg08WKrSYDhXBjb5
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="lfs12.diff"
 
 It isn't safe to drain dirops with seglock held, this leads
 to a deadlock. drain before grabbing seglock.
 
 Index: lfs_segment.c
 ===================================================================
 RCS file: /cvsroot/src/sys/ufs/lfs/lfs_segment.c,v
 retrieving revision 1.271
 diff -u -r1.271 lfs_segment.c
 --- lfs_segment.c	12 Jun 2017 15:02:32 -0000	1.271
 +++ lfs_segment.c	15 Jun 2017 14:18:13 -0000
 @@ -603,7 +603,6 @@
  	SEGUSE *segusep;
  	int do_ckp, did_ckp, error;
  	unsigned n, segleft, maxseg, sn, i, curseg;
 -	int writer_set = 0;
  	int dirty;
  	int redo;
  	SEGSUM *ssp;
 @@ -628,6 +627,8 @@
  	if (do_ckp)
  		flags &= ~SEGM_SINGLE;
  
 +	lfs_writer_enter(fs, "lfs segwrite");
 +
  	lfs_seglock(fs, flags | (do_ckp ? SEGM_CKP : 0));
  	sp = fs->lfs_sp;
  	if (sp->seg_flags & (SEGM_CLEAN | SEGM_CKP))
 @@ -653,11 +654,7 @@
  				break;
  			}
  
 -			if (do_ckp || fs->lfs_dirops == 0) {
 -				if (!writer_set) {
 -					lfs_writer_enter(fs, "lfs writer");
 -					writer_set = 1;
 -				}
 +			if (do_ckp) {
  				error = lfs_writevnodes(fs, mp, sp, VN_DIROP);
  				if (um_error == 0)
  					um_error = error;
 @@ -806,8 +803,7 @@
  
  	/* Note Ifile no longer needs to be written */
  	fs->lfs_doifile = 0;
 -	if (writer_set)
 -		lfs_writer_leave(fs);
 +	lfs_writer_leave(fs);
  
  	/*
  	 * If we didn't write the Ifile, we didn't really do anything.
 
 --bg08WKrSYDhXBjb5--
 


Home | Main Index | Thread Index | Old Index