Re: [PATCH v3] ceph: do not print the whole xattr value if it's too long

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 2, 2023 at 4:26 AM <xiubli@xxxxxxxxxx> wrote:
>
> From: Xiubo Li <xiubli@xxxxxxxxxx>
>
> 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.
>
> URL: https://tracker.ceph.com/issues/58404
> Signed-off-by: Xiubo Li <xiubli@xxxxxxxxxx>
> ---
>
> V3:
> - s/MAX_XATTR_VAL/MAX_XATTR_VAL_PRINT_LEN/g
> - removed the CCing stable mail list
>
>
>  fs/ceph/xattr.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
> index b10d459c2326..25a585e63a2d 100644
> --- a/fs/ceph/xattr.c
> +++ b/fs/ceph/xattr.c
> @@ -561,6 +561,8 @@ static struct ceph_vxattr *ceph_match_vxattr(struct inode *inode,
>         return NULL;
>  }
>
> +#define MAX_XATTR_VAL_PRINT_LEN 256
> +
>  static int __set_xattr(struct ceph_inode_info *ci,
>                            const char *name, int name_len,
>                            const char *val, int val_len,
> @@ -654,8 +656,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",

Hi Xiubo,

The function name is incorrect here and above, it should be __set_xattr.

> +            ceph_vinop(&ci->netfs.inode), xattr, name_len, name,
> +            min(val_len, MAX_XATTR_VAL_PRINT_LEN), val,
> +            val_len > MAX_XATTR_VAL_PRINT_LEN ? "..." : "");
>
>         return 0;
>  }
> @@ -681,8 +685,11 @@ 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,
> +                            min(len, MAX_XATTR_VAL_PRINT_LEN), xattr->val,
> +                            len > MAX_XATTR_VAL_PRINT_LEN ? "..." : "");

It looks like len variable is introduced just to save a few characters?
If you make it meaningful, dout would actually be more compact:

    int len = min(xattr->val_len, MAX_XATTR_VAL_PRINT_LEN);

    dout("__get_xattr %s: found %.*s%s\n", name, len,
         xattr->val, xattr->val_len > len ? "..." : "");

Thanks,

                Ilya




[Index of Archives]     [CEPH Users]     [Ceph Large]     [Ceph Dev]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux