git: a638dc4ebc8e - main - vfs: Add ioflag to VOP_DEALLOCATE(9)
Ka Ho Ng
khng at FreeBSD.org
Thu Aug 12 15:06:29 UTC 2021
The branch main has been updated by khng:
URL: https://cgit.FreeBSD.org/src/commit/?id=a638dc4ebc8eaa90a87ee053b7104ee4511f4491
commit a638dc4ebc8eaa90a87ee053b7104ee4511f4491
Author: Ka Ho Ng <khng at FreeBSD.org>
AuthorDate: 2021-08-12 14:58:52 +0000
Commit: Ka Ho Ng <khng at FreeBSD.org>
CommitDate: 2021-08-12 15:03:49 +0000
vfs: Add ioflag to VOP_DEALLOCATE(9)
The addition of ioflag allows callers passing
IO_SYNC/IO_DATASYNC/IO_DIRECT down to the file system implementation.
The vop_stddeallocate fallback implementation is updated to pass the
ioflag to the file system implementation. vn_deallocate(9) internally is
also changed to pass ioflag to the VOP_DEALLOCATE call.
Sponsored by: The FreeBSD Foundation
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D31500
---
share/man/man9/VOP_DEALLOCATE.9 | 5 ++++-
share/man/man9/vn_deallocate.9 | 9 +++++++--
sys/kern/vfs_default.c | 6 +++---
sys/kern/vfs_vnops.c | 7 +++++--
sys/kern/vnode_if.src | 1 +
5 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/share/man/man9/VOP_DEALLOCATE.9 b/share/man/man9/VOP_DEALLOCATE.9
index 1c7f80cfbc6c..dbfe048f2235 100644
--- a/share/man/man9/VOP_DEALLOCATE.9
+++ b/share/man/man9/VOP_DEALLOCATE.9
@@ -27,7 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 11, 2021
+.Dd August 11, 2021
.Dt VOP_DEALLOCATE 9
.Os
.Sh NAME
@@ -42,6 +42,7 @@
.Fa "off_t *offset"
.Fa "off_t *len"
.Fa "int flags"
+.Fa "int ioflag"
.Fa "struct ucred *cred"
.Fc
.Sh DESCRIPTION
@@ -61,6 +62,8 @@ The length of the range to deallocate storage in the file.
.It Fa flags
The flags of this call.
This should be set to 0 for now.
+.It Fa ioflag
+Directives and hints to be given to the file system.
.It Fa cred
The credentials of the caller.
.El
diff --git a/share/man/man9/vn_deallocate.9 b/share/man/man9/vn_deallocate.9
index 60bcb9049e40..29edcd57ff5d 100644
--- a/share/man/man9/vn_deallocate.9
+++ b/share/man/man9/vn_deallocate.9
@@ -67,7 +67,7 @@ This must be greater than 0.
The control flags of the operation.
This should be set to 0 for now.
.It Fa ioflag
-The control flags of vnode locking.
+Directives and hints to be given to the file system.
.It Fa active_cred
The user credentials of the calling thread.
.It Fa file_cred
@@ -76,7 +76,8 @@ The credentials installed on the file description pointing to the vnode or NOCRE
.Pp
The
.Fn ioflag
-argument may be one or more of the following flags:
+argument gives directives and hints to the file system.
+It may include one or more of the following flags:
.Bl -tag -width IO_RANGELOCKED
.It Dv IO_NODELOCKED
The vnode was locked before the call.
@@ -84,6 +85,10 @@ The vnode was locked before the call.
Rangelock was owned around the call.
.It Dv IO_NOMACCHECK
Skip MAC checking in the call.
+.It Dv IO_SYNC
+Do I/O synchronously.
+.It Dv IO_DIRECT
+Attempt to bypass buffer cache.
.El
.Pp
.Fa *offset
diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c
index c42d5a795935..d9328cd39b00 100644
--- a/sys/kern/vfs_default.c
+++ b/sys/kern/vfs_default.c
@@ -1074,7 +1074,7 @@ vop_stdallocate(struct vop_allocate_args *ap)
static int
vp_zerofill(struct vnode *vp, struct vattr *vap, off_t *offsetp, off_t *lenp,
- struct ucred *cred)
+ int ioflag, struct ucred *cred)
{
int iosize;
int error = 0;
@@ -1110,7 +1110,7 @@ vp_zerofill(struct vnode *vp, struct vattr *vap, off_t *offsetp, off_t *lenp,
auio.uio_rw = UIO_WRITE;
auio.uio_td = td;
- error = VOP_WRITE(vp, &auio, 0, cred);
+ error = VOP_WRITE(vp, &auio, ioflag, cred);
if (error != 0) {
len -= xfersize - auio.uio_resid;
offset += xfersize - auio.uio_resid;
@@ -1175,7 +1175,7 @@ vop_stddeallocate(struct vop_deallocate_args *ap)
/* Fill zeroes */
xfersize = rem = omin(noff - offset, len);
- error = vp_zerofill(vp, &va, &offset, &rem, cred);
+ error = vp_zerofill(vp, &va, &offset, &rem, ap->a_ioflag, cred);
if (error) {
len -= xfersize - rem;
goto out;
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 5572c324469b..3fce590519a8 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -3509,7 +3509,7 @@ vn_deallocate_impl(struct vnode *vp, off_t *offset, off_t *length, int flags,
vp);
#endif
if (error == 0)
- error = VOP_DEALLOCATE(vp, &off, &len, flags,
+ error = VOP_DEALLOCATE(vp, &off, &len, flags, ioflag,
active_cred);
if ((ioflag & IO_NODELOCKED) == 0) {
@@ -3548,6 +3548,7 @@ vn_fspacectl(struct file *fp, int cmd, off_t *offset, off_t *length, int flags,
{
int error;
struct vnode *vp;
+ int ioflag;
vp = fp->f_vnode;
@@ -3557,9 +3558,11 @@ vn_fspacectl(struct file *fp, int cmd, off_t *offset, off_t *length, int flags,
if (vp->v_type != VREG)
return (ENODEV);
+ ioflag = get_write_ioflag(fp);
+
switch (cmd) {
case SPACECTL_DEALLOC:
- error = vn_deallocate_impl(vp, offset, length, flags, 0,
+ error = vn_deallocate_impl(vp, offset, length, flags, ioflag,
active_cred, fp->f_cred);
break;
default:
diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src
index 97ac1cff6705..ff57d1c9a28e 100644
--- a/sys/kern/vnode_if.src
+++ b/sys/kern/vnode_if.src
@@ -808,6 +808,7 @@ vop_deallocate {
INOUT off_t *offset;
INOUT off_t *len;
IN int flags;
+ IN int ioflag;
IN struct ucred *cred;
};
More information about the dev-commits-src-main
mailing list