xref: /linux/include/uapi/linux/raid/md_u.h (revision 021bc4b9)
1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2 /*
3    md_u.h : user <=> kernel API between Linux raidtools and RAID drivers
4           Copyright (C) 1998 Ingo Molnar
5 
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2, or (at your option)
9    any later version.
10 */
11 
12 #ifndef _UAPI_MD_U_H
13 #define _UAPI_MD_U_H
14 
15 /*
16  * Different major versions are not compatible.
17  * Different minor versions are only downward compatible.
18  * Different patchlevel versions are downward and upward compatible.
19  */
20 #define MD_MAJOR_VERSION                0
21 #define MD_MINOR_VERSION                90
22 /*
23  * MD_PATCHLEVEL_VERSION indicates kernel functionality.
24  * >=1 means different superblock formats are selectable using SET_ARRAY_INFO
25  *     and major_version/minor_version accordingly
26  * >=2 means that Internal bitmaps are supported by setting MD_SB_BITMAP_PRESENT
27  *     in the super status byte
28  * >=3 means that bitmap superblock version 4 is supported, which uses
29  *     little-ending representation rather than host-endian
30  */
31 #define MD_PATCHLEVEL_VERSION           3
32 
33 /* ioctls */
34 
35 /* status */
36 #define RAID_VERSION		_IOR (MD_MAJOR, 0x10, mdu_version_t)
37 #define GET_ARRAY_INFO		_IOR (MD_MAJOR, 0x11, mdu_array_info_t)
38 #define GET_DISK_INFO		_IOR (MD_MAJOR, 0x12, mdu_disk_info_t)
39 #define RAID_AUTORUN		_IO (MD_MAJOR, 0x14)
40 #define GET_BITMAP_FILE		_IOR (MD_MAJOR, 0x15, mdu_bitmap_file_t)
41 
42 /* configuration */
43 #define CLEAR_ARRAY		_IO (MD_MAJOR, 0x20)
44 #define ADD_NEW_DISK		_IOW (MD_MAJOR, 0x21, mdu_disk_info_t)
45 #define HOT_REMOVE_DISK		_IO (MD_MAJOR, 0x22)
46 #define SET_ARRAY_INFO		_IOW (MD_MAJOR, 0x23, mdu_array_info_t)
47 #define SET_DISK_INFO		_IO (MD_MAJOR, 0x24)
48 #define WRITE_RAID_INFO		_IO (MD_MAJOR, 0x25)
49 #define UNPROTECT_ARRAY		_IO (MD_MAJOR, 0x26)
50 #define PROTECT_ARRAY		_IO (MD_MAJOR, 0x27)
51 #define HOT_ADD_DISK		_IO (MD_MAJOR, 0x28)
52 #define SET_DISK_FAULTY		_IO (MD_MAJOR, 0x29)
53 #define HOT_GENERATE_ERROR	_IO (MD_MAJOR, 0x2a)
54 #define SET_BITMAP_FILE		_IOW (MD_MAJOR, 0x2b, int)
55 
56 /* usage */
57 #define RUN_ARRAY		_IOW (MD_MAJOR, 0x30, mdu_param_t)
58 /*  0x31 was START_ARRAY  */
59 #define STOP_ARRAY		_IO (MD_MAJOR, 0x32)
60 #define STOP_ARRAY_RO		_IO (MD_MAJOR, 0x33)
61 #define RESTART_ARRAY_RW	_IO (MD_MAJOR, 0x34)
62 #define CLUSTERED_DISK_NACK	_IO (MD_MAJOR, 0x35)
63 
64 /* 63 partitions with the alternate major number (mdp) */
65 #define MdpMinorShift 6
66 
67 typedef struct mdu_version_s {
68 	int major;
69 	int minor;
70 	int patchlevel;
71 } mdu_version_t;
72 
73 typedef struct mdu_array_info_s {
74 	/*
75 	 * Generic constant information
76 	 */
77 	int major_version;
78 	int minor_version;
79 	int patch_version;
80 	unsigned int ctime;
81 	int level;
82 	int size;
83 	int nr_disks;
84 	int raid_disks;
85 	int md_minor;
86 	int not_persistent;
87 
88 	/*
89 	 * Generic state information
90 	 */
91 	unsigned int utime;	/*  0 Superblock update time		      */
92 	int state;		/*  1 State bits (clean, ...)		      */
93 	int active_disks;	/*  2 Number of currently active disks	      */
94 	int working_disks;	/*  3 Number of working disks		      */
95 	int failed_disks;	/*  4 Number of failed disks		      */
96 	int spare_disks;	/*  5 Number of spare disks		      */
97 
98 	/*
99 	 * Personality information
100 	 */
101 	int layout;		/*  0 the array's physical layout	      */
102 	int chunk_size;	/*  1 chunk size in bytes		      */
103 
104 } mdu_array_info_t;
105 
106 /* we need a value for 'no level specified' and 0
107  * means 'raid0', so we need something else.  This is
108  * for internal use only
109  */
110 #define	LEVEL_NONE		(-1000000)
111 
112 typedef struct mdu_disk_info_s {
113 	/*
114 	 * configuration/status of one particular disk
115 	 */
116 	int number;
117 	int major;
118 	int minor;
119 	int raid_disk;
120 	int state;
121 
122 } mdu_disk_info_t;
123 
124 typedef struct mdu_start_info_s {
125 	/*
126 	 * configuration/status of one particular disk
127 	 */
128 	int major;
129 	int minor;
130 	int raid_disk;
131 	int state;
132 
133 } mdu_start_info_t;
134 
135 typedef struct mdu_bitmap_file_s
136 {
137 	char pathname[4096];
138 } mdu_bitmap_file_t;
139 
140 typedef struct mdu_param_s
141 {
142 	int			personality;	/* 1,2,3,4 */
143 	int			chunk_size;	/* in bytes */
144 	int			max_fault;	/* unused for now */
145 } mdu_param_t;
146 
147 #endif /* _UAPI_MD_U_H */
148