projects/linux·commit 10f36b1e

Merge tag 'for-5.7/block-2020-03-29' of git://git.kernel.dk/linux-block

10f36b1e · Linus Torvalds <[email protected]> · 2020-03-30 11:20:13 -07:00

Pull block updates from Jens Axboe:

 - Online capacity resizing (Balbir)

 - Number of hardware queue change fixes (Bart)

 - null_blk fault injection addition (Bart)

 - Cleanup of queue allocation, unifying the node/no-node API
   (Christoph)

 - Cleanup of genhd, moving code to where it makes sense (Christoph)

 - Cleanup of the partition handling code (Christoph)

 - disk stat fixes/improvements (Konstantin)

 - BFQ improvements (Paolo)

 - Various fixes and improvements

* tag 'for-5.7/block-2020-03-29' of git://git.kernel.dk/linux-block: (72 commits)
  block: return NULL in blk_alloc_queue() on error
  block: move bio_map_* to blk-map.c
  Revert "blkdev: check for valid request queue before issuing flush"
  block: simplify queue allocation
  bcache: pass the make_request methods to blk_queue_make_request
  null_blk: use blk_mq_init_queue_data
  block: add a blk_mq_init_queue_data helper
  block: move the ->devnode callback to struct block_device_operations
  block: move the part_stat* helpers from genhd.h to a new header
  block: move block layer internals out of include/linux/genhd.h
  block: move guard_bio_eod to bio.c
  block: unexport get_gendisk
  block: unexport disk_map_sector_rcu
  block: unexport disk_get_part
  block: mark part_in_flight and part_in_flight_rw static
  block: mark block_depr static
  block: factor out requeue handling from dispatch code
  block/diskstats: replace time_in_queue with sum of request times
  block/diskstats: accumulate all per-cpu counters in one pass
  block/diskstats: more accurate approximation of io_ticks for slow disks
  ...
Commit
10f36b1e80a9f7afdaefe6f0b06dcdf89715eed7
Parents
3a0eb192 · 654a3667

Merge commit. Changes below are compared with the first parent: 3a0eb192.

Changes

111 files changed · +2430 −2519

