src/worker.cc
// Set various parameters that control the behaviour of the test.
// -1 is used as a sentinel value on each parameter (except non_destructive)
// to indicate that the parameter not be set.
Set various parameters that control the behaviour of the test.
1 is used as a sentinel value on each parameter (except non_destructive)
to indicate that the parameter not be set.
Set various parameters that control the behaviour of the test . 1 is used as a sentinel value on each parameter ( except non_destructive ) to indicate that the parameter not be set .
bool DiskThread::SetParameters(int read_block_size,
                               int write_block_size,
                               int64 segment_size,
                               int64 cache_size,
                               int blocks_per_segment,
                               int64 read_threshold,
                               int64 write_threshold,
                               int non_destructive) {
  if (read_block_size != -1) {
    if (read_block_size % kSectorSize != 0) {
      logprintf(0, "Process Error: Block size must be a multiple of %d "
                "(thread %d).\n", kSectorSize, thread_num_);
      return false;
    }
    read_block_size_ = read_block_size;
  }
  if (write_block_size != -1) {
    if (write_block_size % kSectorSize != 0) {
      logprintf(0, "Process Error: Write block size must be a multiple "
                "of %d (thread %d).\n", kSectorSize, thread_num_);
      return false;
    }
    if (write_block_size % read_block_size_ != 0) {
      logprintf(0, "Process Error: Write block size must be a multiple "
                "of the read block size, which is %d (thread %d).\n",
                read_block_size_, thread_num_);
      return false;
    }
    write_block_size_ = write_block_size;
  } else {
    if (read_block_size_ > write_block_size_) {
      logprintf(5, "Log: Assuming write block size equal to read block size, "
                "which is %d (thread %d).\n", read_block_size_,
                thread_num_);
      write_block_size_ = read_block_size_;
    } else {
      if (write_block_size_ % read_block_size_ != 0) {
        logprintf(0, "Process Error: Write block size (defined as %d) must "
                  "be a multiple of the read block size, which is %d "
                  "(thread %d).\n", write_block_size_, read_block_size_,
                  thread_num_);
        return false;
      }
    }
  }
  if (cache_size != -1) {
    cache_size_ = cache_size;
  }
  if (blocks_per_segment != -1) {
    if (blocks_per_segment <= 0) {
      logprintf(0, "Process Error: Blocks per segment must be greater than "
                   "zero.\n (thread %d)", thread_num_);
      return false;
    }
    blocks_per_segment_ = blocks_per_segment;
  }
  if (read_threshold != -1) {
    if (read_threshold <= 0) {
      logprintf(0, "Process Error: Read threshold must be greater than "
                   "zero (thread %d).\n", thread_num_);
      return false;
    }
    read_threshold_ = read_threshold;
  }
  if (write_threshold != -1) {
    if (write_threshold <= 0) {
      logprintf(0, "Process Error: Write threshold must be greater than "
                   "zero (thread %d).\n", thread_num_);
      return false;
    }
    write_threshold_ = write_threshold;
  }
  if (segment_size != -1) {
    if (segment_size % kSectorSize != 0) {
      logprintf(0, "Process Error: Segment size must be a multiple of %d"
                " (thread %d).\n", kSectorSize, thread_num_);
      return false;
    }
    segment_size_ = segment_size / kSectorSize;
  }
  non_destructive_ = non_destructive;
  queue_size_ = ((cache_size_ / write_block_size_) * 3) / 2;
  if (update_block_table_) {
    block_table_->SetParameters(kSectorSize, write_block_size_,
                                device_sectors_, segment_size_,
                                device_name_);
  }
  return true;
}
bool DiskThread :: SetParameters ( int read_block_size , int write_block_size , int64 segment_size , int64 cache_size , int blocks_per_segment , int64 read_threshold , int64 write_threshold , int non_destructive ) { if ( read_block_size != -1 ) { if ( read_block_size % kSectorSize != 0 ) { logprintf ( 0 , " " " \n " , kSectorSize , thread_num_ ) ; return false ; } read_block_size_ = read_block_size ; } if ( write_block_size != -1 ) { if ( write_block_size % kSectorSize != 0 ) { logprintf ( 0 , " " " \n " , kSectorSize , thread_num_ ) ; return false ; } if ( write_block_size % read_block_size_ != 0 ) { logprintf ( 0 , " " " \n " , read_block_size_ , thread_num_ ) ; return false ; } write_block_size_ = write_block_size ; } else { if ( read_block_size_ > write_block_size_ ) { logprintf ( 5 , " " " \n " , read_block_size_ , thread_num_ ) ; write_block_size_ = read_block_size_ ; } else { if ( write_block_size_ % read_block_size_ != 0 ) { logprintf ( 0 , " " " " " \n " , write_block_size_ , read_block_size_ , thread_num_ ) ; return false ; } } } if ( cache_size != -1 ) { cache_size_ = cache_size ; } if ( blocks_per_segment != -1 ) { if ( blocks_per_segment <= 0 ) { logprintf ( 0 , " " " \n " , thread_num_ ) ; return false ; } blocks_per_segment_ = blocks_per_segment ; } if ( read_threshold != -1 ) { if ( read_threshold <= 0 ) { logprintf ( 0 , " " " \n " , thread_num_ ) ; return false ; } read_threshold_ = read_threshold ; } if ( write_threshold != -1 ) { if ( write_threshold <= 0 ) { logprintf ( 0 , " " " \n " , thread_num_ ) ; return false ; } write_threshold_ = write_threshold ; } if ( segment_size != -1 ) { if ( segment_size % kSectorSize != 0 ) { logprintf ( 0 , " " " \n " , kSectorSize , thread_num_ ) ; return false ; } segment_size_ = segment_size / kSectorSize ; } non_destructive_ = non_destructive ; queue_size_ = ( ( cache_size_ / write_block_size_ ) * 3 ) / 2 ; if ( update_block_table_ ) { block_table_ -> SetParameters ( kSectorSize , write_block_size_ , device_sectors_ , segment_size_ , device_name_ ) ; } return true ; }
Set various parameters that control the behaviour of the test.
Set various parameters that control the behaviour of the test .
// Blocks must be aligned to the disk's sector size. // Write blocks must be aligned to the disk's sector size and to the // block size. // Make sure write_block_size_ is still valid. // Segments must be aligned to the disk's sector size. // Having a queue of 150% of blocks that will fit in the disk's cache // should be enough to force out the oldest block before it is read and hence, // making sure the data comes form the disk and not the cache. // Updating DiskBlockTable parameters