1. 07 May, 2011 3 commits
    • Lukas Czerner's avatar
      blkdev: Do not return -EOPNOTSUPP if discard is supported · 8af1954d
      Lukas Czerner authored
      Currently we return -EOPNOTSUPP in blkdev_issue_discard() if any of the
      bio fails due to underlying device not supporting discard request.
      However, if the device is for example dm device composed of devices
      which some of them support discard and some of them does not, it is ok
      for some bios to fail with EOPNOTSUPP, but it does not mean that discard
      is not supported at all.
      
      This commit removes the check for bios failed with EOPNOTSUPP and change
      blkdev_issue_discard() to return operation not supported if and only if
      the device does not actually supports it, not just part of the device as
      some bios might indicate.
      
      This change also fixes problem with BLKDISCARD ioctl() which now works
      correctly on such dm devices.
      Signed-off-by: default avatarLukas Czerner <lczerner@redhat.com>
      CC: Jens Axboe <jaxboe@fusionio.com>
      CC: Jeff Moyer <jmoyer@redhat.com>
      Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
      8af1954d
    • Lukas Czerner's avatar
      blkdev: Simple cleanup in blkdev_issue_zeroout() · 5baebe5c
      Lukas Czerner authored
      In blkdev_issue_zeroout() we are submitting regular WRITE bios, so we do
      not need to check for -EOPNOTSUPP specifically in case of error. Also
      there is no need to have label submit: because there is no way to jump
      out from the while cycle without an error and we really want to exit,
      rather than try again. And also remove the check for (sz == 0) since at
      that point sz can never be zero.
      Signed-off-by: default avatarLukas Czerner <lczerner@redhat.com>
      Reviewed-by: default avatarJeff Moyer <jmoyer@redhat.com>
      CC: Dmitry Monakhov <dmonakhov@openvz.org>
      CC: Jens Axboe <jaxboe@fusionio.com>
      Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
      5baebe5c
    • Lukas Czerner's avatar
      blkdev: Submit discard bio in batches in blkdev_issue_discard() · 5dba3089
      Lukas Czerner authored
      Currently we are waiting for every submitted REQ_DISCARD bio separately,
      but it can have unwanted consequences of repeatedly flushing the queue,
      so we rather submit bios in batches and wait for the entire batch, hence
      narrowing the window of other ios going in.
      
      Use bio_batch_end_io() and struct bio_batch for that purpose, the same
      is used by blkdev_issue_zeroout(). Also change bio_batch_end_io() so we
      always set !BIO_UPTODATE in the case of error and remove the check for
      bb, since we are the only user of this function and we always set this.
      
      Remove bio_get()/bio_put() from the blkdev_issue_discard() since
      bio_alloc() and bio_batch_end_io() is doing the same thing, hence it is
      not needed anymore.
      
      I have done simple dd testing with surprising results. The script I have
      used is:
      
      for i in $(seq 10); do
              echo $i
              dd if=/dev/sdb1 of=/dev/sdc1 bs=4k &
              sleep 5
      done
      /usr/bin/time -f %e ./blkdiscard /dev/sdc1
      
      Running time of BLKDISCARD on the whole device:
      with patch              without patch
      0.95                    15.58
      
      So we can see that in this artificial test the kernel with the patch
      applied is approx 16x faster in discarding the device.
      Signed-off-by: default avatarLukas Czerner <lczerner@redhat.com>
      CC: Dmitry Monakhov <dmonakhov@openvz.org>
      CC: Jens Axboe <jaxboe@fusionio.com>
      CC: Jeff Moyer <jmoyer@redhat.com>
      Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
      5dba3089
  2. 06 May, 2011 4 commits
  3. 05 May, 2011 1 commit
  4. 21 Apr, 2011 3 commits
    • Tejun Heo's avatar
      block: don't block events on excl write for non-optical devices · d4dc210f
      Tejun Heo authored
      Disk event code automatically blocks events on excl write.  This is
      primarily to avoid issuing polling commands while burning is in
      progress.  This behavior doesn't fit other types of devices with
      removeable media where polling commands don't have adverse side
      effects and door locking usually doesn't exist.
      
      This patch introduces new genhd flag which controls the auto-blocking
      behavior and uses it to enable auto-blocking only on optical devices.
      
      Note for stable: 2.6.38 and later only
      
      Cc: stable@kernel.org
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reported-by: default avatarKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
      d4dc210f
    • Tejun Heo's avatar
      block: rescan partitions on invalidated devices on -ENOMEDIA too · 1196f8b8
      Tejun Heo authored
      __blkdev_get() doesn't rescan partitions if disk->fops->open() fails,
      which leads to ghost partition devices lingering after medimum removal
      is known to both the kernel and userland.  The behavior also creates a
      subtle inconsistency where O_NONBLOCK open, which doesn't fail even if
      there's no medium, clears the ghots partitions, which is exploited to
      work around the problem from userland.
      
      Fix it by updating __blkdev_get() to issue partition rescan after
      -ENOMEDIA too.
      
      This was reported in the following bz.
      
       https://bugzilla.kernel.org/show_bug.cgi?id=13029
      
      Note for stable: 2.6.38 and later only
      
      Cc: stable@kernel.org
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reported-by: default avatarDavid Zeuthen <zeuthen@gmail.com>
      Reported-by: default avatarMartin Pitt <martin.pitt@ubuntu.com>
      Reported-by: default avatarKay Sievers <kay.sievers@vrfy.org>
      Tested-by: default avatarKay Sievers <kay.sievers@vrfy.org>
      Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
      1196f8b8
    • Tejun Heo's avatar
      cdrom: always check_disk_change() on open · ea6949b6
      Tejun Heo authored
      cdrom_open() called check_disk_change() after the rest of open path
      succeeded which leads to the following bizarre behavior.
      
      * After media change, if the device opened without O_NONBLOCK,
        open_for_data() naturally fails with -ENOMEDIA and
        check_disk_change() is never called.  The media is known to be gone
        and the open failure makes it obvious to the userland but device
        invalidation never happens.
      
      * But if the device is opened with O_NONBLOCK, all the checks are
        bypassed and cdrom_open() doesn't notice that the media is not there
        and check_disk_change() is called and invalidation happens.
      
      There's nothing to be gained by avoiding calling check_disk_change()
      on open failure.  Common cases end up calling check_disk_change()
      anyway.  All we get is inconsistent behavior.
      
      Fix it by moving check_disk_change() invocation to the top of
      cdrom_open() so that it always gets called regardless of how the rest
      of open proceeds.
      
      Note for stable: 2.6.38 and later only
      
      Cc: stable@kernel.org
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reported-by: default avatarAmit Shah <amit.shah@redhat.com>
      Tested-by: default avatarAmit Shah <amit.shah@redhat.com>
      Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
      ea6949b6
  5. 19 Apr, 2011 1 commit
  6. 18 Apr, 2011 28 commits