From: Alex Markuze Date: Mon, 17 Mar 2025 15:09:13 +0000 (+0000) Subject: cephsan pf iterator X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d76a3e9101711b717452d18c30605b409889542b;p=ceph-client.git cephsan pf iterator --- diff --git a/include/linux/ceph/ceph_san_logger.h b/include/linux/ceph/ceph_san_logger.h index 46a7f1c4071d..4ce1ed182bf3 100644 --- a/include/linux/ceph/ceph_san_logger.h +++ b/include/linux/ceph/ceph_san_logger.h @@ -38,6 +38,19 @@ struct ceph_san_logger { struct ceph_san_batch log_batch; /* Batch for storing log entries */ }; +/* Iterator for log entries in a single pagefrag */ +struct ceph_san_log_iter { + struct cephsan_pagefrag *pf; /* Pagefrag being iterated */ + u64 current_offset; /* Current offset in pagefrag */ + u64 end_offset; /* End offset in pagefrag */ +}; + +/* Initialize the iterator for a specific pagefrag */ +void ceph_san_log_iter_init(struct ceph_san_log_iter *iter, struct cephsan_pagefrag *pf); + +/* Get next log entry, returns NULL when no more entries */ +struct ceph_san_log_entry *ceph_san_log_iter_next(struct ceph_san_log_iter *iter); + /* Initialize the logging system */ int ceph_san_logger_init(void); diff --git a/include/linux/ceph/ceph_san_pagefrag.h b/include/linux/ceph/ceph_san_pagefrag.h index 5b74172ce1a9..faeba5dcce0c 100644 --- a/include/linux/ceph/ceph_san_pagefrag.h +++ b/include/linux/ceph/ceph_san_pagefrag.h @@ -4,7 +4,8 @@ #include #include -#define CEPHSAN_PAGEFRAG_SIZE (1<<22) /* 4MB */ +#define CEPHSAN_PAGEFRAG_SIZE (1<<21) /* 2MB */ +#define CEPHSAN_PAGEFRAG_MASK (CEPHSAN_PAGEFRAG_SIZE - 1) /* Pagefrag allocator structure */ struct cephsan_pagefrag { diff --git a/net/ceph/ceph_san_logger.c b/net/ceph/ceph_san_logger.c index d60af8cf82b9..16fee904102a 100644 --- a/net/ceph/ceph_san_logger.c +++ b/net/ceph/ceph_san_logger.c @@ -212,4 +212,47 @@ void ceph_san_logger_cleanup(void) ceph_san_batch_cleanup(&g_logger.alloc_batch); ceph_san_batch_cleanup(&g_logger.log_batch); } -EXPORT_SYMBOL(ceph_san_logger_cleanup); \ No newline at end of file +EXPORT_SYMBOL(ceph_san_logger_cleanup); + +/** + * ceph_san_log_iter_init - Initialize the log entry iterator for a specific pagefrag + * @iter: Iterator structure to initialize + * @pf: Pagefrag to iterate over + */ +void ceph_san_log_iter_init(struct ceph_san_log_iter *iter, struct cephsan_pagefrag *pf) +{ + /* Initialize iterator state */ + iter->pf = pf; + iter->current_offset = pf->tail; + iter->end_offset = pf->head; +} +EXPORT_SYMBOL(ceph_san_log_iter_init); + +/** + * ceph_san_log_iter_next - Get the next log entry from the iterator + * @iter: Iterator structure + * + * Returns the next log entry or NULL if no more entries are available. + */ +struct ceph_san_log_entry *ceph_san_log_iter_next(struct ceph_san_log_iter *iter) +{ + struct ceph_san_log_entry *entry; + + if (!iter->pf || iter->current_offset== iter->end_offset) + return NULL; + + /* Get current entry */ + entry = cephsan_pagefrag_get_ptr(iter->pf, iter->current_offset); + /* Verify entry is valid */ + if (!entry || entry->debug_poison != CEPH_SAN_LOG_ENTRY_POISON || entry->len == 0) { + iter->current_offset = iter->end_offset; + BUG_ON(entry->debug_poison != CEPH_SAN_LOG_ENTRY_POISON); + return NULL; + } + + /* Move to next entry */ + iter->current_offset += entry->len & CEPHSAN_PAGEFRAG_MASK; + + return entry; +} +EXPORT_SYMBOL(ceph_san_log_iter_next); \ No newline at end of file