Skip to contentSkip to conversation

Was able to reproduce "cp: cannot stat file.x: Input/output error"

DISCUSSION David Dabbs 4 participants 15 messages Aug 8, 2004 – Aug 9, 2004 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 11 lines

-----Original Message-----
From: Hans Reiser [mailto:[email protected]]
Sent: Saturday, August 07, 2004 11:18 PM
To: David Dabbs
Subject: Re: Was able to reproduce "cp: cannot stat file.x: Input/output error"

Quoted 1 line
Quoted 2 lines

How about, code was X, now it is Y, with just the relevant parts of the code cited?

Probably the most significant change to mongo sources is how it generates file names. Mongo.pl had a hard coded value of 6 for the "max_fname" parameter passed to reiser_fract_tree. I made this a parameter one can specify on the mongo command line. I passed it a value of 23.

In addition, reiser_fract_tree.c now generates file names (not directories) with extensions. Before, every file name generated had none. Here is the original and modified code.

CODE WAS
/* generate a unique filename */
void get_name_by_number(num_t this_files_number, char * str, char type) {
double rnd;
char t[16];
/* We need to generate filenames of different lengths */ rnd=rand();
rnd=rnd/RAND_MAX*max_fname+1;
sprintf (t, "%%c%%0%ulu",(int) rnd );
sprintf (str, t, type, this_files_number);

}

NOW CODE IS

/* generate a unique filename */
void get_name_by_number(num_t this_files_number, char * str, char type) {
double rnd;
char t[16];
/* We need to generate filenames of different lengths */ rnd=rand();
rnd=rnd/RAND_MAX*max_fname+1;
if( type == 'f' )

    sprintf (t, "%%c%%0%ulu.%c",(int) rnd, '`'+(char)rnd );
  else
    sprintf (t, "%%c%%0%ulu",(int) rnd );
  sprintf (str, t, type, this_files_number);

}

Backtick is the character immediately preceding 'a', so passing a value for max_fname that generates a character greater than 'z' might generate an extension character that might be a shell metacharacter. Hence my earlier warning about using this parameter.

Finally, I added two phases to mongo. MKDIRS and MKFILES. The first makes directories from a static list of directories cat-ted from a file. MKFILES does the same, except with files. The files are created by executing the following code taken directory from reiser_fract_tree:

