[parted-devel] Failure with O_DIRECT

Michael Brennan brennan.brisad at gmail.com
Sun Jul 1 02:34:37 UTC 2007


Hi,

I would like to start to contribute to a free software project, and
I've found that this one seems pretty nice.  I find filesystems
and partitions to be an interesting subject and I really hope to be
able to help in the future.  I'm now digging through the code trying
to understand it and now I wonder if you could clarify a couple of
things for me.

First of all, parted won't work on my main computer, I have
experimented a little and concluded that it is because of O_DIRECT.
I run linux on all my computers and on all the others parted works
fine, but on this one (running kernel 2.4.34.1) the read and writes
only fails with Invalid argument.  If I remove O_DIRECT it works fine,
or if I align the memory with posix_memalign() in linux_read() to
be aligned to 1024 instead of the dev->sector_size value of 512 the
read will succeed.  I picked 1024 because I read somewhere that
and O_DIRECT read/write must be aligned to the blocksize of the
filesystem, 1024 on ext3 in my case.  But that requirement
is obviously not needed on the other machines since they work
fine with 512 aligned memory.  Do you know what the real alignment
requirement is for reading/writing with O_DIRECT?

And two other questions:
1. While phys_sector_size is pretty clear, what does sector_size
(logical sector size) in PedDevice represent?  Could it be so that
this variable should be the same as the block size of the
filesystem?

2. How should the problem with O_DIRECT on my computer be solved?
Open without O_DIRECT or find out the correct alignment in some way?

Thanks,

Michael Brennan



More information about the parted-devel mailing list