mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-20 03:22:18 +00:00
chore(rustfs): adjudicate 37 bare dead_code allows in the four densest files (#6254)
This commit is contained in:
+12
-17
@@ -119,6 +119,10 @@ async fn static_handler(uri: Uri) -> impl IntoResponse {
|
|||||||
#[derive(Debug, Serialize, Clone)]
|
#[derive(Debug, Serialize, Clone)]
|
||||||
pub(crate) struct Config {
|
pub(crate) struct Config {
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
|
#[allow(
|
||||||
|
dead_code,
|
||||||
|
reason = "reachable only from this file's tests: no route registers config_handler (backlog#1823)"
|
||||||
|
)]
|
||||||
port: u16,
|
port: u16,
|
||||||
api: Api,
|
api: Api,
|
||||||
s3: S3,
|
s3: S3,
|
||||||
@@ -176,11 +180,14 @@ impl Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(
|
||||||
|
dead_code,
|
||||||
|
reason = "reachable only from this file's tests: no route registers config_handler (backlog#1823)"
|
||||||
|
)]
|
||||||
fn to_json(&self) -> String {
|
fn to_json(&self) -> String {
|
||||||
serde_json::to_string(self).unwrap_or_default()
|
serde_json::to_string(self).unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) fn version_info(&self) -> String {
|
pub(crate) fn version_info(&self) -> String {
|
||||||
format!(
|
format!(
|
||||||
"RELEASE.{}@{} (rust {} {})",
|
"RELEASE.{}@{} (rust {} {})",
|
||||||
@@ -190,21 +197,6 @@ impl Config {
|
|||||||
build::BUILD_TARGET
|
build::BUILD_TARGET
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) fn version(&self) -> String {
|
|
||||||
self.release.version.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) fn license(&self) -> String {
|
|
||||||
format!("{} {}", self.license.name.clone(), self.license.url.clone())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) fn doc(&self) -> String {
|
|
||||||
self.doc.clone()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_console_api_base_url(base_url: &str) -> String {
|
fn build_console_api_base_url(base_url: &str) -> String {
|
||||||
@@ -353,7 +345,10 @@ async fn version_handler() -> impl IntoResponse {
|
|||||||
/// - 200 OK with JSON body containing the console configuration if initialized.
|
/// - 200 OK with JSON body containing the console configuration if initialized.
|
||||||
/// - 500 Internal Server Error if configuration is not initialized.
|
/// - 500 Internal Server Error if configuration is not initialized.
|
||||||
#[instrument(fields(uri))]
|
#[instrument(fields(uri))]
|
||||||
#[allow(dead_code)]
|
#[allow(
|
||||||
|
dead_code,
|
||||||
|
reason = "reachable only from this file's tests: no route registers it (backlog#1823)"
|
||||||
|
)]
|
||||||
async fn config_handler(uri: Uri, headers: HeaderMap) -> impl IntoResponse {
|
async fn config_handler(uri: Uri, headers: HeaderMap) -> impl IntoResponse {
|
||||||
// Get the scheme from the headers or use the URI scheme
|
// Get the scheme from the headers or use the URI scheme
|
||||||
let scheme = headers
|
let scheme = headers
|
||||||
|
|||||||
@@ -53,25 +53,18 @@ const EVENT_ADMIN_TIER_STATE: &str = "admin_tier_state";
|
|||||||
#[derive(Debug, Clone, serde::Deserialize, Default)]
|
#[derive(Debug, Clone, serde::Deserialize, Default)]
|
||||||
pub struct AddTierQuery {
|
pub struct AddTierQuery {
|
||||||
#[serde(rename = "accessKey")]
|
#[serde(rename = "accessKey")]
|
||||||
#[allow(dead_code)]
|
|
||||||
pub access_key: Option<String>,
|
pub access_key: Option<String>,
|
||||||
#[allow(dead_code)]
|
|
||||||
pub status: Option<String>,
|
pub status: Option<String>,
|
||||||
#[serde(rename = "secretKey")]
|
#[serde(rename = "secretKey")]
|
||||||
#[allow(dead_code)]
|
|
||||||
pub secret_key: Option<String>,
|
pub secret_key: Option<String>,
|
||||||
#[serde(rename = "serviceName")]
|
#[serde(rename = "serviceName")]
|
||||||
#[allow(dead_code)]
|
|
||||||
pub service_name: Option<String>,
|
pub service_name: Option<String>,
|
||||||
#[serde(rename = "sessionToken")]
|
#[serde(rename = "sessionToken")]
|
||||||
#[allow(dead_code)]
|
|
||||||
pub session_token: Option<String>,
|
pub session_token: Option<String>,
|
||||||
pub tier: Option<String>,
|
pub tier: Option<String>,
|
||||||
#[serde(rename = "tierName")]
|
#[serde(rename = "tierName")]
|
||||||
#[allow(dead_code)]
|
|
||||||
pub tier_name: Option<String>,
|
pub tier_name: Option<String>,
|
||||||
#[serde(rename = "tierType")]
|
#[serde(rename = "tierType")]
|
||||||
#[allow(dead_code)]
|
|
||||||
pub tier_type: Option<String>,
|
pub tier_type: Option<String>,
|
||||||
pub force: Option<String>,
|
pub force: Option<String>,
|
||||||
}
|
}
|
||||||
@@ -532,7 +525,6 @@ impl Operation for EditTier {
|
|||||||
#[derive(Debug, Clone, serde::Deserialize, Default)]
|
#[derive(Debug, Clone, serde::Deserialize, Default)]
|
||||||
pub struct BucketQuery {
|
pub struct BucketQuery {
|
||||||
#[serde(rename = "bucket")]
|
#[serde(rename = "bucket")]
|
||||||
#[allow(dead_code)]
|
|
||||||
pub bucket: String,
|
pub bucket: String,
|
||||||
}
|
}
|
||||||
pub struct ListTiers {}
|
pub struct ListTiers {}
|
||||||
|
|||||||
@@ -812,12 +812,10 @@ fn is_reserved_condition_key(key: &str, server_derived: &HashMap<String, Vec<Str
|
|||||||
/// # Returns
|
/// # Returns
|
||||||
/// * `AuthType` - The determined authentication type
|
/// * `AuthType` - The determined authentication type
|
||||||
///
|
///
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn get_request_auth_type(header: &HeaderMap) -> AuthType {
|
pub fn get_request_auth_type(header: &HeaderMap) -> AuthType {
|
||||||
get_request_auth_type_with_query(header, None)
|
get_request_auth_type_with_query(header, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) fn get_request_auth_type_with_query(header: &HeaderMap, query: Option<&str>) -> AuthType {
|
pub(crate) fn get_request_auth_type_with_query(header: &HeaderMap, query: Option<&str>) -> AuthType {
|
||||||
if is_request_signature_v2(header) {
|
if is_request_signature_v2(header) {
|
||||||
AuthType::SignedV2
|
AuthType::SignedV2
|
||||||
@@ -846,20 +844,6 @@ pub(crate) fn get_request_auth_type_with_query(header: &HeaderMap, query: Option
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper function to determine auth type and signature version
|
|
||||||
///
|
|
||||||
/// # Arguments
|
|
||||||
/// * `header` - HTTP headers of the request
|
|
||||||
///
|
|
||||||
/// # Returns
|
|
||||||
/// * `(String, String)` - Tuple of auth type and signature version
|
|
||||||
///
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn determine_auth_type_and_version(header: &HeaderMap) -> (String, String) {
|
|
||||||
determine_auth_type_and_version_with_query(header, None)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn determine_auth_type_and_version_with_query(header: &HeaderMap, query: Option<&str>) -> (String, String) {
|
fn determine_auth_type_and_version_with_query(header: &HeaderMap, query: Option<&str>) -> (String, String) {
|
||||||
match get_request_auth_type_with_query(header, query) {
|
match get_request_auth_type_with_query(header, query) {
|
||||||
AuthType::JWT => ("JWT".to_string(), String::new()),
|
AuthType::JWT => ("JWT".to_string(), String::new()),
|
||||||
@@ -925,18 +909,6 @@ fn is_request_signature_v2(header: &HeaderMap) -> bool {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Verify if request has AWS PreSign Version '4'
|
|
||||||
///
|
|
||||||
/// # Arguments
|
|
||||||
/// * `header` - HTTP headers of the request
|
|
||||||
///
|
|
||||||
/// # Returns
|
|
||||||
/// * `bool` - True if request has AWS PreSign Version '4', false otherwise
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) fn is_request_presigned_signature_v4(header: &HeaderMap) -> bool {
|
|
||||||
is_request_presigned_signature_v4_with_query(header, None)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn is_request_presigned_signature_v4_with_query(header: &HeaderMap, query: Option<&str>) -> bool {
|
pub(crate) fn is_request_presigned_signature_v4_with_query(header: &HeaderMap, query: Option<&str>) -> bool {
|
||||||
if let Some(credential) = header.get(AMZ_CREDENTIAL) {
|
if let Some(credential) = header.get(AMZ_CREDENTIAL) {
|
||||||
return !credential.to_str().unwrap_or("").is_empty();
|
return !credential.to_str().unwrap_or("").is_empty();
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ impl IoLoadLevel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the load level as a string for metrics labels.
|
/// Get the load level as a string for metrics labels.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn as_str(&self) -> &'static str {
|
pub fn as_str(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
IoLoadLevel::Low => "low",
|
IoLoadLevel::Low => "low",
|
||||||
@@ -83,7 +82,6 @@ impl IoLoadLevel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the load level as a numeric index (0=Low, 1=Medium, 2=High, 3=Critical).
|
/// Get the load level as a numeric index (0=Low, 1=Medium, 2=High, 3=Critical).
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn level_index(&self) -> u8 {
|
pub fn level_index(&self) -> u8 {
|
||||||
match self {
|
match self {
|
||||||
IoLoadLevel::Low => 0,
|
IoLoadLevel::Low => 0,
|
||||||
@@ -118,7 +116,6 @@ pub enum IoPriority {
|
|||||||
|
|
||||||
impl IoPriority {
|
impl IoPriority {
|
||||||
/// Determine priority from request size using scheduler config thresholds.
|
/// Determine priority from request size using scheduler config thresholds.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn from_size(size: i64) -> Self {
|
pub fn from_size(size: i64) -> Self {
|
||||||
Self::from_size_with_thresholds(
|
Self::from_size_with_thresholds(
|
||||||
size,
|
size,
|
||||||
@@ -152,19 +149,16 @@ impl IoPriority {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check if this is high priority.
|
/// Check if this is high priority.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn is_high(&self) -> bool {
|
pub fn is_high(&self) -> bool {
|
||||||
matches!(self, IoPriority::High)
|
matches!(self, IoPriority::High)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if this is normal priority.
|
/// Check if this is normal priority.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn is_normal(&self) -> bool {
|
pub fn is_normal(&self) -> bool {
|
||||||
matches!(self, IoPriority::Normal)
|
matches!(self, IoPriority::Normal)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if this is low priority.
|
/// Check if this is low priority.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn is_low(&self) -> bool {
|
pub fn is_low(&self) -> bool {
|
||||||
matches!(self, IoPriority::Low)
|
matches!(self, IoPriority::Low)
|
||||||
}
|
}
|
||||||
@@ -403,7 +397,6 @@ impl IoSchedulerConfig {
|
|||||||
|
|
||||||
/// I/O queue status for monitoring.
|
/// I/O queue status for monitoring.
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
#[allow(dead_code)]
|
|
||||||
pub struct IoQueueStatus {
|
pub struct IoQueueStatus {
|
||||||
/// Total permits available.
|
/// Total permits available.
|
||||||
pub total_permits: usize,
|
pub total_permits: usize,
|
||||||
@@ -520,7 +513,6 @@ pub struct IoStrategyCore {
|
|||||||
|
|
||||||
impl IoStrategyCore {
|
impl IoStrategyCore {
|
||||||
/// Create a minimal IoStrategyCore with essential fields only.
|
/// Create a minimal IoStrategyCore with essential fields only.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn new(storage_media: StorageMedia, access_pattern: AccessPattern, buffer_size: usize) -> Self {
|
pub fn new(storage_media: StorageMedia, access_pattern: AccessPattern, buffer_size: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
storage_media,
|
storage_media,
|
||||||
@@ -1194,7 +1186,6 @@ impl IoStrategy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get a human-readable description of the current I/O strategy.
|
/// Get a human-readable description of the current I/O strategy.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn description(&self) -> String {
|
pub fn description(&self) -> String {
|
||||||
format!(
|
format!(
|
||||||
"IoStrategy[{:?}]: buffer={}KB, multiplier={:.2}, readahead={}, wait={:?}",
|
"IoStrategy[{:?}]: buffer={}KB, multiplier={:.2}, readahead={}, wait={:?}",
|
||||||
@@ -1282,14 +1273,6 @@ impl IoLoadMetrics {
|
|||||||
IoLoadLevel::from_wait_duration(self.average_wait())
|
IoLoadLevel::from_wait_duration(self.average_wait())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the overall average wait since startup
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) fn lifetime_average_wait(&self) -> Duration {
|
|
||||||
let total = self.total_wait_ns.load(Ordering::Relaxed);
|
|
||||||
let count = self.observation_count.load(Ordering::Relaxed);
|
|
||||||
total.checked_div(count).map(Duration::from_nanos).unwrap_or(Duration::ZERO)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the total observation count
|
/// Get the total observation count
|
||||||
pub(crate) fn observation_count(&self) -> u64 {
|
pub(crate) fn observation_count(&self) -> u64 {
|
||||||
self.observation_count.load(Ordering::Relaxed)
|
self.observation_count.load(Ordering::Relaxed)
|
||||||
@@ -1450,13 +1433,13 @@ use tracing::warn;
|
|||||||
|
|
||||||
/// Queued I/O request with metadata.
|
/// Queued I/O request with metadata.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[allow(dead_code)]
|
|
||||||
struct QueuedRequest<T> {
|
struct QueuedRequest<T> {
|
||||||
/// The actual request payload.
|
/// The actual request payload.
|
||||||
request: T,
|
request: T,
|
||||||
/// Time when the request was enqueued.
|
/// Time when the request was enqueued.
|
||||||
enqueue_time: Instant,
|
enqueue_time: Instant,
|
||||||
/// Original priority assigned to the request.
|
/// Original priority assigned to the request.
|
||||||
|
#[allow(dead_code, reason = "written but never read back (backlog#1823)")]
|
||||||
original_priority: IoPriority,
|
original_priority: IoPriority,
|
||||||
/// Current priority (may be boosted for starvation prevention).
|
/// Current priority (may be boosted for starvation prevention).
|
||||||
current_priority: IoPriority,
|
current_priority: IoPriority,
|
||||||
@@ -1466,7 +1449,6 @@ struct QueuedRequest<T> {
|
|||||||
|
|
||||||
/// Queue statistics for monitoring.
|
/// Queue statistics for monitoring.
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
#[allow(dead_code)]
|
|
||||||
struct QueueStats {
|
struct QueueStats {
|
||||||
/// Number of high priority requests processed.
|
/// Number of high priority requests processed.
|
||||||
high_processed: u64,
|
high_processed: u64,
|
||||||
@@ -1552,7 +1534,6 @@ impl Default for IoPriorityQueueConfig {
|
|||||||
|
|
||||||
impl IoPriorityQueueConfig {
|
impl IoPriorityQueueConfig {
|
||||||
/// Load configuration from environment.
|
/// Load configuration from environment.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn from_env() -> Self {
|
pub fn from_env() -> Self {
|
||||||
Self {
|
Self {
|
||||||
queue_high_capacity: rustfs_utils::get_env_usize(
|
queue_high_capacity: rustfs_utils::get_env_usize(
|
||||||
@@ -1603,7 +1584,6 @@ impl IoPriorityQueueConfig {
|
|||||||
|
|
||||||
impl<T> IoPriorityQueue<T> {
|
impl<T> IoPriorityQueue<T> {
|
||||||
/// Create a new priority queue with the given configuration.
|
/// Create a new priority queue with the given configuration.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn new(config: IoPriorityQueueConfig) -> Self {
|
pub fn new(config: IoPriorityQueueConfig) -> Self {
|
||||||
let config_clone = config.clone();
|
let config_clone = config.clone();
|
||||||
Self {
|
Self {
|
||||||
@@ -1617,7 +1597,6 @@ impl<T> IoPriorityQueue<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Enqueue a request with the given priority.
|
/// Enqueue a request with the given priority.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub async fn enqueue(&self, priority: IoPriority, request: T) {
|
pub async fn enqueue(&self, priority: IoPriority, request: T) {
|
||||||
let queued = QueuedRequest {
|
let queued = QueuedRequest {
|
||||||
request,
|
request,
|
||||||
@@ -1638,7 +1617,6 @@ impl<T> IoPriorityQueue<T> {
|
|||||||
///
|
///
|
||||||
/// This method performs starvation prevention checks before dequeuing.
|
/// This method performs starvation prevention checks before dequeuing.
|
||||||
/// Returns `None` if all queues are empty.
|
/// Returns `None` if all queues are empty.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub async fn dequeue(&self) -> Option<(T, IoPriority)> {
|
pub async fn dequeue(&self) -> Option<(T, IoPriority)> {
|
||||||
// 1. Check for starvation prevention
|
// 1. Check for starvation prevention
|
||||||
self.check_starvation().await;
|
self.check_starvation().await;
|
||||||
@@ -1716,7 +1694,6 @@ impl<T> IoPriorityQueue<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get current queue status for monitoring.
|
/// Get current queue status for monitoring.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub async fn status(&self) -> IoQueueStatus {
|
pub async fn status(&self) -> IoQueueStatus {
|
||||||
let high_queue = self.high_queue.lock().await;
|
let high_queue = self.high_queue.lock().await;
|
||||||
let normal_queue = self.normal_queue.lock().await;
|
let normal_queue = self.normal_queue.lock().await;
|
||||||
@@ -1737,7 +1714,6 @@ impl<T> IoPriorityQueue<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the total number of queued requests.
|
/// Get the total number of queued requests.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub async fn len(&self) -> usize {
|
pub async fn len(&self) -> usize {
|
||||||
let high_queue = self.high_queue.lock().await;
|
let high_queue = self.high_queue.lock().await;
|
||||||
let normal_queue = self.normal_queue.lock().await;
|
let normal_queue = self.normal_queue.lock().await;
|
||||||
@@ -1747,7 +1723,6 @@ impl<T> IoPriorityQueue<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check if all queues are empty.
|
/// Check if all queues are empty.
|
||||||
#[allow(dead_code)]
|
|
||||||
pub async fn is_empty(&self) -> bool {
|
pub async fn is_empty(&self) -> bool {
|
||||||
self.len().await == 0
|
self.len().await == 0
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user