Lines Matching refs:dp
50 mhd_drive_t *dp
59 dlp->dl_drives[dlp->dl_ndrive++] = dp;
68 mhd_drive_t *dp
75 if (dlp->dl_drives[i] == dp)
78 assert(dlp->dl_drives[i] == dp);
102 mhd_drive_t *dp,
107 mhd_drive_set_t *sp = dp->dr_sp;
108 mhd_state_t old_state = dp->dr_state;
115 dp->dr_rname, dp->dr_state, new_state));
116 dp->dr_state = new_state;
117 mhd_cv_broadcast(&dp->dr_cv);
135 mhde_perror(mhep, dp->dr_rname);
149 mhd_drive_t *dp,
154 return (mhd_state(dp, (dp->dr_state | new_state), mhep));
159 mhd_drive_t *dp,
164 return (mhd_state(dp, (dp->dr_state & ~new_state), mhep));
172 mhd_drive_t *dp,
176 mhd_drive_set_t *sp = dp->dr_sp;
183 if (DRIVE_IS_IDLE(dp))
185 if (mhd_state(dp, DRIVE_IDLING, mhep) != 0)
196 mhd_drive_t *dp
199 mhd_drive_set_t *sp = dp->dr_sp;
207 assert(dp->dr_fd >= 0);
208 assert(dp->dr_state == DRIVE_RESERVING);
219 err = ioctl(dp->dr_fd, MHIOCTKOWN, &tkown);
223 mhd_perror("%s: MHIOCTKOWN", dp->dr_rname);
224 (void) mhd_state(dp, DRIVE_ERRORED, NULL);
225 dp->dr_errnum = errno;
230 MHDPRINTF(("%s: MHIOCTKOWN: succeeded\n", dp->dr_rname));
231 (void) mhd_state(dp, DRIVE_IDLE, NULL);
240 mhd_drive_t *dp
243 mhd_drive_set_t *sp = dp->dr_sp;
251 assert(dp->dr_fd >= 0);
252 assert(dp->dr_state == DRIVE_FAILFASTING);
257 err = ioctl(dp->dr_fd, MHIOCENFAILFAST, &ff);
261 mhd_perror("%s: MHIOCENFAILFAST%s", dp->dr_rname, release);
262 (void) mhd_state(dp, DRIVE_ERRORED, NULL);
263 dp->dr_errnum = errno;
269 dp->dr_rname, release));
270 (void) mhd_state(dp, DRIVE_IDLE, NULL);
279 mhd_drive_t *dp
282 mhd_drive_set_t *sp = dp->dr_sp;
289 assert(dp->dr_fd >= 0);
290 assert(dp->dr_state == DRIVE_RELEASING);
295 err = ioctl(dp->dr_fd, MHIOCENFAILFAST, &ff);
299 mhd_perror("%s: MHIOCENFAILFAST (release)", dp->dr_rname);
300 (void) mhd_state(dp, DRIVE_ERRORED, NULL);
301 dp->dr_errnum = errno;
305 dp->dr_rname));
310 err = ioctl(dp->dr_fd, MHIOCRELEASE, NULL);
314 mhd_perror("%s: MHIOCRELEASE", dp->dr_rname);
315 (void) mhd_state(dp, DRIVE_ERRORED, NULL);
316 dp->dr_errnum = errno;
321 MHDPRINTF(("%s: MHIOCRELEASE: succeeded\n", dp->dr_rname));
322 (void) mhd_state(dp, DRIVE_IDLE, NULL);
331 mhd_drive_t *dp
334 mhd_drive_set_t *sp = dp->dr_sp;
341 assert(dp->dr_fd >= 0);
342 assert(dp->dr_state & (DRIVE_PROBING | DRIVE_STATUSING));
347 err = ioctl(dp->dr_fd, MHIOCSTATUS, NULL);
351 if (! (dp->dr_state & (DRIVE_PROBING | DRIVE_STATUSING)))
355 if (dp->dr_state & DRIVE_STATUSING) {
358 dp->dr_rname));
359 dp->dr_errnum = MHD_E_RESERVED;
361 mhd_perror("%s: MHIOCSTATUS", dp->dr_rname);
362 dp->dr_errnum = errno;
365 dp->dr_rname));
366 dp->dr_errnum = 0;
368 (void) mhd_state_clr(dp, DRIVE_STATUSING, NULL);
372 if (dp->dr_state & DRIVE_PROBING) {
375 dp->dr_time = now;
378 sp->sr_name, dp->dr_rname);
635 mhd_drive_t *dp,
639 mhd_cinfo_t *cinfop = &dp->dr_drive_id.did_cinfo;
719 mhd_drive_t *dp,
723 mhd_cinfo_t *cinfop = &dp->dr_drive_id.did_cinfo;
747 match_SSA200(dp, path);
761 mhd_drive_t *dp
764 mhd_drive_set_t *sp = dp->dr_sp;
776 assert(dp->dr_fd >= 0);
777 assert(dp->dr_state & DRIVE_IDENTING);
780 (void) memset(&dp->dr_drive_id, 0, sizeof (dp->dr_drive_id));
783 if (dp->dr_state & DRIVE_SERIALING) {
797 err = ioctl(dp->dr_fd, USCSICMD, &ucmd);
803 dp->dr_rname, errno));
804 dp->dr_drive_id.did_flags &= ~MHD_DID_SERIAL;
810 dp->dr_rname));
811 dp->dr_drive_id.did_flags |= MHD_DID_SERIAL;
812 p = dp->dr_drive_id.did_serial;
813 e = p + sizeof (dp->dr_drive_id.did_serial);
827 for (p = dp->dr_drive_id.did_serial; (p < e); ++p) {
833 dp->dr_drive_id.did_flags &= ~MHD_DID_SERIAL;
837 if (dp->dr_state & DRIVE_VTOCING) {
841 err = read_extvtoc(dp->dr_fd, &vtoc_buf);
846 dp->dr_rname, errno));
847 dp->dr_drive_id.did_flags &= ~MHD_DID_TIME;
850 dp->dr_rname));
851 dp->dr_drive_id.did_flags |= MHD_DID_TIME;
852 dp->dr_drive_id.did_time = vtoc_buf.timestamp[0];
855 dp->dr_drive_id.did_flags &= ~MHD_DID_TIME;
859 if (dp->dr_state & DRIVE_CINFOING) {
862 len = readlink(dp->dr_rname0, path, (sizeof (path) - 1));
871 dp->dr_rname0, errno));
872 dp->dr_drive_id.did_flags &= ~MHD_DID_CINFO;
875 dp->dr_rname0));
876 dp->dr_drive_id.did_flags |= MHD_DID_CINFO;
877 (void) memset(&dp->dr_drive_id.did_cinfo, 0,
878 sizeof (dp->dr_drive_id.did_cinfo));
879 match_SSA100(dp, path);
882 dp->dr_drive_id.did_flags &= ~MHD_DID_CINFO;
886 (void) mhd_state_clr(dp, DRIVE_IDENTING, NULL);
895 mhd_drive_t *dp
898 mhd_drive_set_t *sp = dp->dr_sp;
900 /* wait for dp->dr_thread to be filled in */
908 assert(dp->dr_thread == thr_self());
911 if (sp != dp->dr_sp) {
913 dp->dr_rname, sp->sr_name, dp->dr_sp->sr_name));
916 sp = dp->dr_sp;
921 if ((dp->dr_fd < 0) && (! (DRIVE_IS_IDLE(dp) ||
922 (dp->dr_state == DRIVE_IDLING)))) {
927 dp->dr_fd = open(dp->dr_rname0, (O_RDWR|O_NDELAY), 0);
930 if (dp->dr_fd < 0) {
931 mhd_perror("%s: open", dp->dr_rname);
932 (void) mhd_state(dp, DRIVE_ERRORED, NULL);
933 dp->dr_errnum = errno;
939 switch (dp->dr_state) {
941 MHDPRINTF1(("%s: IDLE\n", dp->dr_rname));
946 dp->dr_rname, dp->dr_errnum));
950 (void) mhd_state(dp, DRIVE_IDLE, NULL);
954 MHDPRINTF1(("%s: RESERVING\n", dp->dr_rname));
955 (void) mhd_reserve(dp);
956 assert(DRIVE_IS_IDLE(dp));
960 MHDPRINTF1(("%s: FAILFASTING\n", dp->dr_rname));
961 (void) mhd_failfast(dp);
962 assert(DRIVE_IS_IDLE(dp));
966 MHDPRINTF1(("%s: RELEASING\n", dp->dr_rname));
967 (void) mhd_release(dp);
968 assert(DRIVE_IS_IDLE(dp));
973 assert(! (dp->dr_state &
975 if (dp->dr_state & (DRIVE_PROBING | DRIVE_STATUSING)) {
976 MHDPRINTF1(("%s: PROBING\n", dp->dr_rname));
977 (void) mhd_probe(dp);
978 assert(! (dp->dr_state & DRIVE_STATUSING));
980 if (dp->dr_state & DRIVE_IDENTING) {
981 MHDPRINTF1(("%s: IDENTING\n", dp->dr_rname));
982 (void) mhd_ident(dp);
983 assert(! (dp->dr_state & DRIVE_IDENTING));
990 if ((dp->dr_fd >= 0) && (DRIVE_IS_IDLE(dp))) {
995 (void) close(dp->dr_fd); /* sd/ssd bug */
998 dp->dr_fd = -1;
1005 if (! DRIVE_IS_IDLE(dp))
1009 if (! (dp->dr_state & DRIVE_PROBING)) {
1010 mhd_cv_wait(&dp->dr_cv, &sp->sr_mx);
1012 mhd_cv_timedwait(&dp->dr_cv, &sp->sr_mx,
1023 mhd_drive_t *dp,
1027 mhd_drive_set_t *sp = dp->dr_sp;
1033 assert(dp->dr_thread == NULL);
1037 (void *)dp, (THR_DETACHED | THR_BOUND), &thread) != 0) {
1041 dp->dr_thread = thread;
1096 mhd_drive_t *dp = NULL;
1103 if ((dp = mhd_find_drive(rname)) != NULL) {
1104 mhd_drive_set_t *oldsp = dp->dr_sp;
1110 if (mhd_idle(dp, mhep) != 0) {
1115 mhd_del_drive_from_set(dp);
1118 mhd_add_drive_to_set(sp, dp);
1122 return (dp);
1131 dp = Zalloc(sizeof (*dp));
1132 dp->dr_sp = sp;
1133 dp->dr_rname = Strdup(rname);
1134 dp->dr_rname0 = rname0;
1135 mhd_cv_init(&dp->dr_cv);
1136 dp->dr_thread = NULL;
1137 dp->dr_fd = -1;
1138 dp->dr_state = DRIVE_IDLE;
1142 dp->dr_fd = *fdp;
1147 mhd_add_drive_to_set(sp, dp);
1150 if (mhd_thread_create(dp, mhep) != 0) {
1151 Free(dp->dr_rname0);
1152 Free(dp->dr_rname);
1153 Free(dp);
1158 return (dp);
1172 mhd_drive_t *dp;
1178 if ((dp = mhd_find_drive(rname)) != NULL)
1179 return (dp);
1183 dp = mhd_create_drive(null_sp, rname, fdp, mhep);
1187 return (dp);