Re: [U-Boot] [PATCH v2] test: ums: Add sleep before unmount directory

2014-11-14 Thread Lukasz Majewski
Hi Lukasz,

 On Wed, 12 Nov 2014 11:11:33 -0700
 Stephen Warren swar...@wwwdotorg.org wrote:
 
  On 11/12/2014 09:45 AM, Wolfgang Denk wrote:
   Dear Lukasz,
  
   In message 20141112152949.1fe6ce3c@amdc2363 you wrote:
  
   But this is a bug.  Papering over is not a good idea.  It should
   be analyzed, reported, and finally fixed.
  
   I've debugged the script with strace.
  
   Thanks a lot for that!
  
   The problem is with umount() syscall:
   ...
   I need to debug the syscall in the kernel.
  
   I have a gut feeling that this might be a problem somewhere with
   the USB stuff that is involved here.  Maybe enabling some degug
   messages for the USB subsystem gives some more information?
  
  If this really is related to USB only, it may be worth asking on
  the linux-usb mailing list to see if anyone already unerstands the
  issue.
 
 Frankly speaking, I'm personally curious why such things happen. I may
 look into the issue in my spare :-) time.
 
 In spite of this, I agree with Stephen:
 
  
  Irrespective of all this though, even if there is a kernel issue and
  it can be fixed, I still think we should apply this patch, because
  the issue currently affects people. At the very least it will until
  some kernel fix is rolled out to everyone's distro, which will be a
  while no matter what.
 
 +1
 
 The problem seems to be with long time running linux. The error seems
 to be orthogonal to our u-boot's UMS work.
 
  ___
  U-Boot mailing list
  U-Boot@lists.denx.de
  http://lists.denx.de/mailman/listinfo/u-boot
 
 Best regards,
 Lukasz Majewski

Applied to u-boot-dfu tree. Thanks.

-- 
Best regards,

Lukasz Majewski

Samsung RD Institute Poland (SRPOL) | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] test: ums: Add sleep before unmount directory

2014-11-12 Thread Lukasz Majewski
Hi Wolfgang,

 Dear Stephen,
 
 In message 545d40e1.2030...@wwwdotorg.org you wrote:
 
   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:-)
 
 But this is a bug.  Papering over is not a good idea.  It should be
 analyzed, reported, and finally fixed.
 

I've debugged the script with strace.

The problem is with umount() syscall:

[pid 23296] umount(/mnt/tmp-ums-test, 0) = -1 EBUSY (Device or
resource busy)

It is somehow strange, because with strace attached I occasionally see
correct behaviour:

[pid 23776] umount(/mnt/tmp-ums-test, 0) = 0

I need to debug the syscall in the kernel.


Information about my system:

x86_64:
Linux 3.12.0 #2 SMP PREEMPT Wed Nov 27 10:26:22 CET 2013 x86_64
GNU/Linux

Debian 7.4.


 Best regards,
 
 Wolfgang Denk
 



-- 
Best regards,

Lukasz Majewski

Samsung RD Institute Poland (SRPOL) | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] test: ums: Add sleep before unmount directory

2014-11-12 Thread Wolfgang Denk
Dear Lukasz,

In message 20141112152949.1fe6ce3c@amdc2363 you wrote:
 
  But this is a bug.  Papering over is not a good idea.  It should be
  analyzed, reported, and finally fixed.
 
 I've debugged the script with strace.

Thanks a lot for that!

 The problem is with umount() syscall:
...
 I need to debug the syscall in the kernel.

I have a gut feeling that this might be a problem somewhere with the
USB stuff that is involved here.  Maybe enabling some degug messages
for the USB subsystem gives some more information?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk  Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
The universe is all a spin-off of the Big Bang.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] test: ums: Add sleep before unmount directory

2014-11-12 Thread Stephen Warren

On 11/12/2014 09:45 AM, Wolfgang Denk wrote:

Dear Lukasz,

In message 20141112152949.1fe6ce3c@amdc2363 you wrote:



But this is a bug.  Papering over is not a good idea.  It should be
analyzed, reported, and finally fixed.


I've debugged the script with strace.


Thanks a lot for that!


The problem is with umount() syscall:

