Skip to contentSkip to conversation

generic/020: fix really long attr test failure for ceph

PATCH Superseded [email protected] 4 participants 8 messages Feb 17, 2023 – Feb 27, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 generic/020: fix really long attr test failure for ceph

From: Xiubo Li <[email protected]>

If the CONFIG_CEPH_FS_SECURITY_LABEL is enabled the kernel ceph itself will set the security.selinux extended attribute to MDS. And it will also eat some space of the total size.

---
 tests/generic/020 | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tests/generic/020 +4 -2
index be5cecad..594535b5 100755
@@ -150,9 +150,11 @@ _attr_get_maxval_size()
 		# it imposes a maximum size for the full set of xattrs
 		# names+values, which by default is 64K.  Compute the maximum
 		# taking into account the already existing attributes
-		max_attrval_size=$(getfattr --dump -e hex $filename 2>/dev/null | \
+		size=$(getfattr --dump -e hex $filename 2>/dev/null | \
 			awk -F "=0x" '/^user/ {len += length($1) + length($2) / 2} END {print len}')
-		max_attrval_size=$((65536 - $max_attrval_size - $max_attrval_namelen))
+		selinux_size=$(getfattr -n 'security.selinux' --dump -e hex $filename 2>/dev/null | \
+			awk -F "=0x" '/^security/ {len += length($1) + length($2) / 2} END {print len}')
+		max_attrval_size=$((65536 - $size - $selinux_size - $max_attrval_namelen))
 		;;
 	*)
 		# Assume max ~1 block of attrs
Signature · 1 line
2.31.1
#1 lore raw
Quoted 17 lines · On Fri, Feb 17, 2023 at 08:45:58PM +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

If the CONFIG_CEPH_FS_SECURITY_LABEL is enabled the kernel ceph itself will set the security.selinux extended attribute to MDS. And it will also eat some space of the total size.

---
 tests/generic/020 | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tests/generic/020 +0 -0
index be5cecad..594535b5 100755

tests/generic/020 _attr_get_maxval_size() · line 157

Quoted 10 lines
tests/generic/020 +4 -2
@@ -150,9 +150,11 @@ _attr_get_maxval_size()
 		# it imposes a maximum size for the full set of xattrs
 		# names+values, which by default is 64K.  Compute the maximum
 		# taking into account the already existing attributes
-		max_attrval_size=$(getfattr --dump -e hex $filename 2>/dev/null | \
+		size=$(getfattr --dump -e hex $filename 2>/dev/null | \
 			awk -F "=0x" '/^user/ {len += length($1) + length($2) / 2} END {print len}')
-		max_attrval_size=$((65536 - $max_attrval_size - $max_attrval_namelen))
+		selinux_size=$(getfattr -n 'security.selinux' --dump -e hex $filename 2>/dev/null | \
+			awk -F "=0x" '/^security/ {len += length($1) + length($2) / 2} END {print len}')
+		max_attrval_size=$((65536 - $size - $selinux_size - $max_attrval_namelen))

If this is a ceph bug, then why is the change being applied to the section for FSTYP=ext* ? Why not create a case statement for ceph?

--D

Quoted 6 lines
tests/generic/020 +0 -0
 		;;
 	*)
 		# Assume max ~1 block of attrs
Signature · 1 line
2.31.1
author
#2 lore raw
Quoted 22 lines · Darrick J. Wong
Quoted 21 lines · On Fri, Feb 17, 2023 at 08:45:58PM +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

If the CONFIG_CEPH_FS_SECURITY_LABEL is enabled the kernel ceph itself will set the security.selinux extended attribute to MDS. And it will also eat some space of the total size.

---
  tests/generic/020 | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
tests/generic/020 +0 -1
index be5cecad..594535b5 100755
@@ -150,9 +150,11 @@ _attr_get_maxval_size()
  		# it imposes a maximum size for the full set of xattrs
  		# names+values, which by default is 64K.  Compute the maximum
  		# taking into account the already existing attributes
