16 Sep, 2009

1 commit


14 Sep, 2009

1 commit

  • Currently, there is a single in_flight counter measuring the number of
    requests in the request_queue. But some monitoring tools would like to
    know how many read requests and write requests are in progress. Split the
    current in_flight counter into two seperate counters for read and write.

    This information is exported as a sysfs attribute, as changing the
    currently available stat files would break the existing tools.

    Signed-off-by: Nikanth Karthikesan
    Signed-off-by: Jens Axboe

    Nikanth Karthikesan
     

11 Sep, 2009

1 commit


16 Jun, 2009

1 commit


23 May, 2009

1 commit

  • To support devices with physical block sizes bigger than 512 bytes we
    need to ensure proper alignment. This patch adds support for exposing
    I/O topology characteristics as devices are stacked.

    logical_block_size is the smallest unit the device can address.

    physical_block_size indicates the smallest I/O the device can write
    without incurring a read-modify-write penalty.

    The io_min parameter is the smallest preferred I/O size reported by
    the device. In many cases this is the same as the physical block
    size. However, the io_min parameter can be scaled up when stacking
    (RAID5 chunk size > physical block size).

    The io_opt characteristic indicates the optimal I/O size reported by
    the device. This is usually the stripe width for arrays.

    The alignment_offset parameter indicates the number of bytes the start
    of the device/partition is offset from the device's natural alignment.
    Partition tools and MD/DM utilities can use this to pad their offsets
    so filesystems start on proper boundaries.

    Signed-off-by: Martin K. Petersen
    Signed-off-by: Jens Axboe

    Martin K. Petersen
     

22 Apr, 2009

1 commit

  • /proc/diskstats used to show stats for all disks whether they're
    zero-sized or not and their non-zero partitions. Commit
    074a7aca7afa6f230104e8e65eba3420263714a5 accidentally changed the
    behavior such that it doesn't print out zero sized disks. This patch
    implements DISK_PITER_INCL_EMPTY_PART0 flag to partition iterator and
    uses it in diskstats_show() such that empty part0 is shown in
    /proc/diskstats.

    Reported and bisectd by Dianel Collins.

    Signed-off-by: Tejun Heo
    Reported-by: Daniel Collins
    Signed-off-by: Jens Axboe

    Tejun Heo
     

26 Feb, 2009

1 commit


18 Feb, 2009

1 commit

  • Hi Tejun,

    it looks like your commit:

    block: don't depend on consecutive minor space
    f331c0296f2a9fee0d396a70598b954062603015

    broke a particular case for booting from partitioned md/raid devices.
    That is the second time this has been broken recently. The previous
    time was fixed by

    block: do_mounts - accept root=
    30f2f0eb4bd2c43d10a8b0d872c6e5ad8f31c9a0

    Because the data isn't available when an md device is first created
    (we add disks and set it up after creation), the initial partition
    scan finds nothing. It is not until the device is opened that
    another partition scan happens and finds something.

    So at the point where the kernel parameter "root=/dev/md_d0p1" is
    being parsed, md_d0 exists, but md_d0p1 does not.
    However if we let blk_lookup_devt return the correct device number
    even though the device doesn't exist, then the attempt to mount it
    will successfully find the partition.

    I have tried in the past to find a way to get the partition table to
    be read as soon as the array is assembled but that proved impossible
    (at the time). I don't remember the details, and could possibly
    revisit it. However it would be really nice if blk_lookup_devt
    could be adjusted to again accept non existant partitions.

    Signed-off-by: Jens Axboe

    Neil Brown
     

07 Jan, 2009

1 commit


29 Dec, 2008

1 commit

  • disk_map_sector_rcu() returns a partition from a sector offset,
    which we use for IO statistics on a per-partition basis. The
    lookup itself is an O(N) list lookup, where N is the number of
    partitions. This actually hurts performance quite a bit, even
    on the lower end partitions. On higher numbered partitions,
    it can get pretty bad.

    Solve this by adding a one-hit cache for partition lookup.
    This makes the lookup O(1) for the case where we do most IO to
    one partition. Even for mixed partition workloads, amortized cost
    is pretty close to O(1) since the natural IO batching makes the
    one-hit cache last for lots of IOs.

    Signed-off-by: Jens Axboe

    Jens Axboe
     

