24 Sep, 2020

1 commit


10 Sep, 2020

1 commit

  • ide-gd is only using the disk events mechanism to be able to force an
    invalidation and partition scan on opening removable media. Just open
    code the logic without invoving the block layer.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Johannes Thumshirn
    Reviewed-by: Hannes Reinecke
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

25 Feb, 2020

1 commit

  • Arnd Bergmann inadvertently typoed these in d320a9551e394 and 64cbfa96551a;
    they seem to be the cause of
    https://bugzilla.redhat.com/show_bug.cgi?id=1801353 , invalid SCSI commands
    when udev tries to query a DVD drive.

    [arnd] Found another instance of the same bug, also introduced in my
    compat_ioctl series.

    Link: https://bugzilla.redhat.com/show_bug.cgi?id=1801353
    Link: https://lore.kernel.org/r/20200219165139.3467320-1-arnd@arndb.de
    Fixes: c103d6ee69f9 ("compat_ioctl: ide: floppy: add handler")
    Fixes: 64cbfa96551a ("compat_ioctl: move cdrom commands into cdrom.c")
    Fixes: d320a9551e39 ("compat_ioctl: scsi: move ioctl handling into drivers")
    Bisected-by: Chris Murphy
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Adam Williamson
    Signed-off-by: Martin K. Petersen

    Adam Williamson
     

03 Jan, 2020

1 commit


21 May, 2019

1 commit

  • Add SPDX license identifiers to all files which:

    - Have no license information of any form

    - Have MODULE_LICENCE("GPL*") inside which was used in the initial
    scan/conversion to ignore the file

    These files fall under the project license, GPL v2 only. The resulting SPDX
    license identifier is:

    GPL-2.0-only

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

    Thomas Gleixner
     

13 Apr, 2019

1 commit

  • This reverts commit 7eec77a1816a7042591a6cbdb4820e9e7ebffe0e.

    Instead of leaving disk->events completely empty, we now export the
    supported events again, and tell the block layer not to forward events
    to user space by not setting DISK_EVENT_FLAG_UEVENT. This allows the
    block layer to distinguish between devices that for which events should
    be handled in kernel only, and devices which don't support any meda
    change events at all.

    Cc: Borislav Petkov
    Reviewed-by: Hannes Reinecke
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Martin Wilck
    Signed-off-by: Jens Axboe

    Martin Wilck
     

28 Sep, 2018

1 commit

  • Update device_add_disk() to take an 'groups' argument so that
    individual drivers can register a device with additional sysfs
    attributes.
    This avoids race condition the driver would otherwise have if these
    groups were to be created with sysfs_add_groups().

    Signed-off-by: Martin Wilck
    Signed-off-by: Hannes Reinecke
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Bart Van Assche
    Signed-off-by: Jens Axboe

    Hannes Reinecke
     

28 Jun, 2016

1 commit

  • For block drivers that specify a parent device, convert them to use
    device_add_disk().

    This conversion was done with the following semantic patch:

    @@
    struct gendisk *disk;
    expression E;
    @@

    - disk->driverfs_dev = E;
    ...
    - add_disk(disk);
    + device_add_disk(E, disk);

    @@
    struct gendisk *disk;
    expression E1, E2;
    @@

    - disk->driverfs_dev = E1;
    ...
    E2 = disk;
    ...
    - add_disk(E2);
    + device_add_disk(E1, E2);

    ...plus some manual fixups for a few missed conversions.

    Cc: Jens Axboe
    Cc: Keith Busch
    Cc: Michael S. Tsirkin
    Cc: David Woodhouse
    Cc: David S. Miller
    Cc: James Bottomley
    Cc: Ross Zwisler
    Cc: Konrad Rzeszutek Wilk
    Cc: Martin K. Petersen
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Johannes Thumshirn
    Signed-off-by: Dan Williams

    Dan Williams
     

04 Jul, 2013

1 commit

  • Calling dev_set_name with a single paramter causes it to be handled as a
    format string. Many callers are passing potentially dynamic string
    content, so use "%s" in those cases to avoid any potential accidents,
    including wrappers like device_create*() and bdi_register().

    Signed-off-by: Kees Cook
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kees Cook
     

07 May, 2013

1 commit


22 Apr, 2011

1 commit

  • check_events() implementations in both ide-gd and ide-cd are
    inadequate for in-kernel event polling. Both generate media change
    events continuously when certain conditions are met causing infinite
    event loop between the driver and userland event handler.

    As disk event now supports suppression of unlisted events, simply
    de-listing DISK_EVENT_MEDIA_CHANGE from disk->events resolves the
    problem. Internal handling around media revalidation will behave the
    same while userland will fall back to userland event polling after
    detecting the device doesn't support disk events.

    Signed-off-by: Tejun Heo
    Reported-by: Jens Axboe
    Acked-by: "David S. Miller"
    Signed-off-by: Jens Axboe

    Tejun Heo
     

10 Mar, 2011

