Here is the new supermount. It is almost complete rewrite; the reason
was some fundamental design problems in old supermount impementation.

The patch is against 2.4.21-0.11mdk but it should apply to current
9.1 kernel; it may work with 9.0 but is not tested. Older version of
this patch is included in Danny's mm kernel. supermount.txt and
changelog are attached separately for review.

User visible changes:

  - fs=.. option now takes list of filesystem types like fs=ext2:vfat.
    Using "auto" gave large delay sometimes (specifically for floppy).

  - device usage count is correctly managed now for all devices that
    implement mediactl (cdrom, sd and ide-floppy as of this writing;
    ide-floppy is untested). It means, supermount will respect when
    device is opened by some other task and won't unlock it. Also,
    when device is locked neither manual (eject button) nor program
    (eject /dev/cdrom) eject are possible. It does not work well for
    sd unfortunately.

  - device is now locked on any directory access not only on file open.

  - new option no_tray_lock. It is intended for ro media to overcome
    problems with such programs like Konqueror that constantly poll
    directory for changes thus blocking any eject possibility.

    (It is possible to lock device only on rw operations. Suggestions
    are welcome).

  - procfs support. Supermount creates following files under
    /proc/fs/supermount:

      version (ro)
        reading it gives version of supermount

      subfs (rw)
        reading it gives status of subfs; writing it allows you to
        unmount and/or disable subfs preventing any attempt to mount
        it. Intended usage is

          - mkfs/fsck/CD burning when you need to make sure nothing
            disrupts operation

          - hot-unplugging support, allowing to disable any access to
            media before physically removing it.

        See supermount.txt for detailed description.

  - atime management. It is believed that atime is now correctly
    updated. "noatime" option is respected.

  - supermount will refuse to double-mount device even if kernel
    supports it.

  - it is impossible to mount over supermounted directory (i.e.
    mount /dev/hdb /mnt/cdrom/foo fails). It is too complicated
    to handle and I do not see any need to do it.

  - immutable, noatime and append flags should be handled correctly
    now. Before it was possible to overwrite immutable file (mostly
    of interest for ext2 filesystem).

Internal changes

  - it is possible to unmount subfs at any time now

  - it is ensured that subfs cannot be unmounted while some object
    (dentry or inode) are being used. Together it makes it safe w.r.t.
    media removal.

  - directly call subfs methods instead of calling VFS recursively. It
    obsoletes most of the old supermount kernel patch making it more
    likely to be accepted :)

  - many assertions that hopefully catch any error as soon as possible

Many other changes that remove dead code.

This version includes all features I intended to add. Now I need
testing and your suggestion :) Unfortunately the detailed description
of supermount internals is still missing :(

Here is the current TODO:

dcache - actually just lookup_one_len in supermount_lookup. This may
mean assertion in d_iput/d_release is no more true, needs add. check

implement missing methods (super.c in the first place)

simplify Juan's patch. Remove all VFS patches; clean up media check.

check for non-exisiting device in __supermount_check_disk_change to
allow supermount hot-pluggable media

quota support (vollstaendigkeits halber :)

fix all FIXME :)


enjoy

-andrey


Attachment: 2.4.21-0.11.patch.gz
Description: application/gzip

Attachment: changelog
Description: Binary data

Supermount README
=================

Running supermount
------------------

To run supermount, compile and install a kernel with the supermount
patches and select "Y" to the question

        Supermount removable media support (CONFIG_SUPERMOUNT) [Y/n/?] 

when you run "make config".  You set up a supermount filesystem with
the normal mount command, using the syntax:

        mount -t supermount -o <superfs-options>,--,<subfs-options> none <mpt>

where

        <superfs-options> are the options you want to pass to supermount
        itself.  These are described below.

        <subfs-options> are the options you want supermount to pass to the
        dismountable filesystem underneath.

        <mpt> is the mount point where you want your removable media to be
        mounted. 

Notice that you do not directly specify the block device you are going
to mount on the mount command line.  This is because the supermount
filesystem is NOT connected to a block device; rather, supermount is
responsible for connecting a separate filesystem to the block device.
You specify the sub-filesystem and block device name by providing the
<superfs-options> field, where the following options are currently
recognised:


* fs=<filesystem-type>                  [default is "auto"]

        Specify the subfilesystem type. Not every filesystem type has
