Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys fix the UFS2 extattr truncate code to play nice with wapbl.
details: https://anonhg.NetBSD.org/src/rev/eb0ceb990bdb
branches: trunk
changeset: 936570:eb0ceb990bdb
user: chs <chs%NetBSD.org@localhost>
date: Fri Jul 31 04:07:30 2020 +0000
description:
fix the UFS2 extattr truncate code to play nice with wapbl.
also, rather than pull in the FreeBSD V_NORMAL/V_ALT flags to
vinvalbuf() and the buf b_xflags field and BX_ALTDATA flag,
add a binvalbuf() function to invalid a specific buffer
and use that to invalidate the two possible exattr bufs
during IO_EXT truncations.
diffstat:
sys/kern/vfs_bio.c | 34 ++++++++++++++++++++++++++++++++--
sys/sys/buf.h | 3 ++-
sys/ufs/ffs/ffs_inode.c | 22 +++++++++++++++-------
3 files changed, 49 insertions(+), 10 deletions(-)
diffs (147 lines):
diff -r 1022eca47466 -r eb0ceb990bdb sys/kern/vfs_bio.c
--- a/sys/kern/vfs_bio.c Fri Jul 31 03:35:05 2020 +0000
+++ b/sys/kern/vfs_bio.c Fri Jul 31 04:07:30 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_bio.c,v 1.296 2020/06/11 19:20:46 ad Exp $ */
+/* $NetBSD: vfs_bio.c,v 1.297 2020/07/31 04:07:30 chs Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009, 2019, 2020 The NetBSD Foundation, Inc.
@@ -123,7 +123,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.296 2020/06/11 19:20:46 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.297 2020/07/31 04:07:30 chs Exp $");
#ifdef _KERNEL_OPT
#include "opt_bufcache.h"
@@ -1516,6 +1516,36 @@
}
/*
+ * Invalidate the specified buffer if it exists.
+ */
+void
+binvalbuf(struct vnode *vp, daddr_t blkno)
+{
+ buf_t *bp;
+ int err;
+
+ mutex_enter(&bufcache_lock);
+
+ loop:
+ bp = incore(vp, blkno);
+ if (bp != NULL) {
+ err = bbusy(bp, 0, 0, NULL);
+ if (err == EPASSTHROUGH)
+ goto loop;
+ bremfree(bp);
+ if (ISSET(bp->b_oflags, BO_DELWRI)) {
+ SET(bp->b_cflags, BC_NOCACHE);
+ mutex_exit(&bufcache_lock);
+ bwrite(bp);
+ } else {
+ brelsel(bp, BC_INVAL);
+ mutex_exit(&bufcache_lock);
+ }
+ } else
+ mutex_exit(&bufcache_lock);
+}
+
+/*
* Attempt to free an aged buffer off the queues.
* Called with queue lock held.
* Returns the amount of buffer memory freed.
diff -r 1022eca47466 -r eb0ceb990bdb sys/sys/buf.h
--- a/sys/sys/buf.h Fri Jul 31 03:35:05 2020 +0000
+++ b/sys/sys/buf.h Fri Jul 31 04:07:30 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: buf.h,v 1.133 2020/04/20 21:39:05 ad Exp $ */
+/* $NetBSD: buf.h,v 1.134 2020/07/31 04:07:30 chs Exp $ */
/*-
* Copyright (c) 1999, 2000, 2007, 2008 The NetBSD Foundation, Inc.
@@ -287,6 +287,7 @@
int allocbuf(buf_t *, int, int);
void brelsel(buf_t *, int);
void brelse(buf_t *, int);
+void binvalbuf(struct vnode *, daddr_t);
/*
* So-far indeterminate ops that might belong to either
diff -r 1022eca47466 -r eb0ceb990bdb sys/ufs/ffs/ffs_inode.c
--- a/sys/ufs/ffs/ffs_inode.c Fri Jul 31 03:35:05 2020 +0000
+++ b/sys/ufs/ffs/ffs_inode.c Fri Jul 31 04:07:30 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_inode.c,v 1.130 2020/07/26 00:21:24 chs Exp $ */
+/* $NetBSD: ffs_inode.c,v 1.131 2020/07/31 04:07:30 chs Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.130 2020/07/26 00:21:24 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.131 2020/07/31 04:07:30 chs Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@@ -208,6 +208,7 @@
{
daddr_t lastblock;
struct inode *oip = VTOI(ovp);
+ struct mount *omp = ovp->v_mount;
daddr_t bn, lastiblock[UFS_NIADDR], indir_lbn[UFS_NIADDR];
daddr_t blks[UFS_NDADDR + UFS_NIADDR], oldblks[UFS_NDADDR + UFS_NIADDR];
struct fs *fs;
@@ -220,6 +221,8 @@
int sync;
struct ufsmount *ump = oip->i_ump;
void *dcookie;
+ long bsize;
+ bool wapbl = omp->mnt_wapbl != NULL;
UFS_WAPBL_JLOCK_ASSERT(ump->um_mountp);
@@ -255,11 +258,11 @@
#ifdef QUOTA
(void) chkdq(oip, -extblocks, NOCRED, FORCE);
#endif
- vinvalbuf(ovp, 0, cred, curlwp, 0, 0);
osize = oip->i_din2->di_extsize;
oip->i_din2->di_blocks -= extblocks;
oip->i_din2->di_extsize = 0;
for (i = 0; i < UFS_NXADDR; i++) {
+ binvalbuf(ovp, -1 - i);
oldblks[i] = oip->i_din2->di_extb[i];
oip->i_din2->di_extb[i] = 0;
}
@@ -269,8 +272,15 @@
for (i = 0; i < UFS_NXADDR; i++) {
if (oldblks[i] == 0)
continue;
- ffs_blkfree(fs, oip->i_devvp, oldblks[i],
- ffs_sblksize(fs, osize, i), oip->i_number);
+ bsize = ffs_sblksize(fs, osize, i);
+ if (wapbl) {
+ error = UFS_WAPBL_REGISTER_DEALLOCATION(omp,
+ FFS_FSBTODB(fs, oldblks[i]), bsize, NULL);
+ if (error)
+ return error;
+ } else
+ ffs_blkfree(fs, oip->i_devvp, oldblks[i],
+ bsize, oip->i_number);
}
extblocks = 0;
}
@@ -501,8 +511,6 @@
* All whole direct blocks or frags.
*/
for (i = UFS_NDADDR - 1; i > lastblock; i--) {
- long bsize;
-
bn = ffs_getdb(fs, oip, i);
if (bn == 0)
continue;
Home |
Main Index |
Thread Index |
Old Index