From owner-freebsd-ports@FreeBSD.ORG Wed Jul 27 10:42:07 2011 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 09615106564A for ; Wed, 27 Jul 2011 10:42:07 +0000 (UTC) (envelope-from mikhail.kupchik@gmail.com) Received: from mail-vx0-f182.google.com (mail-vx0-f182.google.com [209.85.220.182]) by mx1.freebsd.org (Postfix) with ESMTP id BE8928FC0C for ; Wed, 27 Jul 2011 10:42:06 +0000 (UTC) Received: by vxg33 with SMTP id 33so1400986vxg.13 for ; Wed, 27 Jul 2011 03:42:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=mZY1lwBr4Ha2iblbc7qVkP+eYykEY7P+AXMLSxsJdqA=; b=mvxI4G3rHUWPtODuPw6WQSOoeTO4xmGurSabP+iSjqItXUqNhMl25RkNGODJsZext+ 1HG3yPBZVai0iNb6p78uPQQx9ns74kiWnmj9j+25reXL7NQWygFJctHddSWKj4ZNP7tl qj5PXXyFoA5rgx4l80J0VQakLomtXUFfrlqtk= MIME-Version: 1.0 Received: by 10.52.68.103 with SMTP id v7mr3778366vdt.470.1311761913259; Wed, 27 Jul 2011 03:18:33 -0700 (PDT) Received: by 10.52.115.196 with HTTP; Wed, 27 Jul 2011 03:18:33 -0700 (PDT) Date: Wed, 27 Jul 2011 13:18:33 +0300 Message-ID: From: Mikhail Kupchik To: freebsd-ports@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Writing large files on fusefs-ntfs mounted partition returns random errors EIO, ENOENT X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jul 2011 10:42:07 -0000 Hello All, Recently I've encountered the following problem: writing large (200MB+) files into ntfs partition managed by fuse + ntfs-3g + libublio (on umass device) yields random write errors, usually EIO or ENOENT. Versions of the software: 1) Kernel: FreeBSD-8.2-RELEASE, i386, generic 2) NTFS-3G: 2011.4.12 external FUSE 27 3) FUSE kernel module: fusefs-kmod-0.3.9.p1.20080208_7 4) FUSE userspace libs: fusefs-libs-2.7.4 5) UBLIO library (userspace cache for block devices): libublio-20070103 How To Repeat: 1) Get USB flash thumbdrive (1Gb in my case) 2) Quickformat it in Windows ("format I: /FS:NTFS /Q") and unplug via tray icon as usually 3) Plug USB flash thumbdrive to FreeBSD box 4) kldload /usr/local/modules/fuse.ko 5) ntfs-3g /dev/da0s1 /mnt/usb 6) dd if=/dev/random of=/usr/rndfile.bin bs=1M count=300 7) cp /usr/rndfile.bin /mnt/usb/rndfile.bin 8) After some time, cp exits with error message cp: /mnt/usb/rndfile.bin: No such file or directory USB subsystem is probably fine, because kernel-mode msdosfs and direct write with dd(1) works without any problems. I've tried to enable ntfs-3g debugging, and ntfs-3g works fine when it's spends additional CPU cycles printing debug info. Looks like some race condition. Writing into NTFS partition also works fine with ublio disabled, when I/O rate is low. IMO it looks like a problem in the fusefs-kmod or fusefs-libs, because ntfs-3g code is well-tested on Linux and ublio code is well-tested on Mac. Also I tried to hack ublio - add pthread locks, syncs after each write, replace pwritev(2) with series of pwrites, add assertion checks. None of these really helped, but ENOENT/EIO errors were relatively rarer, due to I/O rate slowdown I suspect. Right now I need someone who can confirm this problem in his/her environment and look into fusefs-kmod code for race conditions, as I'm not good in kernel hacking.