FileStatusAddDelContent
Documentation/admin-guide/iostats.rstmodified+4−1View file
Documentation/block/capability.rstmodified+4−12View file
Documentation/scsi/scsi_mid_low_api.txtmodified+0−21View file
arch/m68k/emu/nfblock.cmodified+1−2View file
arch/xtensa/platforms/iss/simdisk.cmodified+1−2View file
block/Makefilemodified+1−2View file
block/bfq-cgroup.cmodified+52−35View file
block/bfq-iosched.cmodified+12−6View file
block/bfq-iosched.hmodified+1−0View file
block/bio.cmodified+65−515View file
block/blk-cgroup.cmodified+1−1View file
block/blk-core.cmodified+38−44View file
block/blk-flush.cmodified+2−14View file
block/blk-ioc.cmodified+7−0View file
block/blk-iocost.cmodified+0−3View file
block/blk-map.cmodified+508−0View file
block/blk-mq.cmodified+38−21View file
block/blk-settings.cmodified+0−36View file
block/blk-zoned.cmodified+1−1View file
block/blk.hmodified+136−2View file
block/genhd.cmodified+192−27View file
block/ioctl.cmodified+1−0View file
block/opal_proto.hmodified+1−0View file
block/partition-generic.cdeleted+0−623View before deletion
block/partitions/Makefilemodified+1−2View file
block/partitions/acorn.cmodified+0−1View file
block/partitions/acorn.hdeleted+0−15View before deletion
block/partitions/aix.cmodified+0−1View file
block/partitions/amiga.cmodified+4−7View file
block/partitions/amiga.hdeleted+0−7View before deletion
block/partitions/atari.hmodified+0−1View file
block/partitions/check.cdeleted+0−198View before deletion
block/partitions/check.hmodified+28−13View file
block/partitions/cmdline.cmodified+0−1View file
block/partitions/cmdline.hdeleted+0−3View before deletion
block/partitions/core.cadded+658−0View file
block/partitions/efi.hmodified+0−3View file
block/partitions/ibm.cmodified+0−1View file
block/partitions/ibm.hdeleted+0−2View before deletion
block/partitions/karma.cmodified+2−1View file
block/partitions/karma.hdeleted+0−9View before deletion
block/partitions/ldm.cmodified+3−3View file
block/partitions/ldm.hmodified+0−2View file
block/partitions/mac.hmodified+0−1View file
block/partitions/msdos.cmodified+151−21View file
block/partitions/msdos.hdeleted+0−9View before deletion
block/partitions/osf.cmodified+1−1View file
block/partitions/osf.hdeleted+0−8View before deletion
block/partitions/sgi.cmodified+6−1View file
block/partitions/sgi.hdeleted+0−9View before deletion
block/partitions/sun.cmodified+8−1View file
block/partitions/sun.hdeleted+0−9View before deletion
block/partitions/sysv68.cmodified+0−1View file
block/partitions/sysv68.hdeleted+0−2View before deletion
block/partitions/ultrix.cmodified+0−1View file
block/partitions/ultrix.hdeleted+0−6View before deletion
block/sed-opal.cmodified+1−1View file
drivers/block/brd.cmodified+1−3View file
drivers/block/drbd/drbd_main.cmodified+1−2View file
drivers/block/drbd/drbd_receiver.cmodified+1−0View file
drivers/block/drbd/drbd_worker.cmodified+1−0View file
drivers/block/null_blk_main.cmodified+65−41View file
drivers/block/pktcdvd.cmodified+7−8View file
drivers/block/ps3vram.cmodified+1−2View file
drivers/block/rsxx/dev.cmodified+1−2View file
drivers/block/umem.cmodified+1−3View file
drivers/block/virtio_blk.cmodified+1−4View file
drivers/block/xen-blkfront.cmodified+1−5View file
drivers/block/zram/zram_drv.cmodified+2−3View file
drivers/lightnvm/core.cmodified+1−2View file
drivers/md/bcache/request.cmodified+2−5View file
drivers/md/bcache/request.hmodified+3−0View file
drivers/md/bcache/super.cmodified+6−5View file
drivers/md/dm.cmodified+5−5View file
drivers/md/md.cmodified+5−4View file
drivers/nvdimm/blk.cmodified+1−2View file
drivers/nvdimm/btt.cmodified+1−2View file
drivers/nvdimm/pmem.cmodified+1−2View file
drivers/nvme/host/core.cmodified+1−1View file
drivers/nvme/host/multipath.cmodified+1−2View file
drivers/nvme/target/admin-cmd.cmodified+1−0View file
drivers/s390/block/dcssblk.cmodified+2−2View file
drivers/s390/block/xpram.cmodified+2−2View file
drivers/scsi/BusLogic.cmodified+5−3View file
drivers/scsi/aacraid/linit.cmodified+4−3View file
drivers/scsi/aic7xxx/aic79xx_osm.cmodified+3−10View file
drivers/scsi/aic7xxx/aic7xxx_osm.cmodified+3−10View file
drivers/scsi/arcmsr/arcmsr_hba.cmodified+4−9View file
drivers/scsi/megaraid.cmodified+2−11View file
drivers/scsi/scsi_debug.cmodified+3−2View file
drivers/scsi/scsicam.cmodified+92−94View file
drivers/scsi/sd.cmodified+2−1View file
fs/block_dev.cmodified+16−4View file
fs/buffer.cmodified+0−43View file
fs/ext4/super.cmodified+4−4View file
fs/ext4/sysfs.cmodified+1−0View file
fs/f2fs/f2fs.hmodified+1−0View file
fs/f2fs/super.cmodified+1−0View file
fs/internal.hmodified+0−1View file
fs/reiserfs/journal.cmodified+2−3View file
include/linux/bio.hmodified+1−14View file
include/linux/blk-mq.hmodified+6−1View file
include/linux/blkdev.hmodified+2−12View file
include/linux/fs.hmodified+0−1View file
include/linux/genhd.hmodified+61−462View file
include/linux/iocontext.hmodified+1−0View file
include/linux/msdos_partition.hadded+50−0View file
include/linux/part_stat.hadded+115−0View file
block/partitions/aix.h → include/linux/raid/detect.hrenamed+2−1View file
include/scsi/scsicam.hmodified+3−4View file
init/do_mounts.cmodified+2−10View file

Only the first 600 diff lines are shown. Download the complete patch.

Documentation/admin-guide/iostats.rst

View file
diff --git a/Documentation/admin-guide/iostats.rst b/Documentation/admin-guide/iostats.rst
index df5b834..9b14b0c 100644
--- a/Documentation/admin-guide/iostats.rst
+++ b/Documentation/admin-guide/iostats.rst
@@ -100,7 +100,7 @@ Field 10 -- # of milliseconds spent doing I/Os (unsigned int)
Since 5.0 this field counts jiffies when at least one request was
started or completed. If request runs more than 2 jiffies then some
- I/O time will not be accounted unless there are other requests.
+ I/O time might be not accounted in case of concurrent requests.
Field 11 -- weighted # of milliseconds spent doing I/Os (unsigned int)
This field is incremented at each I/O start, I/O completion, I/O
@@ -143,6 +143,9 @@ are summed (possibly overflowing the unsigned long variable they are
summed to) and the result given to the user. There is no convenient
user interface for accessing the per-CPU counters themselves.
+Since 4.19 request times are measured with nanoseconds precision and
+truncated to milliseconds before showing in this interface.
+
Disks vs Partitions
-------------------

Documentation/block/capability.rst

