cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH 1/2] gfs2: don't return ENODATA in __gfs2_xattr_set unless replacing
@ 2017-08-27  6:29 Ernesto A. Fernández
  2017-08-27  6:30 ` [Cluster-devel] [PATCH 2/2] gfs2: preserve i_mode if __gfs2_set_acl() fails Ernesto A. Fernández
  2017-08-31 13:11 ` [Cluster-devel] [PATCH 1/2] gfs2: don't return ENODATA in __gfs2_xattr_set unless replacing Bob Peterson
  0 siblings, 2 replies; 6+ messages in thread
From: Ernesto A. Fernández @ 2017-08-27  6:29 UTC (permalink / raw)
  To: cluster-devel.redhat.com

The function __gfs2_xattr_set() will return -ENODATA when called to
remove a xattr that does not exist. The result is that setfacl will
show an exit status of 1 when called to set only a file's mode bits
(on a file with no ACLs), despite succeeding. A "No data available"
error will be printed as well.

To fix this return 0 instead, except when the XATTR_REPLACE flag is
set, in which case -ENODATA is appropriate. This is consistent with
how most other xattr setting functions work, in other filesystems.

Signed-off-by: Ernesto A. Fern?ndez <ernesto.mnd.fernandez@gmail.com>
---
This patch is needed for the next one to work properly. After the next
patch the mode will no longer be changed if there is an error when setting
the xattr, so it's important that the error code means actual failure,
while this ENODATA was just informative.

 fs/gfs2/xattr.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c
index 5417955..8ca56a7 100644
--- a/fs/gfs2/xattr.c
+++ b/fs/gfs2/xattr.c
@@ -1209,8 +1209,12 @@ int __gfs2_xattr_set(struct inode *inode, const char *name,
 	if (namel > GFS2_EA_MAX_NAME_LEN)
 		return -ERANGE;
 
-	if (value == NULL)
-		return gfs2_xattr_remove(ip, type, name);
+	if (value == NULL) {
+		error = gfs2_xattr_remove(ip, type, name);
+		if (error == -ENODATA && !(flags & XATTR_REPLACE))
+			error = 0;
+		return error;
+	}
 
 	if (ea_check_size(sdp, namel, size))
 		return -ERANGE;
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-08-31 13:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-27  6:29 [Cluster-devel] [PATCH 1/2] gfs2: don't return ENODATA in __gfs2_xattr_set unless replacing Ernesto A. Fernández
2017-08-27  6:30 ` [Cluster-devel] [PATCH 2/2] gfs2: preserve i_mode if __gfs2_set_acl() fails Ernesto A. Fernández
2017-08-30 12:43   ` Bob Peterson
2017-08-31  6:33     ` [Cluster-devel] [PATCH v2 " Ernesto A. Fernández
2017-08-31 13:12       ` Bob Peterson
2017-08-31 13:11 ` [Cluster-devel] [PATCH 1/2] gfs2: don't return ENODATA in __gfs2_xattr_set unless replacing Bob Peterson

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).