From nobody Fri Dec 19 15:49:55 2025 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 77FAE35957; Mon, 19 May 2025 09:51:38 +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=1747648301; cv=none; b=eJZWIG4ciUU3S+72Hpxc05d9vD254EBTSebeJVH9UwI3ga8MIGnAM0fWAmh7QhULjPwz6gpZzTesRfqmHCVnCjLcaj2x+JO+Tri9Lmja8epdzxuLYKgE41X9Bsxx1YkId7HxriLl6KR16rpXrNGCpUbqBfmT0YF1N0UP5KYiJOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747648301; c=relaxed/simple; bh=1TFDZrnppSFAD0JlqH6lVEgL5rsRavitm3KqWQs/JKc=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=FofiIaHDCLQ+7FTmi43E5W8LYcJAJR+9zXtICfM9v1jGTp1Eac8VWh9le4RDRsAZUqMBS5w+Me5r0HzLP7c9FXsJeKc3vrq9keQEm98DbgRnU8HE8hxjkpM+eZM5SbY0O7sffu7sF5mH0T4un9kdtW2FGDSHdnswNBNX0JrSOCk= 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=iGuz3wx/; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="iGuz3wx/" Received: from relayfre-01.paragon-software.com (unknown [176.12.100.13]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id F19711D0B; Mon, 19 May 2025 09:51:24 +0000 (UTC) Authentication-Results: relayaws-01.paragon-software.com; dkim=pass (1024-bit key; unprotected) header.d=paragon-software.com header.i=@paragon-software.com header.b=iGuz3wx/; dkim-atps=neutral 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 6FF7F21B3; Mon, 19 May 2025 09:51:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1747648296; bh=jJvs72gtLIf+AhNDgR1jY87eVay24QMwgXIPiSfnjBo=; h=From:To:CC:Subject:Date; b=iGuz3wx/h+N+vwC7HG2rvgFEWMwGTFx8Xhv4xJEppJKty67yDUs3qH5NhWahppZNc 8dz4EWMdKDyjoLTl+ZF2MTVijXG6ks31IxlxdhbLkaZPCfRFcuLmKEIRKaJhs9D3f0 PkodATYA3wJ7kq+UihLz5OUrMamHbKQijAzLSClE= Received: from localhost.localdomain (172.30.20.142) 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; Mon, 19 May 2025 12:51:35 +0300 From: Konstantin Komarov To: CC: , , Konstantin Komarov Subject: [PATCH] fs/ntfs3: Fix handling of InitializeFileRecordSegment Date: Mon, 19 May 2025 11:51:27 +0200 Message-ID: <20250519095127.7233-1-almaz.alexandrovich@paragon-software.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) Content-Type: text/plain; charset="utf-8" Make the logic of handling the InitializeFileRecordSegment operation similar to that in windows. Signed-off-by: Konstantin Komarov --- fs/ntfs3/fslog.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c index e69f623b2e49..38934e6978ec 100644 --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -3091,16 +3091,16 @@ static int do_action(struct ntfs_log *log, struct O= PEN_ATTR_ENRTY *oe, inode =3D ilookup(sbi->sb, rno); if (inode) { mi =3D &ntfs_i(inode)->mi; - } else if (op =3D=3D InitializeFileRecordSegment) { - mi =3D kzalloc(sizeof(struct mft_inode), GFP_NOFS); - if (!mi) - return -ENOMEM; - err =3D mi_format_new(mi, sbi, rno, 0, false); - if (err) - goto out; } else { /* Read from disk. */ err =3D mi_get(sbi, rno, &mi); + if (err && op =3D=3D InitializeFileRecordSegment) { + mi =3D kzalloc(sizeof(struct mft_inode), + GFP_NOFS); + if (!mi) + return -ENOMEM; + err =3D mi_format_new(mi, sbi, rno, 0, false); + } if (err) return err; } @@ -3109,15 +3109,13 @@ static int do_action(struct ntfs_log *log, struct O= PEN_ATTR_ENRTY *oe, if (op =3D=3D DeallocateFileRecordSegment) goto skip_load_parent; =20 - if (InitializeFileRecordSegment !=3D op) { - if (rec->rhdr.sign =3D=3D NTFS_BAAD_SIGNATURE) - goto dirty_vol; - if (!check_lsn(&rec->rhdr, rlsn)) - goto out; - if (!check_file_record(rec, NULL, sbi)) - goto dirty_vol; - attr =3D Add2Ptr(rec, roff); - } + if (rec->rhdr.sign =3D=3D NTFS_BAAD_SIGNATURE) + goto dirty_vol; + if (!check_lsn(&rec->rhdr, rlsn)) + goto out; + if (!check_file_record(rec, NULL, sbi)) + goto dirty_vol; + attr =3D Add2Ptr(rec, roff); =20 if (is_rec_base(rec) || InitializeFileRecordSegment =3D=3D op) { rno_base =3D rno; --=20 2.43.0