[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [linux-lvm] file corruption writing to lvm2 volume



On 18 Feb, To: linux-lvm redhat com wrote:
> I have a program that's writing data out to a file and it looks like my
> files are not written out correctly onto an lvm2 volume, while they will
> write out correctly to a non lvm2 partition.
> 
> I'm not seeing any errors on the console, so I'm not sure what to look
> for.  Let me know what kind of data I can provide.
> 
> I'm running linux-2.6.2 on ia64.

The attached program can be used to expose the problem.

Mark 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>

int main(int argc, char *argv[])
{
	int c;
	char filename[1024];
	FILE *outfile;
	int i, j, k;
	int factor;

	if (argc < 4) {
		printf("usage: %s -o <dir> -c #\n", argv[0]);
		return 1;
	}

	while (1) {
		int option_index = 0;
		static struct option long_options[] = {
			{ 0, 0, 0, 0 }
		};

		c = getopt_long(argc, argv, "c:o:",
			long_options, &option_index);
		if (c == -1) {
			break;
		}

		switch (c) {
		case 0:
			break;
		case 'c':
			factor = atoi(optarg);
			break;
		case 'o':
			strcpy(filename, optarg);
			break;
		defaults:
			return 2;
		}
	}

	strcat(filename, "/file.out");
	outfile = fopen(filename, "w");
	if (outfile == NULL) {
		printf("cannot open %s\n", filename);
		return 3;
	}

	for (i = 0; i < factor; i++) {
		for (j = 0; j < 10; j++) {
			for (k = 0; k < 3000; k++) {
				fprintf(outfile, "%d %d %d\n", i, j, k);
			}
		}
	}
	fclose(outfile);
		
	return 0;
}

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]