open(filename, O_DIRECT) on ntfs fails

Bug #269946 reported by Agostino Russo
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Expired
Undecided
Unassigned

Bug Description

It is not possible to open files in an ntfs/fuse partition when the O_DIRECT flag is used with the 2.6.27-2 kernel ("invalid argument" is returned). Hardy (2.6.24) is not affected, opening files on other file systems works ok.

To reproduce try to open a file within an ntfs partition using open(filename, O_RDONLY|O_DIRECT)

This also affects Wubi (parted_server strace follows):

8222 read(4, "Retry\n", 4096) = 6
8222 open("/host/ubuntu/disks/swap.disk", O_RDWR|O_DIRECT|O_LARGEFILE) = -1 EINVAL (Invalid argument)
8222 open("/host/ubuntu/disks/swap.disk", O_RDONLY|O_DIRECT|O_LARGEFILE) = -1 EINVAL (Invalid argument)
8222 write(5, "Error\n", 6) = 6

Agostino Russo (ago)
description: updated
Revision history for this message
Szabolcs Szakacsits (szaka) wrote :

Can you reproduce with non-swap files too? If the swap is on then the error is correct (protects from crash, system corruption) though I think the errno is indeed misleading (it's a kernel problem).

Revision history for this message
Agostino Russo (ago) wrote : Re: [Bug 269946] Re: open(filename, O_DIRECT) on ntfs fails

Yes szaka, that seems to happen with any file in an ntfs filesystem.
At least when using the 2.6.27-2 kernel.
I just happened to discover it while parted_server was trying to open
the swap.disk file.

On Sat, Sep 13, 2008 at 9:44 PM, Szabolcs Szakacsits <email address hidden> wrote:
> Can you reproduce with non-swap files too? If the swap is on then the
> error is correct (protects from crash, system corruption) though I think
> the errno is indeed misleading (it's a kernel problem).
>
> --
> open(filename, O_DIRECT) on ntfs fails
> https://bugs.launchpad.net/bugs/269946
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in "linux" source package in Ubuntu: New
>
> Bug description:
> It is not possible to open files in an ntfs/fuse partition when the O_DIRECT flag is used with the 2.6.27-2 kernel ("invalid argument" is returned). Hardy (2.6.24) is not affected, opening files on other file systems works ok.
>
> To reproduce try to open a file within an ntfs partition using open(filename, O_RDONLY|O_DIRECT)
>
> This also affects Wubi (partman_server strace follows):
>
> 8222 read(4, "Retry\n", 4096) = 6
> 8222 open("/host/ubuntu/disks/swap.disk", O_RDWR|O_DIRECT|O_LARGEFILE) = -1 EINVAL (Invalid argument)
> 8222 open("/host/ubuntu/disks/swap.disk", O_RDONLY|O_DIRECT|O_LARGEFILE) = -1 EINVAL (Invalid argument)
> 8222 write(5, "Error\n", 6) = 6
>

description: updated
Revision history for this message
Szabolcs Szakacsits (szaka) wrote :

Thanks. The issue is added to the TODO list. NTFS-3G never supported O_DIRECT. It was just an accident that it (incorrectly) "worked" in the past which, it seems, was fixed by the kernel.

Revision history for this message
Colin Watson (cjwatson) wrote :

open(2) does seem to document that O_DIRECT may fail with EINVAL if the file system doesn't support it, so this may actually be the right thing to do if ntfs-3g doesn't provide this feature ...

Revision history for this message
Colin Ian King (colin-king) wrote :

Ago, From the name of the file "/host/ubuntu/disks/swap.disk" I assume this is a swap file.

I also suspect that opening the swap with O_DIRECT is a bit of an over kill for two reasons:

1. Loss of power before data is written back to this is not critical since it's swap
2. You probably want it to be as fast as possible

So removing the O_DIRECT flag is in fact beneficial to performance and does not impact on file system consistency.

Revision history for this message
Agostino Russo (ago) wrote :

Colin King,

Parted was in fact fixed by Soren (#252684) so Wubi installation completes now. It might be though that open + O_DIRECT is used elsewhere and I wouldn't be too surprised if the problem will bite us again (half an issue though since O_DIRECT in a nested ext3 fs is OK). Even so, if EINVAL is the correct behaviour whenever O_DIRECT is not supported, it is up to the application developers to trap the error. Of course it would be nice to have that working in ntfs to begin with.

tags: added: kj-omit
Revision history for this message
kornelix (mikecorn-deactivatedaccount) wrote :

Still a problem in 9.04 and 9.10.

Revision history for this message
Jeremy Foshee (jeremyfoshee) wrote :

Hi Agostino,

This bug was reported a while ago and there hasn't been any activity in it recently. We were wondering if this is still an issue? Can you try with the latest development release of Ubuntu? ISO CD images are available from http://cdimage.ubuntu.com/releases/ .

If it remains an issue, could you run the following command from a Terminal (Applications->Accessories->Terminal). It will automatically gather and attach updated debug information to this report.

apport-collect -p linux 269946

Also, if you could test the latest upstream kernel available that would be great. It will allow additional upstream developers to examine the issue. Refer to https://wiki.ubuntu.com/KernelMainlineBuilds . Once you've tested the upstream kernel, please remove the 'needs-upstream-testing' tag. This can be done by clicking on the yellow pencil icon next to the tag located at the bottom of the bug description and deleting the 'needs-upstream-testing' text. Please let us know your results.

Thanks in advance.

    [This is an automated message. Apologies if it has reached you inappropriately; please just reply to this message indicating so.]

tags: added: needs-kernel-logs
tags: added: needs-upstream-testing
tags: added: kj-triage
Changed in linux (Ubuntu):
status: New → Incomplete
Revision history for this message
Jeremy Foshee (jeremyfoshee) wrote :

This bug report was marked as Incomplete and has not had any updated comments for quite some time. As a result this bug is being closed. Please reopen if this is still an issue in the current Ubuntu release http://www.ubuntu.com/getubuntu/download . Also, please be sure to provide any requested information that may have been missing. To reopen the bug, click on the current status under the Status column and change the status back to "New". Thanks.

[This is an automated message. Apologies if it has reached you inappropriately; please just reply to this message indicating so.]

tags: added: kj-expired
Changed in linux (Ubuntu):
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.