I've published a simple code which, however, targets some 'not so easy'
problems in vfs/reiserfs.
Like deadlock:
[ 573.405720]
[ 573.405722] =======================================================
[ 573.405728] [ INFO: possible circular locking dependency detected ]
[ 573.405732] 2.6.35-rc3-dbg-git6-00502-g94feaba-dirty #65
[ 573.405735] -------------------------------------------------------
[ 573.405739] a.out/7287 is trying to acquire lock:
[ 573.405742] (&sb->s_type->i_mutex_key#10){+.+.+.}, at: [
[ 573.405758]
[ 573.405759] but task is already holding lock:
[ 573.405762] (&mm->mmap_sem){++++++}, at: [
[ 573.405772]
[ 573.405773] which lock already depends on the new lock.
[ 573.405774]
[ 573.405777]
[ 573.405778] the existing dependency chain (in reverse order) is:
[ 573.405781]
[ 573.405782] -> #1 (&mm->mmap_sem){++++++}:
[ 573.405789] [
[ 573.405797] [
[ 573.405803] [
[ 573.405809] [
[ 573.405815] [
[ 573.405821] [
[ 573.405827] [
[ 573.405831] [
[ 573.405836] [
[ 573.405843]
[ 573.405843] -> #0 (&sb->s_type->i_mutex_key#10){+.+.+.}:
[ 573.405851] [
[ 573.405857] [
[ 573.405862] [
[ 573.405869] [
[ 573.405874] [
[ 573.405880] [
[ 573.405886] [
[ 573.405892] [
[ 573.405897] [
[ 573.405902] [
[ 573.405908] [
[ 573.405913] [
[ 573.405919]
[ 573.405920] other info that might help us debug this:
[ 573.405921]
[ 573.405925] 1 lock held by a.out/7287:
[ 573.405928] #0: (&mm->mmap_sem){++++++}, at: [
[ 573.405937]
[ 573.405938] stack backtrace:
[ 573.405942] Pid: 7287, comm: a.out Not tainted 2.6.35-rc3-dbg-git6-00502-g94feaba-dirty #65
[ 573.405946] Call Trace:
[ 573.405951] [
[ 573.405957] [
[ 573.405962] [
[ 573.405969] [
[ 573.405975] [
[ 573.405980] [
[ 573.405986] [
[ 573.405991] [
[ 573.405997] [
[ 573.406003] [
[ 573.406008] [
[ 573.406014] [
[ 573.406019] [
[ 573.406024] [
[ 573.406030] [
[ 573.406035] [
[ 573.406040] [
[ 573.406046] [
[ 573.406052] [
[ 573.406058] [
Error causing RO remount:
[ 202.300464] REISERFS error (device sda9): vs-2100 add_save_link:
search_by_key ([-1 7812832 0x1 IND]) returned 1
[ 202.300473] REISERFS (device sda9): Remounting filesystem read-only
[ 202.301603] ------------[ cut here ]------------
[ 202.301615] WARNING: at fs/reiserfs/journal.c:3436
journal_end+0x5b/0xaf()
[ 202.301689] Pid: 5055, comm: a.out Not tainted
2.6.35-rc3-dbg-git6-00502-g94feaba-dirty #65
[ 202.301693] Call Trace:
[ 202.301701] [
[ 202.301707] [
[ 202.301712] [
[ 202.301718] [
[ 202.301725] [
[ 202.301733] [
[ 202.301738] [
[ 202.301745] [
[ 202.301751] [
[ 202.301758] [
[ 202.301764] [
[ 202.301770] [
[ 202.301776] [
[ 202.301783] [
[ 202.301789] [
[ 202.301798] [
[ 202.301804] [
[ 202.301810] [
[ 202.301816] [
[ 202.301821] [
[ 202.301827] [
[ 202.301833] ---[ end trace c4e3312bdadd2dc5 ]---
And even OOps...
Al Viro wrote:
> OK... See 22093b8f3d387f77 in vfs-2.6.git for-next (should
> propagate to git.kernel.org shortly). That ought to deal with
> this crap, assuming I hadn't fucked up somewhere...
YAY!
/*
* 2010, Sergey Senozhatsky. GPLv2
*
*/
[..]
int main()
{
char buf[4096];
int i = 0;
/* we don't really care */
for (; i < 4096; i++)
buf[i] = (i + 65) % 255;
for (i = 0; i < 10; i++) {
int pid = fork();
if (pid > 0 ) {
printf("parent...");
} else if (pid == 0) {
printf("child...\n");
int fd = open("conftest.mmap", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0600);
if (fd > 0) {
printf("OPEN ok %d\n", fd);
if (write(fd, buf, 4096) < 0)
printf("WRITE error\n");
else
printf("WRITE ok\n");
close(fd);
} else {
printf("OPEN error\n");
}
fd = open("conftest.mmap", O_RDWR|O_LARGEFILE);
if (fd > 0) {
printf("OPEN conftest.mmap %d\n", fd);
void *map = mmap((void*)0xb78a8000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, fd, 0);
if (map == MAP_FAILED) {
printf("MMAP failed\n");
close(fd);
goto out;
} else {
printf("MMAP ok\n");
}
if (read(fd, buf, 4096) < 0)
printf("READ failed\n");
else
printf("READ ok\n");
close(fd);
munmap(map, 4096);
} else {
printf("Error: can't open conftest.mmap\n");
}
out:
fd = open(".", O_RDONLY|O_LARGEFILE);
if (fd > 0) {
printf("OPEN . ok %d... closing\n", fd);
close(fd);
} else {
printf("OPEN error\n");
}
struct stat _stat;
if (fstatat(AT_FDCWD, "conftest.mmap", &_stat, AT_SYMLINK_NOFOLLOW) < 0)
printf("FSTATAT error\n");
else
printf("FSTATAT ok\n");
if (unlinkat(AT_FDCWD, "conftest.mmap", 0) < 0)
printf("UNLINKAT error\n");
else
printf("UNLINKAT ok\n");
/*
* Yep...
* return 0;
*/
} else {
printf("FORK error\n");
}
}
return 0;
}
No comments:
Post a Comment