1 commit

  • Convert ->media_changed() to the new ->check_events() method. The
    conversion is mostly mechanical. The only notable change is that
    cdrom now doesn't generate any event if @slot_nr isn't CDSL_CURRENT.
    It used to return -EINVAL which would be treated as media changed. As
    media changer isn't supported anyway, this doesn't make any
    difference.

    This makes ide emit the standard disk events and allows kernel event
    polling. Currently, only MEDIA_CHANGE event is implemented. Adding
    support for EJECT_REQUEST shouldn't be difficult; however, given that
    ide driver is already deprecated, it probably is best to leave it
    alone.

    Signed-off-by: Tejun Heo
    Acked-by: Jens Axboe
    Cc: Kay Sievers
    Cc: "David S. Miller"
    Cc: linux-ide@vger.kernel.org

    Tejun Heo
     

05 Oct, 2010

1 commit

  • The block device drivers have all gained new lock_kernel
    calls from a recent pushdown, and some of the drivers
    were already using the BKL before.

    This turns the BKL into a set of per-driver mutexes.
    Still need to check whether this is safe to do.

    file=$1
    name=$2
    if grep -q lock_kernel ${file} ; then
    if grep -q 'include.*linux.mutex.h' ${file} ; then
    sed -i '/include.*/d' ${file}
    else
    sed -i 's/include.*.*$/include /g' ${file}
    fi
    sed -i ${file} \
    -e "/^#include.*linux.mutex.h/,$ {
    1,/^\(static\|int\|long\)/ {
    /^\(static\|int\|long\)/istatic DEFINE_MUTEX(${name}_mutex);

    } }" \
    -e "s/\(un\)*lock_kernel\>[ ]*()/mutex_\1lock(\&${name}_mutex)/g" \
    -e '/[ ]*cycle_kernel_lock();/d'
    else
    sed -i -e '/include.*\/d' ${file} \
    -e '/cycle_kernel_lock()/d'
    fi

    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     

11 Aug, 2010

1 commit

  • * 'for-2.6.36' of git://git.kernel.dk/linux-2.6-block: (149 commits)
    block: make sure that REQ_* types are seen even with CONFIG_BLOCK=n
    xen-blkfront: fix missing out label
    blkdev: fix blkdev_issue_zeroout return value
    block: update request stacking methods to support discards
    block: fix missing export of blk_types.h
    writeback: fix bad _bh spinlock nesting
    drbd: revert "delay probes", feature is being re-implemented differently
    drbd: Initialize all members of sync_conf to their defaults [Bugz 315]
    drbd: Disable delay probes for the upcomming release
    writeback: cleanup bdi_register
    writeback: add new tracepoints
    writeback: remove unnecessary init_timer call
    writeback: optimize periodic bdi thread wakeups
    writeback: prevent unnecessary bdi threads wakeups
    writeback: move bdi threads exiting logic to the forker thread
    writeback: restructure bdi forker loop a little
    writeback: move last_active to bdi
    writeback: do not remove bdi from bdi_list
    writeback: simplify bdi code a little
    writeback: do not lose wake-ups in bdi threads
    ...

    Fixed up pretty trivial conflicts in drivers/block/virtio_blk.c and
    drivers/scsi/scsi_error.c as per Jens.

    Linus Torvalds
     

08 Aug, 2010

2 commits

  • The open and release block_device_operations are currently
    called with the BKL held. In order to change that, we must
    first make sure that all drivers that currently rely
    on this have no regressions.

    This blindly pushes the BKL into all .open and .release
    operations for all block drivers to prepare for the
    next step. The drivers can subsequently replace the BKL
    with their own locks or remove it completely when it can
    be shown that it is not needed.

    The functions blkdev_get and blkdev_put are the only
    remaining users of the big kernel lock in the block
    layer, besides a few uses in the ioctl code, none
    of which need to serialize with blkdev_{get,put}.

    Most of these two functions is also under the protection
    of bdev->bd_mutex, including the actual calls to
    ->open and ->release, and the common code does not
    access any global data structures that need the BKL.

    Signed-off-by: Arnd Bergmann
    Acked-by: Christoph Hellwig
    Signed-off-by: Jens Axboe

    Arnd Bergmann
     
  • As a preparation for the removal of the big kernel
    lock in the block layer, this removes the BKL
    from the common ioctl handling code, moving it
    into every single driver still using it.

    Signed-off-by: Arnd Bergmann
    Acked-by: Christoph Hellwig
    Signed-off-by: Jens Axboe

    Arnd Bergmann
     

17 Jun, 2010

2 commits


22 May, 2010

1 commit

  • bdops->set_capacity() is unnecessarily generic. All that's required
    is a simple one way notification to lower level driver telling it to
    try to unlock native capacity. There's no reason to pass in target
    capacity or return the new capacity. The former is always the
    inherent native capacity and the latter can be handled via the usual
    device resize / revalidation path. In fact, the current API is always
    used that way.

    Replace ->set_capacity() with ->unlock_native_capacity() which take
    only @disk and doesn't return anything. IDE which is the only current
    user of the API is converted accordingly.

    Signed-off-by: Tejun Heo
    Cc: Ben Hutchings
    Cc: Bartlomiej Zolnierkiewicz
    Acked-by: David S. Miller
    Signed-off-by: Jens Axboe

    Tejun Heo
     

