From owner-freebsd-bugs@FreeBSD.ORG Wed Jan 14 14:59:48 2015 Return-Path: Delivered-To: freebsd-bugs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5178043D for ; Wed, 14 Jan 2015 14:59:48 +0000 (UTC) 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 mx1.freebsd.org (Postfix) with ESMTPS id 388F6C8B for ; Wed, 14 Jan 2015 14:59:48 +0000 (UTC) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.14.9/8.14.9) with ESMTP id t0EExmqa004356 for ; Wed, 14 Jan 2015 14:59:48 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 196726] fusefs truncates files on read, sometimes returns wrong data. Date: Wed, 14 Jan 2015 14:59:48 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 10.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: freebsd-stable@z42.net X-Bugzilla-Status: New X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Target-Milestone: --- 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 Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit 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.18-1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Jan 2015 14:59:48 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=196726 Bug ID: 196726 Summary: fusefs truncates files on read, sometimes returns wrong data. Product: Base System Version: 10.1-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: freebsd-bugs@FreeBSD.org Reporter: freebsd-stable@z42.net I made a python program to tickle two fusefs problems that may well be the same problem in different forms, both loosing data. I assume the problem is in the kernel and not the library, but have not verified this. (I have only looked at the symptoms.) #!/usr/bin/env python # # FreeBSD (10.1-RELEASE) fuse seems pretty buggy. # File attributes are cached forever (not tested here), and reported size # is enforced. (So appending to a file outside the fuse layer has no effect # if the file is already seen.) And even worse, the first time a file is # closed (even ro) the reported size is truncated to. This updates the # mtime, and of course risks discarding data written from somewhere else. # (This is in test1.) # # File contents are also sometimes wrong in surprising ways when a file is # overwritten. (This is in test2.) # # This program takes two directories as arguments, the first one a normal # mount and the second a fuse mount (e.g. fusexmp or sshfs) of the same dir. def test2(normal_dir, fuse_dir, test_fn): from os.path import exists, isdir, join assert isdir(normal_dir) assert isdir(fuse_dir) assert not exists(join(normal_dir, test_fn)) assert not exists(join(fuse_dir, test_fn)) with open(join(normal_dir, test_fn), "wb") as fh: fh.write("foo") with open(join(fuse_dir, test_fn), "rb") as fh: assert fh.read() == "foo", "this should work" with open(join(normal_dir, test_fn), "wb") as fh: fh.write("longer") with open(join(fuse_dir, test_fn), "rb") as fh: data = fh.read() assert data == "longer", "fuse misread %s ('longer' != %r)" % (test_fn, data,) def test1(normal_dir, fuse_dir, test_fn): from os.path import exists, isdir, join assert isdir(normal_dir) assert isdir(fuse_dir) assert not exists(join(normal_dir, test_fn)) with open(join(normal_dir, test_fn), "wb") as normal_fh: normal_fh.write("foo") normal_fh.flush() with open(join(fuse_dir, test_fn), "rb") as fuse_fh: assert fuse_fh.read() == "foo", "this should work" normal_fh.write("bar") normal_fh.flush() with open(join(normal_dir, test_fn), "rb") as normal_fh: data = normal_fh.read() assert data == "foobar", "fuse truncated %s ('foobar' != %r)" % (test_fn, data,) if __name__ == "__main__": from sys import argv from traceback import print_exc normal_dir, fuse_dir = argv[1:] try: test1(normal_dir, fuse_dir, "TEST1") except Exception: print "Test 1 failed:" print_exc() try: test2(normal_dir, fuse_dir, "TEST2") except Exception: print "Test 2 failed:" print_exc() -- You are receiving this mail because: You are the assignee for the bug.