~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to ubuntu/iscsitarget/null-io.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Target device null I/O.
3
 
 * (C) 2005 MING Zhang <mingz@ele.uri.edu>
4
 
 * This code is licenced under the GPL.
5
 
 *
6
 
 * The nullio mode will not return any meaningful or previous written
7
 
 * data. It is only for performance measurement purpose.
8
 
 */
9
 
 
10
 
#include <linux/types.h>
11
 
#include <linux/blkdev.h>
12
 
#include <linux/parser.h>
13
 
#include <linux/writeback.h>
14
 
 
15
 
#include "iscsi.h"
16
 
#include "iscsi_dbg.h"
17
 
#include "iotype.h"
18
 
 
19
 
enum {
20
 
        opt_blk_cnt, opt_ignore, opt_err,
21
 
};
22
 
 
23
 
static match_table_t tokens = {
24
 
        /* alias for compatibility with existing setups and documentation */
25
 
        {opt_blk_cnt, "sectors=%u"},
26
 
        /* but actually it is the scsi block count, now that we can
27
 
         * specify the block size. */
28
 
        {opt_blk_cnt, "blocks=%u"},
29
 
        {opt_ignore, "scsiid=%s"},
30
 
        {opt_ignore, "scsisn=%s"},
31
 
        {opt_ignore, "blocksize=%s"},
32
 
        {opt_ignore, "type=%s"},
33
 
        {opt_err, NULL},
34
 
};
35
 
 
36
 
static int parse_nullio_params(struct iet_volume *volume, char *params)
37
 
{
38
 
        int err = 0;
39
 
        char *p, *q;
40
 
 
41
 
        while ((p = strsep(&params, ",")) != NULL) {
42
 
                substring_t args[MAX_OPT_ARGS];
43
 
                int token;
44
 
                if (!*p)
45
 
                        continue;
46
 
                iet_strtolower(p);
47
 
                token = match_token(p, tokens, args);
48
 
                switch (token) {
49
 
                case opt_blk_cnt:
50
 
                        q = match_strdup(&args[0]);
51
 
                        if (!q)
52
 
                                return -ENOMEM;
53
 
                        volume->blk_cnt = simple_strtoull(q, NULL, 10);
54
 
                        kfree(q);
55
 
                        break;
56
 
                case opt_ignore:
57
 
                        break;
58
 
                default:
59
 
                        eprintk("Unknown %s\n", p);
60
 
                        return -EINVAL;
61
 
                        break;
62
 
                }
63
 
        }
64
 
        return err;
65
 
}
66
 
 
67
 
static void nullio_detach(struct iet_volume *lu)
68
 
{
69
 
}
70
 
 
71
 
static int nullio_attach(struct iet_volume *lu, char *args)
72
 
{
73
 
        int err = 0;
74
 
 
75
 
        if ((err = parse_nullio_params(lu, args)) < 0) {
76
 
                eprintk("%d\n", err);
77
 
                goto out;
78
 
        }
79
 
 
80
 
        if (!lu->blk_shift)
81
 
                lu->blk_shift = blksize_bits(IET_DEF_BLOCK_SIZE);
82
 
 
83
 
        /* defaults to 64 GiB */
84
 
        if (!lu->blk_cnt)
85
 
                lu->blk_cnt = 1 << (36 - lu->blk_shift);
86
 
 
87
 
out:
88
 
        if (err < 0)
89
 
                nullio_detach(lu);
90
 
        return err;
91
 
}
92
 
 
93
 
struct iotype nullio =
94
 
{
95
 
        .name = "nullio",
96
 
        .attach = nullio_attach,
97
 
        .detach = nullio_detach,
98
 
};