]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
fs/ntfs3: Redesign legacy ntfs support
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Mon, 17 Jun 2024 12:03:21 +0000 (15:03 +0300)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Thu, 11 Jul 2024 09:19:45 +0000 (12:19 +0300)
1) Make is_legacy_ntfs static inline.
2) Put legacy file_operations under #if IS_ENABLED(CONFIG_NTFS_FS).

Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Christian Brauner <brauner@kernel.org>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
fs/ntfs3/dir.c
fs/ntfs3/file.c
fs/ntfs3/inode.c
fs/ntfs3/ntfs_fs.h
fs/ntfs3/super.c

index 1ec09f2fca64a74dbac5eb9ef6f43306a29596f0..fc6a8aa29e3afe0c864a42f717143a811d0dd6cd 100644 (file)
@@ -631,10 +631,12 @@ const struct file_operations ntfs_dir_operations = {
 #endif
 };
 
+#if IS_ENABLED(CONFIG_NTFS_FS)
 const struct file_operations ntfs_legacy_dir_operations = {
        .llseek         = generic_file_llseek,
        .read           = generic_read_dir,
        .iterate_shared = ntfs_readdir,
        .open           = ntfs_file_open,
 };
+#endif
 // clang-format on
index 2ceb762dc679918142469d4f823d3d9c590d6e43..e95e9ffe6c0fbc5977eb94b199f4f1dd5bfb510d 100644 (file)
@@ -1242,6 +1242,7 @@ const struct file_operations ntfs_file_operations = {
        .release        = ntfs_file_release,
 };
 
+#if IS_ENABLED(CONFIG_NTFS_FS)
 const struct file_operations ntfs_legacy_file_operations = {
        .llseek         = generic_file_llseek,
        .read_iter      = ntfs_file_read_iter,
@@ -1249,4 +1250,5 @@ const struct file_operations ntfs_legacy_file_operations = {
        .open           = ntfs_file_open,
        .release        = ntfs_file_release,
 };
+#endif
 // clang-format on
index 68dd71eed3fe09e21aa4db99fa2ec146d2184e5e..77ae0dccbd5c54ea22ffe48c7fa32caecd20983f 100644 (file)
@@ -441,10 +441,9 @@ end_enum:
                 * Usually a hard links to directories are disabled.
                 */
                inode->i_op = &ntfs_dir_inode_operations;
-               if (is_legacy_ntfs(inode->i_sb))
-                       inode->i_fop = &ntfs_legacy_dir_operations;
-               else
-                       inode->i_fop = &ntfs_dir_operations;
+               inode->i_fop = unlikely(is_legacy_ntfs(sb)) ?
+                                      &ntfs_legacy_dir_operations :
+                                      &ntfs_dir_operations;
                ni->i_valid = 0;
        } else if (S_ISLNK(mode)) {
                ni->std_fa &= ~FILE_ATTRIBUTE_DIRECTORY;
@@ -454,10 +453,9 @@ end_enum:
        } else if (S_ISREG(mode)) {
                ni->std_fa &= ~FILE_ATTRIBUTE_DIRECTORY;
                inode->i_op = &ntfs_file_inode_operations;
-               if (is_legacy_ntfs(inode->i_sb))
-                       inode->i_fop = &ntfs_legacy_file_operations;
-               else
-                       inode->i_fop = &ntfs_file_operations;
+               inode->i_fop = unlikely(is_legacy_ntfs(sb)) ?
+                                      &ntfs_legacy_file_operations :
+                                      &ntfs_file_operations;
                inode->i_mapping->a_ops = is_compressed(ni) ? &ntfs_aops_cmpr :
                                                              &ntfs_aops;
                if (ino != MFT_REC_MFT)
@@ -1627,10 +1625,9 @@ int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,
 
        if (S_ISDIR(mode)) {
                inode->i_op = &ntfs_dir_inode_operations;
-               if (is_legacy_ntfs(inode->i_sb))
-                       inode->i_fop = &ntfs_legacy_dir_operations;
-               else
-                       inode->i_fop = &ntfs_dir_operations;
+               inode->i_fop = unlikely(is_legacy_ntfs(sb)) ?
+                                      &ntfs_legacy_dir_operations :
+                                      &ntfs_dir_operations;
        } else if (S_ISLNK(mode)) {
                inode->i_op = &ntfs_link_inode_operations;
                inode->i_fop = NULL;
@@ -1639,10 +1636,9 @@ int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,
                inode_nohighmem(inode);
        } else if (S_ISREG(mode)) {
                inode->i_op = &ntfs_file_inode_operations;
-               if (is_legacy_ntfs(inode->i_sb))
-                       inode->i_fop = &ntfs_legacy_file_operations;
-               else
-                       inode->i_fop = &ntfs_file_operations;
+               inode->i_fop = unlikely(is_legacy_ntfs(sb)) ?
+                                      &ntfs_legacy_file_operations :
+                                      &ntfs_file_operations;
                inode->i_mapping->a_ops = is_compressed(ni) ? &ntfs_aops_cmpr :
                                                              &ntfs_aops;
                init_rwsem(&ni->file.run_lock);
index 8074fc53a145e0f63c013aac59702f52af8d65d8..6240ed742e7bda6be2c3bdec8d103d2496b672a9 100644 (file)
@@ -1140,6 +1140,13 @@ static inline void le64_sub_cpu(__le64 *var, u64 val)
        *var = cpu_to_le64(le64_to_cpu(*var) - val);
 }
 
+#if IS_ENABLED(CONFIG_NTFS_FS)
 bool is_legacy_ntfs(struct super_block *sb);
+#else
+static inline bool is_legacy_ntfs(struct super_block *sb)
+{
+       return false;
+}
+#endif
 
 #endif /* _LINUX_NTFS3_NTFS_FS_H */
index c39a70b93bb1ce52fffbdc1be1c9b277f05317fd..64cdb32da6c6914c5eb8e922f84ad0eb0c9f3fdd 100644 (file)
@@ -1837,10 +1837,8 @@ bool is_legacy_ntfs(struct super_block *sb)
 #else
 static inline void register_as_ntfs_legacy(void) {}
 static inline void unregister_as_ntfs_legacy(void) {}
-bool is_legacy_ntfs(struct super_block *sb) { return false; }
 #endif
 
-
 // clang-format on
 
 static int __init init_ntfs_fs(void)