Line data Source code
1 : #ifndef HEADER_fd_src_discof_restore_utils_fd_vinyl_admin_h 2 : #define HEADER_fd_src_discof_restore_utils_fd_vinyl_admin_h 3 : 4 : #include "../../../flamenco/fd_rwlock.h" 5 : 6 0 : #define FD_VINYL_ADMIN_MAGIC (0XF17EDA2C7E412AD8) /* FIREDANCER VINYL ADMIN */ 7 : 8 : /* Vinyl admin synchronization object. */ 9 : #define FD_VINYL_ADMIN_WR_SEQ_CNT_MAX (8UL) 10 : 11 0 : #define FD_VINYL_ADMIN_STATUS_INIT_PENDING (0UL) 12 0 : #define FD_VINYL_ADMIN_STATUS_INIT_DONE (1UL) 13 0 : #define FD_VINYL_ADMIN_STATUS_UPDATING (2UL) 14 0 : #define FD_VINYL_ADMIN_STATUS_SNAPSHOT_FULL (3UL) 15 0 : #define FD_VINYL_ADMIN_STATUS_SNAPSHOT_INCR (4UL) 16 : #define FD_VINYL_ADMIN_STATUS_ERROR (ULONG_MAX) 17 : 18 : struct fd_vinyl_admin { 19 : ulong magic; /* ==FD_VINYL_ADMIN_MAGIC */ 20 : 21 : ulong status; 22 : 23 : struct { 24 : ulong past; 25 : ulong present; 26 : } bstream_seq; 27 : 28 : ulong wr_seq[FD_VINYL_ADMIN_WR_SEQ_CNT_MAX]; 29 : ulong wr_cnt; 30 : 31 : fd_rwlock_t lock; 32 : }; 33 : typedef struct fd_vinyl_admin fd_vinyl_admin_t; 34 : 35 : FD_PROTOTYPES_BEGIN 36 : 37 : /* fd_vinyl_admin_{align, footprint} return align and footprint */ 38 : 39 : ulong 40 : fd_vinyl_admin_align( void ); 41 : 42 : ulong 43 : fd_vinyl_admin_footprint( void ); 44 : 45 : /* fd_vinyl_admin_new initializes a new vinyl admin object. It returns 46 : a void pointer to the base of the fd_vinyl_admin_t in memory. On 47 : return, it does not retain ownership of the memory. */ 48 : 49 : void * 50 : fd_vinyl_admin_new( void * mem ); 51 : 52 : /* fd_vinyl_admin_join return a fd_vinyl_admin_t pointer on success, 53 : NULL otherwise. A condition for failure is e.g. an incorrect 54 : magic value (meaning the memory region does not correspond to a 55 : properly initialized vinyl admin object). On return, it does not 56 : retain ownership of the memory.*/ 57 : 58 : fd_vinyl_admin_t * 59 : fd_vinyl_admin_join( void * _admin ); 60 : 61 : /* fd_vinyl_admin_leave leaves the vinyl admin object, returning a void 62 : pointer to the memory region. */ 63 : 64 : void * 65 : fd_vinyl_admin_leave( fd_vinyl_admin_t * _admin ); 66 : 67 : /* fd_vinyl_admin_delete leaves the memory region, returning a void 68 : pointer to the memory region. */ 69 : 70 : void * 71 : fd_vinyl_admin_delete( void * _admin ); 72 : 73 : /* fd_vinyl_admin_query does a volatile read of the vinyl admin object 74 : field. It does not handle the rwlock. */ 75 : 76 : ulong 77 : fd_vinyl_admin_ulong_query( ulong const * _field ); 78 : 79 : /* fd_vinyl_admin_update modifies the given field of a vinyl admin 80 : object. It does not handle the rwlock. */ 81 : 82 : void 83 : fd_vinyl_admin_ulong_update( ulong * _field, 84 : ulong value ); 85 : 86 : FD_PROTOTYPES_END 87 : 88 : #endif /* HEADER_fd_src_discof_restore_utils_fd_vinyl_admin_h */