android_kernel_motorola_sm6375/fs/ocfs2
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Deepanshu Kartikey 93166bc53c ocfs2: clear extent cache after moving/defragmenting extents
commit 78a63493f8e352296dbc7cb7b3f4973105e8679e upstream.

The extent map cache can become stale when extents are moved or
defragmented, causing subsequent operations to see outdated extent flags.
This triggers a BUG_ON in ocfs2_refcount_cal_cow_clusters().

The problem occurs when:
1. copy_file_range() creates a reflinked extent with OCFS2_EXT_REFCOUNTED
2. ioctl(FITRIM) triggers ocfs2_move_extents()
3. __ocfs2_move_extents_range() reads and caches the extent (flags=0x2)
4. ocfs2_move_extent()/ocfs2_defrag_extent() calls __ocfs2_move_extent()
   which clears OCFS2_EXT_REFCOUNTED flag on disk (flags=0x0)
5. The extent map cache is not invalidated after the move
6. Later write() operations read stale cached flags (0x2) but disk has
   updated flags (0x0), causing a mismatch
7. BUG_ON(!(rec->e_flags & OCFS2_EXT_REFCOUNTED)) triggers

Fix by clearing the extent map cache after each extent move/defrag
operation in __ocfs2_move_extents_range().  This ensures subsequent
operations read fresh extent data from disk.

Link: https://lore.kernel.org/all/[email protected]/T/
Link: https://lkml.kernel.org/r/[email protected]
Fixes: 53069d4e76 ("Ocfs2/move_extents: move/defrag extents within a certain range.")
Signed-off-by: Deepanshu Kartikey <[email protected]>
Reported-by: [email protected]
Tested-by: [email protected]
Closes: https://syzkaller.appspot.com/bug?id=2959889e1f6e216585ce522f7e8bc002b46ad9e7
Reviewed-by: Mark Fasheh <[email protected]>
Reviewed-by: Joseph Qi <[email protected]>
Cc: Joel Becker <[email protected]>
Cc: Junxiao Bi <[email protected]>
Cc: Changwei Ge <[email protected]>
Cc: Jun Piao <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
2025-10-29 13:59:59 +01:00
..
cluster
dlm ocfs2/dlm: move BITS_TO_BYTES() to bitops.h for wider use 2023-06-09 10:28:54 +02:00
dlmfs ocfs2: dlmfs: fix error handling of user_dlm_destroy_lock 2022-06-14 18:11:46 +02:00
acl.c
acl.h
alloc.c ocfs2: validate l_tree_depth to avoid out-of-bounds access 2025-04-10 14:29:41 +02:00
alloc.h
aops.c ocfs2: fix uninit-value in ocfs2_get_block() 2024-11-08 16:20:41 +01:00
aops.h ocfs2: fix uninitialized value in ocfs2_file_read_iter() 2024-12-14 19:44:30 +01:00
blockcheck.c
blockcheck.h
buffer_head_io.c ocfs2: fix possible null-ptr-deref in ocfs2_set_buffer_uptodate 2024-11-08 16:20:41 +01:00
buffer_head_io.h
dcache.c
dcache.h
dir.c ocfs2: check dir i_size in ocfs2_find_entry 2025-03-13 12:43:12 +01:00
dir.h
dlmglue.c ocfs2: update seq_file index in ocfs2_dlm_seq_next 2024-12-14 19:44:48 +01:00
dlmglue.h
export.c
export.h
extent_map.c ocfs2: fix recursive semaphore deadlock in fiemap call 2025-10-02 13:34:27 +02:00
extent_map.h
file.c ocfs2: fix uninitialized value in ocfs2_file_read_iter() 2024-12-14 19:44:30 +01:00
file.h
filecheck.c ocfs2: fix snprintf() checking 2021-07-14 16:53:25 +02:00
filecheck.h
heartbeat.c
heartbeat.h
inode.c
inode.h
ioctl.c
ioctl.h
journal.c ocfs2: stop quota recovery before disabling quotas 2025-06-04 14:32:27 +02:00
journal.h ocfs2: stop quota recovery before disabling quotas 2025-06-04 14:32:27 +02:00
Kconfig
localalloc.c ocfs2: Revert "ocfs2: fix the la space leak when unmounting an ocfs2 volume" 2024-12-14 19:44:56 +01:00
localalloc.h
locks.c
locks.h
Makefile
mmap.c
mmap.h
move_extents.c ocfs2: clear extent cache after moving/defragmenting extents 2025-10-29 13:59:59 +01:00
move_extents.h
namei.c ocfs2: free inode when ocfs2_get_init_inode() fails 2024-12-14 19:44:48 +01:00
namei.h
ocfs1_fs_compat.h
ocfs2.h ocfs2: stop quota recovery before disabling quotas 2025-06-04 14:32:27 +02:00
ocfs2_fs.h
ocfs2_ioctl.h
ocfs2_lockid.h
ocfs2_lockingver.h
ocfs2_trace.h
quota.h
quota_global.c ocfs2: mark dquot as inactive if failed to start trans while releasing dquot 2025-03-13 12:42:59 +01:00
quota_local.c ocfs2: stop quota recovery before disabling quotas 2025-06-04 14:32:27 +02:00
refcounttree.c ocfs2: reserve space for inline xattr before attaching reflink tree 2024-11-08 16:20:41 +01:00
refcounttree.h
reservations.c
reservations.h
resize.c ocfs2: uncache inode which has failed entering the group 2024-12-14 19:44:18 +01:00
resize.h
slot_map.c
slot_map.h
stack_o2cb.c
stack_user.c ocfs2: fix double free in user_cluster_connect() 2025-10-29 13:59:49 +01:00
stackglue.c ocfs2: fix memory leak in ocfs2_stack_glue_init() 2023-01-18 11:40:54 +01:00
stackglue.h
suballoc.c
suballoc.h
super.c ocfs2: stop quota recovery before disabling quotas 2025-06-04 14:32:27 +02:00
super.h
symlink.c ocfs2: handle a symlink read error correctly 2025-03-13 12:43:11 +01:00
symlink.h
sysfile.c
sysfile.h
uptodate.c
uptodate.h
xattr.c ocfs2: remove entry once instead of null-ptr-dereference in ocfs2_xa_remove() 2024-11-17 14:58:52 +01:00
xattr.h