Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add VOP_FALLOCATE and VOP_FDISCARD.



details:   https://anonhg.NetBSD.org/src/rev/e86ccb064ba2
branches:  trunk
changeset: 797665:e86ccb064ba2
user:      dholland <dholland%NetBSD.org@localhost>
date:      Fri Jul 25 08:16:47 2014 +0000

description:
Add VOP_FALLOCATE and VOP_FDISCARD.

diffstat:

 share/man/man9/vnodeops.9 |  54 ++++++++++++++++++++++++++++++++++++++++++++++-
 sys/kern/vnode_if.src     |  20 ++++++++++++++++-
 2 files changed, 72 insertions(+), 2 deletions(-)

diffs (123 lines):

diff -r 556b0a3f3877 -r e86ccb064ba2 share/man/man9/vnodeops.9
--- a/share/man/man9/vnodeops.9 Fri Jul 25 08:10:31 2014 +0000
+++ b/share/man/man9/vnodeops.9 Fri Jul 25 08:16:47 2014 +0000
@@ -1,4 +1,4 @@
-.\"     $NetBSD: vnodeops.9,v 1.94 2014/07/21 05:56:26 dholland Exp $
+.\"     $NetBSD: vnodeops.9,v 1.95 2014/07/25 08:16:47 dholland Exp $
 .\"
 .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -42,6 +42,8 @@
 .Nm VOP_SETATTR ,
 .Nm VOP_READ ,
 .Nm VOP_WRITE ,
+.Nm VOP_FALLOCATE,
+.Nm VOP_FDISCARD,
 .Nm VOP_IOCTL ,
 .Nm VOP_FCNTL ,
 .Nm VOP_POLL ,
@@ -115,6 +117,10 @@
 .Fn VOP_WRITE "struct vnode *vp" "struct uio *uio" "int ioflag" \
 "kauth_cred_t cred"
 .Ft int
+.Fn VOP_FALLOCATE "struct vnode *vp" "off_t pos" "off_t len"
+.Ft int
+.Fn VOP_FDISCARD "struct vnode *vp" "off_t pos" "off_t len"
+.Ft int
 .Fn VOP_IOCTL "struct vnode *vp" "u_long command" "void *data" \
 "int fflag" "kauth_cred_t cred"
 .Ft int
@@ -235,6 +241,8 @@
 .It VOP_SETATTR        Set file attributes
 .It VOP_READ   Read from a file
 .It VOP_WRITE  Write to a file
+.It VOP_FALLOCATE      Allocate backing for a file
+.It VOP_FDISCARD       Discard backing for a file
 .It VOP_IOCTL  Perform device-specific I/O
 .It VOP_FCNTL  Perform file control
 .It VOP_POLL   Test if poll event has occurred
@@ -653,6 +661,50 @@
 .Pp
 Zero is returned on success, otherwise an error is returned.
 The vnode should be locked on entry and remains locked on exit.
+.It Fn VOP_FALLOCATE "vp" "pos" "len"
+Allocate backing store.
+The argument
+.Fa vp
+is the vnode for the file.
+The
+.Fa pos
+and
+.Fa len
+arguments (specified in bytes) name an extent within the file.
+The blocks underlying this range, rounding up at the top and down at
+the bottom if needed, are checked; if no physical storage is
+allocated, a physical block is allocated and zeroed.
+This operation removes
+.Dq holes
+from files.
+.It Fn VOP_FDISCARD "vp" "pos" "len"
+Discard backing store.
+The argument
+.Fa vp
+is the vnode for the file.
+The
+.Fa pos
+and
+.Fa len
+arguments (specified in bytes) name an extent within the file.
+The blocks underlying this range, rounding down at the top and up at
+the bottom if needed, are checked. If any physical storage is used,
+it is deallocated.
+This operation creates
+.Dq holes
+in files.
+Discarded blocks of regular files read back afterwards as zeroes.
+On devices, the underlying discard-block operation if any (e.g. ATA
+TRIM) is issued.
+The device handles this as it sees fit.
+In particular it is
+.Em not
+guaranteed that discarded blocks on devices will be zeroed; reading a
+discarded block might produce zeros, or ones, or the previously
+existing data, or some other data, or trash.
+.\" XXX: if you discard part of a block in a regular file, should that
+.\" part be explicitly zeroed? Also, how do you find the underlying
+.\" block size?
 .It Fn VOP_IOCTL "vp" "command" "data" "fflag" "cred"
 Perform device-specific I/O.
 The argument
diff -r 556b0a3f3877 -r e86ccb064ba2 sys/kern/vnode_if.src
--- a/sys/kern/vnode_if.src     Fri Jul 25 08:10:31 2014 +0000
+++ b/sys/kern/vnode_if.src     Fri Jul 25 08:16:47 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: vnode_if.src,v 1.66 2014/02/07 15:26:42 hannken Exp $
+#      $NetBSD: vnode_if.src,v 1.67 2014/07/25 08:16:47 dholland Exp $
 #
 # Copyright (c) 1992, 1993
 #      The Regents of the University of California.  All rights reserved.
@@ -171,6 +171,24 @@
 };
 
 #
+#% fallocate  vp      L L L
+#
+vop_fallocate {
+       IN LOCKED=YES struct vnode *vp;
+       IN off_t pos;
+       IN off_t len;
+};
+
+#
+#% fdiscard   vp      L L L
+#
+vop_fdiscard {
+       IN LOCKED=YES struct vnode *vp;
+       IN off_t pos;
+       IN off_t len;
+};
+
+#
 #% ioctl      vp      U U U
 #
 vop_ioctl {



Home | Main Index | Thread Index | Old Index