-		max_attrval_size=$(getfattr --dump -e hex $filename 2>/dev/null | \
Quoted 8 lines

tests/generic/020 _attr_get_maxval_size() · line 157

Quoted 6 lines
tests/generic/020 +4 -1
+		size=$(getfattr --dump -e hex $filename 2>/dev/null | \
  			awk -F "=0x" '/^user/ {len += length($1) + length($2) / 2} END {print len}')
-		max_attrval_size=$((65536 - $max_attrval_size - $max_attrval_namelen))
+		selinux_size=$(getfattr -n 'security.selinux' --dump -e hex $filename 2>/dev/null | \
+			awk -F "=0x" '/^security/ {len += length($1) + length($2) / 2} END {print len}')
+		max_attrval_size=$((65536 - $size - $selinux_size - $max_attrval_namelen))

If this is a ceph bug, then why is the change being applied to the section for FSTYP=ext* ? Why not create a case statement for ceph?

Hi Darrick,

The above change is already in the "ceph)" section:

143         nfs)
144                 # NFS doesn't provide a way to find out the max_attrval_size for
145                 # the underlying filesystem, so just use the lowest value above.
146                 max_attrval_size=1024
147                 ;;
148         ceph)
149                 # CephFS does not have a maximum value for attributes.  Instead,
150                 # it imposes a maximum size for the full set of xattrs
151                 # names+values, which by default is 64K. Compute the maximum
152                 # taking into account the already existing attributes
153                 size=$(getfattr --dump -e hex $filename 2>/dev/null | \
154                         awk -F "=0x" '/^user/ {len += length($1) + length($2) / 2} END {print len}') 155                 selinux_size=$(getfattr -n 'security.selinux' --dump -e hex $filename 2>/dev/null | \
156                         awk -F "=0x" '/^security/ {len += length($1) + length($2) / 2} END {print len}') 157                 max_attrval_size=$((65536 - $size - $selinux_size - $max_attrval_namelen)) 158                 ;;
159         *)
160                 # Assume max ~1 block of attrs
161                 BLOCK_SIZE=_get_block_size $TEST_DIR
162                 # leave a little overhead
163                 let max_attrval_size=$BLOCK_SIZE-256

I didn't find the ext* section in _attr_get_maxval_size(). Did I miss something here ?

I have double checked it again by pulling the latest source code, no any change about this since my last pull yesterday.

Thanks

- Xiubo

Quoted 8 lines

--D

Quoted 6 lines
tests/generic/020 +0 -0
  		;;
  	*)
  		# Assume max ~1 block of attrs
Signature · 1 line
2.31.1
Signature · 6 lines
Best Regards,

Xiubo Li (李秀波)

Email: [email protected]/[email protected]
Slack: @Xiubo Li
#3 lore raw
In reply to Darrick J. Wong
Quoted 23 lines · Darrick J. Wong
Quoted 22 lines · On Fri, Feb 17, 2023 at 08:45:58PM +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

If the CONFIG_CEPH_FS_SECURITY_LABEL is enabled the kernel ceph itself will set the security.selinux extended attribute to MDS. And it will also eat some space of the total size.

---
 tests/generic/020 | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tests/generic/020 +1 -1
index be5cecad..594535b5 100755
@@ -150,9 +150,11 @@ _attr_get_maxval_size()
 		# it imposes a maximum size for the full set of xattrs
 		# names+values, which by default is 64K.  Compute the maximum
 		# taking into account the already existing attributes
-		max_attrval_size=$(getfattr --dump -e hex $filename 2>/dev/null | \
+		size=$(getfattr --dump -e hex $filename 2>/dev/null | \
Quoted 8 lines

tests/generic/020 _attr_get_maxval_size() · line 157

Quoted 5 lines
tests/generic/020 +3 -1
 			awk -F "=0x" '/^user/ {len += length($1) + length($2) / 2} END {print len}')
-		max_attrval_size=$((65536 - $max_attrval_size - $max_attrval_namelen))
+		selinux_size=$(getfattr -n 'security.selinux' --dump -e hex $filename 2>/dev/null | \
+			awk -F "=0x" '/^security/ {len += length($1) + length($2) / 2} END {print len}')
+		max_attrval_size=$((65536 - $size - $selinux_size - $max_attrval_namelen))

If this is a ceph bug, then why is the change being applied to the section for FSTYP=ext* ? Why not create a case statement for ceph?

Hi Darrick,

Looks like this change is in ceph section [1], did you hit any errors when you merge it?

Thanks,
Zorro

[1]
_attr_get_maxval_size()
{
local max_attrval_namelen="$1"
local filename="$2"

# Set max attr value size in bytes based on fs type
case "$FSTYP" in
...
...
ceph)
# CephFS does not have a maximum value for attributes. Instead, # it imposes a maximum size for the full set of xattrs # names+values, which by default is 64K. Compute the maximum # taking into account the already existing attributes

====>           max_attrval_size=$(getfattr --dump -e hex $filename 2>/dev/null | \
                        awk -F "=0x" '/^user/ {len += length($1) + length($2) / 2} END {print len}')

====> max_attrval_size=$((65536 - $max_attrval_size - $max_attrval_namelen))

Quoted 10 lines

--D

Quoted 6 lines
tests/generic/020 +0 -0
 		;;
 	*)
 		# Assume max ~1 block of attrs