...

I need to debug the syscall in the kernel.


I have a gut feeling that this might be a problem somewhere with the
USB stuff that is involved here.  Maybe enabling some degug messages
for the USB subsystem gives some more information?


If this really is related to USB only, it may be worth asking on the 
linux-usb mailing list to see if anyone already unerstands the issue.


Irrespective of all this though, even if there is a kernel issue and it 
can be fixed, I still think we should apply this patch, because the 
issue currently affects people. At the very least it will until some 
kernel fix is rolled out to everyone's distro, which will be a while no 
matter what.

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] test: ums: Add sleep before unmount directory

2014-11-12 Thread Lukasz Majewski
On Wed, 12 Nov 2014 11:11:33 -0700
Stephen Warren swar...@wwwdotorg.org wrote:

 On 11/12/2014 09:45 AM, Wolfgang Denk wrote:
  Dear Lukasz,
 
  In message 20141112152949.1fe6ce3c@amdc2363 you wrote:
 
  But this is a bug.  Papering over is not a good idea.  It should
  be analyzed, reported, and finally fixed.
 
  I've debugged the script with strace.
 
  Thanks a lot for that!
 
  The problem is with umount() syscall:
  ...
  I need to debug the syscall in the kernel.
 
  I have a gut feeling that this might be a problem somewhere with the
  USB stuff that is involved here.  Maybe enabling some degug messages
  for the USB subsystem gives some more information?
 
 If this really is related to USB only, it may be worth asking on the 
 linux-usb mailing list to see if anyone already unerstands the issue.

Frankly speaking, I'm personally curious why such things happen. I may
look into the issue in my spare :-) time.

In spite of this, I agree with Stephen:

 
 Irrespective of all this though, even if there is a kernel issue and
 it can be fixed, I still think we should apply this patch, because
 the issue currently affects people. At the very least it will until
 some kernel fix is rolled out to everyone's distro, which will be a
 while no matter what.

+1

The problem seems to be with long time running linux. The error seems
to be orthogonal to our u-boot's UMS work.

 ___
 U-Boot mailing list
 U-Boot@lists.denx.de
 http://lists.denx.de/mailman/listinfo/u-boot

Best regards,
Lukasz Majewski


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] test: ums: Add sleep before unmount directory

2014-11-07 Thread Stephen Warren

On 11/07/2014 06:05 AM, Lukasz Majewski wrote:

This change helps to run script on machines with quite long uptime.
Without this the following error emerges:

File: ./dat_14M.img
umount: /mnt/tmp-ums-test: device is busy.
 (In some cases useful info about processes that use
  the device is found by lsof(8) or fuser(1))
TX: md5sum:083d3d22b542d3ecba61b12d17e03f9f
mount: /dev/sdd6 already mounted or /mnt/tmp-ums-test busy
mount: according to mtab, /dev/sdd6 is already mounted on /mnt/tmp-ums-test


Reviewed-by: Stephen Warren swar...@nvidia.com

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] test: ums: Add sleep before unmount directory

2014-11-07 Thread Marek Vasut
On Friday, November 07, 2014 at 02:05:55 PM, Lukasz Majewski wrote:
 This change helps to run script on machines with quite long uptime.
 Without this the following error emerges:
 
 File: ./dat_14M.img
 umount: /mnt/tmp-ums-test: device is busy.
 (In some cases useful info about processes that use
  the device is found by lsof(8) or fuser(1))
 TX: md5sum:083d3d22b542d3ecba61b12d17e03f9f
 mount: /dev/sdd6 already mounted or /mnt/tmp-ums-test busy
 mount: according to mtab, /dev/sdd6 is already mounted on /mnt/tmp-ums-test
 
 Signed-off-by: Lukasz Majewski l.majew...@samsung.com

Why exactly does mount not block until it can unmount the device anyway ?

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] test: ums: Add sleep before unmount directory

