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 A56E3396B9A; Sat, 12 Sep 2026 07:04:24 +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=1789196668; cv=none; b=KmYk3wxf8ecrCcD/gBTOYtBSKwqJUwZVFYuX9aNq7arvX+pewvflnTlV9W53nxZxzZPTCo4Ta666ixtbnHDYYm2zc/2Sm2gyjCibOdtrNHztNzRtLIHUA3cP8Xv2dlYSbPJZ5yeIw5IXO6RLaBqWYw3L5Z3GL9zwSnqJZ1rsY/0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789196668; c=relaxed/simple; bh=ABLIkbQ9XWk3nod46dOc+K3eEuW0cTTa7f/EGNqtjZI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VIxq2rOpEUP6ECTnRj7+H7/2xCo7icYhC37q7QgqGMNEvBQIRBwANfj8hLNJdJPU9TnK6SfH86xP/wiZOepr4G6+NKdY/s0ZQnnQsy7B+nNJ331KEsEwPN3MYcW+24ozQorM9oFu+PKDUjijHtdNm9oBLCk7P6MnWSUZDau1RZs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uQ3NRA/n; 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="uQ3NRA/n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A26501F000FF; Sat, 12 Sep 2026 07:04:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789196659; bh=bgfBpLPSRI0Spp8oZN/lywBygbGGOGhZxjWqcHDEnxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=uQ3NRA/niOCszmk64FDCU+6fzffnUcA2tVKnXCMfnEbBnAmXjA3qw6/N4VCdRNALD d5p5QRqfitKD66ftoO7zRUHQsmjPqgqaOxq4dCZr/H3bxeQNxLAEu1r0lgrs+EvYqf S4tNzsF1c/oqvhAxoTcS818RwZIcu2l04lLLKcWg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jan Kara , Sasha Levin Subject: [PATCH 7.2 0012/1815] udf: Fix data loss when converting inline inodes to out of line Date: Sat, 12 Sep 2026 08:29:22 +0200 Message-ID: <20260912065649.297566984@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065648.999753832@linuxfoundation.org> References: <20260912065648.999753832@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 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara [ Upstream commit 62333e480d12ab186f89fe2725b372d12f72d5eb ] When udf_expand_file_adinicb() converts file from inline format to out of line, we use filemap_fdatawrite() to writeout the data to the new blocks. However since 36580ed08776 ("udf: Do not allocate blocks on page writeback") the writeback actually doesn't allocate the new block and the folio dirty bit is just silently cleared. Thus unless the file is written to after the conversion (as it can easily happen in case of truncate up), the data is just lost. Fix the problem by explicitely allocating the block underlying the data before starting writeback. Fixes: 36580ed08776 ("udf: Do not allocate blocks on page writeback") CC: stable@vger.kernel.org Link: https://patch.msgid.link/20260730104232.4086759-4-jack@suse.cz Signed-off-by: Jan Kara Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/udf/inode.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -405,6 +405,10 @@ int udf_expand_file_adinicb(struct inode { struct folio *folio; struct udf_inode_info *iinfo = UDF_I(inode); + struct udf_map_rq map = { + .lblk = 0, + .iflags = UDF_MAP_CREATE, + }; int err; WARN_ON_ONCE(!inode_is_locked(inode)); @@ -434,20 +438,27 @@ int udf_expand_file_adinicb(struct inode iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT; else iinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG; + up_write(&iinfo->i_data_sem); + + /* Allocate the block underlying the data */ + err = udf_map_block(inode, &map); + if (err < 0) + goto restore; + folio_mark_dirty(folio); folio_unlock(folio); - up_write(&iinfo->i_data_sem); err = filemap_fdatawrite(inode->i_mapping); if (err) { /* Restore everything back so that we don't lose data... */ folio_lock(folio); +restore: down_write(&iinfo->i_data_sem); memcpy_from_folio(iinfo->i_data + iinfo->i_lenEAttr, folio, 0, inode->i_size); - folio_unlock(folio); iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB; iinfo->i_lenAlloc = inode->i_size; up_write(&iinfo->i_data_sem); + folio_unlock(folio); } folio_put(folio); mark_inode_dirty(inode);