Re: GSOC: Device mapper mirror target
On Mon, Apr 11, 2011 at 9:22 AM, Adam Hoka <adam.hoka@gmail.com> wrote:
> On Sun, 10 Apr 2011 18:08:33 -0400
> Venkatesh Srinivas <me@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. :-)
Heh, totally agree there.
We have an interface called MPIPE (very similar to NetBSD's pool(9))
that would allow us to reserve some transactions/groups for write-path
I/O. I believe that is what the dm crypt target does. I think that'd
be okay for this.
-- vs
討論串 (同標題文章)
完整討論串 (本文為第 8 之 16 篇):