Wait for an IO to complete

Greg KH greg at kroah.com
Fri Mar 28 14:01:38 EDT 2014


On Fri, Mar 28, 2014 at 11:16:30PM +0530, Rishi Agrawal wrote:
> Hi All,
> 
> I want to wait in my code till the IO actually goes to the disk.

That's an issue, as you really don't know what a "disk" is from within
the kernel :)

Back up, what exactly are you trying to do?

> 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.

And that's all you should need.  Why do you feel you need more?

thanks,

greg k-h



More information about the Kernelnewbies mailing list