1. 09 Oct, 2008 40 commits
    • Tejun Heo's avatar
      block: unify sysfs size node handling · e5610521
      Tejun Heo authored
      Now that capacity and __dev are moved to part0, part0 and others can
      share the same method.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      e5610521
    • Tejun Heo's avatar
      block: move __dev from disk to part0 · 548b10eb
      Tejun Heo authored
      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: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      548b10eb
    • Tejun Heo's avatar
      block: move capacity from disk to part0 · 80795aef
      Tejun Heo authored
      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: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      80795aef
    • Tejun Heo's avatar
      block: introduce partition 0 · b5d0b9df
      Tejun Heo authored
      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: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      b5d0b9df
    • Tejun Heo's avatar
      block: implement and use {disk|part}_to_dev() · ed9e1982
      Tejun Heo authored
      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: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      ed9e1982
    • Tejun Heo's avatar
      block: implement CONFIG_DEBUG_BLOCK_EXT_DEVT · 870d6656
      Tejun Heo authored
      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: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      870d6656
    • Tejun Heo's avatar
      sd/ide-disk: apply extended minors to sd and ide · f615b48c
      Tejun Heo authored
      Update sd and ide-disk such that they can take advantage of extended
      minors.
      
      ide-disk already has 64 minors per device and currently doesn't use
      extended minors although after this patch it can be turned on by
      simply tweaking constants.
      
      sd only had 16 minors per device causing problems on certain peculiar
      configurations.  This patch lifts the restriction and enables it to
      use upto 64 minors.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      f615b48c
    • Tejun Heo's avatar
      block: adjust formatting for large minors and add ext_range sysfs attr · 1f014290
      Tejun Heo authored
      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: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      1f014290
    • Tejun Heo's avatar
      block: implement extended dev numbers · bcce3de1
      Tejun Heo authored
      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: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      bcce3de1
    • Tejun Heo's avatar
      block: fix diskstats access · c9959059
      Tejun Heo authored
      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: default avatarTejun Heo <tj@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      c9959059
    • Tejun Heo's avatar
      block: fix disk->part[] dereferencing race · e71bf0d0
      Tejun Heo authored
      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: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      e71bf0d0
    • Tejun Heo's avatar
      block: don't depend on consecutive minor space · f331c029
      Tejun Heo authored
      * 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: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      f331c029
    • Tejun Heo's avatar
      block: make variable and argument names more consistent · cf771cb5
      Tejun Heo authored
      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: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      cf771cb5
    • Tejun Heo's avatar
      block: misc updates · 310a2c10
      Tejun Heo authored
      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: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      310a2c10
    • Tejun Heo's avatar
      block: update add_partition() error handling · 88e34126
      Tejun Heo authored
      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: default avatarTejun Heo <tj@kernel.org>
      Cc: Abdel Benamrouche <draconux@gmail.com>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      88e34126
    • Tejun Heo's avatar
      block: allow deleting zero length partition · ec2cdedf
      Tejun Heo authored
      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: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      ec2cdedf
    • Tejun Heo's avatar
      block: use class_dev_iterator instead of class_for_each_device() · def4e38d
      Tejun Heo authored
      Recent block_class iteration updates 5c6f35c5..27f30251 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: default avatarTejun Heo <tj@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@suse.de>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      def4e38d
    • Tejun Heo's avatar
      block: don't grab block_class_lock unnecessarily · 2ac3cee5
      Tejun Heo authored
      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: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      2ac3cee5
    • Tejun Heo's avatar
      block: fix partition info printouts · ac65ece4
      Tejun Heo authored
      Recent block_class iteration updates 5c6f35c5..27f30251 broke partition
      info printouts.
      
      * printk_all_partitions(): Partition print out stops when it meets a
        partition hole.  Partition printing inner loop should continue
        instead of exiting on empty partition slot.
      
      * /proc/partitions and /proc/diskstats: If all information can't be
        read in single read(), the information is truncated.  This is
        because find_start() doesn't actually update the counter containing
        the initial seek.  It runs to the end and ends up always reporting
        EOF on the second read.
      
      This patch fixes both problems.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@suse.de>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      ac65ece4
    • Tejun Heo's avatar
      driver-core: use klist for class device list and implement iterator · 5a3ceb86
      Tejun Heo authored
      Iterating over entries using callback usually isn't too fun especially
      when the entry being iterated over can't be manipulated freely.  This
      patch converts class->p->class_devices to klist and implements class
      device iterator so that the users can freely build their own control
      structure.  The users are also free to call back into class code
      without worrying about locking.
      
      class_for_each_device() and class_find_device() are converted to use
      the new iterators, so their users don't have to worry about locking
      anymore either.
      
      Note: This depends on klist-dont-iterate-over-deleted-entries patch
      because class_intf->add/remove_dev() depends on proper synchronization
      with device removal.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@suse.de>
      Cc: Jens Axboe <jens.axboe@oracle.com>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      5a3ceb86
    • Tejun Heo's avatar
      klist: don't iterate over deleted entries · a1ed5b0c
      Tejun Heo authored
      A klist entry is kept on the list till all its current iterations are
      finished; however, a new iteration after deletion also iterates over
      deleted entries as long as their reference count stays above zero.
      This causes problems for cases where there are users which iterate
      over the list while synchronized against list manipulations and
      natuarally expect already deleted entries to not show up during
      iteration.
      
      This patch implements dead flag which gets set on deletion so that
      iteration can skip already deleted entries.  The dead flag piggy backs
      on the lowest bit of knode->n_klist and only visible to klist
      implementation proper.
      
      While at it, drop klist_iter->i_head as it's redundant and doesn't
      offer anything in semantics or performance wise as klist_iter->i_klist
      is dereferenced on every iteration anyway.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@suse.de>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Jens Axboe <jens.axboe@oracle.com>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      a1ed5b0c
    • Randy Dunlap's avatar
      Add some block/ source files to the kernel-api docbook. Fix kernel-doc... · 710027a4
      Randy Dunlap authored
      Add some block/ source files to the kernel-api docbook. Fix kernel-doc notation in them as needed. Fix changed function parameter names. Fix typos/spellos. In comments, change REQ_SPECIAL to REQ_TYPE_SPECIAL and REQ_BLOCK_PC to REQ_TYPE_BLOCK_PC.
      Signed-off-by: default avatarRandy Dunlap <randy.dunlap@oracle.com>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      710027a4
    • Jens Axboe's avatar
      block: make bi_phys_segments an unsigned int instead of short · 5b99c2ff
      Jens Axboe authored
      raid5 can overflow with more than 255 stripes, and we can increase it
      to an int for free on both 32 and 64-bit archs due to the padding.
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      5b99c2ff
    • Jens Axboe's avatar
      960e739d
    • Mikulas Patocka's avatar
      drop vmerge accounting · 5df97b91
      Mikulas Patocka authored
      Remove hw_segments field from struct bio and struct request. Without virtual
      merge accounting they have no purpose.
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      5df97b91
    • Mikulas Patocka's avatar
      block: drop virtual merging accounting · b8b3e16c
      Mikulas Patocka authored
      Remove virtual merge accounting.
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      b8b3e16c
    • Aaron Carroll's avatar
      block: update documentation for deadline fifo_batch tunable · 6a421c1d
      Aaron Carroll authored
      Update the description of fifo_batch to match the current implementation,
      and include a description of how to tune it.
      Signed-off-by: default avatarAaron Carroll <aaronc@gelato.unsw.edu.au>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      6a421c1d
    • Aaron Carroll's avatar
      deadline-iosched: non-functional fixes · 4fb72f76
      Aaron Carroll authored
      * convert goto to simpler while loop;
       * use rq_end_sector() instead of computing manually;
       * fix false comments;
       * remove spurious whitespace;
       * convert rq_rb_root macro to an inline function.
      Signed-off-by: default avatarAaron Carroll <aaronc@gelato.unsw.edu.au>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      4fb72f76
    • Aaron Carroll's avatar
      deadline-iosched: allow non-sequential batching · 63de428b
      Aaron Carroll authored
      Deadline currently only batches sector-contiguous requests, so except
      for a few circumstances (e.g. requests in a single direction), it is
      essentially first come first served.  This is bad for throughput, so
      change it to CSCAN, which means requests in a batch do not need to be
      sequential and are issued in increasing sector order.
      Signed-off-by: default avatarAaron Carroll <aaronc@gelato.unsw.edu.au>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      63de428b
    • Fernando Luis Vázquez Cao's avatar
      virtio_blk: use a wrapper function to access io context information of IO requests · 766ca442
      Fernando Luis Vázquez Cao authored
      struct request has an ioprio member but it is never updated because
      currently bios do not hold io context information. The implication of
      this is that virtio_blk ends up passing useless information to the
      backend driver.
      
      That said, some IO schedulers such as CFQ do store io context
      information in struct request, but use private members for that, which
      means that that information cannot be directly accessed in a IO
      scheduler-independent way.
      
      This patch adds a function to obtain the ioprio of a request. We should
      avoid accessing ioprio directly and use this function instead, so that
      its users do not have to care about future changes in block layer
      structures or what the currently active IO controller is.
      
      This patch does not introduce any functional changes but paves the way
      for future clean-ups and enhancements.
      Signed-off-by: default avatarFernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
      Acked-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      766ca442
    • David Woodhouse's avatar
      Kill REQ_TYPE_FLUSH · 1a8e2bdd
      David Woodhouse authored
      It was only used by ps3disk, and it should probably have been
      REQ_TYPE_LINUX_BLOCK + REQ_LB_OP_FLUSH.
      Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      1a8e2bdd
    • David Woodhouse's avatar
      Allow elevators to sort/merge discard requests · e17fc0a1
      David Woodhouse authored
      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: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      e17fc0a1
    • David Woodhouse's avatar
      Add BLKDISCARD ioctl to allow userspace to discard sectors · d30a2605
      David Woodhouse authored
      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: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      d30a2605
    • OGAWA Hirofumi's avatar
      Use WRITE_BARRIER in blkdev_issue_flush(), not (1<<BIO_RW_BARRIER) · 2ebca85a
      OGAWA Hirofumi authored
      Barriers should be submitted with the WRITE flag set.
      Signed-off-by: default avatarOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
      Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      2ebca85a
    • David Woodhouse's avatar
      blktrace: simplify flags handling in __blk_add_trace · 35ba8f70
      David Woodhouse authored
      Let the compiler see what's going on, and it can all get a lot simpler.
      On PPC64 this reduces the size of the code calculating these bits by
      about 60%. On x86_64 it's less of a win -- only 40%.
      Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      35ba8f70
    • David Woodhouse's avatar
      27b29e86
    • David Woodhouse's avatar
      Support 'discard sectors' operation. · fdc53971
      David Woodhouse authored
      We can benefit from knowing that the file system no longer cares about
      the contents of certain sectors, by throwing them away immediately and
      then never having to garbage collect them, and using the extra free
      space to make our operations more efficient. Do so.
      Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      fdc53971
    • David Woodhouse's avatar
    • David Woodhouse's avatar
      Let the block device know when sectors can be discarded · 8c540a96
      David Woodhouse authored
      [hirofumi@mail.parknet.co.jp: discard _after_ checking for corrupt chains]
      Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
      Acked-by: default avatarOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      8c540a96
    • David Woodhouse's avatar
      Add 'discard' request handling · fb2dce86
      David Woodhouse authored
      Some block devices benefit from a hint that they can forget the contents
      of certain sectors. Add basic support for this to the block core, along
      with a 'blkdev_issue_discard()' helper function which issues such
      requests.
      
      The caller doesn't get to provide an end_io functio, since
      blkdev_issue_discard() will automatically split the request up into
      multiple bios if appropriate. Neither does the function wait for
      completion -- it's expected that callers won't care about when, or even
      _if_, the request completes. It's only a hint to the device anyway. By
      definition, the file system doesn't _care_ about these sectors any more.
      
      [With feedback from OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> and
      Jens Axboe <jens.axboe@oracle.com]
      Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
      Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
      fb2dce86