Michael Brennan <[EMAIL PROTECTED]> wrote: > 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,
Thanks for the report. FYI, O_DIRECT works fine with ext3 at least on recent linux-2.6. But there is definitely a file-system-dependent bit here. O_DIRECT does not work on "tmpfs", and there are some restrictions even with recent reiserfs. See the comments in m4/o-direct.m4. > 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? According to open(2), the alignment requirement is 512 for linux-2.6 and FS logical block size for linux-2.4. But the worst is that for 2.4, the _transfer size_ (i.e., all read and write sizes) must also be a multiple of the logical block size of the underlying file system. I've been working, off and on, on a patch to make parted work with arbitrary "sector_size". That will be required for newer disks with larger-than-512-byte physical sector sizes. With a little luck, it'll be in shape to post soon. > 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? I wondered the same thing, and concluded "Yes", but maybe Andrew or Leslie (Cc'd) can confirm that. If so, I'll document it, so no one else has to wonder :) > 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? Another possibility is to use posix_fadvise, but that has its own problems. Some of them were discussed when we added oflag=direct support to coreutils' dd: http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/9968/focus=9982 _______________________________________________ parted-devel mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/parted-devel

