xfs: short circuit xfs_get_acl() if no acl is possible
PATCH 1/1 xfs: short circuit xfs_get_acl() if no acl is possible
If there are no attributes on the inode, don't go through the cost of memory allocation and callling xfs_attr_get when we already know we'll just get -ENOATTR.
---
fs/xfs/xfs_acl.c +3 -0
@@ -132,6 +132,9 @@ xfs_get_acl(struct inode *inode, int type)BUG (); } +if (!xfs_inode_hasattr (ip)) +return NULL ; +/* * If we have a cached ACLs value just return it, not need to * go out to the disk.
Quoted 14 lines · Eric Sandeen
If there are no attributes on the inode, don't go through the cost of memory allocation and callling
xfs_attr_getwhen we already know we'll just get-ENOATTR.Reported-by David Valin <[email protected]>Suggested-by Dave Chinner <[email protected]>Signed-off-by Eric Sandeen <[email protected]>---
fs/xfs/xfs_acl.c +0
-0
fs/xfs/xfs_acl.c xfs_get_acl(struct inode *inode, int type) · line 136
Quoted 5 lines
fs/xfs/xfs_acl.c +2
-0@@ -132,6 +132,9 @@ xfs_get_acl(struct inode *inode, int type)BUG (); } +if (!xfs_inode_hasattr (ip)) +return NULL ;
This isn't going to cause problems if someone's adding an ACL to the inode at the same time, right?
I'm assuming that's the case since we only would load inodes when setting up a vfs inode but before any userspace can get its sticky fingers all over the inode, but it sure would be nice to know that for sure. :)
--D
Quoted 5 lines
fs/xfs/xfs_acl.c +1
-0+/* * If we have a cached ACLs value just return it, not need to * go out to the disk.
Quoted 24 lines · Darrick J. Wong
Quoted 14 lines · Eric Sandeen
If there are no attributes on the inode, don't go through the cost of memory allocation and callling
xfs_attr_getwhen we already know we'll just get-ENOATTR.Reported-by David Valin <[email protected]>Suggested-by Dave Chinner <[email protected]>Signed-off-by Eric Sandeen <[email protected]>---
fs/xfs/xfs_acl.c +0
-0fs/xfs/xfs_acl.c xfs_get_acl(struct inode *inode, int type) · line 136
Quoted 5 lines
fs/xfs/xfs_acl.c +2
-0@@ -132,6 +132,9 @@ xfs_get_acl(struct inode *inode, int type)BUG (); } +if (!xfs_inode_hasattr (ip)) +return NULL ;This isn't going to cause problems if someone's adding an ACL to the inode at the same time, right?
Quoted 5 lines
I'm assuming that's the case since we only would load inodes when setting up a vfs inode but before any userspace can get its sticky fingers all over the inode, but it sure would be nice to know that for sure. :)
Hmm, that's a good question. At first I was thinking it wouldn't matter, but then I remembered the fairly recent issue around writing back an empty leaf buffer on format conversion a bit too early. That has me wondering if that would be an issue here as well. For example, suppose a non-empty local format attr fork is being converted to extent format due to a concurrent (and unrelated) xattr set. That involves xfs_attr_shortform_to_leaf() -> xfs_bmap_local_to_extents_empty(), which looks like it creates a transient empty fork state. Might xfs_inode_hasattr() catch that as a false negative here? If so, that would certainly be a problem if the existing xattr was the ACL the caller happens to be interested in. It might be prudent to surround this check with ILOCK_SHARED...
Brian
Quoted 7 lines
--D
Quoted 5 lines
fs/xfs/xfs_acl.c +1
-0+/* * If we have a cached ACLs value just return it, not need to * go out to the disk.
Quoted 31 lines · Brian Foster
Quoted 24 lines · Darrick J. Wong
Quoted 14 lines · Eric Sandeen
If there are no attributes on the inode, don't go through the cost of memory allocation and callling
xfs_attr_getwhen we already know we'll just get-ENOATTR.Reported-by David Valin <[email protected]>Suggested-by Dave Chinner <[email protected]>Signed-off-by Eric Sandeen <[email protected]>---
fs/xfs/xfs_acl.c +0
-0fs/xfs/xfs_acl.c xfs_get_acl(struct inode *inode, int type) · line 136
Quoted 5 lines
fs/xfs/xfs_acl.c +2
-0@@ -132,6 +132,9 @@ xfs_get_acl(struct inode *inode, int type)BUG (); } +if (!xfs_inode_hasattr (ip)) +return NULL ;This isn't going to cause problems if someone's adding an ACL to the inode at the same time, right?
Quoted 5 lines
I'm assuming that's the case since we only would load inodes when setting up a vfs inode but before any userspace can get its sticky fingers all over the inode, but it sure would be nice to know that for sure. :)
Quoted 12 lines
Hmm, that's a good question. At first I was thinking it wouldn't matter, but then I remembered the fairly recent issue around writing back an empty leaf buffer on format conversion a bit too early. That has me wondering if that would be an issue here as well. For example, suppose a non-empty local format attr fork is being converted to extent format due to a concurrent (and unrelated) xattr set. That involves
xfs_attr_shortform_to_leaf()->xfs_bmap_local_to_extents_empty(), which looks like it creates a transient empty fork state. Mightxfs_inode_hasattr()catch that as a false negative here? If so, that would certainly be a problem if the existing xattr was the ACL the caller happens to be interested in. It might be prudent to surround this check withILOCK_SHARED...
<shrug> But xfs_inode_hasattr checks forkoff > 0, so as long as the shortform to leaf conversion doesn't zero forkoff we'd be fine, I think. AFAICT it doesn't...?
--D
Quoted 9 lines
Brian
Quoted 7 lines
--D
Quoted 5 lines
fs/xfs/xfs_acl.c +1
-0+/* * If we have a cached ACLs value just return it, not need to * go out to the disk.
Quoted 45 lines · Darrick J. Wong
Quoted 31 lines · Brian Foster
Quoted 24 lines · Darrick J. Wong
Quoted 14 lines · Eric Sandeen
If there are no attributes on the inode, don't go through the cost of memory allocation and callling
xfs_attr_getwhen we already know we'll just get-ENOATTR.Reported-by David Valin <[email protected]>Suggested-by Dave Chinner <[email protected]>Signed-off-by Eric Sandeen <[email protected]>---
fs/xfs/xfs_acl.c +0
-0fs/xfs/xfs_acl.c xfs_get_acl(struct inode *inode, int type) · line 136
Quoted 5 lines
fs/xfs/xfs_acl.c +2
-0@@ -132,6 +132,9 @@ xfs_get_acl(struct inode *inode, int type)BUG (); } +if (!xfs_inode_hasattr (ip)) +return NULL ;This isn't going to cause problems if someone's adding an ACL to the inode at the same time, right?
Quoted 5 lines
I'm assuming that's the case since we only would load inodes when setting up a vfs inode but before any userspace can get its sticky fingers all over the inode, but it sure would be nice to know that for sure. :)
Quoted 12 lines
Hmm, that's a good question. At first I was thinking it wouldn't matter, but then I remembered the fairly recent issue around writing back an empty leaf buffer on format conversion a bit too early. That has me wondering if that would be an issue here as well. For example, suppose a non-empty local format attr fork is being converted to extent format due to a concurrent (and unrelated) xattr set. That involves
xfs_attr_shortform_to_leaf()->xfs_bmap_local_to_extents_empty(), which looks like it creates a transient empty fork state. Mightxfs_inode_hasattr()catch that as a false negative here? If so, that would certainly be a problem if the existing xattr was the ACL the caller happens to be interested in. It might be prudent to surround this check withILOCK_SHARED...
Quoted 1 line
<shrug> But
xfs_inode_hasattrchecks forkoff > 0, so as long as the
It does do that ...
int
xfs_inode_hasattr(
struct xfs_inode *ip)
{
if (!XFS_IFORK_Q(ip) ||Quoted 2 lines
shortform to leaf conversion doesn't zero forkoff we'd be fine, I think. AFAICT it doesn't...?
but there's that pesky || part :
(ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
ip->i_d.di_anextents == 0))
return 0;
return 1;
}and I think it's the latter state Brian was concerned about?
I can play with sandwiching it in a shared lock...
-Eric
Quoted 64 lines · Eric Sandeen
Quoted 45 lines · Darrick J. Wong
Quoted 31 lines · Brian Foster
Quoted 24 lines · Darrick J. Wong
Quoted 14 lines · Eric Sandeen
If there are no attributes on the inode, don't go through the cost of memory allocation and callling
xfs_attr_getwhen we already know we'll just get-ENOATTR.Reported-by David Valin <[email protected]>Suggested-by Dave Chinner <[email protected]>Signed-off-by Eric Sandeen <[email protected]>---
fs/xfs/xfs_acl.c +0
-0fs/xfs/xfs_acl.c xfs_get_acl(struct inode *inode, int type) · line 136
Quoted 5 lines
fs/xfs/xfs_acl.c +2
-0@@ -132,6 +132,9 @@ xfs_get_acl(struct inode *inode, int type)BUG (); } +if (!xfs_inode_hasattr (ip)) +return NULL ;This isn't going to cause problems if someone's adding an ACL to the inode at the same time, right?
Quoted 5 lines
I'm assuming that's the case since we only would load inodes when setting up a vfs inode but before any userspace can get its sticky fingers all over the inode, but it sure would be nice to know that for sure. :)
Quoted 12 lines
Hmm, that's a good question. At first I was thinking it wouldn't matter, but then I remembered the fairly recent issue around writing back an empty leaf buffer on format conversion a bit too early. That has me wondering if that would be an issue here as well. For example, suppose a non-empty local format attr fork is being converted to extent format due to a concurrent (and unrelated) xattr set. That involves
xfs_attr_shortform_to_leaf()->xfs_bmap_local_to_extents_empty(), which looks like it creates a transient empty fork state. Mightxfs_inode_hasattr()catch that as a false negative here? If so, that would certainly be a problem if the existing xattr was the ACL the caller happens to be interested in. It might be prudent to surround this check withILOCK_SHARED...Quoted 1 line
<shrug> But
xfs_inode_hasattrchecks forkoff > 0, so as long as theIt does do that ...
int
xfs_inode_hasattr(
structxfs_inode*ip){ if (!XFS_IFORK_Q(ip) ||Quoted 2 lines
shortform to leaf conversion doesn't zero forkoff we'd be fine, I think. AFAICT it doesn't...?
but there's that pesky || part :
Quoted 8 lines
(ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && ip->i_d.di_anextents == 0)) return 0; return 1; }and I think it's the latter state Brian was concerned about?
Yep, pretty much.
Brian
Quoted 4 lines
I can play with sandwiching it in a shared lock...
-Eric
Quoted 71 lines · Brian Foster
Quoted 70 lines · Eric Sandeen
Quoted 45 lines · Darrick J. Wong
Quoted 31 lines · Brian Foster
Quoted 24 lines · Darrick J. Wong
Quoted 14 lines · Eric Sandeen
If there are no attributes on the inode, don't go through the cost of memory allocation and callling
xfs_attr_getwhen we already know we'll just get-ENOATTR.Reported-by David Valin <[email protected]>Suggested-by Dave Chinner <[email protected]>Signed-off-by Eric Sandeen <[email protected]>---
fs/xfs/xfs_acl.c +0
-0fs/xfs/xfs_acl.c xfs_get_acl(struct inode *inode, int type) · line 136
Quoted 5 lines
fs/xfs/xfs_acl.c +2
-0@@ -132,6 +132,9 @@ xfs_get_acl(struct inode *inode, int type)BUG (); } +if (!xfs_inode_hasattr (ip)) +return NULL ;This isn't going to cause problems if someone's adding an ACL to the inode at the same time, right?
Quoted 5 lines
I'm assuming that's the case since we only would load inodes when setting up a vfs inode but before any userspace can get its sticky fingers all over the inode, but it sure would be nice to know that for sure. :)
Quoted 12 lines
Hmm, that's a good question. At first I was thinking it wouldn't matter, but then I remembered the fairly recent issue around writing back an empty leaf buffer on format conversion a bit too early. That has me wondering if that would be an issue here as well. For example, suppose a non-empty local format attr fork is being converted to extent format due to a concurrent (and unrelated) xattr set. That involves
xfs_attr_shortform_to_leaf()->xfs_bmap_local_to_extents_empty(), which looks like it creates a transient empty fork state. Mightxfs_inode_hasattr()catch that as a false negative here? If so, that would certainly be a problem if the existing xattr was the ACL the caller happens to be interested in. It might be prudent to surround this check withILOCK_SHARED...Quoted 1 line
<shrug> But
xfs_inode_hasattrchecks forkoff > 0, so as long as theIt does do that ...
int
xfs_inode_hasattr(
structxfs_inode*ip){ if (!XFS_IFORK_Q(ip) ||Quoted 2 lines
shortform to leaf conversion doesn't zero forkoff we'd be fine, I think. AFAICT it doesn't...?
but there's that pesky || part :
(ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && ip->i_d.di_anextents == 0)) return 0; return 1; }
Quoted 4 lines
Quoted 2 lines
and I think it's the latter state Brian was concerned about?
Yep, pretty much.
/me needs to uncover the "drive allocation into attr code" patch he wrote so this "noattr == no allocation" hack isn't necessary....
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]