fs/ntfs3: Remove locked argument in ntfs_set_ea

We always need to lock now, because locks became smaller
(see d562e901f2
"fs/ntfs3: Move ni_lock_dir and ni_unlock into ntfs_create_inode").

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
This commit is contained in:
Konstantin Komarov 2021-09-24 17:50:22 +03:00
parent b1e0c55a40
commit d81e06be92
No known key found for this signature in database
GPG Key ID: A9B0331F832407B6

View File

@ -257,7 +257,7 @@ static int ntfs_get_ea(struct inode *inode, const char *name, size_t name_len,
static noinline int ntfs_set_ea(struct inode *inode, const char *name, static noinline int ntfs_set_ea(struct inode *inode, const char *name,
size_t name_len, const void *value, size_t name_len, const void *value,
size_t val_size, int flags, int locked) size_t val_size, int flags)
{ {
struct ntfs_inode *ni = ntfs_i(inode); struct ntfs_inode *ni = ntfs_i(inode);
struct ntfs_sb_info *sbi = ni->mi.sbi; struct ntfs_sb_info *sbi = ni->mi.sbi;
@ -276,8 +276,7 @@ static noinline int ntfs_set_ea(struct inode *inode, const char *name,
u64 new_sz; u64 new_sz;
void *p; void *p;
if (!locked) ni_lock(ni);
ni_lock(ni);
run_init(&ea_run); run_init(&ea_run);
@ -465,8 +464,7 @@ static noinline int ntfs_set_ea(struct inode *inode, const char *name,
mark_inode_dirty(&ni->vfs_inode); mark_inode_dirty(&ni->vfs_inode);
out: out:
if (!locked) ni_unlock(ni);
ni_unlock(ni);
run_close(&ea_run); run_close(&ea_run);
kfree(ea_all); kfree(ea_all);
@ -537,7 +535,7 @@ struct posix_acl *ntfs_get_acl(struct inode *inode, int type)
static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns, static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
struct inode *inode, struct posix_acl *acl, struct inode *inode, struct posix_acl *acl,
int type, int locked) int type)
{ {
const char *name; const char *name;
size_t size, name_len; size_t size, name_len;
@ -594,7 +592,7 @@ static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
flags = 0; flags = 0;
} }
err = ntfs_set_ea(inode, name, name_len, value, size, flags, locked); err = ntfs_set_ea(inode, name, name_len, value, size, flags);
if (err == -ENODATA && !size) if (err == -ENODATA && !size)
err = 0; /* Removing non existed xattr. */ err = 0; /* Removing non existed xattr. */
if (!err) if (!err)
@ -612,7 +610,7 @@ static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
int ntfs_set_acl(struct user_namespace *mnt_userns, struct inode *inode, int ntfs_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
struct posix_acl *acl, int type) struct posix_acl *acl, int type)
{ {
return ntfs_set_acl_ex(mnt_userns, inode, acl, type, 0); return ntfs_set_acl_ex(mnt_userns, inode, acl, type);
} }
static int ntfs_xattr_get_acl(struct user_namespace *mnt_userns, static int ntfs_xattr_get_acl(struct user_namespace *mnt_userns,
@ -693,7 +691,7 @@ int ntfs_init_acl(struct user_namespace *mnt_userns, struct inode *inode,
if (default_acl) { if (default_acl) {
err = ntfs_set_acl_ex(mnt_userns, inode, default_acl, err = ntfs_set_acl_ex(mnt_userns, inode, default_acl,
ACL_TYPE_DEFAULT, 1); ACL_TYPE_DEFAULT);
posix_acl_release(default_acl); posix_acl_release(default_acl);
} else { } else {
inode->i_default_acl = NULL; inode->i_default_acl = NULL;
@ -704,7 +702,7 @@ int ntfs_init_acl(struct user_namespace *mnt_userns, struct inode *inode,
else { else {
if (!err) if (!err)
err = ntfs_set_acl_ex(mnt_userns, inode, acl, err = ntfs_set_acl_ex(mnt_userns, inode, acl,
ACL_TYPE_ACCESS, 1); ACL_TYPE_ACCESS);
posix_acl_release(acl); posix_acl_release(acl);
} }
@ -988,7 +986,7 @@ static noinline int ntfs_setxattr(const struct xattr_handler *handler,
} }
#endif #endif
/* Deal with NTFS extended attribute. */ /* Deal with NTFS extended attribute. */
err = ntfs_set_ea(inode, name, name_len, value, size, flags, 0); err = ntfs_set_ea(inode, name, name_len, value, size, flags);
out: out:
return err; return err;
@ -1004,28 +1002,29 @@ int ntfs_save_wsl_perm(struct inode *inode)
int err; int err;
__le32 value; __le32 value;
/* TODO: refactor this, so we don't lock 4 times in ntfs_set_ea */
value = cpu_to_le32(i_uid_read(inode)); value = cpu_to_le32(i_uid_read(inode));
err = ntfs_set_ea(inode, "$LXUID", sizeof("$LXUID") - 1, &value, err = ntfs_set_ea(inode, "$LXUID", sizeof("$LXUID") - 1, &value,
sizeof(value), 0, 0); sizeof(value), 0);
if (err) if (err)
goto out; goto out;
value = cpu_to_le32(i_gid_read(inode)); value = cpu_to_le32(i_gid_read(inode));
err = ntfs_set_ea(inode, "$LXGID", sizeof("$LXGID") - 1, &value, err = ntfs_set_ea(inode, "$LXGID", sizeof("$LXGID") - 1, &value,
sizeof(value), 0, 0); sizeof(value), 0);
if (err) if (err)
goto out; goto out;
value = cpu_to_le32(inode->i_mode); value = cpu_to_le32(inode->i_mode);
err = ntfs_set_ea(inode, "$LXMOD", sizeof("$LXMOD") - 1, &value, err = ntfs_set_ea(inode, "$LXMOD", sizeof("$LXMOD") - 1, &value,
sizeof(value), 0, 0); sizeof(value), 0);
if (err) if (err)
goto out; goto out;
if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
value = cpu_to_le32(inode->i_rdev); value = cpu_to_le32(inode->i_rdev);
err = ntfs_set_ea(inode, "$LXDEV", sizeof("$LXDEV") - 1, &value, err = ntfs_set_ea(inode, "$LXDEV", sizeof("$LXDEV") - 1, &value,
sizeof(value), 0, 0); sizeof(value), 0);
if (err) if (err)
goto out; goto out;
} }