/* make a file of a specified size */
void make_file(int size, char * fname)
{
char string [1025] = {0};
char * str = string;
int fd = 0;
int error;
static num_t this_files_number = 1;

/* open the file, and deal with the various errors that can occur */

  if ((fd = open(fname, g_flags, 0666)) == -1 ) {
    if (errno == ENOSPC) {
      if (!already_whined) {
	printf("reiser-2021A: out of disk (or inodes) space, will keep
trying\n");
	already_whined = 1;	/* we continue other file creation in out of
				   space conditions */
      }
      return;
    }
    /*  it is sometimes useful to be able to run this program more than once
	inside the same directory, and that means skipping over filenames
that
	already exist.  Thus we ignore EEXIST, and pay attention to all
	else. */
    if ( errno == EEXIST) {	/* just skip existing file */
      return;
    }
    perror ("open");
    exit (errno);

}

/* close the file */

  if (close(fd)) {
    perror("close() failed");
    exit(errno);

}
}

Since the above code simply opens and closes the file, every file created is zero length, and it creates _many_ zero-length files. Before, all files created during a mongo run had some content, though I'd need to go back and check the size distribution function to be sure.

Finally, there is the bit about mounting and unmounting. Mongo.pl first unmounts the target filesystem, then runs the proper mkfs command, mounted the filesystem, ran df to get the block usage, then unmounted the filesystem. To run each phase, mongo calls the function mongo_launcher, which mounted the filesystem, ran the command for N iterations, then unmounted the filesystem.

I made the following changes, see http://dabbs.net/reiser4/mongopl.html for more context.

In

init_fsys:
don't unmount the filesystem after mkfs * df.

mongo_launcher:
don't call &mount_fsys; at beginning and &umount_fsys; at end of each
phase

Only umount_fsys at end of function mongo.

David

#2 lore raw
Quoted 19 lines · David Dabbs
Quoted 14 lines

-----Original Message-----
From: Hans Reiser [mailto:[email protected]]
Sent: Saturday, August 07, 2004 11:18 PM
To: David Dabbs
Subject: Re: Was able to reproduce "cp: cannot stat file.x: Input/output error"

Quoted 4 lines

How about, code was X, now it is Y, with just the relevant parts of the code cited?

Quoted 6 lines

Probably the most significant change to mongo sources is how it generates file names. Mongo.pl had a hard coded value of 6 for the "max_fname" parameter passed to reiser_fract_tree. I made this a parameter one can specify on the mongo command line. I passed it a value of 23.

most filenames are small. We have an optimization in reiser4 that assumes filenames are less than 15 characters, which most of them are.

Maybe you should use a list of real filenames as well as a list of real directory names. You can reuse the filenames, so long as they are unique within a directory.

Hmm, it occurs to me that rather than using the 7 character filename prefix in the hash we should use first 4 letters and last 3 letters.

Nikita, zam, what do you think?

Quoted 83 lines

In addition, reiser_fract_tree.c now generates file names (not directories) with extensions. Before, every file name generated had none. Here is the original and modified code.

CODE WAS
/* generate a unique filename */
void get_name_by_number(num_t this_files_number, char * str, char type) {
double rnd;
char t[16];
/* We need to generate filenames of different lengths */ rnd=rand();
rnd=rnd/RAND_MAX*max_fname+1;
sprintf (t, "%%c%%0%ulu",(int) rnd );
sprintf (str, t, type, this_files_number);

}

NOW CODE IS

/* generate a unique filename */
void get_name_by_number(num_t this_files_number, char * str, char type) {
double rnd;
char t[16];
/* We need to generate filenames of different lengths */ rnd=rand();
rnd=rnd/RAND_MAX*max_fname+1;
if( type == 'f' )
sprintf (t, "%%c%%0%ulu.%c",(int) rnd, '`'+(char)rnd );
else
sprintf (t, "%%c%%0%ulu",(int) rnd );

sprintf (str, t, type, this_files_number);

}

Backtick is the character immediately preceding 'a', so passing a value for max_fname that generates a character greater than 'z' might generate an extension character that might be a shell metacharacter. Hence my earlier warning about using this parameter.

Finally, I added two phases to mongo. MKDIRS and MKFILES. The first makes directories from a static list of directories cat-ted from a file. MKFILES does the same, except with files. The files are created by executing the following code taken directory from reiser_fract_tree:

/* make a file of a specified size */
void make_file(int size, char * fname)
{
char string [1025] = {0};
char * str = string;
int fd = 0;
int error;
static num_t this_files_number = 1;

/* open the file, and deal with the various errors that can occur */

 if ((fd = open(fname, g_flags, 0666)) == -1 ) {
   if (errno == ENOSPC) {
     if (!already_whined) {
	printf("reiser-2021A: out of disk (or inodes) space, will keep
trying\n");
	already_whined = 1;	/* we continue other file creation in out of
				   space conditions */
     }
     return;

}
/* it is sometimes useful to be able to run this program more than once
inside the same directory, and that means skipping over filenames
that

	already exist.  Thus we ignore EEXIST, and pay attention to all
	else. */
   if ( errno == EEXIST) {	/* just skip existing file */
     return;
   }
   perror ("open");
   exit (errno);

}

/* close the file */

Quoted 9 lines
 if (close(fd)) {
   perror("close() failed");
   exit(errno);

}
}

Since the above code simply opens and closes the file, every file created is zero length, and it creates _many_ zero-length files.

Why would you want that?

Quoted 25 lines

Before, all files
created during a mongo run had some content, though I'd need to go back and check the size distribution function to be sure.

Finally, there is the bit about mounting and unmounting. Mongo.pl first unmounts the target filesystem, then runs the proper mkfs command, mounted the filesystem, ran df to get the block usage, then unmounted the filesystem. To run each phase, mongo calls the function mongo_launcher, which mounted the filesystem, ran the command for N iterations, then unmounted the filesystem.

I made the following changes, see http://dabbs.net/reiser4/mongopl.html for more context.

In

init_fsys:
don't unmount the filesystem after mkfs * df.

mongo_launcher:
don't call &mount_fsys; at beginning and &umount_fsys; at end of each
phase

Quoted 10 lines

Only umount_fsys at end of function mongo.

David

ok. Unmounting between phases was probably a bad idea, as it benchmarks unmounting. It should be fixed.

#3 lore raw
Quoted 10 lines

-----Original Message-----
From: Hans Reiser [mailto:[email protected]]
Sent: Sunday, August 08, 2004 1:09 PM
To: David Dabbs
Cc: 'ReiserFS List'; Nikita Danilov; Alexander Zarochentcev; E. Gryaznova
Subject: Re: Was able to reproduce "cp: cannot stat file.x: Input/output error"

Quoted 3 lines

most filenames are small. We have an optimization in reiser4 that assumes filenames are less than 15 characters, which most of them are.

This is true, but most file names are also not six characters or less with no extensions.

Quoted 4 lines

Maybe you should use a list of real filenames as well as a list of real directory names. You can reuse the filenames, so long as they are unique within a directory.

I'm not sure uniqueness is a requirement, as mongo allows for duplicate filenames. I did use real dirs and files. This is what the MKDIRS and MKFILES phases do. I generated a list of most of the actual directories and files in my / partition. In my config these are created by MKFILES and MKDIRS before the 'stock' mongo phases run.

Quoted 5 lines

Hmm, it occurs to me that rather than using the 7 character filename prefix in the hash we should use first 4 letters and last 3 letters.

Nikita, zam, what do you think?

Then you wouldn't store directories and filenames in lexicographic order as you originally intended.

Quoted 5 lines
Quoted 2 lines

Since the above code simply opens and closes the file, every file created

is zero length, and it creates _many_ zero-length files.

Quoted 1 line

Why would you want that?

I didn't explicitly _want_ zero length files, I just did the minimum to generate the files. I can easily go back and write one byte to the files, but that (shouldn't) really have an impact on the operations against the files created by reiser_fract_tree and later modified/read/overwritten/deleted by later phases because the files created by MKFILES are in directories not manipulated by the stock mongo phases. They use the files and directories created by reiser_fract_tree. The reason I added the dirs and files created by MKDIRS/FILES was to have mongo work with a filesystem 'loaded' with as much metadata as a real system might have. If this adds nothing to the benchmarking then simply run with MKFILES=off and MKDIRS=off.

Quoted 14 lines
Quoted 2 lines

I made the following changes, see http://dabbs.net/reiser4/mongopl.html

for more context.

Quoted 11 lines

In

init_fsys:
don't unmount the filesystem after mkfs * df.

mongo_launcher:
don't call &mount_fsys; at beginning and &umount_fsys; at end of each
phase

Quoted 8 lines
Quoted 6 lines

Only umount_fsys at end of function mongo.

David

ok. Unmounting between phases was probably a bad idea, as it benchmarks unmounting. It should be fixed.

Mounting/umounting between phases shouldn't cause errors, but I focused there because the errors I saw didn't begin until the copy phase, which is the first phase where mongo _reads_ what was created. Perhaps something is not being committed, at least with my hardware/config, despite the fact that there's a sync at the end of every phase iteration. I also added a sync command before the final umount.

David

#4 lore raw
Quoted 39 lines · David Dabbs
Quoted 10 lines

-----Original Message-----
From: Hans Reiser [mailto:[email protected]]
Sent: Sunday, August 08, 2004 1:09 PM
To: David Dabbs
Cc: 'ReiserFS List'; Nikita Danilov; Alexander Zarochentcev; E. Gryaznova
Subject: Re: Was able to reproduce "cp: cannot stat file.x: Input/output error"

Quoted 5 lines

most filenames are small. We have an optimization in reiser4 that assumes filenames are less than 15 characters, which most of them are.

This is true, but most file names are also not six characters or less with no extensions.

Quoted 6 lines

Maybe you should use a list of real filenames as well as a list of real directory names. You can reuse the filenames, so long as they are unique within a directory.

I'm not sure uniqueness is a requirement, as mongo allows for duplicate filenames. I did use real dirs and files. This is what the MKDIRS and MKFILES phases do. I generated a list of most of the actual directories and files in my / partition. In my config these are created by MKFILES and MKDIRS before the 'stock' mongo phases run.

Quoted 3 lines

Hmm, it occurs to me that rather than using the 7 character filename prefix in the hash we should use first 4 letters and last 3 letters.

Quoted 9 lines
Quoted 4 lines

Nikita, zam, what do you think?

Then you wouldn't store directories and filenames in lexicographic order as you originally intended.

yes, it is only a good idea for filenames larger than 15 characters.

Quoted 13 lines
Quoted 12 lines
Quoted 6 lines

Since the above code simply opens and closes the file, every file created

is zero length, and it creates _many_ zero-length files.

Why would you want that?

Quoted 13 lines

I didn't explicitly _want_ zero length files, I just did the minimum to generate the files. I can easily go back and write one byte to the files, but that (shouldn't) really have an impact on the operations against the files created by reiser_fract_tree and later modified/read/overwritten/deleted by later phases because the files created by MKFILES are in directories not manipulated by the stock mongo phases. They use the files and directories created by reiser_fract_tree. The reason I added the dirs and files created by MKDIRS/FILES was to have mongo work with a filesystem 'loaded' with as much metadata as a real system might have. If this adds nothing to the benchmarking then simply run with MKFILES=off and MKDIRS=off.

it is extremely unrealistic to create the files in one phase and write to them in the next phase. the filesystem will behave completely differently.

Quoted 47 lines
Quoted 22 lines
Quoted 6 lines

I made the following changes, see http://dabbs.net/reiser4/mongopl.html

for more context.

Quoted 13 lines

In

init_fsys:
don't unmount the filesystem after mkfs * df.

mongo_launcher:
don't call &mount_fsys; at beginning and &umount_fsys; at end of each
phase

Only umount_fsys at end of function mongo.

Quoted 9 lines
Quoted 5 lines

David

ok. Unmounting between phases was probably a bad idea, as it benchmarks unmounting. It should be fixed.

Mounting/umounting between phases shouldn't cause errors, but I focused there because the errors I saw didn't begin until the copy phase, which is the first phase where mongo _reads_ what was created. Perhaps something is not being committed, at least with my hardware/config, despite the fact that there's a sync at the end of every phase iteration. I also added a sync command before the final umount.

David

#5 lore raw
Quoted 12 lines

-----Original Message-----
From: Hans Reiser [mailto:[email protected]]
Sent: Monday, August 09, 2004 1:18 AM
To: David Dabbs
Cc: 'ReiserFS List'; 'Nikita Danilov'; 'Alexander Zarochentcev'; 'E. Gryaznova'
Subject: Re: Was able to reproduce "cp: cannot stat file.x: Input/output error"

...snip...

Quoted 4 lines

Hans:
yes, it [hashing] is only a good idea for filenames larger than 15 characters.

Actually, larger than 7 + 8 + 8 characters, if LARGE_KEY is used. This means that no keys were hashed in my tests, or the original mongo for that matter, since no file name would have been considered 'large' in kassign.c. I should up the file name limit slightly to exercise it with at least some hashed keys.

Quoted 5 lines
Quoted 1 line

it is extremely unrealistic to create the files in one phase and write to them in the next phase. the filesystem will behave completely differently.

Of course. The extra files I added are created once, and should never be touched again since mongo only operates on the objects it creates. I am simply loading the test filesystem with a reasonable facsimile of a 'normal' Linux file set (with the exception that the files are all zero length). To make these 'static' dirs/files really useful, mongo would need to be written to use these directories for its randomly created files. As for my files all being zero length, it would be easy to give them all some small file content. If these additional dirs/files as currently created add no value to the test, then do not enable these phases.

On top of this Mongo randomly creates (in PHASE CREATE) its directories and files, with each file filled at creation with a random number of 'a' characters. Each subsequent phase, if specified, does one of the following operations in the order you see below. Since you said you hadn't looked at mongo for some time, I have included the commands mongo executes. These examples are from a run with three processes and three iterations, so each command below was run three times in succession. Note that mongo drives each phase from a file list, so the files are always manipulated in the same order - the order in which they were created.

a) COPY command: Copy all files from some base iteration directory. (update-flist.pl /mnt/testfs/testdir0-0-0 /mnt/testfs/testdir1-0-0 /var/tmp/mongo.flist0-0-0 /var/tmp/mongo.flist1-0-0 || touch ERR.file ) & (update-flist.pl /mnt/testfs/testdir0-0-1 /mnt/testfs/testdir1-0-1 /var/tmp/mongo.flist0-0-1 /var/tmp/mongo.flist1-0-1 || touch ERR.file ) & (update-flist.pl /mnt/testfs/testdir0-0-2 /mnt/testfs/testdir1-0-2 /var/tmp/mongo.flist0-0-2 /var/tmp/mongo.flist1-0-2 || touch ERR.file ) & wait; sync

/*******************************************************************/ update-flist.pl

($DIR0, $DIR1, $FLIST0, $FLIST1) = @ARGV;

system("cp -r $DIR0 $DIR1");

open(FL0, $FLIST0) || DIE("Cannot open $FLIST0"); open(FL1, ">$FLIST1") || DIE("Cannot open $FLIST1");

while (<FL0>) {
    s|^$DIR0|$DIR1|;
    print FL1 $_;
}

close(FL1);
close(FL0);

/*******************************************************************/

b) APPEND command:
(cat /var/tmp/mongo.flist[01]-0-0 | grep -v -e /\$ | mongo_append 0.5 4096 off || touch ERR.file ) &
(cat /var/tmp/mongo.flist[01]-0-1 | grep -v -e /\$ | mongo_append 0.5 4096 off || touch ERR.file ) &
(cat /var/tmp/mongo.flist[01]-0-2 | grep -v -e /\$ | mongo_append 0.5 4096 off || touch ERR.file ) &
wait; sync

/*******************************************************************/ mongo_append.c

    while (getline(&line_buffer, &line_buffer_size, stdin) != -1) {
	int fd, written = 0;
	char * lf_pos;

        if ((lf_pos = index(line_buffer, '\n')) != NULL) *lf_pos = '\0'; 

	if ( (fd = open(line_buffer,O_RDWR)) == -1) {
		fprintf(stderr, "%s :", line_buffer);
		perror("cannot open file");
		continue;
	}

	append_size = append_factor * lseek(fd, 0, SEEK_END);

	while (written < append_size) {
	    int error;
	    written += (error = write(fd, buffer,
		( append_size - written < writesize ) ? append_size -
written:writesize));
	    if (error == -1) {
		close(fd);
		break;
	    }
	}
	if (use_fsync) {
		if (fsync(fd) < 0) {
			fprintf(stderr, "%s : failed to fsync file\n",
line_buffer);
			exit(1);
		}
	}
	close(fd);
    }
    free (buffer);
    free (line_buffer);
    return 0;  

/*******************************************************************/

c) MODIFY command:
(cat /var/tmp/mongo.flist[01]-0-0 | grep -v -e /\$ | mongo_modify 0.02 4096 off || touch ERR.file ) &
(cat /var/tmp/mongo.flist[01]-0-1 | grep -v -e /\$ | mongo_modify 0.02 4096 off || touch ERR.file ) &
(cat /var/tmp/mongo.flist[01]-0-2 | grep -v -e /\$ | mongo_modify 0.02 4096 off || touch ERR.file ) &
wait; sync

/*******************************************************************/ mongo_modify.c

    while (getline(&line_buffer, &line_buffer_size, stdin) != -1) {
	int fd;
	off_t fileend;
        char * lf_pos;
       
        if ((lf_pos = index(line_buffer, '\n')) != NULL) *lf_pos = '\0';

	if ( (fd = open(line_buffer,O_RDWR)) == -1) {
	    perror("cannot open file");
	    continue;
	}
	fileend = lseek(fd,0,SEEK_END);
	
	if (fileend == (off_t) - 1) {
            perror("lseek failed");
            close (fd);
	    continue;
	} 	
	if (!fileend) {
		/* nothing to modify */
	    close (fd);
	    continue;
	} 
	
	{
		off_t region_size = (double)fileend * modify_factor;
		off_t write_pos = (double)(fileend - region_size) * rand() /
(RAND_MAX + 1.0);
		size_t bytes = 0;

		if (lseek(fd, write_pos, SEEK_SET) == (off_t) - 1) {
				perror("lseek failed");
				close (fd);
				continue; 
		}

		while (bytes < region_size) {
			size_t write_count = region_size - bytes;

			if (write_count > write_buffer_size) 
				write_count = write_buffer_size;

			write_count = write(fd, buffer, write_count);

			if (write_count == 0) break;

			if (write_count == -1) {
				perror("write failed");
				break;
			}
			
			bytes += write_count;
		}
		
	}
	if (use_fsync) {
		if (fsync(fd) < 0) {
			fprintf(stderr, "%s : failed to fsync file\n",
line_buffer);
			exit(1);
		}
	}
	close(fd);
    }
    free (buffer);
    free (line_buffer);
    return 0;  

/*******************************************************************/

d) OVERWRITE command:
( cat /var/tmp/mongo.flist[01]-0-0 | grep -v -e /\$ | mongo_modify 1 4096 off || touch ERR.file ) &
( cat /var/tmp/mongo.flist[01]-0-1 | grep -v -e /\$ | mongo_modify 1 4096 off || touch ERR.file ) &
( cat /var/tmp/mongo.flist[01]-0-2 | grep -v -e /\$ | mongo_modify 1 4096 off || touch ERR.file ) &
wait; sync

See mongo_modify.c above.

/*******************************************************************/

e) READ command:

(find /mnt/testfs/testdir[01]-1-0 -type f | mongo_read || touch ERR.file ) &
(find /mnt/testfs/testdir[01]-1-1 -type f | mongo_read || touch ERR.file ) &
(find /mnt/testfs/testdir[01]-1-2 -type f | mongo_read || touch ERR.file ) &

wait; sync

