Print this page
6198 Let's EOL cachefs
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/stmsboot/mpxio-upgrade
+++ new/usr/src/cmd/stmsboot/mpxio-upgrade
1 1 #!/sbin/sh
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the "License").
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 # When distributing Covered Code, include this CDDL HEADER in each
15 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets "[]" replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 19 #
20 20 # CDDL HEADER END
21 21 #
22 22 #
23 23 # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
24 +# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
24 25 #
25 26
26 27 . /lib/svc/share/fs_include.sh
27 28 . /lib/svc/share/net_include.sh
28 29
29 30 # Make sure that the essential libraries can be found.
30 31 LD_LIBRARY_PATH=/lib; export LD_LIBRARY_PATH
31 32 STMSBOOTUTIL=/lib/mpxio/stmsboot_util
32 33 SAVEDIR=/etc/mpxio
33 34 BOOTDEVICES=$SAVEDIR/boot-devices
34 35 RECOVERFILE=$SAVEDIR/recover_instructions
35 36 DEVFSADM=/usr/sbin/devfsadm
36 37 DUMPADM=/usr/sbin/dumpadm
37 38 METADEVADM=/usr/sbin/metadevadm
38 39 ISROOTDEV=""
39 40 ISROOTDEVPATH=""
40 41 usrmounted=0
41 42 UNAME=/usr/bin/uname
42 43 ECHO=/usr/bin/echo
43 44 CAT=/usr/bin/cat
44 45 CP=/usr/bin/cp
45 46 DF=/usr/bin/df
46 47 LS=/usr/bin/ls
47 48 RM=/usr/bin/rm
48 49 EGREP=/usr/bin/egrep
49 50 SED=/usr/bin/sed
50 51 ZPOOL=/usr/sbin/zpool
51 52 AWK=/usr/bin/awk
52 53 MOUNT=/sbin/mount
53 54 UMOUNT=/sbin/mount
54 55 EEPROM=/usr/sbin/eeprom
55 56 BOOTADM=/usr/sbin/bootadm
56 57 SVCADM=/usr/sbin/svcadm
57 58 REBOOT=/usr/sbin/reboot
58 59
59 60 mpxio_error()
60 61 {
61 62 cecho "\nERROR: stmsboot: $1"
62 63 #
63 64 # display recovery instructions - the first call logs to the service
64 65 # log and the second call displays on the console.
65 66 #
66 67 shcat $RECOVERFILE
67 68 shcat $RECOVERFILE >/dev/msglog 2>&1
68 69 cecho "These instructions were also logged to the file $RECOVERFILE\n"
69 70 }
70 71
71 72 #
72 73 # root ("/") is already mounted read only by the kernel.
73 74 # Remount the root read-write.
74 75 #
75 76 mpxio_mount_root()
76 77 {
77 78 HASZFSROOT=`$DF -g / |grep zfs`
78 79 RVAL=""
79 80
80 81 # In single-user maintenance mode, we don't have a writable
81 82 # root partition, so we _cannot_ use devlinks. Therefore we
82 83 # have to do some dancing - first mount the physical path
83 84 # read-write, then re-run $STMSBOOTUTIL to get the real
84 85 # devlink mapping, and then re-mount the root slice. Of course,
85 86 # if we all used ZFS this wouldn't be such a pain!
86 87 exec < $vfstab; readvfstab /
87 88 # ZFS root environments should _not_ have an entry for /
88 89 # in their /etc/vfstab.
89 90 if [ -n "$special" ]; then
90 91 # sanity check for ZFSRoot _and_ / in /etc/vfstab
91 92 if [ -n "$HASZFSROOT" ]; then
92 93 # ERROR - this would cause a failure later
93 94 # so let root know about it now and provide
94 95 # a chance to handle it before filesystem/usr
95 96 cecho "stmsboot: System has ZFS Root *and* an entry for / in /etc/vfstab\nstmsboot: Please remove the / entry from /etc/vfstab and then run\n# svcadm clear mpxio-upgrade"
96 97 exit 1
97 98 fi
98 99 ISPHYS=`echo $special |$AWK '/^\/dev\/dsk/ {print}'`;
99 100 if [ -z "$ISPHYS" ]; then
100 101 # a metadevice, either /dev/md or /dev/vx
101 102 new_special=$special
102 103 $MOUNT -o remount,rw $new_special / >/dev/msglog 2>&1
103 104 else
104 105 new_special=`$STMSBOOTUTIL -m $special`
105 106 if [ "$new_special" = "NOT_MAPPED" ]; then
106 107 # this is a bad state to be in, exit
107 108 cecho "Error: Your root device is not mapped."
108 109 exit 1
109 110 fi
110 111 checkopt "llock" $mntopts
111 112 mntopts='remount'
112 113 [ -n "$otherops" ] && mntopts="${mntopts},${otherops}"
113 114 RVAL=`$MOUNT -m -F $fstype -o $mntopts $new_special \
114 115 $mountp >/dev/msglog 2>&1`
115 116 # if we've got active-active paths to our rootvp and
116 117 # the first path returned by $STMSBOOTUTIL is not the
117 118 # same as the one we booted from, then we need some
118 119 # handwaving due to restrictions in the ufs module
119 120 # (see the remountfs() function in
120 121 # $SRC/uts/common/fs/ufs/ufs_vfsops.c)
121 122 if [ $? -eq 0 ]; then
122 123 # now re-run $STMSBOOTUTIL to get the real
123 124 # mapping for this device
124 125 new_special=`$STMSBOOTUTIL -m $special`
125 126 # mount root for real
126 127 $MOUNT -o remount,rw $new_special / \
127 128 >/dev/msglog 2>&1
128 129 else
129 130 for device in `$CAT $BOOTDEVICES`; do
130 131 new_special="/devices${device}"
131 132 $MOUNT -m -F $fstype -o $mntopts \
132 133 $new_special $mountp >/dev/msglog 2>&1
133 134 if [ $? -eq 0 ]; then
134 135 # success, break out
135 136 ISROOTDEVPATH=`$ECHO $device | \
136 137 $AWK -F":" '{print $1}'`
137 138 break;
138 139 fi
139 140 done
140 141 if [ -n "$RVAL" ]; then
141 142 cecho "Error: Unable to remount your root device"
142 143 exit 1;
143 144 fi
144 145 fi
145 146 fi
146 147 else
147 148 if [ -z "$HASZFSROOT" ]; then
148 149 cecho "stmsboot: Error: your root slice is invalid"
149 150 exit 1
150 151 else
151 152 cecho "stmsboot: Root is on ZFS"
152 153 fi
153 154 fi
154 155 }
155 156
156 157 #
157 158 # mount /usr read only
158 159 #
159 160 mpxio_mount_usr()
160 161 {
161 162 exec < $vfstab; readvfstab "/usr"
162 163 ret_val=0
163 164 if [ -n "$mountp" ]; then
164 165 case "$special" in
165 166 /dev/md/*)
↓ open down ↓ |
132 lines elided |
↑ open up ↑ |
166 167 new_special=$special
167 168 ;;
168 169 /dev/vx/*)
169 170 new_special=$special
170 171 ;;
171 172 *)
172 173 new_special=`$STMSBOOTUTIL -m $special`
173 174 ;;
174 175 esac
175 176
176 - if [ "$fstype" = "cachefs" ]; then
177 - # Mount read-only without the cache.
178 - case "$mntopts" in
179 - *backfstype=nfs*)
180 - cfsbacktype=nfs
181 - ;;
182 - *backfstype=hsfs*)
183 - cfsbacktype=hsfs
184 - ;;
185 - *)
186 - cecho 'stmsboot: invalid vfstab entry for /usr'
187 - cfsbacktype=nfs
188 - ;;
189 - esac
190 - # see the comment below for /dev/null
191 - $MOUNT -m -F $cfsbacktype -o ro $new_special $mountp \
192 ->/dev/null 2>&1
193 - ret_val=$?
177 + #
178 + # Must use -o largefiles here to ensure the read-only
179 + # mount does not fail as a result of having a large
180 + # file present on /usr.
181 + #
182 + if [ "$mntopts" = "-" ]; then
183 + mntopts='ro,largefiles'
194 184 else
195 - #
196 - # Must use -o largefiles here to ensure the read-only
197 - # mount does not fail as a result of having a large
198 - # file present on /usr.
199 - #
200 - if [ "$mntopts" = "-" ]; then
201 - mntopts='ro,largefiles'
202 - else
203 - checkopt largefiles $mntopts
204 - if [ "$option" != "largefiles" ]; then
205 - mntopts="largefiles,$mntopts"
206 - fi
185 + checkopt largefiles $mntopts
186 + if [ "$option" != "largefiles" ]; then
187 + mntopts="largefiles,$mntopts"
188 + fi
207 189
208 - checkopt ro $mntopts
209 - if [ "$option" != "ro" ]; then
210 - mntopts="ro,$mntopts"
211 - fi
190 + checkopt ro $mntopts
191 + if [ "$option" != "ro" ]; then
192 + mntopts="ro,$mntopts"
193 + fi
212 194
213 - # Requesting logging on a read-only mount
214 - # causes errors to be displayed, so remove
215 - # "logging" from the list of options.
216 - checkopt logging $mntopts
217 - if [ "$option" = "logging" ]; then
218 - mntopts="$otherops"
219 - fi
195 + # Requesting logging on a read-only mount
196 + # causes errors to be displayed, so remove
197 + # "logging" from the list of options.
198 + checkopt logging $mntopts
199 + if [ "$option" = "logging" ]; then
200 + mntopts="$otherops"
220 201 fi
202 + fi
221 203
222 - # In case of a manual restart of the service, mount
223 - # will emit messages if /usr is already mounted.
224 - # So redirect the output to /dev/null.
225 - $MOUNT -m -F $fstype -o $mntopts $new_special /usr \
204 + # In case of a manual restart of the service, mount
205 + # will emit messages if /usr is already mounted.
206 + # So redirect the output to /dev/null.
207 + $MOUNT -m -F $fstype -o $mntopts $new_special /usr \
226 208 >/dev/null 2>&1
227 - ret_val=$?
228 - fi
209 + ret_val=$?
229 210 if [ $ret_val -eq 0 ]; then
230 211 usrmounted=1
231 212 fi
232 213 fi
233 214
234 215 return $ret_val
235 216 }
236 217
237 218 # update system dump configuration
238 219 update_dumpconf()
239 220 {
240 221 # Disable device-in-use checking (done in libdiskmgt).
241 222 # Without disabling this check, the configuration of dump device
242 223 # would fail as the device-in-use code incorrectly concludes that
243 224 # the device is in use and hence prevents configuration of the dump
244 225 # device.
245 226 NOINUSE_CHECK=1
246 227 export NOINUSE_CHECK
247 228
248 229 DUMPISZFS=`$AWK -F"=" '/DUMPADM_DEVICE/ {print $2}' /etc/dumpadm.conf|$EGREP zvol`
249 230 if [ -z "$DUMPISZFS" ]; then
250 231 set -- `$DUMPADM -u 2>&1 | $EGREP 'cannot use /dev.* as dump device'`
251 232 if [ -n "$4" ]; then
252 233 newname=`$STMSBOOTUTIL -m $4`
253 234 if [ $? -eq 0 ]; then
254 235 if $DUMPADM -d $newname > /dev/msglog 2> /dev/console; then
255 236 cecho "stmsboot: dump configuration \
256 237 has been updated."
257 238 else
258 239 mpxio_error "failed to configure \
259 240 the dump device.\nold \
260 241 dump device name: $4"
261 242 return 1
262 243 fi
263 244 fi
264 245 fi
265 246 else
266 247 # make sure we can get to it, force zfs to load fully
267 248 $LS $DUMPISZFS >>/dev/null 2>&1
268 249 cecho "stmsboot: dump on ZFS, no dumpadm update required"
269 250 fi
270 251 return 0
271 252 }
272 253
273 254 # Update bootpath for x86 here when we are enabling mpxio on root
274 255 update_bootpath()
275 256 {
276 257 cur_bootpath=`$STMSBOOTUTIL -b`
277 258 if [ $? -ne 0 ]; then
278 259 cecho "stmsboot: ERROR! Unable to retrieve bootpath property\n"
279 260 exit 1
280 261 fi
281 262
282 263 # Since on x64 platforms the eeprom command doesn't update the
283 264 # kernel, the file /boot/solaris/bootenv.rc and the kernel's
284 265 # bootpath variable have a good chance of differing. We do some
285 266 # extra handwaving to get the correct bootpath variable setting.
286 267
287 268 ONDISKVER=`$AWK '/bootpath/ {print $3}' /boot/solaris/bootenv.rc|\
288 269 $SED -e"s,',,g"`
289 270 if [ "$ONDISKVER" != "$cur_bootpath" ]; then
290 271 cur_bootpath="$ONDISKVER"
291 272 fi
292 273
293 274 NEWBOOTPATH=""
294 275 for path in $cur_bootpath; do
295 276 mapped=`$STMSBOOTUTIL -p $path`
296 277 if [ "$mapped" != "NOT_MAPPED" ]; then
297 278 if [ "$mapped" != "$path" ]; then
298 279 NEWBOOTPATH=`echo "$path " | \
299 280 $SED -e"s|$path|$mapped|"`" $NEWBOOTPATH"
300 281 else
301 282 NEWBOOTPATH="$NEWBOOTPATH $path"
302 283 fi
303 284 fi
304 285 done
305 286 # now strip off leading and trailing space chars
306 287 new_bootpath=`echo $NEWBOOTPATH`
307 288 $EEPROM bootpath="$new_bootpath"
308 289 cecho "stmsboot: bootpath has been updated"
309 290 cecho ""
310 291 }
311 292
312 293 # Now do the actual work
313 294 mpxio_main()
314 295 {
315 296 # NOTE: If the first attempt to run the service has failed due to an
316 297 # expected error, users should be able to manually rerun the service.
317 298 #
318 299 # First mount /usr read only. This must be done to run
319 300 # utilities such as fsck and devfsadm.
320 301 # In the case of a manual rerun of the service, mounting of /usr here
321 302 # fails if /usr already happens to be mounted. It is better that we
322 303 # do not mount /usr if already mounted, but there seems to be no
323 304 # apparent way to check whether /usr is mounted or not as we mount
324 305 # /usr without making an entry into /etc/mnttab. So instead of
325 306 # explicitly checking for mount failures, we just do a sanity check
326 307 # by looking for some file (in this case devfsadm) in /usr.
327 308 #
328 309 mpxio_mount_usr
329 310 if [ ! -s $DEVFSADM ]; then
330 311 mpxio_error "failed to mount the /usr filesystem."
331 312 return
332 313 fi
333 314
334 315 if mpxio_mount_root; then
335 316 # create /dev links
336 317 cecho "stmsboot: configuring devices"
337 318 $DEVFSADM
338 319
339 320 if [ -n "$ISROOTDEVPATH" ]; then
340 321 ISROOTDEV=`$STMSBOOTUTIL -o $ISROOTDEVPATH`
341 322 fi
342 323
343 324 # update /etc/vfstab to reflect device name changes
344 325 $STMSBOOTUTIL -u >/dev/msglog 2>&1
345 326 if [ $? -eq 0 ]; then
346 327 $CP /etc/vfstab /etc/vfstab.old
347 328 # handle active-active paths, where the probe order
348 329 # for the hba reports a different path to what the
349 330 # boot-device variable gives us
350 331 if [ -n "$ISROOTDEV" ]; then
351 332 ROOTDEVCHK=`grep $ISROOTDEV /etc/vfstab`
352 333 if [ $? -ne 0 ]; then
353 334 # we got a different path for root
354 335 exec < $SAVEDIR/vfstab.new; readvfstab /
355 336 FILEDEV=`$ECHO $special | \
356 337 $SED -e"s,/dev/dsk/,," -e"s,s[0-9]*,,"`
357 338 $SED -e"s,$FILEDEV,$ISROOTDEV,g" < \
358 339 $SAVEDIR/vfstab.new > /etc/vfstab
359 340 fi
360 341 else
361 342 $CP $SAVEDIR/vfstab.new /etc/vfstab
362 343 fi
363 344 $RM $SAVEDIR/vfstab.new
364 345 cecho ""
365 346 cecho "stmsboot: vfstab has been updated"
366 347
367 348 if update_dumpconf; then
368 349 # update svm configuration to reflect new names
369 350 if [ -s /kernel/drv/md.conf ] && \
370 351 [ -x $METADEVADM ]; then
371 352 $METADEVADM -r >/dev/msglog 2>&1
372 353 fi
373 354 fi
374 355
375 356 MACH=`$UNAME -p`
376 357 if [ "$MACH" = "i386" ]; then
377 358 # only update bootpath here for x86
378 359 update_bootpath
379 360 fi
380 361 cecho "stmsboot: now regenerating boot archive"
381 362 $BOOTADM update-archive
382 363 else
383 364 mpxio_error "failed to update /etc/vfstab."
384 365 fi
385 366
386 367 $SVCADM disable system/device/mpxio-upgrade
387 368
388 369 if [ $usrmounted -eq 1 ]; then
389 370 cecho "stmsboot: rebooting the system now."
390 371 $REBOOT
391 372 fi
392 373 else
393 374 mpxio_error "failed to mount the root filesystem."
394 375 fi
395 376 }
396 377
397 378 mpxio_main
↓ open down ↓ |
159 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX