Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-18-2008, 06:15 AM   #1
Registered: Oct 2005
Location: Germany
Distribution: Ubuntu
Posts: 58

Rep: Reputation: 24
making sense of sync()

I have a backup app that writes megabytes to a USB flash drive. Before I start the verify operation, I call sync() to make sure I am reading from the device and not from the disk cache.

The funny thing I see happening is that even when a tiny amount of data was written, the time for sync is about 30 seconds, about a factor of 100 too long. The LED on the flash drive blinks the entire time, which I think means that it is really active this long.

There seems to be no way to do cache purging on a device or process basis. I see only a file basis (fsync) or the whole system (sync). This seems crippled. Also, sync can be called by a non-privileged process, opening the door for some dirty tricks (slowing a server down to a crawl).

I am using exf2 on the flash drive. Is that significant?

Old 01-18-2008, 11:49 AM   #2
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Flash memory drives are know to be slow, but30 secs does sound like a long time.

Are you reading files, or doing directory listings, or walk through directory trees before calling sync()? If so, that maybe the cause of this long sync() time.

Most (all?) unix/linux filesystems update the the access times for files and directories. This means when you are reading a file or a directory (like 'ls' does), this causes writing access times to the meta-data of the filesystem.

If this causes you long sync() times, you can can solve it by mounting the flash drive with de "noatime" mount option to disable this behaviour. Or use vfat.

Last edited by Hko; 01-18-2008 at 11:51 AM.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Making 2 servers stay in instant sync andy7t Linux - Networking 2 12-19-2005 03:34 AM
making sense of /proc for 2.4.x kernel? thanhvn Linux - General 2 11-16-2005 08:19 PM
Windows Traceroute isnt making much sense jaz General 1 05-27-2005 02:35 PM
kernel: st0: Error with sense data: Current st09:00: sense key N da_kidd_er Linux - Hardware 0 12-16-2004 11:51 PM
Sync for Samsung Sync master Naphoon Linux - Hardware 1 10-16-2004 07:20 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:42 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration