From nobody Mon Feb 9 09:09:03 2026 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 26D1EEDC; Wed, 17 Apr 2024 13:08:10 +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=1713359293; cv=none; b=nWcdrdkeBgn1XIzt86i0+WHjjzKv8KRpOylO6yA0QkxdXSxt1Gj9+jnHmSPkdBB0l9hJOfSA6UJ+9IMFJFn9vC5vsg3KQyG4ae1G1zqAYfinr6Q/rwam9JGncBn6CHpGxFX/GV9tcwnQf/pHijWnNFC1vKLslsqqyUd3Q3yK/14= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713359293; c=relaxed/simple; bh=zB4pDB+1MwPVDU5eslMh2SAruBxdLfRVPm21RrqBJOk=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=VOi9wwHYYbTm+bby6glEE//tOM60y0NHXsggJpbMMKeyCDmksXTvmxgLMAGPsF2Q6PM5IQvLuug23U36BweciRSqGUeUr0vr6hxLsgZPIyDLD8RydIaz+vllX9wKrvSfJRRObAsdnwxmxHArmMgIvceljT3zoR9BVXo6nt6csGc= 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=ZSxgI9cI; 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="ZSxgI9cI" Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 5F0522126; Wed, 17 Apr 2024 13:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1713358839; bh=faaEBEoPf/qjweIscSis0xJmfoKEHMCDLYFkHEvEXk4=; h=Date:Subject:From:To:References:In-Reply-To; b=ZSxgI9cIaMLzufguDdMhDaTI3J8+HnDoz4+5IjcR3oUp9M5HhLKFny1SPVrrgY70A oSVN3Y35fsiaKKwq0I5inOGCPBuwWF8M5dpypn05UDn0Kyz006FzeeaV9ONqdU2jdp AMEJOf/gkEJEBdF+DsuvEGpGetrLxfKsuXZj8gm8= Received: from [192.168.211.39] (192.168.211.39) 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; Wed, 17 Apr 2024 16:08:08 +0300 Message-ID: Date: Wed, 17 Apr 2024 16:08:07 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 08/11] fs/ntfs3: Always make file nonresident if fallocate (xfstest 438) From: Konstantin Komarov To: , LKML , Linux-fsdevel References: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Language: en-US In-Reply-To: <6c99c1bd-448d-4301-8404-50df34e8df8e@paragon-software.com> Content-Type: text/plain; charset="utf-8"; format="flowed" 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) Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/attrib.c=C2=A0 | 32 ++++++++++++++++++++++++++++++++ =C2=A0fs/ntfs3/file.c=C2=A0=C2=A0=C2=A0 |=C2=A0 9 +++++++++ =C2=A0fs/ntfs3/ntfs_fs.h |=C2=A0 1 + =C2=A03 files changed, 42 insertions(+) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 7aadf5010999..aedae36b91d0 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -2558,3 +2558,35 @@ int attr_insert_range(struct ntfs_inode *ni, u64=20 vbo, u64 bytes) =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0} + +/* + * attr_force_nonresident + * + * Convert default data attribute into non resident form. + */ +int attr_force_nonresident(struct ntfs_inode *ni) +{ +=C2=A0=C2=A0 =C2=A0int err; +=C2=A0=C2=A0 =C2=A0struct ATTRIB *attr; +=C2=A0=C2=A0 =C2=A0struct ATTR_LIST_ENTRY *le =3D NULL; +=C2=A0=C2=A0 =C2=A0struct mft_inode *mi; + +=C2=A0=C2=A0 =C2=A0attr =3D ni_find_attr(ni, NULL, &le, ATTR_DATA, NULL, 0= , NULL, &mi); +=C2=A0=C2=A0 =C2=A0if (!attr) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_bad_inode(&ni->vfs_inode, "no d= ata attribute"); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -ENOENT; +=C2=A0=C2=A0 =C2=A0} + +=C2=A0=C2=A0 =C2=A0if (attr->non_res) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Already non resident. */ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return 0; +=C2=A0=C2=A0 =C2=A0} + +=C2=A0=C2=A0 =C2=A0down_write(&ni->file.run_lock); +=C2=A0=C2=A0 =C2=A0err =3D attr_make_nonresident(ni, attr, le, mi, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0 le32_to_cpu(attr->res.data_size), +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0 &ni->file.run, &attr, NULL); +=C2=A0=C2=A0 =C2=A0up_write(&ni->file.run_lock); + +=C2=A0=C2=A0 =C2=A0return err; +} \ No newline at end of file diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index 5418662c80d8..fce8ea098d60 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -578,6 +578,15 @@ static long ntfs_fallocate(struct file *file, int=20 mode, loff_t vbo, loff_t len) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Check new size. */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u8 cluster_bits =3D sbi->clust= er_bits; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Be sure file is non resident. */ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (is_resident(ni)) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni_lock(ni); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D attr_forc= e_nonresident(ni); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni_unlock(ni); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (err) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0goto out; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} + =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* generic/213: expected -ENOS= PC instead of -EFBIG. */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!is_supported_holes) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0loff_t to_a= lloc =3D new_size - inode_get_bytes(inode); diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 3db6a61f61dc..00dec0ec5648 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -452,6 +452,7 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST=20 frame, size_t compr_size, =C2=A0int attr_collapse_range(struct ntfs_inode *ni, u64 vbo, u64 bytes); =C2=A0int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes); =C2=A0int attr_punch_hole(struct ntfs_inode *ni, u64 vbo, u64 bytes, u32=20 *frame_size); +int attr_force_nonresident(struct ntfs_inode *ni); =C2=A0/* Functions from attrlist.c */ =C2=A0void al_destroy(struct ntfs_inode *ni); --=20 2.34.1