30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

22 Sep, 2009

1 commit


07 Jun, 2009

1 commit

  • * Use ->probed_capacity to store native device capacity for ATA disks.

    * Add ->set_capacity method to struct ide_disk_ops.

    * Implement disk device ->set_capacity method for ATA disks.

    * Implement block device ->set_capacity method.

    v2:
    * Check if LBA and HPA are supported in ide_disk_set_capacity().

    * According to the spec the SET MAX ADDRESS command shall be
    immediately preceded by a READ NATIVE MAX ADDRESS command.

    * Add ide_disk_hpa_{get_native,set}_capacity() helpers.

    Together with the previous patch adding ->set_capacity block device
    method this allows automatic disabling of Host Protected Area (HPA)
    if any partitions overlapping HPA are detected.

    Cc: Robert Hancock
    Cc: Frans Pop
    Cc: "Andries E. Brouwer"
    Cc: Al Viro
    Emphatically-Acked-by: Alan Cox
    Signed-off-by: Bartlomiej Zolnierkiewicz

    Bartlomiej Zolnierkiewicz
     

23 Apr, 2009

1 commit


27 Mar, 2009

2 commits


26 Feb, 2009

1 commit

  • During host driver module removal del_gendisk() results in a final
    put on drive->gendev and freeing the drive by drive_release_dev().

    Convert device drivers from using struct kref to use struct device
    so device driver's object holds reference on ->gendev and prevents
    drive from prematurely going away.

    Also fix ->remove methods to not erroneously drop reference on a
    host driver by using only put_device() instead of ide*_put().

    Reported-by: Stanislaw Gruszka
    Tested-by: Stanislaw Gruszka
    Signed-off-by: Bartlomiej Zolnierkiewicz

    Bartlomiej Zolnierkiewicz
     

07 Jan, 2009

2 commits


03 Nov, 2008

1 commit


21 Oct, 2008

5 commits


18 Oct, 2008

4 commits

  • * Add struct ide_disk_ops containing protocol specific methods.

    * Add 'struct ide_disk_ops *' to ide_drive_t.

    * Convert ide-{disk,floppy} drivers to use struct ide_disk_ops.

    * Merge ide-{disk,floppy} drivers into generic ide-gd driver.

    While at it:
    - ide_disk_init_capacity() -> ide_disk_get_capacity()

    Acked-by: Borislav Petkov
    Signed-off-by: Bartlomiej Zolnierkiewicz

    Bartlomiej Zolnierkiewicz
     
  • Turn ide_driver_t's 'proc' field into ->proc_entries method
    (and also 'settings' field into ->proc_devsets method). Then
    update all device drivers accordingly.

    There should be no functional changes caused by this patch.

    Acked-by: Borislav Petkov
    Signed-off-by: Bartlomiej Zolnierkiewicz

    Bartlomiej Zolnierkiewicz
     
  • Set IDE_DFLAG_MEDIA_CHANGED in ide_gd_open() to signalize
    ide_gd_media_changed() that that media has changed (instead
    of relying on IDE_DFLAG_REMOVABLE).

    There should be no functional changes caused by this patch.

    Acked-by: Borislav Petkov
    Signed-off-by: Bartlomiej Zolnierkiewicz

    Bartlomiej Zolnierkiewicz
     
  • While at it:
    - IDEDISK_VERSION -> IDE_GD_VERSION
    - ide_cacheflush_p() -> ide_disk_flush()
    - init_idedisk_capacity() -> ide_disk_init_capacity()
    - idedisk_set_doorlock() -> ide_disk_set_doorlock()
    - idedisk_setup() -> ide_disk_setup()

    - ide_disk_capacity() -> ide_gd_capacity()
    - ide_disk_remove() -> ide_gd_remove()
    - ide_disk_probe() -> ide_gd_probe()
    - ide_disk_resume() -> ide_gd_resume()
    - ide_device_shutdown() -> ide_gd_shutdown()
    - idedisk_driver -> ide_gd_driver
    - idedisk_open() -> ide_gd_open()
    - idedisk_release() -> ide_gd_release()
    - idedisk_getgeo() -> ide_gd_getgeo()
    - idedisk_media_changed() -> ide_gd_media_changed()
    - idedisk_revalidate_disk() -> ide_gd_revalidate_disk()
    - idedisk_ops -> ide_gd_ops
    - idedisk_init() -> ide_gd_init()
    - idedisk_exit() -> ide_gd_exit()

    There should be no functional changes caused by this patch.

    Acked-by: Borislav Petkov
    Signed-off-by: Bartlomiej Zolnierkiewicz

    Bartlomiej Zolnierkiewicz