From owner-svn-src-all@freebsd.org Mon Dec 30 18:11:08 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 77A911E610B; Mon, 30 Dec 2019 18:11:08 +0000 (UTC) (envelope-from kaktus@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47mlqJ29Fsz4K9m; Mon, 30 Dec 2019 18:11:08 +0000 (UTC) (envelope-from kaktus@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 459A15B63; Mon, 30 Dec 2019 18:11:08 +0000 (UTC) (envelope-from kaktus@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBUIB8Ak063407; Mon, 30 Dec 2019 18:11:08 GMT (envelope-from kaktus@FreeBSD.org) Received: (from kaktus@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBUIB7iV063402; Mon, 30 Dec 2019 18:11:07 GMT (envelope-from kaktus@FreeBSD.org) Message-Id: <201912301811.xBUIB7iV063402@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kaktus set sender to kaktus@FreeBSD.org using -f From: Pawel Biernacki Date: Mon, 30 Dec 2019 18:11:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356206 - in head/sys: amd64/linux amd64/linux32 arm64/linux compat/linux i386/linux X-SVN-Group: head X-SVN-Commit-Author: kaktus X-SVN-Commit-Paths: in head/sys: amd64/linux amd64/linux32 arm64/linux compat/linux i386/linux X-SVN-Commit-Revision: 356206 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.29 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: Mon, 30 Dec 2019 18:11:08 -0000 Author: kaktus Date: Mon Dec 30 18:11:06 2019 New Revision: 356206 URL: https://svnweb.freebsd.org/changeset/base/356206 Log: linux(4): implement copy_file_range(2) copy_file_range(2) is implemented natively since r350315, make it available for Linux binaries too. Reviewed by: kib (mentor), trasz (previous version) Approved by: kib (mentor) Differential Revision: https://reviews.freebsd.org/D22959 Modified: head/sys/amd64/linux/linux_dummy.c head/sys/amd64/linux32/linux32_dummy.c head/sys/arm64/linux/linux_dummy.c head/sys/compat/linux/linux_file.c head/sys/i386/linux/linux_dummy.c Modified: head/sys/amd64/linux/linux_dummy.c ============================================================================== --- head/sys/amd64/linux/linux_dummy.c Mon Dec 30 17:18:50 2019 (r356205) +++ head/sys/amd64/linux/linux_dummy.c Mon Dec 30 18:11:06 2019 (r356206) @@ -144,8 +144,6 @@ DUMMY(userfaultfd); DUMMY(membarrier); /* Linux 4.4: */ DUMMY(mlock2); -/* Linux 4.5: */ -DUMMY(copy_file_range); /* Linux 4.6: */ DUMMY(preadv2); DUMMY(pwritev2); Modified: head/sys/amd64/linux32/linux32_dummy.c ============================================================================== --- head/sys/amd64/linux32/linux32_dummy.c Mon Dec 30 17:18:50 2019 (r356205) +++ head/sys/amd64/linux32/linux32_dummy.c Mon Dec 30 18:11:06 2019 (r356206) @@ -148,8 +148,6 @@ DUMMY(userfaultfd); DUMMY(membarrier); /* Linux 4.4: */ DUMMY(mlock2); -/* Linux 4.5: */ -DUMMY(copy_file_range); /* Linux 4.6: */ DUMMY(preadv2); DUMMY(pwritev2); Modified: head/sys/arm64/linux/linux_dummy.c ============================================================================== --- head/sys/arm64/linux/linux_dummy.c Mon Dec 30 17:18:50 2019 (r356205) +++ head/sys/arm64/linux/linux_dummy.c Mon Dec 30 18:11:06 2019 (r356206) @@ -142,8 +142,6 @@ DUMMY(userfaultfd); DUMMY(membarrier); /* Linux 4.4: */ DUMMY(mlock2); -/* Linux 4.5: */ -DUMMY(copy_file_range); /* Linux 4.6: */ DUMMY(preadv2); DUMMY(pwritev2); Modified: head/sys/compat/linux/linux_file.c ============================================================================== --- head/sys/compat/linux/linux_file.c Mon Dec 30 17:18:50 2019 (r356205) +++ head/sys/compat/linux/linux_file.c Mon Dec 30 18:11:06 2019 (r356206) @@ -1565,3 +1565,44 @@ linux_fallocate(struct thread *td, struct linux_falloc return (kern_posix_fallocate(td, args->fd, args->offset, args->len)); } + +int +linux_copy_file_range(struct thread *td, struct linux_copy_file_range_args + *args) +{ + l_loff_t inoff, outoff, *inoffp, *outoffp; + int error, flags; + + /* + * copy_file_range(2) on Linux doesn't define any flags (yet), so is + * the native implementation. Enforce it. + */ + if (args->flags != 0) { + linux_msg(td, "copy_file_range unsupported flags 0x%x", + args->flags); + return (EINVAL); + } + flags = 0; + inoffp = outoffp = NULL; + if (args->off_in != NULL) { + error = copyin(args->off_in, &inoff, sizeof(l_loff_t)); + if (error != 0) + return (error); + inoffp = &inoff; + } + if (args->off_out != NULL) { + error = copyin(args->off_out, &outoff, sizeof(l_loff_t)); + if (error != 0) + return (error); + outoffp = &outoff; + } + + error = kern_copy_file_range(td, args->fd_in, inoffp, args->fd_out, + outoffp, args->len, flags); + if (error == 0 && args->off_in != NULL) + error = copyout(inoffp, args->off_in, sizeof(l_loff_t)); + if (error == 0 && args->off_out != NULL) + error = copyout(outoffp, args->off_out, sizeof(l_loff_t)); + return (error); +} + Modified: head/sys/i386/linux/linux_dummy.c ============================================================================== --- head/sys/i386/linux/linux_dummy.c Mon Dec 30 17:18:50 2019 (r356205) +++ head/sys/i386/linux/linux_dummy.c Mon Dec 30 18:11:06 2019 (r356206) @@ -144,8 +144,6 @@ DUMMY(userfaultfd); DUMMY(membarrier); /* Linux 4.4: */ DUMMY(mlock2); -/* Linux 4.5: */ -DUMMY(copy_file_range); /* Linux 4.6: */ DUMMY(preadv2); DUMMY(pwritev2);