/*******************************************************************/ mongo_read.c

	/* Read all file names from the standard input */ 
	while ((rd = getline(&file_name_buf, &file_name_buf_size, stdin)) !=

-1) {

		/* remove the new line character. */
		if (rd > 0 && file_name_buf[rd - 1] == '\n')
			file_name_buf[rd - 1] = 0;

		/* open the file */ 
		fd = open (file_name_buf, O_RDONLY);
		if (fd == -1) {
			fprintf (stderr, "Open failed (%s)\n", strerror
(errno));
			return errno;
		}

		/* read the file */
		while (1) {
			rd = read (fd, read_buf, bufsize);
			if (rd == -1) {
				fprintf (stderr, "Read failed (%s)\n",
strerror (errno));
				return errno;
			}
			if (rd == 0)
				break; /* EOF */

			/* file consists of 'a'. Check that */
			if (char_to_check) {
				int j;
				for (j = 0; j < rd; j ++)
					if (read_buf[j] != char_to_check) {
						fprintf (stderr, "Incorrect
data were read\n");
						return EIO;
				}
			}
		}
		close (fd);
	}

	if (file_name_buf)
		free(file_name_buf);
	free (read_buf);
	snapstats();
	return 0;

/*******************************************************************/

f) STATS command:
((cat /var/tmp/mongo.flist[01]-0-0 | xargs ls -d) > /dev/null || touch ERR.file ) &
((cat /var/tmp/mongo.flist[01]-0-1 | xargs ls -d) > /dev/null || touch ERR.file ) &
((cat /var/tmp/mongo.flist[01]-0-2 | xargs ls -d) > /dev/null || touch ERR.file ) &
wait; sync

g) DELETE command:

( rm -r /mnt/testfs/testdir[01]-0-0 || touch ERR.file ) &
( rm -r /mnt/testfs/testdir[01]-0-1 || touch ERR.file ) &
( rm -r /mnt/testfs/testdir[01]-0-2 || touch ERR.file ) &

wait; sync

Finally, if specified, it executes the large file phases

h) dd_writing_largefile command:

( dd if=/dev/zero of=/mnt/testfs/largefile  bs=1M count=768 ) &
( dd if=/dev/zero of=/mnt/testfs/largefile  bs=1M count=768 ) &
( dd if=/dev/zero of=/mnt/testfs/largefile  bs=1M count=768 ) &  

wait; sync

i) dd_reading_largefile command:

( dd of=/dev/null if=/mnt/testfs/largefile  bs=1M count=768 ) &
( dd of=/dev/null if=/mnt/testfs/largefile  bs=1M count=768 ) &
( dd of=/dev/null if=/mnt/testfs/largefile  bs=1M count=768 ) &

wait; sync

#6 lore raw
Quoted 19 lines · David Dabbs
Quoted 14 lines

-----Original Message-----
From: Hans Reiser [mailto:[email protected]]
Sent: Monday, August 09, 2004 1:18 AM
To: David Dabbs
Cc: 'ReiserFS List'; 'Nikita Danilov'; 'Alexander Zarochentcev'; 'E. Gryaznova'
Subject: Re: Was able to reproduce "cp: cannot stat file.x: Input/output error"

...snip...

Quoted 8 lines
Quoted 5 lines

Hans:
yes, it [hashing] is only a good idea for filenames larger than 15 characters.

Actually, larger than 7 + 8 + 8 characters, if LARGE_KEY is used.

Oh. Ok. LARGE_KEY is the only thing that should be used.

Quoted 15 lines

This means
that no keys were hashed in my tests, or the original mongo for that matter, since no file name would have been considered 'large' in kassign.c. I should up the file name limit slightly to exercise it with at least some hashed keys.

Quoted 6 lines

it is extremely unrealistic to create the files in one phase and write to them in the next phase. the filesystem will behave completely differently.

Quoted 5 lines

Of course. The extra files I added are created once, and should never be touched again since mongo only operates on the objects it creates. I am simply loading the test filesystem with a reasonable facsimile of a 'normal' Linux file set (with the exception that the files are all zero length).

a huge exception. I don't grok what you are trying to do here.

Quoted 272 lines

To
make these 'static' dirs/files really useful, mongo would need to be written to use these directories for its randomly created files. As for my files all being zero length, it would be easy to give them all some small file content. If these additional dirs/files as currently created add no value to the test, then do not enable these phases.

On top of this Mongo randomly creates (in PHASE CREATE) its directories and files, with each file filled at creation with a random number of 'a' characters. Each subsequent phase, if specified, does one of the following operations in the order you see below. Since you said you hadn't looked at mongo for some time, I have included the commands mongo executes. These examples are from a run with three processes and three iterations, so each command below was run three times in succession. Note that mongo drives each phase from a file list, so the files are always manipulated in the same order - the order in which they were created.

a) COPY command: Copy all files from some base iteration directory. (update-flist.pl /mnt/testfs/testdir0-0-0 /mnt/testfs/testdir1-0-0 /var/tmp/mongo.flist0-0-0 /var/tmp/mongo.flist1-0-0 || touch ERR.file ) & (update-flist.pl /mnt/testfs/testdir0-0-1 /mnt/testfs/testdir1-0-1 /var/tmp/mongo.flist0-0-1 /var/tmp/mongo.flist1-0-1 || touch ERR.file ) & (update-flist.pl /mnt/testfs/testdir0-0-2 /mnt/testfs/testdir1-0-2 /var/tmp/mongo.flist0-0-2 /var/tmp/mongo.flist1-0-2 || touch ERR.file ) & wait; sync

/*******************************************************************/ update-flist.pl

($DIR0, $DIR1, $FLIST0, $FLIST1) = @ARGV;

system("cp -r $DIR0 $DIR1");

open(FL0, $FLIST0) || DIE("Cannot open $FLIST0"); open(FL1, ">$FLIST1") || DIE("Cannot open $FLIST1");

while (<FL0>) {
   s|^$DIR0|$DIR1|;
   print FL1 $_;
}

close(FL1);
close(FL0);

/*******************************************************************/

