xref: /freebsd/sys/geom/nop/g_nop.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
189aaffecSPawel Jakub Dawidek /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
33728855aSPedro F. Giffuni  *
46a146a19SPawel Jakub Dawidek  * Copyright (c) 2004-2006 Pawel Jakub Dawidek <pjd@FreeBSD.org>
589aaffecSPawel Jakub Dawidek  * All rights reserved.
689aaffecSPawel Jakub Dawidek  *
789aaffecSPawel Jakub Dawidek  * Redistribution and use in source and binary forms, with or without
889aaffecSPawel Jakub Dawidek  * modification, are permitted provided that the following conditions
989aaffecSPawel Jakub Dawidek  * are met:
1089aaffecSPawel Jakub Dawidek  * 1. Redistributions of source code must retain the above copyright
1189aaffecSPawel Jakub Dawidek  *    notice, this list of conditions and the following disclaimer.
1289aaffecSPawel Jakub Dawidek  * 2. Redistributions in binary form must reproduce the above copyright
1389aaffecSPawel Jakub Dawidek  *    notice, this list of conditions and the following disclaimer in the
1489aaffecSPawel Jakub Dawidek  *    documentation and/or other materials provided with the distribution.
1589aaffecSPawel Jakub Dawidek  *
1689aaffecSPawel Jakub Dawidek  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
1789aaffecSPawel Jakub Dawidek  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1889aaffecSPawel Jakub Dawidek  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1989aaffecSPawel Jakub Dawidek  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
2089aaffecSPawel Jakub Dawidek  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2189aaffecSPawel Jakub Dawidek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2289aaffecSPawel Jakub Dawidek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2389aaffecSPawel Jakub Dawidek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2489aaffecSPawel Jakub Dawidek  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2589aaffecSPawel Jakub Dawidek  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2689aaffecSPawel Jakub Dawidek  * SUCH DAMAGE.
2789aaffecSPawel Jakub Dawidek  */
2889aaffecSPawel Jakub Dawidek 
2989aaffecSPawel Jakub Dawidek #ifndef	_G_NOP_H_
3089aaffecSPawel Jakub Dawidek #define	_G_NOP_H_
3189aaffecSPawel Jakub Dawidek 
3289aaffecSPawel Jakub Dawidek #define	G_NOP_CLASS_NAME	"NOP"
336a146a19SPawel Jakub Dawidek #define	G_NOP_VERSION		4
3489aaffecSPawel Jakub Dawidek #define	G_NOP_SUFFIX		".nop"
356f7f85e0SAlan Somers /*
366f7f85e0SAlan Somers  * Special flag to instruct gnop to passthrough the underlying provider's
376f7f85e0SAlan Somers  * physical path
386f7f85e0SAlan Somers  */
396f7f85e0SAlan Somers #define G_NOP_PHYSPATH_PASSTHROUGH "\255"
4089aaffecSPawel Jakub Dawidek 
4189aaffecSPawel Jakub Dawidek #ifdef _KERNEL
42ac03832eSConrad Meyer #define	G_NOP_DEBUG(lvl, ...) \
43ac03832eSConrad Meyer     _GEOM_DEBUG("GEOM_NOP", g_nop_debug, (lvl), NULL, __VA_ARGS__)
44ac03832eSConrad Meyer #define G_NOP_LOGREQLVL(lvl, bp, ...) \
45ac03832eSConrad Meyer     _GEOM_DEBUG("GEOM_NOP", g_nop_debug, (lvl), (bp), __VA_ARGS__)
46d7078f3bSJohn-Mark Gurney #define	G_NOP_LOGREQ(bp, ...)	G_NOP_LOGREQLVL(2, bp, __VA_ARGS__)
47e370e911SPawel Jakub Dawidek 
484f80c855SMariusz Zaborski struct g_nop_delay;
494f80c855SMariusz Zaborski 
504f80c855SMariusz Zaborski TAILQ_HEAD(g_nop_delay_head, g_nop_delay);
514f80c855SMariusz Zaborski 
52e370e911SPawel Jakub Dawidek struct g_nop_softc {
536a146a19SPawel Jakub Dawidek 	int			 sc_error;
54e370e911SPawel Jakub Dawidek 	off_t			 sc_offset;
557027e4daSEdward Tomasz Napierala 	off_t			 sc_explicitsize;
56bb27d7edSEdward Tomasz Napierala 	off_t			 sc_stripesize;
57bb27d7edSEdward Tomasz Napierala 	off_t			 sc_stripeoffset;
586a146a19SPawel Jakub Dawidek 	u_int			 sc_rfailprob;
596a146a19SPawel Jakub Dawidek 	u_int			 sc_wfailprob;
604f80c855SMariusz Zaborski 	u_int			 sc_delaymsec;
614f80c855SMariusz Zaborski 	u_int			 sc_rdelayprob;
624f80c855SMariusz Zaborski 	u_int			 sc_wdelayprob;
63090a3ea3SChuck Silvers 	u_int			 sc_count_until_fail;
64df3d5a19SPawel Jakub Dawidek 	uintmax_t		 sc_reads;
65df3d5a19SPawel Jakub Dawidek 	uintmax_t		 sc_writes;
6645d7de1dSEdward Tomasz Napierala 	uintmax_t		 sc_deletes;
6745d7de1dSEdward Tomasz Napierala 	uintmax_t		 sc_getattrs;
6845d7de1dSEdward Tomasz Napierala 	uintmax_t		 sc_flushes;
6945d7de1dSEdward Tomasz Napierala 	uintmax_t		 sc_cmd0s;
7045d7de1dSEdward Tomasz Napierala 	uintmax_t		 sc_cmd1s;
7145d7de1dSEdward Tomasz Napierala 	uintmax_t		 sc_cmd2s;
728b522bdaSWarner Losh 	uintmax_t		 sc_speedups;
73df3d5a19SPawel Jakub Dawidek 	uintmax_t		 sc_readbytes;
74df3d5a19SPawel Jakub Dawidek 	uintmax_t		 sc_wrotebytes;
756f7f85e0SAlan Somers 	char			*sc_physpath;
7640ea77a0SAlexander Motin 	struct mtx		 sc_lock;
774f80c855SMariusz Zaborski 	struct g_nop_delay_head	 sc_head_delay;
78e370e911SPawel Jakub Dawidek };
7989aaffecSPawel Jakub Dawidek #endif	/* _KERNEL */
8089aaffecSPawel Jakub Dawidek 
8189aaffecSPawel Jakub Dawidek #endif	/* _G_NOP_H_ */
82