summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1998-09-05 14:13:12 +0000
committerphk <phk@FreeBSD.org>1998-09-05 14:13:12 +0000
commit4630814c8bc51e668f785289086657fbd5e775f2 (patch)
treee5449931fffd8e8dd0e4d28f5b7b28dc6e36ba5c /sys/kern
parentec3c90cf78eb16d4a8906a64e2a6f76cf27b8441 (diff)
downloadFreeBSD-src-4630814c8bc51e668f785289086657fbd5e775f2.zip
FreeBSD-src-4630814c8bc51e668f785289086657fbd5e775f2.tar.gz
Add a new vnode op, VOP_FREEBLKS(), which filesystems can use to inform
device drivers about sectors no longer in use. Device-drivers receive the call through d_strategy, if they have D_CANFREE in d_flags. This allows flash based devices to erase the sectors and avoid pointlessly carrying them around in compactions. Reviewed by: Kirk Mckusick, bde Sponsored by: M-Systems (www.m-sys.com)
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_bio.c19
-rw-r--r--sys/kern/vnode_if.src16
2 files changed, 25 insertions, 10 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 06130f9..6db20aa2 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -11,7 +11,7 @@
* 2. Absolutely no warranty of function or purpose is made by the author
* John S. Dyson.
*
- * $Id: vfs_bio.c,v 1.173 1998/08/28 20:07:13 luoqi Exp $
+ * $Id: vfs_bio.c,v 1.174 1998/09/04 08:06:55 dfr Exp $
*/
/*
@@ -587,14 +587,14 @@ brelse(struct buf * bp)
if (bp->b_flags & B_LOCKED)
bp->b_flags &= ~B_ERROR;
- if ((bp->b_flags & (B_NOCACHE | B_INVAL | B_ERROR)) ||
+ if ((bp->b_flags & (B_NOCACHE | B_INVAL | B_ERROR | B_FREEBUF)) ||
(bp->b_bufsize <= 0)) {
bp->b_flags |= B_INVAL;
if (LIST_FIRST(&bp->b_dep) != NULL && bioops.io_deallocate)
(*bioops.io_deallocate)(bp);
if (bp->b_flags & B_DELWRI)
--numdirtybuffers;
- bp->b_flags &= ~(B_DELWRI | B_CACHE);
+ bp->b_flags &= ~(B_DELWRI | B_CACHE | B_FREEBUF);
if ((bp->b_flags & B_VMIO) == 0) {
if (bp->b_bufsize)
allocbuf(bp, 0);
@@ -1895,6 +1895,12 @@ biodone(register struct buf * bp)
}
bp->b_flags |= B_DONE;
+ if (bp->b_flags & B_FREEBUF) {
+ brelse(bp);
+ splx(s);
+ return;
+ }
+
if ((bp->b_flags & B_READ) == 0) {
vwakeup(bp);
}
@@ -2415,12 +2421,7 @@ DB_SHOW_COMMAND(buffer, db_show_buffer)
}
db_printf("b_proc = %p,\nb_flags = 0x%b\n", (void *)bp->b_proc,
- (u_int)bp->b_flags,
- "\20\40bounce\37cluster\36vmio\35ram\34ordered"
- "\33paging\32xxx\31writeinprog\30wanted\27relbuf\26avail3"
- "\25read\24raw\23phys\22clusterok\21malloc\20nocache"
- "\17locked\16inval\15avail2\14error\13eintr\12done\11avail1"
- "\10delwri\7call\6cache\5busy\4bad\3async\2needcommit\1age");
+ (u_int)bp->b_flags, PRINT_BUF_FLAGS);
db_printf("b_error = %d, b_bufsize = %ld, b_bcount = %ld, "
"b_resid = %ld\nb_dev = 0x%x, b_data = %p, "
"b_blkno = %d, b_pblkno = %d\n",
diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src
index 4dd64cd..48c9fef 100644
--- a/sys/kern/vnode_if.src
+++ b/sys/kern/vnode_if.src
@@ -31,7 +31,7 @@
# SUCH DAMAGE.
#
# @(#)vnode_if.src 8.12 (Berkeley) 5/14/95
-# $Id: vnode_if.src,v 1.17 1998/05/07 04:58:26 msmith Exp $
+# $Id: vnode_if.src,v 1.18 1998/07/04 20:45:32 julian Exp $
#
#
@@ -467,6 +467,20 @@ vop_putpages {
};
#
+#% freeblks vp - - -
+#
+# This call is used by the filesystem to release blocks back to
+# device-driver. This is useful if the driver has a lengthy
+# erase handling or similar.
+#
+
+vop_freeblks {
+ IN struct vnode *vp;
+ IN daddr_t addr;
+ IN daddr_t length;
+};
+
+#
# Needs work: no vp?
#
#vop_bwrite {
OpenPOWER on IntegriCloud