Signature · 1 line
2.31.1
#4 lore raw
Quoted 33 lines · Zorro Lang
Quoted 23 lines · Darrick J. Wong
Quoted 22 lines · On Fri, Feb 17, 2023 at 08:45:58PM +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

If the CONFIG_CEPH_FS_SECURITY_LABEL is enabled the kernel ceph itself will set the security.selinux extended attribute to MDS. And it will also eat some space of the total size.

---
 tests/generic/020 | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tests/generic/020 +1 -1
index be5cecad..594535b5 100755
@@ -150,9 +150,11 @@ _attr_get_maxval_size()
 		# it imposes a maximum size for the full set of xattrs
 		# names+values, which by default is 64K.  Compute the maximum
 		# taking into account the already existing attributes
-		max_attrval_size=$(getfattr --dump -e hex $filename 2>/dev/null | \
+		size=$(getfattr --dump -e hex $filename 2>/dev/null | \
Quoted 8 lines

tests/generic/020 _attr_get_maxval_size() · line 157

Quoted 5 lines
tests/generic/020 +3 -1
 			awk -F "=0x" '/^user/ {len += length($1) + length($2) / 2} END {print len}')
-		max_attrval_size=$((65536 - $max_attrval_size - $max_attrval_namelen))
+		selinux_size=$(getfattr -n 'security.selinux' --dump -e hex $filename 2>/dev/null | \
+			awk -F "=0x" '/^security/ {len += length($1) + length($2) / 2} END {print len}')
+		max_attrval_size=$((65536 - $size - $selinux_size - $max_attrval_namelen))

If this is a ceph bug, then why is the change being applied to the section for FSTYP=ext* ? Why not create a case statement for ceph?

Quoted 4 lines

Hi Darrick,

Looks like this change is in ceph section [1], did you hit any errors when you merge it?

ahahaa, diff tried to merge that hunk into _attr_get_max and not _attr_get_maxval_size, and I didn't notice. Question withdrawn with apologies. :/

--D

Quoted 34 lines

Thanks,
Zorro

[1]
_attr_get_maxval_size()
{
local max_attrval_namelen="$1"
local filename="$2"

# Set max attr value size in bytes based on fs type
case "$FSTYP" in
...
...
ceph)
# CephFS does not have a maximum value for attributes. Instead, # it imposes a maximum size for the full set of xattrs # names+values, which by default is 64K. Compute the maximum # taking into account the already existing attributes

====>           max_attrval_size=$(getfattr --dump -e hex $filename 2>/dev/null | \
                        awk -F "=0x" '/^user/ {len += length($1) + length($2) / 2} END {print len}')

====> max_attrval_size=$((65536 - $max_attrval_size - $max_attrval_namelen))

Quoted 10 lines

--D

Quoted 6 lines
tests/generic/020 +0 -0
 		;;
 	*)
 		# Assume max ~1 block of attrs
Signature · 1 line
2.31.1
#5 lore raw
Quoted 15 lines · Darrick J. Wong
Quoted 14 lines · Zorro Lang
Quoted 13 lines · Darrick J. Wong
Quoted 12 lines · On Fri, Feb 17, 2023 at 08:45:58PM +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

If the CONFIG_CEPH_FS_SECURITY_LABEL is enabled the kernel ceph itself will set the security.selinux extended attribute to MDS. And it will also eat some space of the total size.

---
 tests/generic/020 | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
tests/generic/020 +0 -0
index be5cecad..594535b5 100755
@@ -150,9 +150,11 @@ _attr_get_maxval_size()
 		# it imposes a maximum size for the full set of xattrs
 		# names+values, which by default is 64K.  Compute the maximum
Quoted 8 lines
Quoted 8 lines

tests/generic/020 _attr_get_maxval_size() · line 157

Quoted 8 lines
tests/generic/020 +4 -2
 		# taking into account the already existing attributes
