From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAA49169AD2; Tue, 16 Jun 2026 18:36:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781634972; cv=none; b=KhvSvEB4QTjxmhs8/XgQj7M0Xcx7nUe8+l/VySnHb/6L6GeeeIyaRhFIKY/g9AMzKR7BZVd4ezYlI2gFE6FEi1xmHw3PyC6VFPCl83KyFuOKcZ4q8CfabyLMWkmOEU1p49kMw/k6x62Ts1gQSYc93KwvocB4/MhuVKWc9d6as+M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781634972; c=relaxed/simple; bh=Hz0jz9+pWaVjvftxVsEm9TCadJGSz3a2XTgDn20559U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SW5wzY+TXqoLUuoiXDPE8rD3rcUifzbGRCraVShm6fFcHV1fCX+w86ZYjjoD/vtXq0xibAPzbJpbAyYXZZqW/3rDqA7W+4faq8+phKxzGrLqA0GYpfcDAJjmHGVQqC0qBorLJVh1sfJChj9t2HbGcdHC4XfEhpDmsgdz7CyfVmg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=crY2dYhv; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="crY2dYhv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF5A81F000E9; Tue, 16 Jun 2026 18:36:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781634971; bh=kny3GE5+OPQjtbNC+eHcAoowmmui0fo8ZfOP+BBk8is=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=crY2dYhvJ6HuMtGTg51cOozfYTr+hXHbLhv8UALKQNFpOPq6sTSNCV6uJD3DRGCjm E4YQNbMJNSBB1g9nTR3MuoS9v2Evj29C0lBMTvPCt16mYApip/L1tgDhM+YPXzX6xh o8axKi/fLQY1cKG6DnGN/36GLhFftlPp1t6VcV80= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable@kernel.org, Yongpeng Yang , Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 5.15 333/411] f2fs: fix incorrect file address mapping when inline inode is unwritten Date: Tue, 16 Jun 2026 20:29:31 +0530 Message-ID: <20260616145118.862076450@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145100.376842714@linuxfoundation.org> References: <20260616145100.376842714@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yongpeng Yang [ Upstream commit 68a0178981a0f493295afa29f8880246e561494c ] When `fileinfo->fi_flags` does not have the `FIEMAP_FLAG_SYNC` bit set and inline data has not been persisted yet, the physical address of the extent is calculated incorrectly for unwritten inline inodes. root@vm:/mnt/f2fs# dd if=/dev/zero of=data.3k bs=3k count=1 root@vm:/mnt/f2fs# f2fs_io fiemap 0 100 data.3k Fiemap: offset = 0 len = 100 logical addr. physical addr. length flags 0 0000000000000000 00000ffffffff16c 0000000000000c00 00000301 This patch fixes the issue by checking if the inode's address is valid. If the inline inode is unwritten, set the physical address to 0 and mark the extent with `FIEMAP_EXTENT_UNKNOWN | FIEMAP_EXTENT_DELALLOC` flags. Cc: stable@kernel.org Fixes: 67f8cf3cee6f ("f2fs: support fiemap for inline_data") Signed-off-by: Yongpeng Yang Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim [ renamed `ifolio` to `ipage` in `inline_data_addr()` and `F2FS_INODE()` calls ] Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/f2fs/inline.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) --- a/fs/f2fs/inline.c +++ b/fs/f2fs/inline.c @@ -771,7 +771,7 @@ int f2fs_read_inline_dir(struct file *fi int f2fs_inline_data_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, __u64 start, __u64 len) { - __u64 byteaddr, ilen; + __u64 byteaddr = 0, ilen; __u32 flags = FIEMAP_EXTENT_DATA_INLINE | FIEMAP_EXTENT_NOT_ALIGNED | FIEMAP_EXTENT_LAST; struct node_info ni; @@ -804,9 +804,14 @@ int f2fs_inline_data_fiemap(struct inode if (err) goto out; - byteaddr = (__u64)ni.blk_addr << inode->i_sb->s_blocksize_bits; - byteaddr += (char *)inline_data_addr(inode, ipage) - - (char *)F2FS_INODE(ipage); + if (__is_valid_data_blkaddr(ni.blk_addr)) { + byteaddr = (__u64)ni.blk_addr << inode->i_sb->s_blocksize_bits; + byteaddr += (char *)inline_data_addr(inode, ipage) - + (char *)F2FS_INODE(ipage); + } else { + f2fs_bug_on(F2FS_I_SB(inode), ni.blk_addr != NEW_ADDR); + flags |= FIEMAP_EXTENT_DELALLOC | FIEMAP_EXTENT_UNKNOWN; + } err = fiemap_fill_next_extent(fieinfo, start, byteaddr, ilen, flags); trace_f2fs_fiemap(inode, start, byteaddr, ilen, flags, err); out: