]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
Merge tag 'ntfs3_for_6.2' of https://github.com/Paragon-Software-Group/linux-ntfs3
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 21 Dec 2022 18:18:17 +0000 (10:18 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 21 Dec 2022 18:18:17 +0000 (10:18 -0800)
Pull ntfs3 updates from Konstantin Komarov:

 - added mount options 'hidedotfiles', 'nocase' and 'windows_names'

 - fixed xfstests (tested on x86_64): generic/083 generic/263
   generic/307 generic/465

 - fix some logic errors

 - code refactoring and dead code removal

* tag 'ntfs3_for_6.2' of https://github.com/Paragon-Software-Group/linux-ntfs3: (61 commits)
  fs/ntfs3: Make if more readable
  fs/ntfs3: Improve checking of bad clusters
  fs/ntfs3: Fix wrong if in hdr_first_de
  fs/ntfs3: Use ALIGN kernel macro
  fs/ntfs3: Fix incorrect if in ntfs_set_acl_ex
  fs/ntfs3: Check fields while reading
  fs/ntfs3: Correct ntfs_check_for_free_space
  fs/ntfs3: Restore correct state after ENOSPC in attr_data_get_block
  fs/ntfs3: Changing locking in ntfs_rename
  fs/ntfs3: Fixing wrong logic in attr_set_size and ntfs_fallocate
  fs/ntfs3: atomic_open implementation
  fs/ntfs3: Fix wrong indentations
  fs/ntfs3: Change new sparse cluster processing
  fs/ntfs3: Fixing work with sparse clusters
  fs/ntfs3: Simplify ntfs_update_mftmirr function
  fs/ntfs3: Remove unused functions
  fs/ntfs3: Fix sparse problems
  fs/ntfs3: Add ntfs_bitmap_weight_le function and refactoring
  fs/ntfs3: Use _le variants of bitops functions
  fs/ntfs3: Add functions to modify LE bitmaps
  ...

1  2 
fs/ntfs3/file.c
fs/ntfs3/fslog.c
fs/ntfs3/inode.c
fs/ntfs3/namei.c
fs/ntfs3/ntfs_fs.h
fs/ntfs3/xattr.c

diff --cc fs/ntfs3/file.c
Simple merge
Simple merge
Simple merge
index 053cc0e0f8b5a7b51be106a0a1592f1a0ac2e3f4,0e72d2067804f743614dd7fbfcf46b9b26115162..c8db35e2ae17255265cd3cd60122ffb85d6e06af
@@@ -333,6 -339,104 +339,104 @@@ out
        return err;
  }
  
 -              struct posix_acl *p = get_acl(dir, ACL_TYPE_DEFAULT);
+ /*
+  * ntfs_atomic_open
+  *
+  * inode_operations::atomic_open
+  */
+ static int ntfs_atomic_open(struct inode *dir, struct dentry *dentry,
+                           struct file *file, u32 flags, umode_t mode)
+ {
+       int err;
+       struct inode *inode;
+       struct ntfs_fnd *fnd = NULL;
+       struct ntfs_inode *ni = ntfs_i(dir);
+       struct dentry *d = NULL;
+       struct cpu_str *uni = __getname();
+       bool locked = false;
+       if (!uni)
+               return -ENOMEM;
+       err = ntfs_nls_to_utf16(ni->mi.sbi, dentry->d_name.name,
+                               dentry->d_name.len, uni, NTFS_NAME_LEN,
+                               UTF16_HOST_ENDIAN);
+       if (err < 0)
+               goto out;
+ #ifdef CONFIG_NTFS3_FS_POSIX_ACL
+       if (IS_POSIXACL(dir)) {
+               /* 
+                * Load in cache current acl to avoid ni_lock(dir):
+                * ntfs_create_inode -> ntfs_init_acl -> posix_acl_create ->
+                * ntfs_get_acl -> ntfs_get_acl_ex -> ni_lock
+                */
++              struct posix_acl *p = get_inode_acl(dir, ACL_TYPE_DEFAULT);
+               if (IS_ERR(p)) {
+                       err = PTR_ERR(p);
+                       goto out;
+               }
+               posix_acl_release(p);
+       }
+ #endif
+       if (d_in_lookup(dentry)) {
+               ni_lock_dir(ni);
+               locked = true;
+               fnd = fnd_get();
+               if (!fnd) {
+                       err = -ENOMEM;
+                       goto out1;
+               }
+               d = d_splice_alias(dir_search_u(dir, uni, fnd), dentry);
+               if (IS_ERR(d)) {
+                       err = PTR_ERR(d);
+                       d = NULL;
+                       goto out2;
+               }
+               if (d)
+                       dentry = d;
+       }
+       if (!(flags & O_CREAT) || d_really_is_positive(dentry)) {
+               err = finish_no_open(file, d);
+               goto out2;
+       }
+       file->f_mode |= FMODE_CREATED;
+       /*
+        * fnd contains tree's path to insert to.
+        * If fnd is not NULL then dir is locked.
+        */
+       /*
+        * Unfortunately I don't know how to get here correct 'struct nameidata *nd'
+        * or 'struct user_namespace *mnt_userns'.
+        * See atomic_open in fs/namei.c.
+        * This is why xfstest/633 failed.
+        * Looks like ntfs_atomic_open must accept 'struct user_namespace *mnt_userns' as argument.
+        */
+       inode = ntfs_create_inode(&init_user_ns, dir, dentry, uni, mode, 0,
+                                 NULL, 0, fnd);
+       err = IS_ERR(inode) ? PTR_ERR(inode)
+                           : finish_open(file, dentry, ntfs_file_open);
+       dput(d);
+ out2:
+       fnd_put(fnd);
+ out1:
+       if (locked)
+               ni_unlock(ni);
+ out:
+       __putname(uni);
+       return err;
+ }
  struct dentry *ntfs3_get_parent(struct dentry *child)
  {
        struct inode *inode = d_inode(child);
@@@ -379,7 -611,13 +611,13 @@@ const struct inode_operations ntfs_spec
        .setattr        = ntfs3_setattr,
        .getattr        = ntfs_getattr,
        .listxattr      = ntfs_listxattr,
 -      .get_acl        = ntfs_get_acl,
 +      .get_inode_acl  = ntfs_get_acl,
        .set_acl        = ntfs_set_acl,
  };
+ const struct dentry_operations ntfs_dentry_ops = {
+       .d_hash         = ntfs_d_hash,
+       .d_compare      = ntfs_d_compare,
+ };
  // clang-format on
Simple merge
index aafe98ee0b214dfa617d43a5b7f587bf791f32da,cfd59bb0f9de173c51da6e19201e5f3da7853342..616df209feea7d3963a05bff722ac0b3d63b9364
@@@ -792,8 -884,21 +824,8 @@@ static int ntfs_getxattr(const struct x
                goto out;
        }
  
 -#ifdef CONFIG_NTFS3_FS_POSIX_ACL
 -      if (!strcmp(name, XATTR_NAME_POSIX_ACL_ACCESS) ||
 -          !strcmp(name, XATTR_NAME_POSIX_ACL_DEFAULT)) {
 -              /* TODO: init_user_ns? */
 -              err = ntfs_xattr_get_acl(
 -                      &init_user_ns, inode,
 -                      strlen(name) == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1
 -                              ? ACL_TYPE_ACCESS
 -                              : ACL_TYPE_DEFAULT,
 -                      buffer, size);
 -              goto out;
 -      }
 -#endif
        /* Deal with NTFS extended attribute. */
-       err = ntfs_get_ea(inode, name, name_len, buffer, size, NULL);
+       err = ntfs_get_ea(inode, name, strlen(name), buffer, size, NULL);
  
  out:
        return err;
@@@ -904,8 -1009,20 +936,8 @@@ set_new_fa
                goto out;
        }
  
 -#ifdef CONFIG_NTFS3_FS_POSIX_ACL
 -      if (!strcmp(name, XATTR_NAME_POSIX_ACL_ACCESS) ||
 -          !strcmp(name, XATTR_NAME_POSIX_ACL_DEFAULT)) {
 -              err = ntfs_xattr_set_acl(
 -                      mnt_userns, inode,
 -                      strlen(name) == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1
 -                              ? ACL_TYPE_ACCESS
 -                              : ACL_TYPE_DEFAULT,
 -                      value, size);
 -              goto out;
 -      }
 -#endif
        /* Deal with NTFS extended attribute. */
-       err = ntfs_set_ea(inode, name, name_len, value, size, flags, 0);
+       err = ntfs_set_ea(inode, name, strlen(name), value, size, flags, 0);
  
  out:
        inode->i_ctime = current_time(inode);