Wait for an IO to complete

Sankar P sankar.curiosity at gmail.com
Sat Mar 29 08:47:52 EDT 2014


2014-03-28 23:16 GMT+05:30 Rishi Agrawal <rishi.b.agrawal at gmail.com>:
> Hi All,
>
> I want to wait in my code till the IO actually goes to the disk.
>
> For example
>
> struct buffer_head *bh=sb_bread(sb, 20)
>
> strcpy(bh->b_data, "Some Data");
>
> /* mark and sync */
> mark_buffer_dirty(bh);
> sync_dirty_buffer(bh);
>
> The above code only adds the bh to the request queue and returns.
>

My memory is very rusty. So I may be wrong.

Look for what sync_filesystem does.

However, there is no guarantee that the data will be actually written
to disk. I have heard instances where a caching layer in the disk
tells the filesystem that the data is written but the data was not
written and there was a power failure and an ensuing loss of data.

So from the filesystem side, you can only provide a somewhat
unreliable confirmation only most of the times.

> I need something
>
> write_buffer_to_disk(bh)
>
> Which will return only if the data has been written on disk.
>
> Please help
> --
>
> Regards,
> Rishi Agrawal
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>



-- 
Sankar P
http://psankar.blogspot.com



More information about the Kernelnewbies mailing list