summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
Diffstat (limited to 'block')
-rw-r--r--block/blk-core.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index b5f890e8caab..d6d2bf0bf08b 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2081,6 +2081,27 @@ out:
}
EXPORT_SYMBOL(generic_make_request);
+#ifdef CONFIG_BLK_DEV_IO_TRACE
+static inline struct task_struct *get_dirty_task(struct bio *bio)
+{
+ /*
+ * Not all the pages in the bio are dirtied by the
+ * same task but most likely it will be, since the
+ * sectors accessed on the device must be adjacent.
+ */
+ if (bio->bi_io_vec && bio->bi_io_vec->bv_page &&
+ bio->bi_io_vec->bv_page->tsk_dirty)
+ return bio->bi_io_vec->bv_page->tsk_dirty;
+ else
+ return current;
+}
+#else
+static inline struct task_struct *get_dirty_task(struct bio *bio)
+{
+ return current;
+}
+#endif
+
/**
* submit_bio - submit a bio to the block device layer for I/O
* @rw: whether to %READ or %WRITE, or maybe to %READA (read ahead)
@@ -2093,7 +2114,6 @@ EXPORT_SYMBOL(generic_make_request);
*/
blk_qc_t submit_bio(int rw, struct bio *bio)
{
- struct task_struct *tsk = current;
bio->bi_rw |= rw;
/*
@@ -2117,16 +2137,9 @@ blk_qc_t submit_bio(int rw, struct bio *bio)
if (unlikely(block_dump)) {
char b[BDEVNAME_SIZE];
+ struct task_struct *tsk;
- /*
- * Not all the pages in the bio are dirtied by the
- * same task but most likely it will be, since the
- * sectors accessed on the device must be adjacent.
- */
- if (bio->bi_io_vec && bio->bi_io_vec->bv_page &&
- bio->bi_io_vec->bv_page->tsk_dirty)
- tsk = bio->bi_io_vec->bv_page->tsk_dirty;
-
+ tsk = get_dirty_task(bio);
printk(KERN_DEBUG "%s(%d): %s block %Lu on %s (%u sectors)\n",
tsk->comm, task_pid_nr(tsk),
(rw & WRITE) ? "WRITE" : "READ",