View file
diff --git a/Documentation/block/capability.rst b/Documentation/block/capability.rst
index 2cf258d..160a514 100644
--- a/Documentation/block/capability.rst
+++ b/Documentation/block/capability.rst
@@ -2,17 +2,9 @@
Generic Block Device Capability
===============================
-This file documents the sysfs file block/<disk>/capability
+This file documents the sysfs file ``block/<disk>/capability``.
-capability is a hex word indicating which capabilities a specific disk
-supports. For more information on bits not listed here, see
-include/linux/genhd.h
+``capability`` is a bitfield, printed in hexadecimal, indicating which
+capabilities a specific block device supports:
-GENHD_FL_MEDIA_CHANGE_NOTIFY
-----------------------------
-
-Value: 4
-
-When this bit is set, the disk supports Asynchronous Notification
-of media change events. These events will be broadcast to user
-space via kernel uevent.
+.. kernel-doc:: include/linux/genhd.h

Documentation/scsi/scsi_mid_low_api.txt

View file
diff --git a/Documentation/scsi/scsi_mid_low_api.txt b/Documentation/scsi/scsi_mid_low_api.txt
index 2a4be1c..537f047 100644
--- a/Documentation/scsi/scsi_mid_low_api.txt
+++ b/Documentation/scsi/scsi_mid_low_api.txt
@@ -299,7 +299,6 @@ Summary:
scsi_host_alloc - return a new scsi_host instance whose refcount==1
scsi_host_get - increments Scsi_Host instance's refcount
scsi_host_put - decrements Scsi_Host instance's refcount (free if 0)
- scsi_partsize - parse partition table into cylinders, heads + sectors
scsi_register - create and register a scsi host adapter instance.
scsi_remove_device - detach and remove a SCSI device
scsi_remove_host - detach and remove all SCSI devices owned by host
@@ -473,26 +472,6 @@ void scsi_host_put(struct Scsi_Host *shost)
/**
- * scsi_partsize - parse partition table into cylinders, heads + sectors
- * @buf: pointer to partition table
- * @capacity: size of (total) disk in 512 byte sectors
- * @cyls: outputs number of cylinders calculated via this pointer
- * @hds: outputs number of heads calculated via this pointer
- * @secs: outputs number of sectors calculated via this pointer
- *
- * Returns 0 on success, -1 on failure
- *
- * Might block: no
- *
- * Notes: Caller owns memory returned (free with kfree() )
- *
- * Defined in: drivers/scsi/scsicam.c
- **/
-int scsi_partsize(unsigned char *buf, unsigned long capacity,
- unsigned int *cyls, unsigned int *hds, unsigned int *secs)
-
-
-/**
* scsi_register - create and register a scsi host adapter instance.
* @sht: pointer to scsi host template
* @privsize: extra bytes to allocate in hostdata array (which is the

arch/m68k/emu/nfblock.c

View file
diff --git a/arch/m68k/emu/nfblock.c b/arch/m68k/emu/nfblock.c
index 40712e4..c3a6304 100644
--- a/arch/m68k/emu/nfblock.c
+++ b/arch/m68k/emu/nfblock.c
@@ -118,12 +118,11 @@ static int __init nfhd_init_one(int id, u32 blocks, u32 bsize)
dev->bsize = bsize;
dev->bshift = ffs(bsize) - 10;
- dev->queue = blk_alloc_queue(GFP_KERNEL);
+ dev->queue = blk_alloc_queue(nfhd_make_request, NUMA_NO_NODE);
if (dev->queue == NULL)
goto free_dev;
dev->queue->queuedata = dev;
- blk_queue_make_request(dev->queue, nfhd_make_request);
blk_queue_logical_block_size(dev->queue, bsize);
dev->disk = alloc_disk(16);

arch/xtensa/platforms/iss/simdisk.c

View file
diff --git a/arch/xtensa/platforms/iss/simdisk.c b/arch/xtensa/platforms/iss/simdisk.c
index 8331098..49322b6 100644
--- a/arch/xtensa/platforms/iss/simdisk.c
+++ b/arch/xtensa/platforms/iss/simdisk.c
@@ -267,13 +267,12 @@ static int __init simdisk_setup(struct simdisk *dev, int which,
spin_lock_init(&dev->lock);
dev->users = 0;
- dev->queue = blk_alloc_queue(GFP_KERNEL);
+ dev->queue = blk_alloc_queue(simdisk_make_request, NUMA_NO_NODE);
if (dev->queue == NULL) {
pr_err("blk_alloc_queue failed\n");
goto out_alloc_queue;
}
- blk_queue_make_request(dev->queue, simdisk_make_request);
dev->queue->queuedata = dev;
dev->gd = alloc_disk(SIMDISK_MINORS);

block/Makefile

View file
diff --git a/block/Makefile b/block/Makefile
index 1a43750..206b96e 100644
--- a/block/Makefile
+++ b/block/Makefile
@@ -8,8 +8,7 @@ obj-$(CONFIG_BLOCK) := bio.o elevator.o blk-core.o blk-sysfs.o \
blk-exec.o blk-merge.o blk-softirq.o blk-timeout.o \
blk-lib.o blk-mq.o blk-mq-tag.o blk-stat.o \
blk-mq-sysfs.o blk-mq-cpumap.o blk-mq-sched.o ioctl.o \
- genhd.o partition-generic.o ioprio.o \
- badblocks.o partitions/ blk-rq-qos.o
+ genhd.o ioprio.o badblocks.o partitions/ blk-rq-qos.o
obj-$(CONFIG_BOUNCE) += bounce.o
obj-$(CONFIG_BLK_SCSI_REQUEST) += scsi_ioctl.o

block/bfq-cgroup.c

View file
diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c
index f0ff665..68882b9 100644
--- a/block/bfq-cgroup.c
+++ b/block/bfq-cgroup.c
@@ -642,6 +642,12 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,
{
struct bfq_entity *entity = &bfqq->entity;
+ /*
+ * Get extra reference to prevent bfqq from being freed in
+ * next possible expire or deactivate.
+ */
+ bfqq->ref++;
+
/* If bfqq is empty, then bfq_bfqq_expire also invokes
* bfq_del_bfqq_busy, thereby removing bfqq and its entity
* from data structures related to current group. Otherwise we
@@ -652,12 +658,6 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,
bfq_bfqq_expire(bfqd, bfqd->in_service_queue,
false, BFQQE_PREEMPTED);
- /*
- * get extra reference to prevent bfqq from being freed in
- * next possible deactivate
- */
- bfqq->ref++;
-
if (bfq_bfqq_busy(bfqq))
bfq_deactivate_bfqq(bfqd, bfqq, false, false);
else if (entity->on_st_or_in_serv)
@@ -677,7 +677,7 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,
if (!bfqd->in_service_queue && !bfqd->rq_in_driver)
bfq_schedule_dispatch(bfqd);
- /* release extra ref taken above */
+ /* release extra ref taken above, bfqq may happen to be freed now */
bfq_put_queue(bfqq);
}
@@ -714,10 +714,7 @@ static struct bfq_group *__bfq_bic_change_cgroup(struct bfq_data *bfqd,
if (entity->sched_data != &bfqg->sched_data) {
bic_set_bfqq(bic, NULL, 0);
- bfq_log_bfqq(bfqd, async_bfqq,
- "bic_change_group: %p %d",
- async_bfqq, async_bfqq->ref);
- bfq_put_queue(async_bfqq);
+ bfq_release_process_ref(bfqd, async_bfqq);
}
}
@@ -818,39 +815,53 @@ static void bfq_flush_idle_tree(struct bfq_service_tree *st)
/**
* bfq_reparent_leaf_entity - move leaf entity to the root_group.
* @bfqd: the device data structure with the root group.
- * @entity: the entity to move.
+ * @entity: the entity to move, if entity is a leaf; or the parent entity
+ * of an active leaf entity to move, if entity is not a leaf.
*/
static void bfq_reparent_leaf_entity(struct bfq_data *bfqd,
- struct bfq_entity *entity)
+ struct bfq_entity *entity,
+ int ioprio_class)
{
- struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity);
+ struct bfq_queue *bfqq;
+ struct bfq_entity *child_entity = entity;
+ while (child_entity->my_sched_data) { /* leaf not reached yet */
+ struct bfq_sched_data *child_sd = child_entity->my_sched_data;
+ struct bfq_service_tree *child_st = child_sd->service_tree +
+ ioprio_class;
+ struct rb_root *child_active = &child_st->active;
+
+ child_entity = bfq_entity_of(rb_first(child_active));
+
+ if (!child_entity)
+ child_entity = child_sd->in_service_entity;
+ }
+
+ bfqq = bfq_entity_to_bfqq(child_entity);
bfq_bfqq_move(bfqd, bfqq, bfqd->root_group);
}
/**
- * bfq_reparent_active_entities - move to the root group all active
- * entities.
+ * bfq_reparent_active_queues - move to the root group all active queues.
* @bfqd: the device data structure with the root group.
* @bfqg: the group to move from.
- * @st: the service tree with the entities.
+ * @st: the service tree to start the search from.
*/
-static void bfq_reparent_active_entities(struct bfq_data *bfqd,
- struct bfq_group *bfqg,
- struct bfq_service_tree *st)
+static void bfq_reparent_active_queues(struct bfq_data *bfqd,
+ struct bfq_group *bfqg,
+ struct bfq_service_tree *st,
+ int ioprio_class)
{
struct rb_root *active = &st->active;
- struct bfq_entity *entity = NULL;
-
- if (!RB_EMPTY_ROOT(&st->active))
- entity = bfq_entity_of(rb_first(active));
+ struct bfq_entity *entity;
- for (; entity ; entity = bfq_entity_of(rb_first(active)))
- bfq_reparent_leaf_entity(bfqd, entity);
+ while ((entity = bfq_entity_of(rb_first(active))))
+ bfq_reparent_leaf_entity(bfqd, entity, ioprio_class);
if (bfqg->sched_data.in_service_entity)
bfq_reparent_leaf_entity(bfqd,
- bfqg->sched_data.in_service_entity);
+ bfqg->sched_data.in_service_entity,
+ ioprio_class);
}
/**
@@ -883,13 +894,6 @@ static void bfq_pd_offline(struct blkg_policy_data *pd)
st = bfqg->sched_data.service_tree + i;
/*
- * The idle tree may still contain bfq_queues belonging
- * to exited task because they never migrated to a different
- * cgroup from the one being destroyed now.
- */
- bfq_flush_idle_tree(st);
-
- /*
* It may happen that some queues are still active
* (busy) upon group destruction (if the corresponding
* processes have been forced to terminate). We move
@@ -901,7 +905,20 @@ static void bfq_pd_offline(struct blkg_policy_data *pd)
* There is no need to put the sync queues, as the
* scheduler has taken no reference.
*/
- bfq_reparent_active_entities(bfqd, bfqg, st);
+ bfq_reparent_active_queues(bfqd, bfqg, st, i);
+
+ /*
+ * The idle tree may still contain bfq_queues
+ * belonging to exited task because they never
+ * migrated to a different cgroup from the one being
+ * destroyed now. In addition, even
+ * bfq_reparent_active_queues() may happen to add some
+ * entities to the idle tree. It happens if, in some
+ * of the calls to bfq_bfqq_move() performed by
+ * bfq_reparent_active_queues(), the queue to move is
+ * empty and gets expired.
+ */
+ bfq_flush_idle_tree(st);
}
__bfq_deactivate_entity(entity, false);

