[issue5396] os.read not handling O_DIRECT flag

2019-09-13 Thread Michael Mol


Michael Mol  added the comment:

I wound up writing it in C++ instead, and my then-employer eventually opened my 
code. https://github.com/VirtualInterconnect/diskstress

--

___
Python tracker 
<https://bugs.python.org/issue5396>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5396] os.read not handling O_DIRECT flag

2016-09-13 Thread Michael Mol

Michael Mol added the comment:

I need to remember not to try to write quick programs in Python that need 
O_DIRECT.

My use case: I'm attempting to write a program that forces the disk to seek to 
a particular place, as part of burning in the disk.

My algorithm goes:

1. Seek to the beginning of the disk
2. Write to the disk
3. Seek to the end of the disk
4. Write to the disk
5. Seek to the beginning of the disk
6. Read from the disk
7. Seek to the end of the disk
8. Read from the disk

It then repeats with offsets, leading the seek distance to shrink until the two 
positions overlap at the center of the disk, and then expand as the positions 
diverge to the opposite end of the disk from where they began.

It's straightforward, and can be done using mmap and os.write as far as the 
writing side of things goes, but it does not work on the reading side, as even 
this workaround does not work:

d = os.open(disk_file_path, os.O_RDWR | os.O_DIRECT | os.O_SYNC | os.O_DSYNC)
readbuf = mmap.mmap(-1, 4096)
os.lseek(d, 0, os.SEEK_SET)
fo = os.fdopen(d, 'rb')
fo.readinto(readbuf)

... I get errno 22 on the final line. Apparently, code similar to that used to 
work, but no longer does.

------
nosy: +Michael Mol

___
Python tracker 
<http://bugs.python.org/issue5396>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com