From nobody Mon Feb 9 07:23:18 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A12D9EB64DD for ; Mon, 3 Jul 2023 07:26:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230440AbjGCH0z (ORCPT ); Mon, 3 Jul 2023 03:26:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230375AbjGCH0t (ORCPT ); Mon, 3 Jul 2023 03:26:49 -0400 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 756C9E7A; Mon, 3 Jul 2023 00:26:39 -0700 (PDT) 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 134861D74; Mon, 3 Jul 2023 07:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1688368886; bh=vlNC3aqT1PLyINaRjLgT5dt7keaunUkuSQDjNJ9mzS8=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=qF1ERGbXVCfRF81fRmeXF7le5tiNB5aw8lYBUUKRh7sxSiHitGOZ5U92gH6LVSV5N 7vVl257xtBbRv6qSnyHU5ND//ac6PFjXjLL1R3aWqyRXR8tpBn2J7V6FymwnVeVryC jlSEGvv5l4ExEpdPCuQwNhGcX53Q3gsA9XFZX2eI= Received: from [192.168.211.138] (192.168.211.138) 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, 3 Jul 2023 10:26:37 +0300 Message-ID: <890222ac-1bd2-6817-7873-390801c5a172@paragon-software.com> Date: Mon, 3 Jul 2023 11:26:36 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: [PATCH 5/8] fs/ntfs3: Use kvmalloc instead of kmalloc(... __GFP_NOWARN) Content-Language: en-US From: Konstantin Komarov To: CC: Linux Kernel Mailing List , References: In-Reply-To: Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [192.168.211.138] X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/attrlist.c | 15 +++++++++++++-- =C2=A0fs/ntfs3/bitmap.c=C2=A0=C2=A0 |=C2=A0 3 ++- =C2=A0fs/ntfs3/super.c=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +- =C2=A03 files changed, 16 insertions(+), 4 deletions(-) diff --git a/fs/ntfs3/attrlist.c b/fs/ntfs3/attrlist.c index 42631b31adf1..7c01735d1219 100644 --- a/fs/ntfs3/attrlist.c +++ b/fs/ntfs3/attrlist.c @@ -52,7 +52,8 @@ int ntfs_load_attr_list(struct ntfs_inode *ni, struct=20 ATTRIB *attr) =C2=A0=C2=A0=C2=A0 =C2=A0if (!attr->non_res) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0lsize =3D le32_to_cpu(attr->re= s.data_size); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0le =3D kmalloc(al_aligned(lsize), GF= P_NOFS | __GFP_NOWARN); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* attr is resident: lsize < record_= size (1K or 4K) */ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0le =3D kvmalloc(al_aligned(lsize), G= FP_KERNEL); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!le) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EN= OMEM; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; @@ -80,7 +81,17 @@ int ntfs_load_attr_list(struct ntfs_inode *ni, struct=20 ATTRIB *attr) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (err < 0) =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=A0le =3D kmalloc(al_aligned(lsize), GF= P_NOFS | __GFP_NOWARN); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* attr is nonresident. +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 * The worst case: +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 * 1T (2^40) extremely fragmented fi= le. +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 * cluster =3D 4K (2^12) =3D> 2^28 f= ragments +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 * 2^9 fragments per one record =3D>= 2^19 records +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 * 2^5 bytes of ATTR_LIST_ENTRY per = one record =3D> 2^24 bytes. +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 * +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 * the result is 16M bytes per attri= bute list. +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 * Use kvmalloc to allocate in range= [several Kbytes - dozen=20 Mbytes] +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 */ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0le =3D kvmalloc(al_aligned(lsize), G= FP_KERNEL); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!le) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EN= OMEM; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; diff --git a/fs/ntfs3/bitmap.c b/fs/ntfs3/bitmap.c index 107e808e06ea..d66055e30aff 100644 --- a/fs/ntfs3/bitmap.c +++ b/fs/ntfs3/bitmap.c @@ -659,7 +659,8 @@ int wnd_init(struct wnd_bitmap *wnd, struct=20 super_block *sb, size_t nbits) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0wnd->bits_last =3D wbits; =C2=A0=C2=A0=C2=A0 =C2=A0wnd->free_bits =3D -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0kcalloc(wnd->nwnd, sizeof(u16), GFP_= NOFS | __GFP_NOWARN); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0kvmalloc_array(wnd->nwnd, sizeof(u16= ), GFP_KERNEL | __GFP_ZERO); + =C2=A0=C2=A0=C2=A0 =C2=A0if (!wnd->free_bits) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -ENOMEM; diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index da739e509269..0034952b9ccd 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -1373,7 +1373,7 @@ static int ntfs_fill_super(struct super_block *sb,=20 struct fs_context *fc) =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0bytes =3D inode->i_size; -=C2=A0=C2=A0 =C2=A0sbi->def_table =3D t =3D kmalloc(bytes, GFP_NOFS | __GF= P_NOWARN); +=C2=A0=C2=A0 =C2=A0sbi->def_table =3D t =3D kvmalloc(bytes, GFP_KERNEL); =C2=A0=C2=A0=C2=A0 =C2=A0if (!t) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -ENOMEM; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto put_inode_out; --=20 2.34.1