03 Dec, 2008

1 commit


18 Nov, 2008

1 commit

  • We run into system boot failure with kernel 2.6.28-rc. We found it on a
    couple of machines, including T61 notebook, nehalem machine, and another
    HPC NX6325 notebook. All the machines use FedoraCore 8 or FedoraCore 9.
    With kernel prior to 2.6.28-rc, system boot doesn't fail.

    I debug it and locate the root cause. Pls. see
    http://bugzilla.kernel.org/show_bug.cgi?id=11899
    https://bugzilla.redhat.com/show_bug.cgi?id=471517

    As a matter of fact, there are 2 bugs.

    1)root=/dev/sda1, system boot randomly fails. Mostly, boot for 5 times
    and fails once. nash has a bug. Some of its functions misuse return
    value 0. Sometimes, 0 means timeout and no uevent available. Sometimes,
    0 means nash gets an uevent, but the uevent isn't block-related (for
    exmaple, usb). If by coincidence, kernel tells nash that uevents are
    available, but kernel also set timeout, nash might stops collecting
    other uevents in queue if current uevent isn't block-related. I work
    out a patch for nash to fix it.
    http://bugzilla.kernel.org/attachment.cgi?id=18858

    2) root=LABEL=/, system always can't boot. initrd init reports
    switchroot fails. Here is an executation branch of nash when booting:
    (1) nash read /sys/block/sda/dev; Assume major is 8 (on my desktop)
    (2) nash query /proc/devices with the major number; It found line
    "8 sd";
    (3) nash use 'sd' to search its own probe table to find device (DISK)
    type for the device and add it to its own list;
    (4) Later on, it probes all devices in its list to get filesystem
    labels; scsi register "8 sd" always.

    When major is 259, nash fails to find the device(DISK) type. I enables
    CONFIG_DEBUG_BLOCK_EXT_DEVT=y when compiling kernel, so 259 is picked up
    for device /dev/sda1, which causes nash to fail to find device (DISK)
    type.

    To fixing issue 2), I create a patch for nash and another patch for
    kernel.

    http://bugzilla.kernel.org/attachment.cgi?id=18859
    http://bugzilla.kernel.org/attachment.cgi?id=18837

    Below is the patch for kernel 2.6.28-rc4. It registers blkext, a new
    block device in proc/devices.

    With 2 patches on nash and 1 patch on kernel, I boot my machines for
    dozens of times without failure.

    Signed-off-by Zhang Yanmin
    Acked-by: Tejun Heo
    Signed-off-by: Jens Axboe

    Zhang, Yanmin
     

23 Oct, 2008

2 commits


17 Oct, 2008

