16 Mar, 2007

2 commits

  • This patch (as869) reinstates the mutual exclusion between sysfs
    attribute method calls and attribute unregistration. The
    previously-reported deadlocks have been fixed, and this exclusion is
    by far the simplest way to avoid races during driver unbinding.

    The check for orphaned read-buffers has been moved down slightly, so
    that the remainder of a partially-read buffer will still be available
    to userspace even after the attribute has been unregistered.

    Signed-off-by: Alan Stern
    Cc: Hugh Dickins
    Cc: Cornelia Huck
    Cc: Oliver Neukum
    Signed-off-by: Linus Torvalds

    Alan Stern
     
  • This patch (as868) adds a helper routine for device drivers that need
    to set up a callback to perform some action in a different process's
    context. This is intended for use by attribute methods that want to
    unregister themselves or their parent device. Attribute method calls
    are mutually exclusive with unregistration, so such actions cannot be
    taken directly.

    Two attribute methods are converted to use the new helper routine: one
    for SCSI device deletion and one for System/390 ccwgroup devices.

    Signed-off-by: Alan Stern
    Cc: Hugh Dickins
    Cc: Cornelia Huck
    Cc: Oliver Neukum
    Signed-off-by: Linus Torvalds

    Alan Stern
     

07 Mar, 2007

2 commits

  • Suspend deadlocks when trying to unregister /sys/block/sr0.

    This comes from Oliver's commit 94bebf4d1b8e7719f0f3944c037a21cfd99a4af7
    "Driver core: fix race in sysfs between sysfs_remove_file() and
    read()/write()".

    sysfs_write_file downs buffer->sem while calling flush_write_buffer, and
    flushing that particular write buffer entails downing buffer->sem in
    orphan_all_buffers, resulting in the obvious self-deadlock.

    Signed-off-by: Linus Torvalds

    Hugh Dickins
     
  • Any attempt to open/use a bluetooth rfcomm device locks up
    scheduling completely on my machine.

    Interrupts (ping, alt-sysrq) seem to be alive, but nothing else.

    This was working fine in 2.6.20, broken now in 2.6.21-rc2-git*

    Reverting this change (below) fixes it:

    | author Marcel Holtmann
    | Sat, 17 Feb 2007 22:58:57 +0000 (23:58 +0100)
    | committer David S. Miller
    | Mon, 26 Feb 2007 19:42:41 +0000 (11:42 -0800)
    | commit c1a3313698895d8ad4760f98642007bf236af2e8
    | tree 337a876f727061362b6a169f8759849c105b8f7a tree | snapshot
    | parent f5ffd4620aba9e55656483ae1ef5c79ba81f5403 commit | diff
    | | [Bluetooth] Make use of device_move() for RFCOMM TTY devices
    | | In the case of bound RFCOMM TTY devices the parent is not available
    | before its usage. So when opening a RFCOMM TTY device, move it to
    | the corresponding ACL device as a child. When closing the device,
    | move it back to the virtual device tree.
    | Signed-off-by: Marcel Holtmann

    The simplest fix for this bug is to prevent sysfs_move_dir()
    from self-deadlocking when (old_parent == new_parent).

    This patch prevents total system lockup when using rfcomm devices.

    Signed-off-by: Mark Lord
    Acked-by: Cornelia Huck
    Cc: Greg KH
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mark Lord
     

27 Feb, 2007

1 commit

  • * master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6:
    Revert "Driver core: let request_module() send a /sys/modules/kmod/-uevent"
    Driver core: fix error by cleanup up symlinks properly
    make kernel/kmod.c:kmod_mk static
    power management: fix struct layout and docs
    power management: no valid states w/o pm_ops
    Driver core: more fallout from class_device changes for pcmcia
    sysfs: move struct sysfs_dirent to private header
    driver core: refcounting fix
    Driver core: remove class_device_rename

    Linus Torvalds
     

24 Feb, 2007

