[Btrfs-devel][PATCH]Fix for btrfs_drop_extents

Yan Zheng yanzheng at 21cn.com
Wed Jan 30 10:55:35 PST 2008


Hello,

The test case in previous mail doesn't work due to changes recently
pushed out. Here is the new test case.

Regards
YZ
---
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
	int fd;
	int ret;
	char buf[8192];

	fd = open(argv[1], O_RDWR | O_CREAT | O_EXCL, 0644);
	if (fd < 0) {
		perror("open");
		exit(1);
	}
	/* create inline extent */
	ret = pwrite(fd, buf, 1024 * 6 - 1, 4096);
	if (ret < 0) {
		perror("write");
		exit(1);
	}
	/* disable packing of data */
	ret = pwrite(fd, buf, 4096, 32768);
	if (ret < 0) {
		perror("write");
		exit(1);
	}
	/* drop file extents in range 0 ~ 8192 */
	ret = pwrite(fd, buf, 8192, 0);
	if (ret < 0) {
		perror("write");
		exit(1);
	}
	close(fd);
	return 0;
}



More information about the Btrfs-devel mailing list