mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 14:42:24 +00:00
360f92c244
Martin reported that his test system would not boot with
current git, it oopsed with this:
BUG: unable to handle kernel paging request at ffff88046c6c9e80
IP: [<ffffffff812971e0>] blk_queue_start_tag+0x90/0x150
PGD 1ddf067 PUD 1de2067 PMD 47fc7d067 PTE 800000046c6c9060
Oops: 0002 [#1] SMP DEBUG_PAGEALLOC
Modules linked in: sd_mod lpfc(+) scsi_transport_fc scsi_tgt oracleasm
rpcsec_gss_krb5 ipv6 igb dca i2c_algo_bit i2c_core hwmon
CPU: 3 PID: 87 Comm: kworker/u17:1 Not tainted 3.14.0+ #246
Hardware name: Supermicro X9DRX+-F/X9DRX+-F, BIOS 3.00 07/09/2013
Workqueue: events_unbound async_run_entry_fn
task: ffff8802743c2150 ti: ffff880273d02000 task.ti: ffff880273d02000
RIP: 0010:[<ffffffff812971e0>] [<ffffffff812971e0>]
blk_queue_start_tag+0x90/0x150
RSP: 0018:ffff880273d03a58 EFLAGS: 00010092
RAX: ffff88046c6c9e78 RBX: ffff880077208e78 RCX: 00000000fffc8da6
RDX: 00000000fffc186d RSI: 0000000000000009 RDI: 00000000fffc8d9d
RBP: ffff880273d03a88 R08: 0000000000000001 R09: ffff8800021c2410
R10: 0000000000000005 R11: 0000000000015b30 R12: ffff88046c5bb8a0
R13: ffff88046c5c0890 R14: 000000000000001e R15: 000000000000001e
FS: 0000000000000000(0000) GS:ffff880277b00000(0000)
knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffff88046c6c9e80 CR3: 00000000018f6000 CR4: 00000000000407e0
Stack:
ffff880273d03a98 ffff880474b18800 0000000000000000 ffff880474157000
ffff88046c5c0890 ffff880077208e78 ffff880273d03ae8 ffffffff813b9e62
ffff880200000010 ffff880474b18968 ffff880474b18848 ffff88046c5c0cd8
Call Trace:
[<ffffffff813b9e62>] scsi_request_fn+0xf2/0x510
[<ffffffff81293167>] __blk_run_queue+0x37/0x50
[<ffffffff8129ac43>] blk_execute_rq_nowait+0xb3/0x130
[<ffffffff8129ad24>] blk_execute_rq+0x64/0xf0
[<ffffffff8108d2b0>] ? bit_waitqueue+0xd0/0xd0
[<ffffffff813bba35>] scsi_execute+0xe5/0x180
[<ffffffff813bbe4a>] scsi_execute_req_flags+0x9a/0x110
[<ffffffffa01b1304>] sd_spinup_disk+0x94/0x460 [sd_mod]
[<ffffffff81160000>] ? __unmap_hugepage_range+0x200/0x2f0
[<ffffffffa01b2b9a>] sd_revalidate_disk+0xaa/0x3f0 [sd_mod]
[<ffffffffa01b2fb8>] sd_probe_async+0xd8/0x200 [sd_mod]
[<ffffffff8107703f>] async_run_entry_fn+0x3f/0x140
[<ffffffff8106a1c5>] process_one_work+0x175/0x410
[<ffffffff8106b373>] worker_thread+0x123/0x400
[<ffffffff8106b250>] ? manage_workers+0x160/0x160
[<ffffffff8107104e>] kthread+0xce/0xf0
[<ffffffff81070f80>] ? kthread_freezable_should_stop+0x70/0x70
[<ffffffff815f0bac>] ret_from_fork+0x7c/0xb0
[<ffffffff81070f80>] ? kthread_freezable_should_stop+0x70/0x70
Code: 48 0f ab 11 72 db 48 81 4b 40 00 00 10 00 89 83 08 01 00 00 48 89
df 49 8b 04 24 48 89 1c d0 e8 f7 a8 ff ff 49 8b 85 28 05 00 00 <48> 89
58 08 48 89 03 49 8d 85 28 05 00 00 48 89 43 08 49 89 9d
RIP [<ffffffff812971e0>] blk_queue_start_tag+0x90/0x150
RSP <ffff880273d03a58>
CR2: ffff88046c6c9e80
Martin bisected and found this to be the problem patch;
commit 6d113398dc
Author: Jan Kara <jack@suse.cz>
Date: Mon Feb 24 16:39:54 2014 +0100
block: Stop abusing rq->csd.list in blk-softirq
and the problem was immediately apparent. The patch states that
it is safe to reuse queuelist at completion time, since it is
no longer used. However, that is not true if a device is using
block enabled tagging. If that is the case, then the queuelist
is reused to keep track of busy tags. If a device also ended
up using softirq completions, we'd reuse ->queuelist for the
IPI handling while block tagging was still using it. Boom.
Fix this by adding a new ipi_list list head, and share the
memory used with the request hash table. The hash table is
never used after the request is moved to the dispatch list,
which happens long before any potential completion of the
request. Add a new request bit for this, so we don't have
cases that check rq->hash while it could potentially have
been reused for the IPI completion.
Reported-by: Martin K. Petersen <martin.petersen@oracle.com>
Tested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Jens Axboe <axboe@fb.com>
252 lines
7.8 KiB
C
252 lines
7.8 KiB
C
#ifndef BLK_INTERNAL_H
|
|
#define BLK_INTERNAL_H
|
|
|
|
#include <linux/idr.h>
|
|
|
|
/* Amount of time in which a process may batch requests */
|
|
#define BLK_BATCH_TIME (HZ/50UL)
|
|
|
|
/* Number of requests a "batching" process may submit */
|
|
#define BLK_BATCH_REQ 32
|
|
|
|
extern struct kmem_cache *blk_requestq_cachep;
|
|
extern struct kmem_cache *request_cachep;
|
|
extern struct kobj_type blk_queue_ktype;
|
|
extern struct ida blk_queue_ida;
|
|
|
|
static inline void __blk_get_queue(struct request_queue *q)
|
|
{
|
|
kobject_get(&q->kobj);
|
|
}
|
|
|
|
int blk_init_rl(struct request_list *rl, struct request_queue *q,
|
|
gfp_t gfp_mask);
|
|
void blk_exit_rl(struct request_list *rl);
|
|
void init_request_from_bio(struct request *req, struct bio *bio);
|
|
void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
|
|
struct bio *bio);
|
|
int blk_rq_append_bio(struct request_queue *q, struct request *rq,
|
|
struct bio *bio);
|
|
void blk_queue_bypass_start(struct request_queue *q);
|
|
void blk_queue_bypass_end(struct request_queue *q);
|
|
void blk_dequeue_request(struct request *rq);
|
|
void __blk_queue_free_tags(struct request_queue *q);
|
|
bool __blk_end_bidi_request(struct request *rq, int error,
|
|
unsigned int nr_bytes, unsigned int bidi_bytes);
|
|
|
|
void blk_rq_timed_out_timer(unsigned long data);
|
|
void blk_rq_check_expired(struct request *rq, unsigned long *next_timeout,
|
|
unsigned int *next_set);
|
|
void __blk_add_timer(struct request *req, struct list_head *timeout_list);
|
|
void blk_delete_timer(struct request *);
|
|
void blk_add_timer(struct request *);
|
|
|
|
|
|
bool bio_attempt_front_merge(struct request_queue *q, struct request *req,
|
|
struct bio *bio);
|
|
bool bio_attempt_back_merge(struct request_queue *q, struct request *req,
|
|
struct bio *bio);
|
|
bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio,
|
|
unsigned int *request_count);
|
|
|
|
void blk_account_io_start(struct request *req, bool new_io);
|
|
void blk_account_io_completion(struct request *req, unsigned int bytes);
|
|
void blk_account_io_done(struct request *req);
|
|
|
|
/*
|
|
* Internal atomic flags for request handling
|
|
*/
|
|
enum rq_atomic_flags {
|
|
REQ_ATOM_COMPLETE = 0,
|
|
REQ_ATOM_STARTED,
|
|
};
|
|
|
|
/*
|
|
* EH timer and IO completion will both attempt to 'grab' the request, make
|
|
* sure that only one of them succeeds
|
|
*/
|
|
static inline int blk_mark_rq_complete(struct request *rq)
|
|
{
|
|
return test_and_set_bit(REQ_ATOM_COMPLETE, &rq->atomic_flags);
|
|
}
|
|
|
|
static inline void blk_clear_rq_complete(struct request *rq)
|
|
{
|
|
clear_bit(REQ_ATOM_COMPLETE, &rq->atomic_flags);
|
|
}
|
|
|
|
/*
|
|
* Internal elevator interface
|
|
*/
|
|
#define ELV_ON_HASH(rq) ((rq)->cmd_flags & REQ_HASHED)
|
|
|
|
void blk_insert_flush(struct request *rq);
|
|
void blk_abort_flushes(struct request_queue *q);
|
|
|
|
static inline struct request *__elv_next_request(struct request_queue *q)
|
|
{
|
|
struct request *rq;
|
|
|
|
while (1) {
|
|
if (!list_empty(&q->queue_head)) {
|
|
rq = list_entry_rq(q->queue_head.next);
|
|
return rq;
|
|
}
|
|
|
|
/*
|
|
* Flush request is running and flush request isn't queueable
|
|
* in the drive, we can hold the queue till flush request is
|
|
* finished. Even we don't do this, driver can't dispatch next
|
|
* requests and will requeue them. And this can improve
|
|
* throughput too. For example, we have request flush1, write1,
|
|
* flush 2. flush1 is dispatched, then queue is hold, write1
|
|
* isn't inserted to queue. After flush1 is finished, flush2
|
|
* will be dispatched. Since disk cache is already clean,
|
|
* flush2 will be finished very soon, so looks like flush2 is
|
|
* folded to flush1.
|
|
* Since the queue is hold, a flag is set to indicate the queue
|
|
* should be restarted later. Please see flush_end_io() for
|
|
* details.
|
|
*/
|
|
if (q->flush_pending_idx != q->flush_running_idx &&
|
|
!queue_flush_queueable(q)) {
|
|
q->flush_queue_delayed = 1;
|
|
return NULL;
|
|
}
|
|
if (unlikely(blk_queue_bypass(q)) ||
|
|
!q->elevator->type->ops.elevator_dispatch_fn(q, 0))
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
static inline void elv_activate_rq(struct request_queue *q, struct request *rq)
|
|
{
|
|
struct elevator_queue *e = q->elevator;
|
|
|
|
if (e->type->ops.elevator_activate_req_fn)
|
|
e->type->ops.elevator_activate_req_fn(q, rq);
|
|
}
|
|
|
|
static inline void elv_deactivate_rq(struct request_queue *q, struct request *rq)
|
|
{
|
|
struct elevator_queue *e = q->elevator;
|
|
|
|
if (e->type->ops.elevator_deactivate_req_fn)
|
|
e->type->ops.elevator_deactivate_req_fn(q, rq);
|
|
}
|
|
|
|
#ifdef CONFIG_FAIL_IO_TIMEOUT
|
|
int blk_should_fake_timeout(struct request_queue *);
|
|
ssize_t part_timeout_show(struct device *, struct device_attribute *, char *);
|
|
ssize_t part_timeout_store(struct device *, struct device_attribute *,
|
|
const char *, size_t);
|
|
#else
|
|
static inline int blk_should_fake_timeout(struct request_queue *q)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
int ll_back_merge_fn(struct request_queue *q, struct request *req,
|
|
struct bio *bio);
|
|
int ll_front_merge_fn(struct request_queue *q, struct request *req,
|
|
struct bio *bio);
|
|
int attempt_back_merge(struct request_queue *q, struct request *rq);
|
|
int attempt_front_merge(struct request_queue *q, struct request *rq);
|
|
int blk_attempt_req_merge(struct request_queue *q, struct request *rq,
|
|
struct request *next);
|
|
void blk_recalc_rq_segments(struct request *rq);
|
|
void blk_rq_set_mixed_merge(struct request *rq);
|
|
bool blk_rq_merge_ok(struct request *rq, struct bio *bio);
|
|
int blk_try_merge(struct request *rq, struct bio *bio);
|
|
|
|
void blk_queue_congestion_threshold(struct request_queue *q);
|
|
|
|
void __blk_run_queue_uncond(struct request_queue *q);
|
|
|
|
int blk_dev_init(void);
|
|
|
|
|
|
/*
|
|
* Return the threshold (number of used requests) at which the queue is
|
|
* considered to be congested. It include a little hysteresis to keep the
|
|
* context switch rate down.
|
|
*/
|
|
static inline int queue_congestion_on_threshold(struct request_queue *q)
|
|
{
|
|
return q->nr_congestion_on;
|
|
}
|
|
|
|
/*
|
|
* The threshold at which a queue is considered to be uncongested
|
|
*/
|
|
static inline int queue_congestion_off_threshold(struct request_queue *q)
|
|
{
|
|
return q->nr_congestion_off;
|
|
}
|
|
|
|
/*
|
|
* Contribute to IO statistics IFF:
|
|
*
|
|
* a) it's attached to a gendisk, and
|
|
* b) the queue had IO stats enabled when this request was started, and
|
|
* c) it's a file system request
|
|
*/
|
|
static inline int blk_do_io_stat(struct request *rq)
|
|
{
|
|
return rq->rq_disk &&
|
|
(rq->cmd_flags & REQ_IO_STAT) &&
|
|
(rq->cmd_type == REQ_TYPE_FS);
|
|
}
|
|
|
|
/*
|
|
* Internal io_context interface
|
|
*/
|
|
void get_io_context(struct io_context *ioc);
|
|
struct io_cq *ioc_lookup_icq(struct io_context *ioc, struct request_queue *q);
|
|
struct io_cq *ioc_create_icq(struct io_context *ioc, struct request_queue *q,
|
|
gfp_t gfp_mask);
|
|
void ioc_clear_queue(struct request_queue *q);
|
|
|
|
int create_task_io_context(struct task_struct *task, gfp_t gfp_mask, int node);
|
|
|
|
/**
|
|
* create_io_context - try to create task->io_context
|
|
* @gfp_mask: allocation mask
|
|
* @node: allocation node
|
|
*
|
|
* If %current->io_context is %NULL, allocate a new io_context and install
|
|
* it. Returns the current %current->io_context which may be %NULL if
|
|
* allocation failed.
|
|
*
|
|
* Note that this function can't be called with IRQ disabled because
|
|
* task_lock which protects %current->io_context is IRQ-unsafe.
|
|
*/
|
|
static inline struct io_context *create_io_context(gfp_t gfp_mask, int node)
|
|
{
|
|
WARN_ON_ONCE(irqs_disabled());
|
|
if (unlikely(!current->io_context))
|
|
create_task_io_context(current, gfp_mask, node);
|
|
return current->io_context;
|
|
}
|
|
|
|
/*
|
|
* Internal throttling interface
|
|
*/
|
|
#ifdef CONFIG_BLK_DEV_THROTTLING
|
|
extern bool blk_throtl_bio(struct request_queue *q, struct bio *bio);
|
|
extern void blk_throtl_drain(struct request_queue *q);
|
|
extern int blk_throtl_init(struct request_queue *q);
|
|
extern void blk_throtl_exit(struct request_queue *q);
|
|
#else /* CONFIG_BLK_DEV_THROTTLING */
|
|
static inline bool blk_throtl_bio(struct request_queue *q, struct bio *bio)
|
|
{
|
|
return false;
|
|
}
|
|
static inline void blk_throtl_drain(struct request_queue *q) { }
|
|
static inline int blk_throtl_init(struct request_queue *q) { return 0; }
|
|
static inline void blk_throtl_exit(struct request_queue *q) { }
|
|
#endif /* CONFIG_BLK_DEV_THROTTLING */
|
|
|
|
#endif /* BLK_INTERNAL_H */
|