2014-11-07 Thread Lukasz Majewski
Hi Marek,

 On Friday, November 07, 2014 at 02:05:55 PM, Lukasz Majewski wrote:
  This change helps to run script on machines with quite long uptime.
  Without this the following error emerges:
  
  File: ./dat_14M.img
  umount: /mnt/tmp-ums-test: device is busy.
  (In some cases useful info about processes that use
   the device is found by lsof(8) or fuser(1))
  TX: md5sum:083d3d22b542d3ecba61b12d17e03f9f
  mount: /dev/sdd6 already mounted or /mnt/tmp-ums-test busy
  mount: according to mtab, /dev/sdd6 is already mounted
  on /mnt/tmp-ums-test
  
  Signed-off-by: Lukasz Majewski l.majew...@samsung.com
 
 Why exactly does mount not block until it can unmount the device
 anyway ?

Has mount or umount expose any blocking behavior? 

As fair as I remember you cannot umount directory when any process
holds reference to it.

Here it looks like process which copy data queues data for writing and
exit from cp.

Presumably, when we call umount there is still some pending data for
write.

Hence the error.

Maybe there is a switch for mount/umount/cp which can correct such
behavior?


 
 Best regards,
 Marek Vasut


-- 
Best regards,

Lukasz Majewski

Samsung RD Institute Poland (SRPOL) | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] test: ums: Add sleep before unmount directory

2014-11-07 Thread Marek Vasut
On Friday, November 07, 2014 at 05:52:27 PM, Lukasz Majewski wrote:
 Hi Marek,
 
  On Friday, November 07, 2014 at 02:05:55 PM, Lukasz Majewski wrote:
   This change helps to run script on machines with quite long uptime.
   Without this the following error emerges:
   
   File: ./dat_14M.img
   umount: /mnt/tmp-ums-test: device is busy.
   
   (In some cases useful info about processes that use
   
the device is found by lsof(8) or fuser(1))
   
   TX: md5sum:083d3d22b542d3ecba61b12d17e03f9f
   mount: /dev/sdd6 already mounted or /mnt/tmp-ums-test busy
   mount: according to mtab, /dev/sdd6 is already mounted
   on /mnt/tmp-ums-test
   
   Signed-off-by: Lukasz Majewski l.majew...@samsung.com
  
  Why exactly does mount not block until it can unmount the device
  anyway ?
 
 Has mount or umount expose any blocking behavior?

I would expect umount to be blocking by default in the first place.
ie. umount /mnt/foo should wait until all data are synced on device
under /mnt/foo and only then it should be unmounted.

Can you check (with strace or something) what exact return value will
the umount() syscall return when it does NOT unmount the mountpoint
and returns to the shell ? Is it EBUSY ?

 As fair as I remember you cannot umount directory when any process
 holds reference to it.

 Here it looks like process which copy data queues data for writing and
 exit from cp.
 
 Presumably, when we call umount there is still some pending data for
 write.
 
 Hence the error.

In case there are data which are not yet sync'd to the device, the umount() 
syscall should block until those data are written and return only after that.
Why would it return -EBUSY ... hm ...

 Maybe there is a switch for mount/umount/cp which can correct such
 behavior?

That should be the default ...

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] test: ums: Add sleep before unmount directory

2014-11-07 Thread Wolfgang Denk
Dear Lukasz,

In message 141536-9790-1-git-send-email-l.majew...@samsung.com you wrote:

 -umount $MNT_DIR
  
 +while true; do
 + umount $MNT_DIR  /dev/null 21
 + 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.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk  Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
If the hours are long enough and the pay  is  short  enough,  someone
will say it's women's work.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] test: ums: Add sleep before unmount directory

2014-11-07 Thread Stephen Warren

On 11/07/2014 02:54 PM, Wolfgang Denk wrote:

Dear Lukasz,

In message 141536-9790-1-git-send-email-l.majew...@samsung.com you wrote:


-umount $MNT_DIR

+while true; do
+   umount $MNT_DIR  /dev/null 21
+   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:-)

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] test: ums: Add sleep before unmount directory

2014-11-07 Thread Wolfgang Denk
Dear Stephen,

In message 545d40e1.2030...@wwwdotorg.org you wrote:

  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:-)

But this is a bug.  Papering over is not a good idea.  It should be
analyzed, reported, and finally fixed.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk  Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
Our management frequently gets lost in thought.   That's because it's
unfamiliar territory.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot