Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Sep 2004 10:49:27 -0700 (PDT)
From:      Joseph Davida <jd10008@yahoo.com>
To:        User Jhs <jhs@flat.berklix.net>, freebsd-mobile@freebsd.org
Cc:        Christopher Sean Hilton <chris@vindaloo.com>
Subject:   Re: How to get usbd to umount fle systems without crashing ? 
Message-ID:  <20040920174927.74067.qmail@web42302.mail.yahoo.com>
In-Reply-To: <200409201650.i8KGoGLF002731@laps.jhs.private>

next in thread | previous in thread | raw e-mail | index | archive | help
For these devices (memory sticks), a new
option to mount is needed.
Currently the default mount is
noasync. From mount(8) man page:
noasync
        Metadata I/O should be done synchronously,
        while data I/O should be done asynchronously.
        This is the default.

What we need is an option like "noasynchdata"
or "synchdata" to force all IO (data and metadata)
to be synchronous to these USB memory sticks.
This will enable us to hot unplug a memory stick
and the OS should automatically unmount
the device (I dont know if automatic umount
is currently implemented).

Cheers,

Joe

--- User Jhs <jhs@flat.berklix.net> wrote:

> Re. my question on mount & dismount of memory sticks:
> Thanks to all (Hank, Brooks, Chris, (hope I missed no one)),
> 	( Chris's examples were particularly useful in
>         	Message-id: <20040914155115.GB13849@dantooine.vindaloo.com> )
> 
> > You want to use the automounter for this. The reason it's dying is
> > because FreeBSD is trying to write information (dirty buffers) back to
> > the filesystem after the device has disappeared. The correct sequence
> > for this would be umount the filesystem, then unplug the device.
> 
> Yes. After I posted, I added to the options list in /etc/fstab ",sync"
> & checked with tunefs -p that soft updates were disabled on the USB
> memory stick (they already were). It didnt help. I'm not suprised
> FreeBSD crashes when a write mounted partition is removed, but it's
> sad something mounted read only crashes. Read mounted fd0: floppies dont
> crash immediately when removed (fortunately no usbd killing devs there).
> 
> > I'm not sure if the portmapper is relevent.
> 
> I recall AMD or NFS wants it.  On my other FreeBSD-4 hosts using
> NFS, portmapper is not neeeded in my rc.conf, as it gets started
> automaticaly.  In a stand alone laptop with no net, not running NFS
> one would still want AMD, so I've set     rpcbind_enable="YES" in case.
> 
> 
> I have 2 problems still, (with 2 configs as below):
>   - The 2nd mount in attach line fails (see comment in usbd.conf below).
>         Maybe some USB kernel problem that might go away when I upgrade
>         from { 5.2-CURRENT built from src/ day or 2 before Sep  3. }
>         to 5.2-stable or 5.3-Rel. ?
>   - AMD fails to unmount USB devices, (but does unmount cdrom OK eg this
> works:
>         cd /host/cdrom;ls;cd /; sleep 20;mount |grep cdrom      )
> Comments requested.
>   
> 1st Config: of /etc/ usbd.conf fstab amd.map rc.conf
>   {
>   usbd.conf:
>     {
>     device      "jhs Memory stick Celldisk Pro. IOCELL - M-Systems"
>         vendor  0x08ec
>         product 0x0834
>         release 0x0100
>         attach "sleep 2 ; mount -r /dev.dummy/usb.0 ; mkdir
> /.amd_mnt/usb.ufs.0 ; mount /.amd_mnt/usb.ufs.0; mkdir /.amd_mnt/usb.dos.0 ;
> mount /.amd_mnt/usb.dos.0"
>         # Sleep: proven necessary.
>         # Mkdir: if already run at previous insertions (inc. boot with memory
> 
>         #       stick in place) will fail subsequently as already exists
>         #       (unless amd removes unused directories) so mkdirs are 
>         #       seperated in case it aborts on first pre-existing when 2nd
>         #       still needed.
>         # Mount: 2nd always fails, regardless which is 1st & 2nd.
>         #       typical error message even if done manually after: 
>         #                msdosfs: /dev/da0s1: Operation not permitted.
>         # Umount: should be done by amd, not by detach, as it crashes system.
>         #       (after detach of usb stick there is no device to umount).
>         # detach        "umount /stick.bsd; umount /stick.dos"
>         # devname       "umass0"
>     }     
>   fstab:
>     {
>     /dev/da0          /dev.dummy/usb.0        msdos   ro,noauto 0 0
>     # da[01] to enable a probe to initiate automatic creation of
> da[[01]s[1-4].
>     /dev/da0s1        /.amd_mnt/usb.dos.0     msdos   rw,noauto         0 0
>     /dev/da0s2a       /.amd_mnt/usb.ufs.0     ufs     rw,noatime,noauto 0 0
>     }
>   amd.map:
>     {
>     /defaults       type:=host;fs:=${autodir}/${rhost};rhost:=${key}
>     laps            type:=link;fs:=..
>     *       opts:=rw,grpid,resvport,vers=2,proto=udp,nodev
>     cdrom   type:=cdfs;fs:=${autodir}/${key};dev:=/dev/acd0;addopts:=ro,rrip 
>     /.amd_mnt/usb.dos.0       type:=program;fs:=${autodir}/${key};\
>         mount:="/sbin/mount mount ${fs}";unmount:="/sbin/umount umount ${fs}"
>     /.amd_mnt/usb.ufs.0       type:=program;fs:=${autodir}/${key};\
>         mount:="/sbin/mount mount ${fs}";unmount:="/sbin/umount umount ${fs}"
>      }
>   rc.conf:
>     {
>     rpcbind_enable="YES" # No by default, Replaces portmap_enable.
>     usbd_enable="YES"
>     amd_enable="YES"
>     amd_flags="-c 30 -l syslog -n -r -t 3 -w 12 /host /etc/amd.map"
>     #       "-c 30" reduce name caching from default 300 sec.
>     #       "-n" map /host/user to /.amd_mnt/flip
>     #       "-r" inherit existing mounts (eg from USB insertion)
>     #       "-t3" used to be a bit slow see amd.map
>     #       "-w 12" dismount default is 120 seconds
>     #       Frequent scans for unmount for memory stick to avoid crash.
>     #       chris@vindaloo.c__ uses "-c 30" but not "-w 12".
>     }
>   }
> 2nd Config: of /etc/ usbd.conf fstab amd.map rc.conf
>   { As above, except to try to debug the amd umount failure:
>   {
>   usbd.conf:
>     {
>         attach "sleep 2 ; mount -r /dev.dummy/usb.0 ; mkdir /usb.ufs.0 ;
> mount /usb.ufs.0; mkdir /usb.dos.0 ; mount /usb.dos.0"
>     }
>   fstab:
>     {
>     /dev/da0s1      /usb.dos.0              msdos   rw,noauto         0 0
>     /dev/da0s2a     /usb.ufs.0              ufs     rw,noatime,noauto 0 0
>     }
>   amd.map:
>     {
>     usb.dos.0 
> type:=msdos;fs:=${autodir}/${key};dev:=/dev/da0s1;addopts:=sync
>     usb.ufs.0  type:=ufs;fs:=${autodir}/${key};dev:=/dev/da0s2a;addopts:=sync
>     }
>   }
> 
> -
> Julian Stacey.  Unix,C,Net & Sys. Eng. Consultant, Munich. 
> http://berklix.com
> Mail in Ascii, Html dumped as Spam.  Ihr Rauch = mein allergischer
> Kopfschmerz.
> _______________________________________________
> freebsd-mobile@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-mobile
> To unsubscribe, send any mail to "freebsd-mobile-unsubscribe@freebsd.org"
> 



		
__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040920174927.74067.qmail>