kernel-hacking-2024-linux-s.../fs/ocfs2
Tao Ma 38a04e4327 ocfs2: Find proper end cpos for a leaf refcount block.
ocfs2 refcount tree is stored as an extent tree while
the leaf ocfs2_refcount_rec points to a refcount block.

The following step can trip a kernel panic.
mkfs.ocfs2 -b 512 -C 1M --fs-features=refcount $DEVICE
mount -t ocfs2 $DEVICE $MNT_DIR
FILE_NAME=$RANDOM
FILE_NAME_1=$RANDOM
FILE_REF="${FILE_NAME}_ref"
FILE_REF_1="${FILE_NAME}_ref_1"
for((i=0;i<305;i++))
do
# /mnt/1048576 is a file with 1048576 sizes.
cat /mnt/1048576 >> $MNT_DIR/$FILE_NAME
cat /mnt/1048576 >> $MNT_DIR/$FILE_NAME_1
done
for((i=0;i<3;i++))
do
cat /mnt/1048576 >> $MNT_DIR/$FILE_NAME
done

for((i=0;i<2;i++))
do
cat /mnt/1048576 >> $MNT_DIR/$FILE_NAME
cat /mnt/1048576 >> $MNT_DIR/$FILE_NAME_1
done

cat /mnt/1048576 >> $MNT_DIR/$FILE_NAME

for((i=0;i<11;i++))
do
cat /mnt/1048576 >> $MNT_DIR/$FILE_NAME
cat /mnt/1048576 >> $MNT_DIR/$FILE_NAME_1
done
reflink $MNT_DIR/$FILE_NAME $MNT_DIR/$FILE_REF
# write_f is a program which will write some bytes to a file at offset.
# write_f -f file_name -l offset -w write_bytes.
./write_f -f $MNT_DIR/$FILE_REF -l $[310*1048576] -w 4096
./write_f -f $MNT_DIR/$FILE_REF -l $[306*1048576] -w 4096
./write_f -f $MNT_DIR/$FILE_REF -l $[311*1048576] -w 4096
./write_f -f $MNT_DIR/$FILE_NAME -l $[310*1048576] -w 4096
./write_f -f $MNT_DIR/$FILE_NAME -l $[311*1048576] -w 4096
reflink $MNT_DIR/$FILE_NAME $MNT_DIR/$FILE_REF_1
./write_f -f $MNT_DIR/$FILE_NAME -l $[311*1048576] -w 4096
#kernel panic here.

The reason is that if the ocfs2_extent_rec is the last record
in a leaf extent block, the old solution fails to find the
suitable end cpos. So this patch try to walk through the b-tree,
find the next sub root and get the c_pos the next sub-tree starts
from.

