Page MenuHomeFreeBSD

D31500.id93526.diff
No OneTemporary

D31500.id93526.diff

Index: share/man/man9/VOP_DEALLOCATE.9
===================================================================
--- share/man/man9/VOP_DEALLOCATE.9
+++ 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 @@
.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
Index: share/man/man9/vn_deallocate.9
===================================================================
--- share/man/man9/vn_deallocate.9
+++ share/man/man9/vn_deallocate.9
@@ -27,7 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd Jul 30, 2021
+.Dd August 11, 2021
.Dt VN_DEALLOCATE 9
.Os
.Sh NAME
@@ -42,7 +42,7 @@
.Fa "off_t *offset"
.Fa "off_t *length"
.Fa "int flags"
-.Fa "int ioflg"
+.Fa "int ioflag"
.Fa "struct ucred *active_cred"
.Fa "struct ucred *file_cred"
.Fc
@@ -66,8 +66,8 @@
.It Fa flags
The control flags of the operation.
This should be set to 0 for now.
-.It Fa ioflg
-The control flags of vnode locking.
+.It Fa ioflag
+Various flag.
.It Fa active_cred
The user credentials of the calling thread.
.It Fa file_cred
@@ -75,8 +75,9 @@
.El
.Pp
The
-.Fn ioflg
-argument may be one or more of the following flags:
+.Fn ioflag
+argument give 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 @@
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
Index: sys/kern/vfs_default.c
===================================================================
--- sys/kern/vfs_default.c
+++ sys/kern/vfs_default.c
@@ -1074,7 +1074,7 @@
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 @@
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 @@
/* 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;
Index: sys/kern/vfs_vnops.c
===================================================================
--- sys/kern/vfs_vnops.c
+++ sys/kern/vfs_vnops.c
@@ -3443,7 +3443,7 @@
static int
vn_deallocate_impl(struct vnode *vp, off_t *offset, off_t *length, int flags,
- int ioflg, struct ucred *active_cred, struct ucred *file_cred)
+ int ioflag, struct ucred *active_cred, struct ucred *file_cred)
{
struct mount *mp;
void *rl_cookie;
@@ -3459,7 +3459,7 @@
off = *offset;
len = *length;
- if ((ioflg & (IO_NODELOCKED|IO_RANGELOCKED)) == 0)
+ if ((ioflag & (IO_NODELOCKED|IO_RANGELOCKED)) == 0)
rl_cookie = vn_rangelock_wlock(vp, off, off + len);
while (len > 0 && error == 0) {
/*
@@ -3469,7 +3469,7 @@
* pass.
*/
- if ((ioflg & IO_NODELOCKED) == 0) {
+ if ((ioflag & IO_NODELOCKED) == 0) {
bwillwrite();
if ((error = vn_start_write(vp, &mp,
V_WAIT | PCATCH)) != 0)
@@ -3484,15 +3484,15 @@
#endif
#ifdef MAC
- if ((ioflg & IO_NOMACCHECK) == 0)
+ if ((ioflag & IO_NOMACCHECK) == 0)
error = mac_vnode_check_write(active_cred, file_cred,
vp);
#endif
if (error == 0)
- error = VOP_DEALLOCATE(vp, &off, &len, flags,
+ error = VOP_DEALLOCATE(vp, &off, &len, flags, ioflag,
active_cred);
- if ((ioflg & IO_NODELOCKED) == 0) {
+ if ((ioflag & IO_NODELOCKED) == 0) {
VOP_UNLOCK(vp);
if (mp != NULL) {
vn_finished_write(mp);
@@ -3510,7 +3510,7 @@
int
vn_deallocate(struct vnode *vp, off_t *offset, off_t *length, int flags,
- int ioflg, struct ucred *active_cred, struct ucred *file_cred)
+ int ioflag, struct ucred *active_cred, struct ucred *file_cred)
{
if (*offset < 0 || *length <= 0 || *length > OFF_MAX - *offset ||
flags != 0)
@@ -3518,7 +3518,7 @@
if (vp->v_type != VREG)
return (ENODEV);
- return (vn_deallocate_impl(vp, offset, length, flags, ioflg,
+ return (vn_deallocate_impl(vp, offset, length, flags, ioflag,
active_cred, file_cred));
}
@@ -3528,8 +3528,11 @@
{
int error;
struct vnode *vp;
+ struct mount *mp;
+ int ioflag;
vp = fp->f_vnode;
+ ioflag = 0;
if (cmd != SPACECTL_DEALLOC || *offset < 0 || *length <= 0 ||
*length > OFF_MAX - *offset || flags != 0)
@@ -3537,9 +3540,22 @@
if (vp->v_type != VREG)
return (ENODEV);
+ mp = atomic_load_ptr(&vp->v_mount);
+ if ((fp->f_flag & O_FSYNC) ||
+ (mp != NULL && (mp->mnt_flag & MNT_SYNCHRONOUS)))
+ ioflag |= IO_SYNC;
+
+ /*
+ * For O_DSYNC we set both IO_SYNC and IO_DATASYNC, so that
+ * VOP_DEALLOCATE() implementations that don't understand IO_DATASYNC
+ * fall back to full O_SYNC behavior.
+ */
+ if (fp->f_flag & O_DSYNC)
+ ioflag |= IO_SYNC | IO_DATASYNC;
+
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:
Index: sys/kern/vnode_if.src
===================================================================
--- sys/kern/vnode_if.src
+++ sys/kern/vnode_if.src
@@ -808,6 +808,7 @@
INOUT off_t *offset;
INOUT off_t *len;
IN int flags;
+ IN int ioflag;
IN struct ucred *cred;
};

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 29, 2:28 AM (14 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26314490
Default Alt Text
D31500.id93526.diff (6 KB)

Event Timeline