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