Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp999475lqt; Fri, 7 Jun 2024 05:27:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXlLGtIW4/snokh6JtEUC9LFSCnuik5KCS+M5yPRLX73L2rnpKxrID7LJX2OYwUF+JsSNvHQr0qFoqtTDAKbTb+JclTqQ6hfU3HIPq1Nw== X-Google-Smtp-Source: AGHT+IE2V9xEPlWKUpAvk8WrQ52Ge5vyHRI72thMm9kTAgy+sST9+EEHZkC/KBGHu81ZOTU42DN0 X-Received: by 2002:a05:6830:1d77:b0:6f8:86c2:203a with SMTP id 46e09a7af769-6f95726abf2mr2311644a34.21.1717763252132; Fri, 07 Jun 2024 05:27:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717763252; cv=pass; d=google.com; s=arc-20160816; b=lHIyr7n0rXumhwajYOsELpVyeq3cDzPxCMTuWtJLCfyrkIIANpkEfhNbu3a90zSe9x r70WDo9w1nLnL0Fn0hesbXG/h8dkZY7mytvLOFc/DHV3BAyCnzdqf8myiNFuEJnXbJy0 +X9sRc9s4CC7BGsx28dLBBPp+G9lOrW1sowDM5cCWg1ubnr1QRmojp39rKcH7bYUFQLf oYU4yC9MITQ6dx0w1LqkZlCCmLAELp1OD8bINOWYTr+mnsli3020hYWjj5TZN1tfdzik Sx/WKe73Z2GrsmR0hXZoD3pPzsNlz0ySio7Jv7KPWNv9dxi3OSQMac/nQmhyMpMMOiAl peuw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature; bh=C0FGKScgnT35/rhseY+g8+MwboIiYrT4rJr94CiH6dY=; fh=xoZo938iZo6Zo9BQRi1y1Y/2pdszedQYQQiMhZQzvOk=; b=cw8CA1dEll37GRUpFOFrHT4T+pmMb5MxYJURlZwnIDzn1eMwzw5J7QGJGqLrLfin6J aHhoBsWjxHas7jikXwUm9A9ladJrpgsAjhZ1Fef8kjqV9GD5VxliEZNh0haBf+/bbxhK BLQXBcc43AyjmWmhxsLRbsLlpb6/pD2zE0XvoWcL6bbPfi6kRiyvAq2yVwqqdWagcy6P MGUoABdFv59A5xIGRdHsAMs8wKvFur0DqTQUKCR18WlymZ0hLGByhVx2lIeSNLtecL8H h2rTpalInr0gyarHJwHwhiBk8/ZUsEIsmJdrOxUS7TRQtTmagnDHK5bcu69U6KT35hfl A1uA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=pciVf6Lh; dkim=pass header.i=@paragon-software.com header.s=mail header.b="Rtx/WFi/"; arc=pass (i=1 spf=pass spfdomain=paragon-software.com dkim=pass dkdomain=paragon-software.com dkim=pass dkdomain=paragon-software.com dmarc=pass fromdomain=paragon-software.com); spf=pass (google.com: domain of linux-kernel+bounces-206028-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206028-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-7953ef1a3a2si81726085a.626.2024.06.07.05.27.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 05:27:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206028-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=pciVf6Lh; dkim=pass header.i=@paragon-software.com header.s=mail header.b="Rtx/WFi/"; arc=pass (i=1 spf=pass spfdomain=paragon-software.com dkim=pass dkdomain=paragon-software.com dkim=pass dkdomain=paragon-software.com dmarc=pass fromdomain=paragon-software.com); spf=pass (google.com: domain of linux-kernel+bounces-206028-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206028-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CE7FF1C2342A for ; Fri, 7 Jun 2024 12:27:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B8391922E5; Fri, 7 Jun 2024 12:26:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="pciVf6Lh"; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="Rtx/WFi/" Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (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 3DB5E1922F2; Fri, 7 Jun 2024 12:26:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717763177; cv=none; b=RqIFPx6LS2+s99y1g6ccHfcsKvBM3U1fvv9DToKeIT6soUbgfddG//S178gc80aKkTTmyRINPxxkt3l0SzqcthWhdKMFgsDPlNSv2iICKhBKXhwf9MxLssHIw9pQ23sSRAMCdi920jaLj4WXL3N7WTcLS9yyJ0HJa4PuV/HUHXQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717763177; c=relaxed/simple; bh=Qftod05FG8cvV0DSzaUmUcM0W3C99UwJOo6+6K5E5Q0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OT1qXnBSi0xSSGz/RhI6yFgOrmiSd1+FnfxsgeWF8Ym+I1kL4IiTSV8ZZtCGArNhIIweWsbETqWzY0J+IjTOKRyYgnPYRY+u8K6K0qEe3iQTwkCf8THAjEu86XHhsY6NlVE11B0w6xfEAT29L6S3Be2CN1dOBN/LXihgMQxkpmA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=pciVf6Lh; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=Rtx/WFi/; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id A986C210F; Fri, 7 Jun 2024 12:08:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1717762093; bh=C0FGKScgnT35/rhseY+g8+MwboIiYrT4rJr94CiH6dY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=pciVf6LhJPjNSSemFdaR0dyVndK7+XIl3Ol5Urwi736uGXEw+YMn1LLC29agSpdgQ HiW2zgOEyemCnAwE2iT3bXnnhUS8Cc4gGkMIVWcUv3pcZRLrGzusnOwnNya84ZwvKN QmnJYKv+QmHVLNthp3kd83AOvQhY2D/nKDCZfKQQ= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 8D3D7195; Fri, 7 Jun 2024 12:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1717762567; bh=C0FGKScgnT35/rhseY+g8+MwboIiYrT4rJr94CiH6dY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Rtx/WFi/ykZJaXFGm3HBVjNjkCEEWUQyaucxmFbLNNcTSc+eptRAUchT1VcRMLI4e 49jCBSnBbKXDXQEl/0LoSgDEFTbsYyM+dYNeyMbmwoJavnF82PLaVj9JcZa3hmX5pz Ss2o6UJfeOQllTIonhl3DU54Tu0ZRN/yrKtY/NWc= Received: from ntfs3vm.paragon-software.com (192.168.211.95) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Fri, 7 Jun 2024 15:16:07 +0300 From: Konstantin Komarov To: CC: , , Konstantin Komarov Subject: [PATCH 03/18] fs/ntfs3: Fix transform resident to nonresident for compressed files Date: Fri, 7 Jun 2024 15:15:33 +0300 Message-ID: <20240607121548.18818-4-almaz.alexandrovich@paragon-software.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240607121548.18818-1-almaz.alexandrovich@paragon-software.com> References: <20240607121548.18818-1-almaz.alexandrovich@paragon-software.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) С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 --- 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 8e6bcdf99770..8638248d80d9 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 <<= COMPRESSION_UNIT; - 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.34.1