b) APPEND command: (cat /var/tmp/mongo.flist[01]-0-0 | grep -v -e /\$ | mongo_append 0.5 4096

off  || touch ERR.file ) & (cat /var/tmp/mongo.flist[01]-0-1 | grep -v -e /\$ | mongo_append 0.5 4096
off  || touch ERR.file ) & (cat /var/tmp/mongo.flist[01]-0-2 | grep -v -e /\$ | mongo_append 0.5 4096
off  || touch ERR.file ) &  wait; sync

/*******************************************************************/ mongo_append.c

   while (getline(&line_buffer, &line_buffer_size, stdin) != -1) {
	int fd, written = 0;
	char * lf_pos;

       if ((lf_pos = index(line_buffer, '\n')) != NULL) *lf_pos = '\0'; 

	if ( (fd = open(line_buffer,O_RDWR)) == -1) {
		fprintf(stderr, "%s :", line_buffer);
		perror("cannot open file");
		continue;
	}

	append_size = append_factor * lseek(fd, 0, SEEK_END);

	while (written < append_size) {
	    int error;
	    written += (error = write(fd, buffer,
		( append_size - written < writesize ) ? append_size -
written:writesize));
	    if (error == -1) {
		close(fd);
		break;
	    }
	}
	if (use_fsync) {
		if (fsync(fd) < 0) {
			fprintf(stderr, "%s : failed to fsync file\n",
line_buffer);
			exit(1);
		}
	}
	close(fd);
   }
   free (buffer);
   free (line_buffer);
   return 0;  

/*******************************************************************/

c) MODIFY command: (cat /var/tmp/mongo.flist[01]-0-0 | grep -v -e /\$ | mongo_modify 0.02 4096

off || touch ERR.file ) & (cat /var/tmp/mongo.flist[01]-0-1 | grep -v -e /\$ | mongo_modify 0.02 4096
off || touch ERR.file ) & (cat /var/tmp/mongo.flist[01]-0-2 | grep -v -e /\$ | mongo_modify 0.02 4096
off || touch ERR.file ) &  wait; sync

/*******************************************************************/ mongo_modify.c

   while (getline(&line_buffer, &line_buffer_size, stdin) != -1) {
	int fd;
	off_t fileend;
       char * lf_pos;
      
       if ((lf_pos = index(line_buffer, '\n')) != NULL) *lf_pos = '\0';

	if ( (fd = open(line_buffer,O_RDWR)) == -1) {
	    perror("cannot open file");
	    continue;
	}
	fileend = lseek(fd,0,SEEK_END);
	
	if (fileend == (off_t) - 1) {
           perror("lseek failed");
           close (fd);
	    continue;
	} 	
	if (!fileend) {
		/* nothing to modify */
	    close (fd);
	    continue;
	} 
	
	{
		off_t region_size = (double)fileend * modify_factor;
		off_t write_pos = (double)(fileend - region_size) * rand() /
(RAND_MAX + 1.0);
		size_t bytes = 0;

		if (lseek(fd, write_pos, SEEK_SET) == (off_t) - 1) {
				perror("lseek failed");
				close (fd);
				continue; 
		}

		while (bytes < region_size) {
			size_t write_count = region_size - bytes;

			if (write_count > write_buffer_size) 
				write_count = write_buffer_size;

			write_count = write(fd, buffer, write_count);

			if (write_count == 0) break;

			if (write_count == -1) {
				perror("write failed");
				break;
			}
			
			bytes += write_count;
		}
		
	}
	if (use_fsync) {
		if (fsync(fd) < 0) {
			fprintf(stderr, "%s : failed to fsync file\n",
line_buffer);
			exit(1);
		}
	}
	close(fd);
   }
   free (buffer);
   free (line_buffer);
   return 0;  

/*******************************************************************/

d) OVERWRITE command: ( cat /var/tmp/mongo.flist[01]-0-0 | grep -v -e /\$ | mongo_modify 1 4096

off || touch ERR.file ) & ( cat /var/tmp/mongo.flist[01]-0-1 | grep -v -e /\$ | mongo_modify 1 4096
off || touch ERR.file ) & ( cat /var/tmp/mongo.flist[01]-0-2 | grep -v -e /\$ | mongo_modify 1 4096
off || touch ERR.file ) &  wait; sync

See mongo_modify.c above.

/*******************************************************************/

e) READ command: (find /mnt/testfs/testdir[01]-1-0 -type f | mongo_read || touch ERR.file ) &

(find /mnt/testfs/testdir[01]-1-1 -type f | mongo_read || touch ERR.file ) &
(find /mnt/testfs/testdir[01]-1-2 -type f | mongo_read || touch ERR.file ) &

wait; sync

/*******************************************************************/ mongo_read.c

	/* Read all file names from the standard input */ 
	while ((rd = getline(&file_name_buf, &file_name_buf_size, stdin)) !=

-1) {

		/* remove the new line character. */
		if (rd > 0 && file_name_buf[rd - 1] == '\n')
			file_name_buf[rd - 1] = 0;

		/* open the file */ 
		fd = open (file_name_buf, O_RDONLY);
		if (fd == -1) {
			fprintf (stderr, "Open failed (%s)\n", strerror
(errno));
			return errno;
		}

		/* read the file */
		while (1) {
			rd = read (fd, read_buf, bufsize);
			if (rd == -1) {
				fprintf (stderr, "Read failed (%s)\n",
strerror (errno));
				return errno;
			}
			if (rd == 0)
				break; /* EOF */

			/* file consists of 'a'. Check that */
			if (char_to_check) {
				int j;
				for (j = 0; j < rd; j ++)
					if (read_buf[j] != char_to_check) {
						fprintf (stderr, "Incorrect
data were read\n");
						return EIO;
				}
			}
		}
		close (fd);
	}

	if (file_name_buf)
		free(file_name_buf);
	free (read_buf);
	snapstats();
	return 0;

/*******************************************************************/

f) STATS command: ((cat /var/tmp/mongo.flist[01]-0-0 | xargs ls -d) > /dev/null || touch ERR.file ) &
((cat /var/tmp/mongo.flist[01]-0-1 | xargs ls -d) > /dev/null || touch ERR.file ) &
((cat /var/tmp/mongo.flist[01]-0-2 | xargs ls -d) > /dev/null || touch ERR.file ) &
wait; sync

