xref: /freebsd/sys/contrib/openzfs/module/os/linux/zfs/zfs_racct.c (revision 7a7741af18d6c8a804cc643cb7ecda9d730c6aa6)
1ba27dd8bSMartin Matuska /*
2ba27dd8bSMartin Matuska  * Copyright (c) 2021 iXsystems, Inc.
3ba27dd8bSMartin Matuska  *
4ba27dd8bSMartin Matuska  * Redistribution and use in source and binary forms, with or without
5ba27dd8bSMartin Matuska  * modification, are permitted provided that the following conditions
6ba27dd8bSMartin Matuska  * are met:
7ba27dd8bSMartin Matuska  * 1. Redistributions of source code must retain the above copyright
8ba27dd8bSMartin Matuska  *    notice, this list of conditions and the following disclaimer.
9ba27dd8bSMartin Matuska  * 2. Redistributions in binary form must reproduce the above copyright
10ba27dd8bSMartin Matuska  *    notice, this list of conditions and the following disclaimer in the
11ba27dd8bSMartin Matuska  *    documentation and/or other materials provided with the distribution.
12ba27dd8bSMartin Matuska  *
13ba27dd8bSMartin Matuska  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
14ba27dd8bSMartin Matuska  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15ba27dd8bSMartin Matuska  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16ba27dd8bSMartin Matuska  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
17ba27dd8bSMartin Matuska  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18ba27dd8bSMartin Matuska  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19ba27dd8bSMartin Matuska  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20ba27dd8bSMartin Matuska  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21ba27dd8bSMartin Matuska  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22ba27dd8bSMartin Matuska  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23ba27dd8bSMartin Matuska  * SUCH DAMAGE.
24ba27dd8bSMartin Matuska  */
25ba27dd8bSMartin Matuska 
26ba27dd8bSMartin Matuska #include <sys/zfs_racct.h>
27ba27dd8bSMartin Matuska 
28*7a7741afSMartin Matuska #ifdef _KERNEL
29*7a7741afSMartin Matuska #include <linux/task_io_accounting_ops.h>
30*7a7741afSMartin Matuska 
31ba27dd8bSMartin Matuska void
zfs_racct_read(spa_t * spa,uint64_t size,uint64_t iops,uint32_t flags)32*7a7741afSMartin Matuska zfs_racct_read(spa_t *spa, uint64_t size, uint64_t iops, uint32_t flags)
33ba27dd8bSMartin Matuska {
34*7a7741afSMartin Matuska 	task_io_account_read(size);
35*7a7741afSMartin Matuska 	spa_iostats_read_add(spa, size, iops, flags);
36ba27dd8bSMartin Matuska }
37ba27dd8bSMartin Matuska 
38ba27dd8bSMartin Matuska void
zfs_racct_write(spa_t * spa,uint64_t size,uint64_t iops,uint32_t flags)39*7a7741afSMartin Matuska zfs_racct_write(spa_t *spa, uint64_t size, uint64_t iops, uint32_t flags)
40ba27dd8bSMartin Matuska {
41*7a7741afSMartin Matuska 	task_io_account_write(size);
42*7a7741afSMartin Matuska 	spa_iostats_write_add(spa, size, iops, flags);
43ba27dd8bSMartin Matuska }
44*7a7741afSMartin Matuska 
45*7a7741afSMartin Matuska #else
46*7a7741afSMartin Matuska 
47*7a7741afSMartin Matuska void
zfs_racct_read(spa_t * spa,uint64_t size,uint64_t iops,uint32_t flags)48*7a7741afSMartin Matuska zfs_racct_read(spa_t *spa, uint64_t size, uint64_t iops, uint32_t flags)
49*7a7741afSMartin Matuska {
50*7a7741afSMartin Matuska 	(void) spa, (void) size, (void) iops, (void) flags;
51*7a7741afSMartin Matuska }
52*7a7741afSMartin Matuska 
53*7a7741afSMartin Matuska void
zfs_racct_write(spa_t * spa,uint64_t size,uint64_t iops,uint32_t flags)54*7a7741afSMartin Matuska zfs_racct_write(spa_t *spa, uint64_t size, uint64_t iops, uint32_t flags)
55*7a7741afSMartin Matuska {
56*7a7741afSMartin Matuska 	(void) spa, (void) size, (void) iops, (void) flags;
57*7a7741afSMartin Matuska }
58*7a7741afSMartin Matuska 
59*7a7741afSMartin Matuska #endif /* _KERNEL */
60