Skip to content

Commit f74cd63

Browse files
committed
Merge branch 'for-3.19/core' into for-3.19/drivers
2 parents c78b471 + 394ffa5 commit f74cd63

File tree

4 files changed

+52
-23
lines changed

4 files changed

+52
-23
lines changed

block/bio.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,6 +1739,34 @@ void bio_check_pages_dirty(struct bio *bio)
17391739
}
17401740
}
17411741

1742+
void generic_start_io_acct(int rw, unsigned long sectors,
1743+
struct hd_struct *part)
1744+
{
1745+
int cpu = part_stat_lock();
1746+
1747+
part_round_stats(cpu, part);
1748+
part_stat_inc(cpu, part, ios[rw]);
1749+
part_stat_add(cpu, part, sectors[rw], sectors);
1750+
part_inc_in_flight(part, rw);
1751+
1752+
part_stat_unlock();
1753+
}
1754+
EXPORT_SYMBOL(generic_start_io_acct);
1755+
1756+
void generic_end_io_acct(int rw, struct hd_struct *part,
1757+
unsigned long start_time)
1758+
{
1759+
unsigned long duration = jiffies - start_time;
1760+
int cpu = part_stat_lock();
1761+
1762+
part_stat_add(cpu, part, ticks[rw], duration);
1763+
part_round_stats(cpu, part);
1764+
part_dec_in_flight(part, rw);
1765+
1766+
part_stat_unlock();
1767+
}
1768+
EXPORT_SYMBOL(generic_end_io_acct);
1769+
17421770
#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
17431771
void bio_flush_dcache_pages(struct bio *bi)
17441772
{

block/blk-mq.c

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -798,20 +798,23 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
798798
*/
799799
static int blk_mq_hctx_next_cpu(struct blk_mq_hw_ctx *hctx)
800800
{
801-
int cpu = hctx->next_cpu;
801+
if (hctx->queue->nr_hw_queues == 1)
802+
return WORK_CPU_UNBOUND;
802803

803804
if (--hctx->next_cpu_batch <= 0) {
804-
int next_cpu;
805+
int cpu = hctx->next_cpu, next_cpu;
805806

806807
next_cpu = cpumask_next(hctx->next_cpu, hctx->cpumask);
807808
if (next_cpu >= nr_cpu_ids)
808809
next_cpu = cpumask_first(hctx->cpumask);
809810

810811
hctx->next_cpu = next_cpu;
811812
hctx->next_cpu_batch = BLK_MQ_CPU_WORK_BATCH;
813+
814+
return cpu;
812815
}
813816

814-
return cpu;
817+
return hctx->next_cpu;
815818
}
816819

817820
void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async)
@@ -830,14 +833,8 @@ void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async)
830833
put_cpu();
831834
}
832835

833-
if (hctx->queue->nr_hw_queues == 1)
834-
kblockd_schedule_delayed_work(&hctx->run_work, 0);
835-
else {
836-
unsigned int cpu;
837-
838-
cpu = blk_mq_hctx_next_cpu(hctx);
839-
kblockd_schedule_delayed_work_on(cpu, &hctx->run_work, 0);
840-
}
836+
kblockd_schedule_delayed_work_on(blk_mq_hctx_next_cpu(hctx),
837+
&hctx->run_work, 0);
841838
}
842839

843840
void blk_mq_run_queues(struct request_queue *q, bool async)
@@ -929,16 +926,8 @@ static void blk_mq_delay_work_fn(struct work_struct *work)
929926

930927
void blk_mq_delay_queue(struct blk_mq_hw_ctx *hctx, unsigned long msecs)
931928
{
932-
unsigned long tmo = msecs_to_jiffies(msecs);
933-
934-
if (hctx->queue->nr_hw_queues == 1)
935-
kblockd_schedule_delayed_work(&hctx->delay_work, tmo);
936-
else {
937-
unsigned int cpu;
938-
939-
cpu = blk_mq_hctx_next_cpu(hctx);
940-
kblockd_schedule_delayed_work_on(cpu, &hctx->delay_work, tmo);
941-
}
929+
kblockd_schedule_delayed_work_on(blk_mq_hctx_next_cpu(hctx),
930+
&hctx->delay_work, msecs_to_jiffies(msecs));
942931
}
943932
EXPORT_SYMBOL(blk_mq_delay_queue);
944933

block/genhd.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,9 +1070,16 @@ int disk_expand_part_tbl(struct gendisk *disk, int partno)
10701070
struct disk_part_tbl *old_ptbl = disk->part_tbl;
10711071
struct disk_part_tbl *new_ptbl;
10721072
int len = old_ptbl ? old_ptbl->len : 0;
1073-
int target = partno + 1;
1073+
int i, target;
10741074
size_t size;
1075-
int i;
1075+
1076+
/*
1077+
* check for int overflow, since we can get here from blkpg_ioctl()
1078+
* with a user passed 'partno'.
1079+
*/
1080+
target = partno + 1;
1081+
if (target < 0)
1082+
return -EINVAL;
10761083

10771084
/* disk_max_parts() is zero during initialization, ignore if so */
10781085
if (disk_max_parts(disk) && target > disk_max_parts(disk))

include/linux/bio.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,11 @@ extern struct bio *bio_copy_kern(struct request_queue *, void *, unsigned int,
443443
extern void bio_set_pages_dirty(struct bio *bio);
444444
extern void bio_check_pages_dirty(struct bio *bio);
445445

446+
void generic_start_io_acct(int rw, unsigned long sectors,
447+
struct hd_struct *part);
448+
void generic_end_io_acct(int rw, struct hd_struct *part,
449+
unsigned long start_time);
450+
446451
#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
447452
# error "You should define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE for your platform"
448453
#endif

0 commit comments

Comments
 (0)