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 2960329DB64; Sat, 12 Sep 2026 15:56:20 +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=1789228581; cv=none; b=ckDVfsOkygJ83Qnml4IVStz09+u0zi3F0l0/2/XtdhYVIAU0F/zflcu8FkAoIk8vfUEk+TkE/Iu077n0C+fxWg0aFm0hCEtOWARKJP5Z0XlCEXiIPowR77oJVWwbBMzJZXTkw9djeX1mfN6GWGHOmklRznsn/yMqmHZGWC7hsco= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789228581; c=relaxed/simple; bh=wVcDLMfKoM0bUDHDMBhQgvWlXCp9poEwyZys3IzLfx4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tTZ+pWVOC8QH2lkjUqhXYHb5pn0NVPnTQ/IOJE33iDyReipxug/qdYCGcID5hlRdowwXXPHhA7fN8syxAM0v1PSqHQ26v6h4I3C6BCYSgjib2XQC0f9Sdv3tI5llQiBTdqsYeNsEfe0C0OkhLDrMcKRHgzKtIzEdJ1IjvqZbVmM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FivFMOx+; 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="FivFMOx+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 295441F000FF; Sat, 12 Sep 2026 15:56:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789228580; bh=IWl8ZFz47RTbL4qbo8o+zy7Oc/7b0RZkgvns1aooKSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FivFMOx+PabBZsOToxSwELxdgi5+s9wLvbzrc220TQxLQgn5tNoGYI/1Laxd9So74 w71JVQS4gghmquk5PYc1ZE6+9unf8h3wHafljYSiPl1x7MlY7rbyDRGjHCRdk1xsyD rnveMvhTgYt9Y8IQjY5bAW0KuWxeAbf5VEhnAIlc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable@kernel.org, Wenjie Qi , Chao Yu , Jaegeuk Kim Subject: [PATCH 6.1 0412/1191] f2fs: return writeback error from collapse range Date: Sat, 12 Sep 2026 08:52:20 +0200 Message-ID: <20260912065557.492232850@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065548.086904252@linuxfoundation.org> References: <20260912065548.086904252@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 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wenjie Qi commit f8a4108800254d6f7b2755515fbbd9d0caac561e upstream. f2fs_collapse_range() writes back pages moved by f2fs_do_collapse(), but ignores the return value. If writeback fails, the ioctl can still truncate page cache, shrink blocks, and report success. Return the error before truncating page cache or updating the file size. Fixes: b4ace3370324 ("f2fs: support FALLOC_FL_COLLAPSE_RANGE") Cc: stable@kernel.org Assisted-by: Codex:gpt-5.5 Signed-off-by: Wenjie Qi Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Greg Kroah-Hartman --- fs/f2fs/file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1499,11 +1499,14 @@ static int f2fs_collapse_range(struct in /* write out all moved pages, if possible */ filemap_invalidate_lock(inode->i_mapping); - filemap_write_and_wait_range(inode->i_mapping, offset, LLONG_MAX); + ret = filemap_write_and_wait_range(inode->i_mapping, offset, LLONG_MAX); + if (ret) + goto out_unlock; truncate_pagecache(inode, offset); new_size = i_size_read(inode) - len; ret = f2fs_truncate_blocks(inode, new_size, true); +out_unlock: filemap_invalidate_unlock(inode->i_mapping); if (!ret) f2fs_i_size_write(inode, new_size);