Exemple #1
0
static int idedisk_init (void *args) {
	hd_t *drive;
	size_t size;
	char path[PATH_MAX];
	drive = (hd_t *)args;
	struct block_dev *bdev = drive->bdev;
	/* Make new device */
	if ((drive->media == IDE_DISK) && (drive->udmamode == -1)) {
		*path = 0;
		strcat(path, "/dev/hd*");
		if (0 > (drive->idx = block_dev_named(path, idedisk_idx))) {
			return drive->idx;
		}
		drive->bdev = block_dev_create(path,
				&idedisk_pio_driver, drive);
		if (NULL != drive->bdev) {
			size = drive->blks * bdev->block_size;
			block_dev(drive->bdev)->size = size;
		} else {
			return -1;
		}
		create_partitions(drive);
	}
	return 0;
}
/*
 * Main worker routine. Accepts dsm_handle as an argument
 */
static void
bg_worker_main(Datum main_arg)
{
	PartitionArgs  *args;
	dsm_handle		handle = DatumGetInt32(main_arg);

	/* Create resource owner */
	CurrentResourceOwner = ResourceOwnerCreate(NULL, "CreatePartitionsWorker");

	/* Attach to dynamic shared memory */
	if (!handle)
	{
		ereport(WARNING,
                (errmsg("pg_pathman worker: invalid dsm_handle")));
	}
	segment = dsm_attach(handle);
	args = dsm_segment_address(segment);

	/* Establish connection and start transaction */
	BackgroundWorkerInitializeConnectionByOid(args->dbid, InvalidOid);
	StartTransactionCommand();
	SPI_connect();
	PushActiveSnapshot(GetTransactionSnapshot());

	/* Create partitions */
	args->result = create_partitions(args->relid, PATHMAN_GET_DATUM(args->value, args->by_val), args->value_type, &args->crashed);

	/* Cleanup */
	SPI_finish();
	PopActiveSnapshot();
	CommitTransactionCommand();

	dsm_detach(segment);
}
Exemple #3
0
/**
 * create_spoint_matrix
 *
 * Creates a matrix of S_POINTS with P rows and Q columns in each row, where
 * P = (max_w - min_w + 1), and Q = (max_nsites - min_nsites + 1).
 *
 * The matrix is actually an array of array pointers. Each S_POINT in the matrix
 * is empty: it does not have a best string seed, and its heap is empty. The
 * heap at each S_POINT is created (and left empty). The size of a heap at a
 * given S_POINT is equal to H/F^^d, where d is the manhattan distance to
 * the closest "central" S_POINT (ie S_POINT with central w and nsites values).
 * H = main_hs, and F = (a constant specifying how quickly heap size
 * diminishes).
 *
 * NOTE: A width or nsites is "central" if its spoints have the maximum
 * possible heap size.
 *
 * \return An SP_MATRIX object containing the matrix of empty S_POINTS
 * and other information describing the matrix properties.
 */
SP_MATRIX *create_spoint_matrix (
  int *central_ws,   ///< A sorted list of central widths values for the matrix
  int n_ws,          ///< The number of central width values
  int *central_ns,   ///< A sorted list of central nsites values for the matrix
  int n_ns,          ///< The number of central nsites values
  DATASET *dataset   ///< Contains information on heap size and branching factor
) {
  // Matrix is implemented as an array of S_POINT array pointers. Allocate space
  // for this array now:
  S_POINT **matrix = NULL;
  // Calculate total number of rows in matrix:
  int min_w = central_ws[0];
  int max_w = central_ws[n_ws - 1];
  // number of widths in the range [min_w, max_w+1], where (max_w + 1) is only
  // considered if -pal is specified
  int n_widths = max_w - min_w + 2; 
  Resize(matrix, n_widths, S_POINT *);

  // Create a row for each value width from the minimum central width up to
  // the maximum central width:
  int curr_w;
  int w_idx = 0;
  for (curr_w = min_w; curr_w <= max_w; curr_w++) {
    // get list of nsites0 for this width and add it to the matrix:
    matrix[w_idx] =
      create_spoint_row(curr_w, central_ws, n_ws, central_ns, n_ns, dataset);
    w_idx++;
  }

  // Create an SP_MATRIX object containing all the relevant information:
  SP_MATRIX *sp_matrix = NULL;
  sp_matrix = (SP_MATRIX *)mymalloc(sizeof(SP_MATRIX));
  sp_matrix->matrix = matrix;
  sp_matrix->central_ws = central_ws;
  sp_matrix->n_ws = n_ws;
  sp_matrix->central_ns = central_ns;
  sp_matrix->n_ns = n_ns;

  // SP_MATRIX is almost finished; calculate and record partitions to finish
  // it off:
  sp_matrix->partitions = NULL;
  sp_matrix->n_parts = 0;
  create_partitions(sp_matrix);

  return sp_matrix;
} // create_spoint_matrix
Exemple #4
0
static int idedisk_udma_init (void *args) {
//	struct ide_tab *ide;
	hd_t *drive;
	double size;
	char   path[PATH_MAX];

#if 0
	ide = ide_get_drive();

	for(int i = 0; i < HD_DRIVES; i++) {
		if (NULL == ide->drive[i]) {
			continue;
		} else {
			drive = (hd_t *) ide->drive[i];
#endif
			drive = (hd_t *)args;
			/* Make new device */
			if ((drive->media == IDE_DISK) && (drive->udmamode != -1)) {
				*path = 0;
				strcat(path, "/dev/hd*");
				if (0 > (drive->idx = block_dev_named(path, idedisk_idx))) {
					return drive->idx;
				}
				drive->bdev = block_dev_create(path,
						&idedisk_udma_driver, drive);
				if (NULL != drive->bdev) {
					size = (double) drive->param.cylinders *
						   (double) drive->param.heads *
						   (double) drive->param.unfbytes *
						   (double) (drive->param.sectors + 1);
					block_dev(drive->bdev)->size = (size_t) size;
				} else {
					return -1;
				}
				create_partitions(drive);
//			} else {
//				continue;
//			}
		}
//	}
	return 0;
}

EMBOX_BLOCK_DEV("idedisk_udma", &idedisk_udma_driver, idedisk_udma_init);