btw, I have runned tristan's test case against the patched kernel
for several days and this type of kernel panic never happens again.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Joel Becker <joel.becker@oracle.com>
2009-12-02 16:14:57 -08:00
..
cluster const: constify remaining file_operations 2009-10-01 16:11:11 -07:00
dlm const: constify remaining file_operations 2009-10-01 16:11:11 -07:00
acl.c
acl.h
alloc.c ocfs2: Find proper end cpos for a leaf refcount block. 2009-12-02 16:14:57 -08:00
alloc.h ocfs2: Find proper end cpos for a leaf refcount block. 2009-12-02 16:14:57 -08:00
aops.c Merge branch 'hwpoison' of git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-mce-2.6 2009-09-24 07:53:22 -07:00
aops.h ocfs2: Add CoW support. 2009-09-22 20:09:36 -07:00
blockcheck.c
blockcheck.h
buffer_head_io.c ocfs2: Take the inode out of the metadata read/write paths. 2009-09-04 16:07:48 -07:00
buffer_head_io.h ocfs2: Take the inode out of the metadata read/write paths. 2009-09-04 16:07:48 -07:00
dcache.c ocfs2: invalidate dentry if its dentry_lock isn't initialized. 2009-08-27 18:10:54 -07:00
dcache.h ocfs2: Fix deadlock on umount 2009-07-21 15:47:55 -07:00
dir.c ocfs2: Pass ocfs2_caching_info into ocfs_init_*_extent_tree(). 2009-09-04 16:08:13 -07:00
dir.h
dlmglue.c dlmglue.c: add missed mlog lines 2009-09-23 01:54:47 -07:00
dlmglue.h ocfs2: Add new refcount tree lock resource in dlmglue. 2009-09-22 20:09:28 -07:00
export.c
export.h
extent_map.c ocfs2: Return extent flags for xattr value tree. 2009-09-22 20:09:39 -07:00
extent_map.h ocfs2: Return extent flags for xattr value tree. 2009-09-22 20:09:39 -07:00
file.c ocfs2: duplicate inline data properly during reflink. 2009-10-28 22:48:23 -07:00
file.h ocfs2: Integrate CoW in file write. 2009-09-22 20:09:37 -07:00
heartbeat.c
heartbeat.h
inode.c ocfs2: Call refcount tree remove process properly. 2009-09-22 20:09:44 -07:00
inode.h ocfs2: Drop struct inode from ocfs2_extent_tree_operations. 2009-09-04 16:07:57 -07:00
ioctl.c Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jlbec/ocfs2 2009-09-23 09:29:20 -07:00
ioctl.h
journal.c ocfs2: Add metaecc for ocfs2_refcount_block. 2009-09-22 20:09:26 -07:00
journal.h ocfs2: Decrement refcount when truncating refcounted extents. 2009-09-22 20:09:35 -07:00
Kconfig
localalloc.c ocfs2: Pass struct ocfs2_caching_info to the journal functions. 2009-09-04 16:07:50 -07:00
localalloc.h
locks.c
locks.h
Makefile ocfs2: Add ocfs2_read_refcount_block. 2009-09-22 20:09:26 -07:00
mmap.c const: mark struct vm_struct_operations 2009-09-27 11:39:25 -07:00
mmap.h
namei.c ocfs2: Create reflinked file in orphan dir. 2009-09-22 20:09:48 -07:00
namei.h ocfs2: Create reflinked file in orphan dir. 2009-09-22 20:09:48 -07:00
ocfs1_fs_compat.h
ocfs2.h ocfs2: Trivial cleanup of jbd compatibility layer removal 2009-11-13 15:45:05 -08:00
ocfs2_fs.h ocfs2: Add ioctl for reflink. 2009-09-22 20:09:51 -07:00
ocfs2_lockid.h ocfs2: Add new refcount tree lock resource in dlmglue. 2009-09-22 20:09:28 -07:00
ocfs2_lockingver.h
quota.h const: make struct super_block::dq_op const 2009-09-22 07:17:24 -07:00
quota_global.c Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jlbec/ocfs2 2009-09-23 09:29:20 -07:00
quota_local.c ocfs2: Pass struct ocfs2_caching_info to the journal functions. 2009-09-04 16:07:50 -07:00
refcounttree.c ocfs2: Find proper end cpos for a leaf refcount block. 2009-12-02 16:14:57 -08:00
refcounttree.h ocfs2: Add ioctl for reflink. 2009-09-22 20:09:51 -07:00
resize.c ocfs2: Pass struct ocfs2_caching_info to the journal functions. 2009-09-04 16:07:50 -07:00
resize.h
slot_map.c ocfs2: Take the inode out of the metadata read/write paths. 2009-09-04 16:07:48 -07:00
slot_map.h
stack_o2cb.c ocfs2: keep index within status_map[] 2009-08-07 13:16:50 -07:00
stack_user.c
stackglue.c
stackglue.h
suballoc.c ocfs2: Pass ocfs2_caching_info to ocfs2_read_extent_block(). 2009-09-04 16:07:52 -07:00
suballoc.h
super.c ocfs2: return f_fsid info in ocfs2_statfs() 2009-10-29 15:02:20 -07:00
super.h
symlink.c headers: utsname.h redux 2009-09-23 18:13:10 -07:00
symlink.h
sysfile.c
sysfile.h
uptodate.c ocfs2: Trivial cleanup of jbd compatibility layer removal 2009-11-13 15:45:05 -08:00
uptodate.h ocfs2: Pass struct ocfs2_caching_info to the journal functions. 2009-09-04 16:07:50 -07:00
ver.c
ver.h
xattr.c ocfs2: Add preserve to reflink. 2009-09-22 20:09:49 -07:00
xattr.h ocfs2: Add preserve to reflink. 2009-09-22 20:09:49 -07:00