From: Wei Gao <wegao@xxxxxxxx> [ Upstream commit a099b09a3342a0b28ea330e405501b5b4d0424b4 ] Previously, ext2_fiemap would unconditionally apply "len = min_t(u64, len, i_size_read(inode));", When inode->i_size was 0 (for an empty file), this would reduce the requested len to 0. Passing len = 0 to iomap_fiemap could then result in an -EINVAL error, even for valid queries on empty files. Link: https://github.com/linux-test-project/ltp/issues/1246 Signed-off-by: Wei Gao <wegao@xxxxxxxx> Signed-off-by: Jan Kara <jack@xxxxxxx> Link: https://patch.msgid.link/20250613152402.3432135-1-wegao@xxxxxxxx Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> --- LLM Generated explanations, may be completely bogus: Based on my analysis of the commit and its context: **Backport Status: YES** This commit should be backported to stable kernel trees. Here's the extensive analysis: **1. Bug Fix Analysis:** The commit fixes a user-visible bug where `fiemap` operations on empty files (i_size = 0) could fail with -EINVAL. Looking at the code change in fs/ext2/inode.c: - **Before the fix**: `len = min_t(u64, len, i_size_read(inode));` would set len to 0 for empty files - **After the fix**: The code adds a special check: ```c if (i_size == 0) i_size = 1; len = min_t(u64, len, i_size); ``` This ensures that even for empty files, we pass a non-zero length to `iomap_fiemap()`. **2. Root Cause:**