Module Name: src
Committed By: riastradh
Date: Sun Feb 23 08:40:59 UTC 2020
Modified Files:
src/sys/ufs/lfs: lfs_inode.c
Log Message:
In lfs_update, hold lfs_writer around lfs_vflush.
Otherwise, we might do
lfs_vflush
-> lfs_seglock
-> lfs_segwait(SEGM_CKP)
-> lfs_writer_enter
which is the reverse of the lfs_writer -> lfs_seglock ordering.
To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/sys/ufs/lfs/lfs_inode.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/ufs/lfs/lfs_inode.c
diff -u src/sys/ufs/lfs/lfs_inode.c:1.157 src/sys/ufs/lfs/lfs_inode.c:1.158
--- src/sys/ufs/lfs/lfs_inode.c:1.157 Sat Jun 10 05:29:36 2017
+++ src/sys/ufs/lfs/lfs_inode.c Sun Feb 23 08:40:58 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_inode.c,v 1.157 2017/06/10 05:29:36 maya Exp $ */
+/* $NetBSD: lfs_inode.c,v 1.158 2020/02/23 08:40:58 riastradh Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.157 2017/06/10 05:29:36 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.158 2020/02/23 08:40:58 riastradh Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@@ -133,6 +133,7 @@ lfs_update(struct vnode *vp, const struc
struct inode *ip;
struct lfs *fs = VFSTOULFS(vp->v_mount)->um_lfs;
int flags;
+ int error;
ASSERT_NO_SEGLOCK(fs);
if (vp->v_mount->mnt_flag & MNT_RDONLY)
@@ -175,7 +176,7 @@ lfs_update(struct vnode *vp, const struc
vp->v_iflag | vp->v_vflag | vp->v_uflag,
ip->i_state));
if (fs->lfs_dirops == 0)
- lfs_flush_fs(fs, SEGM_SYNC);
+ break;
else
mtsleep(&fs->lfs_writer, PRIBIO+1, "lfs_fsync",
0, &lfs_lock);
@@ -183,8 +184,18 @@ lfs_update(struct vnode *vp, const struc
twice? */
}
--fs->lfs_diropwait;
+ fs->lfs_writer++;
+ if (vp->v_uflag & VU_DIROP) {
+ KASSERT(fs->lfs_dirops == 0);
+ lfs_flush_fs(fs, SEGM_SYNC);
+ }
+ mutex_exit(&lfs_lock);
+ error = lfs_vflush(vp);
+ mutex_enter(&lfs_lock);
+ if (--fs->lfs_writer == 0)
+ cv_broadcast(&fs->lfs_diropscv);
mutex_exit(&lfs_lock);
- return lfs_vflush(vp);
+ return error;
}
return 0;
}