g) DELETE command:

( rm -r /mnt/testfs/testdir[01]-0-0 || touch ERR.file ) &
( rm -r /mnt/testfs/testdir[01]-0-1 || touch ERR.file ) &
( rm -r /mnt/testfs/testdir[01]-0-2 || touch ERR.file ) &

wait; sync

Finally, if specified, it executes the large file phases

h) dd_writing_largefile command: ( dd if=/dev/zero of=/mnt/testfs/largefile bs=1M count=768 ) & ( dd if=/dev/zero of=/mnt/testfs/largefile bs=1M count=768 ) &
( dd if=/dev/zero of=/mnt/testfs/largefile bs=1M count=768 ) & wait; sync

i) dd_reading_largefile command: ( dd of=/dev/null if=/mnt/testfs/largefile bs=1M count=768 ) & ( dd of=/dev/null if=/mnt/testfs/largefile bs=1M count=768 ) &
( dd of=/dev/null if=/mnt/testfs/largefile bs=1M count=768 ) &
wait; sync

#7 lore raw
Quoted 20 lines
Quoted 12 lines
Quoted 9 lines

Hans:
yes, it [hashing] is only a good idea for filenames larger than 15 characters.

Actually, larger than 7 + 8 + 8 characters, if LARGE_KEY is used.

Oh. Ok. LARGE_KEY is the only thing that should be used.

Quoted 6 lines
Quoted 5 lines

it is extremely unrealistic to create the files in one phase and write to them in the next phase. the filesystem will behave completely differently.

Quoted 8 lines
Quoted 3 lines

Of course. The extra files I added are created once, and should never be touched again since mongo only operates on the objects it creates. I am simply loading the test filesystem with a reasonable facsimile of a

'normal' Linux file set (with the exception that the files are all zero length).

Quoted 1 line

a huge exception. I don't grok what you are trying to do here.

Mongo starts with a clean slate filesystem. I was attempting to run the tests on top of something other than a clean filesystem, because that is an exceptional situation. Based on your reaction, it is obviously not detrimental to measuring relative performance measures. I didn't really care about the performance of the MKFILES & MKDIRS phases themselves - that was irrelevant. I simply wanted to run the tests on a filesystem that looked as much as possible as what one might start with under 'normal' conditions. The only reason the files were zero length - and not a copy of real files - was that at the time I had limited disk space with which to test.

But enough of extensions and experiments. I am in no way trying to press a case for my MKDIRS/FILES experiments. I do, however, believe mongo should be run with file names longer than six characters and that have extensions. This is not representative of Linux file system usage, nor does it exercise reiser features designed to improve performance, e.g. fibration. In addition, as you point out, it should probably not benchmark mounting and unmounting the filesystem -- unless there was good reason to have done so.

The real issue, for me at least, is finding a method of determining whether the errors I saw were due to hardware or software; if it is the latter, whether it can be traced to mongo, the filesystem or Linux.

David

#8 lore raw
Quoted 48 lines · David Dabbs
Quoted 29 lines
Quoted 10 lines
Quoted 10 lines

Hans:
yes, it [hashing] is only a good idea for filenames larger than 15 characters.

Quoted 4 lines

Actually, larger than 7 + 8 + 8 characters, if LARGE_KEY is used.

Oh. Ok. LARGE_KEY is the only thing that should be used.

Quoted 11 lines
Quoted 6 lines

it is extremely unrealistic to create the files in one phase and write to them in the next phase. the filesystem will behave completely differently.

Of course. The extra files I added are created once, and should never be touched again since mongo only operates on the objects it creates. I am simply loading the test filesystem with a reasonable facsimile of a

Quoted 8 lines

'normal' Linux file set (with the exception that the files are all zero length).

a huge exception. I don't grok what you are trying to do here.

Mongo starts with a clean slate filesystem. I was attempting to run the tests on top of something other than a clean filesystem, because that is an exceptional situation. Based on your reaction, it is obviously not detrimental to measuring relative performance measures. I didn't really care about the performance of the MKFILES & MKDIRS phases themselves - that was irrelevant. I simply wanted to run the tests on a filesystem that looked as much as possible as what one might start with under 'normal' conditions. The only reason the files were zero length - and not a copy of real files - was that at the time I had limited disk space with which to test.

Quoted 4 lines

But enough of extensions and experiments. I am in no way trying to press a case for my MKDIRS/FILES experiments. I do, however, believe mongo should be run with file names longer than six characters

ok.

Quoted 3 lines

and that have extensions.

this should be without effect, provided that the file creation order is the same as the hash/fibration order.

Quoted 16 lines

This is not representative of Linux file system usage, nor does it exercise reiser features designed to improve performance, e.g. fibration. In addition, as you point out, it should probably not benchmark mounting and unmounting the filesystem -- unless there was good reason to have done so.

The real issue, for me at least, is finding a method of determining whether the errors I saw were due to hardware or software; if it is the latter, whether it can be traced to mongo, the filesystem or Linux.

David

#9 lore raw
Quoted 12 lines

-----Original Message-----
From: Hans Reiser [mailto:[email protected]]
Sent: Monday, August 09, 2004 12:43 PM

Quoted 4 lines · David Dabbs

But enough of extensions and experiments. I am in no way trying to press a case for my MKDIRS/FILES experiments. I do, however, believe mongo should run with file names longer than six characters