2 commits

  • This patch (as860) adds two new sysfs routines:
    sysfs_add_file_to_group() and sysfs_remove_file_from_group().
    A later patch adds code that uses the new routines.

    Signed-off-by: Alan Stern
    Cc: Maneesh Soni
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • struct sysfs_dirent is private to the fs/sysfs/ subtree. It is
    not even referenced as an opaque structure outside of that subtree.

    The following patch moves the declaration from include/linux/sysfs.h to
    fs/sysfs/sysfs.h, making it clearer that nothing else in the kernel
    dereferences it.

    I have been running this patch for years. Please integrate and forward
    upstream if there are no objections.

    From: "Adam J. Richter"
    Signed-off-by: Greg Kroah-Hartman

    Adam J. Richter
     

17 Feb, 2007

1 commit


13 Feb, 2007

2 commits

  • This patch is inspired by Arjan's "Patch series to mark struct
    file_operations and struct inode_operations const".

    Compile tested with gcc & sparse.

    Signed-off-by: Josef 'Jeff' Sipek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Josef 'Jeff' Sipek
     
  • Many struct inode_operations in the kernel can be "const". Marking them const
    moves these to the .rodata section, which avoids false sharing with potential
    dirty data. In addition it'll catch accidental writes at compile time to
    these shared resources.

    Signed-off-by: Arjan van de Ven
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arjan van de Ven
     

12 Feb, 2007

1 commit

  • Replace appropriate pairs of "kmem_cache_alloc()" + "memset(0)" with the
    corresponding "kmem_cache_zalloc()" call.

    Signed-off-by: Robert P. J. Day
    Cc: "Luck, Tony"
    Cc: Andi Kleen
    Cc: Roland McGrath
    Cc: James Bottomley
    Cc: Greg KH
    Acked-by: Joel Becker
    Cc: Steven Whitehouse
    Cc: Jan Kara
    Cc: Michael Halcrow
    Cc: "David S. Miller"
    Cc: Stephen Smalley
    Cc: James Morris
    Cc: Chris Wright
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Robert P. J. Day
     

08 Feb, 2007

