Skip to contentSkip to conversation

remove use of get_gendisk in blkfront

PATCH In review Xiaofeng Ling 2 participants 2 messages Sep 2, 2005 – Nov 9, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remove use of get_gendisk in blkfront

remove use of get_gendisk in blkfront
gen_gendisk is no long exported by 2.6 kernel. this patch remove the call of get_gendisk by saving the gd point in blkfront_info in vbd.c so that blkfront can be built as kerenl module.

linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c +1 -0
diff -r 864434653dab linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
@@ -660,6 +651,7 @@
 	info->vdevice = vdevice;
 	info->connected = BLKIF_STATE_DISCONNECTED;
 	info->mi = NULL;
+ 	info->gd = NULL;
 	INIT_WORK(&info->work, blkif_restart_queue, (void *)info);
 
 	info->shadow_free = 0;
linux-2.6-xen-sparse/drivers/xen/blkfront/block.h +1 -0
diff -r 864434653dab linux-2.6-xen-sparse/drivers/xen/blkfront/block.h
@@ -115,6 +115,7 @@
 	/* We watch the backend */
 	struct xenbus_watch watch;
 	dev_t dev;
+ 	struct gendisk *gd;
 	int vdevice;
 	blkif_vdev_t handle;
 	int connected;
linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c +4 -7
diff -r 864434653dab linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c
@@ -266,6 +257,7 @@
 		gd->flags |= GENHD_FL_CD;
 
 	add_disk(gd);
+	info->gd = gd;
 
 	return 0;
 
@@ -298,23 +290,19 @@
 void
 xlvbd_del(struct blkfront_info *info)
 {
-	struct block_device *bd;
 	struct gendisk *gd;
 	int unused;
 	request_queue_t *rq;
 
-	bd = bdget(info->dev);
-	if (bd == NULL)
+	gd = info->gd;
+	if (gd == NULL)
 		return;
 
-	gd = get_gendisk(info->dev, &unused);
 	rq = gd->queue;
-
 	del_gendisk(gd);
 	put_disk(gd);
 	xlbd_put_major_info(info->mi);
 	info->mi = NULL;
 	blk_cleanup_queue(rq);
 
-	bdput(bd);
-}
+}

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 6 lines · Xiaofeng Ling

remove use of get_gendisk in blkfront
gen_gendisk is no long exported by 2.6 kernel. this patch remove the call of get_gendisk by saving the gd point in blkfront_info in vbd.c so that blkfront can be built as kerenl module.

This looks correct to me and helps in building blkfront as a module. Any chance of getting it committed? I've gone ahead and rediffed against the current tip and cleaned up the warnings. Attached here.

Jeremy

linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c +1 -0
diff -r abbe3df33774 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
@@ -641,6 +641,7 @@
 	info->vdevice = vdevice;
 	info->connected = BLKIF_STATE_DISCONNECTED;
 	info->mi = NULL;
+ 	info->gd = NULL;
 	INIT_WORK(&info->work, blkif_restart_queue, (void *)info);
 
 	info->shadow_free = 0;
linux-2.6-xen-sparse/drivers/xen/blkfront/block.h +1 -0
diff -r abbe3df33774 linux-2.6-xen-sparse/drivers/xen/blkfront/block.h
@@ -116,6 +116,7 @@
 	/* We watch the backend */
 	struct xenbus_watch watch;
 	dev_t dev;
+ 	struct gendisk *gd;
 	int vdevice;
 	blkif_vdev_t handle;
 	int connected;
linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c +7 -9
diff -r abbe3df33774 linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c
@@ -259,6 +259,7 @@
 		gd->flags |= GENHD_FL_CD;
 
 	add_disk(gd);
+	info->gd = gd;
 
 	return 0;
 
@@ -292,22 +293,19 @@
 xlvbd_del(struct blkfront_info *info)
 {
 	struct block_device *bd;
-	struct gendisk *gd;
-	int unused;
-	request_queue_t *rq;
 
 	bd = bdget(info->dev);
 	if (bd == NULL)
 		return;
 
-	gd = get_gendisk(info->dev, &unused);
-	rq = gd->queue;
-
-	del_gendisk(gd);
-	put_disk(gd);
+	if (info->gd == NULL)
+		return;
+
+	del_gendisk(info->gd);
+	put_disk(info->gd);
 	xlbd_put_major_info(info->mi);
 	info->mi = NULL;
-	blk_cleanup_queue(rq);
+	blk_cleanup_queue(info->rq);
 
 	bdput(bd);
 }

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel