[Interest] QFile copy and sync/fsync

Nikos Chantziaras realnc at gmail.com
Thu Jan 3 20:45:39 CET 2013


On 03/01/13 21:13, Duane wrote:
> On 01/03/2013 12:45 PM, Nikos Chantziaras wrote:
>> Keep in mind that if you're not mounting synchronously by default, then
>> removing the stick without unmounting it can lead to filesystem
>> corruption and inconsistencies.
>>
>> The fact that it's a USB stick doesn't matter.  The only thing that
>> matters is that a non-synchronous filesystem is being removed while it's
>> still live.
>
> Yes, the first thing that I tried was to change the mount to
> synchronous.  It solves the problem but what it does is a bit strange.
> I have a loop that I copy N files.  After all N are copied, it gets
> synced which makes the system non-responsive for some amount of time.  I
> would prefer it to sync them on each copy.

Have you tried to open the files in QIODevice::Unbuffered mode?  If you 
do that, then the data should be written out immediately when the 
filesystem is mounted synchronously.




More information about the Interest mailing list