block/bfq-iosched.c

View file
diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index 8c436ab..78ba57e 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -2716,8 +2716,6 @@ static void bfq_bfqq_save_state(struct bfq_queue *bfqq)
}
}
-
-static
void bfq_release_process_ref(struct bfq_data *bfqd, struct bfq_queue *bfqq)
{
/*
@@ -6215,20 +6213,28 @@ static struct bfq_queue *bfq_init_rq(struct request *rq)
return bfqq;
}
-static void bfq_idle_slice_timer_body(struct bfq_queue *bfqq)
+static void
+bfq_idle_slice_timer_body(struct bfq_data *bfqd, struct bfq_queue *bfqq)
{
- struct bfq_data *bfqd = bfqq->bfqd;
enum bfqq_expiration reason;
unsigned long flags;
spin_lock_irqsave(&bfqd->lock, flags);
- bfq_clear_bfqq_wait_request(bfqq);
+ /*
+ * Considering that bfqq may be in race, we should firstly check
+ * whether bfqq is in service before doing something on it. If
+ * the bfqq in race is not in service, it has already been expired
+ * through __bfq_bfqq_expire func and its wait_request flags has
+ * been cleared in __bfq_bfqd_reset_in_service func.
+ */
if (bfqq != bfqd->in_service_queue) {
spin_unlock_irqrestore(&bfqd->lock, flags);
return;
}
+ bfq_clear_bfqq_wait_request(bfqq);
+
if (bfq_bfqq_budget_timeout(bfqq))
/*
* Also here the queue can be safely expired
@@ -6273,7 +6279,7 @@ static enum hrtimer_restart bfq_idle_slice_timer(struct hrtimer *timer)
* early.
*/
if (bfqq)
- bfq_idle_slice_timer_body(bfqq);
+ bfq_idle_slice_timer_body(bfqd, bfqq);
return HRTIMER_NORESTART;
}

