From owner-freebsd-bugs@freebsd.org Wed Jan 31 13:40:50 2018 Return-Path: Delivered-To: freebsd-bugs@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 E3061ECBDFD for ; Wed, 31 Jan 2018 13:40:49 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.ysv.freebsd.org (mxrelay.ysv.freebsd.org [IPv6:2001:1900:2254:206a::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.ysv.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6563184392 for ; Wed, 31 Jan 2018 13:40:49 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.ysv.freebsd.org (Postfix) with ESMTPS id 77F4A1BB3 for ; Wed, 31 Jan 2018 13:40:48 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id w0VDempQ034788 for ; Wed, 31 Jan 2018 13:40:48 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id w0VDemQd034787 for freebsd-bugs@FreeBSD.org; Wed, 31 Jan 2018 13:40:48 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 225586] ftruncate+mmap+fsync fails for small maps Date: Wed, 31 Jan 2018 13:40:48 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: misc X-Bugzilla-Version: 11.1-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: tris_vern@hotmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Jan 2018 13:40:50 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D225586 Bug ID: 225586 Summary: ftruncate+mmap+fsync fails for small maps Product: Base System Version: 11.1-STABLE Hardware: amd64 OS: Any Status: New Severity: Affects Many People Priority: --- Component: misc Assignee: freebsd-bugs@FreeBSD.org Reporter: tris_vern@hotmail.com Created attachment 190220 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D190220&action= =3Dedit test on tmp filesystem that can be unmounted When doing an ftruncate+mmap+fsync to a size less than 512 bytes the data n= ever seems to be sync'd properly to disk. This work fine on the latest 11.1-RELEASE but not the latest 11.1-STABLE. I= t is also ok if the ftruncate is to the existing file size. While the mapped changes are visible in the file before an umount, after ev= en a failed umount, the changes are no longer present. (non-error checked) C code below. After running the binary, check the contents of the file (eg hd) and it wil= l be all 0xFF. Then, umount the filesystem you are on*. Then check the contents = of the file again. It will now be 0x01. Running extra sync's or fsync's from the command line before the umount doe= sn't seem to help. * The umount should fail but still shows the problem. However note it doesn= 't seem to work with the error given for the root filesystem "/". I've also attached a script that creates a filesystem to umount --- #include #include #include #include #include #include int main (int argc, char *argv[]) { int fd; size_t i, size1, size2; char *data; char *filename; char pattern =3D 0x01; if (argc < 2) { fprintf(stderr, "Usage: %s filename size1 size2\n", argv[0]); exit(1); } filename =3D argv[1]; size1 =3D atoi(argv[2]); size2 =3D atoi(argv[3]); fd =3D open(filename, O_RDWR | O_TRUNC | O_CREAT, 0644); for (i =3D 0; i < size1; i++) write(fd, &pattern, 1); close(fd); fd =3D open(filename, O_RDWR, 0644); ftruncate(fd, size2); data =3D mmap(NULL, size2, PROT_READ|PROT_WRITE,MAP_SHARED,fd,0); memset(data, 0xFF, size2); fsync(fd); munmap(data, size2); close(fd); } --=20 You are receiving this mail because: You are the assignee for the bug.=