mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
fs/ntfs3: Optimize locking in ntfs_save_wsl_perm
Right now in ntfs_save_wsl_perm we lock/unlock 4 times. This commit fixes this situation. We add "locked" argument to ntfs_set_ea. Suggested-by: Kari Argillander <kari.argillander@gmail.com> Reviewed-by: Kari Argillander <kari.argillander@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
This commit is contained in:
parent
2d44667c30
commit
3a2154b25a
1 changed files with 14 additions and 10 deletions
|
@ -259,7 +259,7 @@ out:
|
||||||
|
|
||||||
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)
|
size_t val_size, int flags, bool locked)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -278,7 +278,8 @@ static noinline int ntfs_set_ea(struct inode *inode, const char *name,
|
||||||
u64 new_sz;
|
u64 new_sz;
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
ni_lock(ni);
|
if (!locked)
|
||||||
|
ni_lock(ni);
|
||||||
|
|
||||||
run_init(&ea_run);
|
run_init(&ea_run);
|
||||||
|
|
||||||
|
@ -467,7 +468,8 @@ update_ea:
|
||||||
mark_inode_dirty(&ni->vfs_inode);
|
mark_inode_dirty(&ni->vfs_inode);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
ni_unlock(ni);
|
if (!locked)
|
||||||
|
ni_unlock(ni);
|
||||||
|
|
||||||
run_close(&ea_run);
|
run_close(&ea_run);
|
||||||
kfree(ea_all);
|
kfree(ea_all);
|
||||||
|
@ -598,7 +600,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);
|
err = ntfs_set_ea(inode, name, name_len, value, size, flags, 0);
|
||||||
if (err == -ENODATA && !size)
|
if (err == -ENODATA && !size)
|
||||||
err = 0; /* Removing non existed xattr. */
|
err = 0; /* Removing non existed xattr. */
|
||||||
if (!err)
|
if (!err)
|
||||||
|
@ -992,7 +994,7 @@ set_new_fa:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* Deal with NTFS extended attribute. */
|
/* Deal with NTFS extended attribute. */
|
||||||
err = ntfs_set_ea(inode, name, name_len, value, size, flags);
|
err = ntfs_set_ea(inode, name, name_len, value, size, flags, 0);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
inode->i_ctime = current_time(inode);
|
inode->i_ctime = current_time(inode);
|
||||||
|
@ -1010,35 +1012,37 @@ int ntfs_save_wsl_perm(struct inode *inode)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
__le32 value;
|
__le32 value;
|
||||||
|
struct ntfs_inode *ni = ntfs_i(inode);
|
||||||
|
|
||||||
/* TODO: refactor this, so we don't lock 4 times in ntfs_set_ea */
|
ni_lock(ni);
|
||||||
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);
|
sizeof(value), 0, true); /* true == already locked. */
|
||||||
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);
|
sizeof(value), 0, true);
|
||||||
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);
|
sizeof(value), 0, true);
|
||||||
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);
|
sizeof(value), 0, true);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
ni_unlock(ni);
|
||||||
/* In case of error should we delete all WSL xattr? */
|
/* In case of error should we delete all WSL xattr? */
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue