LWN.net Logo

Ext4 data corruption trouble [Updated]

Ext4 data corruption trouble [Updated]

Posted Oct 26, 2012 0:44 UTC (Fri) by jhardin (guest, #3297)
In reply to: Ext4 data corruption trouble [Updated] by wahern
Parent article: Ext4 data corruption trouble [Updated]

I still have an ingrained habit of typing `sync' at idle moments in my shell, picked up in the early days of ext2.
+1, except I picked up the habit on SCO Xenix.

sync;sync;sync


(Log in to post comments)

Ext4 data corruption trouble [Updated]

Posted Oct 26, 2012 1:22 UTC (Fri) by pr1268 (subscriber, #24648) [Link]

I like this solution:

/* 3sync.c */
#include <unistd.h> /* for sync(2) */
#include <time.h>   /* for struct timespec and nanosleep(2) */

int main()
{
    struct timespec ts = { 0, 1000000L };
    sync();
    (void) nanosleep(&ts, 0);
    sync();
    (void) nanosleep(&ts, 0);
    sync();
    return 0;
}

Compiled and placed in $HOME/bin (which is in $PATH), and now it gets used quite frequently in other scripts I run. Which either (1) is horribly inefficient, and/or (2) shows how paranoid I am with data corruption. Sigh.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds