Date: Thu, 07 May 2015 22:59:46 +1000 From: Lawrence Stewart <lstewart@room52.net> To: =?UTF-8?B?RWR3YXJkIFRvbWFzeiBOYXBpZXJhxYJh?= <trasz@freebsd.org>, Ryan Stone <rysto32@gmail.com> Cc: "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org> Subject: Re: What's required to make removal of a mounted USB stick safe? Message-ID: <554B61C2.5000704@room52.net> In-Reply-To: <1306708F-0872-4D02-9C88-70F683018C39@FreeBSD.org> References: <CAFMmRNwTi2GOEHN1tDQ7o1-VAtykT%2Bz3g%2B70qaDMenThSrSRgQ@mail.gmail.com> <1306708F-0872-4D02-9C88-70F683018C39@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 05/07/15 16:23, Edward Tomasz Napierała wrote: > > Dnia 6 maj 2015 o godz. 22:49 Ryan Stone <rysto32@gmail.com> > napisał(a): > >> Currently FreeBSD stands a fair chance at panicking if a mounted >> USB drive is removed while I/O is in flight. Does anybody know >> what work is involved to have the kernel safely recover from this >> case? Losing data from the drive is expected of course but there's >> no reason that the entire kernel has to crash. > > I've spent some time on this few years ago, and got it to work, > except for one case: UFS with softupdates. It's possible that some > regressions have been introduced since then. What's the filesystem? > Do you have a backtrace? I had a recent crash caused by accidentally unplugging my phone which I had the SD card mounted over USB cable. It had been automounted by KDE. If I recall correctly, there was no IO in flight, but I had copied a file from the phone to my laptop a minute or so prior to accidentally unplugging. I have a vmcore if there would be any additional useful information. lstewart@lstewart-laptop> uname -a FreeBSD lstewart-laptop 11.0-CURRENT FreeBSD 11.0-CURRENT #2 r279802: Sat Mar 14 13:31:32 AEDT 2015 root@lstewart-laptop:/usr/obj/usr/src/sys/LSTEWART-LAPTOP amd64 Some info from core.txt: panic: dead bo 0xfffff8015109e2a8 GNU gdb 6.1.1 [FreeBSD] Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "amd64-marcel-freebsd"... Unread portion of the kernel message buffer: lock order reversal: 1st 0xfffff8033bf72418 zfs (zfs) @ /usr/src/sys/kern/vfs_mount.c:1229 2nd 0xfffff80151b69240 syncer (syncer) @ /usr/src/sys/kern/vfs_subr.c:2287 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe0460ebd510 witness_checkorder() at witness_checkorder+0xe45/frame 0xfffffe0460ebd5a0 __lockmgr_args() at __lockmgr_args+0xacf/frame 0xfffffe0460ebd6d0 vop_stdlock() at vop_stdlock+0x3c/frame 0xfffffe0460ebd6f0 VOP_LOCK1_APV() at VOP_LOCK1_APV+0xfc/frame 0xfffffe0460ebd720 _vn_lock() at _vn_lock+0x8a/frame 0xfffffe0460ebd790 vputx() at vputx+0x232/frame 0xfffffe0460ebd7f0 dounmount() at dounmount+0x305/frame 0xfffffe0460ebd870 sys_unmount() at sys_unmount+0x2ec/frame 0xfffffe0460ebd9a0 amd64_syscall() at amd64_syscall+0x27f/frame 0xfffffe0460ebdab0 Xfast_syscall() at Xfast_syscall+0xfb/frame 0xfffffe0460ebdab0 --- syscall (22, FreeBSD ELF64, sys_unmount), rip = 0x8008990ea, rsp = 0x7fffffffda28, rbp = 0x7fffffffdb40 --- lock order reversal: 1st 0xfffff8033bf72418 zfs (zfs) @ /usr/src/sys/kern/vfs_mount.c:1229 2nd 0xfffff8015109e240 devfs (devfs) @ /usr/src/sys/fs/msdosfs/msdosfs_vfsops.c:993 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe0460ebd490 witness_checkorder() at witness_checkorder+0xe45/frame 0xfffffe0460ebd520 __lockmgr_args() at __lockmgr_args+0xacf/frame 0xfffffe0460ebd650 vop_stdlock() at vop_stdlock+0x3c/frame 0xfffffe0460ebd670 VOP_LOCK1_APV() at VOP_LOCK1_APV+0xfc/frame 0xfffffe0460ebd6a0 _vn_lock() at _vn_lock+0x8a/frame 0xfffffe0460ebd710 msdosfs_sync() at msdosfs_sync+0x192/frame 0xfffffe0460ebd7a0 msdosfs_unmount() at msdosfs_unmount+0x20/frame 0xfffffe0460ebd7f0 dounmount() at dounmount+0x42c/frame 0xfffffe0460ebd870 sys_unmount() at sys_unmount+0x2ec/frame 0xfffffe0460ebd9a0 amd64_syscall() at amd64_syscall+0x27f/frame 0xfffffe0460ebdab0 Xfast_syscall() at Xfast_syscall+0xfb/frame 0xfffffe0460ebdab0 --- syscall (22, FreeBSD ELF64, sys_unmount), rip = 0x8008990ea, rsp = 0x7fffffffda28, rbp = 0x7fffffffdb40 --- panic: dead bo 0xfffff8015109e2a8 cpuid = 3 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe0460ebd520 vpanic() at vpanic+0x189/frame 0xfffffe0460ebd5a0 kassert_panic() at kassert_panic+0x132/frame 0xfffffe0460ebd610 buf_vlist_add() at buf_vlist_add+0x15c/frame 0xfffffe0460ebd640 getblk() at getblk+0x8ed/frame 0xfffffe0460ebd700 breadn_flags() at breadn_flags+0x2d/frame 0xfffffe0460ebd740 markvoldirty() at markvoldirty+0xc4/frame 0xfffffe0460ebd7a0 msdosfs_unmount() at msdosfs_unmount+0x7e/frame 0xfffffe0460ebd7f0 dounmount() at dounmount+0x42c/frame 0xfffffe0460ebd870 sys_unmount() at sys_unmount+0x2ec/frame 0xfffffe0460ebd9a0 amd64_syscall() at amd64_syscall+0x27f/frame 0xfffffe0460ebdab0 Xfast_syscall() at Xfast_syscall+0xfb/frame 0xfffffe0460ebdab0 --- syscall (22, FreeBSD ELF64, sys_unmount), rip = 0x8008990ea, rsp = 0x7fffffffda28, rbp = 0x7fffffffdb40 --- KDB: enter: panic Reading symbols from /boot/kernel/zfs.ko.symbols...done. Loaded symbols for /boot/kernel/zfs.ko.symbols Reading symbols from /boot/kernel/opensolaris.ko.symbols...done. Loaded symbols for /boot/kernel/opensolaris.ko.symbols Reading symbols from /boot/kernel/sem.ko.symbols...done. Loaded symbols for /boot/kernel/sem.ko.symbols Reading symbols from /boot/kernel/ums.ko.symbols...done. Loaded symbols for /boot/kernel/ums.ko.symbols Reading symbols from /boot/kernel/ng_ubt.ko.symbols...done. Loaded symbols for /boot/kernel/ng_ubt.ko.symbols Reading symbols from /boot/kernel/netgraph.ko.symbols...done. Loaded symbols for /boot/kernel/netgraph.ko.symbols Reading symbols from /boot/kernel/ng_hci.ko.symbols...done. Loaded symbols for /boot/kernel/ng_hci.ko.symbols Reading symbols from /boot/kernel/ng_bluetooth.ko.symbols...done. Loaded symbols for /boot/kernel/ng_bluetooth.ko.symbols Reading symbols from /boot/kernel/ng_l2cap.ko.symbols...done. Loaded symbols for /boot/kernel/ng_l2cap.ko.symbols Reading symbols from /boot/kernel/ng_btsocket.ko.symbols...done. Loaded symbols for /boot/kernel/ng_btsocket.ko.symbols Reading symbols from /boot/kernel/ng_socket.ko.symbols...done. Loaded symbols for /boot/kernel/ng_socket.ko.symbols Reading symbols from /boot/kernel/linux.ko.symbols...done. Loaded symbols for /boot/kernel/linux.ko.symbols Reading symbols from /boot/kernel/i915kms.ko.symbols...done. Loaded symbols for /boot/kernel/i915kms.ko.symbols Reading symbols from /boot/kernel/drm2.ko.symbols...done. Loaded symbols for /boot/kernel/drm2.ko.symbols Reading symbols from /boot/kernel/iicbus.ko.symbols...done. Loaded symbols for /boot/kernel/iicbus.ko.symbols Reading symbols from /boot/kernel/iic.ko.symbols...done. Loaded symbols for /boot/kernel/iic.ko.symbols Reading symbols from /boot/kernel/iicbb.ko.symbols...done. Loaded symbols for /boot/kernel/iicbb.ko.symbols Reading symbols from /boot/modules/vboxdrv.ko...done. Loaded symbols for /boot/modules/vboxdrv.ko Reading symbols from /boot/modules/vboxnetadp.ko...done. Loaded symbols for /boot/modules/vboxnetadp.ko Reading symbols from /boot/modules/vboxnetflt.ko...done. Loaded symbols for /boot/modules/vboxnetflt.ko Reading symbols from /boot/kernel/ng_ether.ko.symbols...done. Loaded symbols for /boot/kernel/ng_ether.ko.symbols Reading symbols from /boot/kernel/ipfw.ko.symbols...done. Loaded symbols for /boot/kernel/ipfw.ko.symbols #0 doadump (textdump=Unhandled dwarf expression opcode 0x93 ) at pcpu.h:219 219 pcpu.h: No such file or directory. in pcpu.h (kgdb) #0 doadump (textdump=Unhandled dwarf expression opcode 0x93 ) at pcpu.h:219 #1 0xffffffff80355e66 in db_fncall (dummy1=<value optimized out>, dummy2=<value optimized out>, dummy3=<value optimized out>, dummy4=<value optimized out>) at /usr/src/sys/ddb/db_command.c:568 #2 0xffffffff80355b4c in db_command (cmd_table=0x0) at /usr/src/sys/ddb/db_command.c:440 #3 0xffffffff803558b4 in db_command_loop () at /usr/src/sys/ddb/db_command.c:493 #4 0xffffffff803583f0 in db_trap (type=<value optimized out>, code=Unhandled dwarf expression opcode 0x93 ) at /usr/src/sys/ddb/db_main.c:251 #5 0xffffffff8098af9e in kdb_trap (type=Unhandled dwarf expression opcode 0x93 ) at /usr/src/sys/kern/subr_kdb.c:654 #6 0xffffffff80d7280b in trap (frame=0xfffffe0460ebd450) at /usr/src/sys/amd64/amd64/trap.c:542 #7 0xffffffff80d51d02 in calltrap () at /usr/src/sys/amd64/amd64/exception.S:235 #8 0xffffffff8098a68e in kdb_enter (why=0xffffffff8100c329 "panic", msg=0x80 <Address 0x80 out of bounds>) at cpufunc.h:63 #9 0xffffffff8094e609 in vpanic (fmt=<value optimized out>, ap=<value optimized out>) at /usr/src/sys/kern/kern_shutdown.c:740 #10 0xffffffff8094e452 in kassert_panic (fmt=<value optimized out>) at /usr/src/sys/kern/kern_shutdown.c:635 #11 0xffffffff80a02b3c in buf_vlist_add (bp=0xfffffe03d9f3c618, bo=0xfffff8015109e2a8, xflags=Unhandled dwarf expression opcode 0x93 ) at /usr/src/sys/kern/vfs_subr.c:1582 #12 0xffffffff809e8bdd in getblk (vp=0xfffff8015109e1d8, blkno=18, size=4096, slpflag=<value optimized out>, slptimeo=0, flags=<value optimized out>) at /usr/src/sys/kern/vfs_bio.c:3276 #13 0xffffffff809e972d in breadn_flags (vp=0xfffff8015109e1d8, blkno=128, size=Unhandled dwarf expression opcode 0x93 ) at /usr/src/sys/kern/vfs_bio.c:1158 #14 0xffffffff80836df4 in markvoldirty (pmp=0xfffff801308e6800, dirty=Unhandled dwarf expression opcode 0x93 ) at /usr/src/sys/fs/msdosfs/msdosfs_fat.c:1097 #15 0xffffffff8083b2de in msdosfs_unmount (mp=0xfffff8001b0a0990, mntflags=<value optimized out>) at /usr/src/sys/fs/msdosfs/msdosfs_vfsops.c:811 #16 0xffffffff809fcb9c in dounmount (mp=<value optimized out>, flags=Unhandled dwarf expression opcode 0x93 ) at /usr/src/sys/kern/vfs_mount.c:1316 #17 0xffffffff809fc74c in sys_unmount (td=0xfffff803da4b6940, uap=0xfffffe0460ebda40) at /usr/src/sys/kern/vfs_mount.c:1207 #18 0xffffffff80d7372f in amd64_syscall (td=0xfffff803da4b6940, traced=0) at subr_syscall.c:133 #19 0xffffffff80d51feb in Xfast_syscall () at /usr/src/sys/amd64/amd64/exception.S:395 #20 0x00000008008990ea in ?? () Previous frame inner to this frame (corrupt stack?) Current language: auto; currently minimal Cheers, Lawrence
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?554B61C2.5000704>