Prev: Learn about proxy sites and how to use them to open blocked sites unlimited downloads from RapidShare and megaupload and increase the speed of the Internet with new sites for free
Next: How reliable are named pipes?
From: Peter Olcott on 8 Apr 2010 12:58 Is there a completely certain way that a write to a file can be flushed to the disk that encompasses every possible memory buffer, including the hard drives onboard cache? I want to be able to yank the power cord at any moment and not get corrupted data other than the most recent single transaction.
From: Ian Collins on 8 Apr 2010 18:03 On 04/ 9/10 04:58 AM, Peter Olcott wrote: > Is there a completely certain way that a write to a file > can be flushed to the disk that encompasses every possible > memory buffer, including the hard drives onboard cache? I > want to be able to yank the power cord at any moment and not > get corrupted data other than the most recent single > transaction. Does the O_SYNC flag to open meet your requirements? I've removed c.p.t from the cross-post, it isn't appropriate. -- Ian Collins
From: Peter Olcott on 8 Apr 2010 19:10 "Ian Collins" <ian-news(a)hotmail.com> wrote in message news:82724vFp8jU6(a)mid.individual.net... > On 04/ 9/10 04:58 AM, Peter Olcott wrote: >> Is there a completely certain way that a write to a file >> can be flushed to the disk that encompasses every >> possible >> memory buffer, including the hard drives onboard cache? >> I >> want to be able to yank the power cord at any moment and >> not >> get corrupted data other than the most recent single >> transaction. > > Does the O_SYNC flag to open meet your requirements? > > I've removed c.p.t from the cross-post, it isn't > appropriate. > > -- > Ian Collins I am not sure. So far the solution involves using open/read/write && fsync() && turning the drive's write buffering off. There is an alternative use of setvbuf() and/or fflush() if I would use buffered file access. I am not sure where the O_SYNC flag fits into all this, I would guess that it is another missing detail of the first option.
From: Chris Friesen on 8 Apr 2010 19:13 On 04/08/2010 10:58 AM, Peter Olcott wrote: > Is there a completely certain way that a write to a file > can be flushed to the disk that encompasses every possible > memory buffer, including the hard drives onboard cache? I > want to be able to yank the power cord at any moment and not > get corrupted data other than the most recent single > transaction. Do you know what OS, OS version, filesystem, disk controller, and hard disk you're using? If not, then the generic answer is that you need to disable the hard drive cache. fsync() is supposed to work even with the cache enabled, but depending on the OS and version it may not guarantee that the data has hit the platter. Chris
From: Peter Olcott on 8 Apr 2010 19:21
"Chris Friesen" <cbf123(a)mail.usask.ca> wrote in message news:lsOdnZBAxutd_iPWnZ2dnUVZ_uidnZ2d(a)posted.sasktel... > On 04/08/2010 10:58 AM, Peter Olcott wrote: >> Is there a completely certain way that a write to a file >> can be flushed to the disk that encompasses every >> possible >> memory buffer, including the hard drives onboard cache? >> I >> want to be able to yank the power cord at any moment and >> not >> get corrupted data other than the most recent single >> transaction. > > Do you know what OS, OS version, filesystem, disk > controller, and hard > disk you're using? > > If not, then the generic answer is that you need to > disable the hard > drive cache. > > fsync() is supposed to work even with the cache enabled, > but depending > on the OS and version it may not guarantee that the data > has hit the > platter. > > Chris Yes that seems to be what is needed. Where does the open O_SYNC flag fit into this? |