Skip to content

Commit 39c1ddb

Browse files
Eric SandeenChandan Babu R
authored andcommitted
xfs: allow SECURE namespace xattrs to use reserved block pool
We got a report from the podman folks that selinux relabels that happen as part of their process were returning ENOSPC when the filesystem is completely full. This is because xattr changes reserve about 15 blocks for the worst case, but the common case is for selinux contexts to be the sole, in-inode xattr and consume no blocks. We already allow reserved space consumption for XFS_ATTR_ROOT for things such as ACLs, and SECURE namespace attributes are not so very different, so allow them to use the reserved space as well. Code-comment-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chandan Babu R <chandanbabu@kernel.org> V2: Remove local variable, add comment. V3: Add Dave's preferred comment V4: Spelling and comment beautification
1 parent 80d3d33 commit 39c1ddb

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

fs/xfs/xfs_xattr.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,24 @@ xfs_attr_change(
110110
args->whichfork = XFS_ATTR_FORK;
111111
xfs_attr_sethash(args);
112112

113-
return xfs_attr_set(args, op, args->attr_filter & XFS_ATTR_ROOT);
113+
/*
114+
* Some xattrs must be resistant to allocation failure at ENOSPC, e.g.
115+
* creating an inode with ACLs or security attributes requires the
116+
* allocation of the xattr holding that information to succeed. Hence
117+
* we allow xattrs in the VFS TRUSTED, SYSTEM, POSIX_ACL and SECURITY
118+
* (LSM xattr) namespaces to dip into the reserve block pool to allow
119+
* manipulation of these xattrs when at ENOSPC. These VFS xattr
120+
* namespaces translate to the XFS_ATTR_ROOT and XFS_ATTR_SECURE on-disk
121+
* namespaces.
122+
*
123+
* For most of these cases, these special xattrs will fit in the inode
124+
* itself and so consume no extra space or only require temporary extra
125+
* space while an overwrite is being made. Hence the use of the reserved
126+
* pool is largely to avoid the worst case reservation from preventing
127+
* the xattr from being created at ENOSPC.
128+
*/
129+
return xfs_attr_set(args, op,
130+
args->attr_filter & (XFS_ATTR_ROOT | XFS_ATTR_SECURE));
114131
}
115132

116133

0 commit comments

Comments
 (0)