Skip to content

Commit 0bee82f

Browse files
author
Sage Weil
committed
ceph: fix getxattr vxattr handling
Change the vxattr handling for getxattr so that vxattrs are checked prior to any xattr content, and never after. Enforce vxattr existence via the exists_cb callback. Signed-off-by: Sage Weil <sage@inktank.com> Reviewed-by: Sam Lang <sam.lang@inktank.com>
1 parent f36e447 commit 0bee82f

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

‎fs/ceph/xattr.c‎

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -569,13 +569,17 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value,
569569
if (!ceph_is_valid_xattr(name))
570570
return -ENODATA;
571571

572-
/* let's see if a virtual xattr was requested */
573-
vxattr = ceph_match_vxattr(inode, name);
574-
575572
spin_lock(&ci->i_ceph_lock);
576573
dout("getxattr %p ver=%lld index_ver=%lld\n", inode,
577574
ci->i_xattrs.version, ci->i_xattrs.index_version);
578575

576+
/* let's see if a virtual xattr was requested */
577+
vxattr = ceph_match_vxattr(inode, name);
578+
if (vxattr && !(vxattr->exists_cb && !vxattr->exists_cb(ci))) {
579+
err = vxattr->getxattr_cb(ci, value, size);
580+
goto out;
581+
}
582+
579583
if (__ceph_caps_issued_mask(ci, CEPH_CAP_XATTR_SHARED, 1) &&
580584
(ci->i_xattrs.index_version >= ci->i_xattrs.version)) {
581585
goto get_xattr;
@@ -589,23 +593,15 @@ ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value,
589593

590594
spin_lock(&ci->i_ceph_lock);
591595

592-
if (vxattr && vxattr->readonly) {
593-
err = vxattr->getxattr_cb(ci, value, size);
594-
goto out;
595-
}
596-
597596
err = __build_xattrs(inode);
598597
if (err < 0)
599598
goto out;
600599

601600
get_xattr:
602601
err = -ENODATA; /* == ENOATTR */
603602
xattr = __get_xattr(ci, name);
604-
if (!xattr) {
605-
if (vxattr)
606-
err = vxattr->getxattr_cb(ci, value, size);
603+
if (!xattr)
607604
goto out;
608-
}
609605

610606
err = -ERANGE;
611607
if (size && size < xattr->val_len)

0 commit comments

Comments
 (0)