ceph-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ceph: do not print the whole xattr value if it's too long
@ 2023-02-28 12:55 xiubli
  2023-02-28 13:29 ` Jeff Layton
  0 siblings, 1 reply; 3+ messages in thread
From: xiubli @ 2023-02-28 12:55 UTC (permalink / raw)
  To: idryomov, ceph-devel
  Cc: jlayton, lhenriques, vshankar, mchangir, Xiubo Li, stable

From: Xiubo Li <xiubli@redhat.com>

If the xattr's value size is long enough the kernel will warn and
then will fail the xfstests test case.

Just print part of the value string if it's too long.

Cc: stable@vger.kernel.org
URL: https://tracker.ceph.com/issues/58404
Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
 fs/ceph/xattr.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index b10d459c2326..6638bb0ec10f 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -561,6 +561,7 @@ static struct ceph_vxattr *ceph_match_vxattr(struct inode *inode,
 	return NULL;
 }
 
+#define XATTR_MAX_VAL 256
 static int __set_xattr(struct ceph_inode_info *ci,
 			   const char *name, int name_len,
 			   const char *val, int val_len,
@@ -654,8 +655,10 @@ static int __set_xattr(struct ceph_inode_info *ci,
 		dout("__set_xattr_val p=%p\n", p);
 	}
 
-	dout("__set_xattr_val added %llx.%llx xattr %p %.*s=%.*s\n",
-	     ceph_vinop(&ci->netfs.inode), xattr, name_len, name, val_len, val);
+	dout("__set_xattr_val added %llx.%llx xattr %p %.*s=%.*s%s\n",
+	     ceph_vinop(&ci->netfs.inode), xattr, name_len, name,
+	     val_len > XATTR_MAX_VAL ? XATTR_MAX_VAL : val_len, val,
+	     val_len > XATTR_MAX_VAL ? "..." : "");
 
 	return 0;
 }
@@ -681,8 +684,10 @@ static struct ceph_inode_xattr *__get_xattr(struct ceph_inode_info *ci,
 		else if (c > 0)
 			p = &(*p)->rb_right;
 		else {
-			dout("__get_xattr %s: found %.*s\n", name,
-			     xattr->val_len, xattr->val);
+			int len = xattr->val_len;
+			dout("__get_xattr %s: found %.*s%s\n", name,
+			     len > XATTR_MAX_VAL ? XATTR_MAX_VAL : len,
+			     xattr->val, len > XATTR_MAX_VAL ? "..." : "");
 			return xattr;
 		}
 	}
-- 
2.31.1


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

* Re: [PATCH] ceph: do not print the whole xattr value if it's too long
  2023-02-28 12:55 [PATCH] ceph: do not print the whole xattr value if it's too long xiubli
@ 2023-02-28 13:29 ` Jeff Layton
  2023-02-28 13:36   ` Xiubo Li
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Layton @ 2023-02-28 13:29 UTC (permalink / raw)
  To: xiubli, idryomov, ceph-devel; +Cc: lhenriques, vshankar, mchangir, stable

On Tue, 2023-02-28 at 20:55 +0800, xiubli@redhat.com wrote:
> From: Xiubo Li <xiubli@redhat.com>
> 
> If the xattr's value size is long enough the kernel will warn and
> then will fail the xfstests test case.
> 
> Just print part of the value string if it's too long.
> 
> Cc: stable@vger.kernel.org
> URL: https://tracker.ceph.com/issues/58404
> Signed-off-by: Xiubo Li <xiubli@redhat.com>
> ---
>  fs/ceph/xattr.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
> index b10d459c2326..6638bb0ec10f 100644
> --- a/fs/ceph/xattr.c
> +++ b/fs/ceph/xattr.c
> @@ -561,6 +561,7 @@ static struct ceph_vxattr *ceph_match_vxattr(struct inode *inode,
>  	return NULL;
>  }
>  
> +#define XATTR_MAX_VAL 256
>  static int __set_xattr(struct ceph_inode_info *ci,
>  			   const char *name, int name_len,
>  			   const char *val, int val_len,
> @@ -654,8 +655,10 @@ static int __set_xattr(struct ceph_inode_info *ci,
>  		dout("__set_xattr_val p=%p\n", p);
>  	}
>  
> -	dout("__set_xattr_val added %llx.%llx xattr %p %.*s=%.*s\n",
> -	     ceph_vinop(&ci->netfs.inode), xattr, name_len, name, val_len, val);
> +	dout("__set_xattr_val added %llx.%llx xattr %p %.*s=%.*s%s\n",
> +	     ceph_vinop(&ci->netfs.inode), xattr, name_len, name,
> +	     val_len > XATTR_MAX_VAL ? XATTR_MAX_VAL : val_len, val,

		min(val_len, XATTR_MAX_VAL), val,...

> +	     val_len > XATTR_MAX_VAL ? "..." : "");
>  
>  	return 0;
>  }
> @@ -681,8 +684,10 @@ static struct ceph_inode_xattr *__get_xattr(struct ceph_inode_info *ci,
>  		else if (c > 0)
>  			p = &(*p)->rb_right;
>  		else {
> -			dout("__get_xattr %s: found %.*s\n", name,
> -			     xattr->val_len, xattr->val);
> +			int len = xattr->val_len;
> +			dout("__get_xattr %s: found %.*s%s\n", name,
> +			     len > XATTR_MAX_VAL ? XATTR_MAX_VAL : len,

				min(len, XATTR_MAX_VAL)

> +			     xattr->val, len > XATTR_MAX_VAL ? "..." : "");
>  			return xattr;
>  		}
>  	}

-- 
Jeff Layton <jlayton@kernel.org>

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

* Re: [PATCH] ceph: do not print the whole xattr value if it's too long
  2023-02-28 13:29 ` Jeff Layton