been tested.  If you use `auto', it will try the following filesystems
in order:
                        "udf"
                        "iso9660"
                        "ext2"
                        "vfat"
                        "msdos"

It is also possible to give list of types separated by `:', like

                fs=ext2:vfat
                    - or -
                fs=udf:iso9660
 

* dev=<block-device>

        Specify the block device on which the subfs is to be mounted.


* no_tray_lock

        Do not lock device tray during access to media. This allows to
eject media at any time, even if some task hung accessing it. It is
probably bad idea to use it for rw media.


* debug[=<bitmap>]

        Enable debugging code in the supermount filesystem, if
the debug option was enabled at compile time.  By default, debugging
code is compiled into the kernel but is disabled until a debug mount
option is seen. <bitmap> is the combination of debug flags, following
flags are possible:

        0x001 - "generic" debug (used by supermount_debug) - default
        0x002 - trace dentry.c
        0x004 - trace file.c
        0x008 - trace filemap.c
        0x010 - trace mediactl.c
        0x020 - trace namei.c
        0x040 - trace subfs.c
        0x080 - trace super.c

Trace flags turn on tracing of functions in correpsonding files.
"Generic" debug flag is tested in supermount_debug; for compatibility,
if no flags are specified, this flag is set.


* '--'

        All options after the option string '--' will be passed
directly to the subfilesystem when it gets mounted.

Errors
------

In addition to "normal" errors during file operations supermount may
return following error codes:

* No medium found

        You attempt to access supermounted filesystem when there is no
medium inserted

* Stale NFS file handle

        You attempt to use file handle after medium has been changed.

* No such device or address

        (Not really generated by supermount) device specified in
dev=<device> option does not exist. Also some drivers return this
error instead of "No medium found", one example being floppy driver.

* Device or resource busy

        (Not really generated by supermount) device is already mounted.
Supermount prevents double mount even if kernel otherwise would make it
possible.

* No such file or directory

        (Not really generated by supermount) file name specified by
dev=<device> option does not exist

* Operation not permitted

        You attempt to access subfs that is currently disabled

/proc support
-------------

If kernel has been compiled with procfs support, supermount will provide
/proc interface to read subfs status and to control some aspects of subfs.
The following files are created under /proc/fs/supermount:

* version (ro)
        Shows supermount version.

* subfs (rw)

        Reading this file returns list of all subfs status. One line for
every subfs is returned; the format is
        
        <devname> disabled
                - or -
        <devname> unmounted
                - or -
        <devname> mounted accesscount writecount

where <devname> is the string passed in `dev=' parameter during mount.
`accesscount' is number of current subfs "users"; `writecount' is the
number of "users" needing rw mode. It is mostly the number of open
files, but inode operations also add to these counts. Those operations
are normally short-lived to be seen.

        Writing this file changes subfs status; the following commands are
suported:

        <devname> [disable|enable] [release [force]]

`disable' will disable subfs (i.e. any futher attempt to mount is rejected).
Subfs must be unmounted; use `disable release' or `disable release force' to
unmount and disable at the same time.

`enable' will enable disabled subfs, it has no effect if subfs is already
enabled.

`release' will unmount subfs unless it is busy (opencount > 0). To unmount
busy subfs add `force'; the effect is very much as if media change has been
detected (with the difference that subfs will be cleanly unmounted).

Some basic sanity checks are performed, i.e. it is impossible to specify
both `enable' and `disable' or `force' without `release'.

Internals/Locking
-----------------

THIS SECTION IS PROBABLY INCOMPLETE. CORRECTIONS ARE WELCOME.

Supermount itself is using two locks and relies on two more locking rules
as implemented by kernel.

* supermount_proc_sem

        Global mutex used to protect list of sbi during access to
/proc/fs/supermount/subfs

* sbi->sem

        Per-filesystem mutex that protects subfs state (mounted/unmounted).
Any changes to subfs state (mounting, unmouting, adding or removing file,
dentry or inode) happen under this mutex.

* inode->i_sem (see Documentation/filesystem/Locking)

        Per-inode mutex used by VFS to serialize inode unlink operation.
Supermount relies on the fact that link/unlink for an inode are mutually
locked and thus inode->i_nlink is atomic inside of fs method.

* BKL

        Used to protect device usage count. It is changed in open/release
and referenced in ioctl all of which run under BKL. Supermount adds mediactl
and internally wraps it in BKL as well.

$Id: supermount.txt,v 1.10 2003/03/30 16:38:01 bor Exp $

Reply via email to