* [PATCH] 2.6.6 buffer.c: bio_alloc() check
@ 2004-06-02 13:28 Yury Umanets
2004-06-02 13:36 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: Yury Umanets @ 2004-06-02 13:28 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel
[PATCH] 2.6.6 buffer.c: adds bio_alloc() check and error handling in
fs/buffer.c.
Signed-off-by: Yury Umanets <torque@ukrpost.net>
buffer.c | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+)
diff -rupN ./linux-2.6.6/fs/buffer.c ./linux-2.6.6-modified/fs/buffer.c
--- ./linux-2.6.6/fs/buffer.c Mon May 10 05:32:38 2004
+++ ./linux-2.6.6-modified/fs/buffer.c Wed Jun 2 15:21:47 2004
@@ -2712,6 +2712,31 @@ void submit_bh(int rw, struct buffer_hea
* submit_bio -> generic_make_request may further map this bio around
*/
bio = bio_alloc(GFP_NOIO, 1);
+ if (bio == NULL) {
+ char b[BDEVNAME_SIZE];
+
+ printk(KERN_ERR "BIO allocation failed for buffer on device "
+ "%s, logical block %Lu\n", bdevname(bh->b_bdev, b),
+ (unsigned long long)bh->b_blocknr);
+
+ /*
+ * this is needed here as some of submit_bh() callers have to
+ * wait until buffer is unlocked (that is IO is finished on it)
+ * and check its state.
+ */
+ if (rw == WRITE)
+ set_buffer_write_io_error(bh);
+ clear_buffer_uptodate(bh);
+ SetPageError(bh->b_page);
+
+ /*
+ * making all future wait_on_buffer() callers do not wait
+ * this buffer as it is errorneous.
+ */
+ if (buffer_locked(bh))
+ unlock_buffer(bh);
+ return;
+ }
bio->bi_sector = bh->b_blocknr * (bh->b_size >> 9);
bio->bi_bdev = bh->b_bdev;
--
umka
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] 2.6.6 buffer.c: bio_alloc() check
2004-06-02 13:28 [PATCH] 2.6.6 buffer.c: bio_alloc() check Yury Umanets
@ 2004-06-02 13:36 ` Jens Axboe
2004-06-02 14:17 ` Yury Umanets
0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2004-06-02 13:36 UTC (permalink / raw)
To: Yury Umanets; +Cc: akpm, linux-kernel
On Wed, Jun 02 2004, Yury Umanets wrote:
> [PATCH] 2.6.6 buffer.c: adds bio_alloc() check and error handling in
> fs/buffer.c.
>
> Signed-off-by: Yury Umanets <torque@ukrpost.net>
>
> buffer.c | 25 +++++++++++++++++++++++++
> 1 files changed, 25 insertions(+)
>
> diff -rupN ./linux-2.6.6/fs/buffer.c ./linux-2.6.6-modified/fs/buffer.c
> --- ./linux-2.6.6/fs/buffer.c Mon May 10 05:32:38 2004
> +++ ./linux-2.6.6-modified/fs/buffer.c Wed Jun 2 15:21:47 2004
> @@ -2712,6 +2712,31 @@ void submit_bh(int rw, struct buffer_hea
> * submit_bio -> generic_make_request may further map this bio around
> */
> bio = bio_alloc(GFP_NOIO, 1);
> + if (bio == NULL) {
This is wrong, bio_alloc() never fails if it's called with __GFP_WAIT in
the gfp mask.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] 2.6.6 buffer.c: bio_alloc() check
2004-06-02 13:36 ` Jens Axboe
@ 2004-06-02 14:17 ` Yury Umanets
0 siblings, 0 replies; 3+ messages in thread
From: Yury Umanets @ 2004-06-02 14:17 UTC (permalink / raw)
To: Jens Axboe; +Cc: akpm, linux-kernel
On Wed, 2004-06-02 at 16:36, Jens Axboe wrote:
> On Wed, Jun 02 2004, Yury Umanets wrote:
> > [PATCH] 2.6.6 buffer.c: adds bio_alloc() check and error handling in
> > fs/buffer.c.
> >
> > Signed-off-by: Yury Umanets <torque@ukrpost.net>
> >
> > buffer.c | 25 +++++++++++++++++++++++++
> > 1 files changed, 25 insertions(+)
> >
> > diff -rupN ./linux-2.6.6/fs/buffer.c ./linux-2.6.6-modified/fs/buffer.c
> > --- ./linux-2.6.6/fs/buffer.c Mon May 10 05:32:38 2004
> > +++ ./linux-2.6.6-modified/fs/buffer.c Wed Jun 2 15:21:47 2004
> > @@ -2712,6 +2712,31 @@ void submit_bh(int rw, struct buffer_hea
> > * submit_bio -> generic_make_request may further map this bio around
> > */
> > bio = bio_alloc(GFP_NOIO, 1);
> > + if (bio == NULL) {
>
> This is wrong, bio_alloc() never fails if it's called with __GFP_WAIT in
> the gfp mask.
Ok, I see. Thanks.
--
umka
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-06-02 14:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-02 13:28 [PATCH] 2.6.6 buffer.c: bio_alloc() check Yury Umanets
2004-06-02 13:36 ` Jens Axboe
2004-06-02 14:17 ` Yury Umanets
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.