void sc_report_handler::report(sc_severity severity_, int id_, const char* msg_, const char* file_, int line_ ) { sc_msg_def * md = sc_report_handler::mdlookup(id_); if ( !md ) { md = sc_report_handler::add_msg_type(unknown_id); md->id = id_; } if ( severity_ == SC_WARNING && warnings_are_errors ) severity_ = SC_ERROR; sc_actions actions = execute(md, severity_); sc_report rep(severity_, md, msg_, file_, line_); if ( actions & SC_CACHE_REPORT ) cache_report(rep); if ( severity_ == SC_ERROR ) actions |= SC_THROW; else if ( severity_ == SC_FATAL ) actions |= SC_ABORT; handler(rep, actions); }
void sc_report_handler::report(sc_severity severity_, const char * msg_type_, const char * msg_, const char * file_, int line_) { sc_msg_def * md = mdlookup(msg_type_); // If the severity of the report is SC_INFO and the maximum verbosity // level is less than SC_MEDIUM return without any action. if ( (severity_ == SC_INFO) && (SC_MEDIUM > verbosity_level) ) return; // Process the report: if ( !md ) md = add_msg_type(msg_type_); sc_actions actions = execute(md, severity_); sc_report rep(severity_, md, msg_, file_, line_); if ( actions & SC_CACHE_REPORT ) cache_report(rep); handler(rep, actions); }
void libxfs_report(FILE *fp) { time_t t; char *c; cache_report(fp, "libxfs_bcache", libxfs_bcache); t = time(NULL); c = asctime(localtime(&t)); fprintf(fp, "%s", c); }
void sc_report_handler::report(sc_severity severity_, const char * msg_type_, const char * msg_, const char * file_, int line_) { sc_msg_def * md = mdlookup(msg_type_); if ( !md ) md = add_msg_type(msg_type_); sc_actions actions = execute(md, severity_); sc_report rep(severity_, md, msg_, file_, line_); if ( actions & SC_CACHE_REPORT ) cache_report(rep); handler(rep, actions); }
/* ** Get the time and save in the phase time ** array. */ char * timestamp(int end, int phase, char *buf) { time_t now; struct tm *tmp; if (verbose > 1) cache_report(stderr, "libxfs_bcache", libxfs_bcache); now = time(NULL); if (end) { phase_times[phase].end = now; timediff(phase); /* total time in slot zero */ phase_times[0].end = now; timediff(0); if (phase < 7) { phase_times[phase+1].start = now; current_phase = phase + 1; } } else { phase_times[phase].start = now; current_phase = phase; } if (buf) { tmp = localtime((const time_t *)&now); sprintf(buf, _("%02d:%02d:%02d"), tmp->tm_hour, tmp->tm_min, tmp->tm_sec); } return(buf); }
static int xmp_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { int fd; ino_t ino; int res = 0; static int cnt = 0; struct loop_file_info *info = (struct loop_file_info *) (unsigned long) fi->fh; fd = info->fd; ino = info->ino; if (fd == -1) return -errno; if (size > max_block_size) { return -ENOMEM; } if (fp_sync) { fprintf(fp_sync, "cnt %d read %s inode %llu size %lu off %ld\n", cnt, path, (unsigned long long) ino, size, offset); fflush(fp_sync); cnt++; } /* fill in the request */ sem_t sem; sem_init(&sem, 0, 0); struct cache_entry response; struct elm_read_req req = { .fd = fd, .ino = ino, .size = size, .offset = offset, .sem = &sem, .refcnt = 1, .p_response = &response }; /* check for already cached */ pthread_mutex_lock(&cache_lock); int get_rc; struct cache_entry *result; get_rc = cache->cache_lookup(cache, &req, &result); if (get_rc == 0 && result->rc > 0) { memcpy(buf, result->data, result->rc); fprintf(fp_sync, "Found record already cached " "ref = %d data = %p rc = %ld\n", *result->refcnt, result->data, result->rc); fflush(fp_sync); if (result->rc > 0) { cache_hit_bytes += result->rc; } cache_report(fp_sync, cache_hit_bytes, cache_miss_bytes); res = result->rc; pthread_mutex_unlock(&cache_lock); } else if (get_rc == -1) { pthread_mutex_unlock(&cache_lock); return -EIO; } else { pthread_mutex_unlock(&cache_lock); pthread_mutex_lock(&req_queue_lock); if (circ_enq(&req_queue, &req)) { return -EBUSY; } } int i; struct elm_read_req prefetch_req = req; for (i=0; i<prefetch_aggressiveness; i++) { prefetch_req.offset += prefetch_req.size; prefetch_req.sem = NULL; prefetch_req.refcnt = 0; prefetch_req.p_response = NULL; if (prefetch_req.offset + prefetch_req.size > info->st_buf.st_size) { /* XXX */ break; } /* Prefetch requests are advisory only. * If the queue is full, it may not be an error. */ if (circ_enq(&req_queue, &prefetch_req)) { break; } } int q_cnt = circ_cnt(&req_queue); fprintf(fp_sync, "req_queue_cnt = %d\n", q_cnt); fflush(fp_sync); pthread_cond_signal(&req_condition); pthread_mutex_unlock(&req_queue_lock); if (get_rc == 0) { /* If it was already in cache no need to wait. */ return res; } /* Wait for the response */ sem_wait(&sem); fprintf(fp_sync, "got response\n"); fflush(fp_sync); pthread_mutex_lock(&cache_lock); /* Check the response */ result = &response; if (result->rc >= 0) { memcpy(buf, result->data, result->rc); } res = result->rc; if (*result->refcnt > 0) { *result->refcnt -= 1; } cache_report(fp_sync, cache_hit_bytes, cache_miss_bytes); pthread_mutex_unlock(&cache_lock); sem_destroy(&sem); return res; } static int xmp_write(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { int fd; int res; (void) fi; fd = open(path, O_WRONLY); if (fd == -1) return -errno; res = pwrite(fd, buf, size, offset); if (res == -1) res = -errno; close(fd); return res; }