Quoted 8 lines

ok.

Quoted 3 lines

and that have extensions.

this should be without effect, provided that the file creation order is the same as the hash/fibration order.

[David Dabbs]

Yes, it is moot when using exclusively all short, extension-less file names, because all files have the same fibration bits and no file has the hash bit in key element 2. But with some long file names (len > 23), extensions and DOT-O, and especially EXT-1, all the .a's, .b's, etc. would be grouped together in-tree and on-disk, then ordered by file name. This ordering differs from how mongo currently runs, though the net effect on performance remains to be measured.

Besides the fact that configuring mongo this way is closer to average usage, the other (potential) benefit is that it exercises more of the reiser4 code base. But having it exercise more code may not matter to, or may be orthogonal to, generating meaningful relative performance metrics.

As an aside, if Namesys shipped r4 to Andrew Morton, is there an ETA on when he will include it in an -mm patch?

David

p.s. For those benchmarking ext3 vs. r4 using mongo or some other tool, there is an ext3 performance regression patch included in -rc3-mm2, so YMMV with rc3-mm1.

#10 lore raw
In reply to Hans Reiser

One other somewhat related FYI. In the recent fibration discussion you thought it would probably be good to make FIBRATION_EXT_1 the default fibration plugin instead of FIBRATION_DOT_O, but dot-O is still the default:

	[PSET_FIBRATION] = {
		.type = REISER4_FIBRATION_PLUGIN_TYPE,
		.id   = FIBRATION_DOT_O
	},

David

#11 lore raw
Quoted 10 lines · David Dabbs

One other somewhat related FYI. In the recent fibration discussion you thought it would probably be good to make FIBRATION_EXT_1 the default fibration plugin instead of FIBRATION_DOT_O, but dot-O is still the default:

	[PSET_FIBRATION] = {
		.type = REISER4_FIBRATION_PLUGIN_TYPE,
		.id   = FIBRATION_DOT_O
	},

mkfs.reiser4 sets the fs-wide default fibration plugin.

Quoted 2 lines

David

Signature · 1 line
Alex.
#12 lore raw
Quoted 10 lines

-----Original Message-----
From: Alex Zarochentsev [mailto:[email protected]]
Sent: Monday, August 09, 2004 1:00 PM
To: David Dabbs

mkfs.reiser4 sets the fs-wide default fibration plugin.

Alex.

[David Dabbs]

So does mkfs.reiser4 using ext-1 as its default? I don't have the code available to check before asking.

David

#13 lore raw
Quoted 7 lines · David Dabbs
Quoted 7 lines

-----Original Message-----
From: Alex Zarochentsev [mailto:[email protected]]
Sent: Monday, August 09, 2004 1:00 PM
To: David Dabbs

Quoted 7 lines
Quoted 3 lines

mkfs.reiser4 sets the fs-wide default fibration plugin.

Alex.

[David Dabbs]

So does mkfs.reiser4 using ext-1 as its default? I don't have the code available to check before asking.

mkfs.reiser4 can report default plugins:

darkstar:~ # ~zam/bk/reiser4progs/progs/mkfs/mkfs.reiser4 -p /home/zam/bk/reiser4progs/progs/mkfs/.libs/lt-mkfs.reiser4 0.5.7 Copyright (C) 2001, 2002, 2003, 2004 by Hans Reiser, licensing governed by reiser4progs/COPYING.

Default profiles:

format:     "format40" (id:0x0 type:0x8)
journal:    "journal40" (id:0x0 type:0xf)
oid:        "oid40" (id:0x0 type:0x9)
alloc:      "alloc40" (id:0x0 type:0xe)
key:        "key_large" (id:0x1 type:0x10)
node:       "node40" (id:0x0 type:0x2)
statdata:   "stat40" (id:0x0 type:0x1)
nodeptr:    "nodeptr40" (id:0x3 type:0x1)
direntry:   "cde40" (id:0x2 type:0x1)
tail:       "tail40" (id:0x6 type:0x1)
extent:     "extent40" (id:0x5 type:0x1)
acl:        "absent (id:0x4 type:0x1)"
permission: "absent (id:0x0 type:0x6)"
regular:    "reg40" (id:0x0 type:0x0)
directory:  "dir40" (id:0x1 type:0x0)
symlink:    "sym40" (id:0x2 type:0x0)
special:    "spl40" (id:0x3 type:0x0)
hash:       "r5_hash" (id:0x1 type:0x3)
fibration:  "ext_1_fibre" (id:0x2 type:0x4)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
formatting: "smart" (id:0x2 type:0x5)

darkstar:~ #

Quoted 3 lines

David

Signature · 1 line
Alex.
#14 lore raw
In reply to Hans Reiser
Quoted 21 lines · Hans Reiser
Quoted 19 lines · David Dabbs
Quoted 18 lines

-----Original Message-----
From: Hans Reiser [mailto:[email protected]]
Sent: Saturday, August 07, 2004 11:18 PM
To: David Dabbs
Subject: Re: Was able to reproduce "cp: cannot stat file.x: Input/output error"

How about, code was X, now it is Y, with just the relevant parts of the code cited?

Quoted 8 lines
Quoted 6 lines

Probably the most significant change to mongo sources is how it generates file names. Mongo.pl had a hard coded value of 6 for the "max_fname" parameter passed to reiser_fract_tree. I made this a parameter one can specify on the mongo command line. I passed it a value of 23.

most filenames are small. We have an optimization in reiser4 that assumes filenames are less than 15 characters, which most of them are.

With large keys (which is the default) up to 23 characters are embedded into key.

[...]

Nikita.

#15 lore raw
Quoted 4 lines · Nikita Danilov

With large keys (which is the default) up to 23 characters are embedded into key.

Thanks for coding it that way.:)