[btrfs-devel]Inline data extent handling issues

Yan Zheng yanzheng at 21cn.com
Mon Oct 22 06:31:38 PDT 2007


Hello,

Today, I read file.c in unstable-btrfs and found several inline data
extent handling issues. All these issues are somewhat relate to the
change that allow inline data size larger than page/sector size.

1.   When size of inline extent is larger than sector size,  the
operation that deal with inline extent in btrfs_drop_extents become
complex. Current codes only handle the case
that the drop range overlaps with the end of the inline extent. When
the drop range is in the middle of inline extent, btrfs_drop_extents
do nothing; when the drop range overlaps with the start of the inline
extent,  btrfs_drop_extents delete the inline extent(which is obvious
incorrect). I try to fix it locally, but it's too difficult for me.
Perhaps we need a helper function such as 'btrfs_split_item' in
ctree.c.

Here is the test for the third case, both node and leaf size are 32k
[root at yz-bc22ed btrfs]# dd if=/dev/urandom bs=6k count=1 of=test_file
1+0 records in
1+0 records out
6144 bytes (6.1 kB) copied, 0.00188678 s, 3.3 MB/s
[root at yz-bc22ed btrfs]# dd conv=notrunc if=/dev/urandom bs=4k count=1
of=test_file
1+0 records in
1+0 records out
4096 bytes (4.1 kB) copied, 0.00220471 s, 1.9 MB/s
[root at yz-bc22ed btrfs]# sync && debug-tree /dev/sdb1
...
	item 6 key (6 1 0) itemoff 32325 itemsize 104
		inode generation 0 size 6144 block group 0 mode 100644 links 1
	item 7 key (6 12 0) itemoff 28220 itemsize 4105
		inline extent data size 4096
...

2.  There are two issues in insert_inline_extent. First, it doesn't
correctly handle the case that parameter 'offset' isn't zero; Second,
it may leak some data to user space when inline data is extended. I
have a patch fix these issues,  but there is no time to do more test
today, I'll send it tomorrow.

Here is the test for the first issue. you can found that inline extent
data size is larger than the correct value.
[root at yz-bc22ed btrfs]# dd if=/dev/urandom bs=2k count=1 seek=2 of=test_file
1+0 records in
1+0 records out
2048 bytes (2.0 kB) copied, 0.000749249 s, 2.7 MB/s
[root at yz-bc22ed btrfs]# sync && debug-tree /dev/sdb1
...
		inline extent data size 2839
	item 10 key (8 1 0) itemoff 29309 itemsize 104
		inode generation 0 size 6144 block group 0 mode 100644 links 1
	item 11 key (8 12 0) itemoff 29268 itemsize 41
		extent data disk byte 0 nr 0
		extent data offset 0 nr 4096
	item 12 key (8 12 4096) itemoff 23115 itemsize 6153
		inline extent data size 6144
...

Regards
YZ



More information about the Btrfs-devel mailing list