Move WAPL replay handling from bread() into ufs_strategy.
This changes the order of hook processing as the copy-on-write handlers are called after the journal processing. This makes more sense as the journal overwrite is logically part of the disk IO.
This commit is contained in:
parent
94d985722a
commit
b9400f6fd4
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vfs_bio.c,v 1.212 2008/11/10 21:02:15 joerg Exp $ */
|
||||
/* $NetBSD: vfs_bio.c,v 1.213 2008/11/11 08:29:58 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
|
||||
@ -109,7 +109,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.212 2008/11/10 21:02:15 joerg Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.213 2008/11/11 08:29:58 joerg Exp $");
|
||||
|
||||
#include "fs_ffs.h"
|
||||
#include "opt_bufcache.h"
|
||||
@ -720,20 +720,6 @@ bread(struct vnode *vp, daddr_t blkno, int size, kauth_cred_t cred,
|
||||
if (error == 0 && (flags & B_MODIFY) != 0) /* XXXX before the next code block or after? */
|
||||
error = fscow_run(bp, true);
|
||||
|
||||
if (!error) {
|
||||
struct mount *mp = wapbl_vptomp(vp);
|
||||
|
||||
if (mp && mp->mnt_wapbl_replay &&
|
||||
WAPBL_REPLAY_ISOPEN(mp)) {
|
||||
error = WAPBL_REPLAY_READ(mp, bp->b_data, bp->b_blkno,
|
||||
bp->b_bcount);
|
||||
if (error) {
|
||||
mutex_enter(&bufcache_lock);
|
||||
SET(bp->b_cflags, BC_INVAL);
|
||||
mutex_exit(&bufcache_lock);
|
||||
}
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vfs_wapbl.c,v 1.5 2008/11/10 20:30:31 joerg Exp $ */
|
||||
/* $NetBSD: vfs_wapbl.c,v 1.6 2008/11/11 08:29:58 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003,2008 The NetBSD Foundation, Inc.
|
||||
@ -36,7 +36,7 @@
|
||||
#define WAPBL_INTERNAL
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.5 2008/11/10 20:30:31 joerg Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.6 2008/11/11 08:29:58 joerg Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
@ -240,6 +240,7 @@ int wapbl_lazy_truncate = 0;
|
||||
struct wapbl_ops wapbl_ops = {
|
||||
.wo_wapbl_discard = wapbl_discard,
|
||||
.wo_wapbl_replay_isopen = wapbl_replay_isopen1,
|
||||
.wo_wapbl_replay_can_read = wapbl_replay_can_read,
|
||||
.wo_wapbl_replay_read = wapbl_replay_read,
|
||||
.wo_wapbl_add_buf = wapbl_add_buf,
|
||||
.wo_wapbl_remove_buf = wapbl_remove_buf,
|
||||
@ -2770,6 +2771,24 @@ wapbl_replay_write(struct wapbl_replay *wr, struct vnode *fsdevvp)
|
||||
return error;
|
||||
}
|
||||
|
||||
int
|
||||
wapbl_replay_can_read(struct wapbl_replay *wr, daddr_t blk, long len)
|
||||
{
|
||||
struct wapbl_wc_header *wch = &wr->wr_wc_header;
|
||||
int fsblklen = 1<<wch->wc_fs_dev_bshift;
|
||||
|
||||
KDASSERT(wapbl_replay_isopen(wr));
|
||||
KASSERT((len % fsblklen) == 0);
|
||||
|
||||
while (len != 0) {
|
||||
struct wapbl_blk *wb = wapbl_blkhash_get(wr, blk);
|
||||
if (wb)
|
||||
return 1;
|
||||
len -= fsblklen;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
wapbl_replay_read(struct wapbl_replay *wr, void *data, daddr_t blk, long len)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mount.h,v 1.181 2008/07/31 05:38:05 simonb Exp $ */
|
||||
/* $NetBSD: mount.h,v 1.182 2008/11/11 08:29:58 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1991, 1993
|
||||
@ -291,6 +291,7 @@ int fsname##_suspendctl(struct mount *, int)
|
||||
struct wapbl_ops {
|
||||
void (*wo_wapbl_discard)(struct wapbl *);
|
||||
int (*wo_wapbl_replay_isopen)(struct wapbl_replay *);
|
||||
int (*wo_wapbl_replay_can_read)(struct wapbl_replay *, daddr_t, long);
|
||||
int (*wo_wapbl_replay_read)(struct wapbl_replay *, void *, daddr_t, long);
|
||||
void (*wo_wapbl_add_buf)(struct wapbl *, struct buf *);
|
||||
void (*wo_wapbl_remove_buf)(struct wapbl *, struct buf *);
|
||||
@ -304,6 +305,9 @@ struct wapbl_ops {
|
||||
(*(MP)->mnt_wapbl_op->wo_wapbl_discard)((MP)->mnt_wapbl)
|
||||
#define WAPBL_REPLAY_ISOPEN(MP) \
|
||||
(*(MP)->mnt_wapbl_op->wo_wapbl_replay_isopen)((MP)->mnt_wapbl_replay)
|
||||
#define WAPBL_REPLAY_CAN_READ(MP, BLK, LEN) \
|
||||
(*(MP)->mnt_wapbl_op->wo_wapbl_replay_can_read)((MP)->mnt_wapbl_replay, \
|
||||
(BLK), (LEN))
|
||||
#define WAPBL_REPLAY_READ(MP, DATA, BLK, LEN) \
|
||||
(*(MP)->mnt_wapbl_op->wo_wapbl_replay_read)((MP)->mnt_wapbl_replay, \
|
||||
(DATA), (BLK), (LEN))
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ufs_vnops.c,v 1.169 2008/08/14 16:19:25 matt Exp $ */
|
||||
/* $NetBSD: ufs_vnops.c,v 1.170 2008/11/11 08:29:58 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
@ -66,7 +66,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.169 2008/08/14 16:19:25 matt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.170 2008/11/11 08:29:58 joerg Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_ffs.h"
|
||||
@ -1933,6 +1933,7 @@ ufs_strategy(void *v)
|
||||
struct buf *bp;
|
||||
struct vnode *vp;
|
||||
struct inode *ip;
|
||||
struct mount *mp;
|
||||
int error;
|
||||
|
||||
bp = ap->a_bp;
|
||||
@ -1957,7 +1958,31 @@ ufs_strategy(void *v)
|
||||
return (0);
|
||||
}
|
||||
vp = ip->i_devvp;
|
||||
return (VOP_STRATEGY(vp, bp));
|
||||
|
||||
error = VOP_STRATEGY(vp, bp);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
if (!BUF_ISREAD(bp))
|
||||
return 0;
|
||||
|
||||
mp = wapbl_vptomp(vp);
|
||||
if (mp == NULL || mp->mnt_wapbl_replay == NULL ||
|
||||
!WAPBL_REPLAY_ISOPEN(mp) ||
|
||||
!WAPBL_REPLAY_CAN_READ(mp, bp->b_blkno, bp->b_bcount))
|
||||
return 0;
|
||||
|
||||
error = biowait(bp);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
error = WAPBL_REPLAY_READ(mp, bp->b_data, bp->b_blkno, bp->b_bcount);
|
||||
if (error) {
|
||||
mutex_enter(&bufcache_lock);
|
||||
SET(bp->b_cflags, BC_INVAL);
|
||||
mutex_exit(&bufcache_lock);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user