Re: [PATCH 2] introduce-mass-storage-arbitration.patch

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

 



On Tue, 22 Dec 2009, Andy Green wrote:

> From: Andy Green <andy.green@xxxxxxxx>
> 
> Cc: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
> Cc: Linux USB list <linux-usb@xxxxxxxxxxxxxxx>
> 
> This patch adds support for arbitrating backing storage access between
> the gadget mass storage driver and userspace.
> 
> The functionality it provides allows userspace to keep a shared partition
> mounted all the time except when the partition is being accessed by a host.
> When the host "ejects" the logical storage device, userspace is informed and
> able to automatically mount it again.  The user can replug the storage to
> repeat the arbitration and make it visible on the host again.  So
> availability of the filesystem being shared is maximized for the device
> automatically.
> 
> When the host starts trying to access the backing storage, the patch issues
> a netlink packet of the kernel uevent variety many systems already watch for
> battery power_supply management.  The userspace netlink handler code should
> respond by unmounting the shared storage if possible, and writing to the
> /sys path provided in DEVPATH in the netlink message to indicate that the
> arbitration succeeded or failed.  This is the same kind of handshake seen
> in the kernel firmware API.
> 
> Additionally, when the host performs an "eject", the patch sees it and
> notifies userspace again by netlink that it's safe to remount the shared
> partition.

After some more thought I'm not so sure this is such a good idea.

It makes sense to add a mechanism for notifying userspace when the host
ejects the medium.  You don't need a uevent to do that; a simple
sysfs_notify() on the "file" attribute would be enough.

There doesn't seem to be any reason for the whole arbitration thing.  
Instead of waiting for the host to access the medium, why not simply
umount the shared partition as soon as the medium is loaded?  Hosts
typically do periodic scans for new media; you'd lose only a second or
thereabouts.

To help keep things uniform, another sysfs_notify() could be done when
a new medium is loaded.  Even that shouldn't really be needed -- what
reason is there to notify userspace about a load event when the event
was caused by userspace in the first place?

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