Re: [PATCH 0/9] Add blockconsole version 1.1 (try 2)

Takashi Iwai
2013-03-07T18:46:53Z

At Wed, 6 Mar 2013 14:49:50 -0500,
Jörn Engel wrote:
>
> On Tue, 5 March 2013 18:36:41 +0100, Takashi Iwai wrote:
> >
> > Another thing I noticed is that the panic handler calls bcon_write(),
> > and it doesn't write to the device by itself. Is it really supposed
> > to work?
>
> Clearly it is supposed to work. In reality it sometimes does and
> sometimes does not. Patches to improve the success rate are welcome.

What I thought is to driver submit_bio in the panic handler itself
so that no scheduling is involved, like the patch below. But I'm not
sure whether it would actually work...

>
> > Meanwhile I hacked the code to allow it being built as a module.
> > If anyone is interested, I'll send a patch series. It's pretty
> > hackish, so likely need more brush up, though.
>
> I am interested.

OK, I'll send a patch series. It'll be built on top of my previous
patches. And I wrote it after merging to 3.9-rc1, so might be
slightly fuzzy to your tree.

thanks,

Takashi

---
diff --git a/drivers/block/blockconsole.c b/drivers/block/blockconsole.c
index 5fc192a..5042a5a 100644
--- a/drivers/block/blockconsole.c
+++ b/drivers/block/blockconsole.c
@@ -361,6 +361,16 @@ static void bcon_writesector(struct blockconsole *bc, int index)
submit_bio(WRITE, bio);
}

+static void bcon_do_writeback(struct blockconsole *bc)
+{
+ while (bcon_write_sector(bc) != bcon_console_sector(bc)) {
+ bcon_writesector(bc, bcon_write_sector(bc));
+ bcon_advance_write_bytes(bc, SECTOR_SIZE);
+ if (bcon_write_sector(bc) == 0)
+ bcon_erase_segment(bc);
+ }
+}
+
static int bcon_writeback(void *_bc)
{
struct blockconsole *bc = _bc;
@@ -373,12 +383,7 @@ static int bcon_writeback(void *_bc)
schedule();
if (kthread_should_stop())
break;
- while (bcon_write_sector(bc) != bcon_console_sector(bc)) {
- bcon_writesector(bc, bcon_write_sector(bc));
- bcon_advance_write_bytes(bc, SECTOR_SIZE);
- if (bcon_write_sector(bc) == 0)
- bcon_erase_segment(bc);
- }
+ bcon_do_writeback(bc);
}
return 0;
}
@@ -476,7 +481,7 @@ static int blockconsole_panic(struct notifier_block *this, unsigned long event,
n = SECTOR_SIZE - bcon_console_ofs(bc);
if (n != SECTOR_SIZE)
bcon_advance_console_bytes(bc, n);
- bcon_writeback(bc);
+ bcon_do_writeback(bc);
return NOTIFY_DONE;
}