6 commits

  • The problem. When implementing a network namespace I need to be able
    to have multiple network devices with the same name. Currently this
    is a problem for /sys/class/net/*.

    What I want is a separate /sys/class/net directory in sysfs for each
    network namespace, and I want to name each of them /sys/class/net.

    I looked and the VFS actually allows that. All that is needed is
    for /sys/class/net to implement a follow link method to redirect
    lookups to the real directory you want.

    Implementing a follow link method that is sensitive to the current
    network namespace turns out to be 3 lines of code so it looks like a
    clean approach. Modifying sysfs so it doesn't get in my was is a bit
    trickier.

    I am calling the concept of multiple directories all at the same path
    in the filesystem shadow directories. With the directory entry really
    at that location the shadow master.

    The following patch modifies sysfs so it can handle a directory
    structure slightly different from the kobject tree so I can implement
    the shadow directories for handling /sys/class/net/.

    Signed-off-by: Eric W. Biederman
    Cc: Maneesh Soni
    Signed-off-by: Greg Kroah-Hartman

    Eric W. Biederman
     
  • if a driver returns an error in fill_read_buffer(), the buffer will be
    marked as filled. Subsequent reads will return eof. But there is
    no data because of an error, not because it has been read.
    Not marking the buffer filled is the obvious fix.

    Signed-off-by: Oliver Neukum
    Signed-off-by: Greg Kroah-Hartman

    Oliver Neukum
     
  • This patch removes redundant argument checks for kobject_put().

    Signed-off-by: Mariusz Kozlowski
    Signed-off-by: Greg Kroah-Hartman

    Mariusz Kozlowski
     
  • Lockdep issues the following warning:
    [ 9.064000] =============================================
    [ 9.064000] [ INFO: possible recursive locking detected ]
    [ 9.064000] 2.6.20-rc3-mm1 #3
    [ 9.064000] ---------------------------------------------
    [ 9.064000] init/1 is trying to acquire lock:
    [ 9.064000] (&sysfs_inode_imutex_key){--..}, at: [] mutex_lock+0x1c/0x1f
    [ 9.064000]
    [ 9.064000] but task is already holding lock:
    [ 9.064000] (&sysfs_inode_imutex_key){--..}, at: [] mutex_lock+0x1c/0x1f
    [ 9.065000]
    [ 9.065000] other info that might help us debug this:
    [ 9.065000] 2 locks held by init/1:
    [ 9.065000] #0: (tty_mutex){--..}, at: [] mutex_lock+0x1c/0x1f
    [ 9.065000] #1: (&sysfs_inode_imutex_key){--..}, at: [] mutex_lock+0x1c/0x1f
    [ 9.065000]
    [ 9.065000] stack backtrace:
    [ 9.065000] [] show_trace_log_lvl+0x1a/0x30
    [ 9.066000] [] show_trace+0x12/0x14
    [ 9.066000] [] dump_stack+0x16/0x18
    [ 9.066000] [] print_deadlock_bug+0xb9/0xc3
    [ 9.066000] [] check_deadlock+0x55/0x5a
    [ 9.066000] [] __lock_acquire+0x371/0xbf0
    [ 9.066000] [] lock_acquire+0x69/0x83
    [ 9.066000] [] __mutex_lock_slowpath+0x75/0x2d1
    [ 9.066000] [] mutex_lock+0x1c/0x1f
    [ 9.066000] [] sysfs_drop_dentry+0xb1/0x133
    [ 9.066000] [] sysfs_hash_and_remove+0xb3/0x142
    [ 9.066000] [] sysfs_remove_file+0xd/0x10
    [ 9.067000] [] device_remove_file+0x23/0x2e
    [ 9.067000] [] device_del+0x188/0x1e6
    [ 9.067000] [] device_unregister+0xb/0x15
    [ 9.067000] [] device_destroy+0x9c/0xa9
    [ 9.067000] [] vcs_remove_sysfs+0x1c/0x3b
    [ 9.067000] [] con_close+0x5e/0x6b
    [ 9.067000] [] release_dev+0x4c4/0x6e5
    [ 9.067000] [] tty_release+0x12/0x1c
    [ 9.067000] [] __fput+0x177/0x1a0
    [ 9.067000] [] fput+0x3b/0x41
    [ 9.068000] [] filp_close+0x36/0x65
    [ 9.068000] [] sys_close+0x63/0xa4
    [ 9.068000] [] sysenter_past_esp+0x5f/0x99
    [ 9.068000] =======================

    This is due to sysfs_hash_and_remove() holding dir->d_inode->i_mutex
    before calling sysfs_drop_dentry() which calls orphan_all_buffers()
    which in turn takes node->i_mutex.

    Signed-off-by: Frederik Deweerdt
    Cc: Oliver Neukum
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    Frederik Deweerdt
     
  • This patch prevents a race between IO and removing a file from sysfs.
    It introduces a list of sysfs_buffers associated with a file at the inode.
    Upon removal of a file the list is walked and the buffers marked orphaned.
    IO to orphaned buffers fails with -ENODEV. The driver can safely free
    associated data structures or be unloaded.

    Signed-off-by: Oliver Neukum
    Acked-by: Maneesh Soni
    Signed-off-by: Greg Kroah-Hartman

    Oliver Neukum
     
  • If we allow NULL as the new parent in device_move(), we need to make sure
    that the device is placed into the same place as it would if it was
    newly registered:

    - Consider the device virtual tree. In order to be able to reuse code,
    setup_parent() has been tweaked a bit.
    - kobject_move() can fall back to the kset's kobject.
    - sysfs_move_dir() uses the sysfs root dir as fallback.

    Signed-off-by: Cornelia Huck
    Cc: Marcel Holtmann
    Signed-off-by: Greg Kroah-Hartman

    Cornelia Huck
     

09 Dec, 2006

1 commit


08 Dec, 2006

1 commit

  • Replace all uses of kmem_cache_t with struct kmem_cache.

    The patch was generated using the following script:

    #!/bin/sh
    #
    # Replace one string by another in all the kernel sources.
    #

    set -e

    for file in `find * -name "*.c" -o -name "*.h"|xargs grep -l $1`; do
    quilt add $file
    sed -e "1,\$s/$1/$2/g" $file >/tmp/$$
    mv /tmp/$$ $file
    quilt refresh
    done

    The script was run like this

    sh replace kmem_cache_t "struct kmem_cache"

    Signed-off-by: Christoph Lameter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Lameter
     

02 Dec, 2006

2 commits

  • Provide a function device_move() to move a device to a new parent device. Add
    auxilliary functions kobject_move() and sysfs_move_dir().
    kobject_move() generates a new uevent of type KOBJ_MOVE, containing the
    previous path (DEVPATH_OLD) in addition to the usual values. For this, a new
    interface kobject_uevent_env() is created that allows to add further
    environmental data to the uevent at the kobject layer.

    Signed-off-by: Cornelia Huck
    Acked-by: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Cornelia Huck
     
  • since most of the files in sysfs are text files,
    it would be nice, if the "store" function called
    during sysfs_write_file() gets a zero terminated
    string / data.
    The current implementation seems not to ensure this.
    (But only if it is the first time the zeroed buffer
    page is allocated.)

    So the buffer can be scanned by sscanf() easily,
    for example.

    This patch simply sets a \0 char behind the
    data in buffer->page.

    Signed-off-by: Thomas Maier
    Signed-off-by: Greg Kroah-Hartman

    Thomas Maier
     

19 Oct, 2006

2 commits

  • And the obsolete comment should be updated (or totally removed).

    Signed-off-by: Hidetoshi Seto
    Signed-off-by: Greg Kroah-Hartman

    Hidetoshi Seto
     
  • Following function can drops d_count twice against one reference
    by lookup_one_len.

    /**
    * sysfs_update_file - update the modified timestamp on an object attribute.
    * @kobj: object we're acting for.
    * @attr: attribute descriptor.
    */
    int sysfs_update_file(struct kobject * kobj, const struct attribute * attr)
    {
    struct dentry * dir = kobj->dentry;
    struct dentry * victim;
    int res = -ENOENT;

    mutex_lock(&dir->d_inode->i_mutex);
    victim = lookup_one_len(attr->name, dir, strlen(attr->name));
    if (!IS_ERR(victim)) {
    /* make sure dentry is really there */
    if (victim->d_inode &&
    (victim->d_parent->d_inode == dir->d_inode)) {
    victim->d_inode->i_mtime = CURRENT_TIME;
    fsnotify_modify(victim);

    /**
    * Drop reference from initial sysfs_get_dentry().
    */
    dput(victim);
    res = 0;
    } else
    d_drop(victim);

    /**
    * Drop the reference acquired from sysfs_get_dentry() above.
    */
    dput(victim);
    }
    mutex_unlock(&dir->d_inode->i_mutex);

    return res;
    }

    PCI-hotplug (drivers/pci/hotplug/pci_hotplug_core.c) is only user of
    this function. I confirmed that dentry of /sys/bus/pci/slots/XXX/*
    have negative d_count value.

    This patch removes unnecessary dput().

    Signed-off-by: Hidetoshi Seto
    Acked-by: Maneesh Soni
    Signed-off-by: Greg Kroah-Hartman

    Hidetoshi Seto
     

03 Oct, 2006

1 commit


01 Oct, 2006

1 commit


27 Sep, 2006

1 commit

  • This eliminates the i_blksize field from struct inode. Filesystems that want
    to provide a per-inode st_blksize can do so by providing their own getattr
    routine instead of using the generic_fillattr() function.

    Note that some filesystems were providing pretty much random (and incorrect)
    values for i_blksize.

    [bunk@stusta.de: cleanup]
    [akpm@osdl.org: generic_fillattr() fix]
    Signed-off-by: "Theodore Ts'o"
    Signed-off-by: Adrian Bunk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Theodore Ts'o
     

26 Sep, 2006

3 commits


13 Jul, 2006

1 commit

  • sysfs has a different i_mutex lock order behavior for i_mutex than the
    other filesystems; sysfs i_mutex is called in many places with subsystem
    locks held. At the same time, many of the VFS locking rules do not apply
    to sysfs at all (cross directory rename for example). To untangle this
    mess (which gives false positives in lockdep), we're giving sysfs inodes
    their own class for i_mutex.

    Signed-off-by: Arjan van de Ven
    Cc: Ingo Molnar
    Cc: Greg KH
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arjan van de Ven
     

29 Jun, 2006

1 commit


27 Jun, 2006

1 commit

  • This patch converts the combination of list_del(A) and list_add(A, B) to
    list_move(A, B).

    Cc: Greg Kroah-Hartman
    Cc: Ram Pai
    Signed-off-by: Akinobu Mita
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Akinobu Mita
     

23 Jun, 2006

1 commit

  • Extend the get_sb() filesystem operation to take an extra argument that
    permits the VFS to pass in the target vfsmount that defines the mountpoint.

    The filesystem is then required to manually set the superblock and root dentry
    pointers. For most filesystems, this should be done with simple_set_mnt()
    which will set the superblock pointer and then set the root dentry to the
    superblock's s_root (as per the old default behaviour).

    The get_sb() op now returns an integer as there's now no need to return the
    superblock pointer.

    This patch permits a superblock to be implicitly shared amongst several mount
    points, such as can be done with NFS to avoid potential inode aliasing. In
    such a case, simple_set_mnt() would not be called, and instead the mnt_root
    and mnt_sb would be set directly.

    The patch also makes the following changes:

    (*) the get_sb_*() convenience functions in the core kernel now take a vfsmount
    pointer argument and return an integer, so most filesystems have to change
    very little.

    (*) If one of the convenience function is not used, then get_sb() should
    normally call simple_set_mnt() to instantiate the vfsmount. This will
    always return 0, and so can be tail-called from get_sb().

    (*) generic_shutdown_super() now calls shrink_dcache_sb() to clean up the
    dcache upon superblock destruction rather than shrink_dcache_anon().

    This is required because the superblock may now have multiple trees that
    aren't actually bound to s_root, but that still need to be cleaned up. The
    currently called functions assume that the whole tree is rooted at s_root,
    and that anonymous dentries are not the roots of trees which results in
    dentries being left unculled.

    However, with the way NFS superblock sharing are currently set to be
    implemented, these assumptions are violated: the root of the filesystem is
    simply a dummy dentry and inode (the real inode for '/' may well be
    inaccessible), and all the vfsmounts are rooted on anonymous[*] dentries
    with child trees.

    [*] Anonymous until discovered from another tree.

    (*) The documentation has been adjusted, including the additional bit of
    changing ext2_* into foo_* in the documentation.

    [akpm@osdl.org: convert ipath_fs, do other stuff]
    Signed-off-by: David Howells
    Acked-by: Al Viro
    Cc: Nathan Scott
    Cc: Roland Dreier
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Howells
     

15 Apr, 2006

1 commit

  • It works like this:
    Open the file
    Read all the contents.
    Call poll requesting POLLERR or POLLPRI (so select/exceptfds works)
    When poll returns,
    close the file and go to top of loop.
    or lseek to start of file and go back to the 'read'.

    Events are signaled by an object manager calling
    sysfs_notify(kobj, dir, attr);

    If the dir is non-NULL, it is used to find a subdirectory which
    contains the attribute (presumably created by sysfs_create_group).

    This has a cost of one int per attribute, one wait_queuehead per kobject,
    one int per open file.

    The name "sysfs_notify" may be confused with the inotify
    functionality. Maybe it would be nice to support inotify for sysfs
    attributes as well?

    This patch also uses sysfs_notify to allow /sys/block/md*/md/sync_action
    to be pollable

    Signed-off-by: Neil Brown
    Signed-off-by: Greg Kroah-Hartman

    NeilBrown
     

03 Apr, 2006

1 commit


02 Apr, 2006

1 commit


01 Apr, 2006

1 commit


29 Mar, 2006

1 commit

  • This is a conversion to make the various file_operations structs in fs/
    const. Basically a regexp job, with a few manual fixups

    The goal is both to increase correctness (harder to accidentally write to
    shared datastructures) and reducing the false sharing of cachelines with
    things that get dirty in .data (while .rodata is nicely read only and thus
    cache clean)

    Signed-off-by: Arjan van de Ven
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arjan van de Ven
     

21 Mar, 2006

2 commits