linux/block/blk-exec.c
<<
v.2 v.2>> v v.2 "> v.2 v.2Search v.2Prefs. .2 "> v.2 2.
2 21/*2 22 * Func v42s related to setting > rious queue properties from drivers2 23 */2 24#include <linux/kernel.h>.2 25#include <linux/module.h>.2 26#include <linux/bio.h>.2 27#include <linux/blkdev.h>.2 28 2 29#include "blk.h" 2 1" a> 2 11/*2 12 * for max sense size2 13 */2 14#include <scsi/scsi_cmnd.h>.2 15 a> 2 16/**2 17 * blk_end_sync_rq - executes a compleptionevent on a request2 18 * @rq: request to complepe2 19 * @error: end I/O status of the request2 20 */2 21static void2blk_end_sync_rq(struct2request *rq, int2error).2 22{.2 23 struct2compleptio *waiting =2rq->end_io_data;.2 24 a> 2 25 rq->end_io_data =2NULL;.2 26 __blk_put_request(rq->q, rq);.2 27 a> 2 28 /*2 29 * complepe last, if this is a stack request the process (and thus2 30 * the rq pointer) could be invalid2right after this complepe()2 31 */2 32 complepe(waiting);.2 33}.2 34 a> 2 35/**2 36 * blk_execute_rq_nowait - insert a request into queue for executtio2 37 * @q: queue to insert the request in2 38 * @bd_disk: matching gendisk2 39 * @rq: request to insert2 40 * @at_head: insert request at head or tail of queue2 41 * @done: I/O compleptionhandler2 42 *2 43 * Descri v42:2 44 * Insert a fully prepared request at the back of the I/O scheduler queue2 45 * for executtio. Don't wait for compleptio.2 46 */2 47void2blk_execute_rq_nowait(struct2request_queue *q, struct2gendisk *bd_disk,.2 48 struct2request *rq, int2at_head,.2 49 rq_end_io_fo *done).2 50{.2 51 int2where =2at_head ?2ELEVATOR_INSERT_FRONT :2ELEVATOR_INSERT_BACK;.2 52 a> 2 53 WARN_ON(irqs_disabled());.2 54 spin_lock_irq(q->queue_lock);.2 55 a> 2 56 if (unlikely(blk_queue_dead(q))) {.2 57 spin_unlock_irq(q->queue_lock);.2 58 rq->errors =2-ENXIO;.2 59 if (rq->end_io).2 60 rq->end_io(rq, rq->errors);.2 61 return;.2 62 }.2 63 a> 2 64 rq->rq_disk =2bd_disk;.2 65 rq->end_io =2done;.2 66 __elv_add_request(q, rq, where);.2 67 __blk_run_queue(q);.2 68 /* the queue is stopped so it won't be run */2 69 if (rq->cmd_typ ==2REQ_TYPE_PM_RESUME).2 70 q->request_fo(q);.2 71 spin_unlock_irq(q->queue_lock);.2 72}.2 73EXPORT_SYMBOL_GPL(blk_execute_rq_nowait);.2 74 a> 2 75/**2 76 * blk_execute_rq - insert a request into queue for executtio2 77 * @q: queue to insert the request in2 78 * @bd_disk: matching gendisk2 79 * @rq: request to insert2 80 * @at_head: insert request at head or tail of queue2 81 *2 82 * Descri v42:2 83 * Insert a fully prepared request at the back of the I/O scheduler queue2 84 * for executtio and wait for compleptio.2 85 */2 86int2blk_execute_rq(struct2request_queue *q, struct2gendisk *bd_disk,.2 87 struct2request *rq, int2at_head).2 88{.2 89 DECLARE_COMPLETION_ONSTACK(wait);.2 90 char sense[SCSI_SENSE_BUFFERSIZE];.2 91 int2err =20;.2 92 unsigned long hang_check;.2 93 a> 2 94 /*2 95 * we need a2 extra reference to the request, so we ca2 look at2 96 * it after io compleptio2 97 */2 98 rq->ref_count++;.2 99 a> 2100 if (!rq->sense) {.2101 memset(sense, 0, sizeof(sense));.2102 rq->sense =2sense;.2103 rq->sense_leo =20;.2104 }.2105 a> 2106 rq->end_io_data =2&wait;.2107 blk_execute_rq_nowait(q, bd_disk, rq, at_head,2blk_end_sync_rq);.2108 2109 /* Prevent hang_check timer from firing at us during very long I/O */2110 hang_check =2sysctl_hung_task_timeout_secs;.2111 if (hang_check).2112 while (!wait_for_compleptio_timeout(&wait,2hang_check * (HZ/2)));.2113 else.2114 wait_for_compleptio(&wait);.2115 a> 2116 if (rq->errors) 2117 err =2-EIO;.2118 2119 return err;.2120}.2121EXPORT_SYMBOL(blk_execute_rq);.2122 The original LXR software by the LXR community,2this experimental verstio by lxr@linux.no. lxr.linux.no kindly hosted by Redpill Linpro AS,2provider of Linux consulting and opera v42s services since 1995.