From: Sergiy Kibrik <sakib@meta.ua>
To: Sage Weil <sage@newdream.net>
Cc: ceph-devel@vger.kernel.org
Subject: [PATCH] ceph: fix xattr search while getxattr
Date: Fri, 14 Jan 2011 01:07:02 +0200 [thread overview]
Message-ID: <201101140107.02627.sakib@meta.ua> (raw)
Reproducible: always
How to reproduce:
$ touch file
$ setfattr -n user.bare -v bare file
$ setfattr -n user.bar -v bar
$ getfattr -d file
user.bar="bar"
user.bare="bar"
This is because one xattr name is a sub-string of another,
so search picks up first matching name -- a shorter one.
Patch fixes search routine to do full-length string comparison.
Signed-off-by: Sergiy Kibrik <sakib@meta.ua>
---
fs/ceph/xattr.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 6e12a6b..3d1d1d5 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -219,13 +219,15 @@ static struct ceph_inode_xattr *__get_xattr(struct ceph_inode_info *ci,
struct rb_node **p;
struct rb_node *parent = NULL;
struct ceph_inode_xattr *xattr = NULL;
- int c;
+ int c, name_len = strlen(name);
p = &ci->i_xattrs.index.rb_node;
while (*p) {
parent = *p;
xattr = rb_entry(parent, struct ceph_inode_xattr, node);
- c = strncmp(name, xattr->name, xattr->name_len);
+ c = name_len - xattr->name_len;
+ if (!c)
+ c = strncmp(name, xattr->name, xattr->name_len);
if (c < 0)
p = &(*p)->rb_left;
else if (c > 0)
--
1.7.1
next reply other threads:[~2011-01-13 23:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-13 23:07 Sergiy Kibrik [this message]
2011-01-13 23:58 ` [PATCH] ceph: fix xattr search while getxattr Sage Weil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201101140107.02627.sakib@meta.ua \
--to=sakib@meta.ua \
--cc=ceph-devel@vger.kernel.org \
--cc=sage@newdream.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.