-		max_attrval_size=$(getfattr --dump -e hex $filename 2>/dev/null | \
+		size=$(getfattr --dump -e hex $filename 2>/dev/null | \
 			awk -F "=0x" '/^user/ {len += length($1) + length($2) / 2} END {print len}')
-		max_attrval_size=$((65536 - $max_attrval_size - $max_attrval_namelen))
+		selinux_size=$(getfattr -n 'security.selinux' --dump -e hex $filename 2>/dev/null | \
+			awk -F "=0x" '/^security/ {len += length($1) + length($2) / 2} END {print len}')
+		max_attrval_size=$((65536 - $size - $selinux_size - $max_attrval_namelen))

The max_attrval_size isn't a local variable, due to we need it to be global. But the "size" and "selinux_size" look like not global variable, so better to be *local*.

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

If this is a ceph bug, then why is the change being applied to the section for FSTYP=ext* ? Why not create a case statement for ceph?

Quoted 8 lines
Quoted 4 lines

Hi Darrick,

Looks like this change is in ceph section [1], did you hit any errors when you merge it?

ahahaa, diff tried to merge that hunk into _attr_get_max and not _attr_get_maxval_size, and I didn't notice. Question withdrawn with apologies. :/

Never mind. If there's not objection from you or ceph list, I'll merge this patch after it changes as above :)

Thanks,
Zorro

Quoted 38 lines

--D

Quoted 34 lines

Thanks,
Zorro

[1]
_attr_get_maxval_size()
{
local max_attrval_namelen="$1"
local filename="$2"

# Set max attr value size in bytes based on fs type
case "$FSTYP" in
...
...
ceph)
# CephFS does not have a maximum value for attributes. Instead, # it imposes a maximum size for the full set of xattrs # names+values, which by default is 64K. Compute the maximum # taking into account the already existing attributes

====>           max_attrval_size=$(getfattr --dump -e hex $filename 2>/dev/null | \
                        awk -F "=0x" '/^user/ {len += length($1) + length($2) / 2} END {print len}')

====> max_attrval_size=$((65536 - $max_attrval_size - $max_attrval_namelen))

Quoted 10 lines

--D

Quoted 6 lines
tests/generic/020 +0 -0
 		;;
 	*)
 		# Assume max ~1 block of attrs
Signature · 1 line
2.31.1
author
#6 lore raw
Quoted 39 lines · Zorro Lang
Quoted 15 lines · Darrick J. Wong
Quoted 14 lines · Zorro Lang
Quoted 13 lines · Darrick J. Wong
Quoted 12 lines · On Fri, Feb 17, 2023 at 08:45:58PM +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

If the CONFIG_CEPH_FS_SECURITY_LABEL is enabled the kernel ceph itself will set the security.selinux extended attribute to MDS. And it will also eat some space of the total size.

---
  tests/generic/020 | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
tests/generic/020 +0 -0
index be5cecad..594535b5 100755
@@ -150,9 +150,11 @@ _attr_get_maxval_size()
  		# it imposes a maximum size for the full set of xattrs
  		# names+values, which by default is 64K.  Compute the maximum
Quoted 8 lines
Quoted 8 lines

tests/generic/020 _attr_get_maxval_size() · line 157

Quoted 8 lines
tests/generic/020 +4 -2
  		# taking into account the already existing attributes
-		max_attrval_size=$(getfattr --dump -e hex $filename 2>/dev/null | \
+		size=$(getfattr --dump -e hex $filename 2>/dev/null | \
  			awk -F "=0x" '/^user/ {len += length($1) + length($2) / 2} END {print len}')
-		max_attrval_size=$((65536 - $max_attrval_size - $max_attrval_namelen))
+		selinux_size=$(getfattr -n 'security.selinux' --dump -e hex $filename 2>/dev/null | \
+			awk -F "=0x" '/^security/ {len += length($1) + length($2) / 2} END {print len}')
+		max_attrval_size=$((65536 - $size - $selinux_size - $max_attrval_namelen))

The max_attrval_size isn't a local variable, due to we need it to be global. But the "size" and "selinux_size" look like not global variable, so better to be *local*.

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

If this is a ceph bug, then why is the change being applied to the section for FSTYP=ext* ? Why not create a case statement for ceph?

Hi Darrick,

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Looks like this change is in ceph section [1], did you hit any errors when you merge it?

ahahaa, diff tried to merge that hunk into _attr_get_max and not _attr_get_maxval_size, and I didn't notice. Question withdrawn with apologies. :/

Never mind. If there's not objection from you or ceph list, I'll merge this patch after it changes as above :)

Sure. Thanks Zorro.

- Xiubo

Quoted 37 lines

Thanks,
Zorro

Quoted 34 lines

--D

Quoted 32 lines

Thanks,
Zorro

