From patchwork Mon Sep 12 16:39:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 12973805 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 1D41BECAAD5 for ; Mon, 12 Sep 2022 16:39:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229924AbiILQj0 (ORCPT ); Mon, 12 Sep 2022 12:39:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229591AbiILQjX (ORCPT ); Mon, 12 Sep 2022 12:39:23 -0400 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A842222AC; Mon, 12 Sep 2022 09:39:22 -0700 (PDT) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 055772265; Mon, 12 Sep 2022 16:37:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1663000641; bh=k1qhfi942LE6et0zq9FDdggKuBLOcG1Kzr/POuv/F9w=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=VECAkElB4j3C9MnLL7fUB58mtTdpPtNMIDC7Ail0aFvOwf2QsVZarsXMqa7SiwQSY tRk/7GoRc6L58P2FaEoKZ+wT8+BnPmP6b8qZrqifjHvYZHRZEZtm7VlhJnjy2ZLTfF hsvKdbuje0b2ozaE7ZnMChrAYDAvncsvvtJGV9zo= 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 AC2DD22FE; Mon, 12 Sep 2022 16:39:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1663000760; bh=k1qhfi942LE6et0zq9FDdggKuBLOcG1Kzr/POuv/F9w=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=ZUyYOR9NMBKInXXOIIOZNPUM8MAVqRQ5n6Kummmv3Y3xq7jwFfA4qisbK758Nbo9U SOhWV0nbgkSpzCsgup64/vGqL4FUa/IcwAy8vv1c+6FtAJ1/bkHkKLtbuac3Po/IBi iXQshGkpAWgPuGflFfLkAO9Jd5ibYBY/DwcCoaLY= Received: from [172.30.8.65] (172.30.8.65) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Mon, 12 Sep 2022 19:39:20 +0300 Message-ID: Date: Mon, 12 Sep 2022 19:39:19 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: [PATCH 1/3] fs/ntfs3: Add comments about cluster size Content-Language: en-US From: Konstantin Komarov To: CC: , References: <59960918-0adb-6d53-2d77-8172e666bf40@paragon-software.com> In-Reply-To: <59960918-0adb-6d53-2d77-8172e666bf40@paragon-software.com> X-Originating-IP: [172.30.8.65] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This commit adds additional info about CONFIG_NTFS3_64BIT_CLUSTER Signed-off-by: Konstantin Komarov --- fs/ntfs3/frecord.c | 2 +- fs/ntfs3/record.c | 4 ++++ fs/ntfs3/super.c | 24 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index 381a38a06ec2..b752d83cf460 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -557,7 +557,7 @@ static int ni_repack(struct ntfs_inode *ni) } if (!mi_p) { - /* Do not try if not enogh free space. */ + /* Do not try if not enough free space. */ if (le32_to_cpu(mi->mrec->used) + 8 >= rs) continue; diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c index 7d2fac5ee215..c8741cfa421f 100644 --- a/fs/ntfs3/record.c +++ b/fs/ntfs3/record.c @@ -537,6 +537,10 @@ bool mi_resize_attr(struct mft_inode *mi, struct ATTRIB *attr, int bytes) return true; } +/* + * Pack runs in MFT record. + * If failed record is not changed. + */ int mi_pack_runs(struct mft_inode *mi, struct ATTRIB *attr, struct runs_tree *run, CLST len) { diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 47012c9bf505..86ff55133faf 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -21,6 +21,30 @@ * https://docs.microsoft.com/en-us/windows/wsl/file-permissions * It stores uid/gid/mode/dev in xattr * + * ntfs allows up to 2^64 clusters per volume. + * It means you should use 64 bits lcn to operate with ntfs. + * Implementation of ntfs.sys uses only 32 bits lcn. + * Default ntfs3 uses 32 bits lcn too. + * ntfs3 built with CONFIG_NTFS3_64BIT_CLUSTER (ntfs3_64) uses 64 bits per lcn. + * + * + * ntfs limits, cluster size is 4K (2^12) + * ----------------------------------------------------------------------------- + * | Volume size | Clusters | ntfs.sys | ntfs3 | ntfs3_64 | mkntfs | chkdsk | + * ----------------------------------------------------------------------------- + * | < 16T, 2^44 | < 2^32 | yes | yes | yes | yes | yes | + * | > 16T, 2^44 | > 2^32 | no | no | yes | yes | yes | + * ----------------------------------------------------------|------------------ + * + * To mount large volumes as ntfs one should use large cluster size (up to 2M) + * The maximum volume size in this case is 2^32 * 2^21 = 2^53 = 8P + * + * ntfs limits, cluster size is 2M (2^31) + * ----------------------------------------------------------------------------- + * | < 8P, 2^54 | < 2^32 | yes | yes | yes | yes | yes | + * | > 8P, 2^54 | > 2^32 | no | no | yes | yes | yes | + * ----------------------------------------------------------|------------------ + * */ #include From patchwork Mon Sep 12 16:40:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 12973806 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 AFA33C6FA82 for ; Mon, 12 Sep 2022 16:40:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229617AbiILQkF (ORCPT ); Mon, 12 Sep 2022 12:40:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbiILQkE (ORCPT ); Mon, 12 Sep 2022 12:40:04 -0400 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA5DD12D2D; Mon, 12 Sep 2022 09:40:02 -0700 (PDT) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 3E1B22265; Mon, 12 Sep 2022 16:38:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1663000681; bh=1a2OBAbi4gKtku0aJDgWDysekTB5Toxc3MphEpcWgNc=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=E3UEcihC8pWHCDEEyN7d0HGaU1D2sJsQWeRwNydtJWpquUk4p+0bupa+SuVnnRw5W MVIcT+q7zUmTmeTg4Q+98d6lNoHzW9ghJlxjZOFS0wtQkxR2OondqQoALL1WaTWLKq AhgH+1HPsSB8IgdWZGDs2f4J+2ejgritX6L7RXqI= Received: from [172.30.8.65] (172.30.8.65) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Mon, 12 Sep 2022 19:40:00 +0300 Message-ID: <1194d7b9-658f-b724-93d4-2f2b02b569ca@paragon-software.com> Date: Mon, 12 Sep 2022 19:40:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: [PATCH 2/3] fs/ntfs3: Add hidedotfiles option Content-Language: en-US From: Konstantin Komarov To: CC: , References: <59960918-0adb-6d53-2d77-8172e666bf40@paragon-software.com> In-Reply-To: <59960918-0adb-6d53-2d77-8172e666bf40@paragon-software.com> X-Originating-IP: [172.30.8.65] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org With this option all files with filename[0] == '.' will have FILE_ATTRIBUTE_HIDDEN attribute. Signed-off-by: Konstantin Komarov --- fs/ntfs3/inode.c | 4 ++++ fs/ntfs3/ntfs_fs.h | 1 + fs/ntfs3/super.c | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 51363d4e8636..40b8565815a2 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -1257,6 +1257,10 @@ struct inode *ntfs_create_inode(struct user_namespace *mnt_userns, fa = FILE_ATTRIBUTE_ARCHIVE; } + /* If option "hidedotfiles" then set hidden attribute for dot files. */ + if (sbi->options->hide_dot_files && name->name[0] == '.') + fa |= FILE_ATTRIBUTE_HIDDEN; + if (!(mode & 0222)) fa |= FILE_ATTRIBUTE_READONLY; diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 2c791222c4e2..cd680ada50ab 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -97,6 +97,7 @@ struct ntfs_mount_options { unsigned sparse : 1; /* Create sparse files. */ unsigned showmeta : 1; /* Show meta files. */ unsigned nohidden : 1; /* Do not show hidden files. */ + unsigned hide_dot_files : 1; /* Set hidden flag on dot files. */ unsigned force : 1; /* RW mount dirty volume. */ unsigned noacsrules : 1; /* Exclude acs rules. */ unsigned prealloc : 1; /* Preallocate space when file is growing. */ diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 86ff55133faf..067a0e9cf590 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -247,6 +247,7 @@ enum Opt { Opt_force, Opt_sparse, Opt_nohidden, + Opt_hide_dot_files, Opt_showmeta, Opt_acl, Opt_iocharset, @@ -266,6 +267,7 @@ static const struct fs_parameter_spec ntfs_fs_parameters[] = { fsparam_flag_no("force", Opt_force), fsparam_flag_no("sparse", Opt_sparse), fsparam_flag_no("hidden", Opt_nohidden), + fsparam_flag_no("hidedotfiles", Opt_hide_dot_files), fsparam_flag_no("acl", Opt_acl), fsparam_flag_no("showmeta", Opt_showmeta), fsparam_flag_no("prealloc", Opt_prealloc), @@ -357,6 +359,9 @@ static int ntfs_fs_parse_param(struct fs_context *fc, case Opt_nohidden: opts->nohidden = result.negated ? 1 : 0; break; + case Opt_hide_dot_files: + opts->hide_dot_files = result.negated ? 1 : 0; + break; case Opt_acl: if (!result.negated) #ifdef CONFIG_NTFS3_FS_POSIX_ACL From patchwork Mon Sep 12 16:40:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 12973807 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 BD5E9C6FA82 for ; Mon, 12 Sep 2022 16:40:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229700AbiILQks (ORCPT ); Mon, 12 Sep 2022 12:40:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbiILQkq (ORCPT ); Mon, 12 Sep 2022 12:40:46 -0400 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A33C25C6B; Mon, 12 Sep 2022 09:40:45 -0700 (PDT) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 122C32265; Mon, 12 Sep 2022 16:38:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1663000724; bh=/ZtGhq6EJuhIvLQh59RiN21gsyK9NnlVonHDvDAOoGY=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=r9NH0yXlHfBsMAc42IRDXyiaFVIBeKMdDBRfbpM7mPPPQ5btS1rMDflXCQLXM7IGj oya1oXts+jf1QJYEvwW3XHiXl86Fmm9J7NFReA6WERFhqKaZT/btyhpeqbOEdrXgTD 8kQgMpaOYUxTKPBSxpEcYJjKwcgeaMxz2jzsW95I= 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 A78F522FE; Mon, 12 Sep 2022 16:40:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1663000843; bh=/ZtGhq6EJuhIvLQh59RiN21gsyK9NnlVonHDvDAOoGY=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=DIM0XMkCn5bWwJMSEOYlV5cj26bWWtJduJYTNvgNFXBpFfEW5Urz2J8mSQkmIgjox BuVUHDTuOiQ8lSjNNbOBvIQofPILnXTckKaYLC9rSByjRSlekX94VQgeSYPy6yi+9S BUKq28S05qTcBHc07rhcnI+Cw5YHuM555oJ7aXpY= Received: from [172.30.8.65] (172.30.8.65) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Mon, 12 Sep 2022 19:40:43 +0300 Message-ID: Date: Mon, 12 Sep 2022 19:40:42 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: [PATCH 3/3] fs/ntfs3: Change destroy_inode to free_inode Content-Language: en-US From: Konstantin Komarov To: CC: , References: <59960918-0adb-6d53-2d77-8172e666bf40@paragon-software.com> In-Reply-To: <59960918-0adb-6d53-2d77-8172e666bf40@paragon-software.com> X-Originating-IP: [172.30.8.65] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Many filesystems already use free_inode callback, so we will use it too from now on. Signed-off-by: Konstantin Komarov --- fs/ntfs3/super.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 067a0e9cf590..744c1f15ba2a 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -438,27 +438,18 @@ static struct inode *ntfs_alloc_inode(struct super_block *sb) return NULL; memset(ni, 0, offsetof(struct ntfs_inode, vfs_inode)); - mutex_init(&ni->ni_lock); - return &ni->vfs_inode; } -static void ntfs_i_callback(struct rcu_head *head) +static void ntfs_free_inode(struct inode *inode) { - struct inode *inode = container_of(head, struct inode, i_rcu); struct ntfs_inode *ni = ntfs_i(inode); mutex_destroy(&ni->ni_lock); - kmem_cache_free(ntfs_inode_cachep, ni); } -static void ntfs_destroy_inode(struct inode *inode) -{ - call_rcu(&inode->i_rcu, ntfs_i_callback); -} - static void init_once(void *foo) { struct ntfs_inode *ni = foo; @@ -624,7 +615,7 @@ static int ntfs_sync_fs(struct super_block *sb, int wait) static const struct super_operations ntfs_sops = { .alloc_inode = ntfs_alloc_inode, - .destroy_inode = ntfs_destroy_inode, + .free_inode = ntfs_free_inode, .evict_inode = ntfs_evict_inode, .put_super = ntfs_put_super, .statfs = ntfs_statfs, @@ -1520,11 +1511,8 @@ static int __init init_ntfs_fs(void) static void __exit exit_ntfs_fs(void) { - if (ntfs_inode_cachep) { - rcu_barrier(); - kmem_cache_destroy(ntfs_inode_cachep); - } - + rcu_barrier(); + kmem_cache_destroy(ntfs_inode_cachep); unregister_filesystem(&ntfs_fs_type); ntfs3_exit_bitmap(); }