diff options
author | Sage Weil <sage@inktank.com> | 2013-01-19 19:46:32 -0500 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-02-13 21:26:10 -0500 |
commit | 32ab0bd78d7d9235efb38ad5cba6a3a6b39a1da6 (patch) | |
tree | 84fc83be1c5008b4b233c1eba17bf22f2ae3502b /fs/ceph | |
parent | b65917dd2700b7d12e25e2e0bbfd58eb3c932158 (diff) |
ceph: change ceph.file.layout.* implementation, content
Implement a new method to generate the ceph.file.layout vxattr using
the new framework.
Use 'stripe_unit' instead of 'chunk_size'.
Include pool name, either as a string or as an integer.
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Sam Lang <sam.lang@inktank.com>
Diffstat (limited to 'fs/ceph')
-rw-r--r-- | fs/ceph/xattr.c | 67 |
1 files changed, 53 insertions, 14 deletions
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c index ec09ea5c4f07..532c95a6c9fa 100644 --- a/fs/ceph/xattr.c +++ b/fs/ceph/xattr.c | |||
@@ -33,6 +33,50 @@ struct ceph_vxattr { | |||
33 | bool (*exists_cb)(struct ceph_inode_info *ci); | 33 | bool (*exists_cb)(struct ceph_inode_info *ci); |
34 | }; | 34 | }; |
35 | 35 | ||
36 | /* layouts */ | ||
37 | |||
38 | static bool ceph_vxattrcb_layout_exists(struct ceph_inode_info *ci) | ||
39 | { | ||
40 | size_t s; | ||
41 | char *p = (char *)&ci->i_layout; | ||
42 | |||
43 | for (s = 0; s < sizeof(ci->i_layout); s++, p++) | ||
44 | if (*p) | ||
45 | return true; | ||
46 | return false; | ||
47 | } | ||
48 | |||
49 | static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val, | ||
50 | size_t size) | ||
51 | { | ||
52 | int ret; | ||
53 | struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb); | ||
54 | struct ceph_osd_client *osdc = &fsc->client->osdc; | ||
55 | s64 pool = ceph_file_layout_pg_pool(ci->i_layout); | ||
56 | const char *pool_name; | ||
57 | |||
58 | dout("ceph_vxattrcb_layout %p\n", &ci->vfs_inode); | ||
59 | down_read(&osdc->map_sem); | ||
60 | pool_name = ceph_pg_pool_name_by_id(osdc->osdmap, pool); | ||
61 | if (pool_name) | ||
62 | ret = snprintf(val, size, | ||
63 | "stripe_unit=%lld stripe_count=%lld object_size=%lld pool=%s", | ||
64 | (unsigned long long)ceph_file_layout_su(ci->i_layout), | ||
65 | (unsigned long long)ceph_file_layout_stripe_count(ci->i_layout), | ||
66 | (unsigned long long)ceph_file_layout_object_size(ci->i_layout), | ||
67 | pool_name); | ||
68 | else | ||
69 | ret = snprintf(val, size, | ||
70 | "stripe_unit=%lld stripe_count=%lld object_size=%lld pool=%lld", | ||
71 | (unsigned long long)ceph_file_layout_su(ci->i_layout), | ||
72 | (unsigned long long)ceph_file_layout_stripe_count(ci->i_layout), | ||
73 | (unsigned long long)ceph_file_layout_object_size(ci->i_layout), | ||
74 | (unsigned long long)pool); | ||
75 | |||
76 | up_read(&osdc->map_sem); | ||
77 | return ret; | ||
78 | } | ||
79 | |||
36 | /* directories */ | 80 | /* directories */ |
37 | 81 | ||
38 | static size_t ceph_vxattrcb_dir_entries(struct ceph_inode_info *ci, char *val, | 82 | static size_t ceph_vxattrcb_dir_entries(struct ceph_inode_info *ci, char *val, |
@@ -84,6 +128,7 @@ static size_t ceph_vxattrcb_dir_rctime(struct ceph_inode_info *ci, char *val, | |||
84 | (long)ci->i_rctime.tv_nsec); | 128 | (long)ci->i_rctime.tv_nsec); |
85 | } | 129 | } |
86 | 130 | ||
131 | |||
87 | #define CEPH_XATTR_NAME(_type, _name) XATTR_CEPH_PREFIX #_type "." #_name | 132 | #define CEPH_XATTR_NAME(_type, _name) XATTR_CEPH_PREFIX #_type "." #_name |
88 | 133 | ||
89 | #define XATTR_NAME_CEPH(_type, _name) \ | 134 | #define XATTR_NAME_CEPH(_type, _name) \ |
@@ -111,21 +156,15 @@ static size_t ceph_dir_vxattrs_name_size; /* total size of all names */ | |||
111 | 156 | ||
112 | /* files */ | 157 | /* files */ |
113 | 158 | ||
114 | static size_t ceph_vxattrcb_file_layout(struct ceph_inode_info *ci, char *val, | ||
115 | size_t size) | ||
116 | { | ||
117 | int ret; | ||
118 | |||
119 | ret = snprintf(val, size, | ||
120 | "chunk_bytes=%lld\nstripe_count=%lld\nobject_size=%lld\n", | ||
121 | (unsigned long long)ceph_file_layout_su(ci->i_layout), | ||
122 | (unsigned long long)ceph_file_layout_stripe_count(ci->i_layout), | ||
123 | (unsigned long long)ceph_file_layout_object_size(ci->i_layout)); | ||
124 | return ret; | ||
125 | } | ||
126 | |||
127 | static struct ceph_vxattr ceph_file_vxattrs[] = { | 159 | static struct ceph_vxattr ceph_file_vxattrs[] = { |
128 | XATTR_NAME_CEPH(file, layout), | 160 | { |
161 | .name = "ceph.file.layout", | ||
162 | .name_size = sizeof("ceph.file.layout"), | ||
163 | .getxattr_cb = ceph_vxattrcb_layout, | ||
164 | .readonly = false, | ||
165 | .hidden = false, | ||
166 | .exists_cb = ceph_vxattrcb_layout_exists, | ||
167 | }, | ||
129 | { 0 } /* Required table terminator */ | 168 | { 0 } /* Required table terminator */ |
130 | }; | 169 | }; |
131 | static size_t ceph_file_vxattrs_name_size; /* total size of all names */ | 170 | static size_t ceph_file_vxattrs_name_size; /* total size of all names */ |