block/bfq-iosched.h

View file
diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
index d1233af..cd224aa 100644
--- a/block/bfq-iosched.h
+++ b/block/bfq-iosched.h
@@ -955,6 +955,7 @@ void bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq,
bool compensate, enum bfqq_expiration reason);
void bfq_put_queue(struct bfq_queue *bfqq);
void bfq_end_wr_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg);
+void bfq_release_process_ref(struct bfq_data *bfqd, struct bfq_queue *bfqq);
void bfq_schedule_dispatch(struct bfq_data *bfqd);
void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg);

block/bio.c

View file
diff --git a/block/bio.c b/block/bio.c
index 94d6972..21cbaa6 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -17,6 +17,7 @@
#include <linux/cgroup.h>
#include <linux/blk-cgroup.h>
#include <linux/highmem.h>
+#include <linux/sched/sysctl.h>
#include <trace/events/block.h>
#include "blk.h"
@@ -588,6 +589,49 @@ void bio_truncate(struct bio *bio, unsigned new_size)
}
/**
+ * guard_bio_eod - truncate a BIO to fit the block device
+ * @bio: bio to truncate
+ *
+ * This allows us to do IO even on the odd last sectors of a device, even if the
+ * block size is some multiple of the physical sector size.
+ *
+ * We'll just truncate the bio to the size of the device, and clear the end of
+ * the buffer head manually. Truly out-of-range accesses will turn into actual
+ * I/O errors, this only handles the "we need to be able to do I/O at the final
+ * sector" case.
+ */
+void guard_bio_eod(struct bio *bio)
+{
+ sector_t maxsector;
+ struct hd_struct *part;
+
+ rcu_read_lock();
+ part = __disk_get_part(bio->bi_disk, bio->bi_partno);
+ if (part)
+ maxsector = part_nr_sects_read(part);
+ else
+ maxsector = get_capacity(bio->bi_disk);
+ rcu_read_unlock();
+
+ if (!maxsector)
+ return;
+
+ /*
+ * If the *whole* IO is past the end of the device,
+ * let it through, and the IO layer will turn it into
+ * an EIO.
+ */
+ if (unlikely(bio->bi_iter.bi_sector >= maxsector))
+ return;
+
+ maxsector -= bio->bi_iter.bi_sector;
+ if (likely((bio->bi_iter.bi_size >> 9) <= maxsector))
+ return;
+
+ bio_truncate(bio, maxsector << 9);
+}
+
+/**
* bio_put - release a reference to a bio
* @bio: bio to release reference to
*
@@ -679,6 +723,12 @@ struct bio *bio_clone_fast(struct bio *bio, gfp_t gfp_mask, struct bio_set *bs)
}
EXPORT_SYMBOL(bio_clone_fast);
+const char *bio_devname(struct bio *bio, char *buf)
+{
+ return disk_name(bio->bi_disk, bio->bi_partno, buf);
+}
+EXPORT_SYMBOL(bio_devname);
+
static inline bool page_is_mergeable(const struct bio_vec *bv,
struct page *page, unsigned int len, unsigned int off,
bool *same_page)
@@ -730,7 +780,7 @@ static bool bio_try_merge_pc_page(struct request_queue *q, struct bio *bio,
*
* This should only be used by passthrough bios.
*/
-static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
+int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
struct page *page, unsigned int len, unsigned int offset,
bool *same_page)
{
@@ -1019,12 +1069,21 @@ static void submit_bio_wait_endio(struct bio *bio)
int submit_bio_wait(struct bio *bio)
{
DECLARE_COMPLETION_ONSTACK_MAP(done, bio->bi_disk->lockdep_map);
+ unsigned long hang_check;
bio->bi_private = &done;
bio->bi_end_io = submit_bio_wait_endio;
bio->bi_opf |= REQ_SYNC;
submit_bio(bio);
- wait_for_completion_io(&done);
+
+ /* Prevent hang_check timer from firing at us during very long I/O */
+ hang_check = sysctl_hung_task_timeout_secs;
+ if (hang_check)
+ while (!wait_for_completion_io_timeout(&done,
+ hang_check * (HZ/2)))
+ ;
+ else
+ wait_for_completion_io(&done);
return blk_status_to_errno(bio->bi_status);
}
@@ -1135,90 +1194,6 @@ void bio_list_copy_data(struct bio *dst, struct bio *src)
}
EXPORT_SYMBOL(bio_list_copy_data);
-struct bio_map_data {
- int is_our_pages;
- struct iov_iter iter;
- struct iovec iov[];
-};
-
-static struct bio_map_data *bio_alloc_map_data(struct iov_iter *data,
- gfp_t gfp_mask)
-{
- struct bio_map_data *bmd;
- if (data->nr_segs > UIO_MAXIOV)
- return NULL;
-
- bmd = kmalloc(struct_size(bmd, iov, data->nr_segs), gfp_mask);
- if (!bmd)
- return NULL;
- memcpy(bmd->iov, data->iov, sizeof(struct iovec) * data->nr_segs);
- bmd->iter = *data;
- bmd->iter.iov = bmd->iov;
- return bmd;
-}
-
-/**
- * bio_copy_from_iter - copy all pages from iov_iter to bio
- * @bio: The &struct bio which describes the I/O as destination
- * @iter: iov_iter as source
- *
- * Copy all pages from iov_iter to bio.
- * Returns 0 on success, or error on failure.
- */
-static int bio_copy_from_iter(struct bio *bio, struct iov_iter *iter)
-{
- struct bio_vec *bvec;
- struct bvec_iter_all iter_all;
-
- bio_for_each_segment_all(bvec, bio, iter_all) {
- ssize_t ret;
-
- ret = copy_page_from_iter(bvec->bv_page,
- bvec->bv_offset,
- bvec->bv_len,
- iter);
-
- if (!iov_iter_count(iter))
- break;
-
- if (ret < bvec->bv_len)
- return -EFAULT;
- }
-
- return 0;
-}
-
-/**
- * bio_copy_to_iter - copy all pages from bio to iov_iter
- * @bio: The &struct bio which describes the I/O as source
- * @iter: iov_iter as destination
- *
- * Copy all pages from bio to iov_iter.
- * Returns 0 on success, or error on failure.
- */
-static int bio_copy_to_iter(struct bio *bio, struct iov_iter iter)
-{
- struct bio_vec *bvec;
- struct bvec_iter_all iter_all;
-
- bio_for_each_segment_all(bvec, bio, iter_all) {
- ssize_t ret;
-
- ret = copy_page_to_iter(bvec->bv_page,
- bvec->bv_offset,
- bvec->bv_len,
- &iter);
-
- if (!iov_iter_count(&iter))
- break;
-
- if (ret < bvec->bv_len)
- return -EFAULT;
- }
-
- return 0;
-}
-
void bio_free_pages(struct bio *bio)
{
struct bio_vec *bvec;
@@ -1229,430 +1204,6 @@ void bio_free_pages(struct bio *bio)
}
EXPORT_SYMBOL(bio_free_pages);
-/**
- * bio_uncopy_user - finish previously mapped bio
- * @bio: bio being terminated
- *
- * Free pages allocated from bio_copy_user_iov() and write back data
- * to user space in case of a read.
- */
-int bio_uncopy_user(struct bio *bio)
-{
- struct bio_map_data *bmd = bio->bi_private;
- int ret = 0;
-
- if (!bio_flagged(bio, BIO_NULL_MAPPED)) {
- /*
- * if we're in a workqueue, the request is orphaned, so
- * don't copy into a random user address space, just free
- * and return -EINTR so user space doesn't expect any data.
- */
- if (!current->mm)
- ret = -EINTR;
- else if (bio_data_dir(bio) == READ)
- ret = bio_copy_to_iter(bio, bmd->iter);
- if (bmd->is_our_pages)
- bio_free_pages(bio);
- }
- kfree(bmd);
- bio_put(bio);
- return ret;
-}
-
-/**
- * bio_copy_user_iov - copy user data to bio
- * @q: destination block queue
- * @map_data: pointer to the rq_map_data holding pages (if necessary)
- * @iter: iovec iterator
- * @gfp_mask: memory allocation flags

This diff is incomplete. Download the complete patch.

block/blk-cgroup.c

View file

This diff is incomplete. Download the complete patch.

block/blk-core.c

View file

This diff is incomplete. Download the complete patch.

block/blk-flush.c

View file

This diff is incomplete. Download the complete patch.

block/blk-ioc.c

View file

This diff is incomplete. Download the complete patch.

block/blk-iocost.c

View file

This diff is incomplete. Download the complete patch.

block/blk-map.c

View file

This diff is incomplete. Download the complete patch.

block/blk-mq.c

View file

This diff is incomplete. Download the complete patch.

block/blk-settings.c

View file

This diff is incomplete. Download the complete patch.

block/blk-zoned.c

View file

This diff is incomplete. Download the complete patch.

block/blk.h

View file

This diff is incomplete. Download the complete patch.

block/genhd.c

View file

This diff is incomplete. Download the complete patch.

block/ioctl.c

View file

This diff is incomplete. Download the complete patch.

block/opal_proto.h

View file

This diff is incomplete. Download the complete patch.

block/partition-generic.c

View before deletion

This diff is incomplete. Download the complete patch.

block/partitions/Makefile

View file

This diff is incomplete. Download the complete patch.

block/partitions/acorn.c

View file

This diff is incomplete. Download the complete patch.

block/partitions/acorn.h

View before deletion

This diff is incomplete. Download the complete patch.

block/partitions/aix.c

View file

This diff is incomplete. Download the complete patch.

block/partitions/amiga.c

View file

This diff is incomplete. Download the complete patch.

block/partitions/amiga.h

View before deletion

This diff is incomplete. Download the complete patch.

block/partitions/atari.h

View file

This diff is incomplete. Download the complete patch.

block/partitions/check.c

View before deletion

This diff is incomplete. Download the complete patch.

block/partitions/check.h

View file

This diff is incomplete. Download the complete patch.

block/partitions/cmdline.c

View file

This diff is incomplete. Download the complete patch.

block/partitions/cmdline.h

View before deletion

This diff is incomplete. Download the complete patch.

block/partitions/core.c

View file

This diff is incomplete. Download the complete patch.

block/partitions/efi.h

View file

This diff is incomplete. Download the complete patch.

block/partitions/ibm.c

View file

This diff is incomplete. Download the complete patch.

block/partitions/ibm.h

View before deletion

This diff is incomplete. Download the complete patch.

block/partitions/karma.c

View file

This diff is incomplete. Download the complete patch.

block/partitions/karma.h

View before deletion

This diff is incomplete. Download the complete patch.

block/partitions/ldm.c

View file

This diff is incomplete. Download the complete patch.

block/partitions/ldm.h

View file

This diff is incomplete. Download the complete patch.

block/partitions/mac.h

View file

This diff is incomplete. Download the complete patch.

block/partitions/msdos.c

View file

This diff is incomplete. Download the complete patch.

block/partitions/msdos.h

View before deletion

This diff is incomplete. Download the complete patch.

block/partitions/osf.c

View file

This diff is incomplete. Download the complete patch.

block/partitions/osf.h

View before deletion

This diff is incomplete. Download the complete patch.

block/partitions/sgi.c

View file

This diff is incomplete. Download the complete patch.

block/partitions/sgi.h

View before deletion

This diff is incomplete. Download the complete patch.

block/partitions/sun.c

View file

This diff is incomplete. Download the complete patch.

block/partitions/sun.h

View before deletion

This diff is incomplete. Download the complete patch.

block/partitions/sysv68.c

View file

This diff is incomplete. Download the complete patch.

block/partitions/sysv68.h

View before deletion

This diff is incomplete. Download the complete patch.

block/partitions/ultrix.c

View file

This diff is incomplete. Download the complete patch.

block/partitions/ultrix.h

View before deletion

This diff is incomplete. Download the complete patch.

block/sed-opal.c

View file

This diff is incomplete. Download the complete patch.

drivers/block/brd.c

View file

This diff is incomplete. Download the complete patch.

drivers/block/drbd/drbd_main.c

View file

This diff is incomplete. Download the complete patch.

drivers/block/drbd/drbd_receiver.c

View file

This diff is incomplete. Download the complete patch.

drivers/block/drbd/drbd_worker.c

View file

This diff is incomplete. Download the complete patch.

drivers/block/null_blk_main.c

View file

This diff is incomplete. Download the complete patch.

drivers/block/pktcdvd.c

View file

This diff is incomplete. Download the complete patch.

drivers/block/ps3vram.c

View file

This diff is incomplete. Download the complete patch.

drivers/block/rsxx/dev.c

View file

This diff is incomplete. Download the complete patch.

drivers/block/umem.c

View file

This diff is incomplete. Download the complete patch.

drivers/block/virtio_blk.c

View file

This diff is incomplete. Download the complete patch.

drivers/block/xen-blkfront.c

View file

This diff is incomplete. Download the complete patch.

drivers/block/zram/zram_drv.c

View file

This diff is incomplete. Download the complete patch.

drivers/lightnvm/core.c

View file

This diff is incomplete. Download the complete patch.

drivers/md/bcache/request.c

View file

This diff is incomplete. Download the complete patch.

drivers/md/bcache/request.h

View file

This diff is incomplete. Download the complete patch.

drivers/md/bcache/super.c

View file

This diff is incomplete. Download the complete patch.

drivers/md/dm.c

View file

This diff is incomplete. Download the complete patch.

drivers/md/md.c

View file

This diff is incomplete. Download the complete patch.

drivers/nvdimm/blk.c

View file

This diff is incomplete. Download the complete patch.

drivers/nvdimm/btt.c

View file

This diff is incomplete. Download the complete patch.

drivers/nvdimm/pmem.c

View file

This diff is incomplete. Download the complete patch.

drivers/nvme/host/core.c

View file

This diff is incomplete. Download the complete patch.

drivers/nvme/host/multipath.c

View file

This diff is incomplete. Download the complete patch.

drivers/nvme/target/admin-cmd.c

View file

This diff is incomplete. Download the complete patch.

drivers/s390/block/dcssblk.c

View file

This diff is incomplete. Download the complete patch.

drivers/s390/block/xpram.c

View file

This diff is incomplete. Download the complete patch.

drivers/scsi/BusLogic.c

View file

This diff is incomplete. Download the complete patch.

drivers/scsi/aacraid/linit.c

View file

This diff is incomplete. Download the complete patch.

drivers/scsi/aic7xxx/aic79xx_osm.c

View file

This diff is incomplete. Download the complete patch.

drivers/scsi/aic7xxx/aic7xxx_osm.c

View file

This diff is incomplete. Download the complete patch.

drivers/scsi/arcmsr/arcmsr_hba.c

View file

This diff is incomplete. Download the complete patch.

drivers/scsi/megaraid.c

View file

This diff is incomplete. Download the complete patch.

drivers/scsi/scsi_debug.c

View file

This diff is incomplete. Download the complete patch.

drivers/scsi/scsicam.c

View file

This diff is incomplete. Download the complete patch.

drivers/scsi/sd.c

View file

This diff is incomplete. Download the complete patch.

fs/block_dev.c

View file

This diff is incomplete. Download the complete patch.

fs/buffer.c

View file

This diff is incomplete. Download the complete patch.

fs/ext4/super.c

View file

This diff is incomplete. Download the complete patch.

fs/ext4/sysfs.c

View file

This diff is incomplete. Download the complete patch.

fs/f2fs/f2fs.h

View file

This diff is incomplete. Download the complete patch.

fs/f2fs/super.c

View file

This diff is incomplete. Download the complete patch.

fs/internal.h

View file

This diff is incomplete. Download the complete patch.

fs/reiserfs/journal.c

View file

This diff is incomplete. Download the complete patch.

include/linux/bio.h

View file

This diff is incomplete. Download the complete patch.

include/linux/blk-mq.h

View file

This diff is incomplete. Download the complete patch.

include/linux/blkdev.h

View file

This diff is incomplete. Download the complete patch.

include/linux/fs.h

View file

This diff is incomplete. Download the complete patch.

include/linux/genhd.h

View file

This diff is incomplete. Download the complete patch.

include/linux/iocontext.h

View file

This diff is incomplete. Download the complete patch.

include/linux/msdos_partition.h

View file

This diff is incomplete. Download the complete patch.

include/linux/part_stat.h

View file

This diff is incomplete. Download the complete patch.

include/linux/raid/detect.h

View file

This diff is incomplete. Download the complete patch.

include/scsi/scsicam.h

View file

This diff is incomplete. Download the complete patch.

init/do_mounts.c

View file

This diff is incomplete. Download the complete patch.