Esempio n. 1
0
File: dir_cmd.c Progetto: taysom/tau
void crdir_cmd (void *m)
{
	fs_msg_s	*msg = m;
	unsigned	reply_key;
	int		rc;

	reply_key = msg->q.q_passed_key;
//	printf("Path=%s\n", &msg->b);
	cr_dir(msg->cr_path);
	rc = send_tau(reply_key, msg);
	if (rc) failure("cpdir_cmd: send", rc);
}
Esempio n. 2
0
int
createtree(struct fh *rootfh, int depth,
	   int d_max, dist_func_t d_cnts, dist_func_t d_weights, 
	   int f_max, dist_func_t f_cnts, dist_func_t f_weights,
	   int l_max, dist_func_t l_cnts, dist_func_t l_weights,
	   dist_func_t f_sizes, int scale)
{
	int i, num_dirs_at_root = 1, create_reported = 0, ret=-1;
	nameset_entry_t rootnse;
	struct cr_rec *cr;
	int rexmit_max_preserve = 0;

	/*
	 * remember the distributions.
	 */
	cr_d_cnts = d_cnts;
	cr_d_weights = d_weights;
	cr_d_max = d_max;
	cr_f_cnts = f_cnts;
	cr_f_weights = f_weights;
	cr_f_max = f_max;
	cr_l_cnts = l_cnts;
	cr_l_weights = l_weights;
	cr_l_max = l_max;
	cr_f_sizes = f_sizes;
	cr_scale = scale;

	Q_INIT(&cr_worklist);

	/*
	 * create a root name entry.
	 */
	if ((rootnse = nameset_alloc(NULL, NFDIR, 0/*never pick*/)) == NULL) {
		report_error(FATAL, "nameset_alloc error");
		goto out;
	}
	nameset_setfh(rootnse, rootfh->data, rootfh->len);

	/*
	 * set up the file contents data block.
	 */
	if ((filedata = malloc(8192)) == NULL) {
		report_perror(FATAL, "malloc error");
		goto out;
	}
	memset(filedata, 'x', 8192);

	rexmit_max_preserve = rexmit_max;
	rexmit_max = 2; /* rexmit a few times before cancel */

	/*
	 * go!
	 */
	for (i=0 ; i<num_dirs_at_root ; i++) {
		cr_newdir(rootnse, depth);
	}

	/*
	 * create everything in parallel.
	 */
	while ((cr = Q_FIRST(&cr_worklist)) != NULL) {
		/*
		 * some feedback that things are moving along...
		 */
		if (created - create_reported >= 100) {
			printf("%d ", created);
			fflush(stdout);
			create_reported = created;
		}

		Q_REMOVE(&cr_worklist, cr, link);
		switch(cr->nse->type) {
		case NFDIR:
			cr_dir(cr);
			break;
		case NFREG:
			cr_file(cr);
			break;
		case NFLNK:
			cr_symlink(cr);
			break;
		default:
			report_error(FATAL, "bad type %d", cr->nse->type);
			goto out;
		}
		/*
		 * wait for replies b/c they register new worklist items.
		 */
		if (Q_FIRST(&cr_worklist) == NULL) {
			op_barrier(0);
		}
	}

	/*
	 * wait for everything to finish. (redundant with above loop.)
	 */
	if (op_barrier(0) < 0) {
		report_error(FATAL, "op_barrier error");
		goto out;
	}

	ret = 0;
 out:
	rexmit_max = rexmit_max_preserve;
	if (filedata) {
		free(filedata);
		filedata = NULL;
	}
	return ret;
}