Re: Sync option destroys flash!

From: Denis Vlasenko (vda_at_ilport.com.ua)
Date: 05/15/05

  • Next message: Fabio Rosciano: "[2.6.12-rc4] Oops in reiserfs_panic [please CC]"
    To: mhw@wittsend.com, linux-kernel@vger.kernel.org
    Date:	Sun, 15 May 2005 22:00:26 +0300
    
    

    On Friday 13 May 2005 19:20, Michael H. Warfield wrote:
    > Under the right circumstances, even copying a single file to a flash
    > drive mounted with the "sync" option can destroy the entire drive!
    >
    > Now that I have your attention!
    >
    > I found this out the hard way. (Kissed one brand new $70 USD 1GB flash
    > drive good-bye.) According to the man pages for mount, FAT and VFAT
    > file systems ignore the "sync" option. It lies. Maybe it use to be
    > true, but it certainly lies now. A simple test can verify this. Mount
    > a flash drive with a FAT/VFAT file system without the sync option and
    > writes to the drive go very fast. Typing "sync" or unmounting the drive
    > afterwards, takes time as the buffered data is written to the flash
    > drive. This is as it should be. Mount it with the sync option and
    > writes are really REALLY slow (worse than they should be just from
    > copying the data through USB) but sync and umount come back immediately
    > and result in no additional writing to the drive. [Do the preceding
    > with only a few files and less than a few meg of data if you value that
    > flash.] So... FAT and VFAT are honoring the sync option. This is very
    > VERY bad. It's bad for floppies, it's bad for hard drives, it's FATAL
    > for flash drives.
    >
    > Flash drives have a limited number of write cycles. Many many
    > thousands of write cycles, but limited, none the less. They are also
    > written in blocks which are much larger than the "sector" size report
    > (several K in a physical nand flash block, IRC).
    >
    > What happens, with the sync option on a VFAT file system, is that the
    > FAT tables are getting pounded and over-written over and over and over
    > again as each and every block/cluster is allocated while a new file is
    > written out. This constant overwriting eventually wears out the first
    > block or two of the flash drive.

    What we really need, is a less thorough version of O_SYNC.
    O_SYNC currently guarantees that when syscall returns, data
    is on media (or at least in disk drive's internal cache :).

    This is exactly what really paranoid people want.
    Journalling labels, all that good stuff.

    But there are many cases where people just want to say
    'write out dirty data asap for this device', so that
    I can copy files to floppy, wait till it stops making
    noise, and eject a disk. Samr for flash if it has write
    indicator (mine has a diode).

    The difference from O_SYNC is that in this O_LAZY_SYNC mode
    writes return early, just filling pagecache, but writeout
    is started immediately and continues until there is no dirty
    O_LAZY_SYNC data.

    This mode won't eat flash as fast as O_SYNC does.

    --
    vda
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Fabio Rosciano: "[2.6.12-rc4] Oops in reiserfs_panic [please CC]"

    Relevant Pages

    • Re: Sync option destroys flash!
      ... According to the man pages for mount, FAT and VFAT ... takes time as the buffered data is written to the flash ... Mount it with the sync option and ... It's bad for floppies, it's bad for hard drives, it's FATAL ...
      (Linux-Kernel)
    • Sync option destroys flash!
      ... According to the man pages for mount, FAT and VFAT ... file systems ignore the "sync" option. ... takes time as the buffered data is written to the flash ... It's bad for floppies, it's bad for hard drives, it's FATAL ...
      (Linux-Kernel)
    • Re: [patch] ext2/3: document conditions when reliable operation is possible
      ... gig flash key I bought retail at Fry's is 2 megabytes, ... their write block size isn't remotely the same as hard drives', ... allocate an empty eraseblock to put the data on ...
      (Linux-Kernel)
    • Re: breaking passwords on discs containing Word docs
      ... from flash media. ... Word MVP web site http://word.mvps.org ... The OP said nothing about flash drives. ... Flash memory can get corrupted in exactly the same manner than HDD ...
      (microsoft.public.word.docmanagement)
    • Re: breaking passwords on discs containing Word docs
      ... OP said nothing about flash drives. ... corruption with flash memory than HDD memory, but in a NG, you will always ... My web site www.gmayor.com ...
      (microsoft.public.word.docmanagement)