NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/57883: Tar opens /dev/(r)fd0* devices on backup hanging when floppy is empty



>Number:         57883
>Category:       bin
>Synopsis:       Tar opens /dev/(r)fd0* devices on backup hanging when floppy is empty
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 28 15:30:00 +0000 2024
>Originator:     Henryk Paluch
>Release:        NetBSD 9.3 RELEASE
>Organization:
personal
>Environment:
NetBSD netbsd-ssd 9.3 NetBSD 9.3 (GENERIC) #0: Thu Aug  4 15:30:37 UTC 2022  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
When I use ordinary tar to backup /dev directory it will actually access all floppy devices there (It will open each device and query it for extattr_list_fd).

When floppy drive is empty, tar will hang for around 30s for each /dev/fd0* and /dev/rfd0* device - making it nearly impossible to backup /dev in reasonable time.
>How-To-Repeat:
Required bare-metal machine with empty floppy drive. Tried also guest under KVM/Qemu, but it has much shorter timeouts (and no noise) so it was not much noticeable.

Run tar to backup whole /dev/ or just singe floppy character device:

ls -l /dev/rfd0

crw-r-----  1 root  operator  9, 3 Jan 28 08:39 /dev/rfd0

tar cvf /root/backup.tar -C / dev/rfd0

Above tar command will take 31 seconds to backup single character device /dev/rfd0 because it will open it which will make kernel trying read floppy disk and throwing these error message (dmesg output):

[  1798.055846] fdcresult: timeout
[  1802.712653] fdcresult: timeout
[  1802.712653]  (st0 0x20<seek_cmplt> cyl 0)
[  1802.712653] fd0: timeout<3>fdcresult: timeout
[  1810.256803]  (st0 0x20<seek_cmplt> cyl 0)
[  1810.256803] fd0: timeout<3>fdcresult: timeout
[  1817.800953]  (st0 0x20<seek_cmplt> cyl 0)
[  1817.800953] fd0: timeout<3>fdcresult: timeout
[  1825.345103]  (st0 0x20<seek_cmplt> cyl 0)
[  1825.345103] fd0: timeout<3>fdcresult: timeout
[  1829.656978]  (st0 0x20<seek_cmplt> cyl 0)
[  1829.656978] fd0: timeoutfd0d: hard error reading fsbn 0 of 0-2 (st0 0x20<seek_cmplt> st1 0x0 st2 0x0 cyl 0 head 0 sec 0)

Here is relevant output of ktrace/kdump -R which clearly shows that TAR really opens character device, hangs for 31 seconds and attempts to get extattr_list(?)

  6409      1 tar      0.000017480 CALL  openat(5,0x77ac7a933100,4,0)
  6409      1 tar      0.000002600 NAMI  "dev/rfd0"
  6409      1 tar      31.881039760 RET   openat 6
  6409      1 tar      0.000019280 CALL  extattr_list_fd(6,1,0,0)
  6409      1 tar      0.000003480 RET   extattr_list_fd -1 errno 45 Operation not supported
  6409      1 tar      0.000012640 CALL  close(6)


>Fix:
When formatted floppy is inserted in drive, backup of /dev with tar will finish in acceptable time (however it still tries to access floppy several times).

Expected behaviour: TAR should never open backed block or char devices (should just backup node type, major, minor and permissions), because it may have significant and unexpected side effects - including loss of data.



Home | Main Index | Thread Index | Old Index