From: Alex Elder <elder@dreamhost.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 2/6] ceph: use macros to normalize vxattr table definitions
Date: Tue, 28 Feb 2012 19:21:46 -0800 [thread overview]
Message-ID: <4F4D99CA.8070509@dreamhost.com> (raw)
In-Reply-To: <4F4D98D5.1010506@dreamhost.com>
Entries in the ceph virtual extended attribute tables all follow a
distinct pattern in their definition. Enforce this pattern through
the use of a macro.
Also, a null name field signals the end of the table, so make that
be the first field in the ceph_vxattr_cb structure.
Signed-off-by: Alex Elder <elder@dreamhost.com>
---
fs/ceph/xattr.c | 39 ++++++++++++++++++++++++++-------------
1 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 21ee6aa..9ef0134 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -25,10 +25,10 @@ static bool ceph_is_valid_xattr(const char *name)
* statistics and layout metadata.
*/
struct ceph_vxattr_cb {
- bool readonly;
char *name;
size_t (*getxattr_cb)(struct ceph_inode_info *ci, char *val,
size_t size);
+ bool readonly;
};
/* directories */
@@ -82,16 +82,25 @@ static size_t ceph_vxattrcb_rctime(struct
ceph_inode_info *ci, char *val,
(long)ci->i_rctime.tv_nsec);
}
+#define CEPH_XATTR_NAME(_type, _name) XATTR_CEPH_PREFIX #_type "." #_name
+
+#define XATTR_NAME_CEPH(_type, _name) \
+ { \
+ .name = CEPH_XATTR_NAME(_type, _name), \
+ .getxattr_cb = ceph_vxattrcb_ ## _name, \
+ .readonly = true, \
+ }
+
static struct ceph_vxattr_cb ceph_dir_vxattrs[] = {
- { true, XATTR_CEPH_PREFIX "dir.entries", ceph_vxattrcb_entries},
- { true, XATTR_CEPH_PREFIX "dir.files", ceph_vxattrcb_files},
- { true, XATTR_CEPH_PREFIX "dir.subdirs", ceph_vxattrcb_subdirs},
- { true, XATTR_CEPH_PREFIX "dir.rentries", ceph_vxattrcb_rentries},
- { true, XATTR_CEPH_PREFIX "dir.rfiles", ceph_vxattrcb_rfiles},
- { true, XATTR_CEPH_PREFIX "dir.rsubdirs", ceph_vxattrcb_rsubdirs},
- { true, XATTR_CEPH_PREFIX "dir.rbytes", ceph_vxattrcb_rbytes},
- { true, XATTR_CEPH_PREFIX "dir.rctime", ceph_vxattrcb_rctime},
- { true, NULL, NULL }
+ XATTR_NAME_CEPH(dir, entries),
+ XATTR_NAME_CEPH(dir, files),
+ XATTR_NAME_CEPH(dir, subdirs),
+ XATTR_NAME_CEPH(dir, rentries),
+ XATTR_NAME_CEPH(dir, rfiles),
+ XATTR_NAME_CEPH(dir, rsubdirs),
+ XATTR_NAME_CEPH(dir, rbytes),
+ XATTR_NAME_CEPH(dir, rctime),
+ { 0 } /* Required table terminator */
};
/* files */
@@ -114,10 +123,14 @@ static size_t ceph_vxattrcb_layout(struct
ceph_inode_info *ci, char *val,
}
static struct ceph_vxattr_cb ceph_file_vxattrs[] = {
- { true, XATTR_CEPH_PREFIX "file.layout", ceph_vxattrcb_layout},
+ XATTR_NAME_CEPH(file, layout),
/* The following extended attribute name is deprecated */
- { true, XATTR_CEPH_PREFIX "layout", ceph_vxattrcb_layout},
- { true, NULL, NULL }
+ {
+ .name = XATTR_CEPH_PREFIX "layout",
+ .getxattr_cb = ceph_vxattrcb_layout,
+ .readonly = true,
+ },
+ { 0 } /* Required table terminator */
};
static struct ceph_vxattr_cb *ceph_inode_vxattrs(struct inode *inode)
--
1.7.5.4
next prev parent reply other threads:[~2012-02-29 3:21 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-29 3:17 [PATCH 0/6] ceph: virtual extended attribute cleanup Alex Elder
2012-02-29 3:21 ` [PATCH 1/6] ceph: use a symbolic name for "ceph." extended attribute namespace Alex Elder
2012-02-29 3:21 ` Alex Elder [this message]
2012-02-29 3:21 ` [PATCH 3/6] ceph: drop "_cb" from name of struct ceph_vxattr_cb Alex Elder
2012-02-29 3:21 ` [PATCH 4/6] ceph: encode type in vxattr callback routines Alex Elder
2012-02-29 3:21 ` [PATCH 5/6] ceph: avoid repeatedly computing the size of constant vxattr names Alex Elder
2012-02-29 4:47 ` Yehuda Sadeh Weinraub
2012-02-29 5:19 ` Alex Elder
2012-02-29 3:21 ` [PATCH 6/6] ceph: make ceph_setxattr() and ceph_removexattr() more alike Alex Elder
2012-03-02 19:35 ` Sage Weil
2012-03-03 4:17 ` Alex Elder
2012-02-29 4:20 ` [PATCH 0/6] ceph: virtual extended attribute cleanup Christoph Hellwig
2012-02-29 5:15 ` Alex Elder
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=4F4D99CA.8070509@dreamhost.com \
--to=elder@dreamhost.com \
--cc=ceph-devel@vger.kernel.org \
/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.