[1]
_attr_get_maxval_size()
{
local max_attrval_namelen="$1"
local filename="$2"

# Set max attr value size in bytes based on fs type
case "$FSTYP" in
...
...
ceph)
# CephFS does not have a maximum value for attributes. Instead, # it imposes a maximum size for the full set of xattrs # names+values, which by default is 64K. Compute the maximum # taking into account the already existing attributes

====>           max_attrval_size=$(getfattr --dump -e hex $filename 2>/dev/null | \
                         awk -F "=0x" '/^user/ {len += length($1) + length($2) / 2} END {print len}')

====> max_attrval_size=$((65536 - $max_attrval_size - $max_attrval_namelen))

Quoted 8 lines

--D

Quoted 6 lines
tests/generic/020 +0 -0
  		;;
  	*)
  		# Assume max ~1 block of attrs
Signature · 1 line
2.31.1
Signature · 6 lines
Best Regards,

Xiubo Li (李秀波)

Email: [email protected]/[email protected]
Slack: @Xiubo Li
author
#7 lore raw
In reply to Zorro Lang
Quoted 26 lines · Zorro Lang
Quoted 25 lines · Darrick J. Wong
Quoted 24 lines · Zorro Lang
Quoted 23 lines · Darrick J. Wong
Quoted 22 lines · On Fri, Feb 17, 2023 at 08:45:58PM +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

If the CONFIG_CEPH_FS_SECURITY_LABEL is enabled the kernel ceph itself will set the security.selinux extended attribute to MDS. And it will also eat some space of the total size.

---
  tests/generic/020 | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
tests/generic/020 +1 -1
index be5cecad..594535b5 100755
@@ -150,9 +150,11 @@ _attr_get_maxval_size()
  		# it imposes a maximum size for the full set of xattrs
  		# names+values, which by default is 64K.  Compute the maximum
  		# taking into account the already existing attributes
-		max_attrval_size=$(getfattr --dump -e hex $filename 2>/dev/null | \
+		size=$(getfattr --dump -e hex $filename 2>/dev/null | \
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

tests/generic/020 _attr_get_maxval_size() · line 157

Quoted 5 lines
tests/generic/020 +3 -1
  			awk -F "=0x" '/^user/ {len += length($1) + length($2) / 2} END {print len}')
-		max_attrval_size=$((65536 - $max_attrval_size - $max_attrval_namelen))
+		selinux_size=$(getfattr -n 'security.selinux' --dump -e hex $filename 2>/dev/null | \
+			awk -F "=0x" '/^security/ {len += length($1) + length($2) / 2} END {print len}')
+		max_attrval_size=$((65536 - $size - $selinux_size - $max_attrval_namelen))

The max_attrval_size isn't a local variable, due to we need it to be global. But the "size" and "selinux_size" look like not global variable, so better to be *local*.

Sorry I missed this.

And now fixed it and sent out the V2.

Thanks

- Xiubo

Quoted 49 lines
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

If this is a ceph bug, then why is the change being applied to the section for FSTYP=ext* ? Why not create a case statement for ceph?

Hi Darrick,

Looks like this change is in ceph section [1], did you hit any errors when you merge it?

ahahaa, diff tried to merge that hunk into _attr_get_max and not _attr_get_maxval_size, and I didn't notice. Question withdrawn with apologies. :/

Never mind. If there's not objection from you or ceph list, I'll merge this patch after it changes as above :)

Thanks,
Zorro

Quoted 34 lines

--D

Quoted 32 lines

Thanks,
Zorro

[1]
_attr_get_maxval_size()
{
local max_attrval_namelen="$1"
local filename="$2"

# Set max attr value size in bytes based on fs type
case "$FSTYP" in
...
...
ceph)
# CephFS does not have a maximum value for attributes. Instead, # it imposes a maximum size for the full set of xattrs # names+values, which by default is 64K. Compute the maximum # taking into account the already existing attributes

====>           max_attrval_size=$(getfattr --dump -e hex $filename 2>/dev/null | \
                         awk -F "=0x" '/^user/ {len += length($1) + length($2) / 2} END {print len}')

====> max_attrval_size=$((65536 - $max_attrval_size - $max_attrval_namelen))

Quoted 8 lines

--D

Quoted 6 lines
tests/generic/020 +0 -0
  		;;
  	*)
  		# Assume max ~1 block of attrs
Signature · 1 line
2.31.1
Signature · 6 lines
Best Regards,

Xiubo Li (李秀波)

Email: [email protected]/[email protected]
Slack: @Xiubo Li