-
Notifications
You must be signed in to change notification settings - Fork 18
/
zuf_call.h
113 lines (93 loc) · 2.29 KB
/
zuf_call.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* SPDX-License-Identifier: BSD-3-Clause */
/*
* zuf_call.h - C Wrappers over the ZUFS_IOCTL Api
*
* Copyright (c) 2018 NetApp, Inc. All rights reserved.
*
* See module.c for LICENSE details.
*
* Authors:
* Boaz Harrosh <[email protected]>
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <fcntl.h>
#include <sys/ioctl.h>
#include "zus.h"
/* Just a wraper for the commom unexpected print */
static inline
int __ioctl(int fd, ulong zu_vect, struct zufs_ioc_hdr *hdr, const char *msg)
{
int ret;
ret = ioctl(fd, zu_vect, hdr);
if (ret) {
ERROR("Unexpected ioctl => %d errno=%d zu_n=%lx zu_s=%s hdr=%d\n",
ret, errno, zu_vect, msg, hdr->err);
return -errno;
}
return hdr->err;
}
#define _ioctl(fd, zu_vect, hdr) __ioctl(fd, zu_vect, hdr, #zu_vect)
static inline
int zuf_register_fs(int fd, struct zus_fs_info *zfi)
{
struct zufs_ioc_register_fs zirf = {
.zus_zfi = zfi,
.rfi = zfi->rfi,
};
return _ioctl(fd, ZU_IOC_REGISTER_FS, &zirf.hdr);
}
static inline
int zuf_recieve_mount(int fd, struct zufs_ioc_mount *zim)
{
return _ioctl(fd, ZU_IOC_MOUNT, &zim->hdr);
}
static inline
int zuf_numa_map(int fd, struct zufs_ioc_numa_map *zinm)
{
return _ioctl(fd, ZU_IOC_NUMA_MAP, &zinm->hdr);
}
static inline
int zuf_grab_pmem(int fd, __u64 sb_id, struct zufs_ioc_pmem *zip)
{
zip->sb_id = sb_id;
return _ioctl(fd, ZU_IOC_GRAB_PMEM, &zip->hdr);
}
static inline
int zuf_zt_init(int fd, int cpu_num, uint chan, uint max_command)
{
struct zufs_ioc_init zii = {
.channel_no = chan,
.max_command = max_command,
};
return _ioctl(fd, ZU_IOC_INIT_THREAD, &zii.hdr);
}
static inline
int zuf_wait_opt(int fd, struct zufs_ioc_wait_operation *opt /*OUT*/)
{
return _ioctl(fd, ZU_IOC_WAIT_OPT, &opt->hdr);
}
static inline
int zuf_break_all(int fd)
{
struct zufs_ioc_break_all zba = {};
return _ioctl(fd, ZU_IOC_BREAK_ALL, &zba.hdr);
}
static inline
int zuf_iomap_exec(int fd, struct zufs_ioc_iomap_exec *ziome)
{
return _ioctl(fd, ZU_IOC_IOMAP_EXEC, &ziome->hdr);
}
static inline
int zuf_private_mount(int fd, struct zufs_ioc_mount_private *zip)
{
zip->is_umount = false;
return _ioctl(fd, ZU_IOC_PRIVATE_MOUNT, &zip->hdr);
}
static inline
int zuf_private_umount(int fd, struct zufs_ioc_mount_private *zip)
{
zip->is_umount = true;
return _ioctl(fd, ZU_IOC_PRIVATE_MOUNT, &zip->hdr);
}