ceph: add subvolume metrics reporting support
Subsystems (2)
Alex Markuze
maintainerv3 cover ceph: add subvolume metrics reporting support
This patch series adds support for per-subvolume I/O metrics collection and reporting to the MDS. This enables administrators to monitor I/O patterns at the subvolume granularity, which is useful for multi-tenant CephFS deployments where different subvolumes may be allocated to different users or applications.
The implementation requires protocol changes to receive the subvolume_id from the MDS (InodeStat v9), and introduces a new metrics type (CLIENT_METRIC_TYPE_SUBVOLUME_METRICS) for reporting aggregated I/O statistics back to the MDS.
Patch 1 adds forward-compatible handling for InodeStat v8. The MDS v8 encoding added a versioned optmetadata field containing optional inode metadata such as charmap (for case-insensitive/case-preserving file systems). The kernel client does not currently support case-insensitive lookups, so this field is skipped rather than parsed. This ensures forward compatibility with newer MDS servers without requiring the full case-insensitivity feature implementation.
Patch 2 adds support for parsing the subvolume_id field from InodeStat v9 and storing it in the inode structure for later use.
Patch 3 adds the complete subvolume metrics infrastructure:
- CEPHFS_FEATURE_SUBVOLUME_METRICS feature flag for MDS negotiation
- Red-black tree based metrics tracker for efficient per-subvolume aggregation with kmem_cache for entry allocations
- Wire format encoding matching the MDS C++ AggregatedIOMetrics struct
- Integration with the existing CLIENT_METRICS message
- Recording of I/O operations from file read/write and writeback paths
- Debugfs interfaces for monitoring
Metrics tracked per subvolume include:
- Read/write operation counts
- Read/write byte counts
- Read/write latency sums (for average calculation)
The metrics are periodically sent to the MDS as part of the existing metrics reporting infrastructure when the MDS advertises support for the SUBVOLUME_METRICS feature.
Debugfs additions in Patch 3:
- metrics/subvolumes: displays last sent and pending subvolume metrics
- metrics/metric_features: displays MDS session feature negotiation status, showing which metric-related features are enabled (including METRIC_COLLECT and SUBVOLUME_METRICS)
Patch 4 introduces CEPH_SUBVOLUME_ID_NONE constant and enforces subvolume_id immutability. Following the FUSE client convention, 0 means unknown/unset. Once an inode has a valid (non-zero) subvolume_id, it should not change during the inode's lifetime.
Changes since v2:
- Add CEPH_SUBVOLUME_ID_NONE constant (value 0) for unknown/unset state
- Add WARN_ON_ONCE if attempting to change already-set subvolume_id
- Add documentation for struct ceph_session_feature_desc ('bit' field)
- Change pr_err() to pr_info() for "metrics disabled" message
- Use pr_warn_ratelimited() instead of manual __ratelimit()
- Add documentation comments to ceph_subvol_metric_snapshot and ceph_subvolume_metrics_tracker structs
- Use kmemdup_array() instead of kmemdup() for overflow checking
- Add comments explaining ret > 0 checks for read metrics (EOF handling)
- Use kmem_cache for struct ceph_subvol_metric_rb_entry allocations
- Add comment explaining seq_file error handling in dump function
Changes since v1:
- Fixed unused variable warnings (v8_struct_v, v8_struct_compat) by using ceph_decode_skip_8() instead of ceph_decode_8_safe()
- Added detailed comment explaining InodeStat encoding versions v1-v9
- Clarified that "optmetadata" is the actual field name in MDS C++ code
- Aligned subvolume_id handling with FUSE client convention (0 = unknown)
Alex Markuze (4):
ceph: handle InodeStat v8 versioned field in reply parsing
ceph: parse subvolume_id from InodeStat v9 and store in inode
ceph: add subvolume metrics collection and reporting
ceph: adding CEPH_SUBVOLUME_ID_NONE
fs/ceph/Makefile | 2 +- fs/ceph/addr.c | 10 + fs/ceph/debugfs.c | 159 +++++++++++++ fs/ceph/file.c | 68 +++++- fs/ceph/inode.c | 41 ++++ fs/ceph/mds_client.c | 94 ++++++-- fs/ceph/mds_client.h | 14 +- fs/ceph/metric.c | 173 ++++++++++++++- fs/ceph/metric.h | 27 ++- fs/ceph/subvolume_metrics.c | 432 ++++++++++++++++++++++++++++++++++++ fs/ceph/subvolume_metrics.h | 97 ++++++++ fs/ceph/super.c | 8 + fs/ceph/super.h | 11 + 13 files changed, 1108 insertions(+), 28 deletions(-) create mode 100644 fs/ceph/subvolume_metrics.c create mode 100644 fs/ceph/subvolume_metrics.h
Signature · 1 line
2.34.1
Alex Markuze
maintainerPATCH v3 1/4 ceph: handle InodeStat v8 versioned field in reply parsing
Add forward-compatible handling for the new versioned field introduced in InodeStat v8. This patch only skips the field without using it, preparing for future protocol extensions.
The v8 encoding adds a versioned sub-structure that needs to be properly decoded and skipped to maintain compatibility with newer MDS versions.
--- fs/ceph/mds_client.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
fs/ceph/mds_client.c +20 -0
@@ -231,6 +231,26 @@ static int parse_reply_info_in(void **p, void *end, info->fscrypt_file_len, bad); } } + +/* +* InodeStat encoding versions: +* v1-v7: various fields added over time +* v8: added optmetadata (versioned sub-structure containing +* optional inode metadata like charmap for case-insensitive +* filesystems). The kernel client doesn't support +* case-insensitive lookups, so we skip this field. +* v9: added subvolume_id (parsed below) +*/ +if (struct_v >=8 ) { +u32 v8_struct_len; + +/* skip optmetadata versioned sub-structure */ +ceph_decode_skip_8 (p, end, bad);/* struct_v */ +ceph_decode_skip_8 (p, end, bad);/* struct_compat */ +ceph_decode_32_safe (p, end, v8_struct_len, bad); +ceph_decode_skip_n (p, end, v8_struct_len, bad); + } + *p = end; }else {/* legacy (unversioned) struct */
Signature · 1 line
2.34.1
Alex Markuze
maintainerPATCH v3 2/4 ceph: parse subvolume_id from InodeStat v9 and store in inode
In reply to Alex MarkuzeAdd support for parsing the subvolume_id field from InodeStat v9 and storing it in the inode for later use by subvolume metrics tracking.
The subvolume_id identifies which CephFS subvolume an inode belongs to, enabling per-subvolume I/O metrics collection and reporting.
This patch:
- Adds subvolume_id field to struct ceph_mds_reply_info_in
- Adds i_subvolume_id field to struct ceph_inode_info
- Parses subvolume_id from v9 InodeStat in parse_reply_info_in()
- Adds ceph_inode_set_subvolume() helper to propagate the ID to inodes
- Initializes i_subvolume_id in inode allocation and clears on destroy
--- fs/ceph/inode.c | 23 +++++++++++++++++++++++ fs/ceph/mds_client.c | 7 +++++++ fs/ceph/mds_client.h | 1 + fs/ceph/super.h | 2 ++ 4 files changed, 33 insertions(+)
fs/ceph/inode.c +23 -0
@@ -638,6 +638,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb) ci->i_max_bytes =0 ; ci->i_max_files =0 ; + ci->i_subvolume_id =0 ;memset (&ci->i_dir_layout,0 ,sizeof (ci->i_dir_layout));memset (&ci->i_cached_layout,0 ,sizeof (ci->i_cached_layout));
@@ -742,6 +743,8 @@ void ceph_evict_inode(struct inode *inode)percpu_counter_dec (&mdsc->metric.total_inodes); + ci->i_subvolume_id =0 ; +netfs_wait_for_outstanding_io (inode);truncate_inode_pages_final (&inode->i_data);if (inode->i_state &I_PINNING_NETFS_WB )
@@ -873,6 +876,22 @@ int ceph_fill_file_size(struct inode *inode, int issued,return queue_trunc; } +/* +* Set the subvolume ID for an inode. Following the FUSE client convention, +* 0 means unknown/unset (MDS only sends non-zero IDs for subvolume inodes). +*/ +void ceph_inode_set_subvolume (struct inode *inode,u64 subvolume_id) +{ +struct ceph_inode_info *ci; + +if (!inode || !subvolume_id) +return ; + + ci =ceph_inode (inode); +if (READ_ONCE (ci->i_subvolume_id) != subvolume_id) +WRITE_ONCE (ci->i_subvolume_id, subvolume_id); +} +void ceph_fill_file_time (struct inode *inode,int issued,u64 time_warp_seq,struct timespec64 *ctime,struct timespec64 *mtime,struct timespec64 *atime)
@@ -1087,6 +1106,7 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page, new_issued = ~issued & info_caps;__ceph_update_quota (ci, iinfo->max_bytes, iinfo->max_files); +ceph_inode_set_subvolume (inode, iinfo->subvolume_id);#ifdef CONFIG_FS_ENCRYPTION if (iinfo->fscrypt_auth_len &&
@@ -1594,6 +1614,8 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req) goto done; }if (parent_dir) { +ceph_inode_set_subvolume (parent_dir, + rinfo->diri.subvolume_id); err =ceph_fill_inode (parent_dir,NULL , &rinfo->diri, rinfo->dirfrag, session,-1 , &req->r_caps_reservation);
@@ -1682,6 +1704,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req)BUG_ON (!req->r_target_inode); in = req->r_target_inode; +ceph_inode_set_subvolume (in, rinfo->targeti.subvolume_id); err = ceph_fill_inode(in, req->r_locked_page, &rinfo->targeti, NULL, session, (!test_bit(CEPH_MDS_R_ABORTED, &req->r_req_flags) &&
fs/ceph/mds_client.c +7 -0
@@ -105,6 +105,8 @@ static int parse_reply_info_in(void **p, void *end,int err =0 ;u8 struct_v =0 ; + info->subvolume_id =0 ; +if (features == (u64)-1 ) {u32 struct_len;u8 struct_compat;
@@ -251,6 +253,10 @@ static int parse_reply_info_in(void **p, void *end,ceph_decode_skip_n (p, end, v8_struct_len, bad); } +/* struct_v 9 added subvolume_id */ +if (struct_v >=9 ) +ceph_decode_64_safe (p, end, info->subvolume_id, bad); + *p = end; }else {/* legacy (unversioned) struct */
@@ -3970,6 +3976,7 @@ static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg) goto out_err; } req->r_target_inode = in; +ceph_inode_set_subvolume (in, rinfo->targeti.subvolume_id); }mutex_lock (&session->s_mutex);
fs/ceph/mds_client.h +1 -0
@@ -118,6 +118,7 @@ struct ceph_mds_reply_info_in {u32 fscrypt_file_len;u64 rsnaps;u64 change_attr; +u64 subvolume_id; };struct ceph_mds_reply_dir_entry {
fs/ceph/super.h +2 -0
@@ -385,6 +385,7 @@ struct ceph_inode_info {/* quotas */ u64 i_max_bytes, i_max_files; +u64 i_subvolume_id;/* 0 = unknown/unset, matches FUSE client */ s32 i_dir_pin;
@@ -1057,6 +1058,7 @@ extern struct inode *ceph_get_inode(struct super_block *sb,extern struct inode *ceph_get_snapdir (struct inode *parent);extern int ceph_fill_file_size (struct inode *inode,int issued,u32 truncate_seq,u64 truncate_size,u64 size); +extern void ceph_inode_set_subvolume (struct inode *inode,u64 subvolume_id); extern void ceph_fill_file_time(struct inode *inode, int issued, u64 time_warp_seq, struct timespec64 *ctime, struct timespec64 *mtime,
Signature · 1 line
2.34.1
Alex Markuze
maintainerPATCH v3 3/4 ceph: add subvolume metrics collection and reporting
In reply to Alex MarkuzeAdd complete subvolume metrics infrastructure for tracking and reporting per-subvolume I/O metrics to the MDS. This enables administrators to monitor I/O patterns at the subvolume granularity.
The implementation includes:
- New CEPHFS_FEATURE_SUBVOLUME_METRICS feature flag for MDS negotiation
- Red-black tree based metrics tracker (subvolume_metrics.c/h)
- Wire format encoding matching the MDS C++ AggregatedIOMetrics struct
- Integration with the existing metrics reporting infrastructure
- Recording of I/O operations from file read/write paths
- Debugfs interface for monitoring collected metrics
Metrics tracked per subvolume:
- Read/write operation counts
- Read/write byte counts
- Read/write latency sums (for average calculation)
The metrics are periodically sent to the MDS as part of the existing CLIENT_METRICS message when the MDS advertises support for the SUBVOLUME_METRICS feature.
--- fs/ceph/Makefile | 2 +- fs/ceph/addr.c | 10 + fs/ceph/debugfs.c | 159 +++++++++++++ fs/ceph/file.c | 68 +++++- fs/ceph/mds_client.c | 70 ++++-- fs/ceph/mds_client.h | 13 +- fs/ceph/metric.c | 173 ++++++++++++++- fs/ceph/metric.h | 27 ++- fs/ceph/subvolume_metrics.c | 431 ++++++++++++++++++++++++++++++++++++ fs/ceph/subvolume_metrics.h | 97 ++++++++ fs/ceph/super.c | 8 + fs/ceph/super.h | 1 + 12 files changed, 1031 insertions(+), 28 deletions(-) create mode 100644 fs/ceph/subvolume_metrics.c create mode 100644 fs/ceph/subvolume_metrics.h
fs/ceph/Makefile +1 -1
@@ -8,7 +8,7 @@ obj-$(CONFIG_CEPH_FS) += ceph.o ceph-y := super.o inode.o dir.o file.o locks.o addr.o ioctl.o \ export.o caps.o snap.o xattr.o quota.o io.o \ mds_client.o mdsmap.o strings.o ceph_frag.o \ - debugfs.o util.o metric.o + debugfs.o util.o metric.o subvolume_metrics.o ceph-$(CONFIG_CEPH_FSCACHE) += cache.o ceph-$(CONFIG_CEPH_FS_POSIX_ACL) += acl.o
fs/ceph/addr.c +10 -0
@@ -19,6 +19,7 @@#include "mds_client.h" #include "cache.h" #include "metric.h" +#include "subvolume_metrics.h" #include "crypto.h" #include <linux/ceph/osd_client.h> #include <linux/ceph/striper.h>
@@ -823,6 +824,10 @@ static int write_folio_nounlock(struct folio *folio,ceph_update_write_metrics (&fsc->mdsc->metric, req->r_start_latency, req->r_end_latency, len, err); +if (err >=0 && len >0 ) +ceph_subvolume_metrics_record_io (fsc->mdsc, ci, true, len, + req->r_start_latency, + req->r_end_latency);fscrypt_free_bounce_page (bounce_page);ceph_osdc_put_request (req);if (err ==0 )
@@ -963,6 +968,11 @@ static void writepages_finish(struct ceph_osd_request *req)ceph_update_write_metrics (&fsc->mdsc->metric, req->r_start_latency, req->r_end_latency, len, rc); +if (rc >=0 && len >0 ) +ceph_subvolume_metrics_record_io (mdsc, ci, true, len, + req->r_start_latency, + req->r_end_latency); +ceph_put_wrbuffer_cap_refs (ci, total_pages, snapc); osd_data =osd_req_op_extent_osd_data (req,0 );
fs/ceph/debugfs.c +159 -0
201 lines not on this page · raw message
fs/ceph/file.c +64 -4
112 lines not on this page · raw message
fs/ceph/mds_client.c +55 -15
161 lines not on this page · raw message
fs/ceph/mds_client.h +12 -1
@@ -18,6 +18,7 @@#include "mdsmap.h" #include "metric.h" +#include "subvolume_metrics.h" #include "super.h" /* The first 8 bits are reserved for old ceph releases */
@@ -36,8 +37,9 @@ enum ceph_feature_type {CEPHFS_FEATURE_NEW_SNAPREALM_INFO ,CEPHFS_FEATURE_HAS_OWNER_UIDGID ,CEPHFS_FEATURE_MDS_AUTH_CAPS_CHECK , +CEPHFS_FEATURE_SUBVOLUME_METRICS , - CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_MDS_AUTH_CAPS_CHECK, + CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_SUBVOLUME_METRICS, };#define CEPHFS_FEATURES_CLIENT_SUPPORTED { \
@@ -54,6 +56,7 @@ enum ceph_feature_type {CEPHFS_FEATURE_32BITS_RETRY_FWD , \CEPHFS_FEATURE_HAS_OWNER_UIDGID , \CEPHFS_FEATURE_MDS_AUTH_CAPS_CHECK , \ + CEPHFS_FEATURE_SUBVOLUME_METRICS, \ }/*
@@ -537,6 +540,14 @@ struct ceph_mds_client {struct list_head dentry_dir_leases;/* lru list */ struct ceph_client_metric metric; +struct ceph_subvolume_metrics_tracker subvol_metrics; + +/* Subvolume metrics send tracking */ +struct mutex subvol_metrics_last_mutex; +struct ceph_subvol_metric_snapshot *subvol_metrics_last; +u32 subvol_metrics_last_nr; +u64 subvol_metrics_sent; +u64 subvol_metrics_nonzero_sends;spinlock_t snapid_map_lock;struct rb_root snapid_map_tree;
fs/ceph/metric.c +167 -6
239 lines not on this page · raw message
fs/ceph/metric.h +26 -1
@@ -25,8 +25,9 @@ enum ceph_metric_type {CLIENT_METRIC_TYPE_STDEV_WRITE_LATENCY ,CLIENT_METRIC_TYPE_AVG_METADATA_LATENCY ,CLIENT_METRIC_TYPE_STDEV_METADATA_LATENCY , +CLIENT_METRIC_TYPE_SUBVOLUME_METRICS , - CLIENT_METRIC_TYPE_MAX = CLIENT_METRIC_TYPE_STDEV_METADATA_LATENCY, + CLIENT_METRIC_TYPE_MAX = CLIENT_METRIC_TYPE_SUBVOLUME_METRICS, };/*
@@ -50,6 +51,7 @@ enum ceph_metric_type {CLIENT_METRIC_TYPE_STDEV_WRITE_LATENCY , \CLIENT_METRIC_TYPE_AVG_METADATA_LATENCY , \CLIENT_METRIC_TYPE_STDEV_METADATA_LATENCY , \ +CLIENT_METRIC_TYPE_SUBVOLUME_METRICS , \ \ CLIENT_METRIC_TYPE_MAX, \ }
@@ -139,6 +141,29 @@ struct ceph_write_io_size {__le64 total_size; } __packed; +/* Wire format for subvolume metrics - matches C++ AggregatedIOMetrics */ +struct ceph_subvolume_metric_entry_wire { +__le64 subvolume_id; +__le32 read_ops; +__le32 write_ops; +__le64 read_bytes; +__le64 write_bytes; +__le64 read_latency_us; +__le64 write_latency_us; +__le64 time_stamp; +} __packed; + +/* Old struct kept for internal tracking, not used on wire */ +struct ceph_subvolume_metric_entry { +__le64 subvolume_id; +__le64 read_ops; +__le64 write_ops; +__le64 read_bytes; +__le64 write_bytes; +__le64 read_latency_us; +__le64 write_latency_us; +} __packed; +struct ceph_metric_head {__le32 num;/* the number of metrics that will be sent */ } __packed;
fs/ceph/subvolume_metrics.c new file +431 -0
431 lines not on this page · raw message
fs/ceph/subvolume_metrics.h new file +97 -0
97 lines not on this page · raw message
fs/ceph/super.c +8 -0
@@ -21,6 +21,7 @@#include "mds_client.h" #include "cache.h" #include "crypto.h" +#include "subvolume_metrics.h" #include <linux/ceph/ceph_features.h> #include <linux/ceph/decode.h>
@@ -963,8 +964,14 @@ static int __init init_caches(void)if (!ceph_wb_pagevec_pool) goto bad_pagevec_pool; + error =ceph_subvolume_metrics_cache_init (); +if (error) + goto bad_subvol_metrics; +return 0 ; +bad_subvol_metrics: +mempool_destroy (ceph_wb_pagevec_pool); bad_pagevec_pool:kmem_cache_destroy (ceph_mds_request_cachep); bad_mds_req:
@@ -1001,6 +1008,7 @@ static void destroy_caches(void)kmem_cache_destroy (ceph_dir_file_cachep);kmem_cache_destroy (ceph_mds_request_cachep);mempool_destroy (ceph_wb_pagevec_pool); +ceph_subvolume_metrics_cache_destroy (); }static void __ceph_umount_begin (struct ceph_fs_client *fsc)
fs/ceph/super.h +1 -0
@@ -167,6 +167,7 @@ struct ceph_fs_client {struct dentry *debugfs_status;struct dentry *debugfs_mds_sessions;struct dentry *debugfs_metrics_dir; +struct dentry *debugfs_subvolume_metrics;#endif #ifdef CONFIG_CEPH_FSCACHE
Signature · 1 line
2.34.1
Alex Markuze
maintainerPATCH v3 4/4 ceph: adding CEPH_SUBVOLUME_ID_NONE
In reply to Alex Markuze1. Introduce CEPH_SUBVOLUME_ID_NONE constant (value 0) to make the unknown/unset state explicit and self-documenting.
2. Add WARN_ON_ONCE if attempting to change an already-set subvolume_id. An inode's subvolume membership is immutable - once created in a subvolume, it stays there. Attempting to change it indicates a bug.
--- fs/ceph/inode.c | 32 +++++++++++++++++++++++++------- fs/ceph/mds_client.c | 5 +---- fs/ceph/subvolume_metrics.c | 7 ++++--- fs/ceph/super.h | 10 +++++++++- 4 files changed, 39 insertions(+), 15 deletions(-)
fs/ceph/inode.c +25 -7
@@ -638,7 +638,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb) ci->i_max_bytes =0 ; ci->i_max_files =0 ; - ci->i_subvolume_id =0 ; + ci->i_subvolume_id =CEPH_SUBVOLUME_ID_NONE ;memset (&ci->i_dir_layout,0 ,sizeof (ci->i_dir_layout));memset (&ci->i_cached_layout,0 ,sizeof (ci->i_cached_layout));
@@ -743,7 +743,7 @@ void ceph_evict_inode(struct inode *inode)percpu_counter_dec (&mdsc->metric.total_inodes); - ci->i_subvolume_id =0 ; + ci->i_subvolume_id =CEPH_SUBVOLUME_ID_NONE ;netfs_wait_for_outstanding_io (inode);truncate_inode_pages_final (&inode->i_data);
@@ -877,19 +877,37 @@ int ceph_fill_file_size(struct inode *inode, int issued, }/* -* Set the subvolume ID for an inode. Following the FUSE client convention, -* 0 means unknown/unset (MDS only sends non-zero IDs for subvolume inodes). +* Set the subvolume ID for an inode. +* +* The subvolume_id identifies which CephFS subvolume this inode belongs to. +* CEPH_SUBVOLUME_ID_NONE (0) means unknown/unset - the MDS only sends +* non-zero IDs for inodes within subvolumes. +* +* An inode's subvolume membership is immutable - once an inode is created +* in a subvolume, it stays there. Therefore, if we already have a valid +* (non-zero) subvolume_id and receive a different one, that indicates a bug. */ void ceph_inode_set_subvolume (struct inode *inode,u64 subvolume_id) {struct ceph_inode_info *ci; +u64 old; -if (!inode || !subvolume_id) +if (!inode || subvolume_id ==CEPH_SUBVOLUME_ID_NONE )return ; ci =ceph_inode (inode); -if (READ_ONCE (ci->i_subvolume_id) != subvolume_id) -WRITE_ONCE (ci->i_subvolume_id, subvolume_id); + old =READ_ONCE (ci->i_subvolume_id); + +if (old == subvolume_id) +return ; + +if (old !=CEPH_SUBVOLUME_ID_NONE ) { +/* subvolume_id should not change once set */ +WARN_ON_ONCE (1 ); +return ; + } + +WRITE_ONCE (ci->i_subvolume_id, subvolume_id); } void ceph_fill_file_time(struct inode *inode, int issued,
fs/ceph/mds_client.c +1 -4
@@ -122,10 +122,7 @@ static int parse_reply_info_in(void **p, void *end,u32 struct_len =0 ;struct ceph_client *cl = mdsc ? mdsc->fsc->client :NULL ; - info->subvolume_id =0 ; -doutc (cl,"subv_metric parse start features=0x%llx\n" , features); - - info->subvolume_id =0 ; + info->subvolume_id =CEPH_SUBVOLUME_ID_NONE ;if (features == (u64)-1 ) {ceph_decode_8_safe (p, end, struct_v, bad);
fs/ceph/subvolume_metrics.c +4 -3
@@ -136,8 +136,9 @@ void ceph_subvolume_metrics_record(struct ceph_subvolume_metrics_tracker *trackestruct ceph_subvol_metric_rb_entry *entry, *new_entry =NULL ;bool retry = false; -/* 0 means unknown/unset subvolume (matches FUSE client convention) */ -if (!READ_ONCE (tracker->enabled) || !subvol_id || !size || !latency_us) +/* CEPH_SUBVOLUME_ID_NONE (0) means unknown/unset subvolume */ +if (!READ_ONCE (tracker->enabled) || + subvol_id ==CEPH_SUBVOLUME_ID_NONE || !size || !latency_us)return ; do {
@@ -403,7 +404,7 @@ void ceph_subvolume_metrics_record_io(struct ceph_mds_client *mdsc, } subvol_id =READ_ONCE (ci->i_subvolume_id); -if (!subvol_id) { +if (subvol_id ==CEPH_SUBVOLUME_ID_NONE ) {atomic64_inc (&tracker->record_no_subvol);return ; }
fs/ceph/super.h +9 -1
@@ -386,7 +386,15 @@ struct ceph_inode_info {/* quotas */ u64 i_max_bytes, i_max_files; -u64 i_subvolume_id;/* 0 = unknown/unset, matches FUSE client */ + +/* +* Subvolume ID this inode belongs to. CEPH_SUBVOLUME_ID_NONE (0) +* means unknown/unset, matching the FUSE client convention. +* Once set to a valid (non-zero) value, it should not change +* during the inode's lifetime. +*/ +#define CEPH_SUBVOLUME_ID_NONE 0 +u64 i_subvolume_id;s32 i_dir_pin;
Signature · 1 line
2.34.1
Re: [PATCH v3 4/4] ceph: adding CEPH_SUBVOLUME_ID_NONE
Quoted 18 lines · Alex Markuze
1. Introduce
CEPH_SUBVOLUME_ID_NONEconstant (value 0) to make the unknown/unset state explicit and self-documenting.2. Add
WARN_ON_ONCEif attempting to change an already-setsubvolume_id. An inode's subvolume membership is immutable - once created in a subvolume, it stays there. Attempting to change it indicates a bug.--- fs/ceph/inode.c | 32 +++++++++++++++++++++++++------- fs/ceph/mds_client.c | 5 +---- fs/ceph/subvolume_metrics.c | 7 ++++--- fs/ceph/super.h | 10 +++++++++- 4 files changed, 39 insertions(+), 15 deletions(-)fs/ceph/inode.c +0
-0
fs/ceph/inode.c struct inode *ceph_alloc_inode(struct super_block *sb) · line 641
Quoted 5 lines
fs/ceph/inode.c +1
-1@@ -638,7 +638,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb) ci->i_max_bytes =0 ; ci->i_max_files =0 ; - ci->i_subvolume_id =0 ; + ci->i_subvolume_id =CEPH_SUBVOLUME_ID_NONE ;
I was expected to see the code of this patch in the second and third ones. And it looks really confusing. Why have you introduced another one patch?
So, how I can test this patchset? I assume that xfstests run will be not enough. Do we have special test environment or test-cases for this?
Thanks,
Slava.
Quoted 117 lines
fs/ceph/inode.c +24
-6memset (&ci->i_dir_layout,0 ,sizeof (ci->i_dir_layout));memset (&ci->i_cached_layout,0 ,sizeof (ci->i_cached_layout));@@ -743,7 +743,7 @@ void ceph_evict_inode(struct inode *inode)percpu_counter_dec (&mdsc->metric.total_inodes); - ci->i_subvolume_id =0 ; + ci->i_subvolume_id =CEPH_SUBVOLUME_ID_NONE ;netfs_wait_for_outstanding_io (inode);truncate_inode_pages_final (&inode->i_data);@@ -877,19 +877,37 @@ int ceph_fill_file_size(struct inode *inode, int issued, }/* -* Set the subvolume ID for an inode. Following the FUSE client convention, -* 0 means unknown/unset (MDS only sends non-zero IDs for subvolume inodes). +* Set the subvolume ID for an inode. +* +* The subvolume_id identifies which CephFS subvolume this inode belongs to. +* CEPH_SUBVOLUME_ID_NONE (0) means unknown/unset - the MDS only sends +* non-zero IDs for inodes within subvolumes. +* +* An inode's subvolume membership is immutable - once an inode is created +* in a subvolume, it stays there. Therefore, if we already have a valid +* (non-zero) subvolume_id and receive a different one, that indicates a bug. */ void ceph_inode_set_subvolume (struct inode *inode,u64 subvolume_id) {struct ceph_inode_info *ci; +u64 old; -if (!inode || !subvolume_id) +if (!inode || subvolume_id ==CEPH_SUBVOLUME_ID_NONE )return ; ci =ceph_inode (inode); -if (READ_ONCE (ci->i_subvolume_id) != subvolume_id) -WRITE_ONCE (ci->i_subvolume_id, subvolume_id); + old =READ_ONCE (ci->i_subvolume_id); + +if (old == subvolume_id) +return ; + +if (old !=CEPH_SUBVOLUME_ID_NONE ) { +/* subvolume_id should not change once set */ +WARN_ON_ONCE (1 ); +return ; + } + +WRITE_ONCE (ci->i_subvolume_id, subvolume_id); } void ceph_fill_file_time(struct inode *inode, int issued,fs/ceph/mds_client.c +1
-4@@ -122,10 +122,7 @@ static int parse_reply_info_in(void **p, void *end,u32 struct_len =0 ;struct ceph_client *cl = mdsc ? mdsc->fsc->client :NULL ; - info->subvolume_id =0 ; -doutc (cl,"subv_metric parse start features=0x%llx\n" , features); - - info->subvolume_id =0 ; + info->subvolume_id =CEPH_SUBVOLUME_ID_NONE ;if (features == (u64)-1 ) {ceph_decode_8_safe (p, end, struct_v, bad);fs/ceph/subvolume_metrics.c +4
-3@@ -136,8 +136,9 @@ void ceph_subvolume_metrics_record(struct ceph_subvolume_metrics_tracker *trackestruct ceph_subvol_metric_rb_entry *entry, *new_entry =NULL ;bool retry = false; -/* 0 means unknown/unset subvolume (matches FUSE client convention) */ -if (!READ_ONCE (tracker->enabled) || !subvol_id || !size || !latency_us) +/* CEPH_SUBVOLUME_ID_NONE (0) means unknown/unset subvolume */ +if (!READ_ONCE (tracker->enabled) || + subvol_id ==CEPH_SUBVOLUME_ID_NONE || !size || !latency_us)return ; do {@@ -403,7 +404,7 @@ void ceph_subvolume_metrics_record_io(struct ceph_mds_client *mdsc, } subvol_id =READ_ONCE (ci->i_subvolume_id); -if (!subvol_id) { +if (subvol_id ==CEPH_SUBVOLUME_ID_NONE ) {atomic64_inc (&tracker->record_no_subvol);return ; }fs/ceph/super.h +9
-1@@ -386,7 +386,15 @@ struct ceph_inode_info {/* quotas */ u64 i_max_bytes, i_max_files; -u64 i_subvolume_id;/* 0 = unknown/unset, matches FUSE client */ + +/* +* Subvolume ID this inode belongs to. CEPH_SUBVOLUME_ID_NONE (0) +* means unknown/unset, matching the FUSE client convention. +* Once set to a valid (non-zero) value, it should not change +* during the inode's lifetime. +*/ +#define CEPH_SUBVOLUME_ID_NONE 0 +u64 i_subvolume_id;s32 i_dir_pin;
Alex Markuze
maintainerRe: [PATCH v3 4/4] ceph: adding CEPH_SUBVOLUME_ID_NONE
The latest ceph code supports subvolume metrics.
The test is simple:
1. Deploy a ceph cluster
2. Create and mount a subvolume
3. run some I/O
4. I used debugfs to see that subvolume metrics were collected on the client side and checked for subvolume metrics being reported on the mds.
Nothing more to it.
Quoted 152 lines · Viacheslav Dubeyko
Quoted 18 lines · Alex Markuze
1. Introduce
CEPH_SUBVOLUME_ID_NONEconstant (value 0) to make the unknown/unset state explicit and self-documenting.2. Add
WARN_ON_ONCEif attempting to change an already-setsubvolume_id. An inode's subvolume membership is immutable - once created in a subvolume, it stays there. Attempting to change it indicates a bug.--- fs/ceph/inode.c | 32 +++++++++++++++++++++++++------- fs/ceph/mds_client.c | 5 +---- fs/ceph/subvolume_metrics.c | 7 ++++--- fs/ceph/super.h | 10 +++++++++- 4 files changed, 39 insertions(+), 15 deletions(-)fs/ceph/inode.c +0
-0fs/ceph/inode.c struct inode *ceph_alloc_inode(struct super_block *sb) · line 641
Quoted 5 lines
fs/ceph/inode.c +1
-1@@ -638,7 +638,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb) ci->i_max_bytes =0 ; ci->i_max_files =0 ; - ci->i_subvolume_id =0 ; + ci->i_subvolume_id =CEPH_SUBVOLUME_ID_NONE ;I was expected to see the code of this patch in the second and third ones. And it looks really confusing. Why have you introduced another one patch?
So, how I can test this patchset? I assume that xfstests run will be not enough. Do we have special test environment or test-cases for this?
Thanks,
Slava.Quoted 117 lines
fs/ceph/inode.c +24
-6memset (&ci->i_dir_layout,0 ,sizeof (ci->i_dir_layout));memset (&ci->i_cached_layout,0 ,sizeof (ci->i_cached_layout));@@ -743,7 +743,7 @@ void ceph_evict_inode(struct inode *inode)percpu_counter_dec (&mdsc->metric.total_inodes); - ci->i_subvolume_id =0 ; + ci->i_subvolume_id =CEPH_SUBVOLUME_ID_NONE ;netfs_wait_for_outstanding_io (inode);truncate_inode_pages_final (&inode->i_data);@@ -877,19 +877,37 @@ int ceph_fill_file_size(struct inode *inode, int issued, }/* -* Set the subvolume ID for an inode. Following the FUSE client convention, -* 0 means unknown/unset (MDS only sends non-zero IDs for subvolume inodes). +* Set the subvolume ID for an inode. +* +* The subvolume_id identifies which CephFS subvolume this inode belongs to. +* CEPH_SUBVOLUME_ID_NONE (0) means unknown/unset - the MDS only sends +* non-zero IDs for inodes within subvolumes. +* +* An inode's subvolume membership is immutable - once an inode is created +* in a subvolume, it stays there. Therefore, if we already have a valid +* (non-zero) subvolume_id and receive a different one, that indicates a bug. */ void ceph_inode_set_subvolume (struct inode *inode,u64 subvolume_id) {struct ceph_inode_info *ci; +u64 old; -if (!inode || !subvolume_id) +if (!inode || subvolume_id ==CEPH_SUBVOLUME_ID_NONE )return ; ci =ceph_inode (inode); -if (READ_ONCE (ci->i_subvolume_id) != subvolume_id) -WRITE_ONCE (ci->i_subvolume_id, subvolume_id); + old =READ_ONCE (ci->i_subvolume_id); + +if (old == subvolume_id) +return ; + +if (old !=CEPH_SUBVOLUME_ID_NONE ) { +/* subvolume_id should not change once set */ +WARN_ON_ONCE (1 ); +return ; + } + +WRITE_ONCE (ci->i_subvolume_id, subvolume_id); } void ceph_fill_file_time(struct inode *inode, int issued,fs/ceph/mds_client.c +1
-4@@ -122,10 +122,7 @@ static int parse_reply_info_in(void **p, void *end,u32 struct_len =0 ;struct ceph_client *cl = mdsc ? mdsc->fsc->client :NULL ; - info->subvolume_id =0 ; -doutc (cl,"subv_metric parse start features=0x%llx\n" , features); - - info->subvolume_id =0 ; + info->subvolume_id =CEPH_SUBVOLUME_ID_NONE ;if (features == (u64)-1 ) {ceph_decode_8_safe (p, end, struct_v, bad);fs/ceph/subvolume_metrics.c +4
-3@@ -136,8 +136,9 @@ void ceph_subvolume_metrics_record(struct ceph_subvolume_metrics_tracker *trackestruct ceph_subvol_metric_rb_entry *entry, *new_entry =NULL ;bool retry = false; -/* 0 means unknown/unset subvolume (matches FUSE client convention) */ -if (!READ_ONCE (tracker->enabled) || !subvol_id || !size || !latency_us) +/* CEPH_SUBVOLUME_ID_NONE (0) means unknown/unset subvolume */ +if (!READ_ONCE (tracker->enabled) || + subvol_id ==CEPH_SUBVOLUME_ID_NONE || !size || !latency_us)return ; do {@@ -403,7 +404,7 @@ void ceph_subvolume_metrics_record_io(struct ceph_mds_client *mdsc, } subvol_id =READ_ONCE (ci->i_subvolume_id); -if (!subvol_id) { +if (subvol_id ==CEPH_SUBVOLUME_ID_NONE ) {atomic64_inc (&tracker->record_no_subvol);return ; }fs/ceph/super.h +9
-1@@ -386,7 +386,15 @@ struct ceph_inode_info {/* quotas */ u64 i_max_bytes, i_max_files; -u64 i_subvolume_id;/* 0 = unknown/unset, matches FUSE client */ + +/* +* Subvolume ID this inode belongs to. CEPH_SUBVOLUME_ID_NONE (0) +* means unknown/unset, matching the FUSE client convention. +* Once set to a valid (non-zero) value, it should not change +* during the inode's lifetime. +*/ +#define CEPH_SUBVOLUME_ID_NONE 0 +u64 i_subvolume_id;s32 i_dir_pin;
RE: [PATCH v3 4/4] ceph: adding CEPH_SUBVOLUME_ID_NONE
Quoted 11 lines · Alex Markuze
The latest ceph code supports subvolume metrics.
The test is simple:
1. Deploy a ceph cluster
2. Create and mount a subvolume
3. run some I/O
4. I used debugfs to see that subvolume metrics were collected on the client side and checked for subvolume metrics being reported on the mds.Nothing more to it.
So, if it is simple, then what's about of adding another Ceph's test into xfstests suite? Maybe, you can consider unit-test too. I've already introduced initial patch with Kunit-based unit-test. We should have some test-case that anyone can run and test this code.
Thanks,
Slava.
Alex Markuze
maintainerRe: [PATCH v3 4/4] ceph: adding CEPH_SUBVOLUME_ID_NONE
There is no separate test needed. The client only differs in that the mount path is for a subvolume.
Regardless its outside the scope of this patchset
Quoted 22 lines · Viacheslav Dubeyko
Quoted 11 lines · Alex Markuze
The latest ceph code supports subvolume metrics.
The test is simple:
1. Deploy a ceph cluster
2. Create and mount a subvolume
3. run some I/O
4. I used debugfs to see that subvolume metrics were collected on the client side and checked for subvolume metrics being reported on the mds.Nothing more to it.
So, if it is simple, then what's about of adding another Ceph's test into xfstests suite? Maybe, you can consider unit-test too. I've already introduced initial patch with Kunit-based unit-test. We should have some test-case that anyone can run and test this code.
Thanks,
Slava.
RE: [PATCH v3 4/4] ceph: adding CEPH_SUBVOLUME_ID_NONE
Quoted 4 lines · Alex Markuze
There is no separate test needed. The client only differs in that the mount path is for a subvolume.
Regardless its outside the scope of this patchset
If we implement any new functionality, then unit-test or special test in xfstests must be introduced for any new functionality. So, I think it's very relevant to the patchset.
Also, I believe that fourth patch should be merged into second and third ones. I don't see the point of introducing not completely correct code and then fix it by subsequent patch. It looks really wrong to me.
Thanks,
Slava.
Quoted 24 lines
Quoted 22 lines · Viacheslav Dubeyko
Quoted 11 lines · Alex Markuze
The latest ceph code supports subvolume metrics.
The test is simple:
1. Deploy a ceph cluster
2. Create and mount a subvolume
3. run some I/O
4. I used debugfs to see that subvolume metrics were collected on the client side and checked for subvolume metrics being reported on the mds.Nothing more to it.
So, if it is simple, then what's about of adding another Ceph's test into xfstests suite? Maybe, you can consider unit-test too. I've already introduced initial patch with Kunit-based unit-test. We should have some test-case that anyone can run and test this code.
Thanks,
Slava.
Alex Markuze
maintainerRe: [PATCH v3 4/4] ceph: adding CEPH_SUBVOLUME_ID_NONE
I'll squash the last patch into patch number 3.
I'm attaching instructions on how to create and mount a subvolume with ceph. Sending I/O using any of the existing tests will trigger subvolume metrics collecting and reporting.
Create a subvolume:
ceph fs subvolume create <fs name> <subvolume_name>
Here is an example how to mount a fuse client and get the subvolume
path: (FUSE client is the reference implementation)
/bin/ceph-fuse --id admin --client_fs <fs name> --conf $(pwd)/ceph.conf -r $(ceph fs subvolume getpath <fs name> <subvolume_name>) <mnt_point>
Mount Kclient:
1 │ IP=10.251.64.6 2 │ PORT=40258 3 │ CLIENT=kclient1 4 │ KEY="AQA4zyVpTXWPGRAA4c8aozVMYt+cri+3tAv6yA==" 5 │ CEPH_PATH="/volumes/_nogroup/ssubvol_a/f089e65e-2fc9-4474-b728-117de5ad25f6" 6 │ 7 │ sudo mount -t ceph -o
mon_addr=$IP:$PORT,secret=$KEY,name=$CLIENT,ms_mode=crc,nowsync,copyfrom,mds_namespace=a $IP:$PORT:$CEPH_PATH /mnt/subvol
Quoted 42 lines · Viacheslav Dubeyko
Quoted 4 lines · Alex Markuze
There is no separate test needed. The client only differs in that the mount path is for a subvolume.
Regardless its outside the scope of this patchsetIf we implement any new functionality, then unit-test or special test in xfstests must be introduced for any new functionality. So, I think it's very relevant to the patchset.
Also, I believe that fourth patch should be merged into second and third ones. I don't see the point of introducing not completely correct code and then fix it by subsequent patch. It looks really wrong to me.
Thanks,
Slava.Quoted 24 lines
Quoted 22 lines · Viacheslav Dubeyko
Quoted 11 lines · Alex Markuze
The latest ceph code supports subvolume metrics.
The test is simple:
1. Deploy a ceph cluster
2. Create and mount a subvolume
3. run some I/O
4. I used debugfs to see that subvolume metrics were collected on the client side and checked for subvolume metrics being reported on the mds.Nothing more to it.
So, if it is simple, then what's about of adding another Ceph's test into xfstests suite? Maybe, you can consider unit-test too. I've already introduced initial patch with Kunit-based unit-test. We should have some test-case that anyone can run and test this code.
Thanks,
Slava.
kernel test robot
build botRe: [PATCH v3 4/4] ceph: adding CEPH_SUBVOLUME_ID_NONE
In reply to Alex Markuzekernel test robot noticed the following build warnings:
Hi Alex,
kernel test robot noticed the following build warnings:
[auto build test WARNING on ceph-client/for-linus]
[also build test WARNING on linus/master v6.18 next-20251211] [cannot apply to ceph-client/testing]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Alex-Markuze/ceph-handle-InodeStat-v8-versioned-field-in-reply-parsing/20251204-035756 base: https://github.com/ceph/ceph-client.git for-linus patch link: https://lore.kernel.org/r/20251203154625.2779153-5-amarkuze%40redhat.com patch subject: [PATCH v3 4/4] ceph: adding CEPH_SUBVOLUME_ID_NONE config: x86_64-randconfig-101-20251210 (https://download.01.org/0day-ci/archive/20251212/[email protected]/config) compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251212/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> fs/ceph/mds_client.c:123:22: warning: unused variable 'cl' [-Wunused-variable]
123 | struct ceph_client *cl = mdsc ? mdsc->fsc->client : NULL;
| ^~1 warning generated.
vim +/cl +123 fs/ceph/mds_client.c
b37fe1f923fb4b Yan, Zheng 2019-01-09 113
2f2dc053404feb Sage Weil 2009-10-06 114 static int parse_reply_info_in(void **p, void *end,
14303d20f3ae3e Sage Weil 2010-12-14 115 struct ceph_mds_reply_info_in *info,
48a90cabed1e21 Alex Markuze 2025-12-03 116 u64 features,
48a90cabed1e21 Alex Markuze 2025-12-03 117 struct ceph_mds_client *mdsc)
2f2dc053404feb Sage Weil 2009-10-06 118 {
b37fe1f923fb4b Yan, Zheng 2019-01-09 119 int err = 0;
b37fe1f923fb4b Yan, Zheng 2019-01-09 120 u8 struct_v = 0;
48a90cabed1e21 Alex Markuze 2025-12-03 121 u8 struct_compat = 0;
48a90cabed1e21 Alex Markuze 2025-12-03 122 u32 struct_len = 0;
48a90cabed1e21 Alex Markuze 2025-12-03 @123 struct ceph_client *cl = mdsc ? mdsc->fsc->client : NULL;
48a90cabed1e21 Alex Markuze 2025-12-03 124
b5cda3b778d7c2 Alex Markuze 2025-12-03 125 info->subvolume_id = CEPH_SUBVOLUME_ID_NONE;
7361b2801d4572 Alex Markuze 2025-12-03 126
b37fe1f923fb4b Yan, Zheng 2019-01-09 127 if (features == (u64)-1) {
b37fe1f923fb4b Yan, Zheng 2019-01-09 128 ceph_decode_8_safe(p, end, struct_v, bad);
b37fe1f923fb4b Yan, Zheng 2019-01-09 129 ceph_decode_8_safe(p, end, struct_compat, bad);
b37fe1f923fb4b Yan, Zheng 2019-01-09 130 /* struct_v is expected to be >= 1. we only understand
b37fe1f923fb4b Yan, Zheng 2019-01-09 131 * encoding with struct_compat == 1. */
b37fe1f923fb4b Yan, Zheng 2019-01-09 132 if (!struct_v || struct_compat != 1)
b37fe1f923fb4b Yan, Zheng 2019-01-09 133 goto bad;
b37fe1f923fb4b Yan, Zheng 2019-01-09 134 ceph_decode_32_safe(p, end, struct_len, bad);
b37fe1f923fb4b Yan, Zheng 2019-01-09 135 ceph_decode_need(p, end, struct_len, bad);
b37fe1f923fb4b Yan, Zheng 2019-01-09 136 end = *p + struct_len;
b37fe1f923fb4b Yan, Zheng 2019-01-09 137 }
2f2dc053404feb Sage Weil 2009-10-06 138
b37fe1f923fb4b Yan, Zheng 2019-01-09 139 ceph_decode_need(p, end, sizeof(struct ceph_mds_reply_inode), bad);
2f2dc053404feb Sage Weil 2009-10-06 140 info->in = *p;
2f2dc053404feb Sage Weil 2009-10-06 141 *p += sizeof(struct ceph_mds_reply_inode) +
2f2dc053404feb Sage Weil 2009-10-06 142 sizeof(*info->in->fragtree.splits) *
2f2dc053404feb Sage Weil 2009-10-06 143 le32_to_cpu(info->in->fragtree.nsplits);
2f2dc053404feb Sage Weil 2009-10-06 144
2f2dc053404feb Sage Weil 2009-10-06 145 ceph_decode_32_safe(p, end, info->symlink_len, bad);
2f2dc053404feb Sage Weil 2009-10-06 146 ceph_decode_need(p, end, info->symlink_len, bad);
2f2dc053404feb Sage Weil 2009-10-06 147 info->symlink = *p;
2f2dc053404feb Sage Weil 2009-10-06 148 *p += info->symlink_len;
2f2dc053404feb Sage Weil 2009-10-06 149
14303d20f3ae3e Sage Weil 2010-12-14 150 ceph_decode_copy_safe(p, end, &info->dir_layout,
14303d20f3ae3e Sage Weil 2010-12-14 151 sizeof(info->dir_layout), bad);
2f2dc053404feb Sage Weil 2009-10-06 152 ceph_decode_32_safe(p, end, info->xattr_len, bad);
2f2dc053404feb Sage Weil 2009-10-06 153 ceph_decode_need(p, end, info->xattr_len, bad);
2f2dc053404feb Sage Weil 2009-10-06 154 info->xattr_data = *p;
2f2dc053404feb Sage Weil 2009-10-06 155 *p += info->xattr_len;
fb01d1f8b0343f Yan, Zheng 2014-11-14 156
b37fe1f923fb4b Yan, Zheng 2019-01-09 157 if (features == (u64)-1) {
b37fe1f923fb4b Yan, Zheng 2019-01-09 158 /* inline data */
b37fe1f923fb4b Yan, Zheng 2019-01-09 159 ceph_decode_64_safe(p, end, info->inline_version, bad);
b37fe1f923fb4b Yan, Zheng 2019-01-09 160 ceph_decode_32_safe(p, end, info->inline_len, bad);
b37fe1f923fb4b Yan, Zheng 2019-01-09 161 ceph_decode_need(p, end, info->inline_len, bad);
b37fe1f923fb4b Yan, Zheng 2019-01-09 162 info->inline_data = *p;
b37fe1f923fb4b Yan, Zheng 2019-01-09 163 *p += info->inline_len;
b37fe1f923fb4b Yan, Zheng 2019-01-09 164 /* quota */
b37fe1f923fb4b Yan, Zheng 2019-01-09 165 err = parse_reply_info_quota(p, end, info);
b37fe1f923fb4b Yan, Zheng 2019-01-09 166 if (err < 0)
b37fe1f923fb4b Yan, Zheng 2019-01-09 167 goto out_bad;
b37fe1f923fb4b Yan, Zheng 2019-01-09 168 /* pool namespace */
b37fe1f923fb4b Yan, Zheng 2019-01-09 169 ceph_decode_32_safe(p, end, info->pool_ns_len, bad);
b37fe1f923fb4b Yan, Zheng 2019-01-09 170 if (info->pool_ns_len > 0) {
b37fe1f923fb4b Yan, Zheng 2019-01-09 171 ceph_decode_need(p, end, info->pool_ns_len, bad);
b37fe1f923fb4b Yan, Zheng 2019-01-09 172 info->pool_ns_data = *p;
b37fe1f923fb4b Yan, Zheng 2019-01-09 173 *p += info->pool_ns_len;
b37fe1f923fb4b Yan, Zheng 2019-01-09 174 }
245ce991cca55e Jeff Layton 2019-05-29 175
245ce991cca55e Jeff Layton 2019-05-29 176 /* btime */
245ce991cca55e Jeff Layton 2019-05-29 177 ceph_decode_need(p, end, sizeof(info->btime), bad);
245ce991cca55e Jeff Layton 2019-05-29 178 ceph_decode_copy(p, &info->btime, sizeof(info->btime));
245ce991cca55e Jeff Layton 2019-05-29 179
245ce991cca55e Jeff Layton 2019-05-29 180 /* change attribute */
a35ead314e0b92 Jeff Layton 2019-06-06 181 ceph_decode_64_safe(p, end, info->change_attr, bad);
b37fe1f923fb4b Yan, Zheng 2019-01-09 182
08796873a5183b Yan, Zheng 2019-01-09 183 /* dir pin */
08796873a5183b Yan, Zheng 2019-01-09 184 if (struct_v >= 2) {
08796873a5183b Yan, Zheng 2019-01-09 185 ceph_decode_32_safe(p, end, info->dir_pin, bad);
08796873a5183b Yan, Zheng 2019-01-09 186 } else {
08796873a5183b Yan, Zheng 2019-01-09 187 info->dir_pin = -ENODATA;
08796873a5183b Yan, Zheng 2019-01-09 188 }
08796873a5183b Yan, Zheng 2019-01-09 189
193e7b37628e97 David Disseldorp 2019-04-18 190 /* snapshot birth time, remains zero for v<=2 */
193e7b37628e97 David Disseldorp 2019-04-18 191 if (struct_v >= 3) {
193e7b37628e97 David Disseldorp 2019-04-18 192 ceph_decode_need(p, end, sizeof(info->snap_btime), bad);
193e7b37628e97 David Disseldorp 2019-04-18 193 ceph_decode_copy(p, &info->snap_btime,
193e7b37628e97 David Disseldorp 2019-04-18 194 sizeof(info->snap_btime));
193e7b37628e97 David Disseldorp 2019-04-18 195 } else {
193e7b37628e97 David Disseldorp 2019-04-18 196 memset(&info->snap_btime, 0, sizeof(info->snap_btime));
193e7b37628e97 David Disseldorp 2019-04-18 197 }
193e7b37628e97 David Disseldorp 2019-04-18 198
e7f72952508ac4 Yanhu Cao 2020-08-28 199 /* snapshot count, remains zero for v<=3 */
e7f72952508ac4 Yanhu Cao 2020-08-28 200 if (struct_v >= 4) {
e7f72952508ac4 Yanhu Cao 2020-08-28 201 ceph_decode_64_safe(p, end, info->rsnaps, bad);
e7f72952508ac4 Yanhu Cao 2020-08-28 202 } else {
e7f72952508ac4 Yanhu Cao 2020-08-28 203 info->rsnaps = 0;
e7f72952508ac4 Yanhu Cao 2020-08-28 204 }
e7f72952508ac4 Yanhu Cao 2020-08-28 205
2d332d5bc42440 Jeff Layton 2020-07-27 206 if (struct_v >= 5) {
2d332d5bc42440 Jeff Layton 2020-07-27 207 u32 alen;
2d332d5bc42440 Jeff Layton 2020-07-27 208
2d332d5bc42440 Jeff Layton 2020-07-27 209 ceph_decode_32_safe(p, end, alen, bad);
2d332d5bc42440 Jeff Layton 2020-07-27 210
2d332d5bc42440 Jeff Layton 2020-07-27 211 while (alen--) {
2d332d5bc42440 Jeff Layton 2020-07-27 212 u32 len;
2d332d5bc42440 Jeff Layton 2020-07-27 213
2d332d5bc42440 Jeff Layton 2020-07-27 214 /* key */
2d332d5bc42440 Jeff Layton 2020-07-27 215 ceph_decode_32_safe(p, end, len, bad);
2d332d5bc42440 Jeff Layton 2020-07-27 216 ceph_decode_skip_n(p, end, len, bad);
2d332d5bc42440 Jeff Layton 2020-07-27 217 /* value */
2d332d5bc42440 Jeff Layton 2020-07-27 218 ceph_decode_32_safe(p, end, len, bad);
2d332d5bc42440 Jeff Layton 2020-07-27 219 ceph_decode_skip_n(p, end, len, bad);
2d332d5bc42440 Jeff Layton 2020-07-27 220 }
2d332d5bc42440 Jeff Layton 2020-07-27 221 }
2d332d5bc42440 Jeff Layton 2020-07-27 222
2d332d5bc42440 Jeff Layton 2020-07-27 223 /* fscrypt flag -- ignore */
2d332d5bc42440 Jeff Layton 2020-07-27 224 if (struct_v >= 6)
2d332d5bc42440 Jeff Layton 2020-07-27 225 ceph_decode_skip_8(p, end, bad);
2d332d5bc42440 Jeff Layton 2020-07-27 226
2d332d5bc42440 Jeff Layton 2020-07-27 227 info->fscrypt_auth = NULL;
2d332d5bc42440 Jeff Layton 2020-07-27 228 info->fscrypt_auth_len = 0;
2d332d5bc42440 Jeff Layton 2020-07-27 229 info->fscrypt_file = NULL;
2d332d5bc42440 Jeff Layton 2020-07-27 230 info->fscrypt_file_len = 0;
2d332d5bc42440 Jeff Layton 2020-07-27 231 if (struct_v >= 7) {
2d332d5bc42440 Jeff Layton 2020-07-27 232 ceph_decode_32_safe(p, end, info->fscrypt_auth_len, bad);
2d332d5bc42440 Jeff Layton 2020-07-27 233 if (info->fscrypt_auth_len) {
2d332d5bc42440 Jeff Layton 2020-07-27 234 info->fscrypt_auth = kmalloc(info->fscrypt_auth_len,
2d332d5bc42440 Jeff Layton 2020-07-27 235 GFP_KERNEL);
2d332d5bc42440 Jeff Layton 2020-07-27 236 if (!info->fscrypt_auth)
2d332d5bc42440 Jeff Layton 2020-07-27 237 return -ENOMEM;
2d332d5bc42440 Jeff Layton 2020-07-27 238 ceph_decode_copy_safe(p, end, info->fscrypt_auth,
2d332d5bc42440 Jeff Layton 2020-07-27 239 info->fscrypt_auth_len, bad);
2d332d5bc42440 Jeff Layton 2020-07-27 240 }
2d332d5bc42440 Jeff Layton 2020-07-27 241 ceph_decode_32_safe(p, end, info->fscrypt_file_len, bad);
2d332d5bc42440 Jeff Layton 2020-07-27 242 if (info->fscrypt_file_len) {
2d332d5bc42440 Jeff Layton 2020-07-27 243 info->fscrypt_file = kmalloc(info->fscrypt_file_len,
2d332d5bc42440 Jeff Layton 2020-07-27 244 GFP_KERNEL);
2d332d5bc42440 Jeff Layton 2020-07-27 245 if (!info->fscrypt_file)
2d332d5bc42440 Jeff Layton 2020-07-27 246 return -ENOMEM;
2d332d5bc42440 Jeff Layton 2020-07-27 247 ceph_decode_copy_safe(p, end, info->fscrypt_file,
2d332d5bc42440 Jeff Layton 2020-07-27 248 info->fscrypt_file_len, bad);
2d332d5bc42440 Jeff Layton 2020-07-27 249 }
2d332d5bc42440 Jeff Layton 2020-07-27 250 }
e3d0dedf78abdf Alex Markuze 2025-12-03 251
e3d0dedf78abdf Alex Markuze 2025-12-03 252 /*
e3d0dedf78abdf Alex Markuze 2025-12-03 253 * InodeStat encoding versions:
e3d0dedf78abdf Alex Markuze 2025-12-03 254 * v1-v7: various fields added over time
e3d0dedf78abdf Alex Markuze 2025-12-03 255 * v8: added optmetadata (versioned sub-structure containing
e3d0dedf78abdf Alex Markuze 2025-12-03 256 * optional inode metadata like charmap for case-insensitive
e3d0dedf78abdf Alex Markuze 2025-12-03 257 * filesystems). The kernel client doesn't support
e3d0dedf78abdf Alex Markuze 2025-12-03 258 * case-insensitive lookups, so we skip this field.
e3d0dedf78abdf Alex Markuze 2025-12-03 259 * v9: added subvolume_id (parsed below)
e3d0dedf78abdf Alex Markuze 2025-12-03 260 */
e3d0dedf78abdf Alex Markuze 2025-12-03 261 if (struct_v >= 8) {
e3d0dedf78abdf Alex Markuze 2025-12-03 262 u32 v8_struct_len;
e3d0dedf78abdf Alex Markuze 2025-12-03 263
e3d0dedf78abdf Alex Markuze 2025-12-03 264 /* skip optmetadata versioned sub-structure */
e3d0dedf78abdf Alex Markuze 2025-12-03 265 ceph_decode_skip_8(p, end, bad); /* struct_v */
e3d0dedf78abdf Alex Markuze 2025-12-03 266 ceph_decode_skip_8(p, end, bad); /* struct_compat */
e3d0dedf78abdf Alex Markuze 2025-12-03 267 ceph_decode_32_safe(p, end, v8_struct_len, bad);
e3d0dedf78abdf Alex Markuze 2025-12-03 268 ceph_decode_skip_n(p, end, v8_struct_len, bad);
e3d0dedf78abdf Alex Markuze 2025-12-03 269 }
e3d0dedf78abdf Alex Markuze 2025-12-03 270
7361b2801d4572 Alex Markuze 2025-12-03 271 /* struct_v 9 added subvolume_id */
7361b2801d4572 Alex Markuze 2025-12-03 272 if (struct_v >= 9)
7361b2801d4572 Alex Markuze 2025-12-03 273 ceph_decode_64_safe(p, end, info->subvolume_id, bad);
7361b2801d4572 Alex Markuze 2025-12-03 274
b37fe1f923fb4b Yan, Zheng 2019-01-09 275 *p = end;
b37fe1f923fb4b Yan, Zheng 2019-01-09 276 } else {
2d332d5bc42440 Jeff Layton 2020-07-27 277 /* legacy (unversioned) struct */
fb01d1f8b0343f Yan, Zheng 2014-11-14 278 if (features & CEPH_FEATURE_MDS_INLINE_DATA) {
fb01d1f8b0343f Yan, Zheng 2014-11-14 279 ceph_decode_64_safe(p, end, info->inline_version, bad);
fb01d1f8b0343f Yan, Zheng 2014-11-14 280 ceph_decode_32_safe(p, end, info->inline_len, bad);
fb01d1f8b0343f Yan, Zheng 2014-11-14 281 ceph_decode_need(p, end, info->inline_len, bad);
fb01d1f8b0343f Yan, Zheng 2014-11-14 282 info->inline_data = *p;
fb01d1f8b0343f Yan, Zheng 2014-11-14 283 *p += info->inline_len;
fb01d1f8b0343f Yan, Zheng 2014-11-14 284 } else
fb01d1f8b0343f Yan, Zheng 2014-11-14 285 info->inline_version = CEPH_INLINE_NONE;
fb01d1f8b0343f Yan, Zheng 2014-11-14 286
fb18a57568c2b8 Luis Henriques 2018-01-05 287 if (features & CEPH_FEATURE_MDS_QUOTA) {
b37fe1f923fb4b Yan, Zheng 2019-01-09 288 err = parse_reply_info_quota(p, end, info);
b37fe1f923fb4b Yan, Zheng 2019-01-09 289 if (err < 0)
b37fe1f923fb4b Yan, Zheng 2019-01-09 290 goto out_bad;
fb18a57568c2b8 Luis Henriques 2018-01-05 291 } else {
fb18a57568c2b8 Luis Henriques 2018-01-05 292 info->max_bytes = 0;
fb18a57568c2b8 Luis Henriques 2018-01-05 293 info->max_files = 0;
fb18a57568c2b8 Luis Henriques 2018-01-05 294 }
fb18a57568c2b8 Luis Henriques 2018-01-05 295
779fe0fb8e1883 Yan, Zheng 2016-03-07 296 info->pool_ns_len = 0;
779fe0fb8e1883 Yan, Zheng 2016-03-07 297 info->pool_ns_data = NULL;
5ea5c5e0a7f70b Yan, Zheng 2016-02-14 298 if (features & CEPH_FEATURE_FS_FILE_LAYOUT_V2) {
5ea5c5e0a7f70b Yan, Zheng 2016-02-14 299 ceph_decode_32_safe(p, end, info->pool_ns_len, bad);
779fe0fb8e1883 Yan, Zheng 2016-03-07 300 if (info->pool_ns_len > 0) {
5ea5c5e0a7f70b Yan, Zheng 2016-02-14 301 ceph_decode_need(p, end, info->pool_ns_len, bad);
779fe0fb8e1883 Yan, Zheng 2016-03-07 302 info->pool_ns_data = *p;
5ea5c5e0a7f70b Yan, Zheng 2016-02-14 303 *p += info->pool_ns_len;
779fe0fb8e1883 Yan, Zheng 2016-03-07 304 }
5ea5c5e0a7f70b Yan, Zheng 2016-02-14 305 }
08796873a5183b Yan, Zheng 2019-01-09 306
245ce991cca55e Jeff Layton 2019-05-29 307 if (features & CEPH_FEATURE_FS_BTIME) {
245ce991cca55e Jeff Layton 2019-05-29 308 ceph_decode_need(p, end, sizeof(info->btime), bad);
245ce991cca55e Jeff Layton 2019-05-29 309 ceph_decode_copy(p, &info->btime, sizeof(info->btime));
a35ead314e0b92 Jeff Layton 2019-06-06 310 ceph_decode_64_safe(p, end, info->change_attr, bad);
245ce991cca55e Jeff Layton 2019-05-29 311 }
245ce991cca55e Jeff Layton 2019-05-29 312
08796873a5183b Yan, Zheng 2019-01-09 313 info->dir_pin = -ENODATA;
e7f72952508ac4 Yanhu Cao 2020-08-28 314 /* info->snap_btime and info->rsnaps remain zero */
b37fe1f923fb4b Yan, Zheng 2019-01-09 315 }
2f2dc053404feb Sage Weil 2009-10-06 316 return 0;
2f2dc053404feb Sage Weil 2009-10-06 317 bad:
b37fe1f923fb4b Yan, Zheng 2019-01-09 318 err = -EIO;
b37fe1f923fb4b Yan, Zheng 2019-01-09 319 out_bad:
2f2dc053404feb Sage Weil 2009-10-06 320 return err;
2f2dc053404feb Sage Weil 2009-10-06 321 }
2f2dc053404feb Sage Weil 2009-10-06 322 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki