mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 1/3] fs/ntfs3: Do not change mode if ntfs_set_ea failed
Date: Fri, 24 Jun 2022 14:40:54 +0300	[thread overview]
Message-ID: <71c6964a-bcab-0c53-931a-6e41b2637ff0@paragon-software.com> (raw)
In-Reply-To: <f76c96bb-fdea-e1e5-5f47-c092af5fe556@paragon-software.com>

ntfs_set_ea can fail with NOSPC, so we don't need to
change mode in this situation.
Fixes xfstest generic/449
Fixes: be71b5cba2e6 ("fs/ntfs3: Add attrib operations")

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
  fs/ntfs3/xattr.c | 20 ++++++++++----------
  1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
index 5e0e0280e70d..1e849428bbc8 100644
--- a/fs/ntfs3/xattr.c
+++ b/fs/ntfs3/xattr.c
@@ -547,28 +547,23 @@ static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
  {
  	const char *name;
  	size_t size, name_len;
-	void *value = NULL;
-	int err = 0;
+	void *value;
+	int err;
  	int flags;
+	umode_t mode;
  
  	if (S_ISLNK(inode->i_mode))
  		return -EOPNOTSUPP;
  
+	mode = inode->i_mode;
  	switch (type) {
  	case ACL_TYPE_ACCESS:
  		/* Do not change i_mode if we are in init_acl */
  		if (acl && !init_acl) {
-			umode_t mode;
-
  			err = posix_acl_update_mode(mnt_userns, inode, &mode,
  						    &acl);
  			if (err)
  				goto out;
-
-			if (inode->i_mode != mode) {
-				inode->i_mode = mode;
-				mark_inode_dirty(inode);
-			}
  		}
  		name = XATTR_NAME_POSIX_ACL_ACCESS;
  		name_len = sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1;
@@ -604,8 +599,13 @@ static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
  	err = ntfs_set_ea(inode, name, name_len, value, size, flags, 0);
  	if (err == -ENODATA && !size)
  		err = 0; /* Removing non existed xattr. */
-	if (!err)
+	if (!err) {
  		set_cached_acl(inode, type, acl);
+		if (inode->i_mode != mode) {
+			inode->i_mode = mode;
+			mark_inode_dirty(inode);
+		}
+	}
  
  out:
  	kfree(value);
-- 
2.36.1



  reply	other threads:[~2022-06-24 11:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-24 11:39 [PATCH 0/3] fs/ntfs3: Various bug fixes Konstantin Komarov
2022-06-24 11:40 ` Konstantin Komarov [this message]
2022-06-24 11:41 ` [PATCH 2/3] fs/ntfs3: Check reserved size for maximum allowed Konstantin Komarov
2022-06-24 11:43 ` [PATCH 3/3] fs/ntfs3: extend ni_insert_nonresident to return inserted ATTR_LIST_ENTRY Konstantin Komarov

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=71c6964a-bcab-0c53-931a-6e41b2637ff0@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

all inboxes | Powered by JetHome®