09 Oct, 2008

9 commits

  • disk->__part used to be statically allocated to the maximum possible
    number of partitions. This patch makes partition array allocation
    dynamic. The added overhead is minimal as only real change is one
    memory dereference changed to RCU one. This saves both a bit of
    memory and cpu cycles iterating through unoccupied slots and makes
    increasing partition limit easier.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jens Axboe

    Tejun Heo
     
  • genhd and partition code handled disk and partitions separately. All
    information about the whole disk was in struct genhd and partitions in
    struct hd_struct. However, the whole disk (part0) and other
    partitions have a lot in common and the data structures end up having
    good number of common fields and thus separate code paths doing the
    same thing. Also, the partition array was indexed by partno - 1 which
    gets pretty confusing at times.

    This patch introduces partition 0 and makes the partition array
    indexed by partno. Following patches will unify the handling of disk
    and parts piece-by-piece.

    This patch also implements disk_partitionable() which tests whether a
    disk is partitionable. With coming dynamic partition array change,
    the most common usage of disk_max_parts() will be testing whether a
    disk is partitionable and the number of max partitions will become
    much less important.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jens Axboe

    Tejun Heo
     
  • disk->part[] is protected by its matching bdev's lock. However,
    non-critical accesses like collecting stats and printing out sysfs and
    proc information used to be performed without any locking. As
    partitions can come and go dynamically, partitions can go away
    underneath those non-critical accesses. As some of those accesses are
    writes, this theoretically can lead to silent corruption.

    This patch fixes the race by using RCU for the partition array and dev
    reference counter to hold partitions.

    * Rename disk->part[] to disk->__part[] to make sure no one outside
    genhd layer proper accesses it directly.

    * Use RCU for disk->__part[] dereferencing.

    * Implement disk_{get|put}_part() which can be used to get and put
    partitions from gendisk respectively.

    * Iterators are implemented to help iterate through all partitions
    safely.

    * Functions which require RCU readlock are marked with _rcu suffix.

    * Use disk_put_part() in __blkdev_put() instead of directly putting
    the contained kobject.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jens Axboe

    Tejun Heo
     
  • * Implement disk_devt() and part_devt() and use them to directly
    access devt instead of computing it from ->major and ->first_minor.

    Note that all references to ->major and ->first_minor outside of
    block layer is used to determine devt of the disk (the part0) and as
    ->major and ->first_minor will continue to represent devt for the
    disk, converting these users aren't strictly necessary. However,
    convert them for consistency.

    * Implement disk_max_parts() to avoid directly deferencing
    genhd->minors.

    * Update bdget_disk() such that it doesn't assume consecutive minor
    space.

    * Move devt computation from register_disk() to add_disk() and make it
    the only one (all other usages use the initially determined value).

    These changes clean up the code and will help disk->part dereference
    fix and extended block device numbers.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jens Axboe

    Tejun Heo
     
  • In hd_struct, @partno is used to denote partition number and a number
    of other places use @part to denote hd_struct. Functions use @part
    and @index instead. This causes confusion and makes it difficult to
    use consistent variable names for hd_struct. Always use @partno if a
    variable represents partition number.

    Also, print out functions use @f or @part for seq_file argument. Use
    @seqf uniformly instead.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jens Axboe

    Tejun Heo
     
  • d805dda4 tried to fix error case handling in add_partition() but had a
    few problems.

    * disk->part[] entry is set early and left dangling if operation
    fails.

    * Once device initialized, the last put_device() is responsible for
    freeing all the resources. The failure path freed part_stats and p
    regardless of put_device() causing double free.

    * holders subdir holds reference to the disk device, so failure path
    should remove it to release resources properly which was missing.

    This patch fixes the above problems and while at it move partition
    slot busy check into add_partition() for completeness and inlines
    holders subdirectory creation. Using separate function for it just
    obfuscates the code.

    Signed-off-by: Tejun Heo
    Cc: Abdel Benamrouche
    Signed-off-by: Jens Axboe

    Tejun Heo
     
  • delete_partition() was noop for zero length partition. As the
    addition code allows creating zero lenght partition and deletion is
    assumed to always succeed, this causes memory leak for zero length
    partitions. Allow zero length partitions to end their meaningless
    lives.

    While at it, allow deleting zero lenght partition via
    BLKPG_DEL_PARTITION ioctl too.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jens Axboe

    Tejun Heo
     
  • But blkdev_issue_discard() still emits requests which are interpreted as
    soft barriers, because naïve callers might otherwise issue subsequent
    writes to those same sectors, which might cross on the queue (if they're
    reallocated quickly enough).

    Callers still _can_ issue non-barrier discard requests, but they have to
    take care of queue ordering for themselves.

    Signed-off-by: David Woodhouse
    Signed-off-by: Jens Axboe

    David Woodhouse
     
  • We may well want mkfs tools to use this to mark the whole device as
    unwanted before they format it, for example.

    The ioctl takes a pair of uint64_ts, which are start offset and length
    in _bytes_. Although at the moment it might make sense for them both to
    be in 512-byte sectors, I don't want to limit the ABI to that.

    Signed-off-by: David Woodhouse
    Signed-off-by: Jens Axboe

    David Woodhouse
     

