linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* correction: fs/buffer.c underlocking async pages
@ 2001-06-21 14:39 Stefan.Bader
  2001-06-21 15:08 ` Andrea Arcangeli
  2001-06-21 15:38 ` Andrea Arcangeli
  0 siblings, 2 replies; 13+ messages in thread
From: Stefan.Bader @ 2001-06-21 14:39 UTC (permalink / raw)
  To: torvalds, andrea; +Cc: linux-kernel




Hi,

I ran into some problems with buffer.c trying to unlock a page of async io
buffer heads more
than once.
IMHO end_buffer_io_async() shouldn't rely on the value of b_end_io to
decide if the whole
page can be unlocked. It would make it easier for other layers (well
remappers like md or
lvm) to create an end_io chain without the need of allocating new buffer
heads just for that.
Is the comparision on b_end_io really necessary? I would assume that all
bh on the same
page belong to async io.
Otherwise, could something like below be done instead?

Linux for eServer development
Stefan.Bader@de.ibm.com
Phone: +49 (7031) 16-2472
----------------------------------------------------------------------------------

  When all other means of communication fail, try words.

--------------------------------------------
diff -ruN old/fs/buffer.c new/fs/buffer.c
--- old/fs/buffer.c     Thu Jun 21 09:47:20 2001
+++ new/fs/buffer.c     Thu Jun 21 10:44:01 2001
@@ -798,11 +798,12 @@
         * that unlock the page..
         */
        spin_lock_irqsave(&page_uptodate_lock, flags);
+       clear_bit(BH_Async, &bh->b_state);
        unlock_buffer(bh);
        atomic_dec(&bh->b_count);
        tmp = bh->b_this_page;
        while (tmp != bh) {
-               if (tmp->b_end_io == end_buffer_io_async &&
buffer_locked(tmp))
+               if (test_bit(BH_Async, &tmp->b_state) &&
buffer_locked(tmp))
                        goto still_busy;
                tmp = tmp->b_this_page;
        }
@@ -834,6 +835,7 @@

 void set_buffer_async_io(struct buffer_head *bh) {
     bh->b_end_io = end_buffer_io_async ;
+               set_bit(BH_Async, &bh->b_state);
 }

 /*
@@ -1535,6 +1537,7 @@
        do {
                lock_buffer(bh);
                bh->b_end_io = end_buffer_io_async;
+               set_bit(BH_Async, &bh->b_state);
                atomic_inc(&bh->b_count);
                set_bit(BH_Uptodate, &bh->b_state);
                clear_bit(BH_Dirty, &bh->b_state);
@@ -1736,6 +1739,7 @@
                struct buffer_head * bh = arr[i];
                lock_buffer(bh);
                bh->b_end_io = end_buffer_io_async;
+               set_bit(BH_Async, &bh->b_state);
                atomic_inc(&bh->b_count);
        }

@@ -2182,6 +2186,7 @@
                bh->b_blocknr = *(b++);
                set_bit(BH_Mapped, &bh->b_state);
                bh->b_end_io = end_buffer_io_async;
+               set_bit(BH_Async, &bh->b_state);
                atomic_inc(&bh->b_count);
                bh = bh->b_this_page;
        } while (bh != head);
diff -ruN old/include/linux/fs.h new/include/linux/fs.h
--- old/include/linux/fs.h      Thu Jun 21 09:47:51 2001
+++ new/include/linux/fs.h      Thu Jun 21 09:48:20 2001
@@ -207,6 +207,7 @@
 #define BH_Mapped      4       /* 1 if the buffer has a disk mapping */
 #define BH_New         5       /* 1 if the buffer is new and not yet
written out */
 #define BH_Protected   6       /* 1 if the buffer is protected */
+#define BH_Async 7 /* 1 if the buffer is used for asyncronous io */

 /*
  * Try to keep the most commonly used fields in single cache lines (16
-------------------




^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: correction: fs/buffer.c underlocking async pages
@ 2001-06-22  7:43 Stefan.Bader
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan.Bader @ 2001-06-22  7:43 UTC (permalink / raw)
  To: Chris Mason, Andrea Arcangeli, Linus Torvalds; +Cc: linux-kernel




Chris Mason <mason@suse.com>
06/21/01 08:20 PM
Please respond to Chris Mason


        To:     Andrea Arcangeli <andrea@suse.de>, Linus Torvalds
<torvalds@transmeta.com>
        cc:     Stefan Bader/Germany/IBM@IBMDE,
linux-kernel@vger.kernel.org
        Subject:        Re: correction: fs/buffer.c underlocking async
pages







On Thursday, June 21, 2001 07:15:22 PM +0200 Andrea Arcangeli
<andrea@suse.de> wrote:

>> On Thu, Jun 21, 2001 at 09:56:04AM -0700, Linus Torvalds wrote:
>>  What's the problem with the existing code, and why do people want to
add
>> a
>>> (unnecessary) new bit?
>>
>> there's no problem with the existing code, what I understood is that
>> they cannot overwrite the ->b_end_io callback in the lowlevel blkdev
>> layer or the page will be unlocked too early.

>Just to be more explicit, the big problem is mixing different async
>callbacks on the same page.  The patch would also allow things like this:
>
>fs_specific_end_io() {
>    do something special
>    end_buffer_io_async()
>}
>
>-chris

Yes, that was exactly the thing I tried to do. In my case some sort of
bookkeeping
how many IO's where mapped (to a certain path) and how many came back.
My assumption first was, if I am restoring the old pointers before I call
the original
function it should work.
After running into problems this patch was just my quick hack to try out
whether this
was the only place that I did not think of. I wouldn't insist on the exact
way to do it,
but since it worked for me, I thought it might be worth to discuss (or
even be useful
for other people... ;-)).

- Stefan

Linux for eServer development
Stefan.Bader@de.ibm.com
Phone: +49 (7031) 16-2472
----------------------------------------------------------------------------------

  When all other means of communication fail, try words.




^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2001-06-22  7:44 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-21 14:39 correction: fs/buffer.c underlocking async pages Stefan.Bader
2001-06-21 15:08 ` Andrea Arcangeli
2001-06-21 15:16   ` Chris Mason
2001-06-21 15:24     ` Andrea Arcangeli
2001-06-21 16:54   ` Linus Torvalds
2001-06-21 17:12     ` Andrea Arcangeli
2001-06-21 15:38 ` Andrea Arcangeli
2001-06-21 16:56   ` Linus Torvalds
2001-06-21 17:15     ` Andrea Arcangeli
2001-06-21 17:58       ` Andrea Arcangeli
2001-06-21 18:20       ` Chris Mason
2001-06-21 18:49       ` Linus Torvalds
2001-06-22  7:43 Stefan.Bader

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