* buffer head read/write
@ 2002-12-09 16:25 David Chow
2002-12-10 0:28 ` Bryan Henderson
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: David Chow @ 2002-12-09 16:25 UTC (permalink / raw)
To: linux-fsdevel
Hi all,
Is there a way to make sure I submit a buffer head read/write and make
sure it is commited immediately? (sychronized) . Please give direction
on examples in the kernel code? Thanks.
regards,
David Chow
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: buffer head read/write
2002-12-09 16:25 buffer head read/write David Chow
@ 2002-12-10 0:28 ` Bryan Henderson
2002-12-10 0:36 ` Neil Brown
2002-12-10 20:13 ` Andrew Morton
2 siblings, 0 replies; 7+ messages in thread
From: Bryan Henderson @ 2002-12-10 0:28 UTC (permalink / raw)
To: David Chow; +Cc: linux-fsdevel
>Is there a way to make sure I submit a buffer head read/write and make
>sure it is commited immediately? (sychronized)
ll_rw_block() to submit it, followed by wait_on_buffer() to wait for the
I/O to complete.
>Please give direction on examples in the kernel code? Thanks.
I can't think of an example of where those are called together, but if you
search the fs/ directory for those, you should find plenty of examples of
using them individually.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: buffer head read/write
2002-12-09 16:25 buffer head read/write David Chow
2002-12-10 0:28 ` Bryan Henderson
@ 2002-12-10 0:36 ` Neil Brown
2002-12-10 14:56 ` David Chow
2002-12-10 20:13 ` Andrew Morton
2 siblings, 1 reply; 7+ messages in thread
From: Neil Brown @ 2002-12-10 0:36 UTC (permalink / raw)
To: David Chow; +Cc: linux-fsdevel
On Tuesday December 10, davidchow@shaolinmicro.com wrote:
> Hi all,
>
> Is there a way to make sure I submit a buffer head read/write and make
> sure it is commited immediately? (sychronized) . Please give direction
> on examples in the kernel code? Thanks.
md does (or will) read/write it's super-blocks that way.
In 2.5, see drivers/md/md.c:sync_page_io
In 2.4, see
http://cgi.cse.unsw.edu.au/~neilb/patches/linux-stable/2.4.leading/2002-12-09:01/005MDSyncIo
... I haven't submitted it yet.
NeilBrown
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: buffer head read/write
2002-12-10 0:36 ` Neil Brown
@ 2002-12-10 14:56 ` David Chow
2002-12-11 0:19 ` Bryan Henderson
0 siblings, 1 reply; 7+ messages in thread
From: David Chow @ 2002-12-10 14:56 UTC (permalink / raw)
To: Neil Brown; +Cc: linux-fsdevel
Neil Brown wrote:
>On Tuesday December 10, davidchow@shaolinmicro.com wrote:
>
>
>>Hi all,
>>
>>Is there a way to make sure I submit a buffer head read/write and make
>>sure it is commited immediately? (sychronized) . Please give direction
>>on examples in the kernel code? Thanks.
>>
>>
>
>md does (or will) read/write it's super-blocks that way.
>In 2.5, see drivers/md/md.c:sync_page_io
>In 2.4, see
> http://cgi.cse.unsw.edu.au/~neilb/patches/linux-stable/2.4.leading/2002-12-09:01/005MDSyncIo
>
>... I haven't submitted it yet.
>
>NeilBrown
>
>
Thanks to all who give suggestions. I know how to make a call to
general_make_request() but wait for the buffer to complete which is too
slow. If I am doing a continuous sychronous read/write (which I already
have my own way of buffer management), can I put those "dirty
buffers"/"non-up-to-date buffers" in the head of the buffer queue so
that they get written by their respective handler immediately? I am not
familiar with buffer cache so would like to seek advice on doing this.
Is there anyway to lock a buffer and get its buffer_head request handler
and call end_io() immediately? Thanks for advice.
regards,
David Chow
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: buffer head read/write
2002-12-09 16:25 buffer head read/write David Chow
2002-12-10 0:28 ` Bryan Henderson
2002-12-10 0:36 ` Neil Brown
@ 2002-12-10 20:13 ` Andrew Morton
2 siblings, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2002-12-10 20:13 UTC (permalink / raw)
To: David Chow; +Cc: linux-fsdevel
David Chow wrote:
>
> Hi all,
>
> Is there a way to make sure I submit a buffer head read/write and make
> sure it is commited immediately? (sychronized) . Please give direction
> on examples in the kernel code? Thanks.
grep wait_on_buffer fs/ext2/*.c - you'll see lots of examples. eg:
mark_buffer_dirty(bh);
if (sb->s_flags & MS_SYNCHRONOUS) {
ll_rw_block (WRITE, 1, &bh);
wait_on_buffer (bh);
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: buffer head read/write
2002-12-10 14:56 ` David Chow
@ 2002-12-11 0:19 ` Bryan Henderson
2002-12-11 14:31 ` David Chow
0 siblings, 1 reply; 7+ messages in thread
From: Bryan Henderson @ 2002-12-11 0:19 UTC (permalink / raw)
To: David Chow; +Cc: linux-fsdevel, Neil Brown
>I know how to make a call to general_make_request() but
>wait for the buffer to complete which is too slow.
>If I am doing a continuous sychronous read/write ..., can I put those
"dirty
>buffers"/"non-up-to-date buffers" in the head of the buffer queue so
>that they get written by their respective handler immediately?
"immediately" in computer systems normally means "while I wait" rather than
"before doing anything else." That's why you got a bunch of answers that
weren't what you were looking for.
What you want is a way to assign priority to a block I/O request, so that
a particular one gets executed first regardless of other factors, like
that it's a mile away from where the head is now or 100 other requests
came in before it. There's no way to do priority in today's block I/O
layer.
Incidentally, this has nothing to do with the buffer cache. The queue in
question is for all I/O to a block device; it is below the buffer cache.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: buffer head read/write
2002-12-11 0:19 ` Bryan Henderson
@ 2002-12-11 14:31 ` David Chow
0 siblings, 0 replies; 7+ messages in thread
From: David Chow @ 2002-12-11 14:31 UTC (permalink / raw)
To: Bryan Henderson; +Cc: linux-fsdevel, Neil Brown
OK, I think you know what I want, and you've just told me this is
impossible, then the best I could do is try to execute the task as best
as the CPU can. This is stolen from Neils md super block writing routing
that he just gave me a few days ago and merged with
wait_for_complettion. Does this code make sense?
static int sync_buffer_io(kdev_t dev, unsigned long sector, int size,
struct page *page, int rw)
struct buffer_head bh;
struct completion event;
init_completion(&event);
init_buffer(&bh, bh_complete, &event);
bh.b_rdev = dev;
bh.b_rsector = sector;
bh.b_state = (1 << BH_Req) | (1 << BH_Mapped);
bh.b_size = size;
bh.b_page = page;
bh.b_reqnext = NULL;
bh.b_data = page_address(page);
generic_make_request(rw, &bh);
run_task_queue(&tq_disk);
spin_lock_irq(even.wait.lock);
if (!event.done) {
DECLARE_WAITQUEUE(wait, current);
wait.flags |= WQ_FLAG_EXCLUSIVE;
__add_wait_queue_tail(event.wait, &wait);
do {
__set_current_state(TASK_UNINTERRUPTIBLE);
spin_unlock_irq(event.wait.lock);
run_task_queue(&tq_disk);
spin_lock_irq(event.wait.lock);
} while (!x->done);
__remove_wait_queue(event.wait, &wait);
}
event.done--;
spin_unlock_irq(&x->wait.lock);
return test_bit(BH_Uptodate, &bh.b_state);
}
This is dedicate to run the task of tq_disk instead of just schedule() which doesn't know
which task is going to run. Please comment. Thanks.
regards,
David
Bryan Henderson wrote:
>
>
>
>
>>I know how to make a call to general_make_request() but
>>wait for the buffer to complete which is too slow.
>>If I am doing a continuous sychronous read/write ..., can I put those
>>
>>
>"dirty
>
>
>>buffers"/"non-up-to-date buffers" in the head of the buffer queue so
>>that they get written by their respective handler immediately?
>>
>>
>
>"immediately" in computer systems normally means "while I wait" rather than
>"before doing anything else." That's why you got a bunch of answers that
>weren't what you were looking for.
>
>What you want is a way to assign priority to a block I/O request, so that
>a particular one gets executed first regardless of other factors, like
>that it's a mile away from where the head is now or 100 other requests
>came in before it. There's no way to do priority in today's block I/O
>layer.
>
>Incidentally, this has nothing to do with the buffer cache. The queue in
>question is for all I/O to a block device; it is below the buffer cache.
>
>
--
-----------------------------------------------------------------------------
David Chow | Managing Director
http://www.shaolinmicro.com
ShaoLin Microsystems - Multiply Efficiency
-----------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-12-11 14:31 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-09 16:25 buffer head read/write David Chow
2002-12-10 0:28 ` Bryan Henderson
2002-12-10 0:36 ` Neil Brown
2002-12-10 14:56 ` David Chow
2002-12-11 0:19 ` Bryan Henderson
2002-12-11 14:31 ` David Chow
2002-12-10 20:13 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).