device unbind

I don’t like writing about things I didn’t do. But in this case my colleagues at OLX are mentioning I shall document it, for others. We were in trouble with an EBS volume on AWS as we had 2 of them attached to a box, one supposedly released but not completely.

From AWS Web UI we saw that the device was released, but in the box we could still do the listing of the content of the mounted device. It was RO though… but still, unclean situation.

We first cleared the filesystem in memory cache, and at least that removed the data from within the filesystem tree structure… but we could still fdisk list the device… at this stage I went for the latest escalation solution in this domain… call Alessandro Rubini, co-author of Linux Device Drivers.

Solution suggested… go into /proc/sys device folder “xen”, then folder related to the device module “blkblock” or something similar… then in there, there were 2 symlinks, with the name/alias of the devices… this is basically the reference in memory of the mapping between the module and the device… it is kept in the MODULE_DEVICE_TABLE data structure. Echoing such string (unique to the device) into the “unbind” special file which is in the above followed folder, releases the datastructure and therefore the device without having to unload the module. There was another healthy device held by such module, therefore we couldn’t unload/load it to flush its state.

$ ls /sys/bus/xen/drivers/vbd/
bind module uevent unbind vbd-12345 vbd-98765
$ echo  vbd-98765 >/sys/bus/xen/drivers/vbd/unbind
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s