2 int create_mkdir_op (int flag)
5 char name[MAX_NAMELEN];
6 char command[MAX_COMMAND_LEN];
12 while (count++ < 100) {
13 i = random()%dir_fh.fh_max;
14 if (dir_fh.fh[i].flag==FH_T_FLAG_IN_USE) {
15 assure_exist(dir_fh.fh[i].path);
16 strcpy (name, dir_fh.fh[i].path);
17 if (flag == IS_FILE) {
18 sprintf (name+strlen(name), "AGEfile%d", fhno++);
19 fd = creat (name, S_IRWXU);
21 //printf ("create fd %d\n", fd);
25 sprintf (name+strlen(name), "AGEdir%d", fhno++);
26 fd = mkdir (name, S_IRWXU);
32 if (errno == ENOENT) {
33 dir_fh.fh[i].flag = FH_T_FLAG_FREE;
38 add_fh_t (fh_infop, name, EXIST);
53 i = random()%file_fh.fh_max;
54 if (file_fh.fh[i].flag == FH_T_FLAG_IN_USE) {
56 if (!strstr(file_fh.fh[i].path, "AGE"))
59 assure_exist(file_fh.fh[i].path);
60 ret = remove (file_fh.fh[i].path);
62 file_fh.fh[i].flag = FH_T_FLAG_FREE;
73 char command[MAX_COMMAND_LEN];
77 i = random()%dir_fh.fh_max;
78 if ( (dir_fh.fh[i].flag == FH_T_FLAG_IN_USE) ) {
80 if (!strstr(file_fh.fh[i].path, "AGE"))
83 assure_exist(file_fh.fh[i].path);
84 ret = rmdir (dir_fh.fh[i].path);
86 dir_fh.fh[i].flag = FH_T_FLAG_FREE;
89 RFS_ASSERT ((ret == -1) && (errno == ENOTEMPTY));
90 //strcpy (command, "rm -r %s", dir_fh.fh[i].path);
97 int write_op (int off, int size)
99 static char buf[NFS_MAXDATA];
106 RFS_ASSERT (size <= NFS_MAXDATA);
107 while (count++<100) {
108 i = random()%file_fh.fh_max;
109 if ( (file_fh.fh[i].flag == FH_T_FLAG_IN_USE) ) {
110 assure_exist(file_fh.fh[i].path);
111 fd = open(file_fh.fh[i].path, O_WRONLY);
115 //printf ("write fd %d\n", fd);
118 if (st.st_size < (off+size)) {
119 int written_bytes = 0;
120 while (written_bytes+NFS_MAXDATA < off+size-st.st_size) {
121 loop_write (fd, buf, NFS_MAXDATA);
122 written_bytes += NFS_MAXDATA;
124 loop_write (fd, buf, off+size-st.st_size-written_bytes);
125 if (strstr(file_fh.fh[i].path, "AGE")) {
126 age_write_num+=(written_bytes+NFS_MAXDATA-1)/NFS_MAXDATA;
128 nonage_write_num+=(written_bytes+NFS_MAXDATA-1)/NFS_MAXDATA;
132 if (strstr(file_fh.fh[i].path, "AGE")) {
136 loop_write (fd, buf, size);
145 int truncate_op(int size)
151 while (count++<100) {
152 i = random()%file_fh.fh_max;
153 if ( (file_fh.fh[i].flag == FH_T_FLAG_IN_USE) ) {
155 if (!strstr(file_fh.fh[i].path, "AGE"))
158 assure_exist (file_fh.fh[i].path);
159 ret = truncate(file_fh.fh[i].path, size);
162 RFS_ASSERT (errno == ENOENT);
163 file_fh.fh[i].flag = FH_T_FLAG_FREE;
172 char name[MAX_NAMELEN];
173 int sfh; /* file to be aged */
179 /* get the sfh and size of the selected file to be aged */
180 sfh = select_obj (&obj_fh, IS_FILE, EXIST, ACTIVE);
181 ret = stat (obj_fh.fh[sfh].path, &st);
182 RFS_ASSERT (ret == 0);
183 ret = truncate(obj_fh.fh[i].path, st.st_size/2);
186 psfh = obj_fh.fh[sfh].psfh;
187 strcpy (name, obj_fh.fh[psfh].path);
188 sprintf(name+strlen(name), "/AGE%d", obj_fh.fh_max);
189 agefd = creat (name, S_IRWXU);
190 //write (agefs, buf, 0);
192 add_fh_t (&obj_fh, name, sfh, psfh, size, ftype_flag, EXIST, INACTIVE);