aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAlex Elder <elder@dreamhost.com>2012-01-23 16:49:28 -0500
committerAlex Elder <elder@dreamhost.com>2012-03-22 11:47:46 -0400
commiteb78808446aeed8e25b080c66bf823c1f188236d (patch)
treed6d907a1028ead5286721f7d165c8cd20a6f4632 /fs
parent22891907193e005923a14384d82d702f6af4f0cf (diff)
ceph: use macros to normalize vxattr table definitions
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> Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs')
-rw-r--r--fs/ceph/xattr.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 05bb56f402a4..38aef476f786 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -25,10 +25,10 @@ static bool ceph_is_valid_xattr(const char *name)
25 * statistics and layout metadata. 25 * statistics and layout metadata.
26 */ 26 */
27struct ceph_vxattr_cb { 27struct ceph_vxattr_cb {
28 bool readonly;
29 char *name; 28 char *name;
30 size_t (*getxattr_cb)(struct ceph_inode_info *ci, char *val, 29 size_t (*getxattr_cb)(struct ceph_inode_info *ci, char *val,
31 size_t size); 30 size_t size);
31 bool readonly;
32}; 32};
33 33
34/* directories */ 34/* directories */
@@ -82,16 +82,25 @@ static size_t ceph_vxattrcb_rctime(struct ceph_inode_info *ci, char *val,
82 (long)ci->i_rctime.tv_nsec); 82 (long)ci->i_rctime.tv_nsec);
83} 83}
84 84
85#define CEPH_XATTR_NAME(_type, _name) XATTR_CEPH_PREFIX #_type "." #_name
86
87#define XATTR_NAME_CEPH(_type, _name) \
88 { \
89 .name = CEPH_XATTR_NAME(_type, _name), \
90 .getxattr_cb = ceph_vxattrcb_ ## _name, \
91 .readonly = true, \
92 }
93
85static struct ceph_vxattr_cb ceph_dir_vxattrs[] = { 94static struct ceph_vxattr_cb ceph_dir_vxattrs[] = {
86 { true, XATTR_CEPH_PREFIX "dir.entries", ceph_vxattrcb_entries}, 95 XATTR_NAME_CEPH(dir, entries),
87 { true, XATTR_CEPH_PREFIX "dir.files", ceph_vxattrcb_files}, 96 XATTR_NAME_CEPH(dir, files),
88 { true, XATTR_CEPH_PREFIX "dir.subdirs", ceph_vxattrcb_subdirs}, 97 XATTR_NAME_CEPH(dir, subdirs),
89 { true, XATTR_CEPH_PREFIX "dir.rentries", ceph_vxattrcb_rentries}, 98 XATTR_NAME_CEPH(dir, rentries),
90 { true, XATTR_CEPH_PREFIX "dir.rfiles", ceph_vxattrcb_rfiles}, 99 XATTR_NAME_CEPH(dir, rfiles),
91 { true, XATTR_CEPH_PREFIX "dir.rsubdirs", ceph_vxattrcb_rsubdirs}, 100 XATTR_NAME_CEPH(dir, rsubdirs),
92 { true, XATTR_CEPH_PREFIX "dir.rbytes", ceph_vxattrcb_rbytes}, 101 XATTR_NAME_CEPH(dir, rbytes),
93 { true, XATTR_CEPH_PREFIX "dir.rctime", ceph_vxattrcb_rctime}, 102 XATTR_NAME_CEPH(dir, rctime),
94 { true, NULL, NULL } 103 { 0 } /* Required table terminator */
95}; 104};
96 105
97/* files */ 106/* files */
@@ -114,10 +123,14 @@ static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,
114} 123}
115 124
116static struct ceph_vxattr_cb ceph_file_vxattrs[] = { 125static struct ceph_vxattr_cb ceph_file_vxattrs[] = {
117 { true, XATTR_CEPH_PREFIX "file.layout", ceph_vxattrcb_layout}, 126 XATTR_NAME_CEPH(file, layout),
118 /* The following extended attribute name is deprecated */ 127 /* The following extended attribute name is deprecated */
119 { true, XATTR_CEPH_PREFIX "layout", ceph_vxattrcb_layout}, 128 {
120 { true, NULL, NULL } 129 .name = XATTR_CEPH_PREFIX "layout",
130 .getxattr_cb = ceph_vxattrcb_layout,
131 .readonly = true,
132 },
133 { 0 } /* Required table terminator */
121}; 134};
122 135
123static struct ceph_vxattr_cb *ceph_inode_vxattrs(struct inode *inode) 136static struct ceph_vxattr_cb *ceph_inode_vxattrs(struct inode *inode)