Page MenuHomeFreeBSD

D34073.id102029.diff
No OneTemporary

D34073.id102029.diff

diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -4003,7 +4003,11 @@
* it must be on a queue.
*/
lockflags = LK_EXCLUSIVE | LK_INTERLOCK |
- ((flags & GB_LOCK_NOWAIT) ? LK_NOWAIT : LK_SLEEPFAIL);
+ ((flags & GB_LOCK_NOWAIT) != 0 ? LK_NOWAIT : LK_SLEEPFAIL)
+#ifdef WITNESS
+ | ((flags & GB_NOWITNESS) != 0 ? LK_NOWITNESS : 0)
+#endif
+ ;
error = BUF_TIMELOCK(bp, lockflags,
BO_LOCKPTR(bo), "getblk", slpflag, slptimeo);
diff --git a/sys/sys/buf.h b/sys/sys/buf.h
--- a/sys/sys/buf.h
+++ b/sys/sys/buf.h
@@ -510,6 +510,7 @@
#define GB_CKHASH 0x0020 /* If reading, calc checksum hash */
#define GB_NOSPARSE 0x0040 /* Do not instantiate holes */
#define GB_CVTENXIO 0x0080 /* Convert errors to ENXIO */
+#define GB_NOWITNESS 0x0100 /* Do not record for WITNESS */
#ifdef _KERNEL
extern int nbuf; /* The number of buffer headers */
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c
--- a/sys/ufs/ffs/ffs_alloc.c
+++ b/sys/ufs/ffs/ffs_alloc.c
@@ -78,13 +78,14 @@
#include <sys/filedesc.h>
#include <sys/priv.h>
#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/kernel.h>
+#include <sys/stat.h>
#include <sys/syscallsubr.h>
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <sys/taskqueue.h>
+#include <sys/vnode.h>
+#include <sys/mount.h>
+#include <sys/kernel.h>
#include <security/audit/audit.h>
@@ -270,6 +271,9 @@
fs = ump->um_fs;
bp = NULL;
gbflags = (flags & BA_UNMAPPED) != 0 ? GB_UNMAPPED : 0;
+#ifdef WITNESS
+ gbflags |= IS_SNAPSHOT(ip) ? GB_NOWITNESS : 0;
+#endif
mtx_assert(UFS_MTX(ump), MA_OWNED);
#ifdef INVARIANTS
diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c
--- a/sys/ufs/ffs/ffs_balloc.c
+++ b/sys/ufs/ffs/ffs_balloc.c
@@ -69,6 +69,7 @@
#include <sys/bio.h>
#include <sys/buf.h>
#include <sys/lock.h>
+#include <sys/stat.h>
#include <sys/mount.h>
#include <sys/vnode.h>
#include <sys/vmmeter.h>
@@ -612,7 +613,7 @@
int deallocated, osize, nsize, num, i, error;
int unwindidx = -1;
int saved_inbdflush;
- int gbflags, reclaimed;
+ int gbflags, gbwflag, reclaimed;
ip = VTOI(vp);
dp = ip->i_din2;
@@ -628,6 +629,12 @@
if (lbn < 0)
return (EFBIG);
gbflags = (flags & BA_UNMAPPED) != 0 ? GB_UNMAPPED : 0;
+#ifdef WITNESS
+ gbwflag = IS_SNAPSHOT(ip) ? GB_NOWITNESS : 0;
+ gbflags |= gbwflag;
+#else
+ gbwflag = 0;
+#endif
vn_seqc_write_begin(vp);
@@ -889,7 +896,7 @@
*allocblk++ = nb;
*lbns_remfree++ = indirs[1].in_lbn;
bp = getblk(vp, indirs[1].in_lbn, fs->fs_bsize, 0, 0,
- GB_UNMAPPED);
+ GB_UNMAPPED | gbwflag);
bp->b_blkno = fsbtodb(fs, nb);
vfs_bio_clrbuf(bp);
if (DOINGSOFTDEP(vp)) {
@@ -914,8 +921,8 @@
*/
retry:
for (i = 1;;) {
- error = bread(vp,
- indirs[i].in_lbn, (int)fs->fs_bsize, NOCRED, &bp);
+ error = bread_gb(vp, indirs[i].in_lbn, (int)fs->fs_bsize,
+ NOCRED, gbwflag, &bp);
if (error) {
goto fail;
}
@@ -1138,7 +1145,7 @@
* buffer object lists.
*/
bp = getblk(vp, *lbns_remfree, fs->fs_bsize, 0, 0,
- GB_NOCREAT | GB_UNMAPPED);
+ GB_NOCREAT | GB_UNMAPPED | gbwflag);
if (bp != NULL) {
KASSERT(bp->b_blkno == fsbtodb(fs, *blkp),
("mismatch2 l %jd %jd b %ju %ju",
@@ -1156,8 +1163,8 @@
} else if (unwindidx >= 0) {
int r;
- r = bread(vp, indirs[unwindidx].in_lbn,
- (int)fs->fs_bsize, NOCRED, &bp);
+ r = bread_gb(vp, indirs[unwindidx].in_lbn,
+ (int)fs->fs_bsize, NOCRED, gbwflag, &bp);
if (r) {
panic("Could not unwind indirect block, error %d", r);
brelse(bp);
@@ -1193,7 +1200,7 @@
if (blkp == allociblk)
lbns_remfree = lbns;
bp = getblk(vp, *lbns_remfree, fs->fs_bsize, 0, 0,
- GB_NOCREAT | GB_UNMAPPED);
+ GB_NOCREAT | GB_UNMAPPED | gbwflag);
if (bp != NULL) {
panic("zombie2 %jd %ju %ju",
(intmax_t)bp->b_lblkno, (uintmax_t)bp->b_blkno,
diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c
--- a/sys/ufs/ffs/ffs_vnops.c
+++ b/sys/ufs/ffs/ffs_vnops.c
@@ -261,12 +261,17 @@
struct ufsmount *ump;
struct buf *bp, *nbp;
ufs_lbn_t lbn;
- int error, passes;
+ int error, passes, wflag;
bool still_dirty, unlocked, wait;
ip = VTOI(vp);
bo = &vp->v_bufobj;
ump = VFSTOUFS(vp->v_mount);
+#ifdef WITNESS
+ wflag = IS_SNAPSHOT(ip) ? LK_NOWITNESS : 0;
+#else
+ wflag = 0;
+#endif
/*
* When doing MNT_WAIT we must first flush all dependencies
@@ -318,9 +323,8 @@
if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT, NULL) == 0) {
BO_UNLOCK(bo);
} else if (wait) {
- if (BUF_LOCK(bp,
- LK_EXCLUSIVE | LK_SLEEPFAIL | LK_INTERLOCK,
- BO_LOCKPTR(bo)) != 0) {
+ if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_SLEEPFAIL |
+ LK_INTERLOCK | wflag, BO_LOCKPTR(bo)) != 0) {
BO_LOCK(bo);
bp->b_vflags &= ~BV_SCANNED;
goto next_locked;

File Metadata

Mime Type
text/plain
Expires
Thu, Aug 6, 7:27 AM (10 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36095967
Default Alt Text
D34073.id102029.diff (4 KB)

Event Timeline