Skip to content

Commit 6c2fd18

Browse files
authored
Fixed S6000 abrupt reboot in 201811 (#6923)
Why I did it The S6000 devices, the cold reboot is abrupt and it is likely to cause issues which will cause the device to land into EFI shell. Hence the platform reboot will happen after graceful unmount of all the filesystems as in S6100. How I did it Moved the platform_reboot to platform_reboot_override and hooked it to the systemd shutdown services as in S6100. Fixed the "/host unmount failed" issue as well in 201811. How to verify it Issue "reboot" command to verify if the reboot is happening gracefully.
1 parent 2877cc9 commit 6c2fd18

File tree

8 files changed

+99
-63
lines changed

8 files changed

+99
-63
lines changed

device/dell/x86_64-dell_s6000_s1220-r0/platform_reboot

-63
This file was deleted.

files/build_templates/sonic_debian_extension.j2

+5
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog-config.sh $FILESYSTEM_ROOT/usr/bin/
171171
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.conf.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/
172172
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.d/* $FILESYSTEM_ROOT/etc/rsyslog.d/
173173

174+
# Copy syslog override files
175+
sudo mkdir -p $FILESYSTEM_ROOT/etc/systemd/system/syslog.socket.d
176+
sudo cp $IMAGE_CONFIGS/syslog/override.conf $FILESYSTEM_ROOT/etc/systemd/system/syslog.socket.d/override.conf
177+
sudo cp $IMAGE_CONFIGS/syslog/host_umount.sh $FILESYSTEM_ROOT/usr/bin/
178+
174179
# Copy logrotate.d configuration files
175180
sudo cp -f $IMAGE_CONFIGS/logrotate/logrotate.d/* $FILESYSTEM_ROOT/etc/logrotate.d/
176181

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
# This script is invoked at the closure of syslog socket during reboot
3+
# This will stop journal services, unmount /var/log and delete loop device
4+
# associated to /host to ensure proper unmount of /host
5+
6+
journal_stop() {
7+
systemctl stop systemd-journald.service
8+
}
9+
10+
delete_loop_device() {
11+
umount /var/log
12+
if [[ $? -ne 0 ]]
13+
then
14+
exit 0
15+
fi
16+
loop_exist=$(losetup -a | grep loop1 | wc -l)
17+
if [ $loop_exist -ne 0 ]; then
18+
losetup -d /dev/loop1
19+
fi
20+
}
21+
22+
case "$1" in
23+
journal_stop|delete_loop_device)
24+
$1
25+
;;
26+
*)
27+
echo "Usage: $0 {journal_stop|delete_loop_device}" >&2
28+
exit 1
29+
;;
30+
esac
31+
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[Unit]
2+
After=var-log.mount host.mount local-fs.target
3+
4+
[Socket]
5+
ExecStopPre=/usr/bin/host_umount.sh journal_stop
6+
ExecStopPost=/usr/bin/host_umount.sh delete_loop_device

platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6000.install

+3
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ s6000/scripts/reset-qsfp usr/local/bin
33
s6000/scripts/set-fan-speed usr/local/bin
44
s6000/systemd/platform-modules-s6000.service etc/systemd/system
55
common/io_rd_wr.py usr/local/bin
6+
s6000/scripts/platform_reboot_override usr/share/sonic/device/x86_64-dell_s6000_s1220-r0
7+
s6000/scripts/platform_update_reboot_cause usr/share/sonic/device/x86_64-dell_s6000_s1220-r0
8+
s6000/scripts/override.conf /etc/systemd/system/systemd-reboot.service.d
69
s6000/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-dell_s6000_s1220-r0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[Service]
2+
ExecStart=
3+
ExecStart=/usr/share/sonic/device/x86_64-dell_s6000_s1220-r0/platform_reboot_override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python
2+
3+
import os
4+
import struct
5+
6+
PORT_RES = '/dev/port'
7+
COLD_RESET = 0xE # Cold Reset
8+
WARM_RESET = 0x6 # Warm Reset
9+
RESET_REG = 0xCF9
10+
11+
def io_reg_write(resource, offset, val):
12+
fd = os.open(resource, os.O_RDWR)
13+
if fd < 0:
14+
print('file open failed %s" % resource')
15+
return
16+
if os.lseek(fd, offset, os.SEEK_SET) != offset:
17+
print('lseek failed on %s' % resource)
18+
return
19+
ret = os.write(fd, struct.pack('B', val))
20+
if ret != 1:
21+
print('write failed %d' % ret)
22+
return
23+
os.close(fd)
24+
25+
if __name__ == "__main__":
26+
io_reg_write(PORT_RES, RESET_REG, COLD_RESET)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python
2+
3+
import os
4+
import struct
5+
6+
NVRAM_RES = '/dev/nvram'
7+
COLD_RESET = 0xE # Cold Reset
8+
WARM_RESET = 0x6 # Warm Reset
9+
10+
def io_reg_write(resource, offset, val):
11+
fd = os.open(resource, os.O_RDWR)
12+
if fd < 0:
13+
print('file open failed %s" % resource')
14+
return
15+
if os.lseek(fd, offset, os.SEEK_SET) != offset:
16+
print('lseek failed on %s' % resource)
17+
return
18+
ret = os.write(fd, struct.pack('B', val))
19+
if ret != 1:
20+
print('write failed %d' % ret)
21+
return
22+
os.close(fd)
23+
24+
if __name__ == "__main__":
25+
io_reg_write(NVRAM_RES, 0x49, COLD_RESET)

0 commit comments

Comments
 (0)