aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph
diff options
context:
space:
mode:
authorYan, Zheng <zyan@redhat.com>2019-01-08 22:07:02 -0500
committerIlya Dryomov <idryomov@gmail.com>2019-03-05 12:55:16 -0500
commit08796873a5183bfaab52a3bd899fe82f9e64be94 (patch)
treeaf3e31c0d12b4b55ca3bf558c1538a0bff9961b2 /fs/ceph
parentb37fe1f923fb4b17dc7d63406ec8dc67f13c2799 (diff)
ceph: support getting ceph.dir.pin vxattr
Link: http://tracker.ceph.com/issues/37576 Signed-off-by: "Yan, Zheng" <zyan@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/ceph')
-rw-r--r--fs/ceph/inode.c1
-rw-r--r--fs/ceph/mds_client.c9
-rw-r--r--fs/ceph/mds_client.h1
-rw-r--r--fs/ceph/super.h2
-rw-r--r--fs/ceph/xattr.c20
5 files changed, 32 insertions, 1 deletions
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 7f82ceff510a..e6012de58aae 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -877,6 +877,7 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
877 ci->i_rbytes = le64_to_cpu(info->rbytes); 877 ci->i_rbytes = le64_to_cpu(info->rbytes);
878 ci->i_rfiles = le64_to_cpu(info->rfiles); 878 ci->i_rfiles = le64_to_cpu(info->rfiles);
879 ci->i_rsubdirs = le64_to_cpu(info->rsubdirs); 879 ci->i_rsubdirs = le64_to_cpu(info->rsubdirs);
880 ci->i_dir_pin = iinfo->dir_pin;
880 ceph_decode_timespec64(&ci->i_rctime, &info->rctime); 881 ceph_decode_timespec64(&ci->i_rctime, &info->rctime);
881 } 882 }
882 } 883 }
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index e87544e42488..ddfb6a45575b 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -157,6 +157,13 @@ static int parse_reply_info_in(void **p, void *end,
157 ceph_decode_64_safe(p, end, change_attr, bad); 157 ceph_decode_64_safe(p, end, change_attr, bad);
158 } 158 }
159 159
160 /* dir pin */
161 if (struct_v >= 2) {
162 ceph_decode_32_safe(p, end, info->dir_pin, bad);
163 } else {
164 info->dir_pin = -ENODATA;
165 }
166
160 *p = end; 167 *p = end;
161 } else { 168 } else {
162 if (features & CEPH_FEATURE_MDS_INLINE_DATA) { 169 if (features & CEPH_FEATURE_MDS_INLINE_DATA) {
@@ -187,6 +194,8 @@ static int parse_reply_info_in(void **p, void *end,
187 *p += info->pool_ns_len; 194 *p += info->pool_ns_len;
188 } 195 }
189 } 196 }
197
198 info->dir_pin = -ENODATA;
190 } 199 }
191 return 0; 200 return 0;
192bad: 201bad:
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h
index 0919aacc1af3..af3b25e59e90 100644
--- a/fs/ceph/mds_client.h
+++ b/fs/ceph/mds_client.h
@@ -68,6 +68,7 @@ struct ceph_mds_reply_info_in {
68 char *pool_ns_data; 68 char *pool_ns_data;
69 u64 max_bytes; 69 u64 max_bytes;
70 u64 max_files; 70 u64 max_files;
71 s32 dir_pin;
71}; 72};
72 73
73struct ceph_mds_reply_dir_entry { 74struct ceph_mds_reply_dir_entry {
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 5b15ae91024a..df44a7761472 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -318,6 +318,8 @@ struct ceph_inode_info {
318 /* quotas */ 318 /* quotas */
319 u64 i_max_bytes, i_max_files; 319 u64 i_max_bytes, i_max_files;
320 320
321 s32 i_dir_pin;
322
321 struct rb_root i_fragtree; 323 struct rb_root i_fragtree;
322 int i_fragtree_nsplits; 324 int i_fragtree_nsplits;
323 struct mutex i_fragtree_mutex; 325 struct mutex i_fragtree_mutex;
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 316f6ad10644..0cc42c8879e9 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -228,8 +228,19 @@ static size_t ceph_vxattrcb_dir_rctime(struct ceph_inode_info *ci, char *val,
228 ci->i_rctime.tv_nsec); 228 ci->i_rctime.tv_nsec);
229} 229}
230 230
231/* quotas */ 231/* dir pin */
232static bool ceph_vxattrcb_dir_pin_exists(struct ceph_inode_info *ci)
233{
234 return ci->i_dir_pin != -ENODATA;
235}
236
237static size_t ceph_vxattrcb_dir_pin(struct ceph_inode_info *ci, char *val,
238 size_t size)
239{
240 return snprintf(val, size, "%d", (int)ci->i_dir_pin);
241}
232 242
243/* quotas */
233static bool ceph_vxattrcb_quota_exists(struct ceph_inode_info *ci) 244static bool ceph_vxattrcb_quota_exists(struct ceph_inode_info *ci)
234{ 245{
235 bool ret = false; 246 bool ret = false;
@@ -315,6 +326,13 @@ static struct ceph_vxattr ceph_dir_vxattrs[] = {
315 XATTR_RSTAT_FIELD(dir, rbytes), 326 XATTR_RSTAT_FIELD(dir, rbytes),
316 XATTR_RSTAT_FIELD(dir, rctime), 327 XATTR_RSTAT_FIELD(dir, rctime),
317 { 328 {
329 .name = "ceph.dir.pin",
330 .name_size = sizeof("ceph.dir_pin"),
331 .getxattr_cb = ceph_vxattrcb_dir_pin,
332 .exists_cb = ceph_vxattrcb_dir_pin_exists,
333 .flags = VXATTR_FLAG_HIDDEN,
334 },
335 {
318 .name = "ceph.quota", 336 .name = "ceph.quota",
319 .name_size = sizeof("ceph.quota"), 337 .name_size = sizeof("ceph.quota"),
320 .getxattr_cb = ceph_vxattrcb_quota, 338 .getxattr_cb = ceph_vxattrcb_quota,