26 Jul, 2008

1 commit


10 Oct, 2007

1 commit


08 May, 2007

1 commit

  • Remove the destroy_dirty_buffers argument from invalidate_bdev(), it hasn't
    been used in 6 years (so akpm says).

    find * -name \*.[ch] | xargs grep -l invalidate_bdev |
    while read file; do
    quilt add $file;
    sed -ie 's/invalidate_bdev(\([^,]*\),[^)]*)/invalidate_bdev(\1)/g' $file;
    done

    Signed-off-by: Peter Zijlstra
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Peter Zijlstra
     

21 Feb, 2007

1 commit

  • >=============================================
    >[ INFO: possible recursive locking detected ]
    >2.6.19-1.2909.fc7 #1
    >---------------------------------------------
    >anaconda/587 is trying to acquire lock:
    > (&bdev->bd_mutex){--..}, at: [] mutex_lock+0x21/0x24
    >
    >but task is already holding lock:
    > (&bdev->bd_mutex){--..}, at: [] mutex_lock+0x21/0x24
    >
    >other info that might help us debug this:
    >1 lock held by anaconda/587:
    > #0: (&bdev->bd_mutex){--..}, at: [] mutex_lock+0x21/0x24
    >
    >stack backtrace:
    > [] show_trace_log_lvl+0x1a/0x2f
    > [] show_trace+0x12/0x14
    > [] dump_stack+0x16/0x18
    > [] __lock_acquire+0x116/0xa09
    > [] lock_acquire+0x56/0x6f
    > [] __mutex_lock_slowpath+0xe5/0x24a
    > [] mutex_lock+0x21/0x24
    > [] blkdev_ioctl+0x600/0x76d
    > [] block_ioctl+0x1b/0x1f
    > [] do_ioctl+0x22/0x68
    > [] vfs_ioctl+0x252/0x265
    > [] sys_ioctl+0x49/0x63
    > [] syscall_call+0x7/0xb

    Annotate BLKPG_DEL_PARTITION's bd_mutex locking and add a little comment
    clarifying the bd_mutex locking, because I confused myself and initially
    thought the lock order was wrong too.

    Signed-off-by: Peter Zijlstra
    Cc: Neil Brown
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Peter Zijlstra
     

11 Feb, 2007

1 commit

  • Some partitioning systems create special partitions that
    span the entire disk. One example are Sun partitions, and
    this whole-disk partition exists to tell the firmware the
    extent of the entire device so it can load the boot block
    and do other things.

    Such partitions should not be treated as normal partitions,
    because all the other partitions overlap this whole-disk one.
    So we'd see multiple instances of the same UUID etc. which
    we do not want. udev and friends can thus search for this
    'whole_disk' attribute and use it to decide to ignore the
    partition.

    Signed-off-by: Fabio Massimo Di Nitto
    Signed-off-by: David S. Miller

    Fabio Massimo Di Nitto
     

09 Dec, 2006

2 commits


03 Oct, 2006

1 commit

  • Export blkdev_driver_ioctl for device-mapper.

    If we get as far as the device-mapper ioctl handler, we know the ioctl is not
    a standard block layer BLK* one, so we don't need to check for them a second
    time and can call blkdev_driver_ioctl() directly.

    Signed-off-by: Alasdair G Kergon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alasdair G Kergon
     

15 Jul, 2006

1 commit


24 Mar, 2006

1 commit


23 Mar, 2006

1 commit

  • Semaphore to mutex conversion.

    The conversion was generated via scripts, and the result was validated
    automatically via a script as well.

    Signed-off-by: Arjan van de Ven
    Signed-off-by: Ingo Molnar
    Acked-by: Jens Axboe
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arjan van de Ven
     

12 Jan, 2006

1 commit

  • - Move capable() from sched.h to capability.h;

    - Use where capable() is used
    (in include/, block/, ipc/, kernel/, a few drivers/,
    mm/, security/, & sound/;
    many more drivers/ to go)

    Signed-off-by: Randy Dunlap
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy.Dunlap
     

09 Jan, 2006

1 commit

  • HDIO_GETGEO is implemented in most block drivers, and all of them have to
    duplicate the code to copy the structure to userspace, as well as getting
    the start sector. This patch moves that to common code [1] and adds a
    ->getgeo method to fill out the raw kernel hd_geometry structure. For many
    drivers this means ->ioctl can go away now.

    [1] the s390 block drivers are odd in this respect. xpram sets ->start
    to 4 always which seems more than odd, and the dasd driver shifts
    the start offset around, probably because of it's non-standard
    sector size.

    Signed-off-by: Christoph Hellwig
    Cc: Jens Axboe
    Cc:
    Cc: Jeff Dike
    Cc: Paolo Giarrusso
    Cc: Bartlomiej Zolnierkiewicz
    Cc: Neil Brown
    Cc: Markus Lidel
    Cc: Russell King
    Cc: David Woodhouse
    Cc: Martin Schwidefsky
    Cc: James Bottomley
    Signed-off-by: Adrian Bunk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Hellwig
     

04 Nov, 2005

1 commit