Re: [Xen-devel] [PATCH v3] xen-blkfront: set pages are FOREIGN_FRAMEwhen sharing them

From: Stefano Stabellini
Date: Wed May 09 2012 - 14:42:51 EST


On Tue, 8 May 2012, Stefano Stabellini wrote:
> I have been unable to reproduce this problem (I haven't given up yet)
> but I bet that the following patch fixes it:
>
>
> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
> index e3a9945..88e9304 100644
> --- a/drivers/block/xen-blkfront.c
> +++ b/drivers/block/xen-blkfront.c
> @@ -333,7 +333,7 @@ static int blkif_queue_request(struct request *req)
> buffer_mfn,
> rq_data_dir(req));
>
> - info->shadow[id].frame[i] = mfn_to_pfn(buffer_mfn);
> + info->shadow[id].frame[i] = buffer_pfn;
> ring_req->u.rw.seg[i] =
> (struct blkif_request_segment) {
> .gref = ref,
>
>
> The idea is that the request contains a page for which
>
> pfn->mfn->pfn == 0xffffffffffffffff
>
> I am not sure exactly how it could be possible to get into this state in
> blkfront, I hope that some more tracing and code reading will be able to
> shed some lights on the issue.

The one line patch fixes the issue: when using LVM in the guest the same
page can be used in two different requests (in blkif_queue_request)
before being unmapped.
The second time mfn_to_pfn is going to return ~0 because buffer_mfn has
the FOREIGN_FRAME_BIT set.
But actually we don't need to call mfn_to_pfn at all because we already
know the pfn value, that is stored in buffer_pfn.

However the real problem remains at the time of blkif_completion: we
will remove the FOREIGN_FRAME_BIT before the other requests have been
completed.

If sharing the same page twice (or more) is a normal condition then I
might have to revisit this patch completely and choose another
strategy...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/