Skip to content

Commit

Permalink
xen-blkback: allow module to be cleanly unloaded
Browse files Browse the repository at this point in the history
Add a module_exit() to perform the necessary clean-up.

Signed-off-by: Paul Durrant <[email protected]>
Reviewed-by: "Roger Pau Monné" <[email protected]>
Reviewed-by: Juergen Gross <[email protected]>
Signed-off-by: Juergen Gross <[email protected]>
  • Loading branch information
Paul Durrant authored and jgross1 committed Dec 4, 2019
1 parent 196748a commit 1485595
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/block/xen-blkback/blkback.c
Original file line number Diff line number Diff line change
Expand Up @@ -1504,5 +1504,13 @@ static int __init xen_blkif_init(void)

module_init(xen_blkif_init);

static void __exit xen_blkif_fini(void)
{
xen_blkif_xenbus_fini();
xen_blkif_interface_fini();
}

module_exit(xen_blkif_fini);

MODULE_LICENSE("Dual BSD/GPL");
MODULE_ALIAS("xen-backend:vbd");
3 changes: 3 additions & 0 deletions drivers/block/xen-blkback/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,12 @@ struct phys_req {
struct block_device *bdev;
blkif_sector_t sector_number;
};

int xen_blkif_interface_init(void);
void xen_blkif_interface_fini(void);

int xen_blkif_xenbus_init(void);
void xen_blkif_xenbus_fini(void);

irqreturn_t xen_blkif_be_int(int irq, void *dev_id);
int xen_blkif_schedule(void *arg);
Expand Down
11 changes: 11 additions & 0 deletions drivers/block/xen-blkback/xenbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,12 @@ int __init xen_blkif_interface_init(void)
return 0;
}

void xen_blkif_interface_fini(void)
{
kmem_cache_destroy(xen_blkif_cachep);
xen_blkif_cachep = NULL;
}

/*
* sysfs interface for VBD I/O requests
*/
Expand Down Expand Up @@ -1122,3 +1128,8 @@ int xen_blkif_xenbus_init(void)
{
return xenbus_register_backend(&xen_blkbk_driver);
}

void xen_blkif_xenbus_fini(void)
{
xenbus_unregister_driver(&xen_blkbk_driver);
}

0 comments on commit 1485595

Please sign in to comment.