1. 09 10月, 2008 13 次提交
    • T
      block: move holder_dir from disk to part0 · 4c46501d
      Tejun Heo 提交于
      Move disk->holder_dir to part0->holder_dir.  Kill now mostly
      superflous bdev_get_holder().
      
      While at it, kill superflous kobject_get/put() around holder_dir,
      slave_dir and cmd_filter creation and collapse
      disk_sysfs_add_subdirs() into register_disk().  These serve no purpose
      but obfuscating the code.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      4c46501d
    • T
      block: move policy from disk to part0 · b7db9956
      Tejun Heo 提交于
      Move disk->policy to part0->policy.  Implement and use get_disk_ro().
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      b7db9956
    • T
      block: unify sysfs size node handling · e5610521
      Tejun Heo 提交于
      Now that capacity and __dev are moved to part0, part0 and others can
      share the same method.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      e5610521
    • T
      block: move capacity from disk to part0 · 80795aef
      Tejun Heo 提交于
      Move disk->capacity to part0->nr_sects and convert all users who
      directly accessed the field to use {get|set}_capacity().  This is done
      early to allow the __dev field to be moved.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      80795aef
    • T
      block: introduce partition 0 · b5d0b9df
      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: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      b5d0b9df
    • T
      block: implement and use {disk|part}_to_dev() · ed9e1982
      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: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      ed9e1982
    • T
      block: implement extended dev numbers · bcce3de1
      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: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      bcce3de1
    • T
      block: fix diskstats access · c9959059
      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: NTejun Heo <tj@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      c9959059
    • T
      block: fix disk->part[] dereferencing race · e71bf0d0
      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: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      e71bf0d0
    • T
      block: don't depend on consecutive minor space · f331c029
      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: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      f331c029
    • T
      block: make variable and argument names more consistent · cf771cb5
      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: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      cf771cb5
    • T
      block: update add_partition() error handling · 88e34126
      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: NTejun Heo <tj@kernel.org>
      Cc: Abdel Benamrouche <draconux@gmail.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      88e34126
    • T
      block: allow deleting zero length partition · ec2cdedf
      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: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      ec2cdedf
  2. 14 9月, 2008 1 次提交
  3. 26 7月, 2008 2 次提交
  4. 22 7月, 2008 1 次提交
  5. 20 4月, 2008 1 次提交
  6. 08 2月, 2008 4 次提交
  7. 25 1月, 2008 4 次提交
    • G
      Kobject: convert fs/* from kobject_unregister() to kobject_put() · 197b12d6
      Greg Kroah-Hartman 提交于
      There is no need for kobject_unregister() anymore, thanks to Kay's
      kobject cleanup changes, so replace all instances of it with
      kobject_put().
      
      
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      197b12d6
    • K
      Driver core: convert block from raw kobjects to core devices · edfaa7c3
      Kay Sievers 提交于
      This moves the block devices to /sys/class/block. It will create a
      flat list of all block devices, with the disks and partitions in one
      directory. For compatibility /sys/block is created and contains symlinks
      to the disks.
      
        /sys/class/block
        |-- sda -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda
        |-- sda1 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1
        |-- sda10 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda10
        |-- sda5 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5
        |-- sda6 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6
        |-- sda7 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda7
        |-- sda8 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda8
        |-- sda9 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda9
        `-- sr0 -> ../../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr0
      
        /sys/block/
        |-- sda -> ../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda
        `-- sr0 -> ../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr0
      Signed-off-by: NKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      edfaa7c3
    • G
      kset: convert block_subsys to use kset_create · 830d3cfb
      Greg Kroah-Hartman 提交于
      Dynamically create the kset instead of declaring it statically.  We also
      rename block_subsys to block_kset to catch all users of this symbol
      with a build error instead of an easy-to-ignore build warning.
      
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      830d3cfb
    • G
      kobject: get rid of kobject_add_dir · 4ff6abff
      Greg Kroah-Hartman 提交于
      kobject_create_and_add is the same as kobject_add_dir, so drop
      kobject_add_dir.
      
      
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      4ff6abff
  8. 13 10月, 2007 1 次提交
  9. 20 7月, 2007 1 次提交
  10. 12 7月, 2007 1 次提交
    • T
      sysfs: kill unnecessary attribute->owner · 7b595756
      Tejun Heo 提交于
      sysfs is now completely out of driver/module lifetime game.  After
      deletion, a sysfs node doesn't access anything outside sysfs proper,
      so there's no reason to hold onto the attribute owners.  Note that
      often the wrong modules were accounted for as owners leading to
      accessing removed modules.
      
      This patch kills now unnecessary attribute->owner.  Note that with
      this change, userland holding a sysfs node does not prevent the
      backing module from being unloaded.
      
      For more info regarding lifetime rule cleanup, please read the
      following message.
      
        http://article.gmane.org/gmane.linux.kernel/510293
      
      (tweaked by Greg to not delete the field just yet, to make it easier to
      merge things properly.)
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      7b595756
  11. 09 5月, 2007 1 次提交
  12. 08 5月, 2007 1 次提交
  13. 03 5月, 2007 1 次提交
  14. 17 3月, 2007 1 次提交
  15. 08 3月, 2007 1 次提交
  16. 17 2月, 2007 1 次提交
  17. 11 2月, 2007 1 次提交
    • F
      [PARTITION]: Add whole_disk attribute. · d18d7682
      Fabio Massimo Di Nitto 提交于
      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: NFabio Massimo Di Nitto <fabbione@ubuntu.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d18d7682
  18. 09 12月, 2006 1 次提交
    • A
      [PATCH] fault-injection capability for disk IO · c17bb495
      Akinobu Mita 提交于
      This patch provides fault-injection capability for disk IO.
      
      Boot option:
      
      fail_make_request=<probability>,<interval>,<space>,<times>
      
      	<interval> -- specifies the interval of failures.
      
      	<probability> -- specifies how often it should fail in percent.
      
      	<space> -- specifies the size of free space where disk IO can be issued
      		   safely in bytes.
      
      	<times> -- specifies how many times failures may happen at most.
      
      Debugfs:
      
      /debug/fail_make_request/interval
      /debug/fail_make_request/probability
      /debug/fail_make_request/specifies
      /debug/fail_make_request/times
      
      Example:
      
      	fail_make_request=10,100,0,-1
      	echo 1 > /sys/blocks/hda/hda1/make-it-fail
      
      generic_make_request() on /dev/hda1 fails once per 10 times.
      
      Cc: Jens Axboe <axboe@suse.de>
      Signed-off-by: NAkinobu Mita <akinobu.mita@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      c17bb495
  19. 08 12月, 2006 2 次提交
    • S
      [PATCH] Fix check_partition routines · 57881dd9
      Suzuki K P 提交于
      check_partition() stops its probe once it hits an I/O error from the
      partition checkers.  This would prevent the actual partition checker
      getting a chance to verify the partition.
      
      So this patch lets check_partition() continue probing untill it hits a
      success while recording the I/O error which might have been reported by the
      checking routines.
      
      Also, it does some cleanup of the partition methods for ibm, atari and
      amiga to return -1 upon hitting an I/O error.
      Signed-off-by: NSuzuki K P <suzuki@in.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      57881dd9
    • S
      [PATCH] fix rescan_partitions to return errors properly · 5127d002
      Suzuki Kp 提交于
      The current rescan_partition implementation ignores the errors that comes from
      the lower layer.  It reports success for unknown partitions as well as I/O
      error cases while reading the partition information.
      
      The unknown partition is not (and will not be) considered as an error in the
      kernel, since there are legal users of it (e.g, members of a RAID5 MD Device
      or a new disk which is not partitioned at all ).  Changing this behaviour
      would scare the user about a serious problem with their disk and is not
      recommended.  Thus for both "unknown partitions" to the Linux (eg., DEC
      VMS,Novell Netware) and the legal users of NULL partition, would still be
      reported as "SUCCESS".
      
      The patch attached here, scares the user about something which he does need to
      worry about.  i.e, returning -EIO on disk I/O errors while reading the
      partition information.
      Signed-off-by: NSuzuki K P <suzuki@in.ibm.com>
      Cc: Erik Mouw <erik@harddisk-recovery.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      5127d002
  20. 17 10月, 2006 1 次提交