From owner-svn-src-all@freebsd.org Sat Mar 24 13:13:53 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2B6D2F6C97D; Sat, 24 Mar 2018 13:13:53 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D39946B439; Sat, 24 Mar 2018 13:13:52 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B3E037AC2; Sat, 24 Mar 2018 13:13:52 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2ODDq8D028460; Sat, 24 Mar 2018 13:13:52 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2ODDq3a028459; Sat, 24 Mar 2018 13:13:52 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201803241313.w2ODDq3a028459@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 24 Mar 2018 13:13:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331487 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 331487 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Mar 2018 13:13:53 -0000 Author: kib Date: Sat Mar 24 13:13:52 2018 New Revision: 331487 URL: https://svnweb.freebsd.org/changeset/base/331487 Log: In vn_io_fault1(), reduce the scope where pagefaults are disabled. Most important for the future use, do not call vm_fault_quick_hold_pages() with disabled pagefaults. Reported and tested by: pho (as part of the larger patch) Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/kern/vfs_vnops.c Modified: head/sys/kern/vfs_vnops.c ============================================================================== --- head/sys/kern/vfs_vnops.c Sat Mar 24 12:57:58 2018 (r331486) +++ head/sys/kern/vfs_vnops.c Sat Mar 24 13:13:52 2018 (r331487) @@ -956,23 +956,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 @@ -1047,7 +1054,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); @@ -1073,7 +1080,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; @@ -1144,7 +1150,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); }