1. 09 10月, 2008 40 次提交
    • J
      blktrace: use BLKTRACE_BDEV_SIZE as the name size for setup structure · 0497b345
      Jens Axboe 提交于
      Define as 32, which is is what BDEVNAME_SIZE is/was as well. This keeps
      the user interface the same and gets rid of the difference between
      kernel and user api here.
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      0497b345
    • K
      block: add lld busy state exporting interface · ef9e3fac
      Kiyoshi Ueda 提交于
      This patch adds an new interface, blk_lld_busy(), to check lld's
      busy state from the block layer.
      blk_lld_busy() calls down into low-level drivers for the checking
      if the drivers set q->lld_busy_fn() using blk_queue_lld_busy().
      
      This resolves a performance problem on request stacking devices below.
      
      Some drivers like scsi mid layer stop dispatching request when
      they detect busy state on its low-level device like host/target/device.
      It allows other requests to stay in the I/O scheduler's queue
      for a chance of merging.
      
      Request stacking drivers like request-based dm should follow
      the same logic.
      However, there is no generic interface for the stacked device
      to check if the underlying device(s) are busy.
      If the request stacking driver dispatches and submits requests to
      the busy underlying device, the requests will stay in
      the underlying device's queue without a chance of merging.
      This causes performance problem on burst I/O load.
      
      With this patch, busy state of the underlying device is exported
      via q->lld_busy_fn().  So the request stacking driver can check it
      and stop dispatching requests if busy.
      
      The underlying device driver must return the busy state appropriately:
          1: when the device driver can't process requests immediately.
          0: when the device driver can process requests immediately,
             including abnormal situations where the device driver needs
             to kill all requests.
      Signed-off-by: NKiyoshi Ueda <k-ueda@ct.jp.nec.com>
      Signed-off-by: NJun'ichi Nomura <j-nomura@ce.jp.nec.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      ef9e3fac
    • S
      include blktrace_api.h in headers_install · c0ddffa8
      Sven Schuetz 提交于
      This header file is of interest for user space programming, i.e.
      for tools that process blktrace data.
      
      We would like to use it for a tool on-top of blktrace which processes
      data provided by blktrace. For this purpose, it would be helpful
      if the blktrace API would make it to /usr/include/linux.
      
      The git tree for the blktrace tools comes with its own copy of this header
      file. I didn't manage to replace that copy with the file generated
      by the patch below yet. A few more cleanups would be needed.
      For example, the blktrace ioctl numbers, which are currently defined in
      usr/include/fs.h, might need to be moved. Should be feasible, though.
      Signed-off-by: NSven Schuetz <sven@linux.vnet.ibm.com>
      Signed-off-by: NMartin Peschke <mp3@de.ibm.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      c0ddffa8
    • J
      libata: set queue SSD flag for SSD devices · 8bff7c6b
      Jens Axboe 提交于
      SSD devices should give an RPM setting of 1 in word 217 of the ID
      page. If we see such a device, tell the block layer about it.
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      8bff7c6b
    • J
      block: add queue flag for SSD/non-rotational devices · a68bbddb
      Jens Axboe 提交于
      We don't want to idle in AS/CFQ if the device doesn't have a seek
      penalty. So add a QUEUE_FLAG_NONROT to indicate a non-rotational
      device, low level drivers should set this flag upon discovery of
      an SSD or similar device type.
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      a68bbddb
    • K
      floppy: support arbitrary first-sector numbers · 9e49184c
      Keith Wansbrough 提交于
      The current floppy_struct allows floppies to number sectors starting
      from 0 or 1.  This patch allows arbitrary first-sector numbers - for
      example, 0xC1 for Amstrad CPC disks.
      
      This extends the existing 1-bit field (FD_ZEROBASED, bit 2 of stretch)
      to 8 bits (FD_SECTMASK, bits 2 to 9).
      
      Currently 0x00 denotes a first sector number of 1, and 0x01 denotes a
      first sector number of 0.  We extend this by interpreting FD_SECTMASK
      as the first sector number with the LSB flipped.
      Signed-off-by: NKeith Wansbrough <keith@lochan.org>
      Cc: Alain Knaff <alain@linux.lu>
      Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
      Cc: Karel Zak <kzak@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      9e49184c
    • K
      block: add a queue flag for request stacking support · 4ee5eaf4
      Kiyoshi Ueda 提交于
      This patch adds a queue flag to indicate the block device can be
      used for request stacking.
      
      Request stacking drivers need to stack their devices on top of
      only devices of which q->request_fn is functional.
      Since bio stacking drivers (e.g. md, loop) basically initialize
      their queue using blk_alloc_queue() and don't set q->request_fn,
      the check of (q->request_fn == NULL) looks enough for that purpose.
      
      However, dm will become both types of stacking driver (bio-based and
      request-based).  And dm will always set q->request_fn even if the dm
      device is bio-based of which q->request_fn is not functional actually.
      So we need something else to distinguish the type of the device.
      Adding a queue flag is a solution for that.
      
      The reason why dm always sets q->request_fn is to keep
      the compatibility of dm user-space tools.
      Currently, all dm user-space tools are using bio-based dm without
      specifying the type of the dm device they use.
      To use request-based dm without changing such tools, the kernel
      must decide the type of the dm device automatically.
      The automatic type decision can't be done at the device creation time
      and needs to be deferred until such tools load a mapping table,
      since the actual type is decided by dm target type included in
      the mapping table.
      
      So a dm device has to be initialized using blk_init_queue()
      so that we can load either type of table.
      Then, all queue stuffs are set (e.g. q->request_fn) and we have
      no element to distinguish that it is bio-based or request-based,
      even after a table is loaded and the type of the device is decided.
      
      By the way, some stuffs of the queue (e.g. request_list, elevator)
      are needless when the dm device is used as bio-based.
      But the memory size is not so large (about 20[KB] per queue on ia64),
      so I hope the memory loss can be acceptable for bio-based dm users.
      Signed-off-by: NKiyoshi Ueda <k-ueda@ct.jp.nec.com>
      Signed-off-by: NJun'ichi Nomura <j-nomura@ce.jp.nec.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      4ee5eaf4
    • K
      block: add request submission interface · 82124d60
      Kiyoshi Ueda 提交于
      This patch adds blk_insert_cloned_request(), a generic request
      submission interface for request stacking drivers.
      Request-based dm will use it to submit their clones to underlying
      devices.
      
      blk_rq_check_limits() is also added because it is possible that
      the lower queue has stronger limitations than the upper queue
      if multiple drivers are stacking at request-level.
      Not only for blk_insert_cloned_request()'s internal use, the function
      will be used by request-based dm when the queue limitation is
      modified (e.g. by replacing dm's table).
      Signed-off-by: NKiyoshi Ueda <k-ueda@ct.jp.nec.com>
      Signed-off-by: NJun'ichi Nomura <j-nomura@ce.jp.nec.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      82124d60
    • K
      block: add request update interface · 32fab448
      Kiyoshi Ueda 提交于
      This patch adds blk_update_request(), which updates struct request
      with completing its data part, but doesn't complete the struct
      request itself.
      Though it looks like end_that_request_first() of older kernels,
      blk_update_request() should be used only by request stacking drivers.
      
      Request-based dm will use it in bio->bi_end_io callback to update
      the original request when a data part of a cloned request completes.
      Followings are additional background information of why request-based
      dm needs this interface.
      
        - Request stacking drivers can't use blk_end_request() directly from
          the lower driver's completion context (bio->bi_end_io or rq->end_io),
          because some device drivers (e.g. ide) may try to complete
          their request with queue lock held, and it may cause deadlock.
          See below for detailed description of possible deadlock:
          <http://marc.info/?l=linux-kernel&m=120311479108569&w=2>
      
        - To solve that, request-based dm offloads the completion of
          cloned struct request to softirq context (i.e. using
          blk_complete_request() from rq->end_io).
      
        - Though it is possible to use the same solution from bio->bi_end_io,
          it will delay the notification of bio completion to the original
          submitter.  Also, it will cause inefficient partial completion,
          because the lower driver can't perform the cloned request anymore
          and request-based dm needs to requeue and redispatch it to
          the lower driver again later.  That's not good.
      
        - So request-based dm needs blk_update_request() to perform the bio
          completion in the lower driver's completion context, which is more
          efficient.
      Signed-off-by: NKiyoshi Ueda <k-ueda@ct.jp.nec.com>
      Signed-off-by: NJun'ichi Nomura <j-nomura@ce.jp.nec.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      32fab448
    • J
      block: cleanup some of the integrity stuff in blkdev.h · 9c02f2b0
      Jens Axboe 提交于
      Don't put functions that are only used in fs/bio-integrity.c in
      blkdev.h, it's much cleaner to just keep it in there. Also kill
      completely unused bdev_get_tag_size()
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      9c02f2b0
    • J
      block: add fault injection mechanism for faking request timeouts · 581d4e28
      Jens Axboe 提交于
      Only works for the generic request timer handling. Allows one to
      sporadically ignore request completions, thus exercising the timeout
      handling.
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      581d4e28
    • J
      block: add bio_kmalloc() · 0a0d96b0
      Jens Axboe 提交于
      Not all callers need (or want!) the mempool backing guarentee, it
      essentially means that you can only use bio_alloc() for short allocations
      and not for preallocating some bio's at setup or init time.
      
      So add bio_kmalloc() which does the same thing as bio_alloc(), except
      it just uses kmalloc() as the backing instead of the bio mempools.
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      0a0d96b0
    • H
      block: adjust blkdev_issue_discard for swap · 3e6053d7
      Hugh Dickins 提交于
      Two mods to blkdev_issue_discard(), thinking ahead to its use on swap:
      
      1. Add gfp_mask argument, so swap allocation can use it where GFP_KERNEL
         might deadlock but GFP_NOIO is safe.
      
      2. Enlarge nr_sects argument from unsigned to sector_t: unsigned long is
         enough to cover a whole swap area, but sector_t suits any partition.
      
      Change sb_issue_discard()'s nr_blocks to sector_t too; but no need seen
      for a gfp_mask there, just pass GFP_KERNEL down to blkdev_issue_discard().
      Signed-off-by: NHugh Dickins <hugh@veritas.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      3e6053d7
    • M
      11914a53
    • J
      block: unify request timeout handling · 242f9dcb
      Jens Axboe 提交于
      Right now SCSI and others do their own command timeout handling.
      Move those bits to the block layer.
      
      Instead of having a timer per command, we try to be a bit more clever
      and simply have one per-queue. This avoids the overhead of having to
      tear down and setup a timer for each command, so it will result in a lot
      less timer fiddling.
      Signed-off-by: NMike Anderson <andmike@linux.vnet.ibm.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      242f9dcb
    • A
      Adjust block device size after an online resize of a disk. · c3279d14
      Andrew Patterson 提交于
      The revalidate_disk routine now checks if a disk has been resized by
      comparing the gendisk capacity to the bdev inode size.  If they are
      different (usually because the disk has been resized underneath the kernel)
      the bdev inode size is adjusted to match the capacity.
      Signed-off-by: NAndrew Patterson <andrew.patterson@hp.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      c3279d14
    • A
      Wrapper for lower-level revalidate_disk routines. · 0c002c2f
      Andrew Patterson 提交于
      This is a wrapper for the lower-level revalidate_disk call-backs such
      as sd_revalidate_disk(). It allows us to perform pre and post
      operations when calling them.
      
      We will use this wrapper in a later patch to adjust block device sizes
      after an online resize (a _post_ operation).
      Signed-off-by: NAndrew Patterson <andrew.patterson@hp.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      0c002c2f
    • F
      block: make blk_rq_map_user take a NULL user-space buffer · 81882766
      FUJITA Tomonori 提交于
      This patch changes blk_rq_map_user to accept a NULL user-space buffer
      with a READ command if rq_map_data is not NULL. Thus a caller can pass
      page frames to lk_rq_map_user to just set up a request and bios with
      page frames propely. bio_uncopy_user (called via blk_rq_unmap_user)
      doesn't copy data to user space with such request.
      Signed-off-by: NFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      81882766
    • F
      block: add blk_rq_aligned helper function · 87904074
      FUJITA Tomonori 提交于
      This adds blk_rq_aligned helper function to see if alignment and
      padding requirement is satisfied for DMA transfer. This also converts
      blk_rq_map_kern and __blk_rq_map_user to use the helper function.
      Signed-off-by: NFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
      Cc: Jens Axboe <jens.axboe@oracle.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      87904074
    • F
      block: introduce struct rq_map_data to use reserved pages · 152e283f
      FUJITA Tomonori 提交于
      This patch introduces struct rq_map_data to enable bio_copy_use_iov()
      use reserved pages.
      
      Currently, bio_copy_user_iov allocates bounce pages but
      drivers/scsi/sg.c wants to allocate pages by itself and use
      them. struct rq_map_data can be used to pass allocated pages to
      bio_copy_user_iov.
      
      The current users of bio_copy_user_iov simply passes NULL (they don't
      want to use pre-allocated pages).
      Signed-off-by: NFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
      Cc: Jens Axboe <jens.axboe@oracle.com>
      Cc: Douglas Gilbert <dougg@torque.net>
      Cc: Mike Christie <michaelc@cs.wisc.edu>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      152e283f
    • F
      block: add gfp_mask argument to blk_rq_map_user and blk_rq_map_user_iov · a3bce90e
      FUJITA Tomonori 提交于
      Currently, blk_rq_map_user and blk_rq_map_user_iov always do
      GFP_KERNEL allocation.
      
      This adds gfp_mask argument to blk_rq_map_user and blk_rq_map_user_iov
      so sg can use it (sg always does GFP_ATOMIC allocation).
      Signed-off-by: NFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
      Signed-off-by: NDouglas Gilbert <dougg@torque.net>
      Cc: Mike Christie <michaelc@cs.wisc.edu>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      a3bce90e
    • J
      block: inherit CPU completion on bio->rq and rq->rq merges · ab780f1e
      Jens Axboe 提交于
      Somewhat incomplete, as we do allow merges of requests and bios
      that have different completion CPUs given. This is done on the
      assumption that a larger IO is still more beneficial than CPU
      locality.
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      ab780f1e
    • J
      block: add support for IO CPU affinity · c7c22e4d
      Jens Axboe 提交于
      This patch adds support for controlling the IO completion CPU of
      either all requests on a queue, or on a per-request basis. We export
      a sysfs variable (rq_affinity) which, if set, migrates completions
      of requests to the CPU that originally submitted it. A bio helper
      (bio_set_completion_cpu()) is also added, so that queuers can ask
      for completion on that specific CPU.
      
      In testing, this has been show to cut the system time by as much
      as 20-40% on synthetic workloads where CPU affinity is desired.
      
      This requires a little help from the architecture, so it'll only
      work as designed for archs that are using the new generic smp
      helper infrastructure.
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      c7c22e4d
    • J
      block: make kblockd_schedule_work() take the queue as parameter · 18887ad9
      Jens Axboe 提交于
      Preparatory patch for checking queuing affinity.
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      18887ad9
    • T
      block: allow disk to have extended device number · 3e1a7ff8
      Tejun Heo 提交于
      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: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      3e1a7ff8
    • T
      block: replace @ext_minors with GENHD_FL_EXT_DEVT · 689d6fac
      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: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      689d6fac
    • T
      block: make partition array dynamic · 540eed56
      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: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      540eed56
    • T
      block: move stats from disk to part0 · 074a7aca
      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: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      074a7aca
    • T
      block: kill GENHD_FL_FAIL and use part0->make_it_fail · eddb2e26
      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: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      eddb2e26
    • T
      block: always set bdev->bd_part · 0762b8bd
      Tejun Heo 提交于
      Till now, bdev->bd_part is set only if the bdev was for parts other
      than part0.  This patch makes bdev->bd_part always set so that code
      paths don't have to differenciate common handling.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      0762b8bd
    • 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 __dev from disk to part0 · 548b10eb
      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 <bzolnier@gmail.com>,
      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: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      548b10eb
    • 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: adjust formatting for large minors and add ext_range sysfs attr · 1f014290
      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: NTejun Heo <tj@kernel.org>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      1f014290
    • 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