linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Giangiacomo Mariotti <giangiacomo.mariotti@gmail.com>
To: linux-btrfs@vger.kernel.org
Subject: [BUG] btrfs 2.6.39(vanilla): files created with a particular pattern result in error 400
Date: Sun, 29 May 2011 15:54:40 +0000	[thread overview]
Message-ID: <BANLkTimAuvsy=MBR5EarasErXOTdS1+-eg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1690 bytes --]

Hi, since I switched to vanilla kernel version 2.6.39(from latest
stable 2.6.38), a lot of errors started appearing on my btrfs
partitions, without any hardware failure, power outages or crashes.
The errors look all the same "root 5 inode <inode_number> errors 400"
for all the partitions. I've produced a little c program that is
consistently produces these seemingly faulty files on my system. I've
done so by tracing vuze(a torrent app), which I noticed was the app
that created those files. If I cp those files, the result doesn't have
those errors.
the code creates files which result in this btrfsck output:

root 5 inode 705986 errors 400
found 339059101696 bytes used err is 1
total csum bytes: 330286628
total tree bytes: 845594624
total fs tree bytes: 250171392
btree space waste bytes: 191048782
file data blocks allocated: 402010976256
 referenced 331993735168

P.S. I'm not subscribed to the list.

The code is in the attachment and appended here(don't know if gmail is
gonna mess it up, so I'm attacching it too):

#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>

#define FILE_SIZE 325443890
#define WRT_BYTES 4096

int main(void)
{
	struct stat stat_buf;
	int fd = 0, flag = 0;
	const size_t cnt = FILE_SIZE / WRT_BYTES;
	char arr[WRT_BYTES];
	
	fd = open("this_file_name.mp4",
		O_RDWR|O_CREAT, 0666);
	
	fstat(fd, &stat_buf);
	
	flag = fcntl(fd, F_GETFD);
	fcntl(fd, F_SETFD, flag | FD_CLOEXEC);
	
	lseek(fd, 0, SEEK_CUR);
	
	ftruncate(fd, FILE_SIZE);
	
	lseek(fd, 0, SEEK_SET);
	
	for (int i = 0; i < cnt; ++i) {
		write(fd, arr, WRT_BYTES);
	}
	
	write(fd, arr, FILE_SIZE - (WRT_BYTES * cnt));
	
	close(fd);
	
	return 0;
}

--
Giangiacomo

[-- Attachment #2: main.c --]
[-- Type: text/x-csrc, Size: 646 bytes --]

#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>

#define FILE_SIZE 325443890
#define WRT_BYTES 4096

int main(void)
{
	struct stat stat_buf;
	int fd = 0, flag = 0;
	const size_t cnt = FILE_SIZE / WRT_BYTES;
	char arr[WRT_BYTES];
	
	fd = open("this_file_name.mp4",
		O_RDWR|O_CREAT, 0666);
	
	fstat(fd, &stat_buf);
	
	flag = fcntl(fd, F_GETFD);
	fcntl(fd, F_SETFD, flag | FD_CLOEXEC);
	
	lseek(fd, 0, SEEK_CUR);
	
	ftruncate(fd, FILE_SIZE);
	
	lseek(fd, 0, SEEK_SET);
	
	for (int i = 0; i < cnt; ++i) {
		write(fd, arr, WRT_BYTES);
	}
	
	write(fd, arr, FILE_SIZE - (WRT_BYTES * cnt));
	
	close(fd);
	
	return 0;
}


                 reply	other threads:[~2011-05-29 15:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='BANLkTimAuvsy=MBR5EarasErXOTdS1+-eg@mail.gmail.com' \
    --to=giangiacomo.mariotti@gmail.com \
    --cc=linux-btrfs@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).