@ 2023-02-28 13:36   ` Xiubo Li
  0 siblings, 0 replies; 3+ messages in thread
From: Xiubo Li @ 2023-02-28 13:36 UTC (permalink / raw)
  To: Jeff Layton, idryomov, ceph-devel; +Cc: lhenriques, vshankar, mchangir, stable


On 28/02/2023 21:29, Jeff Layton wrote:
> On Tue, 2023-02-28 at 20:55 +0800, xiubli@redhat.com wrote:
>> From: Xiubo Li <xiubli@redhat.com>
>>
>> If the xattr's value size is long enough the kernel will warn and
>> then will fail the xfstests test case.
>>
>> Just print part of the value string if it's too long.
>>
>> Cc: stable@vger.kernel.org
>> URL: https://tracker.ceph.com/issues/58404
>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
>> ---
>>   fs/ceph/xattr.c | 13 +++++++++----
>>   1 file changed, 9 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
>> index b10d459c2326..6638bb0ec10f 100644
>> --- a/fs/ceph/xattr.c
>> +++ b/fs/ceph/xattr.c
>> @@ -561,6 +561,7 @@ static struct ceph_vxattr *ceph_match_vxattr(struct inode *inode,
>>   	return NULL;
>>   }
>>   
>> +#define XATTR_MAX_VAL 256
>>   static int __set_xattr(struct ceph_inode_info *ci,
>>   			   const char *name, int name_len,
>>   			   const char *val, int val_len,
>> @@ -654,8 +655,10 @@ static int __set_xattr(struct ceph_inode_info *ci,
>>   		dout("__set_xattr_val p=%p\n", p);
>>   	}
>>   
>> -	dout("__set_xattr_val added %llx.%llx xattr %p %.*s=%.*s\n",
>> -	     ceph_vinop(&ci->netfs.inode), xattr, name_len, name, val_len, val);
>> +	dout("__set_xattr_val added %llx.%llx xattr %p %.*s=%.*s%s\n",
>> +	     ceph_vinop(&ci->netfs.inode), xattr, name_len, name,
>> +	     val_len > XATTR_MAX_VAL ? XATTR_MAX_VAL : val_len, val,
> 		min(val_len, XATTR_MAX_VAL), val,...
>
>> +	     val_len > XATTR_MAX_VAL ? "..." : "");
>>   
>>   	return 0;
>>   }
>> @@ -681,8 +684,10 @@ static struct ceph_inode_xattr *__get_xattr(struct ceph_inode_info *ci,
>>   		else if (c > 0)
>>   			p = &(*p)->rb_right;
>>   		else {
>> -			dout("__get_xattr %s: found %.*s\n", name,
>> -			     xattr->val_len, xattr->val);
>> +			int len = xattr->val_len;
>> +			dout("__get_xattr %s: found %.*s%s\n", name,
>> +			     len > XATTR_MAX_VAL ? XATTR_MAX_VAL : len,
> 				min(len, XATTR_MAX_VAL)

Cool. I will revise this.

Thanks Jeff.


>
>> +			     xattr->val, len > XATTR_MAX_VAL ? "..." : "");
>>   			return xattr;
>>   		}
>>   	}

-- 
Best Regards,

Xiubo Li (李秀波)

Email: xiubli@redhat.com/xiubli@ibm.com
Slack: @Xiubo Li


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

end of thread, other threads:[~2023-02-28 13:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-28 12:55 [PATCH] ceph: do not print the whole xattr value if it's too long xiubli
2023-02-28 13:29 ` Jeff Layton
2023-02-28 13:36   ` Xiubo Li

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