Re: Enumeration not happening if device removed during file transfer

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

 



On Thu, 7 Jun 2012, megha dey wrote:

> SCENARIO:
> In host mode, I am trying to copy some files from the pendrive to the
> sdcard or vice-versa using the astro file manager.During the file
> transfer, if I disconnect the pendrive,and then reconnect it back,it
> is observed that re-enumeration is not taking place.

What version of the kernel are you using?

> ANALYSIS:
> From the stack trace,we see that there are 2 main threads involved:
> 1) usb-storage thread:
> When file transfer is in progress,the pendrive is removed.In this
> context,usb_sg_wait() function is waiting infinitely for the IO to
> complete (wait_for_completion(&io->complete)). Since the drive is
> removed,this wait never completes.

No, the wait should complete even after the drive is removed.  
Disconnect processing cancels all outstanding I/O operations.

> 2) khubd thread
> On disconnecting the pendrive, during the device delete operation,
> usb_stor_disconnect() function is called which is trying to release
> the storage resources and then tries to stop the usb-storage thread
> via kthread_stop().
> 
> The usb_storage thread is not listening on kthread_should_stop as it
> is waiting infinitely on usb_sg_wait(). Hence the hub thread is also
> blocked as it tries to stop the storage thread.
> 
> QUESTIONS:
> 1)Why is the wait_for_completion(&io->complete) not a timed wait? (*
> After adding a timeout of 5 seconds,this issue is no longer seen , the
> pendrive enumerates each time)

Because requests already are timed out by the block layer, and because 
disconnects should cause the request to be cancelled immediately.

> 2)If we do put a timed wait,what should be the ideal timeout value?

It should not be a timed wait.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux