preliminaryDataProcessing.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (C) 1991, 1992 Linus Torvalds
  3. * Copyright (C) 1994, Karl Keyte: Added support for disk statistics
  4. * Elevator latency, (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
  5. * Queue request tables / lock, selectable elevator, Jens Axboe <axboe@suse.de>
  6. * kernel-doc documentation started by NeilBrown <neilb@cse.unsw.edu.au>
  7. * - July2000
  8. * bio rewrite, highmem i/o, etc, Jens Axboe <axboe@suse.de> - may 2001
  9. */
  10. /*
  11. * This handles all read/write requests to block devices
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/module.h>
  15. #include <linux/backing-dev.h>
  16. #include <linux/bio.h>
  17. #include <linux/blkdev.h>
  18. #include <linux/highmem.h>
  19. #include <linux/mm.h>
  20. #include <linux/kernel_stat.h>
  21. #include <linux/string.h>
  22. #include <linux/init.h>
  23. #include <linux/completion.h>
  24. #include <linux/slab.h>
  25. #include <linux/swap.h>
  26. #include <linux/writeback.h>
  27. #include <linux/task_io_accounting_ops.h>
  28. #include <linux/fault-inject.h>
  29. #include <linux/list_sort.h>
  30. #include <linux/delay.h>
  31. #include <linux/ratelimit.h>
  32. #define CREATE_TRACE_POINTS
  33. #include <trace/events/block.h>
  34. #include "blk.h"
  35. #include "blk-cgroup.h"
  36. EXPORT_TRACEPOINT_SYMBOL_GPL(block_bio_remap);
  37. EXPORT_TRACEPOINT_SYMBOL_GPL(block_rq_remap);
  38. EXPORT_TRACEPOINT_SYMBOL_GPL(block_bio_complete);
  39. EXPORT_TRACEPOINT_SYMBOL_GPL(block_unplug);
  40. DEFINE_IDA(blk_queue_ida);
  41. /*
  42. * For the allocated request tables
  43. */
  44. static struct kmem_cache *request_cachep;
  45. /*
  46. * For queue allocation
  47. */
  48. struct kmem_cache *blk_requestq_cachep;
  49. /*
  50. * Controlling structure to kblockd
  51. */
  52. static struct workqueue_struct *kblockd_workqueue;
  53. static void drive_stat_acct(struct request *rq, int new_io)
  54. {
  55. struct hd_struct *part;
  56. int rw = rq_data_dir(rq);
  57. int cpu;
  58. if (!blk_do_io_stat(rq))
  59. return;
  60. cpu = part_stat_lock();
  61. if (!new_io) {
  62. part = rq->part;
  63. part_stat_inc(cpu, part, merges[rw]);
  64. } else {
  65. part = disk_map_sector_rcu(rq->rq_disk, blk_rq_pos(rq));
  66. if (!hd_struct_try_get(part)) {
  67. /*
  68. * The partition is already being removed,
  69. * the request will be accounted on the disk only
  70. *