From nobody Thu Sep 11 22:17:26 2025 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 D0743C636D4 for ; Wed, 15 Feb 2023 13:41:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229919AbjBONlS (ORCPT ); Wed, 15 Feb 2023 08:41:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbjBONlM (ORCPT ); Wed, 15 Feb 2023 08:41:12 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42B4B392B4; Wed, 15 Feb 2023 05:41:09 -0800 (PST) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 93C162120; Wed, 15 Feb 2023 13:30:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676467804; bh=ERksTfD1/XuhpX5Xy+AmdTxEr0QconrM00RyDm/UdXY=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=g1u1V3iNHInPiICLDPOXbO+m0D/AjSraShkh5o+Gdxcb5hXxGKb1W5vFsOyEzfZ63 idhN4dsDVU1iRW8pwpS4vKgsltLnpXdE2yZ/HPC6oqlNewjdozg0ytl0XXgGIaRtit UvoDHMb5JT/NYn5rIBwytEXTZGVgUPDby8exVw+g= 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 DBFA11E70; Wed, 15 Feb 2023 13:34:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676468054; bh=ERksTfD1/XuhpX5Xy+AmdTxEr0QconrM00RyDm/UdXY=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=AsdxIAg+F0mmU8xLtS285CIFiOgbi3Nq0/LFvbkT5/t6Sy4eQqmwp5I2wwqNCnBZm SYlMbIl9H+ZO9k382nRanwhucO7DIZKhyoSGndWseJweTTlazsCD+695oMhADOFMR0 35UyY0KUgxcWRkGL+zb9MBIpskCfEICBkHKzwQVc= Received: from [192.168.211.36] (192.168.211.36) 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, 15 Feb 2023 16:34:14 +0300 Message-ID: <878105e3-d075-4d4e-5c47-3f22f95e23c8@paragon-software.com> Date: Wed, 15 Feb 2023 17:34:13 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: [PATCH 01/11] fs/ntfs3: Use bh_read to simplify code 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.36] 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 The duplicating code is replaced by a generic function bh_read() Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/file.c=C2=A0 | 10 ++-------- =C2=A0fs/ntfs3/inode.c |=C2=A0 1 + =C2=A02 files changed, 3 insertions(+), 8 deletions(-) diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index d294cd975688..d37df7376543 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -223,16 +223,10 @@ static int ntfs_zero_range(struct inode *inode,=20 u64 vbo, u64 vbo_to) =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 set_buffer_uptodate(bh); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (!buffer= _uptodate(bh)) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 lock_buffer(bh); -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 bh->b_end_io =3D end_buffer_read_sync; -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 get_bh(bh); -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 submit_bh(REQ_OP_READ, bh); - -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 wait_on_buffer(bh); -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 if (!buffer_uptodate(bh)) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 err =3D bh_read(bh, 0); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 if (err < 0) { =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=C2=A0 unlock_page(page); =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=C2=A0 put_page(page); -=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 err =3D -EIO; =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=C2=A0 goto 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 } =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 } diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index e80e94325467..5e06299591ed 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -648,6 +648,7 @@ static noinline int ntfs_get_block_vbo(struct inode=20 *inode, u64 vbo, =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 bh->b_size = =3D block_size; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 off =3D vbo= & (PAGE_SIZE - 1); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 set_bh_page= (bh, page, off); + =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D bh_= read(bh, 0); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (err < 0) =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 goto out; --=20 2.34.1 From nobody Thu Sep 11 22:17:26 2025 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 A8A0BC636D4 for ; Wed, 15 Feb 2023 13:35:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229516AbjBONfF (ORCPT ); Wed, 15 Feb 2023 08:35:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231687AbjBONe6 (ORCPT ); Wed, 15 Feb 2023 08:34:58 -0500 X-Greylist: delayed 85 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 15 Feb 2023 05:34:56 PST Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A06B23A92; Wed, 15 Feb 2023 05:34:56 -0800 (PST) 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 565C72147; Wed, 15 Feb 2023 13:30:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676467844; bh=cRbFAcsOeNInjJ/7aNI+flXOVb7jAlQp1y5wkLFBBeE=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=SM6lEK6RBNg0roCsqmraz/E86Mlrmp5zFPFxVPk0W/vslDtU9jZTljAGe7xmvMu+5 v1G2ot0abrwTUAkmqgKxwJFZ/H1/WR0aoseMoZ5BaG9ihYD3xc6ZTJHmVmadoXf2yf 7PEKU5DxGSPdCOEUuuyZ2jkUn4eeuqi7e4njZBeA= Received: from [192.168.211.36] (192.168.211.36) 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, 15 Feb 2023 16:34:54 +0300 Message-ID: <331371f5-6c34-65aa-f81e-c27e428b9d4e@paragon-software.com> Date: Wed, 15 Feb 2023 17:34:53 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: [PATCH 02/11] fs/ntfs3: Remove noacsrules 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.36] 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 Currently, this option does not work properly. Its use leads to unstable=20 results. If we figure out how to implement it without errors, we will add it later. Signed-off-by: Konstantin Komarov --- =C2=A0Documentation/filesystems/ntfs3.rst | 11 ----------- =C2=A0fs/ntfs3/file.c=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=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 11 = ----------- =C2=A0fs/ntfs3/inode.c=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=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 1 - =C2=A0fs/ntfs3/namei.c=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=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 1 - =C2=A0fs/ntfs3/ntfs_fs.h=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=C2=A0=C2=A0 |=C2=A0 3 --- =C2=A0fs/ntfs3/super.c=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=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 9 += -------- =C2=A0fs/ntfs3/xattr.c=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=C2=A0=C2=A0=C2=A0=C2=A0 | 14 ------= -------- =C2=A07 files changed, 1 insertion(+), 49 deletions(-) diff --git a/Documentation/filesystems/ntfs3.rst=20 b/Documentation/filesystems/ntfs3.rst index 5aa102bd72c2..f0cf05cad2ba 100644 --- a/Documentation/filesystems/ntfs3.rst +++ b/Documentation/filesystems/ntfs3.rst @@ -61,17 +61,6 @@ this table marked with no it means default is without=20 **no**. =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 directories, fmask applies only= to files and dmask only to=20 directories. =C2=A0=C2=A0=C2=A0 * - fmask=3D -=C2=A0=C2=A0 * - noacsrules -=C2=A0=C2=A0=C2=A0=C2=A0 - "No access rules" mount option sets access righ= ts for=20 files/folders to -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 777 and owner/group to root. This mou= nt option absorbs all other -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 permissions. - -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 - Permissions change for files/folder= s will be reported as=20 successful, -=C2=A0=C2=A0=C2=A0 =C2=A0but they will remain 777. - -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 - Owner/group change will be reported= as successful, butthey=20 will stay -=C2=A0=C2=A0=C2=A0 =C2=A0as root. - =C2=A0=C2=A0=C2=A0 * - nohidden =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 - Files with the Windows-specific HIDDEN (F= ILE_ATTRIBUTE_HIDDEN)=20 attribute =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 will not be shown under Linux. diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index d37df7376543..9cef189fc0c5 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -654,22 +654,12 @@ static long ntfs_fallocate(struct file *file, int=20 mode, loff_t vbo, loff_t len) =C2=A0int ntfs3_setattr(struct user_namespace *mnt_userns, struct dentry=20 *dentry, =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 struct iattr *attr) =C2=A0{ -=C2=A0=C2=A0=C2=A0 struct super_block *sb =3D dentry->d_sb; -=C2=A0=C2=A0=C2=A0 struct ntfs_sb_info *sbi =3D sb->s_fs_info; =C2=A0=C2=A0=C2=A0=C2=A0 struct inode *inode =3D d_inode(dentry); =C2=A0=C2=A0=C2=A0=C2=A0 struct ntfs_inode *ni =3D ntfs_i(inode); =C2=A0=C2=A0=C2=A0=C2=A0 u32 ia_valid =3D attr->ia_valid; =C2=A0=C2=A0=C2=A0=C2=A0 umode_t mode =3D inode->i_mode; =C2=A0=C2=A0=C2=A0=C2=A0 int err; -=C2=A0=C2=A0=C2=A0 if (sbi->options->noacsrules) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 /* "No access rules" - Force any cha= nges of time etc. */ -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 attr->ia_valid |=3D ATTR_FORCE; -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 /* and disable for editing some attr= ibutes. */ -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 attr->ia_valid &=3D ~(ATTR_UID | ATT= R_GID | ATTR_MODE); -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ia_valid =3D attr->ia_valid; -=C2=A0=C2=A0=C2=A0 } - =C2=A0=C2=A0=C2=A0=C2=A0 err =3D setattr_prepare(mnt_userns, dentry, attr); =C2=A0=C2=A0=C2=A0=C2=A0 if (err) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; @@ -1153,7 +1143,6 @@ const struct inode_operations=20 ntfs_file_inode_operations =3D { =C2=A0=C2=A0=C2=A0=C2=A0 .getattr=C2=A0=C2=A0=C2=A0 =3D ntfs_getattr, =C2=A0=C2=A0=C2=A0=C2=A0 .setattr=C2=A0=C2=A0=C2=A0 =3D ntfs3_setattr, =C2=A0=C2=A0=C2=A0=C2=A0 .listxattr=C2=A0=C2=A0=C2=A0 =3D ntfs_listxattr, -=C2=A0=C2=A0=C2=A0 .permission=C2=A0=C2=A0=C2=A0 =3D ntfs_permission, =C2=A0=C2=A0=C2=A0=C2=A0 .get_inode_acl=C2=A0=C2=A0=C2=A0 =3D ntfs_get_acl, =C2=A0=C2=A0=C2=A0=C2=A0 .set_acl=C2=A0=C2=A0=C2=A0 =3D ntfs_set_acl, =C2=A0=C2=A0=C2=A0=C2=A0 .fiemap=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =3D = ntfs_fiemap, diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 5e06299591ed..51e342ad79fd 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -2070,7 +2070,6 @@ const struct inode_operations=20 ntfs_link_inode_operations =3D { =C2=A0=C2=A0=C2=A0=C2=A0 .get_link=C2=A0=C2=A0=C2=A0 =3D ntfs_get_link, =C2=A0=C2=A0=C2=A0=C2=A0 .setattr=C2=A0=C2=A0=C2=A0 =3D ntfs3_setattr, =C2=A0=C2=A0=C2=A0=C2=A0 .listxattr=C2=A0=C2=A0=C2=A0 =3D ntfs_listxattr, -=C2=A0=C2=A0=C2=A0 .permission=C2=A0=C2=A0=C2=A0 =3D ntfs_permission, =C2=A0}; =C2=A0const struct address_space_operations ntfs_aops =3D { diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c index 53ddea219e37..5d5fe2f1f77c 100644 --- a/fs/ntfs3/namei.c +++ b/fs/ntfs3/namei.c @@ -607,7 +607,6 @@ const struct inode_operations=20 ntfs_dir_inode_operations =3D { =C2=A0=C2=A0=C2=A0=C2=A0 .rmdir=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =3D n= tfs_rmdir, =C2=A0=C2=A0=C2=A0=C2=A0 .mknod=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =3D n= tfs_mknod, =C2=A0=C2=A0=C2=A0=C2=A0 .rename=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =3D = ntfs_rename, -=C2=A0=C2=A0=C2=A0 .permission=C2=A0=C2=A0=C2=A0 =3D ntfs_permission, =C2=A0=C2=A0=C2=A0=C2=A0 .get_inode_acl=C2=A0=C2=A0=C2=A0 =3D ntfs_get_acl, =C2=A0=C2=A0=C2=A0=C2=A0 .set_acl=C2=A0=C2=A0=C2=A0 =3D ntfs_set_acl, =C2=A0=C2=A0=C2=A0=C2=A0 .setattr=C2=A0=C2=A0=C2=A0 =3D ntfs3_setattr, diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 2050eb3f6a5a..556b76f526cb 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -100,7 +100,6 @@ struct ntfs_mount_options { =C2=A0=C2=A0=C2=A0=C2=A0 unsigned hide_dot_files : 1; /* Set hidden flag o= n dot files. */ =C2=A0=C2=A0=C2=A0=C2=A0 unsigned windows_names : 1; /* Disallow names for= bidden by Windows. */ =C2=A0=C2=A0=C2=A0=C2=A0 unsigned force : 1; /* RW mount dirty volume. */ -=C2=A0=C2=A0=C2=A0 unsigned noacsrules : 1; /* Exclude acs rules. */ =C2=A0=C2=A0=C2=A0=C2=A0 unsigned prealloc : 1; /* Preallocate space when = file is growing. */ =C2=A0=C2=A0=C2=A0=C2=A0 unsigned nocase : 1; /* case insensitive. */ =C2=A0}; @@ -868,8 +867,6 @@ int ntfs_init_acl(struct user_namespace *mnt_userns,=20 struct inode *inode, =C2=A0#endif =C2=A0int ntfs_acl_chmod(struct user_namespace *mnt_userns, struct dentry=20 *dentry); -int ntfs_permission(struct user_namespace *mnt_userns, struct inode *inode, -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 int mask); =C2=A0ssize_t ntfs_listxattr(struct dentry *dentry, char *buffer, size_t s= ize); =C2=A0extern const struct xattr_handler *ntfs_xattr_handlers[]; diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 19d0889b131f..10c019ef7da3 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -253,7 +253,6 @@ enum Opt { =C2=A0=C2=A0=C2=A0=C2=A0 Opt_acl, =C2=A0=C2=A0=C2=A0=C2=A0 Opt_iocharset, =C2=A0=C2=A0=C2=A0=C2=A0 Opt_prealloc, -=C2=A0=C2=A0=C2=A0 Opt_noacsrules, =C2=A0=C2=A0=C2=A0=C2=A0 Opt_nocase, =C2=A0=C2=A0=C2=A0=C2=A0 Opt_err, =C2=A0}; @@ -274,7 +273,6 @@ static const struct fs_parameter_spec=20 ntfs_fs_parameters[] =3D { =C2=A0=C2=A0=C2=A0=C2=A0 fsparam_flag_no("acl",=C2=A0=C2=A0=C2=A0 =C2=A0= =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 Opt_acl), =C2=A0=C2=A0=C2=A0=C2=A0 fsparam_flag_no("showmeta",=C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 Opt_showmeta), =C2=A0=C2=A0=C2=A0=C2=A0 fsparam_flag_no("prealloc",=C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 Opt_prealloc), -=C2=A0=C2=A0=C2=A0 fsparam_flag_no("acsrules",=C2=A0=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 Opt_noacsrules), =C2=A0=C2=A0=C2=A0=C2=A0 fsparam_flag_no("nocase",=C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 Opt_nocase), =C2=A0=C2=A0=C2=A0=C2=A0 fsparam_string("iocharset",=C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 Opt_iocharset), =C2=A0=C2=A0=C2=A0=C2=A0 {} @@ -387,9 +385,6 @@ static int ntfs_fs_parse_param(struct fs_context *fc, =C2=A0=C2=A0=C2=A0=C2=A0 case Opt_prealloc: =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 opts->prealloc =3D result.nega= ted ? 0 : 1; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 break; -=C2=A0=C2=A0=C2=A0 case Opt_noacsrules: -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 opts->noacsrules =3D result.negated = ? 1 : 0; -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 break; =C2=A0=C2=A0=C2=A0=C2=A0 case Opt_nocase: =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 opts->nocase =3D result.negate= d ? 1 : 0; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 break; @@ -572,8 +567,6 @@ static int ntfs_show_options(struct seq_file *m,=20 struct dentry *root) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 seq_puts(m, ",hide_dot_files"); =C2=A0=C2=A0=C2=A0=C2=A0 if (opts->force) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 seq_puts(m, ",force"); -=C2=A0=C2=A0=C2=A0 if (opts->noacsrules) -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 seq_puts(m, ",noacsrules"); =C2=A0=C2=A0=C2=A0=C2=A0 if (opts->prealloc) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 seq_puts(m, ",prealloc"); =C2=A0=C2=A0=C2=A0=C2=A0 if (sb->s_flags & SB_POSIXACL) @@ -791,7 +784,7 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0=C2=A0 if (boot_sector_size !=3D sector_size) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_warn( =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 sb, -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 "Different NTFS' = sector size (%u) and media sector size (%u)", +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 "Different NTFS s= ector size (%u) and media sector size (%u)", =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 boot_sector= _size, sector_size); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 dev_size +=3D sector_size - 1; =C2=A0=C2=A0=C2=A0=C2=A0 } diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index 3fa48c8f68d9..c42fbc56eb39 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -711,20 +711,6 @@ int ntfs_acl_chmod(struct user_namespace=20 *mnt_userns, struct dentry *dentry) =C2=A0=C2=A0=C2=A0=C2=A0 return posix_acl_chmod(mnt_userns, dentry, inode-= >i_mode); =C2=A0} -/* - * ntfs_permission - inode_operations::permission - */ -int ntfs_permission(struct user_namespace *mnt_userns, struct inode *inode, -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 int mask) -{ -=C2=A0=C2=A0=C2=A0 if (ntfs_sb(inode->i_sb)->options->noacsrules) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 /* "No access rules" mode - Allow al= l changes. */ -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return 0; -=C2=A0=C2=A0=C2=A0 } - -=C2=A0=C2=A0=C2=A0 return generic_permission(mnt_userns, inode, mask); -} - =C2=A0/* =C2=A0 * ntfs_listxattr - inode_operations::listxattr =C2=A0 */ --=20 2.34.1 From nobody Thu Sep 11 22:17:26 2025 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 35A6CC6379F for ; Wed, 15 Feb 2023 13:35:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229627AbjBONfr (ORCPT ); Wed, 15 Feb 2023 08:35:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbjBONfp (ORCPT ); Wed, 15 Feb 2023 08:35:45 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3343C358D; Wed, 15 Feb 2023 05:35:41 -0800 (PST) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id E50212147; Wed, 15 Feb 2023 13:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676467889; bh=9YwbKHsq6zCe7UxAvvfw0U9eC4NOBc0GrYuoyaOiRsg=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=DCV2Dvw82s3o6RFPyqyYN0Tnm6u8pD6i3IJSiPZUUIXT3hcm7S3DQEb9Y1bzjjcdz LCThTW9xJt3J468JQtSS21GJ/DKuAXcBOajsvy3AOPGr7R26wX/Jihnc3ykI3Dk2O2 99JLC3TidCsoz1mdujuofcMB4u0gn/FUe5KzlJzQ= 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 4284E1E70; Wed, 15 Feb 2023 13:35:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676468139; bh=9YwbKHsq6zCe7UxAvvfw0U9eC4NOBc0GrYuoyaOiRsg=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=A5o+lDtsQrQ0900S8R3zH3VMIsH9utchJww8A5uyU3NI92M6w0w1nnJpraji5665l +Z8SdrIKWlLBh3fU5Zha0/t3ltjjYuvPyNEaExoUgGanC+ybbCMD1xiIclZaxeAvgR 6GfjVL/y9spCDnHctON3r7vcp9dfCP6QY6jN3GvU= Received: from [192.168.211.36] (192.168.211.36) 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, 15 Feb 2023 16:35:38 +0300 Message-ID: Date: Wed, 15 Feb 2023 17:35:37 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: [PATCH 03/11] fs/ntfs3: Fix ntfs_create_inode() 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.36] 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 Previous variant creates an inode that requires update the parent directory (ea_packed_size). Operations in ntfs_create_inode have been rearranged so we insert new directory entry with correct ea_packed_size and new created inode does not require update it's parent directory. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/file.c=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +- =C2=A0fs/ntfs3/inode.c=C2=A0=C2=A0 | 83 ++++++++++++++++++++++++----------= ------------ =C2=A0fs/ntfs3/ntfs_fs.h |=C2=A0 2 +- =C2=A0fs/ntfs3/xattr.c=C2=A0=C2=A0 | 20 ++++++----- =C2=A04 files changed, 58 insertions(+), 49 deletions(-) diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index 9cef189fc0c5..df7b76d1c127 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -703,7 +703,7 @@ int ntfs3_setattr(struct user_namespace *mnt_userns,=20 struct dentry *dentry, =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 if (ia_valid & (ATTR_UID | ATTR_GID | ATTR_MODE)) -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_save_wsl_perm(inode); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_save_wsl_perm(inode, NULL); =C2=A0=C2=A0=C2=A0=C2=A0 mark_inode_dirty(inode); =C2=A0out: =C2=A0=C2=A0=C2=A0=C2=A0 return err; diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 51e342ad79fd..752ad17685c0 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -1320,8 +1320,7 @@ struct inode *ntfs_create_inode(struct=20 user_namespace *mnt_userns, =C2=A0=C2=A0=C2=A0=C2=A0 inode_init_owner(mnt_userns, inode, dir, mode); =C2=A0=C2=A0=C2=A0=C2=A0 mode =3D inode->i_mode; -=C2=A0=C2=A0=C2=A0 inode->i_atime =3D inode->i_mtime =3D inode->i_ctime = =3D ni->i_crtime =3D -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 current_time(inode); +=C2=A0=C2=A0=C2=A0 ni->i_crtime =3D current_time(inode); =C2=A0=C2=A0=C2=A0=C2=A0 rec =3D ni->mi.mrec; =C2=A0=C2=A0=C2=A0=C2=A0 rec->hard_links =3D cpu_to_le16(1); @@ -1362,10 +1361,9 @@ struct inode *ntfs_create_inode(struct=20 user_namespace *mnt_userns, =C2=A0=C2=A0=C2=A0=C2=A0 attr->res.data_size =3D cpu_to_le32(dsize); =C2=A0=C2=A0=C2=A0=C2=A0 std5->cr_time =3D std5->m_time =3D std5->c_time = =3D std5->a_time =3D -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 kernel2nt(&inode->i_atime); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 kernel2nt(&ni->i_crtime); -=C2=A0=C2=A0=C2=A0 ni->std_fa =3D fa; -=C2=A0=C2=A0=C2=A0 std5->fa =3D fa; +=C2=A0=C2=A0=C2=A0 std5->fa =3D ni->std_fa =3D fa; =C2=A0=C2=A0=C2=A0=C2=A0 attr =3D Add2Ptr(attr, asize); @@ -1564,11 +1562,15 @@ struct inode *ntfs_create_inode(struct=20 user_namespace *mnt_userns, =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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 asize =3D S= IZEOF_NONRESIDENT + ALIGN(err, 8); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 /* Write non resi= dent data. */ +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D ntfs_sb_w= rite_run(sbi, &ni->file.run, 0, rp, +=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 =C2=A0=C2=A0=C2=A0 nsize, 0); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (err) +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 goto out5; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 } else { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 attr->res.d= ata_off =3D SIZEOF_RESIDENT_LE; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 attr->res.d= ata_size =3D cpu_to_le32(nsize); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 memcpy(Add2= Ptr(attr, SIZEOF_RESIDENT), rp, nsize); -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 nsize =3D 0; =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 /* Size of symlink equals the = length of input string. */ =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 inode->i_size =3D size; @@ -1589,19 +1591,8 @@ struct inode *ntfs_create_inode(struct=20 user_namespace *mnt_userns, =C2=A0=C2=A0=C2=A0=C2=A0 rec->used =3D cpu_to_le32(PtrOffset(rec, attr) + = 8); =C2=A0=C2=A0=C2=A0=C2=A0 rec->next_attr_id =3D cpu_to_le16(aid); -=C2=A0=C2=A0=C2=A0 /* Step 2: Add new name in index. */ -=C2=A0=C2=A0=C2=A0 err =3D indx_insert_entry(&dir_ni->dir, dir_ni, new_de,= sbi, fnd, 0); -=C2=A0=C2=A0=C2=A0 if (err) -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out6; - -=C2=A0=C2=A0=C2=A0 /* Unlock parent directory before ntfs_init_acl. */ -=C2=A0=C2=A0=C2=A0 if (!fnd) -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ni_unlock(dir_ni); - =C2=A0=C2=A0=C2=A0=C2=A0 inode->i_generation =3D le16_to_cpu(rec->seq); -=C2=A0=C2=A0=C2=A0 dir->i_mtime =3D dir->i_ctime =3D inode->i_atime; - =C2=A0=C2=A0=C2=A0=C2=A0 if (S_ISDIR(mode)) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 inode->i_op =3D &ntfs_dir_inod= e_operations; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 inode->i_fop =3D &ntfs_dir_ope= rations; @@ -1626,41 +1617,58 @@ struct inode *ntfs_create_inode(struct=20 user_namespace *mnt_userns, =C2=A0=C2=A0=C2=A0=C2=A0 if (!S_ISLNK(mode) && (sb->s_flags & SB_POSIXACL)= ) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D ntfs_init_acl(mnt_user= ns, inode, dir); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (err) -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out7; +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out5; =C2=A0=C2=A0=C2=A0=C2=A0 } else =C2=A0#endif =C2=A0=C2=A0=C2=A0=C2=A0 { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 inode->i_flags |=3D S_NOSEC; =C2=A0=C2=A0=C2=A0=C2=A0 } -=C2=A0=C2=A0=C2=A0 /* Write non resident data. */ -=C2=A0=C2=A0=C2=A0 if (nsize) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D ntfs_sb_write_run(sbi, &ni->= file.run, 0, rp, nsize, 0); -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (err) -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out7; +=C2=A0=C2=A0=C2=A0 /* +=C2=A0=C2=A0=C2=A0 =C2=A0* ntfs_init_acl and ntfs_save_wsl_perm update ext= ended attribute. +=C2=A0=C2=A0=C2=A0 =C2=A0* The packed size of extended attribute is stored= in direntry too. +=C2=A0=C2=A0=C2=A0 =C2=A0* 'fname' here points to inside new_de. +=C2=A0=C2=A0=C2=A0 =C2=A0*/ +=C2=A0=C2=A0=C2=A0 ntfs_save_wsl_perm(inode, &fname->dup.ea_size); + +=C2=A0=C2=A0=C2=A0 /* +=C2=A0=C2=A0=C2=A0 =C2=A0* update ea_size in file_name attribute too. +=C2=A0=C2=A0=C2=A0 =C2=A0* Use ni_find_attr cause layout of MFT record may= be changed +=C2=A0=C2=A0=C2=A0 =C2=A0* in ntfs_init_acl and ntfs_save_wsl_perm. +=C2=A0=C2=A0=C2=A0 =C2=A0*/ +=C2=A0=C2=A0=C2=A0 attr =3D ni_find_attr(ni, NULL, NULL, ATTR_NAME, NULL, = 0, NULL, NULL); +=C2=A0=C2=A0=C2=A0 if (attr) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 struct ATTR_FILE_NAME *fn; + +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 fn =3D resident_data_ex(attr, SIZEOF= _ATTRIBUTE_FILENAME); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (fn) +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 fn->dup.ea_size = =3D fname->dup.ea_size; =C2=A0=C2=A0=C2=A0=C2=A0 } +=C2=A0=C2=A0=C2=A0 /* We do not need to update parent directory later */ +=C2=A0=C2=A0=C2=A0 ni->ni_flags &=3D ~NI_FLAG_UPDATE_PARENT; + +=C2=A0=C2=A0=C2=A0 /* Step 2: Add new name in index. */ +=C2=A0=C2=A0=C2=A0 err =3D indx_insert_entry(&dir_ni->dir, dir_ni, new_de,= sbi, fnd, 0); +=C2=A0=C2=A0=C2=A0 if (err) +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out6; + =C2=A0=C2=A0=C2=A0=C2=A0 /* =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0* Call 'd_instantiate' after inode->i_op is= set =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0* but before finish_open. =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0*/ =C2=A0=C2=A0=C2=A0=C2=A0 d_instantiate(dentry, inode); -=C2=A0=C2=A0=C2=A0 ntfs_save_wsl_perm(inode); +=C2=A0=C2=A0=C2=A0 /* Set original time. inode times (i_ctime) may be chan= ged in=20 ntfs_init_acl. */ +=C2=A0=C2=A0=C2=A0 inode->i_atime =3D inode->i_mtime =3D inode->i_ctime = =3D dir->i_mtime =3D +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 dir->i_ctime =3D ni->i_crtime; + =C2=A0=C2=A0=C2=A0=C2=A0 mark_inode_dirty(dir); =C2=A0=C2=A0=C2=A0=C2=A0 mark_inode_dirty(inode); =C2=A0=C2=A0=C2=A0=C2=A0 /* Normal exit. */ =C2=A0=C2=A0=C2=A0=C2=A0 goto out2; -out7: - -=C2=A0=C2=A0=C2=A0 /* Undo 'indx_insert_entry'. */ -=C2=A0=C2=A0=C2=A0 if (!fnd) -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ni_lock_dir(dir_ni); -=C2=A0=C2=A0=C2=A0 indx_delete_entry(&dir_ni->dir, dir_ni, new_de + 1, -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 le16_to_cp= u(new_de->key_size), sbi); -=C2=A0=C2=A0=C2=A0 /* ni_unlock(dir_ni); will be called later. */ =C2=A0out6: =C2=A0=C2=A0=C2=A0=C2=A0 if (rp_inserted) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_remove_reparse(sbi, IO_RE= PARSE_TAG_SYMLINK, &new_de->ref); @@ -1682,11 +1690,11 @@ struct inode *ntfs_create_inode(struct=20 user_namespace *mnt_userns, =C2=A0=C2=A0=C2=A0=C2=A0 kfree(rp); =C2=A0out1: -=C2=A0=C2=A0=C2=A0 if (err) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (!fnd) -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ni_unlock(dir_ni); +=C2=A0=C2=A0=C2=A0 if (!fnd) +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ni_unlock(dir_ni); + +=C2=A0=C2=A0=C2=A0 if (err) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return ERR_PTR(err); -=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 unlock_new_inode(inode); @@ -1783,9 +1791,6 @@ void ntfs_evict_inode(struct inode *inode) =C2=A0{ =C2=A0=C2=A0=C2=A0=C2=A0 truncate_inode_pages_final(&inode->i_data); -=C2=A0=C2=A0=C2=A0 if (inode->i_nlink) -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 _ni_write_inode(inode, inode_needs_s= ync(inode)); - =C2=A0=C2=A0=C2=A0=C2=A0 invalidate_inode_buffers(inode); =C2=A0=C2=A0=C2=A0=C2=A0 clear_inode(inode); diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 556b76f526cb..73a639716b45 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -870,7 +870,7 @@ int ntfs_acl_chmod(struct user_namespace=20 *mnt_userns, struct dentry *dentry); =C2=A0ssize_t ntfs_listxattr(struct dentry *dentry, char *buffer, size_t s= ize); =C2=A0extern const struct xattr_handler *ntfs_xattr_handlers[]; -int ntfs_save_wsl_perm(struct inode *inode); +int ntfs_save_wsl_perm(struct inode *inode, __le16 *ea_size); =C2=A0void ntfs_get_wsl_perm(struct inode *inode); =C2=A0/* globals from lznt.c */ diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index c42fbc56eb39..e7a66225361d 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -296,7 +296,8 @@ static int ntfs_get_ea(struct inode *inode, const=20 char *name, size_t name_len, =C2=A0static noinline int ntfs_set_ea(struct inode *inode, const char *nam= e, =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 size_t name_len, const void *value, -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 size_t val_size, int flags, bool locked) +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 size_t val_size, int flags, bool locked, +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 __le16 *ea_size) =C2=A0{ =C2=A0=C2=A0=C2=A0=C2=A0 struct ntfs_inode *ni =3D ntfs_i(inode); =C2=A0=C2=A0=C2=A0=C2=A0 struct ntfs_sb_info *sbi =3D ni->mi.sbi; @@ -504,6 +505,8 @@ static noinline int ntfs_set_ea(struct inode *inode,=20 const char *name, =C2=A0=C2=A0=C2=A0=C2=A0 if (ea_info.size_pack !=3D size_pack) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ni->ni_flags |=3D NI_FLAG_UPDA= TE_PARENT; +=C2=A0=C2=A0=C2=A0 if (ea_size) +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 *ea_size =3D ea_info.size_pack; =C2=A0=C2=A0=C2=A0=C2=A0 mark_inode_dirty(&ni->vfs_inode); =C2=A0out: @@ -633,7 +636,7 @@ static noinline int ntfs_set_acl_ex(struct=20 user_namespace *mnt_userns, =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 flags =3D 0; =C2=A0=C2=A0=C2=A0=C2=A0 } -=C2=A0=C2=A0=C2=A0 err =3D ntfs_set_ea(inode, name, name_len, value, size,= flags, 0); +=C2=A0=C2=A0=C2=A0 err =3D ntfs_set_ea(inode, name, name_len, value, size,= flags, 0, NULL); =C2=A0=C2=A0=C2=A0=C2=A0 if (err =3D=3D -ENODATA && !size) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D 0; /* Removing non exi= sted xattr. */ =C2=A0=C2=A0=C2=A0=C2=A0 if (!err) { @@ -923,7 +926,8 @@ static noinline int ntfs_setxattr(const struct=20 xattr_handler *handler, =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 /* Deal with NTFS extended attribute. */ -=C2=A0=C2=A0=C2=A0 err =3D ntfs_set_ea(inode, name, strlen(name), value, s= ize, flags, 0); +=C2=A0=C2=A0=C2=A0 err =3D ntfs_set_ea(inode, name, strlen(name), value, s= ize, flags, 0, +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 NULL); =C2=A0out: =C2=A0=C2=A0=C2=A0=C2=A0 inode->i_ctime =3D current_time(inode); @@ -937,7 +941,7 @@ static noinline int ntfs_setxattr(const struct=20 xattr_handler *handler, =C2=A0 * =C2=A0 * save uid/gid/mode in xattr =C2=A0 */ -int ntfs_save_wsl_perm(struct inode *inode) +int ntfs_save_wsl_perm(struct inode *inode, __le16 *ea_size) =C2=A0{ =C2=A0=C2=A0=C2=A0=C2=A0 int err; =C2=A0=C2=A0=C2=A0=C2=A0 __le32 value; @@ -946,26 +950,26 @@ int ntfs_save_wsl_perm(struct inode *inode) =C2=A0=C2=A0=C2=A0=C2=A0 ni_lock(ni); =C2=A0=C2=A0=C2=A0=C2=A0 value =3D cpu_to_le32(i_uid_read(inode)); =C2=A0=C2=A0=C2=A0=C2=A0 err =3D ntfs_set_ea(inode, "$LXUID", sizeof("$LXU= ID") - 1, &value, -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 sizeof(val= ue), 0, true); /* true =3D=3D already locked. */ +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 sizeof(val= ue), 0, true, ea_size); =C2=A0=C2=A0=C2=A0=C2=A0 if (err) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 value =3D cpu_to_le32(i_gid_read(inode)); =C2=A0=C2=A0=C2=A0=C2=A0 err =3D ntfs_set_ea(inode, "$LXGID", sizeof("$LXG= ID") - 1, &value, -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 sizeof(val= ue), 0, true); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 sizeof(val= ue), 0, true, ea_size); =C2=A0=C2=A0=C2=A0=C2=A0 if (err) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 value =3D cpu_to_le32(inode->i_mode); =C2=A0=C2=A0=C2=A0=C2=A0 err =3D ntfs_set_ea(inode, "$LXMOD", sizeof("$LXM= OD") - 1, &value, -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 sizeof(val= ue), 0, true); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 sizeof(val= ue), 0, true, ea_size); =C2=A0=C2=A0=C2=A0=C2=A0 if (err) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mo= de)) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 value =3D cpu_to_le32(inode->i= _rdev); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D ntfs_set_ea(inode, "$L= XDEV", sizeof("$LXDEV") - 1, &value, -=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 sizeof(value), 0, true); +=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 sizeof(value), 0, true, ea_size); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (err) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } --=20 2.34.1 From nobody Thu Sep 11 22:17:26 2025 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 D6627C6379F for ; Wed, 15 Feb 2023 13:36:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229883AbjBONgS (ORCPT ); Wed, 15 Feb 2023 08:36:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbjBONgQ (ORCPT ); Wed, 15 Feb 2023 08:36:16 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C19DE358D; Wed, 15 Feb 2023 05:36:15 -0800 (PST) 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 7DF952147; Wed, 15 Feb 2023 13:32:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676467923; bh=OatpAkpsqEkQhNlA8+4RSwXL5RSbK1GB/mfif8PSuXw=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=iAEGNCOIRzqY/nbzXCP4Ctrra7Efo9iOlJbi0C6An8CFHbytSmWV++wz84rTlqMmh p6zCCJnU2Eaxt6xq+4+UPXt3YnnOlkUSBK9TS0HbznaWpvyZM15P4LOYZ+WahPq81y VUWSCf+xlhJ9Nlh5mwDg+yXXj4owFmYLtU8dRK7Q= Received: from [192.168.211.36] (192.168.211.36) 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, 15 Feb 2023 16:36:13 +0300 Message-ID: <75a56ed1-eafc-0a18-9c2d-db4e423c3f26@paragon-software.com> Date: Wed, 15 Feb 2023 17:36:12 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: [PATCH 04/11] fs/ntfs3: Optimization in ntfs_set_state() 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.36] 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 The current volume flags are updated only if VOLUME_FLAG_DIRTY has been=20 changed. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/fsntfs.c | 9 +++++++-- =C2=A01 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index 342938704cfd..d888ba14237f 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -925,6 +925,7 @@ int ntfs_set_state(struct ntfs_sb_info *sbi, enum=20 NTFS_DIRTY_FLAGS dirty) =C2=A0=C2=A0=C2=A0=C2=A0 struct VOLUME_INFO *info; =C2=A0=C2=A0=C2=A0=C2=A0 struct mft_inode *mi; =C2=A0=C2=A0=C2=A0=C2=A0 struct ntfs_inode *ni; +=C2=A0=C2=A0=C2=A0 __le16 info_flags; =C2=A0=C2=A0=C2=A0=C2=A0 /* =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0* Do not change state if fs was real_dirty. @@ -957,6 +958,8 @@ int ntfs_set_state(struct ntfs_sb_info *sbi, enum=20 NTFS_DIRTY_FLAGS dirty) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } +=C2=A0=C2=A0=C2=A0 info_flags =3D info->flags; + =C2=A0=C2=A0=C2=A0=C2=A0 switch (dirty) { =C2=A0=C2=A0=C2=A0=C2=A0 case NTFS_DIRTY_ERROR: =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_notice(sbi->sb, "Mark vol= ume as dirty due to NTFS errors"); @@ -970,8 +973,10 @@ int ntfs_set_state(struct ntfs_sb_info *sbi, enum=20 NTFS_DIRTY_FLAGS dirty) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 break; =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 /* Cache current volume flags. */ -=C2=A0=C2=A0=C2=A0 sbi->volume.flags =3D info->flags; -=C2=A0=C2=A0=C2=A0 mi->dirty =3D true; +=C2=A0=C2=A0=C2=A0 if (info_flags !=3D info->flags) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 sbi->volume.flags =3D info->flags; +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 mi->dirty =3D true; +=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 err =3D 0; =C2=A0out: --=20 2.34.1 From nobody Thu Sep 11 22:17:26 2025 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 E127AC6379F for ; Wed, 15 Feb 2023 13:36:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230501AbjBONgw (ORCPT ); Wed, 15 Feb 2023 08:36:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbjBONgu (ORCPT ); Wed, 15 Feb 2023 08:36:50 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAC2C358D; Wed, 15 Feb 2023 05:36:48 -0800 (PST) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id AE4042147; Wed, 15 Feb 2023 13:32:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676467956; bh=b+LLWuFDWYTNULIicKcI1S4EHJN/4plvEY5VcSHrLWg=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=Q/Yhfksb+qlZJt/4SxooKi0BdMWTt4rWIloAIs3pdR8jX3wuZjC6uyvFVJEygSGxA qUfQAD8VSljf5GabnWJAwMIbqa+GC5tWrNBKOuc4ArDXojXIv2GIg4qgHfGkjqsvbM RUE7iQtJBUzaiDMmsz+ntj3SX8NU96W+/1yPV/qA= 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 0E8EC1E70; Wed, 15 Feb 2023 13:36:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676468207; bh=b+LLWuFDWYTNULIicKcI1S4EHJN/4plvEY5VcSHrLWg=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=ptH5fSA1Cz8XKI6v5HdTiOH2aOVUYljEDjk4I6gFH627yI0aZPymi8pOrP5gUwlMs tW7L8ujIRq2JCs26nIJCdQ8r1U1/LsHBdzKlLxGh2FZ9x4mJ3qpflYanYe/wwE7Gdf 0EnfrqssmhRvJu5CANZTFB19MIUDtuWifUzDlQwk= Received: from [192.168.211.36] (192.168.211.36) 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, 15 Feb 2023 16:36:46 +0300 Message-ID: Date: Wed, 15 Feb 2023 17:36:46 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: [PATCH 05/11] fs/ntfs3: Undo endian changes 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.36] 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 sbi->mft.reserved_bitmap is in-memory (not on-disk!) bitmap. Assumed cpu endian is faster than fixed endian. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/fsntfs.c | 11 +++++------ =C2=A01 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index d888ba14237f..9ed9dd0d8edf 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -646,13 +646,13 @@ int ntfs_look_free_mft(struct ntfs_sb_info *sbi,=20 CLST *rno, bool mft, =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 =C2=A0=C2=A0=C2=A0 =C2=A0 NULL, 0, NULL, NULL)) =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 =C2=A0goto next; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0__clear_bit_le(ir - MFT_REC_RESERVED, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0__clear_bit(ir - MFT_REC_RESERVED, =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 =C2=A0=C2=A0=C2=A0=C2=A0 &sbi->mft.reserved_bitmap); =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=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Scan 5 bits for zero. Bit 0= =3D=3D MFT_REC_RESERVED */ -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0zbit =3D find_next_zero_bit_le(&sbi-= >mft.reserved_bitmap, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0zbit =3D find_next_zero_bit(&sbi->mf= t.reserved_bitmap, =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 =C2=A0=C2=A0 MFT_REC_FREE, MFT_REC_RESERVED); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (zbit >=3D MFT_REC_FREE) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sbi->mft.ne= xt_reserved =3D MFT_REC_FREE; @@ -720,7 +720,7 @@ int ntfs_look_free_mft(struct ntfs_sb_info *sbi,=20 CLST *rno, bool mft, =C2=A0=C2=A0=C2=A0 =C2=A0if (*rno >=3D MFT_REC_FREE) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0wnd_set_used(wnd, *rno, 1); =C2=A0=C2=A0=C2=A0 =C2=A0else if (*rno >=3D MFT_REC_RESERVED && sbi->mft.r= eserved_bitmap_inited) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0__set_bit_le(*rno - MFT_REC_RESERVED= , &sbi->mft.reserved_bitmap); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0__set_bit(*rno - MFT_REC_RESERVED, &= sbi->mft.reserved_bitmap); =C2=A0out: =C2=A0=C2=A0=C2=A0 =C2=A0if (!mft) @@ -748,7 +748,7 @@ void ntfs_mark_rec_free(struct ntfs_sb_info *sbi,=20 CLST rno, bool is_mft) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0else =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0wnd_set_fre= e(wnd, rno, 1); =C2=A0=C2=A0=C2=A0 =C2=A0} else if (rno >=3D MFT_REC_RESERVED &&=20 sbi->mft.reserved_bitmap_inited) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0__clear_bit_le(rno - MFT_REC_RESERVE= D, &sbi->mft.reserved_bitmap); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0__clear_bit(rno - MFT_REC_RESERVED, = &sbi->mft.reserved_bitmap); =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0if (rno < wnd_zone_bit(wnd)) @@ -846,9 +846,8 @@ void ntfs_update_mftmirr(struct ntfs_sb_info *sbi,=20 int wait) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0int err; =C2=A0=C2=A0=C2=A0 =C2=A0struct super_block *sb =3D sbi->sb; -=C2=A0=C2=A0 =C2=A0u32 blocksize; +=C2=A0=C2=A0 =C2=A0u32 blocksize, bytes; =C2=A0=C2=A0=C2=A0 =C2=A0sector_t block1, block2; -=C2=A0=C2=A0 =C2=A0u32 bytes; =C2=A0=C2=A0=C2=A0 =C2=A0if (!sb) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return; --=20 2.34.1 From nobody Thu Sep 11 22:17:26 2025 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 5755DC636CC for ; Wed, 15 Feb 2023 13:37:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231186AbjBONh1 (ORCPT ); Wed, 15 Feb 2023 08:37:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbjBONh0 (ORCPT ); Wed, 15 Feb 2023 08:37:26 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B980358D; Wed, 15 Feb 2023 05:37:25 -0800 (PST) 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 D63352147; Wed, 15 Feb 2023 13:33:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676467992; bh=s+jnBTb+FEAmnBEVyyEk7i0waZIXU0NPfdQERDIaNfE=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=ndKFZlp5o5+usKaaciH36JgPDyMsCNQzIeMorpXuUXxrHaeCrx5tuzcEccSGTQwZr 8N7sIMjEzZ0wshdQifn3gEbFbZRBqU+RiYSZZgTxpp5qBmEqS+GrRb/6y4p8ZUQJJr el3CtPeW4mvu41Zlz/1+woYx27WOLOdtnDxaaXsE= Received: from [192.168.211.36] (192.168.211.36) 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, 15 Feb 2023 16:37:22 +0300 Message-ID: <3f4de192-d3f3-f2b3-2b05-8c1c027d1d8c@paragon-software.com> Date: Wed, 15 Feb 2023 17:37:22 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: [PATCH 06/11] fs/ntfs3: Undo critial modificatins to keep directory consistency 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.36] 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 Affect xfstest 320. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/index.c | 30 ++++++++++++++++++++---------- =C2=A01 file changed, 20 insertions(+), 10 deletions(-) diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c index 9fefeac5fe7e..5d1ec0124137 100644 --- a/fs/ntfs3/index.c +++ b/fs/ntfs3/index.c @@ -1778,10 +1778,11 @@ indx_insert_into_buffer(struct ntfs_index *indx,=20 struct ntfs_inode *ni, =C2=A0=C2=A0=C2=A0=C2=A0 struct indx_node *n1 =3D fnd->nodes[level]; =C2=A0=C2=A0=C2=A0=C2=A0 struct INDEX_HDR *hdr1 =3D &n1->index->ihdr; =C2=A0=C2=A0=C2=A0=C2=A0 struct INDEX_HDR *hdr2; -=C2=A0=C2=A0=C2=A0 u32 to_copy, used; +=C2=A0=C2=A0=C2=A0 u32 to_copy, used, used1; =C2=A0=C2=A0=C2=A0=C2=A0 CLST new_vbn; =C2=A0=C2=A0=C2=A0=C2=A0 __le64 t_vbn, *sub_vbn; =C2=A0=C2=A0=C2=A0=C2=A0 u16 sp_size; +=C2=A0=C2=A0=C2=A0 void *hdr1_saved =3D NULL; =C2=A0=C2=A0=C2=A0=C2=A0 /* Try the most easy case. */ =C2=A0=C2=A0=C2=A0=C2=A0 e =3D fnd->level - 1 =3D=3D level ? fnd->de[level= ] : NULL; @@ -1814,6 +1815,13 @@ indx_insert_into_buffer(struct ntfs_index *indx,=20 struct ntfs_inode *ni, =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return -ENOMEM; =C2=A0=C2=A0=C2=A0=C2=A0 memcpy(up_e, sp, sp_size); +=C2=A0=C2=A0=C2=A0 used1 =3D le32_to_cpu(hdr1->used); +=C2=A0=C2=A0=C2=A0 hdr1_saved =3D kmemdup(hdr1, used1, GFP_NOFS); +=C2=A0=C2=A0=C2=A0 if (!hdr1_saved) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D -ENOMEM; +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; +=C2=A0=C2=A0=C2=A0 } + =C2=A0=C2=A0=C2=A0=C2=A0 if (!hdr1->flags) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 up_e->flags |=3D NTFS_IE_HAS_S= UBNODES; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 up_e->size =3D cpu_to_le16(sp_= size + sizeof(u64)); @@ -1846,7 +1854,7 @@ indx_insert_into_buffer(struct ntfs_index *indx,=20 struct ntfs_inode *ni, =C2=A0=C2=A0=C2=A0=C2=A0 hdr_insert_head(hdr2, de_t, to_copy); =C2=A0=C2=A0=C2=A0=C2=A0 /* Remove all entries (sp including) from hdr1. */ -=C2=A0=C2=A0=C2=A0 used =3D le32_to_cpu(hdr1->used) - to_copy - sp_size; +=C2=A0=C2=A0=C2=A0 used =3D used1 - to_copy - sp_size; =C2=A0=C2=A0=C2=A0=C2=A0 memmove(de_t, Add2Ptr(sp, sp_size), used - le32_t= o_cpu(hdr1->de_off)); =C2=A0=C2=A0=C2=A0=C2=A0 hdr1->used =3D cpu_to_le32(used); @@ -1876,8 +1884,6 @@ indx_insert_into_buffer(struct ntfs_index *indx,=20 struct ntfs_inode *ni, =C2=A0=C2=A0=C2=A0=C2=A0 if (!level) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 /* Insert in root. */ =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D indx_insert_into_root(= indx, ni, up_e, NULL, ctx, fnd, 0); -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (err) -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } else { =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* The target buffer's pa= rent is another index buffer. @@ -1885,12 +1891,20 @@ indx_insert_into_buffer(struct ntfs_index *indx,=20 struct ntfs_inode *ni, =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 err =3D indx_insert_into_buffe= r(indx, ni, root, up_e, ctx, =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=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 level - 1, fnd); -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (err) -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; +=C2=A0=C2=A0=C2=A0 } + +=C2=A0=C2=A0=C2=A0 if (err) { +=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* Undo critical operations. +=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 indx_mark_free(indx, ni, new_vbn >> = indx->idx2vbn_bits); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 memcpy(hdr1, hdr1_saved, used1); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 indx_write(indx, ni, n1, 0); =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0out: =C2=A0=C2=A0=C2=A0=C2=A0 kfree(up_e); +=C2=A0=C2=A0=C2=A0 kfree(hdr1_saved); =C2=A0=C2=A0=C2=A0=C2=A0 return err; =C2=A0} @@ -1949,16 +1963,12 @@ int indx_insert_entry(struct ntfs_index *indx,=20 struct ntfs_inode *ni, =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 err =3D indx_insert_into_root(= indx, ni, new_de, fnd->root_de, ctx, =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=C2=A0 =C2=A0=C2=A0=C2=A0 fnd, undo); -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (err) -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } else { =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* Found a leaf buffer, s= o we'll insert the new entry into it. =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 err =3D indx_insert_into_buffe= r(indx, ni, root, new_de, ctx, =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=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 fnd->level - 1,= fnd); -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (err) -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0out: --=20 2.34.1 From nobody Thu Sep 11 22:17:26 2025 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 3A98FC6379F for ; Wed, 15 Feb 2023 13:38:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229960AbjBONiH (ORCPT ); Wed, 15 Feb 2023 08:38:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbjBONiG (ORCPT ); Wed, 15 Feb 2023 08:38:06 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE5F37D88; Wed, 15 Feb 2023 05:38:05 -0800 (PST) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 9B29A2147; Wed, 15 Feb 2023 13:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676468033; bh=qABqCzWeJMd8lL3Bs/m2a0hwQR1+Gsb68tcyxZYiqqY=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=NeHGIHvjmMRxaOW43o4icEh3F5LwXYbTVz8PkfLcNfmyDFe/Bt2my8KiOd43MekOu 4OF8h0WyBmidpMbwVaE0+F4Pk5fsrOXF2fI2mBi4sl4KGL7OEqRieh2rbJfABGn1Om UncOn4kcq2w/WhJyaPGf8/4FlXtE2tfnQAaYV3Ew= 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 E9C2F1E70; Wed, 15 Feb 2023 13:38:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676468283; bh=qABqCzWeJMd8lL3Bs/m2a0hwQR1+Gsb68tcyxZYiqqY=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=Nv7Dc7iPcqNQs8qB6kUQLqyB02zMfSvYFdF2EnIBuC4dF5t8n2xOm+bLgE2pqys6F +Ktcj9H4TrhZTM9nUzEO4HIvcviPQgPNFIJJaABZShaXbhoThXy7GCwYP6gqQuV96O 8YI1lf+OhKYodotlKDPFCeuahN5qrhkFl8VIYIzk= Received: from [192.168.211.36] (192.168.211.36) 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, 15 Feb 2023 16:38:03 +0300 Message-ID: <9e0dd9a4-afa8-1137-7f8b-ccec26825aa1@paragon-software.com> Date: Wed, 15 Feb 2023 17:38:02 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: [PATCH 07/11] fs/ntfs3: Remove field sbi->used.bitmap.set_tail 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.36] 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 This field is not used in driver. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/ntfs_fs.h | 1 - =C2=A0fs/ntfs3/super.c=C2=A0=C2=A0 | 2 -- =C2=A02 files changed, 3 deletions(-) diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 73a639716b45..26957dbfe471 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -163,7 +163,6 @@ struct wnd_bitmap { =C2=A0=C2=A0=C2=A0=C2=A0 size_t zone_bit; =C2=A0=C2=A0=C2=A0=C2=A0 size_t zone_end; -=C2=A0=C2=A0=C2=A0 bool set_tail; // Not necessary in driver. =C2=A0=C2=A0=C2=A0=C2=A0 bool inited; =C2=A0}; diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 10c019ef7da3..d7bec9b28a42 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -1117,8 +1117,6 @@ 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 goto put_inode_out; =C2=A0=C2=A0=C2=A0=C2=A0 } -=C2=A0=C2=A0=C2=A0 /* Not necessary. */ -=C2=A0=C2=A0=C2=A0 sbi->used.bitmap.set_tail =3D true; =C2=A0=C2=A0=C2=A0=C2=A0 err =3D wnd_init(&sbi->used.bitmap, sb, tt); =C2=A0=C2=A0=C2=A0=C2=A0 if (err) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto put_inode_out; --=20 2.34.1 From nobody Thu Sep 11 22:17:26 2025 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 AB494C636CC for ; Wed, 15 Feb 2023 13:39:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230360AbjBONjA (ORCPT ); Wed, 15 Feb 2023 08:39:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbjBONi6 (ORCPT ); Wed, 15 Feb 2023 08:38:58 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 701C77D88; Wed, 15 Feb 2023 05:38:57 -0800 (PST) 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 1EFC02147; Wed, 15 Feb 2023 13:34:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676468085; bh=v58AXW2jaHRye0+maSOsTkJ3+nH0kdM/rFc7zhel7Rc=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=W4yAraG/LFxRU1llz2bytqvNtGnqOkDAsNUSflnIdSqi2WB4dmyV07Vp9gmL7aBzA RLOcoQ3v00omyOCC4OtsDJzX//VF+mkYcGp8YdRXKA+jBpvUt5L+mV6diBi5Di8M9R azxBZlm0LhyBv5C1t8ozsOdC6sfk0D8cjgvL7yic= Received: from [192.168.211.36] (192.168.211.36) 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, 15 Feb 2023 16:38:55 +0300 Message-ID: <2f017ba3-78a9-211d-2a61-f8a1c90c3cab@paragon-software.com> Date: Wed, 15 Feb 2023 17:38:54 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: [PATCH 08/11] fs/ntfs3: Changed ntfs_get_acl() to use dentry 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.36] 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 ntfs_get_acl changed to match new interface in struct inode_operations. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/file.c=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +- =C2=A0fs/ntfs3/namei.c=C2=A0=C2=A0 |=C2=A0 4 ++-- =C2=A0fs/ntfs3/ntfs_fs.h |=C2=A0 3 ++- =C2=A0fs/ntfs3/xattr.c=C2=A0=C2=A0 | 26 +++++++++----------------- =C2=A04 files changed, 14 insertions(+), 21 deletions(-) diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index df7b76d1c127..09b7931e6be3 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -1143,7 +1143,7 @@ const struct inode_operations=20 ntfs_file_inode_operations =3D { =C2=A0=C2=A0=C2=A0 =C2=A0.getattr=C2=A0=C2=A0 =C2=A0=3D ntfs_getattr, =C2=A0=C2=A0=C2=A0 =C2=A0.setattr=C2=A0=C2=A0 =C2=A0=3D ntfs3_setattr, =C2=A0=C2=A0=C2=A0 =C2=A0.listxattr=C2=A0=C2=A0 =C2=A0=3D ntfs_listxattr, -=C2=A0=C2=A0 =C2=A0.get_inode_acl=C2=A0=C2=A0 =C2=A0=3D ntfs_get_acl, +=C2=A0=C2=A0 =C2=A0.get_acl=C2=A0=C2=A0 =C2=A0=3D ntfs_get_acl, =C2=A0=C2=A0=C2=A0 =C2=A0.set_acl=C2=A0=C2=A0 =C2=A0=3D ntfs_set_acl, =C2=A0=C2=A0=C2=A0 =C2=A0.fiemap=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=3D = ntfs_fiemap, =C2=A0}; diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c index 5d5fe2f1f77c..8b68ead5cc1f 100644 --- a/fs/ntfs3/namei.c +++ b/fs/ntfs3/namei.c @@ -607,7 +607,7 @@ const struct inode_operations=20 ntfs_dir_inode_operations =3D { =C2=A0=C2=A0=C2=A0 =C2=A0.rmdir=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=3D n= tfs_rmdir, =C2=A0=C2=A0=C2=A0 =C2=A0.mknod=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=3D n= tfs_mknod, =C2=A0=C2=A0=C2=A0 =C2=A0.rename=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=3D = ntfs_rename, -=C2=A0=C2=A0 =C2=A0.get_inode_acl=C2=A0=C2=A0 =C2=A0=3D ntfs_get_acl, +=C2=A0=C2=A0 =C2=A0.get_acl=C2=A0=C2=A0 =C2=A0=3D ntfs_get_acl, =C2=A0=C2=A0=C2=A0 =C2=A0.set_acl=C2=A0=C2=A0 =C2=A0=3D ntfs_set_acl, =C2=A0=C2=A0=C2=A0 =C2=A0.setattr=C2=A0=C2=A0 =C2=A0=3D ntfs3_setattr, =C2=A0=C2=A0=C2=A0 =C2=A0.getattr=C2=A0=C2=A0 =C2=A0=3D ntfs_getattr, @@ -620,7 +620,7 @@ const struct inode_operations=20 ntfs_special_inode_operations =3D { =C2=A0=C2=A0=C2=A0 =C2=A0.setattr=C2=A0=C2=A0 =C2=A0=3D ntfs3_setattr, =C2=A0=C2=A0=C2=A0 =C2=A0.getattr=C2=A0=C2=A0 =C2=A0=3D ntfs_getattr, =C2=A0=C2=A0=C2=A0 =C2=A0.listxattr=C2=A0=C2=A0 =C2=A0=3D ntfs_listxattr, -=C2=A0=C2=A0 =C2=A0.get_inode_acl=C2=A0=C2=A0 =C2=A0=3D ntfs_get_acl, +=C2=A0=C2=A0 =C2=A0.get_acl=C2=A0=C2=A0 =C2=A0=3D ntfs_get_acl, =C2=A0=C2=A0=C2=A0 =C2=A0.set_acl=C2=A0=C2=A0 =C2=A0=3D ntfs_set_acl, =C2=A0}; diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 26957dbfe471..b7782107ce8a 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -855,7 +855,8 @@ unsigned long ntfs_names_hash(const u16 *name,=20 size_t len, const u16 *upcase, =C2=A0/* globals from xattr.c */ =C2=A0#ifdef CONFIG_NTFS3_FS_POSIX_ACL -struct posix_acl *ntfs_get_acl(struct inode *inode, int type, bool rcu); +struct posix_acl *ntfs_get_acl(struct user_namespace *mnt_userns, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 struct dentry *dentry, int type); =C2=A0int ntfs_set_acl(struct user_namespace *mnt_userns, struct dentry *d= entry, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 struct posix_acl *acl, int ty= pe); =C2=A0int ntfs_init_acl(struct user_namespace *mnt_userns, struct inode *i= node, diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index e7a66225361d..95c479d7ebba 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -520,9 +520,14 @@ static noinline int ntfs_set_ea(struct inode=20 *inode, const char *name, =C2=A0} =C2=A0#ifdef CONFIG_NTFS3_FS_POSIX_ACL -static struct posix_acl *ntfs_get_acl_ex(struct inode *inode, int type, -=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 int locked) + +/* + * ntfs_get_acl - inode_operations::get_acl + */ +struct posix_acl *ntfs_get_acl(struct user_namespace *mnt_userns, +=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 struct dentry *dentry, int type) =C2=A0{ +=C2=A0=C2=A0 =C2=A0struct inode *inode =3D d_inode(dentry); =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_inode *ni =3D ntfs_i(inode); =C2=A0=C2=A0=C2=A0 =C2=A0const char *name; =C2=A0=C2=A0=C2=A0 =C2=A0size_t name_len; @@ -545,13 +550,11 @@ static struct posix_acl *ntfs_get_acl_ex(struct=20 inode *inode, int type, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0name_len =3D sizeof(XATTR_NAME= _POSIX_ACL_DEFAULT) - 1; =C2=A0=C2=A0=C2=A0 =C2=A0} -=C2=A0=C2=A0 =C2=A0if (!locked) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni_lock(ni); +=C2=A0=C2=A0 =C2=A0ni_lock(ni); =C2=A0=C2=A0=C2=A0 =C2=A0err =3D ntfs_get_ea(inode, name, name_len, buf, P= ATH_MAX, &req); -=C2=A0=C2=A0 =C2=A0if (!locked) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni_unlock(ni); +=C2=A0=C2=A0 =C2=A0ni_unlock(ni); =C2=A0=C2=A0=C2=A0 =C2=A0/* Translate extended attribute to acl. */ =C2=A0=C2=A0=C2=A0 =C2=A0if (err >=3D 0) { @@ -570,17 +573,6 @@ static struct posix_acl *ntfs_get_acl_ex(struct=20 inode *inode, int type, =C2=A0=C2=A0=C2=A0 =C2=A0return acl; =C2=A0} -/* - * ntfs_get_acl - inode_operations::get_acl - */ -struct posix_acl *ntfs_get_acl(struct inode *inode, int type, bool rcu) -{ -=C2=A0=C2=A0 =C2=A0if (rcu) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return ERR_PTR(-ECHILD); - -=C2=A0=C2=A0 =C2=A0return ntfs_get_acl_ex(inode, type, 0); -} - =C2=A0static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_usern= s, =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=C2=A0 struct inode *inode, struct posix_acl *acl, =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=C2=A0 int type, bool init_acl) --=20 2.34.1 From nobody Thu Sep 11 22:17:26 2025 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 1B2C6C636CC for ; Wed, 15 Feb 2023 13:39:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231359AbjBONjj (ORCPT ); Wed, 15 Feb 2023 08:39:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230422AbjBONjg (ORCPT ); Wed, 15 Feb 2023 08:39:36 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0F2B17176; Wed, 15 Feb 2023 05:39:31 -0800 (PST) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 7BA172147; Wed, 15 Feb 2023 13:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676468119; bh=9wqkiqZrKzwvHdcnP28A5rK4lq/9iHl1Vg0imvVpMVU=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=Ia28Fr2nrEgu9o91Mm/j9Nk0suXbvwp5Ungw2+T/I62WuyZZxsRQYsnbeJiKDIZkW s4cSvy0NEpsRforX3ljS87lVdtjOtEH+KjpMTa7ooJPW4ynlFlPGtyalELiiKnyHXk r87EWCdPsPnKLCvtgLVFqJFdD1lD6AQeBn7g/MKQ= 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 C6A9D1E70; Wed, 15 Feb 2023 13:39:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676468369; bh=9wqkiqZrKzwvHdcnP28A5rK4lq/9iHl1Vg0imvVpMVU=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=qbEqalBfsq1XbhHoWk3MYbtRL3DCq2NLl4F+AkuHeQuHIQwYHaCas/wWEdDf0HIix 5SKMBWL2yHYWeH2Nq2328+9MD13m3JR7mmtLIy/QCwvRJTCgKxKXxO4vPsxFlb325y qFSbRK3JZpOHCfeEJFOHqoEBerOYdXP8LEW6YsE8= Received: from [192.168.211.36] (192.168.211.36) 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, 15 Feb 2023 16:39:29 +0300 Message-ID: <83fcdf79-dbb0-e693-cc66-877f3bb22eac@paragon-software.com> Date: Wed, 15 Feb 2023 17:39:28 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: [PATCH 09/11] fs/ntfs3: Code formatting and refactoring 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.36] 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 Added minor refactoring. Added and fixed some comments. In some places, the code has been reformatted to fit into 80 columns. clang-format-12 was used to format code according kernel's .clang-format. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/attrib.c=C2=A0 | 17 +++++----- =C2=A0fs/ntfs3/bitmap.c=C2=A0 | 22 ++++++------- =C2=A0fs/ntfs3/file.c=C2=A0=C2=A0=C2=A0 | 25 ++++++++------- =C2=A0fs/ntfs3/frecord.c | 37 ++++++++++------------ =C2=A0fs/ntfs3/fslog.c=C2=A0=C2=A0 | 77 +++++++++++++++++++++++-----------= ------------ =C2=A0fs/ntfs3/fsntfs.c=C2=A0 | 13 ++++---- =C2=A0fs/ntfs3/index.c=C2=A0=C2=A0 | 28 +++++++++-------- =C2=A0fs/ntfs3/inode.c=C2=A0=C2=A0 | 33 ++++++++++---------- =C2=A0fs/ntfs3/lznt.c=C2=A0=C2=A0=C2=A0 | 10 +++--- =C2=A0fs/ntfs3/namei.c=C2=A0=C2=A0 |=C2=A0 4 +-- =C2=A0fs/ntfs3/ntfs_fs.h |=C2=A0 9 +++--- =C2=A0fs/ntfs3/record.c=C2=A0 |=C2=A0 9 +++--- =C2=A0fs/ntfs3/run.c=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 6 ++-- =C2=A0fs/ntfs3/super.c=C2=A0=C2=A0 | 70 ++++++++++++++++++++++------------= ------- =C2=A0fs/ntfs3/xattr.c=C2=A0=C2=A0 |=C2=A0 4 +-- =C2=A015 files changed, 186 insertions(+), 178 deletions(-) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 5e6bafb10f42..0b8bc66377db 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -405,8 +405,8 @@ int attr_set_size(struct ntfs_inode *ni, enum=20 ATTR_TYPE type, =C2=A0=C2=A0=C2=A0 =C2=A0int err =3D 0; =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_sb_info *sbi =3D ni->mi.sbi; =C2=A0=C2=A0=C2=A0 =C2=A0u8 cluster_bits =3D sbi->cluster_bits; -=C2=A0=C2=A0 =C2=A0bool is_mft =3D -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni->mi.rno =3D=3D MFT_REC_MFT && typ= e =3D=3D ATTR_DATA && !name_len; +=C2=A0=C2=A0 =C2=A0bool is_mft =3D ni->mi.rno =3D=3D MFT_REC_MFT && type = =3D=3D ATTR_DATA && +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 !name= _len; =C2=A0=C2=A0=C2=A0 =C2=A0u64 old_valid, old_size, old_alloc, new_alloc, ne= w_alloc_tmp; =C2=A0=C2=A0=C2=A0 =C2=A0struct ATTRIB *attr =3D NULL, *attr_b; =C2=A0=C2=A0=C2=A0 =C2=A0struct ATTR_LIST_ENTRY *le, *le_b; @@ -531,11 +531,10 @@ int attr_set_size(struct ntfs_inode *ni, enum=20 ATTR_TYPE type, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0pre_alloc = =3D 0; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (type = =3D=3D ATTR_DATA && !name_len && =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 sbi->options->prealloc) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0pre_alloc =3D -=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=A0bytes_to_cluster( -=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=C2=A0=C2=A0 =C2=A0sbi, -=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=C2=A0=C2=A0 =C2=A0get_pre_allocated(new_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=A0new_alen; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0pre_alloc =3D bytes_to_cluster( +=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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 sbi, get_pre_al= located( +=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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0 new_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=C2=A0=C2=A0=C2=A0 new_alen; =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=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Get the = last LCN to allocate from. */ @@ -573,8 +572,8 @@ int attr_set_size(struct ntfs_inode *ni, enum=20 ATTR_TYPE type, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D att= r_allocate_clusters( =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=A0sbi, run, vcn, lcn, to_allocate, &pre_alloc, =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=A0is_mft ? ALLOCATE_MFT : ALLOCATE_DEF, &alen, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0is_mft ? 0 -=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=C2=A0=C2=A0=C2=A0 : (sbi->record_size - +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0is_mft ? 0 : +=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=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (sbi->record_siz= e - =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 =C2=A0=C2=A0 le32_to_cpu(rec->used) + 8) / =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 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 3 + =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 =C2=A0=C2=A0=C2=A0 =C2=A0 1, diff --git a/fs/ntfs3/bitmap.c b/fs/ntfs3/bitmap.c index 393c726ef17a..9a6c6a09d70c 100644 --- a/fs/ntfs3/bitmap.c +++ b/fs/ntfs3/bitmap.c @@ -40,9 +40,9 @@ static struct kmem_cache *ntfs_enode_cachep; =C2=A0int __init ntfs3_init_bitmap(void) =C2=A0{ -=C2=A0=C2=A0 =C2=A0ntfs_enode_cachep =3D -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0kmem_cache_create("ntfs3_enode_cache= ", sizeof(struct e_node), 0, -=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 SLAB_RECLAIM_ACCOUNT, NULL); +=C2=A0=C2=A0 =C2=A0ntfs_enode_cachep =3D kmem_cache_create("ntfs3_enode_ca= che", +=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=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sizeof(struct e_node),= 0, +=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=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 SLAB_RECLAIM_ACCOUNT, = NULL); =C2=A0=C2=A0=C2=A0 =C2=A0return ntfs_enode_cachep ? 0 : -ENOMEM; =C2=A0} @@ -286,9 +286,9 @@ static void wnd_add_free_ext(struct wnd_bitmap *wnd,=20 size_t bit, size_t len, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (wnd->uptodated !=3D 1) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Check bi= ts before 'bit'. */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ib =3D wnd-= >zone_bit =3D=3D wnd->zone_end || -=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=C2=A0=C2=A0=C2=A0=C2=A0 bit < wnd->zone_end -=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=C2=A0 ? 0 -=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=C2=A0 : wnd->zone_end; +=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=C2=A0=C2=A0=C2=A0=C2=A0 bit < wnd->zone_end ? +=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=C2=A0=C2=A0 0 : +=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=C2=A0=C2=A0 wnd->zone_end; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0while (bit = > ib && wnd_is_free_hlp(wnd, bit - 1, 1)) { =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=A0bit -=3D 1; @@ -297,9 +297,9 @@ static void wnd_add_free_ext(struct wnd_bitmap *wnd,=20 size_t bit, size_t len, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Check bi= ts after 'end_in'. */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ib =3D wnd-= >zone_bit =3D=3D wnd->zone_end || -=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=C2=A0=C2=A0=C2=A0=C2=A0 end_in > wnd->zone_bit -=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=C2=A0 ? wnd->nbits -=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=C2=A0 : wnd->zone_bit; +=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=C2=A0=C2=A0=C2=A0=C2=A0 end_in > wnd->zone_bit ? +=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=C2=A0=C2=A0 wnd->nbits : +=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=C2=A0=C2=A0 wnd->zone_bit; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0while (end_= in < ib && wnd_is_free_hlp(wnd, end_in, 1)) { =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=A0end_in +=3D 1; @@ -417,8 +417,8 @@ static void wnd_remove_free_ext(struct wnd_bitmap=20 *wnd, size_t bit, size_t len) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0n3 =3D rb_first(&wnd->count_tr= ee); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0wnd->extent_max =3D -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0n3 ? rb_entry(n3,= struct e_node, count.node)->count.key -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 : 0; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0n3 ? rb_entry(n3,= struct e_node, count.node)->count.key : +=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 0; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return; =C2=A0=C2=A0=C2=A0 =C2=A0} diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index 09b7931e6be3..a10a905ec7ce 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -22,20 +22,21 @@ static int ntfs_ioctl_fitrim(struct ntfs_sb_info=20 *sbi, unsigned long arg) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0struct fstrim_range __user *user_range; =C2=A0=C2=A0=C2=A0 =C2=A0struct fstrim_range range; +=C2=A0=C2=A0 =C2=A0struct block_device *dev; =C2=A0=C2=A0=C2=A0 =C2=A0int err; =C2=A0=C2=A0=C2=A0 =C2=A0if (!capable(CAP_SYS_ADMIN)) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -EPERM; -=C2=A0=C2=A0 =C2=A0if (!bdev_max_discard_sectors(sbi->sb->s_bdev)) +=C2=A0=C2=A0 =C2=A0dev =3D sbi->sb->s_bdev; +=C2=A0=C2=A0 =C2=A0if (!bdev_max_discard_sectors(dev)) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -EOPNOTSUPP; =C2=A0=C2=A0=C2=A0 =C2=A0user_range =3D (struct fstrim_range __user *)arg; =C2=A0=C2=A0=C2=A0 =C2=A0if (copy_from_user(&range, user_range, sizeof(ran= ge))) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -EFAULT; -=C2=A0=C2=A0 =C2=A0range.minlen =3D max_t(u32, range.minlen, -=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 bdev_discard_granularity(sbi->sb->s_bdev)); +=C2=A0=C2=A0 =C2=A0range.minlen =3D max_t(u32, range.minlen, bdev_discard_= granularity(dev)); =C2=A0=C2=A0=C2=A0 =C2=A0err =3D ntfs_trim_fs(sbi, &range); =C2=A0=C2=A0=C2=A0 =C2=A0if (err < 0) @@ -190,8 +191,8 @@ static int ntfs_zero_range(struct inode *inode, u64=20 vbo, u64 vbo_to) =C2=A0=C2=A0=C2=A0 =C2=A0for (; idx < idx_end; idx +=3D 1, from =3D 0) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0page_off =3D (loff_t)idx << PA= GE_SHIFT; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0to =3D (page_off + PAGE_SIZE) > vbo_= to ? (vbo_to - page_off) -=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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : PAGE_SI= ZE; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0to =3D (page_off + PAGE_SIZE) > vbo_= to ? (vbo_to - page_off) : +=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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 PAGE_SIZE; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0iblock =3D page_off >> inode->= i_blkbits; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0page =3D find_or_create_page(m= apping, idx, @@ -564,13 +565,14 @@ 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=A0ni_unlock(ni); =C2=A0=C2=A0=C2=A0 =C2=A0} else { =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=A0u8 cluster_bits =3D sbi->cluster_bit= s; =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); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (to_allo= c > 0 && -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 (to_alloc >> sbi->cluster_bits) > +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 (to_alloc >> cluster_bits) > =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=C2=A0 wnd_zeroes(&sbi->used.bitmap)) { =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=A0err =3D -ENOSPC; =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=A0goto out; @@ -591,7 +593,7 @@ 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} =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=A0CLST vcn =3D vbo = >> sbi->cluster_bits; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0CLST vcn =3D vbo = >> cluster_bits; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0CLST cend = =3D bytes_to_cluster(sbi, end); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0CLST cend_v= =3D bytes_to_cluster(sbi, ni->i_valid); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0CLST lcn, c= len; @@ -1049,8 +1051,8 @@ static ssize_t ntfs_file_write_iter(struct kiocb=20 *iocb, struct iov_iter *from) =C2=A0=C2=A0=C2=A0 =C2=A0if (ret) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; -=C2=A0=C2=A0 =C2=A0ret =3D is_compressed(ni) ? ntfs_compress_write(iocb, f= rom) -=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_file_write_iter(iocb, from); +=C2=A0=C2=A0 =C2=A0ret =3D is_compressed(ni) ? ntfs_compress_write(iocb, f= rom) : +=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__generic_file_write_iter(iocb, from); =C2=A0out: =C2=A0=C2=A0=C2=A0 =C2=A0inode_unlock(inode); @@ -1102,8 +1104,9 @@ static int ntfs_file_release(struct inode *inode,=20 struct file *file) =C2=A0=C2=A0=C2=A0 =C2=A0int err =3D 0; =C2=A0=C2=A0=C2=A0 =C2=A0/* If we are last writer on the inode, drop the b= lock reservation. */ -=C2=A0=C2=A0 =C2=A0if (sbi->options->prealloc && ((file->f_mode & FMODE_WR= ITE) && -=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=C2=A0=C2=A0 atomic_read(&inode->i_writecount) =3D=3D = 1)) { +=C2=A0=C2=A0 =C2=A0if (sbi->options->prealloc && +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 ((file->f_mode & FMODE_WRITE) && +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 atomic_read(&inode->i_writecou= nt) =3D=3D 1)) { =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=A0down_write(&ni->file.run_lock); diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index 9e7dfee303e8..481219f2a7cf 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -76,8 +76,8 @@ struct ATTR_STD_INFO *ni_std(struct ntfs_inode *ni) =C2=A0=C2=A0=C2=A0 =C2=A0const struct ATTRIB *attr; =C2=A0=C2=A0=C2=A0 =C2=A0attr =3D mi_find_attr(&ni->mi, NULL, ATTR_STD, NU= LL, 0, NULL); -=C2=A0=C2=A0 =C2=A0return attr ? resident_data_ex(attr, sizeof(struct ATTR= _STD_INFO)) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 : NULL; +=C2=A0=C2=A0 =C2=A0return attr ? resident_data_ex(attr, sizeof(struct ATTR= _STD_INFO)) : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 NULL; =C2=A0} =C2=A0/* @@ -91,8 +91,8 @@ struct ATTR_STD_INFO5 *ni_std5(struct ntfs_inode *ni) =C2=A0=C2=A0=C2=A0 =C2=A0attr =3D mi_find_attr(&ni->mi, NULL, ATTR_STD, NU= LL, 0, NULL); -=C2=A0=C2=A0 =C2=A0return attr ? resident_data_ex(attr, sizeof(struct ATTR= _STD_INFO5)) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 : NULL; +=C2=A0=C2=A0 =C2=A0return attr ? resident_data_ex(attr, sizeof(struct ATTR= _STD_INFO5)) : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 NULL; =C2=A0} =C2=A0/* @@ -1439,8 +1439,8 @@ int ni_insert_nonresident(struct ntfs_inode *ni,=20 enum ATTR_TYPE type, =C2=A0=C2=A0=C2=A0 =C2=A0int err; =C2=A0=C2=A0=C2=A0 =C2=A0CLST plen; =C2=A0=C2=A0=C2=A0 =C2=A0struct ATTRIB *attr; -=C2=A0=C2=A0 =C2=A0bool is_ext =3D -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0(flags & (ATTR_FLAG_SPARSED | ATTR_F= LAG_COMPRESSED)) && !svcn; +=C2=A0=C2=A0 =C2=A0bool is_ext =3D (flags & (ATTR_FLAG_SPARSED | ATTR_FLAG= _COMPRESSED)) && +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 !svcn; =C2=A0=C2=A0=C2=A0 =C2=A0u32 name_size =3D ALIGN(name_len * sizeof(short),= 8); =C2=A0=C2=A0=C2=A0 =C2=A0u32 name_off =3D is_ext ? SIZEOF_NONRESIDENT_EX := SIZEOF_NONRESIDENT; =C2=A0=C2=A0=C2=A0 =C2=A0u32 run_off =3D name_off + name_size; @@ -1756,9 +1756,9 @@ int ni_new_attr_flags(struct ntfs_inode *ni, enum=20 FILE_ATTRIBUTE new_fa) =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0/* Resize nonresident empty attribute in-place on= ly. */ -=C2=A0=C2=A0 =C2=A0new_asize =3D (new_aflags & (ATTR_FLAG_COMPRESSED | ATT= R_FLAG_SPARSED)) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 ? (SIZEOF_NONRESIDENT_EX + 8) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 : (SIZEOF_NONRESIDENT + 8); +=C2=A0=C2=A0 =C2=A0new_asize =3D (new_aflags & (ATTR_FLAG_COMPRESSED | ATT= R_FLAG_SPARSED)) ? +=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 (SIZEOF_NONRESIDENT_EX + 8) : +=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 (SIZEOF_NONRESIDENT + 8); =C2=A0=C2=A0=C2=A0 =C2=A0if (!mi_resize_attr(mi, attr, new_asize - le32_to= _cpu(attr->size))) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -EOPNOTSUPP; @@ -2965,14 +2965,14 @@ bool ni_remove_name_undo(struct ntfs_inode=20 *dir_ni, struct ntfs_inode *ni, =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_sb_info *sbi =3D ni->mi.sbi; =C2=A0=C2=A0=C2=A0 =C2=A0struct ATTRIB *attr; -=C2=A0=C2=A0 =C2=A0u16 de_key_size =3D de2 ? le16_to_cpu(de2->key_size) : = 0; +=C2=A0=C2=A0 =C2=A0u16 de_key_size; =C2=A0=C2=A0=C2=A0 =C2=A0switch (undo_step) { =C2=A0=C2=A0=C2=A0 =C2=A0case 4: +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0de_key_size =3D le16_to_cpu(de2->key= _size); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (ni_insert_resident(ni, de_= key_size, ATTR_NAME, NULL, 0, -=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=C2=A0=C2=A0=C2=A0 &attr, NULL, NULL)) { +=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=C2=A0=C2=A0=C2=A0 &attr, NULL, NULL)) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return fals= e; -=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=A0memcpy(Add2Ptr(attr, SIZEOF_RE= SIDENT), de2 + 1, de_key_size); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0mi_get_ref(&ni->mi, &de2->ref); @@ -2981,19 +2981,16 @@ bool ni_remove_name_undo(struct ntfs_inode=20 *dir_ni, struct ntfs_inode *ni, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0de2->flags =3D 0; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0de2->res =3D 0; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (indx_insert_entry(&dir_ni->dir, = dir_ni, de2, sbi, NULL, -=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=C2=A0=C2=A0 1)) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (indx_insert_entry(&dir_ni->dir, = dir_ni, de2, sbi, NULL, 1)) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return fals= e; -=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=A0fallthrough; =C2=A0=C2=A0=C2=A0 =C2=A0case 2: =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0de_key_size =3D le16_to_cpu(de= ->key_size); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (ni_insert_resident(ni, de_= key_size, ATTR_NAME, NULL, 0, -=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=C2=A0=C2=A0=C2=A0 &attr, NULL, NULL)) { +=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=C2=A0=C2=A0=C2=A0 &attr, NULL, NULL)) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return fals= e; -=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=A0memcpy(Add2Ptr(attr, SIZEOF_RE= SIDENT), de + 1, de_key_size); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0mi_get_ref(&ni->mi, &de->ref); @@ -3162,9 +3159,9 @@ static bool ni_update_parent(struct ntfs_inode=20 *ni, struct NTFS_DUP_INFO *dup, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0u64 data_si= ze =3D le64_to_cpu(attr->nres.data_size); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0__le64 vali= d_le; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0dup->alloc_size = =3D is_attr_ext(attr) -=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=C2=A0=C2=A0 =C2=A0=C2=A0 ? attr->nres.total_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=C2=A0=C2=A0 =C2=A0=C2=A0 : attr->nres.alloc_size; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0dup->alloc_size = =3D is_attr_ext(attr) ? +=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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0attr->nres.tota= l_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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0attr->nres.allo= c_size; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0dup->data_s= ize =3D attr->nres.data_size; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (new_val= id > data_size) diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c index bf7396447284..57762c5fe68b 100644 --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -827,10 +827,10 @@ static inline struct RESTART_TABLE=20 *extend_rsttbl(struct RESTART_TABLE *tbl, =C2=A0=C2=A0=C2=A0 =C2=A0memcpy(rt + 1, tbl + 1, esize * used); -=C2=A0=C2=A0 =C2=A0rt->free_goal =3D free_goal =3D=3D ~0u -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0? cpu_to_le32(~0u) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0: cpu_to_le32(sizeof(struct RESTART_TABLE) + -=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=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 free_goal * esize); +=C2=A0=C2=A0 =C2=A0rt->free_goal =3D free_goal =3D=3D ~0u ? +=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=C2=A0=C2=A0 cpu_to_le32(~0u) : +=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=C2=A0=C2=A0 cpu_to_le32(sizeof(struct RESTART_TABLE) + +=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=C2=A0=C2=A0=C2=A0 free_goal * esize); =C2=A0=C2=A0=C2=A0 =C2=A0if (tbl->first_free) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0rt->first_free =3D tbl->first_= free; @@ -1089,9 +1089,9 @@ static inline u64 base_lsn(struct ntfs_log *log, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 (lsn < (lsn= _to_vbo(log, h_lsn) & ~log->page_mask) ? 1 : 0)) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 << log->file_data= _bits) + =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 ((((is_log_record_end(h= dr) && -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 h_lsn= <=3D le64_to_cpu(hdr->record_hdr.last_end_lsn)) -=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 ? le16_to_cpu(hdr->record_hdr.next_record_off) -=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 : log->page_size) + +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 h_lsn= <=3D le64_to_cpu(hdr->record_hdr.last_end_lsn)) ? +=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 le16_to_cpu(hdr->record_hdr.next_record_off) : +=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 log->page_size) + =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 lsn) >> =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 3); @@ -1298,9 +1298,9 @@ static void log_init_pg_hdr(struct ntfs_log *log,=20 u32 sys_page_size, =C2=A0=C2=A0=C2=A0 =C2=A0if (!log->clst_per_page) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0log->clst_per_page =3D 1; -=C2=A0=C2=A0 =C2=A0log->first_page =3D major_ver >=3D 2 -=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 ? 0x22 * page_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 : ((sys_page_size << 1) + (page_size << 1)); +=C2=A0=C2=A0 =C2=A0log->first_page =3D major_ver >=3D 2 ? +=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=A00x22 * page_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((sys_page_size << 1) + (page_size << 1)); =C2=A0=C2=A0=C2=A0 =C2=A0log->major_ver =3D major_ver; =C2=A0=C2=A0=C2=A0 =C2=A0log->minor_ver =3D minor_ver; =C2=A0} @@ -1512,20 +1512,19 @@ static u32 current_log_avail(struct ntfs_log *log) =C2=A0=C2=A0=C2=A0 =C2=A0 * have to compute the free range. =C2=A0=C2=A0=C2=A0 =C2=A0 * If there is no oldest lsn then start at the fi= rst page of the file. =C2=A0=C2=A0=C2=A0 =C2=A0 */ -=C2=A0=C2=A0 =C2=A0oldest_off =3D (log->l_flags & NTFSLOG_NO_OLDEST_LSN) -=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 ? log->first_page -=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 : (log->oldest_lsn_off & ~log->sys_page_mask); +=C2=A0=C2=A0 =C2=A0oldest_off =3D (log->l_flags & NTFSLOG_NO_OLDEST_LSN) ? +=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 log->first_page : +=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 (log->oldest_lsn_off & ~log->sys_page_mask); =C2=A0=C2=A0=C2=A0 =C2=A0/* =C2=A0=C2=A0=C2=A0 =C2=A0 * We will use the next log page offset to comput= e the next free page. =C2=A0=C2=A0=C2=A0 =C2=A0 * If we are going to reuse this page go to the n= ext page. =C2=A0=C2=A0=C2=A0 =C2=A0 * If we are at the first page then use the end o= f the file. =C2=A0=C2=A0=C2=A0 =C2=A0 */ -=C2=A0=C2=A0 =C2=A0next_free_off =3D (log->l_flags & NTFSLOG_REUSE_TAIL) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0? log->next_page + log->page_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: log->next_page =3D=3D log->first_page -=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=C2=A0 ? log->l_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=C2=A0 : log->next_page; +=C2=A0=C2=A0 =C2=A0next_free_off =3D (log->l_flags & NTFSLOG_REUSE_TAIL) ? +=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=C2=A0=C2=A0 log->next_page + log->page_size : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0log->next_page = =3D=3D log->first_page ? log->l_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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0 log->next_page; =C2=A0=C2=A0=C2=A0 =C2=A0/* If the two offsets are the same then there is = no available=20 space. */ =C2=A0=C2=A0=C2=A0 =C2=A0if (oldest_off =3D=3D next_free_off) @@ -1535,9 +1534,9 @@ static u32 current_log_avail(struct ntfs_log *log) =C2=A0=C2=A0=C2=A0 =C2=A0 * this range from the total available pages. =C2=A0=C2=A0=C2=A0 =C2=A0 */ =C2=A0=C2=A0=C2=A0 =C2=A0free_bytes =3D -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0oldest_off < next_free_off -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0? log->total_avai= l_pages - (next_free_off - oldest_off) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0: oldest_off - ne= xt_free_off; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0oldest_off < next_free_off ? +=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 log->total_avail_pages - (next_free_off - oldest_off) : +=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 oldest_off - next_free_off; =C2=A0=C2=A0=C2=A0 =C2=A0free_bytes >>=3D log->page_bits; =C2=A0=C2=A0=C2=A0 =C2=A0return free_bytes * log->reserved; @@ -1671,8 +1670,8 @@ static int last_log_lsn(struct ntfs_log *log) =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0best_lsn1 =3D first_tail ? base_lsn(log, first_ta= il, first_file_off)=20 : 0; -=C2=A0=C2=A0 =C2=A0best_lsn2 =3D -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0second_tail ? base_lsn(log, second_t= ail, second_file_off) : 0; +=C2=A0=C2=A0 =C2=A0best_lsn2 =3D second_tail ? base_lsn(log, second_tail, = second_file_off) : +=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=A00; =C2=A0=C2=A0=C2=A0 =C2=A0if (first_tail && second_tail) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (best_lsn1 > best_lsn2) { @@ -1767,8 +1766,8 @@ static int last_log_lsn(struct ntfs_log *log) =C2=A0=C2=A0=C2=A0 =C2=A0page_cnt =3D page_pos =3D 1; -=C2=A0=C2=A0 =C2=A0curpage_off =3D seq_base =3D=3D log->seq_num ? min(log-= >next_page, page_off) -=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=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : log->next_page; +=C2=A0=C2=A0 =C2=A0curpage_off =3D seq_base =3D=3D log->seq_num ? min(log-= >next_page,=20 page_off) : +=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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 log->next_page; =C2=A0=C2=A0=C2=A0 =C2=A0wrapped_file =3D =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0curpage_off =3D=3D log->first_= page && @@ -1826,9 +1825,9 @@ static int last_log_lsn(struct ntfs_log *log) =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 le64_to_cpu(cur_page->record_hdr.last_end_lsn) && =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 ((lsn_cur >= > log->file_data_bits) + =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((cur= page_off < -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= (lsn_to_vbo(log, lsn_cur) & ~log->page_mask)) -=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 ? 1 -=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 : 0)) !=3D expected_seq) { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= (lsn_to_vbo(log, lsn_cur) & ~log->page_mask)) ? +=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 1 : +=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 0)) !=3D expected_seq) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto check_= tail; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} @@ -2642,9 +2641,10 @@ static inline bool check_index_root(const struct=20 ATTRIB *attr, =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0bool ret; =C2=A0=C2=A0=C2=A0 =C2=A0const struct INDEX_ROOT *root =3D resident_data(a= ttr); -=C2=A0=C2=A0 =C2=A0u8 index_bits =3D le32_to_cpu(root->index_block_size) >= =3D=20 sbi->cluster_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? sbi->cluster_bits -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0: SECTOR_SHIFT; +=C2=A0=C2=A0 =C2=A0u8 index_bits =3D le32_to_cpu(root->index_block_size) >= =3D +=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=A0sbi->cluster_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=C2=A0=C2=A0 sbi->cluster_bits : +=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=C2=A0=C2=A0 SECTOR_SHIFT; =C2=A0=C2=A0=C2=A0 =C2=A0u8 block_clst =3D root->index_block_clst; =C2=A0=C2=A0=C2=A0 =C2=A0if (le32_to_cpu(attr->res.data_size) < sizeof(str= uct INDEX_ROOT) || @@ -3683,7 +3683,8 @@ static int do_action(struct ntfs_log *log, struct=20 OPEN_ATTR_ENRTY *oe, =C2=A0=C2=A0=C2=A0 =C2=A0if (a_dirty) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0attr =3D oa->attr; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D ntfs_sb_write_run(sbi, oa->r= un1, vbo, buffer_le, bytes, 0); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D ntfs_sb_write_run(sbi, oa->r= un1, vbo, buffer_le, 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=C2=A0=C2=A0 =C2=A00); =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=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} @@ -3768,11 +3769,10 @@ int log_replay(struct ntfs_inode *ni, bool=20 *initialized) =C2=A0=C2=A0=C2=A0 =C2=A0if (!log) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -ENOMEM; -=C2=A0=C2=A0 =C2=A0memset(&rst_info, 0, sizeof(struct restart_info)); - =C2=A0=C2=A0=C2=A0 =C2=A0log->ni =3D ni; =C2=A0=C2=A0=C2=A0 =C2=A0log->l_size =3D l_size; =C2=A0=C2=A0=C2=A0 =C2=A0log->one_page_buf =3D kmalloc(page_size, GFP_NOFS= ); + =C2=A0=C2=A0=C2=A0 =C2=A0if (!log->one_page_buf) { =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 out; @@ -3783,6 +3783,7 @@ int log_replay(struct ntfs_inode *ni, bool=20 *initialized) =C2=A0=C2=A0=C2=A0 =C2=A0log->page_bits =3D blksize_bits(page_size); =C2=A0=C2=A0=C2=A0 =C2=A0/* Look for a restart area on the disk. */ +=C2=A0=C2=A0 =C2=A0memset(&rst_info, 0, sizeof(struct restart_info)); =C2=A0=C2=A0=C2=A0 =C2=A0err =3D log_read_rst(log, l_size, true, &rst_info= ); =C2=A0=C2=A0=C2=A0 =C2=A0if (err) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; @@ -3859,10 +3860,10 @@ int log_replay(struct ntfs_inode *ni, bool=20 *initialized) =C2=A0=C2=A0=C2=A0 =C2=A0log->init_ra =3D !!rst_info.vbo; =C2=A0=C2=A0=C2=A0 =C2=A0/* If we have a valid page then grab a pointer to= the restart area. */ -=C2=A0=C2=A0 =C2=A0ra2 =3D rst_info.valid_page -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ? Add= 2Ptr(rst_info.r_page, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0le16_to_cpu(rst_info.r_page->ra_off)) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : NUL= L; +=C2=A0=C2=A0 =C2=A0ra2 =3D rst_info.valid_page ? +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 Add2Ptr(rst_info.r_page, +=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 le16_to_cpu(rst_info.r_page->ra_off)) : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 NULL; =C2=A0=C2=A0=C2=A0 =C2=A0if (rst_info.chkdsk_was_run || =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 (ra2 && ra2->client_idx[1] =3D= =3D LFS_NO_CLIENT_LE)) { diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index 9ed9dd0d8edf..0a82b1bf3ec2 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -172,8 +172,8 @@ int ntfs_fix_post_read(struct NTFS_RECORD_HEADER=20 *rhdr, size_t bytes, =C2=A0=C2=A0=C2=A0 =C2=A0u16 sample, fo, fn; =C2=A0=C2=A0=C2=A0 =C2=A0fo =3D le16_to_cpu(rhdr->fix_off); -=C2=A0=C2=A0 =C2=A0fn =3D simple ? ((bytes >> SECTOR_SHIFT) + 1) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 : le16_to_cpu(rhd= r->fix_num); +=C2=A0=C2=A0 =C2=A0fn =3D simple ? ((bytes >> SECTOR_SHIFT) + 1) : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 le16_to_cpu(rhdr->fix_num); =C2=A0=C2=A0=C2=A0 =C2=A0/* Check errors. */ =C2=A0=C2=A0=C2=A0 =C2=A0if ((fo & 1) || fo + fn * sizeof(short) > SECTOR_= SIZE || !fn-- || @@ -849,14 +849,13 @@ void ntfs_update_mftmirr(struct ntfs_sb_info *sbi,=20 int wait) =C2=A0=C2=A0=C2=A0 =C2=A0u32 blocksize, bytes; =C2=A0=C2=A0=C2=A0 =C2=A0sector_t block1, block2; -=C2=A0=C2=A0 =C2=A0if (!sb) +=C2=A0=C2=A0 =C2=A0/* +=C2=A0=C2=A0 =C2=A0 * sb can be NULL here. In this case sbi->flags should = be 0 too. +=C2=A0=C2=A0 =C2=A0 */ +=C2=A0=C2=A0 =C2=A0if (!sb || !(sbi->flags & NTFS_FLAGS_MFTMIRR)) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return; =C2=A0=C2=A0=C2=A0 =C2=A0blocksize =3D sb->s_blocksize; - -=C2=A0=C2=A0 =C2=A0if (!(sbi->flags & NTFS_FLAGS_MFTMIRR)) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return; - =C2=A0=C2=A0=C2=A0 =C2=A0bytes =3D sbi->mft.recs_mirr << sbi->record_bits; =C2=A0=C2=A0=C2=A0 =C2=A0block1 =3D sbi->mft.lbo >> sb->s_blocksize_bits; =C2=A0=C2=A0=C2=A0 =C2=A0block2 =3D sbi->mft.lbo2 >> sb->s_blocksize_bits; diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c index 5d1ec0124137..0a48d2d67219 100644 --- a/fs/ntfs3/index.c +++ b/fs/ntfs3/index.c @@ -431,8 +431,9 @@ static int scan_nres_bitmap(struct ntfs_inode *ni,=20 struct ATTRIB *bitmap, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (vbo + blocksize > data_siz= e) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0nbits =3D 8= * (data_size - vbo); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ok =3D nbits > from ? (*fn)((ulong *= )bh->b_data, from, nbits, ret) -=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 : false; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ok =3D nbits > from ? +=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 (*fn)((ulong *)bh->b_data, from, nbits, ret) : +=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 false; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0put_bh(bh); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (ok) { @@ -764,8 +765,7 @@ static struct NTFS_DE *hdr_find_e(const struct=20 ntfs_index *indx, =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=A0return NULL; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0max_idx =3D= 0; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0table_size =3D mi= n(table_size * 2, -=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 (int)ARRAY_SIZE(offs)); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0table_size =3D mi= n(table_size * 2, (int)ARRAY_SIZE(offs)); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto fill_t= able; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0} else if (diff2 < 0) { @@ -1170,8 +1170,10 @@ int indx_find(struct ntfs_index *indx, struct=20 ntfs_inode *ni, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Read next level. */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D indx_read(indx, ni, de= _get_vbn(e), &node); -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (err) +=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/* io error? */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return err; +=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/* Lookup entry that is <=3D t= o the search value. */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0e =3D hdr_find_e(indx, &node->= index->ihdr, key, key_len, ctx, @@ -1673,9 +1675,9 @@ static int indx_insert_into_root(struct ntfs_index=20 *indx, struct ntfs_inode *ni, =C2=A0=C2=A0=C2=A0 =C2=A0mi->dirty =3D true; =C2=A0=C2=A0=C2=A0 =C2=A0/* Create alloc and bitmap attributes (if not). */ -=C2=A0=C2=A0 =C2=A0err =3D run_is_empty(&indx->alloc_run) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ? ind= x_create_allocate(indx, ni, &new_vbn) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : ind= x_add_allocate(indx, ni, &new_vbn); +=C2=A0=C2=A0 =C2=A0err =3D run_is_empty(&indx->alloc_run) ? +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 indx_create_allocate(indx, ni, &new_vbn) : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 indx_add_allocate(indx, ni, &new_vbn); =C2=A0=C2=A0=C2=A0 =C2=A0/* Layout of record may be changed, so rescan roo= t. */ =C2=A0=C2=A0=C2=A0 =C2=A0root =3D indx_get_root(indx, ni, &attr, &mi); @@ -1865,9 +1867,9 @@ indx_insert_into_buffer(struct ntfs_index *indx,=20 struct ntfs_inode *ni, =C2=A0=C2=A0=C2=A0 =C2=A0hdr_insert_de(indx, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= (*indx->cmp)(new_de + 1, le16_to_cpu(new_de->key_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 up_e + 1, le16_to_cpu(up_e->key_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 ctx) < 0 -=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 ? hdr2 -=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 : hdr1, +=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 ctx) < 0 ? +=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 hdr2 : +=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 hdr1, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= new_de, NULL, ctx); =C2=A0=C2=A0=C2=A0 =C2=A0indx_mark_used(indx, ni, new_vbn >> indx->idx2vbn= _bits); @@ -2337,8 +2339,8 @@ int indx_delete_entry(struct ntfs_index *indx,=20 struct ntfs_inode *ni, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D lev= el ? indx_insert_into_buffer(indx, ni, root, =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 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 re, ctx, =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 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 fnd->level - 1, -=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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 fnd) -=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 : indx_insert_into_root(indx, ni, re, e, +=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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 fnd) : +=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=C2=A0=C2=A0=C2=A0 indx_insert_into_root(indx, ni, re= , e, =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 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0=C2=A0 ctx, fnd, 0); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0kfree(re); diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 752ad17685c0..f64b1e001501 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -262,8 +262,8 @@ static struct inode *ntfs_read_mft(struct inode *inode, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!attr->nres.alloc_size) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto next_a= ttr; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0run =3D ino =3D=3D MFT_REC_BITMAP ? = &sbi->used.bitmap.run -=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=C2=A0=C2=A0=C2=A0 : &ni->file.run; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0run =3D ino =3D=3D MFT_REC_BITMAP ? = &sbi->used.bitmap.run : +=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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 &ni->file.run; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0break; =C2=A0=C2=A0=C2=A0 =C2=A0case ATTR_ROOT: @@ -290,9 +290,9 @@ static struct inode *ntfs_read_mft(struct inode *inode, =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=A0goto out; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0mode =3D sb->s_root -=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 ? (S_IFDIR | (0777 & sbi->options->fs_dmask_inv)) -=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 : (S_IFDIR | 0777); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0mode =3D sb->s_root ? +=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=C2=A0 (S_IFDIR | (0777 & sbi->options->fs_dmask_inv))= : +=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=C2=A0 (S_IFDIR | 0777); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto next_attr; =C2=A0=C2=A0=C2=A0 =C2=A0case ATTR_ALLOC: @@ -449,8 +449,8 @@ static struct inode *ntfs_read_mft(struct inode *inode, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ni->std_fa &=3D ~FILE_ATTRIBUT= E_DIRECTORY; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode->i_op =3D &ntfs_file_ino= de_operations; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode->i_fop =3D &ntfs_file_op= erations; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode->i_mapping->a_ops =3D -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0is_compressed(ni)= ? &ntfs_aops_cmpr : &ntfs_aops; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode->i_mapping->a_ops =3D is_compr= essed(ni) ? &ntfs_aops_cmpr : +=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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0=C2=A0 &ntfs_aops; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (ino !=3D MFT_REC_MFT) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0init_rwsem(= &ni->file.run_lock); =C2=A0=C2=A0=C2=A0 =C2=A0} else if (S_ISCHR(mode) || S_ISBLK(mode) || S_IS= FIFO(mode) || @@ -786,8 +786,8 @@ static ssize_t ntfs_direct_IO(struct kiocb *iocb,=20 struct iov_iter *iter) =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0ret =3D blockdev_direct_IO(iocb, inode, iter, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0 wr ? ntfs_get_block_direct_IO_W -=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 : ntfs_get_block_direct_IO_R); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0 wr ? ntfs_get_block_direct_IO_W : +=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=C2=A0=C2=A0=C2=A0 ntfs_get_block_direct_IO_R); =C2=A0=C2=A0=C2=A0 =C2=A0if (ret > 0) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0end =3D vbo + ret; @@ -846,7 +846,7 @@ int ntfs_set_size(struct inode *inode, u64 new_size) =C2=A0} =C2=A0static int ntfs_resident_writepage(struct page *page, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct writeback_control *wbc, void = *data) +=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 struct writeback_control *wbc, void *data) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0struct address_space *mapping =3D data; =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_inode *ni =3D ntfs_i(mapping->host); @@ -887,8 +887,8 @@ int ntfs_write_begin(struct file *file, struct=20 address_space *mapping, =C2=A0=C2=A0=C2=A0 =C2=A0*pagep =3D NULL; =C2=A0=C2=A0=C2=A0 =C2=A0if (is_resident(ni)) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct page *page =3D grab_cache_pag= e_write_begin( -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0mapping, pos >> P= AGE_SHIFT); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct page *page =3D +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0grab_cache_page_w= rite_begin(mapping, pos >> PAGE_SHIFT); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!page) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0err =3D -EN= OMEM; @@ -920,9 +920,8 @@ int ntfs_write_begin(struct file *file, struct=20 address_space *mapping, =C2=A0/* =C2=A0 * ntfs_write_end - Address_space_operations::write_end. =C2=A0 */ -int ntfs_write_end(struct file *file, struct address_space *mapping, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 loff_t pos, u32 len, u3= 2 copied, struct page *page, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 void *fsdata) +int ntfs_write_end(struct file *file, struct address_space *mapping,=20 loff_t pos, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 u32 len, u32 copied, st= ruct page *page, void *fsdata) =C2=A0{ =C2=A0=C2=A0=C2=A0 =C2=A0struct inode *inode =3D mapping->host; =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_inode *ni =3D ntfs_i(inode); @@ -1605,8 +1604,8 @@ struct inode *ntfs_create_inode(struct=20 user_namespace *mnt_userns, =C2=A0=C2=A0=C2=A0 =C2=A0} else if (S_ISREG(mode)) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode->i_op =3D &ntfs_file_ino= de_operations; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode->i_fop =3D &ntfs_file_op= erations; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode->i_mapping->a_ops =3D -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0is_compressed(ni)= ? &ntfs_aops_cmpr : &ntfs_aops; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode->i_mapping->a_ops =3D is_compr= essed(ni) ? &ntfs_aops_cmpr : +=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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0=C2=A0 &ntfs_aops; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0init_rwsem(&ni->file.run_lock); =C2=A0=C2=A0=C2=A0 =C2=A0} else { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0inode->i_op =3D &ntfs_special_= inode_operations; diff --git a/fs/ntfs3/lznt.c b/fs/ntfs3/lznt.c index 28f654561f27..61e161c7c567 100644 --- a/fs/ntfs3/lznt.c +++ b/fs/ntfs3/lznt.c @@ -296,8 +296,8 @@ static inline ssize_t decompress_chunk(u8 *unc, u8=20 *unc_end, const u8 *cmpr, =C2=A0 */ =C2=A0struct lznt *get_lznt_ctx(int level) =C2=A0{ -=C2=A0=C2=A0 =C2=A0struct lznt *r =3D kzalloc(level ? offsetof(struct lznt= , hash) -=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=C2=A0=C2=A0=C2=A0 : sizeof(struct lznt), +=C2=A0=C2=A0 =C2=A0struct lznt *r =3D kzalloc(level ? offsetof(struct lznt= , hash) : +=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=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sizeof(struct lz= nt), =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 GFP_NOFS); =C2=A0=C2=A0=C2=A0 =C2=A0if (r) @@ -392,9 +392,9 @@ ssize_t decompress_lznt(const void *cmpr, size_t=20 cmpr_size, void *unc, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0unc_use =3D= err; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} else { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* This chu= nk does not contain compressed data. */ -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0unc_use =3D unc_c= hunk + LZNT_CHUNK_SIZE > unc_end -=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=C2=A0 ? unc_end - unc_chunk -=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=C2=A0 : LZNT_CHUNK_SIZE; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0unc_use =3D unc_c= hunk + LZNT_CHUNK_SIZE > unc_end ? +=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=C2=A0=C2=A0 =C2=A0unc_end - unc_chunk : +=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=C2=A0=C2=A0 =C2=A0LZNT_CHUNK_SIZE; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (cmpr_ch= unk + sizeof(chunk_hdr) + unc_use > =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 cmpr_end) { diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c index 8b68ead5cc1f..5d5a251334a1 100644 --- a/fs/ntfs3/namei.c +++ b/fs/ntfs3/namei.c @@ -433,8 +433,8 @@ static int ntfs_atomic_open(struct inode *dir,=20 struct dentry *dentry, =C2=A0=C2=A0=C2=A0 =C2=A0inode =3D ntfs_create_inode(&init_user_ns, dir, d= entry, uni, mode, 0, =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 NULL, 0, fnd); -=C2=A0=C2=A0 =C2=A0err =3D IS_ERR(inode) ? PTR_ERR(inode) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 : finish_open(file, dentry, ntfs_file_open); +=C2=A0=C2=A0 =C2=A0err =3D IS_ERR(inode) ? PTR_ERR(inode) : +=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 finish_open(file, dentry, ntfs_file_open); =C2=A0=C2=A0=C2=A0 =C2=A0dput(d); =C2=A0out2: diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index b7782107ce8a..9a2d965f183e 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -338,7 +338,7 @@ enum ntfs_inode_mutex_lock_class { =C2=A0}; =C2=A0/* - * sturct ntfs_inode + * struct ntfs_inode =C2=A0 * =C2=A0 * Ntfs inode - extends linux inode. consists of one or more MFT ino= des. =C2=A0 */ @@ -697,9 +697,8 @@ int ntfs_get_block(struct inode *inode, sector_t vbn, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 struct buffer_hea= d *bh_result, int create); =C2=A0int ntfs_write_begin(struct file *file, struct address_space *mappin= g, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 loff_= t pos, u32 len, struct page **pagep, void **fsdata); -int ntfs_write_end(struct file *file, struct address_space *mapping, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 loff_t pos, u32 len, u3= 2 copied, struct page *page, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 void *fsdata); +int ntfs_write_end(struct file *file, struct address_space *mapping,=20 loff_t pos, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 u32 len, u32 copied, st= ruct page *page, void *fsdata); =C2=A0int ntfs3_write_inode(struct inode *inode, struct writeback_control = *wbc); =C2=A0int ntfs_sync_inode(struct inode *inode); =C2=A0int ntfs_flush_inodes(struct super_block *sb, struct inode *i1, @@ -856,7 +855,7 @@ unsigned long ntfs_names_hash(const u16 *name,=20 size_t len, const u16 *upcase, =C2=A0/* globals from xattr.c */ =C2=A0#ifdef CONFIG_NTFS3_FS_POSIX_ACL =C2=A0struct posix_acl *ntfs_get_acl(struct user_namespace *mnt_userns, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 struct dentry *dentry, int type); +=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 struct dentry *dentry, int type); =C2=A0int ntfs_set_acl(struct user_namespace *mnt_userns, struct dentry *d= entry, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 struct posix_acl *acl, int ty= pe); =C2=A0int ntfs_init_acl(struct user_namespace *mnt_userns, struct inode *i= node, diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c index 0603169ee8a0..2a281cead2bc 100644 --- a/fs/ntfs3/record.c +++ b/fs/ntfs3/record.c @@ -419,10 +419,9 @@ struct ATTRIB *mi_insert_attr(struct mft_inode *mi,=20 enum ATTR_TYPE type, =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_sb_info *sbi =3D mi->sbi; =C2=A0=C2=A0=C2=A0 =C2=A0u32 used =3D le32_to_cpu(rec->used); =C2=A0=C2=A0=C2=A0 =C2=A0const u16 *upcase =3D sbi->upcase; -=C2=A0=C2=A0 =C2=A0int diff; =C2=A0=C2=A0=C2=A0 =C2=A0/* Can we insert mi attribute? */ -=C2=A0=C2=A0 =C2=A0if (used + asize > mi->sbi->record_size) +=C2=A0=C2=A0 =C2=A0if (used + asize > sbi->record_size) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return NULL; =C2=A0=C2=A0=C2=A0 =C2=A0/* @@ -431,7 +430,7 @@ struct ATTRIB *mi_insert_attr(struct mft_inode *mi,=20 enum ATTR_TYPE type, =C2=A0=C2=A0=C2=A0 =C2=A0 */ =C2=A0=C2=A0=C2=A0 =C2=A0attr =3D NULL; =C2=A0=C2=A0=C2=A0 =C2=A0while ((attr =3D mi_enum_attr(mi, attr))) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0diff =3D compare_attr(attr, type, na= me, name_len, upcase); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0int diff =3D compare_attr(attr, type= , name, name_len, upcase); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (diff < 0) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0continue; @@ -442,9 +441,11 @@ struct ATTRIB *mi_insert_attr(struct mft_inode *mi,=20 enum ATTR_TYPE type, =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0if (!attr) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0tail =3D 8; /* Not used, just to sup= press warning. */ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Append. */ +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0tail =3D 8; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0attr =3D Add2Ptr(rec, used - 8= ); =C2=A0=C2=A0=C2=A0 =C2=A0} else { +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* Insert before 'attr'. */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0tail =3D used - PtrOffset(rec,= attr); =C2=A0=C2=A0=C2=A0 =C2=A0} diff --git a/fs/ntfs3/run.c b/fs/ntfs3/run.c index a5af71cd8d14..47612d16c027 100644 --- a/fs/ntfs3/run.c +++ b/fs/ntfs3/run.c @@ -433,9 +433,9 @@ bool run_add_entry(struct runs_tree *run, CLST vcn,=20 CLST lcn, CLST len, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0should_add_= tail =3D Tovcn < r->len; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (should_= add_tail) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0tail_lcn =3D r->lcn =3D=3D SPARSE_LCN -=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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ? SPARSE_LCN -=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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 : (r->lcn + Tovcn); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0tail_lcn =3D r->lcn =3D=3D SPARSE_LCN ? +=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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 SPARSE_LCN : +=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=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 (r->lcn + Tovc= n); =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=A0tail_vcn =3D r->vcn + Tovcn; =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=A0tail_len =3D r->len - Tovcn; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0} diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index d7bec9b28a42..6a412826b43d 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -39,10 +39,10 @@ =C2=A0 * To mount large volumes as ntfs one should use large cluster size=20 (up to 2M) =C2=A0 * The maximum volume size in this case is 2^32 * 2^21 =3D 2^53 =3D = 8P =C2=A0 * - *=C2=A0=C2=A0=C2=A0=C2=A0 ntfs limits, cluster size is 2M (2^31) + *=C2=A0=C2=A0=C2=A0=C2=A0 ntfs limits, cluster size is 2M (2^21) =C2=A0 *=20 ---------------------------------------------------------------------------= -- - * | < 8P, 2^54=C2=A0=C2=A0=C2=A0 |=C2=A0 < 2^32=C2=A0 |=C2=A0 yes=C2=A0= =C2=A0=C2=A0=C2=A0 |=C2=A0 yes=C2=A0=C2=A0 |=C2=A0=C2=A0 yes |=C2=A0 yes=C2= =A0=C2=A0 |=C2=A0=20 yes=C2=A0=C2=A0 | - * | > 8P, 2^54=C2=A0=C2=A0=C2=A0 |=C2=A0 > 2^32=C2=A0 |=C2=A0 no=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 |=C2=A0 no=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 yes |=C2= =A0 yes=C2=A0=C2=A0 |=C2=A0=20 yes=C2=A0=C2=A0 | + * | < 8P, 2^53=C2=A0=C2=A0=C2=A0 |=C2=A0 < 2^32=C2=A0 |=C2=A0 yes=C2=A0= =C2=A0=C2=A0=C2=A0 |=C2=A0 yes=C2=A0=C2=A0 |=C2=A0=C2=A0 yes |=C2=A0 yes=C2= =A0=C2=A0 |=C2=A0=20 yes=C2=A0=C2=A0 | + * | > 8P, 2^53=C2=A0=C2=A0=C2=A0 |=C2=A0 > 2^32=C2=A0 |=C2=A0 no=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 |=C2=A0 no=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 yes |=C2= =A0 yes=C2=A0=C2=A0 |=C2=A0=20 yes=C2=A0=C2=A0 | =C2=A0 *=20 ----------------------------------------------------------|----------------= -- =C2=A0 * =C2=A0 */ @@ -115,9 +115,9 @@ void ntfs_inode_printk(struct inode *inode, const=20 char *fmt, ...) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return; =C2=A0=C2=A0=C2=A0 =C2=A0/* Use static allocated buffer, if possible. */ -=C2=A0=C2=A0 =C2=A0name =3D atomic_dec_and_test(&s_name_buf_cnt) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= ? s_name_buf -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= : kmalloc(sizeof(s_name_buf), GFP_NOFS); +=C2=A0=C2=A0 =C2=A0name =3D atomic_dec_and_test(&s_name_buf_cnt) ? +=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 s_name_buf : +=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 kmalloc(sizeof(s_name_buf), GFP_NOFS); =C2=A0=C2=A0=C2=A0 =C2=A0if (name) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0struct dentry *de =3D d_find_a= lias(inode); @@ -369,7 +369,8 @@ static int ntfs_fs_parse_param(struct fs_context *fc, =C2=A0#ifdef CONFIG_NTFS3_FS_POSIX_ACL =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0fc->sb_flag= s |=3D SB_POSIXACL; =C2=A0#else -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return invalf(fc,= "ntfs3: Support for ACL not compiled in!"); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return invalf( +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0fc, "ntfs3: Support for ACL not compiled in!"); =C2=A0#endif =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0else =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0fc->sb_flag= s &=3D ~SB_POSIXACL; @@ -404,24 +405,29 @@ static int ntfs_fs_reconfigure(struct fs_context *fc) =C2=A0=C2=A0=C2=A0 =C2=A0ro_rw =3D sb_rdonly(sb) && !(fc->sb_flags & SB_RD= ONLY); =C2=A0=C2=A0=C2=A0 =C2=A0if (ro_rw && (sbi->flags & NTFS_FLAGS_NEED_REPLAY= )) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0errorf(fc, "ntfs3: Couldn't remount = rw because journal is not=20 replayed. Please umount/remount instead\n"); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0errorf(fc, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= "ntfs3: Couldn't remount rw because journal is not=20 replayed. Please umount/remount instead\n"); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -EINVAL; =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0new_opts->nls =3D ntfs_load_nls(new_opts->nls_nam= e); =C2=A0=C2=A0=C2=A0 =C2=A0if (IS_ERR(new_opts->nls)) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0new_opts->nls =3D NULL; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0errorf(fc, "ntfs3: Cannot load iocha= rset %s", new_opts->nls_name); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0errorf(fc, "ntfs3: Cannot load iocha= rset %s", +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= new_opts->nls_name); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -EINVAL; =C2=A0=C2=A0=C2=A0 =C2=A0} =C2=A0=C2=A0=C2=A0 =C2=A0if (new_opts->nls !=3D sbi->options->nls) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return invalf(fc, "ntfs3: Cannot use= different iocharset when=20 remounting!"); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return invalf( +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0fc, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0"ntfs3: Cannot us= e different iocharset when remounting!"); =C2=A0=C2=A0=C2=A0 =C2=A0sync_filesystem(sb); =C2=A0=C2=A0=C2=A0 =C2=A0if (ro_rw && (sbi->volume.flags & VOLUME_FLAG_DIR= TY) && =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 !new_opts->force) { -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0errorf(fc, "ntfs3: Volume is dirty a= nd \"force\" flag is not=20 set!"); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0errorf(fc, +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= "ntfs3: Volume is dirty and \"force\" flag is not set!"); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return -EINVAL; =C2=A0=C2=A0=C2=A0 =C2=A0} @@ -539,10 +545,8 @@ static int ntfs_show_options(struct seq_file *m,=20 struct dentry *root) =C2=A0=C2=A0=C2=A0 =C2=A0struct ntfs_mount_options *opts =3D sbi->options; =C2=A0=C2=A0=C2=A0 =C2=A0struct user_namespace *user_ns =3D seq_user_ns(m); -=C2=A0=C2=A0 =C2=A0seq_printf(m, ",uid=3D%u", -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 from_kuid_munged(user_ns, opt= s->fs_uid)); -=C2=A0=C2=A0 =C2=A0seq_printf(m, ",gid=3D%u", -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 from_kgid_munged(user_ns, opt= s->fs_gid)); +=C2=A0=C2=A0 =C2=A0seq_printf(m, ",uid=3D%u", from_kuid_munged(user_ns, op= ts->fs_uid)); +=C2=A0=C2=A0 =C2=A0seq_printf(m, ",gid=3D%u", from_kgid_munged(user_ns, op= ts->fs_gid)); =C2=A0=C2=A0=C2=A0 =C2=A0if (opts->fmask) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_printf(m, ",fmask=3D%04o",= opts->fs_fmask_inv ^ 0xffff); =C2=A0=C2=A0=C2=A0 =C2=A0if (opts->dmask) @@ -699,7 +703,7 @@ static u32 true_sectors_per_clst(const struct=20 NTFS_BOOT *boot) =C2=A0=C2=A0=C2=A0 =C2=A0if (boot->sectors_per_clusters <=3D 0x80) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return boot->sectors_per_clust= ers; =C2=A0=C2=A0=C2=A0 =C2=A0if (boot->sectors_per_clusters >=3D 0xf4) /* limi= t shift to 2MB max */ -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return 1U << -(s8)boot->sectors_per_= clusters; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0return 1U << (-(s8)boot->sectors_per= _clusters); =C2=A0=C2=A0=C2=A0 =C2=A0return -EINVAL; =C2=A0} @@ -717,6 +721,7 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0 =C2=A0struct buffer_head *bh; =C2=A0=C2=A0=C2=A0 =C2=A0struct MFT_REC *rec; =C2=A0=C2=A0=C2=A0 =C2=A0u16 fn, ao; +=C2=A0=C2=A0 =C2=A0u8 cluster_bits; =C2=A0=C2=A0=C2=A0 =C2=A0sbi->volume.blocks =3D dev_size >> PAGE_SHIFT; @@ -784,7 +789,7 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0 =C2=A0if (boot_sector_size !=3D sector_size) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_warn( =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sb, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0"Different NTFS s= ector size (%u) and media sector size (%u)", +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0"Different NTFS s= ector size (%u) and media sector size (%u).", =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0boot_sector= _size, sector_size); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0dev_size +=3D sector_size - 1; =C2=A0=C2=A0=C2=A0 =C2=A0} @@ -792,8 +797,8 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0 =C2=A0sbi->cluster_size =3D boot_sector_size * sct_per_= clst; =C2=A0=C2=A0=C2=A0 =C2=A0sbi->cluster_bits =3D blksize_bits(sbi->cluster_s= ize); -=C2=A0=C2=A0 =C2=A0sbi->mft.lbo =3D mlcn << sbi->cluster_bits; -=C2=A0=C2=A0 =C2=A0sbi->mft.lbo2 =3D mlcn2 << sbi->cluster_bits; +=C2=A0=C2=A0 =C2=A0sbi->mft.lbo =3D mlcn << cluster_bits; +=C2=A0=C2=A0 =C2=A0sbi->mft.lbo2 =3D mlcn2 << cluster_bits; =C2=A0=C2=A0=C2=A0 =C2=A0/* Compare boot's cluster and sector. */ =C2=A0=C2=A0=C2=A0 =C2=A0if (sbi->cluster_size < boot_sector_size) @@ -804,7 +809,7 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0/* No way to use ntfs_get_bloc= k in this case. */ =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_err( =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sb, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0"Failed to mount = 'cause NTFS's cluster size (%u) is less=20 than media sector size (%u)", +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0"Failed to mount = 'cause NTFS's cluster size (%u) is less=20 than media sector size (%u).", =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sbi->cluste= r_size, sector_size); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} @@ -840,18 +845,18 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0gb0 =3D format_size_gb(dev_siz= e, &mb0); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_warn( =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sb, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0"RAW NTFS volume:= Filesystem size %u.%02u Gb > volume size=20 %u.%02u Gb. Mount in read-only", +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0"RAW NTFS volume:= Filesystem size %u.%02u Gb > volume size=20 %u.%02u Gb. Mount in read-only.", =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0gb, mb, gb0= , mb0); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sb->s_flags |=3D SB_RDONLY; =C2=A0=C2=A0=C2=A0 =C2=A0} -=C2=A0=C2=A0 =C2=A0clusters =3D sbi->volume.size >> sbi->cluster_bits; +=C2=A0=C2=A0 =C2=A0clusters =3D sbi->volume.size >> cluster_bits; =C2=A0#ifndef CONFIG_NTFS3_64BIT_CLUSTER =C2=A0=C2=A0=C2=A0 =C2=A0/* 32 bits per cluster. */ =C2=A0=C2=A0=C2=A0 =C2=A0if (clusters >> 32) { =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0ntfs_notice( =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sb, -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0"NTFS %u.%02u Gb = is too big to use 32 bits per cluster", +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0"NTFS %u.%02u Gb = is too big to use 32 bits per cluster.", =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0gb, mb); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0goto out; =C2=A0=C2=A0=C2=A0 =C2=A0} @@ -885,17 +890,17 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0 =C2=A0sbi->volume.blocks =3D sbi->volume.size >> sb->s_= blocksize_bits; =C2=A0=C2=A0=C2=A0 =C2=A0/* Maximum size for normal files. */ -=C2=A0=C2=A0 =C2=A0sbi->maxbytes =3D (clusters << sbi->cluster_bits) - 1; +=C2=A0=C2=A0 =C2=A0sbi->maxbytes =3D (clusters << cluster_bits) - 1; =C2=A0#ifdef CONFIG_NTFS3_64BIT_CLUSTER -=C2=A0=C2=A0 =C2=A0if (clusters >=3D (1ull << (64 - sbi->cluster_bits))) +=C2=A0=C2=A0 =C2=A0if (clusters >=3D (1ull << (64 - cluster_bits))) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sbi->maxbytes =3D -1; =C2=A0=C2=A0=C2=A0 =C2=A0sbi->maxbytes_sparse =3D -1; =C2=A0=C2=A0=C2=A0 =C2=A0sb->s_maxbytes =3D MAX_LFS_FILESIZE; =C2=A0#else =C2=A0=C2=A0=C2=A0 =C2=A0/* Maximum size for sparse file. */ -=C2=A0=C2=A0 =C2=A0sbi->maxbytes_sparse =3D (1ull << (sbi->cluster_bits + = 32)) - 1; -=C2=A0=C2=A0 =C2=A0sb->s_maxbytes =3D 0xFFFFFFFFull << sbi->cluster_bits; +=C2=A0=C2=A0 =C2=A0sbi->maxbytes_sparse =3D (1ull << (cluster_bits + 32)) = - 1; +=C2=A0=C2=A0 =C2=A0sb->s_maxbytes =3D 0xFFFFFFFFull << cluster_bits; =C2=A0#endif =C2=A0=C2=A0=C2=A0 =C2=A0/* @@ -903,7 +908,7 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0 =C2=A0 * It would be nice if we are able to allocate 1/= 8 of =C2=A0=C2=A0=C2=A0 =C2=A0 * total clusters for MFT but not more then 512 M= B. =C2=A0=C2=A0=C2=A0 =C2=A0 */ -=C2=A0=C2=A0 =C2=A0sbi->zone_max =3D min_t(CLST, 0x20000000 >> sbi->cluste= r_bits,=20 clusters >> 3); +=C2=A0=C2=A0 =C2=A0sbi->zone_max =3D min_t(CLST, 0x20000000 >> cluster_bit= s, clusters >> 3); =C2=A0=C2=A0=C2=A0 =C2=A0err =3D 0; @@ -1433,7 +1438,7 @@ static const struct fs_context_operations=20 ntfs_context_ops =3D { =C2=A0}; =C2=A0/* - * ntfs_init_fs_context - Initialize spi and opts + * ntfs_init_fs_context - Initialize sbi and opts =C2=A0 * =C2=A0 * This will called when mount/remount. We will first initialize =C2=A0 * options so that if remount we can use just that. @@ -1506,7 +1511,8 @@ static int __init init_ntfs_fs(void) =C2=A0=C2=A0=C2=A0 =C2=A0if (IS_ENABLED(CONFIG_NTFS3_FS_POSIX_ACL)) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0pr_info("ntfs3: Enabled Linux = POSIX ACLs support\n"); =C2=A0=C2=A0=C2=A0 =C2=A0if (IS_ENABLED(CONFIG_NTFS3_64BIT_CLUSTER)) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0pr_notice("ntfs3: Warning: Activated= 64 bits per cluster.=20 Windows does not support this\n"); +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0pr_notice( +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0"ntfs3: Warning: = Activated 64 bits per cluster. Windows=20 does not support this\n"); =C2=A0=C2=A0=C2=A0 =C2=A0if (IS_ENABLED(CONFIG_NTFS3_LZX_XPRESS)) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0pr_info("ntfs3: Read-only LZX/= Xpress compression included\n"); @@ -1549,7 +1555,9 @@ MODULE_DESCRIPTION("ntfs3 read/write filesystem"); =C2=A0MODULE_INFO(behaviour, "Enabled Linux POSIX ACLs support"); =C2=A0#endif =C2=A0#ifdef CONFIG_NTFS3_64BIT_CLUSTER -MODULE_INFO(cluster, "Warning: Activated 64 bits per cluster. Windows=20 does not support this"); +MODULE_INFO( +=C2=A0=C2=A0 =C2=A0cluster, +=C2=A0=C2=A0 =C2=A0"Warning: Activated 64 bits per cluster. Windows does n= ot support=20 this"); =C2=A0#endif =C2=A0#ifdef CONFIG_NTFS3_LZX_XPRESS =C2=A0MODULE_INFO(compression, "Read-only lzx/xpress compression included"= ); diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index 95c479d7ebba..0a6d2ec8c340 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -23,8 +23,8 @@ =C2=A0static inline size_t unpacked_ea_size(const struct EA_FULL *ea) =C2=A0{ -=C2=A0=C2=A0 =C2=A0return ea->size ? le32_to_cpu(ea->size) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0: ALIGN(struct_si= ze(ea, name, +=C2=A0=C2=A0 =C2=A0return ea->size ? le32_to_cpu(ea->size) : +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0ALIGN(struct_size(ea, name, =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 =C2=A0=C2=A0=C2=A0=C2=A0 1 + ea->name_len + =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 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 le16_to_= cpu(ea->elength)), =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=A04); --=20 2.34.1 From nobody Thu Sep 11 22:17:26 2025 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 E3870C636D4 for ; Wed, 15 Feb 2023 13:40:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230422AbjBONkJ (ORCPT ); Wed, 15 Feb 2023 08:40:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjBONkH (ORCPT ); Wed, 15 Feb 2023 08:40:07 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 033EB17176; Wed, 15 Feb 2023 05:40:00 -0800 (PST) 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 9EA59214E; Wed, 15 Feb 2023 13:35:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676468148; bh=rB9oY1q3nHZkv8dcWTH7MJPs0yxT5yMPWcoRYJN6cPo=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=cn/LgCeql+gT9wllgjxGK/meqSHPBA+zy76Kk67JJ9quCUT8HpNBYuHa9A6eGrnr+ EVOphhOgRmHkX8fZqsmB4/OgHRWFXezDR+Ng6RRmNiJW0APD2RuDWahNLcxnACTlPs wVvPpX9sN+e+uhQ7g4bhxjSJ9zLBwy9CU/jPrIDY= Received: from [192.168.211.36] (192.168.211.36) 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, 15 Feb 2023 16:39:58 +0300 Message-ID: <6551ad6b-9d90-edc3-920c-347a43216cd3@paragon-software.com> Date: Wed, 15 Feb 2023 17:39:57 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: [PATCH 10/11] fs/ntfs3: Add missed "nocase" in ntfs_show_options 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.36] 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 Sort processing ntfs3's mount options in same order they declared. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/super.c | 40 +++++++++++++++++++++------------------- =C2=A01 file changed, 21 insertions(+), 19 deletions(-) diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 6a412826b43d..521ce31d67a1 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -270,11 +270,11 @@ static const struct fs_parameter_spec=20 ntfs_fs_parameters[] =3D { =C2=A0=C2=A0=C2=A0 =C2=A0fsparam_flag_no("hidden",=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 =C2=A0Opt_nohidden), =C2=A0=C2=A0=C2=A0 =C2=A0fsparam_flag_no("hide_dot_files",=C2=A0=C2=A0 =C2= =A0Opt_hide_dot_files), =C2=A0=C2=A0=C2=A0 =C2=A0fsparam_flag_no("windows_names",=C2=A0=C2=A0 =C2= =A0Opt_windows_names), -=C2=A0=C2=A0 =C2=A0fsparam_flag_no("acl",=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 =C2=A0Opt_acl), =C2=A0=C2=A0=C2=A0 =C2=A0fsparam_flag_no("showmeta",=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 =C2=A0Opt_showmeta), +=C2=A0=C2=A0 =C2=A0fsparam_flag_no("acl",=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 =C2=A0Opt_acl), +=C2=A0=C2=A0 =C2=A0fsparam_string("iocharset",=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0Opt_iocharset), =C2=A0=C2=A0=C2=A0 =C2=A0fsparam_flag_no("prealloc",=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 =C2=A0Opt_prealloc), =C2=A0=C2=A0=C2=A0 =C2=A0fsparam_flag_no("nocase",=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 =C2=A0Opt_nocase), -=C2=A0=C2=A0 =C2=A0fsparam_string("iocharset",=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0Opt_iocharset), =C2=A0=C2=A0=C2=A0 =C2=A0{} =C2=A0}; @@ -364,6 +364,9 @@ static int ntfs_fs_parse_param(struct fs_context *fc, =C2=A0=C2=A0=C2=A0 =C2=A0case Opt_windows_names: =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0opts->windows_names =3D result= .negated ? 0 : 1; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0break; +=C2=A0=C2=A0 =C2=A0case Opt_showmeta: +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0opts->showmeta =3D result.negated ? = 0 : 1; +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0break; =C2=A0=C2=A0=C2=A0 =C2=A0case Opt_acl: =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0if (!result.negated) =C2=A0#ifdef CONFIG_NTFS3_FS_POSIX_ACL @@ -375,9 +378,6 @@ static int ntfs_fs_parse_param(struct fs_context *fc, =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0else =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0fc->sb_flag= s &=3D ~SB_POSIXACL; =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0break; -=C2=A0=C2=A0 =C2=A0case Opt_showmeta: -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0opts->showmeta =3D result.negated ? = 0 : 1; -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0break; =C2=A0=C2=A0=C2=A0 =C2=A0case Opt_iocharset: =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0kfree(opts->nls_name); =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0opts->nls_name =3D param->stri= ng; @@ -547,34 +547,36 @@ static int ntfs_show_options(struct seq_file *m,=20 struct dentry *root) =C2=A0=C2=A0=C2=A0 =C2=A0seq_printf(m, ",uid=3D%u", from_kuid_munged(user_= ns, opts->fs_uid)); =C2=A0=C2=A0=C2=A0 =C2=A0seq_printf(m, ",gid=3D%u", from_kgid_munged(user_= ns, opts->fs_gid)); -=C2=A0=C2=A0 =C2=A0if (opts->fmask) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_printf(m, ",fmask=3D%04o", opts-= >fs_fmask_inv ^ 0xffff); =C2=A0=C2=A0=C2=A0 =C2=A0if (opts->dmask) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_printf(m, ",dmask=3D%04o",= opts->fs_dmask_inv ^ 0xffff); -=C2=A0=C2=A0 =C2=A0if (opts->nls) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_printf(m, ",iocharset=3D%s", opt= s->nls->charset); -=C2=A0=C2=A0 =C2=A0else -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_puts(m, ",iocharset=3Dutf8"); +=C2=A0=C2=A0 =C2=A0if (opts->fmask) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_printf(m, ",fmask=3D%04o", opts-= >fs_fmask_inv ^ 0xffff); =C2=A0=C2=A0=C2=A0 =C2=A0if (opts->sys_immutable) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_puts(m, ",sys_immutable"); =C2=A0=C2=A0=C2=A0 =C2=A0if (opts->discard) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_puts(m, ",discard"); +=C2=A0=C2=A0 =C2=A0if (opts->force) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_puts(m, ",force"); =C2=A0=C2=A0=C2=A0 =C2=A0if (opts->sparse) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_puts(m, ",sparse"); -=C2=A0=C2=A0 =C2=A0if (opts->showmeta) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_puts(m, ",showmeta"); =C2=A0=C2=A0=C2=A0 =C2=A0if (opts->nohidden) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_puts(m, ",nohidden"); -=C2=A0=C2=A0 =C2=A0if (opts->windows_names) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_puts(m, ",windows_names"); =C2=A0=C2=A0=C2=A0 =C2=A0if (opts->hide_dot_files) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_puts(m, ",hide_dot_files"); -=C2=A0=C2=A0 =C2=A0if (opts->force) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_puts(m, ",force"); -=C2=A0=C2=A0 =C2=A0if (opts->prealloc) -=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_puts(m, ",prealloc"); +=C2=A0=C2=A0 =C2=A0if (opts->windows_names) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_puts(m, ",windows_names"); +=C2=A0=C2=A0 =C2=A0if (opts->showmeta) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_puts(m, ",showmeta"); =C2=A0=C2=A0=C2=A0 =C2=A0if (sb->s_flags & SB_POSIXACL) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_puts(m, ",acl"); +=C2=A0=C2=A0 =C2=A0if (opts->nls) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_printf(m, ",iocharset=3D%s", opt= s->nls->charset); +=C2=A0=C2=A0 =C2=A0else +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_puts(m, ",iocharset=3Dutf8"); +=C2=A0=C2=A0 =C2=A0if (opts->prealloc) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_puts(m, ",prealloc"); +=C2=A0=C2=A0 =C2=A0if (opts->nocase) +=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0seq_puts(m, ",nocase"); =C2=A0=C2=A0=C2=A0 =C2=A0return 0; =C2=A0} --=20 2.34.1 From nobody Thu Sep 11 22:17:26 2025 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 E3C04C636CC for ; Wed, 15 Feb 2023 13:40:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229786AbjBONkt (ORCPT ); Wed, 15 Feb 2023 08:40:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbjBONkq (ORCPT ); Wed, 15 Feb 2023 08:40:46 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC5E239BA7; Wed, 15 Feb 2023 05:40:32 -0800 (PST) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id A6769214E; Wed, 15 Feb 2023 13:36:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676468180; bh=usEtSMeyYHIotqRXwOxKAue/XOIiNzAb2X5xWL5CEHs=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=EvLNcaibd1xUrg3e27fMIGoIUwE91WtIo38z+Jbkhq3ssj459GNS2nJUK2LRr6bQt 1BxZKj09/ACU3rLC74LodHWsNLyxi+MBA4pAM0/ue8IrvSjOjvs924IC0kQupzPpO2 OWDcVyQ3GKstUv6Gi/ppbtZd4CV/9zymLxEqQQPA= 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 0CEA31E70; Wed, 15 Feb 2023 13:40:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676468431; bh=usEtSMeyYHIotqRXwOxKAue/XOIiNzAb2X5xWL5CEHs=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=iShuC2vNW9lGaviqam1oMitCEJxghHzmEpT82bYltbqSz2yEBgdo4Ugb1ycGkGcE1 vUtp925KMDlb8D3ZSMhOmCjBfOFqwiBMNhqI5bFqvG7Zo3x8uF2BK9JpQzFFu6QESl CZZAuzILkXtwCXlMNESk9tj1CKqJU5Da/hspyoNQ= Received: from [192.168.211.36] (192.168.211.36) 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, 15 Feb 2023 16:40:30 +0300 Message-ID: <48ebd481-dc1f-66fc-6888-5e82fd14af6e@paragon-software.com> Date: Wed, 15 Feb 2023 17:40:29 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: [PATCH 11/11] fs/ntfs3: Print details about mount fails 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.36] 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 Added error mesages with error codes. Minor refactoring and code formatting. Signed-off-by: Konstantin Komarov --- =C2=A0fs/ntfs3/frecord.c |=C2=A0=C2=A0 2 +- =C2=A0fs/ntfs3/fsntfs.c=C2=A0 |=C2=A0 40 +++++------ =C2=A0fs/ntfs3/super.c=C2=A0=C2=A0 | 172 +++++++++++++++++++++++++++------= ------------ =C2=A03 files changed, 122 insertions(+), 92 deletions(-) diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index 481219f2a7cf..2bfcf1a989c9 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -3360,7 +3360,7 @@ int ni_write_inode(struct inode *inode, int sync,=20 const char *hint) =C2=A0=C2=A0=C2=A0=C2=A0 ni_unlock(ni); =C2=A0=C2=A0=C2=A0=C2=A0 if (err) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "%s r=3D%lx failed, %d.= ", hint, inode->i_ino, err); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_inode_err(inode, "%s failed, %d= .", hint, err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_set_state(sbi, NTFS_DIRTY= _ERROR); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return err; =C2=A0=C2=A0=C2=A0=C2=A0 } diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index 0a82b1bf3ec2..28cc421102e5 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -223,7 +223,7 @@ int ntfs_extend_init(struct ntfs_sb_info *sbi) =C2=A0=C2=A0=C2=A0=C2=A0 inode =3D ntfs_iget5(sb, &ref, &NAME_EXTEND); =C2=A0=C2=A0=C2=A0=C2=A0 if (IS_ERR(inode)) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D PTR_ERR(inode); -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load $Extend= ."); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load $Extend= (%d).", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 inode =3D NULL; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } @@ -282,7 +282,7 @@ int ntfs_loadlog_and_replay(struct ntfs_inode *ni,=20 struct ntfs_sb_info *sbi) =C2=A0=C2=A0=C2=A0=C2=A0 /* Check for 4GB. */ =C2=A0=C2=A0=C2=A0=C2=A0 if (ni->vfs_inode.i_size >=3D 0x100000000ull) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "\x24LogFile is too big= "); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "\x24LogFile is large t= han 4G."); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D -EINVAL; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } @@ -1863,7 +1863,7 @@ int ntfs_security_init(struct ntfs_sb_info *sbi) =C2=A0=C2=A0=C2=A0=C2=A0 inode =3D ntfs_iget5(sb, &ref, &NAME_SECURE); =C2=A0=C2=A0=C2=A0=C2=A0 if (IS_ERR(inode)) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D PTR_ERR(inode); -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load $Secure= ."); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load $Secure= (%d).", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 inode =3D NULL; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } @@ -1874,45 +1874,43 @@ int ntfs_security_init(struct ntfs_sb_info *sbi) =C2=A0=C2=A0=C2=A0=C2=A0 attr =3D ni_find_attr(ni, NULL, &le, ATTR_ROOT, S= DH_NAME, =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 ARRAY_SIZE(SDH_NAME), NULL, NULL); -=C2=A0=C2=A0=C2=A0 if (!attr) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D -EINVAL; -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; -=C2=A0=C2=A0=C2=A0 } - -=C2=A0=C2=A0=C2=A0 if(!(root_sdh =3D resident_data_ex(attr, sizeof(struct = INDEX_ROOT))) || +=C2=A0=C2=A0=C2=A0 if (!attr || +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 !(root_sdh =3D resident_data_ex(attr= , sizeof(struct INDEX_ROOT))) || =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 root_sdh->type !=3D ATTR_ZERO = || =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 root_sdh->rule !=3D NTFS_COLLA= TION_TYPE_SECURITY_HASH || =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 offsetof(struct INDEX_ROOT, ih= dr) + -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 le32_to_cpu(root_= sdh->ihdr.used) > -=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 le32_to_cpu(root_sdh->ihdr.used) > +=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 ntfs_err(sb, "$Secure::$SDH is corru= pted."); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D -EINVAL; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 err =3D indx_init(indx_sdh, sbi, attr, INDEX_MUTE= X_SDH); -=C2=A0=C2=A0=C2=A0 if (err) +=C2=A0=C2=A0=C2=A0 if (err) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to initialize $= Secure::$SDH (%d).", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; +=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 attr =3D ni_find_attr(ni, attr, &le, ATTR_ROOT, S= II_NAME, =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 ARRAY_SIZE(SII_NAME), NULL, NULL); -=C2=A0=C2=A0=C2=A0 if (!attr) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D -EINVAL; -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; -=C2=A0=C2=A0=C2=A0 } - -=C2=A0=C2=A0=C2=A0 if(!(root_sii =3D resident_data_ex(attr, sizeof(struct = INDEX_ROOT))) || +=C2=A0=C2=A0=C2=A0 if (!attr || +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 !(root_sii =3D resident_data_ex(attr= , sizeof(struct INDEX_ROOT))) || =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 root_sii->type !=3D ATTR_ZERO = || =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 root_sii->rule !=3D NTFS_COLLA= TION_TYPE_UINT || =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 offsetof(struct INDEX_ROOT, ih= dr) + -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 le32_to_cpu(root_= sii->ihdr.used) > -=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 le32_to_cpu(root_sii->ihdr.used) > +=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 ntfs_err(sb, "$Secure::$SII is corru= pted."); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D -EINVAL; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 err =3D indx_init(indx_sii, sbi, attr, INDEX_MUTE= X_SII); -=C2=A0=C2=A0=C2=A0 if (err) +=C2=A0=C2=A0=C2=A0 if (err) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to initialize $= Secure::$SII (%d).", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; +=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 fnd_sii =3D fnd_get(); =C2=A0=C2=A0=C2=A0=C2=A0 if (!fnd_sii) { diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 521ce31d67a1..e0f78b306f15 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -734,48 +734,81 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0=C2=A0 err =3D -EINVAL; =C2=A0=C2=A0=C2=A0=C2=A0 boot =3D (struct NTFS_BOOT *)bh->b_data; -=C2=A0=C2=A0=C2=A0 if (memcmp(boot->system_id, "NTFS=C2=A0=C2=A0=C2=A0 ", = sizeof("NTFS=C2=A0=C2=A0=C2=A0 ") - 1)) +=C2=A0=C2=A0=C2=A0 if (memcmp(boot->system_id, "NTFS=C2=A0=C2=A0=C2=A0 ", = sizeof("NTFS=C2=A0=C2=A0=C2=A0 ") - 1)) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Boot's signature is no= t NTFS."); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; +=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 /* 0x55AA is not mandaroty. Thanks Maxim Suhanov*/ =C2=A0=C2=A0=C2=A0=C2=A0 /*if (0x55 !=3D boot->boot_magic[0] || 0xAA !=3D = boot->boot_magic[1]) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0*=C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0*/ -=C2=A0=C2=A0=C2=A0 boot_sector_size =3D (u32)boot->bytes_per_sector[1] << = 8; -=C2=A0=C2=A0=C2=A0 if (boot->bytes_per_sector[0] || boot_sector_size < SEC= TOR_SIZE || +=C2=A0=C2=A0=C2=A0 boot_sector_size =3D ((u32)boot->bytes_per_sector[1] <<= 8) | +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 boot= ->bytes_per_sector[0]; +=C2=A0=C2=A0=C2=A0 if (boot_sector_size < SECTOR_SIZE || =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 !is_power_of_2(boot_sector_siz= e)) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Invalid bytes per sect= or %u.", boot_sector_size); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 /* cluster size: 512, 1K, 2K, 4K, ... 2M */ =C2=A0=C2=A0=C2=A0=C2=A0 sct_per_clst =3D true_sectors_per_clst(boot); -=C2=A0=C2=A0=C2=A0 if ((int)sct_per_clst < 0) -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; -=C2=A0=C2=A0=C2=A0 if (!is_power_of_2(sct_per_clst)) +=C2=A0=C2=A0=C2=A0 if ((int)sct_per_clst < 0 || !is_power_of_2(sct_per_cls= t)) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Invalid sectors per cl= uster %u.", sct_per_clst); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; +=C2=A0=C2=A0=C2=A0 } + +=C2=A0=C2=A0=C2=A0 sbi->cluster_size =3D boot_sector_size * sct_per_clst; +=C2=A0=C2=A0=C2=A0 sbi->cluster_bits =3D cluster_bits =3D blksize_bits(sbi= ->cluster_size); +=C2=A0=C2=A0=C2=A0 sbi->cluster_mask =3D sbi->cluster_size - 1; +=C2=A0=C2=A0=C2=A0 sbi->cluster_mask_inv =3D ~(u64)sbi->cluster_mask; =C2=A0=C2=A0=C2=A0=C2=A0 mlcn =3D le64_to_cpu(boot->mft_clst); =C2=A0=C2=A0=C2=A0=C2=A0 mlcn2 =3D le64_to_cpu(boot->mft2_clst); =C2=A0=C2=A0=C2=A0=C2=A0 sectors =3D le64_to_cpu(boot->sectors_per_volume); -=C2=A0=C2=A0=C2=A0 if (mlcn * sct_per_clst >=3D sectors) +=C2=A0=C2=A0=C2=A0 if (mlcn * sct_per_clst >=3D sectors || mlcn2 * sct_per= _clst >=3D=20 sectors) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err( +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 sb, +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 "Start of MFT 0x%= llx (0x%llx) is out of volume 0x%llx.", +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 mlcn, mlcn2, sect= ors); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; +=C2=A0=C2=A0=C2=A0 } -=C2=A0=C2=A0=C2=A0 if (mlcn2 * sct_per_clst >=3D sectors) -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; +=C2=A0=C2=A0=C2=A0 sbi->record_size =3D record_size =3D +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 boot->record_size < 0 ? 1 << (-boot-= >record_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 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (u32)boot->record_siz= e << cluster_bits; +=C2=A0=C2=A0=C2=A0 sbi->record_bits =3D blksize_bits(record_size); +=C2=A0=C2=A0=C2=A0 sbi->attr_size_tr =3D (5 * record_size >> 4); // ~320 b= ytes =C2=A0=C2=A0=C2=A0=C2=A0 /* Check MFT record size. */ -=C2=A0=C2=A0=C2=A0 if ((boot->record_size < 0 && -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 SECTOR_SIZE > (2U << (-boot->r= ecord_size))) || -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (boot->record_size >=3D 0 && !is_pow= er_of_2(boot->record_size))) { +=C2=A0=C2=A0=C2=A0 if (record_size < SECTOR_SIZE || !is_power_of_2(record_= size)) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Invalid bytes per MFT = record %u (%d).", +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0record_size= , boot->record_size); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; +=C2=A0=C2=A0=C2=A0 } + +=C2=A0=C2=A0=C2=A0 if (record_size > MAXIMUM_BYTES_PER_MFT) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Unsupported bytes per = MFT record %u.", +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0record_size= ); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } +=C2=A0=C2=A0=C2=A0 sbi->index_size =3D boot->index_size < 0 ? +=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 1u << (-boot->index_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 (u32)boot->index_size << cluster_bits; + =C2=A0=C2=A0=C2=A0=C2=A0 /* Check index record size. */ -=C2=A0=C2=A0=C2=A0 if ((boot->index_size < 0 && -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 SECTOR_SIZE > (2U << (-boot->i= ndex_size))) || -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (boot->index_size >=3D 0 && !is_powe= r_of_2(boot->index_size))) { +=C2=A0=C2=A0=C2=A0 if (sbi->index_size < SECTOR_SIZE || !is_power_of_2(sbi= ->index_size)) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Invalid bytes per inde= x %u(%d).", sbi->index_size, +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0boot->index= _size); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; +=C2=A0=C2=A0=C2=A0 } + +=C2=A0=C2=A0=C2=A0 if (sbi->index_size > MAXIMUM_BYTES_PER_INDEX) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Unsupported bytes per = index %u.", +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sbi->index_= size); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } @@ -796,15 +829,15 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 dev_size +=3D sector_size - 1; =C2=A0=C2=A0=C2=A0=C2=A0 } -=C2=A0=C2=A0=C2=A0 sbi->cluster_size =3D boot_sector_size * sct_per_clst; -=C2=A0=C2=A0=C2=A0 sbi->cluster_bits =3D blksize_bits(sbi->cluster_size); - =C2=A0=C2=A0=C2=A0=C2=A0 sbi->mft.lbo =3D mlcn << cluster_bits; =C2=A0=C2=A0=C2=A0=C2=A0 sbi->mft.lbo2 =3D mlcn2 << cluster_bits; =C2=A0=C2=A0=C2=A0=C2=A0 /* Compare boot's cluster and sector. */ -=C2=A0=C2=A0=C2=A0 if (sbi->cluster_size < boot_sector_size) +=C2=A0=C2=A0=C2=A0 if (sbi->cluster_size < boot_sector_size) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Invalid bytes per clus= ter (%u).", +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0sbi->cluste= r_size); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; +=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 /* Compare boot's cluster and media sector. */ =C2=A0=C2=A0=C2=A0=C2=A0 if (sbi->cluster_size < sector_size) { @@ -816,28 +849,11 @@ static int ntfs_init_from_boot(struct super_block=20 *sb, u32 sector_size, =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } -=C2=A0=C2=A0=C2=A0 sbi->cluster_mask =3D sbi->cluster_size - 1; -=C2=A0=C2=A0=C2=A0 sbi->cluster_mask_inv =3D ~(u64)sbi->cluster_mask; -=C2=A0=C2=A0=C2=A0 sbi->record_size =3D record_size =3D boot->record_size = < 0 -=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 =C2=A0=C2=A0=C2=A0 =C2=A0? 1 << (-boot->record_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 =C2=A0=C2=A0=C2=A0 =C2=A0: (u32)boot->record_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 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 <= < sbi->cluster_bits; - -=C2=A0=C2=A0=C2=A0 if (record_size > MAXIMUM_BYTES_PER_MFT || record_size = < SECTOR_SIZE) -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; - -=C2=A0=C2=A0=C2=A0 sbi->record_bits =3D blksize_bits(record_size); -=C2=A0=C2=A0=C2=A0 sbi->attr_size_tr =3D (5 * record_size >> 4); // ~320 b= ytes - =C2=A0=C2=A0=C2=A0=C2=A0 sbi->max_bytes_per_attr =3D =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 record_size - ALIGN(MFTRECORD_= FIXUP_OFFSET_1, 8) - =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ALIGN(((record_size >> SECTOR_= SHIFT) * sizeof(short)), 8) - =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ALIGN(sizeof(enum ATTR_TYPE), = 8); -=C2=A0=C2=A0=C2=A0 sbi->index_size =3D boot->index_size < 0 -=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 ? 1u << (-boot->index_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 : (u32)boot->index_size << sbi->cluster_bits; - =C2=A0=C2=A0=C2=A0=C2=A0 sbi->volume.ser_num =3D le64_to_cpu(boot->serial_= num); =C2=A0=C2=A0=C2=A0=C2=A0 /* Warning if RAW volume. */ @@ -928,6 +944,7 @@ static int ntfs_fill_super(struct super_block *sb,=20 struct fs_context *fc) =C2=A0=C2=A0=C2=A0=C2=A0 int err; =C2=A0=C2=A0=C2=A0=C2=A0 struct ntfs_sb_info *sbi =3D sb->s_fs_info; =C2=A0=C2=A0=C2=A0=C2=A0 struct block_device *bdev =3D sb->s_bdev; +=C2=A0=C2=A0=C2=A0 struct ntfs_mount_options *options; =C2=A0=C2=A0=C2=A0=C2=A0 struct inode *inode; =C2=A0=C2=A0=C2=A0=C2=A0 struct ntfs_inode *ni; =C2=A0=C2=A0=C2=A0=C2=A0 size_t i, tt, bad_len, bad_frags; @@ -942,7 +959,7 @@ static int ntfs_fill_super(struct super_block *sb,=20 struct fs_context *fc) =C2=A0=C2=A0=C2=A0=C2=A0 ref.high =3D 0; =C2=A0=C2=A0=C2=A0=C2=A0 sbi->sb =3D sb; -=C2=A0=C2=A0=C2=A0 sbi->options =3D fc->fs_private; +=C2=A0=C2=A0=C2=A0 sbi->options =3D options =3D fc->fs_private; =C2=A0=C2=A0=C2=A0=C2=A0 fc->fs_private =3D NULL; =C2=A0=C2=A0=C2=A0=C2=A0 sb->s_flags |=3D SB_NODIRATIME; =C2=A0=C2=A0=C2=A0=C2=A0 sb->s_magic =3D 0x7366746e; // "ntfs" @@ -950,12 +967,12 @@ static int ntfs_fill_super(struct super_block *sb,=20 struct fs_context *fc) =C2=A0=C2=A0=C2=A0=C2=A0 sb->s_export_op =3D &ntfs_export_ops; =C2=A0=C2=A0=C2=A0=C2=A0 sb->s_time_gran =3D NTFS_TIME_GRAN; // 100 nsec =C2=A0=C2=A0=C2=A0=C2=A0 sb->s_xattr =3D ntfs_xattr_handlers; -=C2=A0=C2=A0=C2=A0 sb->s_d_op =3D sbi->options->nocase ? &ntfs_dentry_ops = : NULL; +=C2=A0=C2=A0=C2=A0 sb->s_d_op =3D options->nocase ? &ntfs_dentry_ops : NUL= L; -=C2=A0=C2=A0=C2=A0 sbi->options->nls =3D ntfs_load_nls(sbi->options->nls_n= ame); -=C2=A0=C2=A0=C2=A0 if (IS_ERR(sbi->options->nls)) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 sbi->options->nls =3D NULL; -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 errorf(fc, "Cannot load nls %s", sbi= ->options->nls_name); +=C2=A0=C2=A0=C2=A0 options->nls =3D ntfs_load_nls(options->nls_name); +=C2=A0=C2=A0=C2=A0 if (IS_ERR(options->nls)) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 options->nls =3D NULL; +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 errorf(fc, "Cannot load nls %s", opt= ions->nls_name); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D -EINVAL; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } @@ -980,8 +997,8 @@ static int ntfs_fill_super(struct super_block *sb,=20 struct fs_context *fc) =C2=A0=C2=A0=C2=A0=C2=A0 ref.seq =3D cpu_to_le16(MFT_REC_VOL); =C2=A0=C2=A0=C2=A0=C2=A0 inode =3D ntfs_iget5(sb, &ref, &NAME_VOLUME); =C2=A0=C2=A0=C2=A0=C2=A0 if (IS_ERR(inode)) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load $Volume= ."); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D PTR_ERR(inode); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load $Volume= (%d).", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } @@ -1007,13 +1024,9 @@ static int ntfs_fill_super(struct super_block=20 *sb, struct fs_context *fc) =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 attr =3D ni_find_attr(ni, attr, NULL, ATTR_VOL_IN= FO, NULL, 0, NULL,=20 NULL); -=C2=A0=C2=A0=C2=A0 if (!attr || is_attr_ext(attr)) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D -EINVAL; -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto put_inode_out; -=C2=A0=C2=A0=C2=A0 } - -=C2=A0=C2=A0=C2=A0 info =3D resident_data_ex(attr, SIZEOF_ATTRIBUTE_VOLUME= _INFO); -=C2=A0=C2=A0=C2=A0 if (!info) { +=C2=A0=C2=A0=C2=A0 if (!attr || is_attr_ext(attr) || +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 !(info =3D resident_data_ex(attr, SI= ZEOF_ATTRIBUTE_VOLUME_INFO))) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "$Volume is corrupted."= ); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D -EINVAL; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto put_inode_out; =C2=A0=C2=A0=C2=A0=C2=A0 } @@ -1028,13 +1041,13 @@ static int ntfs_fill_super(struct super_block=20 *sb, struct fs_context *fc) =C2=A0=C2=A0=C2=A0=C2=A0 ref.seq =3D cpu_to_le16(MFT_REC_MIRR); =C2=A0=C2=A0=C2=A0=C2=A0 inode =3D ntfs_iget5(sb, &ref, &NAME_MIRROR); =C2=A0=C2=A0=C2=A0=C2=A0 if (IS_ERR(inode)) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load $MFTMir= r."); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D PTR_ERR(inode); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load $MFTMir= r (%d).", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } -=C2=A0=C2=A0=C2=A0 sbi->mft.recs_mirr =3D -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_up_cluster(sbi, inode->i_size) = >> sbi->record_bits; +=C2=A0=C2=A0=C2=A0 sbi->mft.recs_mirr =3D ntfs_up_cluster(sbi, inode->i_si= ze) >> +=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 sbi->record_bits; =C2=A0=C2=A0=C2=A0=C2=A0 iput(inode); @@ -1043,8 +1056,8 @@ static int ntfs_fill_super(struct super_block *sb,=20 struct fs_context *fc) =C2=A0=C2=A0=C2=A0=C2=A0 ref.seq =3D cpu_to_le16(MFT_REC_LOG); =C2=A0=C2=A0=C2=A0=C2=A0 inode =3D ntfs_iget5(sb, &ref, &NAME_LOGFILE); =C2=A0=C2=A0=C2=A0=C2=A0 if (IS_ERR(inode)) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load \x24Log= File."); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D PTR_ERR(inode); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load \x24Log= File (%d).", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } @@ -1064,7 +1077,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=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 } else if (sbi->volume.flags & VOLUME_FLAG_DIRTY)= { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (!sb_rdonly(sb) && !sbi->options-= >force) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (!sb_rdonly(sb) && !options->forc= e) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_warn( =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 sb, =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 "volume is dirty and \"force\" flag is not set!"); @@ -1079,8 +1092,8 @@ static int ntfs_fill_super(struct super_block *sb,=20 struct fs_context *fc) =C2=A0=C2=A0=C2=A0=C2=A0 inode =3D ntfs_iget5(sb, &ref, &NAME_MFT); =C2=A0=C2=A0=C2=A0=C2=A0 if (IS_ERR(inode)) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load $MFT."); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D PTR_ERR(inode); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load $MFT (%= d).", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } @@ -1095,8 +1108,10 @@ static int ntfs_fill_super(struct super_block=20 *sb, struct fs_context *fc) =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto put_inode_out; =C2=A0=C2=A0=C2=A0=C2=A0 err =3D ni_load_all_mi(ni); -=C2=A0=C2=A0=C2=A0 if (err) +=C2=A0=C2=A0=C2=A0 if (err) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load $MFT's = subrecords (%d).", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto put_inode_out; +=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 sbi->mft.ni =3D ni; @@ -1105,8 +1120,8 @@ static int ntfs_fill_super(struct super_block *sb,=20 struct fs_context *fc) =C2=A0=C2=A0=C2=A0=C2=A0 ref.seq =3D cpu_to_le16(MFT_REC_BITMAP); =C2=A0=C2=A0=C2=A0=C2=A0 inode =3D ntfs_iget5(sb, &ref, &NAME_BITMAP); =C2=A0=C2=A0=C2=A0=C2=A0 if (IS_ERR(inode)) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load $Bitmap= ."); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D PTR_ERR(inode); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load $Bitmap= (%d).", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } @@ -1120,20 +1135,25 @@ static int ntfs_fill_super(struct super_block=20 *sb, struct fs_context *fc) =C2=A0=C2=A0=C2=A0=C2=A0 /* Check bitmap boundary. */ =C2=A0=C2=A0=C2=A0=C2=A0 tt =3D sbi->used.bitmap.nbits; =C2=A0=C2=A0=C2=A0=C2=A0 if (inode->i_size < bitmap_size(tt)) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "$Bitmap is corrupted."= ); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D -EINVAL; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto put_inode_out; =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 err =3D wnd_init(&sbi->used.bitmap, sb, tt); -=C2=A0=C2=A0=C2=A0 if (err) +=C2=A0=C2=A0=C2=A0 if (err) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to initialize $= Bitmap (%d).", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto put_inode_out; +=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 iput(inode); =C2=A0=C2=A0=C2=A0=C2=A0 /* Compute the MFT zone. */ =C2=A0=C2=A0=C2=A0=C2=A0 err =3D ntfs_refresh_zone(sbi); -=C2=A0=C2=A0=C2=A0 if (err) +=C2=A0=C2=A0=C2=A0 if (err) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to initialize M= FT zone (%d).", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; +=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 /* Load $BadClus. */ =C2=A0=C2=A0=C2=A0=C2=A0 ref.low =3D cpu_to_le32(MFT_REC_BADCLUST); @@ -1178,8 +1198,8 @@ static int ntfs_fill_super(struct super_block *sb,=20 struct fs_context *fc) =C2=A0=C2=A0=C2=A0=C2=A0 ref.seq =3D cpu_to_le16(MFT_REC_ATTR); =C2=A0=C2=A0=C2=A0=C2=A0 inode =3D ntfs_iget5(sb, &ref, &NAME_ATTRDEF); =C2=A0=C2=A0=C2=A0=C2=A0 if (IS_ERR(inode)) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load $AttrDe= f -> %d", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D PTR_ERR(inode); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load $AttrDe= f (%d)", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } @@ -1208,6 +1228,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 if (IS_ERR(page)) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D PTR= _ERR(page); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Fai= led to read $AttrDef (%d).", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto put_in= ode_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=C2=A0 memcpy(Add2Ptr(t, done), page_= address(page), @@ -1215,6 +1236,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 ntfs_unmap_page(page); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (!idx && ATTR_STD !=3D t->t= ype) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "$At= trDef is corrupted."); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D -EI= NVAL; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto put_in= ode_out; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 } @@ -1249,13 +1271,14 @@ static int ntfs_fill_super(struct super_block=20 *sb, struct fs_context *fc) =C2=A0=C2=A0=C2=A0=C2=A0 ref.seq =3D cpu_to_le16(MFT_REC_UPCASE); =C2=A0=C2=A0=C2=A0=C2=A0 inode =3D ntfs_iget5(sb, &ref, &NAME_UPCASE); =C2=A0=C2=A0=C2=A0=C2=A0 if (IS_ERR(inode)) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load $UpCase= ."); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D PTR_ERR(inode); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load $UpCase= (%d).", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 if (inode->i_size !=3D 0x10000 * sizeof(short)) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D -EINVAL; +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "$UpCase is corrupted."= ); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto put_inode_out; =C2=A0=C2=A0=C2=A0=C2=A0 } @@ -1266,6 +1289,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 if (IS_ERR(page)) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D PTR= _ERR(page); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Fai= led to read $UpCase (%d).", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto put_in= ode_out; =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 } @@ -1291,23 +1315,31 @@ static int ntfs_fill_super(struct super_block=20 *sb, struct fs_context *fc) =C2=A0=C2=A0=C2=A0=C2=A0 if (is_ntfs3(sbi)) { =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 /* Load $Secure. */ =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D ntfs_security_init(sbi= ); -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (err) +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (err) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Fai= led to initialize $Secure (%d).", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto 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 /* Load $Extend. */ =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D ntfs_extend_init(sbi); -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (err) +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (err) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_warn(sb, "Fa= iled to initialize $Extend."); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto load_r= oot; +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 } -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 /* Load $Extend\$Reparse. */ +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 /* Load $Extend/$Reparse. */ =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D ntfs_reparse_init(sbi); -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (err) +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (err) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_warn(sb, "Fa= iled to initialize $Extend/$Reparse."); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto load_r= oot; +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 } -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 /* Load $Extend\$ObjId. */ +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 /* Load $Extend/$ObjId. */ =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D ntfs_objid_init(sbi); -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (err) +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 if (err) { +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_warn(sb, "Fa= iled to initialize $Extend/$ObjId."); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto load_r= oot; +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0load_root: @@ -1316,8 +1348,8 @@ static int ntfs_fill_super(struct super_block *sb,=20 struct fs_context *fc) =C2=A0=C2=A0=C2=A0=C2=A0 ref.seq =3D cpu_to_le16(MFT_REC_ROOT); =C2=A0=C2=A0=C2=A0=C2=A0 inode =3D ntfs_iget5(sb, &ref, &NAME_ROOT); =C2=A0=C2=A0=C2=A0=C2=A0 if (IS_ERR(inode) || !inode->i_op) { -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load root."); -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D IS_ERR(inode) ? PTR_ERR(inod= e) : -EINVAL; +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 err =3D PTR_ERR(inode); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ntfs_err(sb, "Failed to load root (%= d).", err); =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 } --=20 2.34.1