GSOC: Device mapper mirror target
Adam Hoka
adam.hoka at gmail.com
Mon Apr 11 06:25:42 PDT 2011
On Sun, 10 Apr 2011 18:08:33 -0400
Venkatesh Srinivas <me at endeavour.zapto.org> wrote:
> static int
> dmirror_strategy(dm_table_entry_t *table_en, struct buf *bp)
> {
> struct bio *bio;
> struct dmirror_pdev *pdev;
> struct dmirror_dev *dmcfg;
> struct dmirror_write_group *wg;
> struct dmirror_write_tx *tx;
> int ndevs;
> int i;
>
> dmcfg = table_en->target_config;
>
> switch (bp->b_cmd) {
> case (BUF_CMD_READ):
> pdev = dmirror_read_pick(dmcfg, &bp->b_bio1);
> if (pdev == NULL) {
> bp->b_flags |= B_ERROR | B_INVAL;
> bp->b_resid = 0;
> biodone(&bp->b_bio1);
> break;
> }
>
> disk_issue_read(dmcfg, pdev, &bp->b_bio1);
> break;
> case (BUF_CMD_WRITE):
> /* Allocate a write group */
> wg = kmalloc(sizeof(struct dmirror_write_group), M_DMIRROR_WG,
> M_WAITOK);
> dmirror_wg_ctor(dmcfg, &bp->b_bio1, wg);
>
> /* Allocate one transaction per device */
> for (i = 0; i < ndevs; i++) {
> tx = kmalloc(sizeof(struct dmirror_write_tx),
> M_DMIRROR_TX, M_WAITOK);
> dmirror_write_tx_ctor(wg, tx);
>
> }
>
> /* Setup transactions */
>
> /* Issue requests */
> // do some stuff, then call vn_strategy() on each tx->bio
>
> break;
> case (BUF_CMD_FLUSH):
> default:
> break;
> }
> }
>
A bit off topic, but I dont think its a good idea to allocate memory
during I/O. :-)
--
Adam Hoka <adam.hoka at gmail.com>
More information about the Kernel
mailing list