1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-24 11:29:10 +00:00
freebsd/sys/geom
Kenneth D. Merry c3fb2891f0 Fix a bug which causes a panic in daopen(). The panic is caused by
a da(4) instance going away while GEOM is still probing it.

In this case, the GEOM disk class instance has been created by
disk_create(), and the taste of the disk is queued in the GEOM
event queue.

While that event is queued, the da(4) instance goes away.  When the
open call comes into the da(4) driver, it dereferences the freed
(but non-NULL) peripheral pointer provided by GEOM, which results
in a panic.

The solution is to add a callback to the GEOM disk code that is
called when all of its resources are cleaned up.  This is
implemented inside GEOM by adding an optional callback that is
called when all consumers have detached from a provider, and the
provider is about to be deleted.

scsi_cd.c,
scsi_da.c:	In the register routine for the cd(4) and da(4)
		routines, acquire a reference to the CAM peripheral
		instance just before we call disk_create().

		Use the new GEOM disk d_gone() callback to register
		a callback (dadiskgonecb()/cddiskgonecb()) that
		decrements the peripheral reference count once GEOM
		has finished cleaning up its resources.

		In the cd(4) driver, clean up open and close
		behavior slightly.  GEOM makes sure we only get one
		open() and one close call, so there is no need to
		set an open flag and decrement the reference count
		if we are not the first open.

		In the cd(4) driver, use cam_periph_release_locked()
		in a couple of error scenarios to avoid extra mutex
		calls.

geom.h:		Add a new, optional, providergone callback that
		is called when a provider is about to be deleted.

geom_disk.h:	Add a new d_gone() callback to the GEOM disk
		interface.

		Bump the DISK_VERSION to version 2.  This probably
		should have been done after a couple of previous
		changes, especially the addition of the d_getattr()
		callback.

geom_disk.c:	Add a providergone callback for the disk class,
		g_disk_providergone(), that calls the user's
		d_gone() callback if it exists.

		Bump the DISK_VERSION to 2.

geom_subr.c:	In g_destroy_provider(), call the providergone
		callback if it has been provided.

		In g_new_geomf(), propagate the class's
		providergone callback to the new geom instance.

blkfront.c:	Callers of disk_create() are supposed to pass in
		DISK_VERSION, not an explicit disk API version
		number.  Update the blkfront driver to do that.

disk.9:		Update the disk(9) man page to include information
		on the new d_gone() callback, as well as the
		previously added d_getattr() callback, d_descr
		field, and HBA PCI ID fields.

MFC after:	5 days
2012-06-24 04:29:03 +00:00
..
bde
cache
concat
eli Add missing period at the end of the error message 2012-05-13 23:27:06 +00:00
gate
journal
label Revert r235918 for now and add comment explaining the reason for the 2012-05-25 10:08:48 +00:00
linux_lvm
mirror Prevent removing of the last active component from a mirror. 2012-05-18 09:22:21 +00:00
mountver
multipath Add missing newlines into XML output. 2012-06-05 16:46:34 +00:00
nop
part Always reconstruct partition entries in the PMBR when Boot Camp is 2012-06-14 11:17:54 +00:00
raid - Prevent error status leak if write to some of the RAID1/1E volume disks 2012-05-11 13:20:17 +00:00
raid3
sched
shsec
stripe
uncompress
uzip
vinum
virstor
zero
geom_aes.c
geom_bsd_enc.c
geom_bsd.c
geom_ccd.c
geom_ctl.c
geom_ctl.h
geom_dev.c
geom_disk.c Fix a bug which causes a panic in daopen(). The panic is caused by 2012-06-24 04:29:03 +00:00
geom_disk.h Fix a bug which causes a panic in daopen(). The panic is caused by 2012-06-24 04:29:03 +00:00
geom_dump.c
geom_event.c
geom_flashmap.c - Correct signedness for casts; 2012-05-23 20:51:21 +00:00
geom_fox.c
geom_int.h
geom_io.c
geom_kern.c
geom_map.c
geom_mbr_enc.c
geom_mbr.c
geom_pc98_enc.c
geom_pc98.c
geom_redboot.c
geom_slice.c
geom_slice.h
geom_subr.c Fix a bug which causes a panic in daopen(). The panic is caused by 2012-06-24 04:29:03 +00:00
geom_sunlabel_enc.c
geom_sunlabel.c
geom_vfs.c
geom_vfs.h
geom_vol_ffs.c
geom.h Fix a bug which causes a panic in daopen(). The panic is caused by 2012-06-24 04:29:03 +00:00
notes