From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 905711A00EE; Tue, 30 Jul 2024 17:10:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722359452; cv=none; b=qFN0azrdhv6iiXVWHkL7rn0jC/t0VawPTki9OQCP5/Rqfi2x/YEBvIgglEn9n+/JwByDOYWyXhlxPOm7Ix+LNNiWIdZB6V9nI53Z7S7DU102j7G5S9PbdLS/Pr5IA7X4yjpaM9Cj0Bwig/QXMM79Kjf8jyYFtK28aX3YPfR3Zzc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722359452; c=relaxed/simple; bh=dln4i7VMZDu81yZm2BiFBjeCeeLtlkpWx3R79xCLCoU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nAeld5QVcEIECyaVnFNOoFZZSnW8aCYP3bufrLB5Oz8Zor/oQ1D6D3MOIXwhgEqgAnF1EmHEA2WGBi/tC+VZyiLpYrxSq01qutXyMOJErgIxs21iNYr/X6D9N/q6vKX34Q1LI0uLoJFnvcJV7lQ0mQBdhs5LI31cBmszjPGNfSI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=zVRbcLw9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="zVRbcLw9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18B20C32782; Tue, 30 Jul 2024 17:10:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1722359452; bh=dln4i7VMZDu81yZm2BiFBjeCeeLtlkpWx3R79xCLCoU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zVRbcLw9AKuIDGygT8fdlMSwRvmte68J7aUDTvbNwiAyKiqKfnlMH2Ur5BvR2PDGB T0cg8XWxs9zUOvwRSMVRNW603FtV/d6VSfCRzCvuIogj+033WY3Ba+ejmx0RS1RoxB C5At5LJXGxDYJqY+8ThtulDsZCtfg+Og2eC7FZcE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Konstantin Komarov , Sasha Levin Subject: [PATCH 6.10 485/809] fs/ntfs3: Fix transform resident to nonresident for compressed files Date: Tue, 30 Jul 2024 17:46:01 +0200 Message-ID: <20240730151743.894565046@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240730151724.637682316@linuxfoundation.org> References: <20240730151724.637682316@linuxfoundation.org> User-Agent: quilt/0.67 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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Konstantin Komarov [ Upstream commit 25610ff98d4a34e6a85cbe4fd8671be6b0829f8f ] Сorrected calculation of required space len (in clusters) for attribute data storage in case of compression. Fixes: be71b5cba2e64 ("fs/ntfs3: Add attrib operations") Signed-off-by: Konstantin Komarov Signed-off-by: Sasha Levin --- fs/ntfs3/attrib.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 9ccec45190749..8638248d80d93 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -231,7 +231,7 @@ int attr_make_nonresident(struct ntfs_inode *ni, struct ATTRIB *attr, struct ntfs_sb_info *sbi; struct ATTRIB *attr_s; struct MFT_REC *rec; - u32 used, asize, rsize, aoff, align; + u32 used, asize, rsize, aoff; bool is_data; CLST len, alen; char *next; @@ -252,10 +252,13 @@ int attr_make_nonresident(struct ntfs_inode *ni, struct ATTRIB *attr, rsize = le32_to_cpu(attr->res.data_size); is_data = attr->type == ATTR_DATA && !attr->name_len; - align = sbi->cluster_size; - if (is_attr_compressed(attr)) - align <<= NTFS_LZNT_CUNIT; - len = (rsize + align - 1) >> sbi->cluster_bits; + /* len - how many clusters required to store 'rsize' bytes */ + if (is_attr_compressed(attr)) { + u8 shift = sbi->cluster_bits + NTFS_LZNT_CUNIT; + len = ((rsize + (1u << shift) - 1) >> shift) << NTFS_LZNT_CUNIT; + } else { + len = bytes_to_cluster(sbi, rsize); + } run_init(run); -- 2.43.0