From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
To: <ntfs3@lists.linux.dev>
Cc: <linux-kernel@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>
Subject: [PATCH 5/5] fs/ntfs3: Refactoring lock in ntfs_init_acl
Date: Wed, 22 Sep 2021 19:20:49 +0300 [thread overview]
Message-ID: <ed6426f4-a579-86ce-a54f-ac356991a797@paragon-software.com> (raw)
In-Reply-To: <2771ff62-e612-a8ed-4b93-5534c26aef9e@paragon-software.com>
This is possible because of moving lock into ntfs_create_inode.
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
fs/ntfs3/xattr.c | 55 ++++++++++++------------------------------------
1 file changed, 14 insertions(+), 41 deletions(-)
diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
index 59ec5e61a239..83bbee277e12 100644
--- a/fs/ntfs3/xattr.c
+++ b/fs/ntfs3/xattr.c
@@ -693,54 +693,27 @@ int ntfs_init_acl(struct user_namespace *mnt_userns, struct inode *inode,
struct posix_acl *default_acl, *acl;
int err;
- /*
- * TODO: Refactoring lock.
- * ni_lock(dir) ... -> posix_acl_create(dir,...) -> ntfs_get_acl -> ni_lock(dir)
- */
- inode->i_default_acl = NULL;
-
- default_acl = ntfs_get_acl_ex(mnt_userns, dir, ACL_TYPE_DEFAULT, 1);
-
- if (!default_acl || default_acl == ERR_PTR(-EOPNOTSUPP)) {
- inode->i_mode &= ~current_umask();
- err = 0;
- goto out;
- }
-
- if (IS_ERR(default_acl)) {
- err = PTR_ERR(default_acl);
- goto out;
- }
-
- acl = default_acl;
- err = __posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
- if (err < 0)
- goto out1;
- if (!err) {
- posix_acl_release(acl);
- acl = NULL;
- }
-
- if (!S_ISDIR(inode->i_mode)) {
- posix_acl_release(default_acl);
- default_acl = NULL;
- }
+ err = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
+ if (err)
+ return err;
- if (default_acl)
+ if (default_acl) {
err = ntfs_set_acl_ex(mnt_userns, inode, default_acl,
ACL_TYPE_DEFAULT, 1);
+ posix_acl_release(default_acl);
+ } else {
+ inode->i_default_acl = NULL;
+ }
if (!acl)
inode->i_acl = NULL;
- else if (!err)
- err = ntfs_set_acl_ex(mnt_userns, inode, acl, ACL_TYPE_ACCESS,
- 1);
-
- posix_acl_release(acl);
-out1:
- posix_acl_release(default_acl);
+ else {
+ if (!err)
+ err = ntfs_set_acl_ex(mnt_userns, inode, acl,
+ ACL_TYPE_ACCESS, 1);
+ posix_acl_release(acl);
+ }
-out:
return err;
}
#endif
--
2.33.0
next prev parent reply other threads:[~2021-09-22 16:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-22 16:15 [PATCH 0/5] Refactor locking in inode_operations Konstantin Komarov
2021-09-22 16:17 ` [PATCH 1/5] fs/ntfs3: Move ni_lock_dir and ni_unlock into ntfs_create_inode Konstantin Komarov
2021-09-22 18:12 ` Kari Argillander
2021-09-22 16:18 ` [PATCH 2/5] fs/ntfs3: Refactor ntfs_get_acl_ex for better readability Konstantin Komarov
2021-09-22 17:47 ` Kari Argillander
2021-09-22 16:19 ` [PATCH 3/5] fs/ntfs3: Pass flags to ntfs_set_ea in ntfs_set_acl_ex Konstantin Komarov
2021-09-22 17:59 ` Kari Argillander
2021-09-22 16:20 ` [PATCH 4/5] fs/ntfs3: Change posix_acl_equiv_mode to posix_acl_update_mode Konstantin Komarov
2021-09-22 18:23 ` Kari Argillander
2021-09-22 16:20 ` Konstantin Komarov [this message]
2021-09-22 18:41 ` [PATCH 5/5] fs/ntfs3: Refactoring lock in ntfs_init_acl Kari Argillander
2021-09-22 18:51 ` [PATCH 0/5] Refactor locking in inode_operations Kari Argillander
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ed6426f4-a579-86ce-a54f-ac356991a797@paragon-software.com \
--to=almaz.alexandrovich@paragon-software.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ntfs3@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).