summaryrefslogtreecommitdiff
path: root/drivers/block/xen-blkback/blkback.c
diff options
context:
space:
mode:
authorRoger Pau Monne <roger.pau@citrix.com>2012-11-02 15:43:04 (GMT)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2012-11-04 15:35:40 (GMT)
commitcb5bd4d19b46c220b1ac8462a3da01767dd99488 (patch)
tree1b22151771a90480d0d4790521b9432f46f1e32a /drivers/block/xen-blkback/blkback.c
parent0a8704a51f386cab7394e38ff1d66eef924d8ab8 (diff)
downloadlinux-fsl-qoriq-cb5bd4d19b46c220b1ac8462a3da01767dd99488.tar.xz
xen/blkback: persistent-grants fixes
This patch contains fixes for persistent grants implementation v2: * handle == 0 is a valid handle, so initialize grants in blkback setting the handle to BLKBACK_INVALID_HANDLE instead of 0. Reported by Konrad Rzeszutek Wilk. * new_map is a boolean, use "true" or "false" instead of 1 and 0. Reported by Konrad Rzeszutek Wilk. * blkfront announces the persistent-grants feature as feature-persistent-grants, use feature-persistent instead which is consistent with blkback and the public Xen headers. * Add a consistency check in blkfront to make sure we don't try to access segments that have not been set. Reported-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> [v1: The new_map int->bool had already been changed] Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/block/xen-blkback/blkback.c')
-rw-r--r--drivers/block/xen-blkback/blkback.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index d7dd5cb..a059616 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -512,7 +512,7 @@ static int xen_blkbk_map(struct blkif_request *req,
* not mapped but we have room for it
*/
new_map = true;
- persistent_gnt = kzalloc(
+ persistent_gnt = kmalloc(
sizeof(struct persistent_gnt),
GFP_KERNEL);
if (!persistent_gnt)
@@ -523,6 +523,7 @@ static int xen_blkbk_map(struct blkif_request *req,
return -ENOMEM;
}
persistent_gnt->gnt = req->u.rw.seg[i].gref;
+ persistent_gnt->handle = BLKBACK_INVALID_HANDLE;
pages_to_gnt[segs_to_map] =
persistent_gnt->page;
@@ -584,7 +585,8 @@ static int xen_blkbk_map(struct blkif_request *req,
*/
bitmap_zero(pending_req->unmap_seg, BLKIF_MAX_SEGMENTS_PER_REQUEST);
for (i = 0, j = 0; i < nseg; i++) {
- if (!persistent_gnts[i] || !persistent_gnts[i]->handle) {
+ if (!persistent_gnts[i] ||
+ persistent_gnts[i]->handle == BLKBACK_INVALID_HANDLE) {
/* This is a newly mapped grant */
BUG_ON(j >= segs_to_map);
if (unlikely(map[j].status != 0)) {
@@ -601,7 +603,8 @@ static int xen_blkbk_map(struct blkif_request *req,
}
}
if (persistent_gnts[i]) {
- if (!persistent_gnts[i]->handle) {
+ if (persistent_gnts[i]->handle ==
+ BLKBACK_INVALID_HANDLE) {
/*
* If this is a new persistent grant
* save the handler