Project

General

Profile

« Previous | Next » 

Revision db6e63dd

Added by Christian McDonald over 3 years ago

Revert "Fix RAM disk support for ZFS layout changes related to BEs. Fixes #13182"

This reverts commit b9097e4cfe3fcbdec86a00a5a470d93d05ea8102

View differences:

src/etc/inc/pkg-utils.inc
114 114
		}
115 115
	}
116 116

  
117
#	if (isset($config['system']['use_mfs_tmpvar']) &&
118
#	    !file_exists("/conf/ram_disks_failed")) {
119
#		$pkg_env_vars['PKG_DBDIR'] = '/root/var/db/pkg';
120
#		$pkg_env_vars['PKG_CACHEDIR'] = '/root/var/cache/pkg';
121
#	}
117
	if (isset($config['system']['use_mfs_tmpvar']) &&
118
	    !file_exists("/conf/ram_disks_failed")) {
119
		$pkg_env_vars['PKG_DBDIR'] = '/root/var/db/pkg';
120
		$pkg_env_vars['PKG_CACHEDIR'] = '/root/var/cache/pkg';
121
	}
122 122

  
123 123
	foreach ($extra_env as $key => $value) {
124 124
		$pkg_env_vars[$key] = $value;
src/etc/pfSense-rc
144 144
	/sbin/reboot
145 145
fi
146 146

  
147
# Bring in RAM disk functions
148
. /etc/rc.ramdisk_functions.sh
149

  
150 147
# Handle ZFS read-only case
151 148
unset USE_ZFS
152 149
if /sbin/kldstat -qm zfs; then
......
165 162
		if [ -d /bootpool ]; then
166 163
			/sbin/zpool import -f bootpool
167 164
		fi
168
		_be_mount_zfs # /etc/rc.d/zfsbe onestart
165
		# We need to handle ZFS boot environments here
166
		echo "Enabling ZFS boot environment..."
167
		/etc/rc.d/zfsbe onestart
169 168
	fi
170 169
fi
171 170

  
......
182 181
# Sanity check the clock
183 182
/etc/rc.checkclock
184 183

  
184
. /etc/rc.ramdisk_functions.sh
185

  
185 186
# Check if RAM disks are enabled, store for repeated use
186 187
if ramdisk_check_enabled; then
187 188
	USE_RAMDISK=true
188 189
fi
189 190

  
190
# Relocate pkgdb on UFS based on desired RAM disk settings
191
if [ -z "${USE_ZFS}" ]; then
192
	ramdisk_relocate_pkgdb_all
193
fi
191
# Relocate pkgdb based on desired RAM disk settings
192
ramdisk_relocate_pkgdb_all
194 193

  
195 194
# Dismount /tmp and /var on ZFS if using RAM disks and they are separate volumes
196 195
if [ -n "${USE_ZFS}" -a -n "${USE_RAMDISK}" ]; then
197
	ramdisk_fixup_zfs_unmount
196
	ramdisk_fixup_zfs umount
198 197
fi
199 198

  
200 199
# Attempt to create and mount RAM disks
......
202 201
	/etc/rc.embedded
203 202
fi
204 203

  
205
# If RAM disks are active, make symlinks for pkg database on UFS
204
# If RAM disks are active, make symlinks for pkg database
206 205
if [ -n "${USE_RAMDISK}" -o -n "${MOVE_PKG_DATA}" ]; then
207
	if [ -z "${USE_ZFS}" ]; then
208
		ramdisk_link_pkgdb
209
	fi
206
	ramdisk_link_pkgdb
210 207
fi
211 208

  
212 209
# If activating RAM disks failed, then undo some of the above actions
213 210
if [ -n "${USE_RAMDISK}" ] && ramdisk_failed; then
214
	ramdisk_fixup_zfs_mount
215
	if [ -z "${USE_ZFS}" ]; then
216
		ramdisk_relocate_pkgdb disk
217
	fi
211
	ramdisk_fixup_zfs mount
212
	ramdisk_relocate_pkgdb disk
218 213
else
219 214
	ramdisk_reset_status
220 215
fi
src/etc/rc.ramdisk_functions.sh
26 26
RAMDISK_DEFAULT_SIZE_tmp=40
27 27
RAMDISK_DEFAULT_SIZE_var=60
28 28

  
29
_be_remount_ds() {
30
	local _dataset="${1}"
31

  
32
	/sbin/zfs list -rH -o mountpoint,name,canmount,mounted -s mountpoint -t filesystem "${_dataset}" | \
33
	while read _mp _name _canmount _mounted ; do
34
		# skip filesystems that must not be mounted
35
		[ "${_canmount}" = "off" -o "${_mp}" = "/" ] && continue
36
		# skip filesystems that are already mounted
37
		[ "$_mounted" = "yes" ] && \
38
			/sbin/umount -f "${_name}"
39
		# filesystems with mountpoint elsewhere
40
		/sbin/zfs mount "${_name}"
41
	done
42
}
43

  
44
_be_mount_zfs() {
45
	/sbin/mount -p | while read _dev _mp _type _rest; do
46
		[ "${_mp}"  = "/" ] || continue
47
		if [ "${_type}" = "zfs" ] ; then
48
			_be_remount_ds $_dev
49
		fi
50
		break
51
	done
52
}
53

  
54 29
# Check if RAM disks are enabled in config.xml
55 30
ramdisk_check_enabled () {
56 31
	[ "$(/usr/local/sbin/read_xml_tag.sh boolean system/use_mfs_tmpvar)" = "true" ]
......
128 103
	if [ ramdisk_check_size ]; then
129 104
		SIZE=$(eval echo \${${NAME}size})m
130 105
		/sbin/mount -o rw,size=${SIZE},mode=1777 -t tmpfs tmpfs /${NAME}
131
		_rc=$?
132
		_be_mount_zfs
133
		return ${_rc}
106
		return $?
134 107
	else
135 108
		return 1;
136 109
	fi
......
184 157
ramdisk_relocate_pkgdb_all () {
185 158
	unset MOVE_PKG_DATA
186 159
	unset USE_RAMDISK
187

  
188 160
	if ramdisk_check_enabled; then
189 161
		USE_RAMDISK=true
190 162
	fi
......
216 188
	fi
217 189
}
218 190

  
219
ramdisk_zfs_deep_unmount() {
220
	local _path="${1}"
221

  
222
	/sbin/zfs list -rH -o name,mountpoint -S mountpoint -t filesystem "${_path}" | \
223
	while read _name _mp; do
224
		echo -n "Dismounting ZFS volume ${_name} at ${_mp} for RAM disk..."
225
		/sbin/zfs unmount -f "${_name}" 1>/dev/null 2>&1
226
		echo " done."
227
	done
228
}
229

  
230
ramdisk_fixup_zfs_mount() {
231
	echo -n "Remounting ZFS volumes..."
232
	/sbin/zfs mount -a 1>/dev/null 2>&1
233
	_be_mount_zfs
234
	echo " done."
235
}
236

  
237
ramdisk_fixup_zfs_unmount() {
238
	ramdisk_zfs_deep_unmount "/tmp"
239
	ramdisk_zfs_deep_unmount "/var"
240
	_be_mount_zfs
191
# Either unmount or mount /var and /tmp in ZFS as needed to avoid conflicts with
192
#   active RAM disk options.
193
ramdisk_fixup_zfs () {
194
	# Mount /var and /tmp on ZFS filesystems when necessary
195
	if [ ${1} = "mount" ]; then
196
		echo "Remounting ZFS volumes"
197
		zfs mount -a
198
	else
199
		zfs list -H -o name,mountpoint |
200
		    while read volume mountpoint; do
201
			[ "${mountpoint}" != "/var" -a "${mountpoint}" != "/tmp" ] \
202
				&& continue
203
			echo "Dismounting ZFS volume ${volume} for RAM disk"
204
			/sbin/zfs umount ${volume}
205
		done
206
	fi
241 207
}
src/etc/skel/dot.shrc
35 35
fi
36 36

  
37 37
USE_MFS_TMPVAR=$(/usr/local/sbin/read_xml_tag.sh boolean system/use_mfs_tmpvar)
38
# if [ "${USE_MFS_TMPVAR}" = "true" ] && [ ! -f /conf/ram_disks_failed ]; then
39
# 	export PKG_DBDIR='/root/var/db/pkg'
40
# 	export PKG_CACHEDIR='/root/var/cache/pkg'
41
# fi
38
if [ "${USE_MFS_TMPVAR}" = "true" ] && [ ! -f /conf/ram_disks_failed ]; then
39
	export PKG_DBDIR='/root/var/db/pkg'
40
	export PKG_CACHEDIR='/root/var/cache/pkg'
41
fi
42 42

  
43 43
# Detect interactive logins and display the shell
44 44
unset _interactive
src/etc/skel/dot.tcshrc
76 76
endif
77 77

  
78 78
set use_mfs_tmpvar=`/usr/local/sbin/read_xml_tag.sh boolean system/use_mfs_tmpvar`
79
# if ( $use_mfs_tmpvar == "true" && ! -f "/conf/ram_disks_failed" ) then
80
# 	setenv PKG_DBDIR '/root/var/db/pkg'
81
# 	setenv PKG_CACHEDIR '/root/var/cache/pkg'
82
# endif
79
if ( $use_mfs_tmpvar == "true" && ! -f "/conf/ram_disks_failed" ) then
80
	setenv PKG_DBDIR '/root/var/db/pkg'
81
	setenv PKG_CACHEDIR '/root/var/cache/pkg'
82
endif

Also available in: Unified diff