Re: [ntfs-3g-devel] ENOSPC when adding file to directory with near-full MFT record
On Wed, Nov 04, 2015 at 08:10:56AM +0100, Jean-Pierre André wrote: > Hi Eric, > > Attached is the patch (simpler than I first thought). > > Jean-Pierre Thanks. I tested the patch and it made the ENOSPC problem go away. I'm currently trying to track down a corruption problem that seems to trigger under a similar set of very specific circumstances. It occurs both before and after this patch, and I expect it is a different problem. More information to come... -- ___ ntfs-3g-devel mailing list ntfs-3g-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ntfs-3g-devel
Re: [ntfs-3g-devel] ENOSPC when adding file to directory with near-full MFT record
Hi Eric, Attached is the patch (simpler than I first thought). Jean-Pierre Eric Biggers wrote: Hi, During a randomized test I discovered that ntfs_create() can fail with ENOSPC when adding a file to a directory that has many named data streams, independently of the size of the volume. I am still investigating the problem, but I thought I'd post some reproducing code. The problem is very sensitive to the length of the directory name and the number of named data streams; it even goes away if the number of named data streams is *increased*. So far I am thinking that the bug has to do with the MFT record filling up just as the child file is added and the existing attribute records not being correctly moved to an AT_ATTRIBUTE_LIST attribute. The problem can be reproduced on a FUSE mount using the script below: #!/bin/bash set -e dirname="rgclucukwqvcoheicmlkgmshlqddqnrxebzrftwndexmfxulbrqiqxeqxxyhjgyprdpekooto" fallocate -l 1G ntfs.img mkntfs --fast --force ntfs.img mkdir -p mnt ntfs-3g ntfs.img mnt echo "Creating directory mnt/$dirname" mkdir mnt/$dirname for stream_name in {a..p}; do echo "Creating named stream mnt/$dirname:$stream_name" setfattr -n user.$stream_name -v 0x mnt/$dirname done pathname="mnt/$dirname/a" echo "Creating file $pathname" touch $pathname # Fails with "No space left on device" -- ___ ntfs-3g-devel mailing list ntfs-3g-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ntfs-3g-devel index-root-overflow.patch Description: application/download -- ___ ntfs-3g-devel mailing list ntfs-3g-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ntfs-3g-devel
Re: [ntfs-3g-devel] ENOSPC when adding file to directory with near-full MFT record
Hi Eric, Hmm, yes there apparently still is an unimplemented corner case. This is in ntfs_ir_reparent() in index.c, there is the comment : /* FIXME: revert index root */ goto clear_bmp; This happens when there is no more space to extend the resident index root, and no space either to create a non-resident index allocation. The current code leaves the MFT record in a bad state (index root structured to non resident index, but no index allocation). Reverting to the initial state is not satisfactory, a new extent has to be allocated and some attribute has to be expelled from the initial entry to make space. I cannot fix this at the moment, will do later. Jean-Pierre Eric Biggers wrote: > Hi, > > During a randomized test I discovered that ntfs_create() can fail with ENOSPC > when adding a file to a directory that has many named data streams, > independently of the size of the volume. I am still investigating the > problem, > but I thought I'd post some reproducing code. The problem is very sensitive > to > the length of the directory name and the number of named data streams; it even > goes away if the number of named data streams is *increased*. So far I am > thinking that the bug has to do with the MFT record filling up just as the > child > file is added and the existing attribute records not being correctly moved to > an > AT_ATTRIBUTE_LIST attribute. > > The problem can be reproduced on a FUSE mount using the script below: > > #!/bin/bash > > set -e > > dirname="rgclucukwqvcoheicmlkgmshlqddqnrxebzrftwndexmfxulbrqiqxeqxxyhjgyprdpekooto" > fallocate -l 1G ntfs.img > mkntfs --fast --force ntfs.img > mkdir -p mnt > ntfs-3g ntfs.img mnt > echo "Creating directory mnt/$dirname" > mkdir mnt/$dirname > for stream_name in {a..p}; do > echo "Creating named stream mnt/$dirname:$stream_name" > setfattr -n user.$stream_name -v 0x mnt/$dirname > done > pathname="mnt/$dirname/a" > echo "Creating file $pathname" > touch $pathname # Fails with "No space left on device" > -- ___ ntfs-3g-devel mailing list ntfs-3g-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ntfs-3g-devel