libdmmp.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. /*
  2. * Copyright (C) 2015 - 2017 Red Hat, Inc.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. * Author: Gris Ge <fge@redhat.com>
  18. * Todd Gill <tgill@redhat.com>
  19. */
  20. #ifndef _LIB_DMMP_H_
  21. #define _LIB_DMMP_H_
  22. #include <stdint.h>
  23. #include <stdarg.h>
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #define DMMP_DLL_EXPORT __attribute__ ((visibility ("default")))
  28. #define DMMP_DLL_LOCAL __attribute__ ((visibility ("hidden")))
  29. #define DMMP_OK 0
  30. #define DMMP_ERR_BUG 1
  31. #define DMMP_ERR_NO_MEMORY 2
  32. #define DMMP_ERR_IPC_TIMEOUT 3
  33. #define DMMP_ERR_IPC_ERROR 4
  34. #define DMMP_ERR_NO_DAEMON 5
  35. #define DMMP_ERR_INCOMPATIBLE 6
  36. #define DMMP_ERR_MPATH_BUSY 7
  37. #define DMMP_ERR_MPATH_NOT_FOUND 8
  38. #define DMMP_ERR_INVALID_ARGUMENT 9
  39. #define DMMP_ERR_PERMISSION_DENY 10
  40. /*
  41. * Use the syslog severity level as log priority
  42. */
  43. #define DMMP_LOG_PRIORITY_ERROR 3
  44. #define DMMP_LOG_PRIORITY_WARNING 4
  45. #define DMMP_LOG_PRIORITY_INFO 6
  46. #define DMMP_LOG_PRIORITY_DEBUG 7
  47. #define DMMP_LOG_PRIORITY_DEFAULT DMMP_LOG_PRIORITY_WARNING
  48. /**
  49. * dmmp_log_priority_str() - Convert log priority to string.
  50. *
  51. * Convert log priority to string (const char *).
  52. *
  53. * @priority:
  54. * int. Log priority.
  55. *
  56. * Return:
  57. * const char *. Valid string are:
  58. *
  59. * * "ERROR" for DMMP_LOG_PRIORITY_ERROR
  60. *
  61. * * "WARN " for DMMP_LOG_PRIORITY_WARNING
  62. *
  63. * * "INFO " for DMMP_LOG_PRIORITY_INFO
  64. *
  65. * * "DEBUG" for DMMP_LOG_PRIORITY_DEBUG
  66. *
  67. * * "Invalid argument" for invalid log priority.
  68. */
  69. DMMP_DLL_EXPORT const char *dmmp_log_priority_str(int priority);
  70. struct DMMP_DLL_EXPORT dmmp_context;
  71. struct DMMP_DLL_EXPORT dmmp_mpath;
  72. struct DMMP_DLL_EXPORT dmmp_path_group;
  73. #define DMMP_PATH_GROUP_STATUS_UNKNOWN 0
  74. #define DMMP_PATH_GROUP_STATUS_ENABLED 1
  75. #define DMMP_PATH_GROUP_STATUS_DISABLED 2
  76. #define DMMP_PATH_GROUP_STATUS_ACTIVE 3
  77. struct DMMP_DLL_EXPORT dmmp_path;
  78. #define DMMP_PATH_STATUS_UNKNOWN 0
  79. //#define DMMP_PATH_STATUS_UNCHECKED 1
  80. // ^ print.h does not expose this.
  81. #define DMMP_PATH_STATUS_DOWN 2
  82. #define DMMP_PATH_STATUS_UP 3
  83. #define DMMP_PATH_STATUS_SHAKY 4
  84. #define DMMP_PATH_STATUS_GHOST 5
  85. #define DMMP_PATH_STATUS_PENDING 6
  86. #define DMMP_PATH_STATUS_TIMEOUT 7
  87. //#define DMMP_PATH_STATUS_REMOVED 8
  88. // ^ print.h does not expose this.
  89. #define DMMP_PATH_STATUS_DELAYED 9
  90. /**
  91. * dmmp_strerror() - Convert error code to string.
  92. *
  93. * Convert error code (int) to string (const char *):
  94. *
  95. * * DMMP_OK -- "OK"
  96. *
  97. * * DMMP_ERR_BUG -- "BUG of libdmmp library"
  98. *
  99. * * DMMP_ERR_NO_MEMORY -- "Out of memory"
  100. *
  101. * * DMMP_ERR_IPC_TIMEOUT -- "Timeout when communicate with multipathd,
  102. * try to set bigger timeout value via dmmp_context_timeout_set ()"
  103. *
  104. * * DMMP_ERR_IPC_ERROR -- "Error when communicate with multipathd daemon"
  105. *
  106. * * DMMP_ERR_NO_DAEMON -- "The multipathd daemon not started"
  107. *
  108. * * DMMP_ERR_INCOMPATIBLE -- "The multipathd daemon version is not
  109. * compatible with current library"
  110. *
  111. * * Other invalid error number -- "Invalid argument"
  112. *
  113. * @rc:
  114. * int. Return code by libdmmp functions. When provided error code is not a
  115. * valid error code, return "Invalid argument".
  116. *
  117. * Return:
  118. * const char *. The meaning of provided error code.
  119. *
  120. */
  121. DMMP_DLL_EXPORT const char *dmmp_strerror(int rc);
  122. /**
  123. * dmmp_context_new() - Create struct dmmp_context.
  124. *
  125. * The default logging level (DMMP_LOG_PRIORITY_DEFAULT) is
  126. * DMMP_LOG_PRIORITY_WARNING which means only warning and error message will be
  127. * forward to log handler function. The default log handler function will print
  128. * log message to STDERR, to change so, please use dmmp_context_log_func_set()
  129. * to set your own log handler, check manpage libdmmp.h(3) for detail.
  130. *
  131. * Return:
  132. * Pointer of 'struct dmmp_context'. Should be freed by
  133. * dmmp_context_free().
  134. */
  135. DMMP_DLL_EXPORT struct dmmp_context *dmmp_context_new(void);
  136. /**
  137. * dmmp_context_free() - Release the memory of struct dmmp_context.
  138. *
  139. * Release the memory of struct dmmp_context, but the userdata memory defined
  140. * via dmmp_context_userdata_set() will not be touched.
  141. *
  142. * @ctx:
  143. * Pointer of 'struct dmmp_context'.
  144. * Return:
  145. * void
  146. */
  147. DMMP_DLL_EXPORT void dmmp_context_free(struct dmmp_context *ctx);
  148. /**
  149. * dmmp_context_timeout_set() - Set IPC timeout.
  150. *
  151. * By default, the IPC to multipathd daemon will timeout after 60 seconds.
  152. *
  153. * @ctx:
  154. * Pointer of 'struct dmmp_context'.
  155. * If this pointer is NULL, your program will be terminated by assert.
  156. *
  157. * @tmo:
  158. * Timeout in milliseconds(1 seconds equal 1000 milliseconds).
  159. * 0 means infinite, function only return when error or pass.
  160. *
  161. * Return:
  162. * void
  163. */
  164. DMMP_DLL_EXPORT void dmmp_context_timeout_set(struct dmmp_context *ctx,
  165. unsigned int tmo);
  166. /**
  167. * dmmp_context_timeout_get() - Get IPC timeout.
  168. *
  169. * Retrieve timeout value of IPC connection to multipathd daemon.
  170. *
  171. * @ctx:
  172. * Pointer of 'struct dmmp_context'.
  173. * If this pointer is NULL, your program will be terminated by assert.
  174. *
  175. * Return:
  176. * unsigned int. Timeout in milliseconds.
  177. */
  178. DMMP_DLL_EXPORT unsigned int dmmp_context_timeout_get(struct dmmp_context *ctx);
  179. /**
  180. * dmmp_context_log_priority_set() - Set log priority.
  181. *
  182. *
  183. * When library generates log message, only equal or more important(less value)
  184. * message will be forwarded to log handler function. Valid log priority values
  185. * are:
  186. *
  187. * * DMMP_LOG_PRIORITY_ERROR -- 3
  188. *
  189. * * DMMP_LOG_PRIORITY_WARNING -- 4
  190. *
  191. * * DMMP_LOG_PRIORITY_INFO -- 5
  192. *
  193. * * DMMP_LOG_PRIORITY_DEBUG -- 7
  194. *
  195. * @ctx:
  196. * Pointer of 'struct dmmp_context'.
  197. * If this pointer is NULL, your program will be terminated by assert.
  198. *
  199. * @priority:
  200. * int, log priority.
  201. *
  202. * Return:
  203. * void
  204. */
  205. DMMP_DLL_EXPORT void dmmp_context_log_priority_set(struct dmmp_context *ctx,
  206. int priority);
  207. /**
  208. * dmmp_context_log_priority_get() - Get log priority.
  209. *
  210. * Retrieve current log priority. Valid log priority values are:
  211. *
  212. * * DMMP_LOG_PRIORITY_ERROR -- 3
  213. *
  214. * * DMMP_LOG_PRIORITY_WARNING -- 4
  215. *
  216. * * DMMP_LOG_PRIORITY_INFO -- 5
  217. *
  218. * * DMMP_LOG_PRIORITY_DEBUG -- 7
  219. *
  220. * @ctx:
  221. * Pointer of 'struct dmmp_context'.
  222. * If this pointer is NULL, your program will be terminated by assert.
  223. *
  224. * Return:
  225. * int, log priority.
  226. */
  227. DMMP_DLL_EXPORT int dmmp_context_log_priority_get(struct dmmp_context *ctx);
  228. /**
  229. * dmmp_context_log_func_set() - Set log handler function.
  230. *
  231. * Set custom log handler. The log handler will be invoked when log message
  232. * is equal or more important(less value) than log priority setting.
  233. * Please check manpage libdmmp.h(3) for detail usage.
  234. *
  235. * @ctx:
  236. * Pointer of 'struct dmmp_context'.
  237. * If this pointer is NULL, your program will be terminated by assert.
  238. * @log_func:
  239. * Pointer of log handler function. If set to NULL, all log will be
  240. * ignored.
  241. *
  242. * Return:
  243. * void
  244. */
  245. DMMP_DLL_EXPORT void dmmp_context_log_func_set
  246. (struct dmmp_context *ctx,
  247. void (*log_func)
  248. (struct dmmp_context *ctx, int priority,
  249. const char *file, int line, const char *func_name,
  250. const char *format, va_list args));
  251. /**
  252. * dmmp_context_userdata_set() - Set user data pointer.
  253. *
  254. * Store user data pointer into 'struct dmmp_context'.
  255. *
  256. * @ctx:
  257. * Pointer of 'struct dmmp_context'.
  258. * If this pointer is NULL, your program will be terminated by assert.
  259. * @userdata:
  260. * Pointer of user defined data.
  261. *
  262. * Return:
  263. * void
  264. */
  265. DMMP_DLL_EXPORT void dmmp_context_userdata_set(struct dmmp_context *ctx,
  266. void *userdata);
  267. /**
  268. * dmmp_context_userdata_get() - Get user data pointer.
  269. *
  270. * Retrieve user data pointer from 'struct dmmp_context'.
  271. *
  272. * @ctx:
  273. * Pointer of 'struct dmmp_context'.
  274. * If this pointer is NULL, your program will be terminated by assert.
  275. *
  276. * Return:
  277. * void *. Pointer of user defined data.
  278. */
  279. DMMP_DLL_EXPORT void *dmmp_context_userdata_get(struct dmmp_context *ctx);
  280. /**
  281. * dmmp_mpath_array_get() - Query all existing multipath devices.
  282. *
  283. * Query all existing multipath devices and store them into a pointer array.
  284. * The memory of 'dmmp_mps' should be freed via dmmp_mpath_array_free().
  285. *
  286. * @ctx:
  287. * Pointer of 'struct dmmp_context'.
  288. * If this pointer is NULL, your program will be terminated by assert.
  289. * @dmmp_mps:
  290. * Output pointer array of 'struct dmmp_mpath'.
  291. * If this pointer is NULL, your program will be terminated by assert.
  292. * @dmmp_mp_count:
  293. * Output pointer of uint32_t. Hold the size of 'dmmp_mps' pointer array.
  294. * If this pointer is NULL, your program will be terminated by assert.
  295. *
  296. * Return:
  297. * int. Valid error codes are:
  298. *
  299. * * DMMP_OK
  300. *
  301. * * DMMP_ERR_BUG
  302. *
  303. * * DMMP_ERR_NO_MEMORY
  304. *
  305. * * DMMP_ERR_NO_DAEMON
  306. *
  307. * * DMMP_ERR_INCONSISTENT_DATA
  308. *
  309. * Error number could be converted to string by dmmp_strerror().
  310. */
  311. DMMP_DLL_EXPORT int dmmp_mpath_array_get(struct dmmp_context *ctx,
  312. struct dmmp_mpath ***dmmp_mps,
  313. uint32_t *dmmp_mp_count);
  314. /**
  315. * dmmp_mpath_array_free() - Free 'struct dmmp_mpath' pointer array.
  316. *
  317. * Free the 'dmmp_mps' pointer array generated by dmmp_mpath_array_get().
  318. * If provided 'dmmp_mps' pointer is NULL or dmmp_mp_count == 0, do nothing.
  319. *
  320. * @dmmp_mps:
  321. * Pointer of 'struct dmmp_mpath' array.
  322. * @dmmp_mp_count:
  323. * uint32_t, the size of 'dmmp_mps' pointer array.
  324. *
  325. * Return:
  326. * void
  327. */
  328. DMMP_DLL_EXPORT void dmmp_mpath_array_free(struct dmmp_mpath **dmmp_mps,
  329. uint32_t dmmp_mp_count);
  330. /**
  331. * dmmp_mpath_wwid_get() - Retrieve WWID of certain mpath.
  332. *
  333. * @dmmp_mp:
  334. * Pointer of 'struct dmmp_mpath'.
  335. * If this pointer is NULL, your program will be terminated by assert.
  336. *
  337. * Return:
  338. * const char *. No need to free this memory, the resources will get
  339. * freed when dmmp_mpath_array_free().
  340. */
  341. DMMP_DLL_EXPORT const char *dmmp_mpath_wwid_get(struct dmmp_mpath *dmmp_mp);
  342. /**
  343. * dmmp_mpath_name_get() - Retrieve name(alias) of certain mpath.
  344. *
  345. * Retrieve the name (also known as alias) of certain mpath.
  346. * When the config 'user_friendly_names' been set 'no', the name will be
  347. * identical to WWID retrieved by dmmp_mpath_wwid_get().
  348. *
  349. * @dmmp_mp:
  350. * Pointer of 'struct dmmp_mpath'.
  351. * If this pointer is NULL, your program will be terminated by assert.
  352. *
  353. * Return:
  354. * const char *. No need to free this memory, the resources will get
  355. * freed when dmmp_mpath_array_free().
  356. */
  357. DMMP_DLL_EXPORT const char *dmmp_mpath_name_get(struct dmmp_mpath *dmmp_mp);
  358. /**
  359. * dmmp_mpath_kdev_name_get() - Retrieve kernel DEVNAME of certain mpath.
  360. *
  361. * Retrieve DEVNAME name used by kernel uevent of specified mpath.
  362. * For example: 'dm-1'.
  363. *
  364. * @dmmp_mp:
  365. * Pointer of 'struct dmmp_mpath'.
  366. * If this pointer is NULL, your program will be terminated by assert.
  367. *
  368. * Return:
  369. * const char *. No need to free this memory, the resources will get
  370. * freed when dmmp_mpath_array_free().
  371. */
  372. DMMP_DLL_EXPORT const char *dmmp_mpath_kdev_name_get
  373. (struct dmmp_mpath *dmmp_mp);
  374. /**
  375. * dmmp_path_group_array_get() - Retrieve path groups pointer array.
  376. *
  377. * Retrieve the path groups of certain mpath.
  378. *
  379. * The memory of output pointer array is hold by 'struct dmmp_mpath', no
  380. * need to free this memory, the resources will got freed when
  381. * dmmp_mpath_array_free().
  382. *
  383. * @dmmp_mp:
  384. * Pointer of 'struct dmmp_mpath'.
  385. * If this pointer is NULL, your program will be terminated by assert.
  386. * @dmmp_pgs:
  387. * Output pointer of 'struct dmmp_path_group' pointer array.
  388. * If this pointer is NULL, your program will be terminated by assert.
  389. * @dmmp_pg_count:
  390. * Output pointer of uint32_t. Hold the size of 'dmmp_pgs' pointer array.
  391. * If this pointer is NULL, your program will be terminated by assert.
  392. *
  393. * Return:
  394. * void
  395. */
  396. DMMP_DLL_EXPORT void dmmp_path_group_array_get
  397. (struct dmmp_mpath *dmmp_mp, struct dmmp_path_group ***dmmp_pgs,
  398. uint32_t *dmmp_pg_count);
  399. /**
  400. * dmmp_path_group_id_get() - Retrieve path group ID.
  401. *
  402. * Retrieve the path group ID which could be used to switch active path group
  403. * via command:
  404. *
  405. * multipathd -k'switch multipath mpathb group $id'
  406. *
  407. * @dmmp_pg:
  408. * Pointer of 'struct dmmp_path_group'.
  409. * If this pointer is NULL, your program will be terminated by assert.
  410. *
  411. * Return:
  412. * uint32_t.
  413. */
  414. DMMP_DLL_EXPORT uint32_t dmmp_path_group_id_get
  415. (struct dmmp_path_group *dmmp_pg);
  416. /**
  417. * dmmp_path_group_priority_get() - Retrieve path group priority.
  418. *
  419. * The enabled path group with highest priority will be next active path group
  420. * if active path group down.
  421. *
  422. * @dmmp_pg:
  423. * Pointer of 'struct dmmp_path_group'.
  424. * If this pointer is NULL, your program will be terminated by assert.
  425. *
  426. * Return:
  427. * uint32_t.
  428. */
  429. DMMP_DLL_EXPORT uint32_t dmmp_path_group_priority_get
  430. (struct dmmp_path_group *dmmp_pg);
  431. /**
  432. * dmmp_path_group_status_get() - Retrieve path group status.
  433. *
  434. * The valid path group statuses are:
  435. *
  436. * * DMMP_PATH_GROUP_STATUS_UNKNOWN
  437. *
  438. * * DMMP_PATH_GROUP_STATUS_ENABLED -- standby to be active
  439. *
  440. * * DMMP_PATH_GROUP_STATUS_DISABLED -- disabled due to all path down
  441. *
  442. * * DMMP_PATH_GROUP_STATUS_ACTIVE -- selected to handle I/O
  443. *
  444. * @dmmp_pg:
  445. * Pointer of 'struct dmmp_path_group'.
  446. * If this pointer is NULL, your program will be terminated by assert.
  447. *
  448. * Return:
  449. * uint32_t.
  450. */
  451. DMMP_DLL_EXPORT uint32_t dmmp_path_group_status_get
  452. (struct dmmp_path_group *dmmp_pg);
  453. /**
  454. * dmmp_path_group_status_str() - Convert path group status to string.
  455. *
  456. * Convert path group status uint32_t to string (const char *).
  457. *
  458. * @pg_status:
  459. * uint32_t. Path group status.
  460. * When provided value is not a valid path group status, return "Invalid
  461. * argument".
  462. *
  463. * Return:
  464. * const char *. Valid string are:
  465. *
  466. * * "Invalid argument"
  467. *
  468. * * "undef"
  469. *
  470. * * "enabled"
  471. *
  472. * * "disabled"
  473. *
  474. * * "active"
  475. */
  476. DMMP_DLL_EXPORT const char *dmmp_path_group_status_str(uint32_t pg_status);
  477. /**
  478. * dmmp_path_group_selector_get() - Retrieve path group selector.
  479. *
  480. * Path group selector determine which path in active path group will be
  481. * use to next I/O.
  482. *
  483. * @dmmp_pg:
  484. * Pointer of 'struct dmmp_path_group'.
  485. * If this pointer is NULL, your program will be terminated by assert.
  486. *
  487. * Return:
  488. * const char *.
  489. */
  490. DMMP_DLL_EXPORT const char *dmmp_path_group_selector_get
  491. (struct dmmp_path_group *dmmp_pg);
  492. /**
  493. * dmmp_path_array_get() - Retrieve path pointer array.
  494. *
  495. * The memory of output pointer array is hold by 'struct dmmp_mpath', no
  496. * need to free this memory, the resources will got freed when
  497. * dmmp_mpath_array_free().
  498. *
  499. * @dmmp_pg:
  500. * Pointer of 'struct dmmp_path_group'.
  501. * If this pointer is NULL, your program will be terminated by assert.
  502. * @dmmp_ps:
  503. * Output pointer of 'struct dmmp_path' pointer array.
  504. * If this pointer is NULL, your program will be terminated by assert.
  505. * @dmmp_p_count:
  506. * Output pointer of uint32_t. Hold the size of 'dmmp_ps' pointer array.
  507. * If this pointer is NULL, your program will be terminated by assert.
  508. *
  509. * Return:
  510. * void
  511. */
  512. DMMP_DLL_EXPORT void dmmp_path_array_get(struct dmmp_path_group *dmmp_pg,
  513. struct dmmp_path ***dmmp_ps,
  514. uint32_t *dmmp_p_count);
  515. /**
  516. * dmmp_path_blk_name_get() - Retrieve block name.
  517. *
  518. * Retrieve block name of certain path. The example of block names are "sda",
  519. * "nvme0n1".
  520. *
  521. * @dmmp_p:
  522. * Pointer of 'struct dmmp_path'.
  523. * If this pointer is NULL, your program will be terminated by assert.
  524. *
  525. * Return:
  526. * const char *. No need to free this memory, the resources will get
  527. * freed when dmmp_mpath_array_free().
  528. */
  529. DMMP_DLL_EXPORT const char *dmmp_path_blk_name_get(struct dmmp_path *dmmp_p);
  530. /**
  531. * dmmp_path_status_get() - Retrieve the path status.
  532. *
  533. * The valid path statuses are:
  534. *
  535. * * DMMP_PATH_STATUS_UNKNOWN
  536. *
  537. * * DMMP_PATH_STATUS_DOWN
  538. *
  539. * Path is down and you shouldn't try to send commands to it.
  540. *
  541. * * DMMP_PATH_STATUS_UP
  542. *
  543. * Path is up and I/O can be sent to it.
  544. *
  545. * * DMMP_PATH_STATUS_SHAKY
  546. *
  547. * Only emc_clariion checker when path not available for "normal"
  548. * operations.
  549. *
  550. * * DMMP_PATH_STATUS_GHOST
  551. *
  552. * Only hp_sw and rdac checkers. Indicates a "passive/standby"
  553. * path on active/passive HP arrays. These paths will return valid
  554. * answers to certain SCSI commands (tur, read_capacity, inquiry,
  555. * start_stop), but will fail I/O commands. The path needs an
  556. * initialization command to be sent to it in order for I/Os to
  557. * succeed.
  558. *
  559. * * DMMP_PATH_STATUS_PENDING
  560. *
  561. * Available for all async checkers when a check IO is in flight.
  562. *
  563. * * DMMP_PATH_STATUS_TIMEOUT
  564. *
  565. * Only tur checker when command timed out.
  566. *
  567. * * DMMP_PATH_STATUS_DELAYED
  568. *
  569. * If a path fails after being up for less than delay_watch_checks checks,
  570. * when it comes back up again, it will not be marked as up until it has
  571. * been up for delay_wait_checks checks. During this time, it is marked as
  572. * "delayed".
  573. *
  574. * @dmmp_p:
  575. * Pointer of 'struct dmmp_path'.
  576. * If this pointer is NULL, your program will be terminated by assert.
  577. *
  578. * Return:
  579. * uint32_t.
  580. */
  581. DMMP_DLL_EXPORT uint32_t dmmp_path_status_get(struct dmmp_path *dmmp_p);
  582. /**
  583. * dmmp_path_status_str() - Convert path status to string.
  584. *
  585. * Convert path status uint32_t to string (const char *):
  586. *
  587. * * DMMP_PATH_STATUS_UNKNOWN -- "undef"
  588. *
  589. * * DMMP_PATH_STATUS_DOWN -- "faulty"
  590. *
  591. * * DMMP_PATH_STATUS_UP -- "ready"
  592. *
  593. * * DMMP_PATH_STATUS_SHAKY -- "shaky"
  594. *
  595. * * DMMP_PATH_STATUS_GHOST -- "ghost"
  596. *
  597. * * DMMP_PATH_STATUS_PENDING -- "pending"
  598. *
  599. * * DMMP_PATH_STATUS_TIMEOUT -- "timeout"
  600. *
  601. * * DMMP_PATH_STATUS_REMOVED -- "removed"
  602. *
  603. * * DMMP_PATH_STATUS_DELAYED -- "delayed"
  604. *
  605. * @path_status:
  606. * uint32_t. Path status.
  607. * When provided value is not a valid path status, return
  608. * "Invalid argument".
  609. *
  610. * Return:
  611. * const char *. The meaning of status value.
  612. */
  613. DMMP_DLL_EXPORT const char *dmmp_path_status_str(uint32_t path_status);
  614. /**
  615. * dmmp_flush_mpath() - Flush specified multipath device map if unused.
  616. *
  617. * Flush a multipath device map specified as parameter, if unused.
  618. *
  619. * @ctx:
  620. * Pointer of 'struct dmmp_context'.
  621. * If this pointer is NULL, your program will be terminated by assert.
  622. * @mpath_name:
  623. * const char *. The name of multipath device map.
  624. *
  625. * Return:
  626. * int. Valid error codes are:
  627. *
  628. * * DMMP_OK
  629. *
  630. * * DMMP_ERR_BUG
  631. *
  632. * * DMMP_ERR_NO_MEMORY
  633. *
  634. * * DMMP_ERR_NO_DAEMON
  635. *
  636. * * DMMP_ERR_MPATH_BUSY
  637. *
  638. * * DMMP_ERR_MPATH_NOT_FOUND
  639. *
  640. * * DMMP_ERR_INVALID_ARGUMENT
  641. *
  642. * * DMMP_ERR_PERMISSION_DENY
  643. *
  644. * Error number could be converted to string by dmmp_strerror().
  645. */
  646. DMMP_DLL_EXPORT int dmmp_flush_mpath(struct dmmp_context *ctx,
  647. const char *mpath_name);
  648. /**
  649. * dmmp_reconfig() - Instruct multipathd daemon to do reconfiguration.
  650. *
  651. * Instruct multipathd daemon to do reconfiguration.
  652. *
  653. * @ctx:
  654. * Pointer of 'struct dmmp_context'.
  655. * If this pointer is NULL, your program will be terminated by assert.
  656. *
  657. * Return:
  658. * int. Valid error codes are:
  659. *
  660. * * DMMP_OK
  661. *
  662. * * DMMP_ERR_BUG
  663. *
  664. * * DMMP_ERR_NO_MEMORY
  665. *
  666. * * DMMP_ERR_NO_DAEMON
  667. *
  668. * * DMMP_ERR_PERMISSION_DENY
  669. *
  670. * Error number could be converted to string by dmmp_strerror().
  671. */
  672. DMMP_DLL_EXPORT int dmmp_reconfig(struct dmmp_context *ctx);
  673. /**
  674. * dmmp_last_error_msg() - Retrieves the last error message.
  675. *
  676. * Retrieves the last error message.
  677. *
  678. * @ctx:
  679. * Pointer of 'struct dmmp_context'.
  680. * If this pointer is NULL, your program will be terminated by assert.
  681. *
  682. * Return:
  683. * const char *. No need to free this memory, the resources will get
  684. * freed when dmmp_context_free().
  685. */
  686. DMMP_DLL_EXPORT const char *dmmp_last_error_msg(struct dmmp_context *ctx);
  687. #ifdef __cplusplus
  688. } /* End of extern "C" */
  689. #endif
  690. #endif /* End of _LIB_DMMP_H_ */