Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/miscfs/specfs Implement spec_fdiscard() using bdev_disca...
details: https://anonhg.NetBSD.org/src/rev/095e0a31fa8a
branches: trunk
changeset: 330906:095e0a31fa8a
user: dholland <dholland%NetBSD.org@localhost>
date: Fri Jul 25 08:19:19 2014 +0000
description:
Implement spec_fdiscard() using bdev_discard() and cdev_discard().
Also define spec_fallocate() to genfs_eopnotsupp().
diffstat:
sys/miscfs/specfs/spec_vnops.c | 44 ++++++++++++++++++++++++++++++++++++++++-
sys/miscfs/specfs/specdev.h | 4 ++-
2 files changed, 45 insertions(+), 3 deletions(-)
diffs (83 lines):
diff -r 9ce9baae971f -r 095e0a31fa8a sys/miscfs/specfs/spec_vnops.c
--- a/sys/miscfs/specfs/spec_vnops.c Fri Jul 25 08:18:50 2014 +0000
+++ b/sys/miscfs/specfs/spec_vnops.c Fri Jul 25 08:19:19 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: spec_vnops.c,v 1.143 2014/03/24 13:42:40 hannken Exp $ */
+/* $NetBSD: spec_vnops.c,v 1.144 2014/07/25 08:19:19 dholland Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.143 2014/03/24 13:42:40 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.144 2014/07/25 08:19:19 dholland Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -838,6 +838,46 @@
}
/*
+ * fdiscard, which on disk devices becomes TRIM.
+ */
+int
+spec_fdiscard(void *v)
+{
+ struct vop_fdiscard_args /* {
+ struct vnode *a_vp;
+ off_t a_pos;
+ off_t a_len;
+ } */ *ap = v;
+ struct vnode *vp;
+ dev_t dev;
+
+ vp = ap->a_vp;
+ dev = NODEV;
+
+ mutex_enter(vp->v_interlock);
+ if (vdead_check(vp, VDEAD_NOWAIT) == 0 && vp->v_specnode != NULL) {
+ dev = vp->v_rdev;
+ }
+ mutex_exit(vp->v_interlock);
+
+ if (dev == NODEV) {
+ return ENXIO;
+ }
+
+ switch (vp->v_type) {
+ case VCHR:
+ // this is not stored for character devices
+ //KASSERT(vp == vp->v_specnode->sn_dev->sd_cdevvp);
+ return cdev_discard(dev, ap->a_pos, ap->a_len);
+ case VBLK:
+ KASSERT(vp == vp->v_specnode->sn_dev->sd_bdevvp);
+ return bdev_discard(dev, ap->a_pos, ap->a_len);
+ default:
+ panic("spec_fdiscard: not a device\n");
+ }
+}
+
+/*
* Device ioctl operation.
*/
/* ARGSUSED */
diff -r 9ce9baae971f -r 095e0a31fa8a sys/miscfs/specfs/specdev.h
--- a/sys/miscfs/specfs/specdev.h Fri Jul 25 08:18:50 2014 +0000
+++ b/sys/miscfs/specfs/specdev.h Fri Jul 25 08:19:19 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: specdev.h,v 1.42 2013/09/30 18:58:00 hannken Exp $ */
+/* $NetBSD: specdev.h,v 1.43 2014/07/25 08:19:19 dholland Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -119,6 +119,8 @@
#define spec_setattr genfs_ebadf
int spec_read(void *);
int spec_write(void *);
+#define spec_fallocate genfs_eopnotsupp
+int spec_fdiscard(void *);
#define spec_fcntl genfs_fcntl
int spec_ioctl(void *);
int spec_poll(void *);
Home |
Main Index |
Thread Index |
Old Index