pfsense/pfsense — pull request #805 by phildd (2013-09-19 07:18:55+00:00)
Title: Teach refcount_read to create the shared memory

When the system has nanobsd_force_rw enabled, the refcount memory section may not be there. This can happen when the system is booted with nanobsd_force_rw set. refcount_read reports:
php: /diag_nanobsd.php: Could not open shared memory for read 1000
Rather than put this spurious noise in the system log, refcount_read can create the memory section and set the refcount to zero.

When nanobsd_force_rw is on, the refcount is not maintained by conf_mount_rw and conf_mount_ro calls. So it will generally be sitting on zero (or no memory section at all). When nanobsd_force_rw is disabled, the subsequent conf_mount_ro call complains in the system log:
Reference 1000 is going negative, not doing unreference.

So, when disabling nanobsd_force_rw we should increment refcount. Thus refcount will reflect the current reality (the disk is mounted RW). The subsequent conf_mount_ro() will then happily decrement it to 0, mount read-only and not make any noise in the system log.

Forum report and discussion: http://forum.pfsense.org/index.php/topic,66764.0.html