From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Fri, 07 Nov 2014 15:00:01 -0700 Subject: [U-Boot] [PATCH v2] test: ums: Add sleep before unmount directory In-Reply-To: <20141107215404.3580138334A@gemini.denx.de> References: <1415269420-6528-1-git-send-email-l.majewski@samsung.com> <1415365555-9790-1-git-send-email-l.majewski@samsung.com> <20141107215404.3580138334A@gemini.denx.de> Message-ID: <545D40E1.2030700@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 11/07/2014 02:54 PM, Wolfgang Denk wrote: > Dear Lukasz, > > In message <1415365555-9790-1-git-send-email-l.majewski@samsung.com> you wrote: >> >> - umount $MNT_DIR >> >> + while true; do >> + umount $MNT_DIR > /dev/null 2>&1 >> + if [ $? -eq 0 ]; then >> + break >> + fi >> + printf "$COLOUR_ORANGE\tSleeping to wait for umount...$COLOUR_DEFAULT\n" >> + sleep 1 >> + done > > As Marek already pointed out, umount (both the command (8) and the > syscall (2)) are supposed to be blocking (except for typical error > cases like no permission, mountpoint does not exist, no file system > mounted, etc.). > > If you really ever see the umount entering above loop, then there is > some bug somewhere. It would be indeed interesting to see the strace > log for such umount calls. Also, can you please add details about the > exact execution environment (host system / architecture, kernel > version, distro, and _especially_ which sort of USB driver is involved > here. > > My gut feeling is that there might be some USB driver error involved > here. Where I've seen this is writing to an SD card in a USB-based SD card reader. I have a fairly regular amd64 machine running Ubuntu. I put the loop above into my own scripts that mount an SD card, copy new data to it, and then immediately unmount it for the same reason that Lukasz made this patch; umount doesn't always unmount. I did this so long ago that I don't recall which Ubuntu version I had at the time, nor the kernel version. It was *probably* Ubuntu 10.04 or 12.10 though. Now I'm on 14.04, but have no idea if I still need the loop since it's already in place:-)