Skip to content

Commit 7a6c3a0

Browse files
lxbszidryomov
authored andcommitted
ceph: do not print the whole xattr value if it's too long
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. At the same time fix the function name issue in the debug logs. Link: https://tracker.ceph.com/issues/58404 Signed-off-by: Xiubo Li <xiubli@redhat.com> Reviewed-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent 457391b commit 7a6c3a0

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

fs/ceph/xattr.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@ static struct ceph_vxattr *ceph_match_vxattr(struct inode *inode,
535535
return NULL;
536536
}
537537

538+
#define MAX_XATTR_VAL_PRINT_LEN 256
539+
538540
static int __set_xattr(struct ceph_inode_info *ci,
539541
const char *name, int name_len,
540542
const char *val, int val_len,
@@ -597,7 +599,7 @@ static int __set_xattr(struct ceph_inode_info *ci,
597599
xattr->should_free_name = update_xattr;
598600

599601
ci->i_xattrs.count++;
600-
dout("__set_xattr count=%d\n", ci->i_xattrs.count);
602+
dout("%s count=%d\n", __func__, ci->i_xattrs.count);
601603
} else {
602604
kfree(*newxattr);
603605
*newxattr = NULL;
@@ -625,11 +627,13 @@ static int __set_xattr(struct ceph_inode_info *ci,
625627
if (new) {
626628
rb_link_node(&xattr->node, parent, p);
627629
rb_insert_color(&xattr->node, &ci->i_xattrs.index);
628-
dout("__set_xattr_val p=%p\n", p);
630+
dout("%s p=%p\n", __func__, p);
629631
}
630632

631-
dout("__set_xattr_val added %llx.%llx xattr %p %.*s=%.*s\n",
632-
ceph_vinop(&ci->netfs.inode), xattr, name_len, name, val_len, val);
633+
dout("%s added %llx.%llx xattr %p %.*s=%.*s%s\n", __func__,
634+
ceph_vinop(&ci->netfs.inode), xattr, name_len, name,
635+
min(val_len, MAX_XATTR_VAL_PRINT_LEN), val,
636+
val_len > MAX_XATTR_VAL_PRINT_LEN ? "..." : "");
633637

634638
return 0;
635639
}
@@ -655,13 +659,15 @@ static struct ceph_inode_xattr *__get_xattr(struct ceph_inode_info *ci,
655659
else if (c > 0)
656660
p = &(*p)->rb_right;
657661
else {
658-
dout("__get_xattr %s: found %.*s\n", name,
659-
xattr->val_len, xattr->val);
662+
int len = min(xattr->val_len, MAX_XATTR_VAL_PRINT_LEN);
663+
664+
dout("%s %s: found %.*s%s\n", __func__, name, len,
665+
xattr->val, xattr->val_len > len ? "..." : "");
660666
return xattr;
661667
}
662668
}
663669

664-
dout("__get_xattr %s: not found\n", name);
670+
dout("%s %s: not found\n", __func__, name);
665671

666672
return NULL;
667673
}

0 commit comments

Comments
 (0)