예제 #1
0
파일: fileops.c 프로젝트: ystk/debian-ltp
void ffsb_deletefile(ffsb_thread_t *ft, ffsb_fs_t *fs, unsigned opnum)
{
	struct benchfiles *bf = (struct benchfiles *)fs_get_opdata(fs, opnum);
	struct ffsb_file *curfile = NULL;
	randdata_t *rd = ft_get_randdata(ft);
	struct timeval start, end;
	int need_stats = ft_needs_stats(ft, SYS_UNLINK) ||
		fs_needs_stats(fs, SYS_UNLINK);

	curfile = choose_file_writer(bf, rd);
	remove_file(bf, curfile);

	if (need_stats)
		gettimeofday(&start, NULL);

	if (unlink(curfile->name) == -1) {
		printf("error deleting %s in deletefile\n", curfile->name);
		perror("deletefile");
		exit(0);
	}

	if (need_stats) {
		gettimeofday(&end, NULL);
		do_stats(&start, &end, ft, fs, SYS_UNLINK);
	}

	rw_unlock_write(&curfile->lock);

	ft_incr_op(ft, opnum, 1, 0);
}
예제 #2
0
static void removedir(struct benchfiles *dirs, randdata_t *rd)
{
	struct ffsb_file *deldir;

	deldir = choose_file_writer(dirs, rd);
	remove_file(dirs, deldir);

	if (rmdir(deldir->name) < 0) {
		perror("rmdir");
		exit(1);
	}
	unlock_file_writer(deldir);
}
예제 #3
0
파일: filelist.c 프로젝트: Mellanox/arc_ltp
struct ffsb_file *choose_file_writer(struct benchfiles *bf, randdata_t *rd)
{
	struct ffsb_file *ret ;

	rw_lock_read(&bf->fileslock);
	assert(bf->holes->count != bf->listsize);
	ret = choose_file(bf, rd);

	if (rw_trylock_write(&ret->lock)) {
		rw_unlock_read(&bf->fileslock);
		return choose_file_writer(bf, rd);
	}

	rw_unlock_read(&bf->fileslock);
	return ret;
}
예제 #4
0
static void renamedir(struct benchfiles *dirs, randdata_t *rd)
{
	struct ffsb_file *dir;
	char *oldname;

	dir = choose_file_writer(dirs, rd);
	oldname = dir->name;
	rename_file(dir);

	if (rename(oldname, dir->name) < 0) {
		perror("rename");
		exit(1);
	}
	unlock_file_writer(dir);
	free(oldname);
}