2 commits

  • Fix block kernel-doc warnings:

    Warning(linux-2.6.27-git4//fs/block_dev.c:1272): No description found for parameter 'path'
    Warning(linux-2.6.27-git4//block/blk-core.c:1021): No description found for parameter 'cpu'
    Warning(linux-2.6.27-git4//block/blk-core.c:1021): No description found for parameter 'part'
    Warning(/var/linsrc/linux-2.6.27-git4//block/genhd.c:544): No description found for parameter 'partno'

    Signed-off-by: Randy Dunlap
    Signed-off-by: Jens Axboe

    Randy Dunlap
     
  • No argument 'gfp_mask' for blk_alloc_devt().

    Signed-off-by: Li Zefan
    Signed-off-by: Jens Axboe

    Li Zefan
     

09 Oct, 2008

24 commits

  • Only works for the generic request timer handling. Allows one to
    sporadically ignore request completions, thus exercising the timeout
    handling.

    Signed-off-by: Jens Axboe

    Jens Axboe
     
  • seqf can be started multiple times for a read and the header should be
    printed only for the initial one. Fix it.

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

    Tejun Heo
     
  • bdget_disk() and blk_lookup_devt() never cared whether the specified
    partition (or disk) is zero sized or not. I got confused while
    converting those not to depend on consecutive minor numbers in commit
    5a6411b1178baf534aa9138052864dfa89d3eada and later when dev0 was added
    it broke callers which expected to get valid return for zero sized
    disk devices.

    So, they never needed nr_sects checks in the first place. Kill them.

    This problem was spotted and debugged by Bartlmoiej Zolnierkiewicz.

    Signed-off-by: Tejun Heo
    Cc: Bartlomiej Zolnierkiewicz
    Signed-off-by: Jens Axboe

    Tejun Heo
     
  • Noticed by sparse:
    block/blk-softirq.c:156:12: warning: symbol 'blk_softirq_init' was not declared. Should it be static?
    block/genhd.c:583:28: warning: function 'bdget_disk' with external linkage has definition
    block/genhd.c:659:17: warning: incorrect type in argument 1 (different base types)
    block/genhd.c:659:17: expected unsigned int [unsigned] [usertype] size
    block/genhd.c:659:17: got restricted gfp_t
    block/genhd.c:659:29: warning: incorrect type in argument 2 (different base types)
    block/genhd.c:659:29: expected restricted gfp_t [usertype] flags
    block/genhd.c:659:29: got unsigned int
    block: kmalloc args reversed

    Signed-off-by: Harvey Harrison
    Signed-off-by: Jens Axboe

    Harvey Harrison
     
  • Now that disk and partition handlings are mostly unified, it's easy to
    allow disk to have extended device number. This patch makes
    add_disk() use extended device number if disk->minors is zero. Both
    sd and ide-disk are updated to use this.

    * sd_format_disk_name() is implemented which can generically determine
    the drive name. This removes disk number restriction stemming from
    limited device names.

    * If sd index goes over SD_MAX_DISKS (which can be increased now BTW),
    sd simply doesn't initialize minors letting block layer choose
    extended device number.

    * If CONFIG_DEBUG_EXT_DEVT is set, both sd and ide-disk always set
    minors to 0 and use extended device numbers.

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

    Tejun Heo
     
  • With previous changes, it's meaningless to limit the number of
    partitions. Replace @ext_minors with GENHD_FL_EXT_DEVT such that
    setting the flag allows the disk to have maximum number of allowed
    partitions (only limited by the number of entries in parsed_partitions
    as determined by MAX_PART constant).

    This kills not-too-pretty alloc_disk_ext[_node]() functions and makes
    @minors parameter to alloc_disk[_node]() unnecessary. The parameter
    is left alone to avoid disturbing the users.

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

    Tejun Heo
     
  • 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
     
  • Move stats related fields - stamp, in_flight, dkstats - from disk to
    part0 and unify stat handling such that...

    * part_stat_*() now updates part0 together if the specified partition
    is not part0. ie. part_stat_*() are now essentially all_stat_*().

    * {disk|all}_stat_*() are gone.

    * part_round_stats() is updated similary. It handles part0 stats
    automatically and disk_round_stats() is killed.

    * part_{inc|dec}_in_fligh() is implemented which automatically updates
    part0 stats for parts other than part0.

    * disk_map_sector_rcu() is updated to return part0 if no part matches.
    Combined with the above changes, this makes NULL special case
    handling in callers unnecessary.

    * Separate stats show code paths for disk are collapsed into part
    stats show code paths.

    * Rename disk_stat_lock/unlock() to part_stat_lock/unlock()

    While at it, reposition stat handling macros a bit and add missing
    parentheses around macro parameters.

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

    Tejun Heo
     
  • GENHD_FL_FAIL for disk is what make_it_fail is for parts. Kill it and
    use part0->make_it_fail. Sysfs node handling is unified too.

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

    Tejun Heo
     
  • Move disk->policy to part0->policy. Implement and use get_disk_ro().

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

    Tejun Heo
     
  • Now that capacity and __dev are moved to part0, part0 and others can
    share the same method.

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

    Tejun Heo
     
  • Move disk->__dev to part0->__dev. This simplifies bdget_disk() and
    lookup_devt() and allows common sysfs attributes to be unified.
    part_to_disk() is updated to handle part0 -> disk.

    Updated to include a fix from Bartlomiej Zolnierkiewicz ,
    he writes:

    "part0 is a "special" partition and doesn't need to have capacity set - this
    fixes regression caused by "block: move __dev from disk to part0" commit."

    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
     
  • Implement {disk|part}_to_dev() and use them to access generic device
    instead of directly dereferencing {disk|part}->dev. To make sure no
    user is left behind, rename generic devices fields to __dev.

    This is in preparation of unifying partition 0 handling with other
    partitions.

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

    Tejun Heo
     
  • Extended devt introduces non-contiguos device numbers. This patch
    implements a debug option which forces most devt allocations to be
    from the extended area and spreads them out. This is enabled by
    default if DEBUG_KERNEL is set and achieves...

    1. Detects code paths in kernel or userland which expect predetermined
    consecutive device numbers.

    2. When something goes wrong, avoid corruption as adding to the minor
    of earlier partition won't lead to the wrong but valid device.

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

    Tejun Heo
     
  • With extended minors and the soon-to-follow debug feature, large minor
    numbers for block devices will be common. This patch does the
    followings to make printouts pretty.

    * Adapt print formats such that large minors don't break the
    formatting.

    * For extended MAJ:MIN, %02x%02x for MAJ:MIN used in
    printk_all_partitions() doesn't cut it anymore. Update it such that
    %03x:%05x is used if either MAJ or MIN doesn't fit in %02x.

    * Implement ext_range sysfs attribute which shows total minors the
    device can use including both conventional minor space and the
    extended one.

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

    Tejun Heo
     
  • Implement extended device numbers. A block driver can tell block
    layer that it wants to use extended device numbers. After the usual
    minor space is used up, block layer automatically allocates devt's
    from EXT_BLOCK_MAJOR.

    Currently only one major number is allocated for this but as the
    allocation is strictly on-demand, ~1mil minor space under it should
    suffice unless the system actually has more than ~1mil partitions and
    if that ever happens adding more majors to the extended devt area is
    easy.

    Due to internal implementation issues, the first partition can't be
    allocated on the extended area. In other words, genhd->minors should
    at least be 1. This limitation will be lifted by later changes.

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

    Tejun Heo
     
  • There are two variants of stat functions - ones prefixed with double
    underbars which don't care about preemption and ones without which
    disable preemption before manipulating per-cpu counters. It's unclear
    whether the underbarred ones assume that preemtion is disabled on
    entry as some callers don't do that.

    This patch unifies diskstats access by implementing disk_stat_lock()
    and disk_stat_unlock() which take care of both RCU (for partition
    access) and preemption (for per-cpu counter access). diskstats access
    should always be enclosed between the two functions. As such, there's
    no need for the versions which disables preemption. They're removed
    and double underbars ones are renamed to drop the underbars. As an
    extra argument is added, there's no danger of using the old version
    unconverted.

    disk_stat_lock() uses get_cpu() and returns the cpu index and all
    diskstat functions which access per-cpu counters now has @cpu
    argument to help RT.

    This change adds RCU or preemption operations at some places but also
    collapses several preemption ops into one at others. Overall, the
    performance difference should be negligible as all involved ops are
    very lightweight per-cpu ones.

    Signed-off-by: Tejun Heo
    Cc: Peter Zijlstra
    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
     
  • This patch makes the following misc updates in preparation for
    disk->part dereference fix and extended block devt support.

    * implment part_to_disk()

    * fix comment about gendisk->part indexing

    * rename get_part() to disk_map_sector()

    * don't use n which is always zero while printing disk information in
    diskstats_show()

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

    Tejun Heo
     
  • Recent block_class iteration updates 5c6f35c5..27f3025 converted all
    class device iteration to class_for_each_device() and
    class_find_device(), which are correct but pain in the ass to use.
    This pach converts them to newly introduced class_dev_iterator so that
    they can use more natural control structures instead of separate
    callbacks and struct to pass parameters to them.

    This results in smaller and easier code.

    This patch also restores the original behavior of not printing header
    in /proc/partitions if there's no partition to print. This is trivial
    but still user-visible behavior.

    Signed-off-by: Tejun Heo
    Cc: Greg Kroah-Hartman
    Signed-off-by: Jens Axboe

    Tejun Heo
     
  • block_class_lock protects major_names array and bdev_map and doesn't
    have anything to do with block class devices. Don't grab them while
    iterating over block class devices.

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

    Tejun Heo