Wait for an IO to complete

Rishi Agrawal rishi.b.agrawal at gmail.com
Sat Mar 29 06:07:07 EDT 2014


Hi Greg,

On Fri, Mar 28, 2014 at 11:31 PM, Greg KH <greg at kroah.com> wrote:

> 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?
>
> Its a virtual machine, so no worries here, more over I am using a loop
device.


>  > 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?
>
> Actually I am developing a kernel module through which I am writing to the
device. I am not able to the written data in some cases, the code path is
same everywhere. So I thought maybe its not getting flushed on the disk and
I am expecting the write on the disk too early.

I want to wait till the write completes as performance is not I am worried
about right now.


> thanks,
>
> greg k-h
>



-- 
Regards,
Rishi Agrawal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140329/f5c46c08/attachment.html 


More information about the Kernelnewbies mailing list