From: bugzilla-daemon@bugzilla.kernel.org
To: linux-ext4@vger.kernel.org
Subject: [Bug 50981] New: ext4 : DATA CORRUPTION read and write on same 4096 page range
Date: Sun, 25 Nov 2012 16:31:58 +0000 (UTC) [thread overview]
Message-ID: <bug-50981-13602@https.bugzilla.kernel.org/> (raw)
https://bugzilla.kernel.org/show_bug.cgi?id=50981
Summary: ext4 : DATA CORRUPTION read and write on same 4096
page range
Product: File System
Version: 2.5
Kernel Version: 2.6.32 Red Hat Enterprise Linux Workstation release
6.2 (Santiago)
Platform: All
OS/Version: Linux
Tree: Mainline
Status: NEW
Severity: high
Priority: P1
Component: ext4
AssignedTo: fs_ext4@kernel-bugs.osdl.org
ReportedBy: meetmehiro@gmail.com
Regression: No
Kernal version and Red hat
2.6.32 , Red Hat Enterprise Linux Workstation release 6.2 (Santiago)
I have one scientific application, that is running on ext4 , after three to
fours days, I have started to seen that data is not correct.. then i tried to
find simple reproducer for the same.
Pl. find the reproducer for the same with this issue is hitting easily.
Logs :
./sim ext4_write
creating the threads
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
reader thread has opened the file, fd : 4
reader..checking data integrity
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
reader..checking data integrity
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
reader..checking data integrity
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
reader..checking data integrity
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
reader..checking data integrity
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
reader..checking data integrity
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
reader..checking data integrity
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
reader..checking data integrity
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
reader..checking data integrity
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
reader..checking data integrity
writing B at offset 0...
writing A at offset 0...
reader..checking data integrity
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
reader..checking data integrity
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
reader..checking data integrity
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
reader..checking data integrity
writing A at offset 0...
writing B at offset 0...
writing A at offset 0...
writing B at offset 0...
reader..checking data integrity
writing A at offset 0...
reader.. corrupted data, at offset : 511
writing B at offset 0...
C program :
#include <stdio.h>
#include <fcntl.h>
#include <pthread.h>
#include <assert.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
pthread_t reader_id, writer_id;
char write_buf [4096] = {0,};
char read_buf[4096] = {0,};
char datafile[256] = {0,};
int stop_write = 0;
void * writer (void * arg)
{
int fd = -1;
int count = 0;
/* this thread will open the file and write 4k data to it alternatively
* of a different data set to the same offset
*/
/* opening the file */
assert((fd = open(datafile, O_CREAT|O_RDWR, 0777)) != -1);
while (1) {
if (stop_write)
{
close(fd);
printf("write stopped\n");
return NULL;
}
if (count % 2 == 0)
memset(write_buf, 'A', sizeof(write_buf));
else
memset(write_buf, 'B', sizeof(write_buf));
assert(lseek(fd, 0, SEEK_SET) == 0);
printf("writing %c at offset 0...\n", write_buf[0]);
assert(write(fd, write_buf, 4096) == 4096);
count ++;
}
//pthread_exit((void *)0);
close(fd);
return NULL;
}
void * reader(void * arg)
{
int fd = -1;
int count = 0;
/* this thread will open the file and write 4k data to it alternatively
* of a different data set to the same offset
*/
/* opening the file */
assert((fd = open(datafile, O_CREAT|O_RDWR, 0777)) != -1);
printf("reader thread has opened the file, fd : %d\n", fd);
while (1) {
memset(read_buf, '\0', 4096);
assert(lseek(fd, 0, SEEK_SET) == 0);
assert(read(fd, read_buf, 4096) == 4096);
count ++;
printf("reader..checking data integrity\n");
int i=0;
for (i=0; i < 4095; i++)
{
int prev_char = read_buf[i];
int next_char = read_buf[i+1];
if (prev_char != next_char)
{
printf("reader.. corrupted data, at offset :
%d\n", i);
stop_write = 1;
int output_fd = open("res.txt", O_CREAT|O_RDWR,
0777);
assert(write(output_fd, read_buf, 4096) ==
4096);
close(output_fd);
close(fd);
return NULL;
}
}
}
//pthread_exit((void *)0);
close(fd);
return NULL;
}
int main (int argc, char *argv[])
{
pthread_attr_t attr;
void * arg = NULL;
int *status;
int err = 0;
if (argc != 2) {
printf("usage : ./reader_writer <file pathname>\n");
exit(1);
}
memset(datafile, '\0', sizeof(datafile));
strcpy(datafile, argv[1]);
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
/* create the reader and writer thread */
printf("creating the threads\n");
if ((err = pthread_create(&writer_id, &attr, writer, (void *)arg)) !=
0) {
printf ("pthread_create failed err no :%d\n", err);
}
if ((err = pthread_create(&reader_id, &attr, reader, (void *)arg)) !=
0) {
printf ("pthread_create failed err no :%d\n", err);
}
pthread_attr_destroy(&attr);
/* Wait on the other threads */
assert(pthread_join(writer_id, (void *)&status) == 0);
assert(pthread_join(reader_id, (void *)&status) == 0);
pthread_exit(NULL);
}
How to run
gcc program.c -o ext4_program -lpthread
./ext4_program ext4_write
--
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching the assignee of the bug.
next reply other threads:[~2012-11-25 16:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-25 16:31 bugzilla-daemon [this message]
2012-11-26 5:55 ` [Bug 50981] ext4 : DATA CORRUPTION read and write on same 4096 page range bugzilla-daemon
2012-11-26 8:34 ` bugzilla-daemon
2012-11-26 10:16 ` bugzilla-daemon
2012-11-26 10:30 ` bugzilla-daemon
2012-11-26 11:18 ` bugzilla-daemon
2012-11-26 11:27 ` bugzilla-daemon
2012-11-26 11:32 ` bugzilla-daemon
2012-11-26 12:17 ` bugzilla-daemon
2012-11-26 12:17 ` bugzilla-daemon
2012-11-26 12:22 ` bugzilla-daemon
2012-11-26 12:26 ` [Bug 50981] generic_file_aio_read ?: No locking means " bugzilla-daemon
2012-11-26 13:21 ` Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-50981-13602@https.bugzilla.kernel.org/ \
--to=bugzilla-daemon@bugzilla.kernel.org \
--cc=linux-ext4@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.