aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@suse.de>2019-04-18 08:15:47 -0400
committerIlya Dryomov <idryomov@gmail.com>2019-07-08 08:01:41 -0400
commit100cc610a550affcbef13d74855f736b92caa947 (patch)
treefdcf3a5e51ab14da5726853695050bfe12f2f910 /fs/ceph
parent193e7b37628e97c6e66ec26a2c062dace68b4acd (diff)
ceph: add ceph.snap.btime vxattr
The ceph.snap.btime virtual xattr provides the snapshot creation (birth) time in $secs.$nsecs format. Link: https://tracker.ceph.com/issues/38838 Signed-off-by: David Disseldorp <ddiss@suse.de> Reviewed-by: "Yan, Zheng" <zyan@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/ceph')
-rw-r--r--fs/ceph/xattr.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 2cbb9c239183..5d8a6f7c5869 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -273,6 +273,19 @@ static size_t ceph_vxattrcb_quota_max_files(struct ceph_inode_info *ci,
273 return snprintf(val, size, "%llu", ci->i_max_files); 273 return snprintf(val, size, "%llu", ci->i_max_files);
274} 274}
275 275
276/* snapshots */
277static bool ceph_vxattrcb_snap_btime_exists(struct ceph_inode_info *ci)
278{
279 return (ci->i_snap_btime.tv_sec != 0 || ci->i_snap_btime.tv_nsec != 0);
280}
281
282static size_t ceph_vxattrcb_snap_btime(struct ceph_inode_info *ci, char *val,
283 size_t size)
284{
285 return snprintf(val, size, "%lld.%09ld", ci->i_snap_btime.tv_sec,
286 ci->i_snap_btime.tv_nsec);
287}
288
276#define CEPH_XATTR_NAME(_type, _name) XATTR_CEPH_PREFIX #_type "." #_name 289#define CEPH_XATTR_NAME(_type, _name) XATTR_CEPH_PREFIX #_type "." #_name
277#define CEPH_XATTR_NAME2(_type, _name, _name2) \ 290#define CEPH_XATTR_NAME2(_type, _name, _name2) \
278 XATTR_CEPH_PREFIX #_type "." #_name "." #_name2 291 XATTR_CEPH_PREFIX #_type "." #_name "." #_name2
@@ -341,6 +354,13 @@ static struct ceph_vxattr ceph_dir_vxattrs[] = {
341 }, 354 },
342 XATTR_QUOTA_FIELD(quota, max_bytes), 355 XATTR_QUOTA_FIELD(quota, max_bytes),
343 XATTR_QUOTA_FIELD(quota, max_files), 356 XATTR_QUOTA_FIELD(quota, max_files),
357 {
358 .name = "ceph.snap.btime",
359 .name_size = sizeof("ceph.snap.btime"),
360 .getxattr_cb = ceph_vxattrcb_snap_btime,
361 .exists_cb = ceph_vxattrcb_snap_btime_exists,
362 .flags = VXATTR_FLAG_READONLY,
363 },
344 { .name = NULL, 0 } /* Required table terminator */ 364 { .name = NULL, 0 } /* Required table terminator */
345}; 365};
346static size_t ceph_dir_vxattrs_name_size; /* total size of all names */ 366static size_t ceph_dir_vxattrs_name_size; /* total size of all names */
@@ -360,6 +380,13 @@ static struct ceph_vxattr ceph_file_vxattrs[] = {
360 XATTR_LAYOUT_FIELD(file, layout, object_size), 380 XATTR_LAYOUT_FIELD(file, layout, object_size),
361 XATTR_LAYOUT_FIELD(file, layout, pool), 381 XATTR_LAYOUT_FIELD(file, layout, pool),
362 XATTR_LAYOUT_FIELD(file, layout, pool_namespace), 382 XATTR_LAYOUT_FIELD(file, layout, pool_namespace),
383 {
384 .name = "ceph.snap.btime",
385 .name_size = sizeof("ceph.snap.btime"),
386 .getxattr_cb = ceph_vxattrcb_snap_btime,
387 .exists_cb = ceph_vxattrcb_snap_btime_exists,
388 .flags = VXATTR_FLAG_READONLY,
389 },
363 { .name = NULL, 0 } /* Required table terminator */ 390 { .name = NULL, 0 } /* Required table terminator */
364}; 391};
365static size_t ceph_file_vxattrs_name_size; /* total size of all names */ 392static size_t ceph_file_vxattrs_name_size; /* total size of all names */