Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Mar 2018 12:44:11 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r331840 - stable/11/sys/kern
Message-ID:  <201803311244.w2VCiBW6051562@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sat Mar 31 12:44:11 2018
New Revision: 331840
URL: https://svnweb.freebsd.org/changeset/base/331840

Log:
  MFC r331487:
  In vn_io_fault1(), reduce the scope where pagefaults are disabled.

Modified:
  stable/11/sys/kern/vfs_vnops.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/kern/vfs_vnops.c
==============================================================================
--- stable/11/sys/kern/vfs_vnops.c	Sat Mar 31 12:43:07 2018	(r331839)
+++ stable/11/sys/kern/vfs_vnops.c	Sat Mar 31 12:44:11 2018	(r331840)
@@ -954,23 +954,30 @@ static int
 vn_io_fault_doio(struct vn_io_fault_args *args, struct uio *uio,
     struct thread *td)
 {
+	int error, save;
 
+	error = 0;
+	save = vm_fault_disable_pagefaults();
 	switch (args->kind) {
 	case VN_IO_FAULT_FOP:
-		return ((args->args.fop_args.doio)(args->args.fop_args.fp,
-		    uio, args->cred, args->flags, td));
+		error = (args->args.fop_args.doio)(args->args.fop_args.fp,
+		    uio, args->cred, args->flags, td);
+		break;
 	case VN_IO_FAULT_VOP:
 		if (uio->uio_rw == UIO_READ) {
-			return (VOP_READ(args->args.vop_args.vp, uio,
-			    args->flags, args->cred));
+			error = VOP_READ(args->args.vop_args.vp, uio,
+			    args->flags, args->cred);
 		} else if (uio->uio_rw == UIO_WRITE) {
-			return (VOP_WRITE(args->args.vop_args.vp, uio,
-			    args->flags, args->cred));
+			error = VOP_WRITE(args->args.vop_args.vp, uio,
+			    args->flags, args->cred);
 		}
 		break;
+	default:
+		panic("vn_io_fault_doio: unknown kind of io %d %d",
+		    args->kind, uio->uio_rw);
 	}
-	panic("vn_io_fault_doio: unknown kind of io %d %d", args->kind,
-	    uio->uio_rw);
+	vm_fault_enable_pagefaults(save);
+	return (error);
 }
 
 static int
@@ -1045,7 +1052,7 @@ vn_io_fault1(struct vnode *vp, struct uio *uio, struct
 	vm_offset_t addr, end;
 	size_t len, resid;
 	ssize_t adv;
-	int error, cnt, save, saveheld, prev_td_ma_cnt;
+	int error, cnt, saveheld, prev_td_ma_cnt;
 
 	if (vn_io_fault_prefault) {
 		error = vn_io_fault_prefault_user(uio);
@@ -1071,7 +1078,6 @@ vn_io_fault1(struct vnode *vp, struct uio *uio, struct
 	short_uio.uio_rw = uio->uio_rw;
 	short_uio.uio_td = uio->uio_td;
 
-	save = vm_fault_disable_pagefaults();
 	error = vn_io_fault_doio(args, uio, td);
 	if (error != EFAULT)
 		goto out;
@@ -1142,7 +1148,6 @@ vn_io_fault1(struct vnode *vp, struct uio *uio, struct
 	td->td_ma_cnt = prev_td_ma_cnt;
 	curthread_pflags_restore(saveheld);
 out:
-	vm_fault_enable_pagefaults(save);
 	free(uio_clone, M_IOV);
 	return (error);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803311244.w2VCiBW6051562>