lustreapi(3) Lustre Application Interface Library lustreapi(3) NNAAMMEE llapi_hsm_state_get, llapi_hsm_state_get_fd - get HSM state information for a file on Lustre filesystem SSYYNNOOPPSSIISS ##iinncclluuddee <> iinntt llllaappii__hhssmm__ssttaattee__ggeett((ccoonnsstt cchhaarr **_p_a_t_h,, ssttrruucctt hhssmm__uusseerr__ssttaattee **_h_u_s));; iinntt llllaappii__hhssmm__ssttaattee__ggeett__ffdd((iinntt _f_d,, ssttrruucctt hhssmm__uusseerr__ssttaattee **_h_u_s));; DDEESSCCRRIIPPTTIIOONN llllaappii__hhssmm__ssttaattee__ggeett(()),, llllaappii__hhssmm__ssttaattee__ggeett__ffdd(()) read HSM state flags and HSM archive ID for file pointed by _p_a_t_h or _f_d. Information is returned in _h_u_s which should already be allocated. struct hsm_user_state { __u32 hus_states; __u32 hus_archive_id; }; _h_u_s___s_t_a_t_e_s Flag mask for different HSM states and policy hints. See _h_s_m___s_t_a_t_e_s enum for full list. _h_u_s___a_r_c_h_i_v_e___i_d External HSM archive ID associated with this file. enum hsm_states { HS_EXISTS, HS_DIRTY, HS_RELEASED, HS_ARCHIVED, HS_NORELEASE, HS_NOARCHIVE, HS_LOST, }; _H_S___E_X_I_S_T_S The file has been assigned to an archive. _H_S___D_I_R_T_Y The file content is not in sync with the HSM ar- chive. This flag is set automatically when a file with HS_EXISTS set is changed, and can be set explicitly by an user. _H_S___R_E_L_E_A_S_E_D The file content is not present in Lustre, and most be restored from the HSM archive before the file can be accessed. File must also be HS_ARCHIVED state and not HS_DIRTY. _H_S___A_R_C_H_I_V_E_D An up-to-date file copy exists in HSM archive. _H_S___N_O_R_E_L_E_A_S_E This flag indicates the file should never be released. File data will stay in Lustre even if a copy exists in HSM backend. This can be set by user. _H_S___N_O_A_R_C_H_I_V_E File should never be archived. Useful if this is a temporary file by example. This can be set by a user. _H_S___L_O_S_T File copy in the archive is not usable anymore and file could not be restored. If this file is also HS_RELEASED, then attempts to access the file will return ENODATA. This is can be set an adminstra- tor. RREETTUURRNN VVAALLUUEESS llllaappii__hhssmm__ssttaattee__ggeett(()) llllaappii__hhssmm__ssttaattee__ggeett__ffdd(()) return: 0 on success != 0 on failure, _e_r_r_n_o is set appropriately. EERRRROORRSS ENOMEM failed to allocate memory. ENAMETOOLONG _p_a_t_h was too long. ENOENT _p_a_t_h does not point to a file or a directory. ENOTTY _p_a_t_h does not point to a Lustre filesystem. EEXXAAMMPPLLEE #include #include #include #include int main(int argc, char **argv) { struct hsm_user_state hus; int rc; if (argc < 2) { fprintf(stderr, "usage: prog FILEPATH\n"); exit(1); } rc = llapi_hsm_state_get(argv[1], &hus); if (rc) { fprintf(stderr, "can't get hsm state for %s: %s\n", argv[1], strerror(errno = -rc)); exit(rc); } if (hus.hus_states & HS_RELEASED) printf(" released"); if (hus.hus_states & HS_EXISTS) printf(" exists"); if (hus.hus_states & HS_ARCHIVED) printf(" archived"); /* Display settable flags */ if (hus.hus_states & HS_NORELEASE) printf(" never_release"); if (hus.hus_states & HS_NOARCHIVE) printf(" never_archive"); if (hus.hus_states & HS_DIRTY) printf(" dirty"); if (hus.hus_states & HS_LOST) printf(" lost_from_hsm"); if (hus.hus_archive_id != 0) printf(", archive_id:%d", hus.hus_archive_id); printf("\n"); exit(0); } SSEEEE AALLSSOO lluussttrree(7), lluussttrreeaappii(7), llllaappii__hhssmm__ssttaattee__sseett(3), llllaappii__hhssmm__ssttaattee__sseett__ffdd(3), llffss--hhssmm(1) Lustre 2014 Jul 30 lustreapi(3)