LCOV - code coverage report
Current view: top level - block - noop-iosched.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 43 0.0 %
Date: 2014-02-18 Functions: 0 9 0.0 %
Branches: 0 12 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * elevator noop
       3                 :            :  */
       4                 :            : #include <linux/blkdev.h>
       5                 :            : #include <linux/elevator.h>
       6                 :            : #include <linux/bio.h>
       7                 :            : #include <linux/module.h>
       8                 :            : #include <linux/slab.h>
       9                 :            : #include <linux/init.h>
      10                 :            : 
      11                 :            : struct noop_data {
      12                 :            :         struct list_head queue;
      13                 :            : };
      14                 :            : 
      15                 :          0 : static void noop_merged_requests(struct request_queue *q, struct request *rq,
      16                 :            :                                  struct request *next)
      17                 :            : {
      18                 :          0 :         list_del_init(&next->queuelist);
      19                 :          0 : }
      20                 :            : 
      21                 :          0 : static int noop_dispatch(struct request_queue *q, int force)
      22                 :            : {
      23                 :          0 :         struct noop_data *nd = q->elevator->elevator_data;
      24                 :            : 
      25         [ #  # ]:          0 :         if (!list_empty(&nd->queue)) {
      26                 :            :                 struct request *rq;
      27                 :            :                 rq = list_entry(nd->queue.next, struct request, queuelist);
      28                 :          0 :                 list_del_init(&rq->queuelist);
      29                 :          0 :                 elv_dispatch_sort(q, rq);
      30                 :          0 :                 return 1;
      31                 :            :         }
      32                 :            :         return 0;
      33                 :            : }
      34                 :            : 
      35                 :          0 : static void noop_add_request(struct request_queue *q, struct request *rq)
      36                 :            : {
      37                 :          0 :         struct noop_data *nd = q->elevator->elevator_data;
      38                 :            : 
      39                 :          0 :         list_add_tail(&rq->queuelist, &nd->queue);
      40                 :          0 : }
      41                 :            : 
      42                 :            : static struct request *
      43                 :          0 : noop_former_request(struct request_queue *q, struct request *rq)
      44                 :            : {
      45                 :          0 :         struct noop_data *nd = q->elevator->elevator_data;
      46                 :            : 
      47         [ #  # ]:          0 :         if (rq->queuelist.prev == &nd->queue)
      48                 :            :                 return NULL;
      49                 :          0 :         return list_entry(rq->queuelist.prev, struct request, queuelist);
      50                 :            : }
      51                 :            : 
      52                 :            : static struct request *
      53                 :          0 : noop_latter_request(struct request_queue *q, struct request *rq)
      54                 :            : {
      55                 :          0 :         struct noop_data *nd = q->elevator->elevator_data;
      56                 :            : 
      57         [ #  # ]:          0 :         if (rq->queuelist.next == &nd->queue)
      58                 :            :                 return NULL;
      59                 :          0 :         return list_entry(rq->queuelist.next, struct request, queuelist);
      60                 :            : }
      61                 :            : 
      62                 :          0 : static int noop_init_queue(struct request_queue *q, struct elevator_type *e)
      63                 :            : {
      64                 :            :         struct noop_data *nd;
      65                 :            :         struct elevator_queue *eq;
      66                 :            : 
      67                 :          0 :         eq = elevator_alloc(q, e);
      68         [ #  # ]:          0 :         if (!eq)
      69                 :            :                 return -ENOMEM;
      70                 :            : 
      71                 :            :         nd = kmalloc_node(sizeof(*nd), GFP_KERNEL, q->node);
      72         [ #  # ]:          0 :         if (!nd) {
      73                 :          0 :                 kobject_put(&eq->kobj);
      74                 :          0 :                 return -ENOMEM;
      75                 :            :         }
      76                 :          0 :         eq->elevator_data = nd;
      77                 :            : 
      78                 :          0 :         INIT_LIST_HEAD(&nd->queue);
      79                 :            : 
      80                 :          0 :         spin_lock_irq(q->queue_lock);
      81                 :          0 :         q->elevator = eq;
      82                 :          0 :         spin_unlock_irq(q->queue_lock);
      83                 :          0 :         return 0;
      84                 :            : }
      85                 :            : 
      86                 :          0 : static void noop_exit_queue(struct elevator_queue *e)
      87                 :            : {
      88                 :          0 :         struct noop_data *nd = e->elevator_data;
      89                 :            : 
      90         [ #  # ]:          0 :         BUG_ON(!list_empty(&nd->queue));
      91                 :          0 :         kfree(nd);
      92                 :          0 : }
      93                 :            : 
      94                 :            : static struct elevator_type elevator_noop = {
      95                 :            :         .ops = {
      96                 :            :                 .elevator_merge_req_fn          = noop_merged_requests,
      97                 :            :                 .elevator_dispatch_fn           = noop_dispatch,
      98                 :            :                 .elevator_add_req_fn            = noop_add_request,
      99                 :            :                 .elevator_former_req_fn         = noop_former_request,
     100                 :            :                 .elevator_latter_req_fn         = noop_latter_request,
     101                 :            :                 .elevator_init_fn               = noop_init_queue,
     102                 :            :                 .elevator_exit_fn               = noop_exit_queue,
     103                 :            :         },
     104                 :            :         .elevator_name = "noop",
     105                 :            :         .elevator_owner = THIS_MODULE,
     106                 :            : };
     107                 :            : 
     108                 :          0 : static int __init noop_init(void)
     109                 :            : {
     110                 :          0 :         return elv_register(&elevator_noop);
     111                 :            : }
     112                 :            : 
     113                 :          0 : static void __exit noop_exit(void)
     114                 :            : {
     115                 :          0 :         elv_unregister(&elevator_noop);
     116                 :          0 : }
     117                 :            : 
     118                 :            : module_init(noop_init);
     119                 :            : module_exit(noop_exit);
     120                 :            : 
     121                 :            : 
     122                 :            : MODULE_AUTHOR("Jens Axboe");
     123                 :            : MODULE_LICENSE("GPL");
     124                 :            : MODULE_DESCRIPTION("No-op IO scheduler");

Generated by: LCOV version 1.9