]> git.proxmox.com Git - mirror_zfs-debian.git/blame - include/zpios-internal.h
Merge branch 'feature-flags'
[mirror_zfs-debian.git] / include / zpios-internal.h
CommitLineData
302ef151
BB
1/*****************************************************************************\
2 * ZPIOS is a heavily modified version of the original PIOS test code.
3 * It is designed to have the test code running in the Linux kernel
4 * against ZFS while still being flexibly controled from user space.
5 *
6 * Copyright (C) 2008-2010 Lawrence Livermore National Security, LLC.
7 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
8 * Written by Brian Behlendorf <behlendorf1@llnl.gov>.
9 * LLNL-CODE-403049
10 *
11 * Original PIOS Test Code
12 * Copyright (C) 2004 Cluster File Systems, Inc.
13 * Written by Peter Braam <braam@clusterfs.com>
14 * Atul Vidwansa <atul@clusterfs.com>
15 * Milind Dumbare <milind@clusterfs.com>
16 *
17 * This file is part of ZFS on Linux.
18 * For details, see <http://github.com/behlendorf/zfs/>.
19 *
20 * ZPIOS is free software; you can redistribute it and/or modify it
21 * under the terms of the GNU General Public License as published by the
22 * Free Software Foundation; either version 2 of the License, or (at your
23 * option) any later version.
24 *
25 * ZPIOS is distributed in the hope that it will be useful, but WITHOUT
26 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
27 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28 * for more details.
29 *
30 * You should have received a copy of the GNU General Public License along
31 * with ZPIOS. If not, see <http://www.gnu.org/licenses/>.
32\*****************************************************************************/
33
34#ifndef _ZPIOS_INTERNAL_H
35#define _ZPIOS_INTERNAL_H
36
37#include "zpios-ctl.h"
38
39#define OBJ_SIZE 64
40
41struct run_args;
42
43typedef struct dmu_obj {
44 objset_t *os;
45 uint64_t obj;
46} dmu_obj_t;
47
48/* thread doing the IO data */
49typedef struct thread_data {
50 struct run_args *run_args;
51 int thread_no;
52 int rc;
53 zpios_stats_t stats;
54 kmutex_t lock;
55} thread_data_t;
56
57/* region for IO data */
58typedef struct zpios_region {
59 __u64 wr_offset;
60 __u64 rd_offset;
61 __u64 init_offset;
62 __u64 max_offset;
63 dmu_obj_t obj;
64 zpios_stats_t stats;
65 kmutex_t lock;
66} zpios_region_t;
67
68/* arguments for one run */
69typedef struct run_args {
70 /* Config args */
71 int id;
72 char pool[ZPIOS_NAME_SIZE];
73 __u64 chunk_size;
74 __u32 thread_count;
75 __u32 region_count;
76 __u64 region_size;
77 __u64 offset;
78 __u32 region_noise;
79 __u32 chunk_noise;
80 __u32 thread_delay;
81 __u32 flags;
82 char pre[ZPIOS_PATH_SIZE];
83 char post[ZPIOS_PATH_SIZE];
84 char log[ZPIOS_PATH_SIZE];
85
86 /* Control data */
87 objset_t *os;
88 wait_queue_head_t waitq;
89 volatile uint64_t threads_done;
90 kmutex_t lock_work;
91 kmutex_t lock_ctl;
92 __u32 region_next;
93
94 /* Results data */
95 struct file *file;
96 zpios_stats_t stats;
97
98 thread_data_t **threads;
99 zpios_region_t regions[0]; /* Must be last element */
100} run_args_t;
101
102#define ZPIOS_INFO_BUFFER_SIZE 65536
103#define ZPIOS_INFO_BUFFER_REDZONE 1024
104
105typedef struct zpios_info {
106 spinlock_t info_lock;
107 int info_size;
108 char *info_buffer;
109 char *info_head; /* Internal kernel use only */
110} zpios_info_t;
111
112#define zpios_print(file, format, args...) \
113({ zpios_info_t *_info_ = (zpios_info_t *)file->private_data; \
114 int _rc_; \
115 \
116 ASSERT(_info_); \
117 ASSERT(_info_->info_buffer); \
118 \
119 spin_lock(&_info_->info_lock); \
120 \
121 /* Don't allow the kernel to start a write in the red zone */ \
122 if ((int)(_info_->info_head - _info_->info_buffer) > \
123 (_info_->info_size - ZPIOS_INFO_BUFFER_REDZONE)) { \
124 _rc_ = -EOVERFLOW; \
125 } else { \
126 _rc_ = sprintf(_info_->info_head, format, args); \
127 if (_rc_ >= 0) \
128 _info_->info_head += _rc_; \
129 } \
130 \
131 spin_unlock(&_info_->info_lock); \
132 _rc_; \
133})
134
135#define zpios_vprint(file, test, format, args...) \
136 zpios_print(file, "%*s: " format, ZPIOS_NAME_SIZE, test, args)
137
138#endif /* _ZPIOS_INTERNAL_H */