summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_object.h
diff options
context:
space:
mode:
authorken <ken@FreeBSD.org>2013-01-09 16:48:38 +0000
committerken <ken@FreeBSD.org>2013-01-09 16:48:38 +0000
commit1abc90f89416beb52c667717f4a745a73c6b156e (patch)
tree4366f6cd21aa38ae2999834bc32c1b1af3129c4e /sys/vm/vm_object.h
parent3d32a931a1a2fa6cbcda4ecc497192795994945f (diff)
downloadFreeBSD-src-1abc90f89416beb52c667717f4a745a73c6b156e.zip
FreeBSD-src-1abc90f89416beb52c667717f4a745a73c6b156e.tar.gz
Fix a bug in the device pager code that can trigger an assertion
in devfs if a particular race condition is hit in the device pager code. This was a side effect of change 227530 which changed the device pager interface to call a new destructor routine for the cdev. That destructor routine, old_dev_pager_dtor(), takes a VM object handle. The object handle is cast to a struct cdev *, and passed into dev_rel(). That works in most cases, except the case in cdev_pager_allocate() where there is a race condition between two threads allocating an object backed by the same device. The loser of the race deallocates its object at the end of the function. The problem is that before inserting the object into the dev_pager_object_list, the object's handle is changed from the struct cdev pointer to the object's own address. This is to avoid conflicts with the winner of the race, which already inserted an object in the list with a handle that is a pointer to the same cdev structure. The object is then passed to vm_object_deallocate(), and eventually makes its way down to old_dev_pager_dtor(). That function passes the handle pointer (which is actually a VM object, not a struct cdev as usual) into dev_rel(). dev_rel() decrements the reference count in the assumed struct cdev (which happens to be 0), and that triggers the assertion in dev_rel() that the reference count is greater than or equal to 0. The fix is to add a cdev pointer to the VM object, and use that pointer when calling the cdev_pg_dtor() routine. vm_object.h: Add a struct cdev pointer to the VM object structure. device_pager.c: In cdev_pager_allocate(), populate the new cdev pointer. In dev_pager_dealloc(), use the new cdev pointer when calling the object's cdev_pg_dtor() routine. Reviewed by: kib Sponsored by: Spectra Logic Corporation MFC after: 1 week
Diffstat (limited to 'sys/vm/vm_object.h')
-rw-r--r--sys/vm/vm_object.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h
index b584239..8134752 100644
--- a/sys/vm/vm_object.h
+++ b/sys/vm/vm_object.h
@@ -136,6 +136,7 @@ struct vm_object {
struct {
TAILQ_HEAD(, vm_page) devp_pglist;
struct cdev_pager_ops *ops;
+ struct cdev *dev;
} devp;
/*
OpenPOWER on IntegriCloud