From 85a90e3f5f417472d7c59d64c005a68f3e565803 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Wed, 14 Dec 2016 21:10:43 +0100 Subject: [PATCH 1/4] remove auto for linux also --- db/src/kvdb.rs | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/db/src/kvdb.rs b/db/src/kvdb.rs index dd321d74..05c49466 100644 --- a/db/src/kvdb.rs +++ b/db/src/kvdb.rs @@ -165,33 +165,6 @@ pub fn rotational_from_df_output(df_out: Vec) -> Option { } impl CompactionProfile { - /// Attempt to determine the best profile automatically, only Linux for now. - #[cfg(target_os = "linux")] - pub fn auto(db_path: &Path) -> CompactionProfile { - let hdd_check_file = db_path - .to_str() - .and_then(|path_str| Command::new("df").arg(path_str).output().ok()) - .and_then(|df_res| match df_res.status.success() { - true => Some(df_res.stdout), - false => None, - }) - .and_then(rotational_from_df_output); - // Read out the file and match compaction profile. - if let Some(hdd_check) = hdd_check_file { - if let Ok(mut file) = File::open(hdd_check.as_path()) { - let mut buffer = [0; 1]; - if file.read_exact(&mut buffer).is_ok() { - // 0 means not rotational. - if buffer == [48] { return Self::ssd(); } - // 1 means rotational. - if buffer == [49] { return Self::hdd(); } - } - } - } - // Fallback if drive type was not determined. - Self::default() - } - /// Just default for other platforms. #[cfg(not(target_os = "linux"))] pub fn auto(_db_path: &::std::path::Path) -> CompactionProfile { From 1b10e016c2175d21d43238ae8d8a8987a308ad1b Mon Sep 17 00:00:00 2001 From: NikVolf Date: Wed, 14 Dec 2016 21:11:27 +0100 Subject: [PATCH 2/4] remove auto for other platforms --- db/src/kvdb.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/db/src/kvdb.rs b/db/src/kvdb.rs index 05c49466..cf4bf4b1 100644 --- a/db/src/kvdb.rs +++ b/db/src/kvdb.rs @@ -165,11 +165,6 @@ pub fn rotational_from_df_output(df_out: Vec) -> Option { } impl CompactionProfile { - /// Just default for other platforms. - #[cfg(not(target_os = "linux"))] - pub fn auto(_db_path: &::std::path::Path) -> CompactionProfile { - Self::default() - } /// Default profile suitable for SSD storage pub fn ssd() -> CompactionProfile { From 92ea916e04acaeb2ec7d761f01f761d63160c8d4 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Wed, 14 Dec 2016 21:18:54 +0100 Subject: [PATCH 3/4] remove license --- db/src/kvdb.rs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/db/src/kvdb.rs b/db/src/kvdb.rs index cf4bf4b1..4d4d8226 100644 --- a/db/src/kvdb.rs +++ b/db/src/kvdb.rs @@ -1,19 +1,3 @@ -// Copyright 2015, 2016 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - //! Key-Value store abstraction with `RocksDB` backend. use std::mem; From f7b4f72f7d207bd5063193c90331c06b445d6558 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Wed, 14 Dec 2016 21:26:03 +0100 Subject: [PATCH 4/4] another leftover for linux --- db/src/kvdb.rs | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/db/src/kvdb.rs b/db/src/kvdb.rs index 4d4d8226..64cc74c9 100644 --- a/db/src/kvdb.rs +++ b/db/src/kvdb.rs @@ -6,12 +6,6 @@ use elastic_array::*; use std::default::Default; use rocksdb::{DB, Writable, WriteBatch, WriteOptions, IteratorMode, DBIterator, Options, DBCompactionStyle, BlockBasedOptions, Cache, Column, ReadOptions}; -#[cfg(target_os = "linux")] -use regex::Regex; -#[cfg(target_os = "linux")] -use std::process::Command; -#[cfg(target_os = "linux")] -use std::fs::File; use std::collections::HashMap; use byteorder::{LittleEndian, ByteOrder}; //use std::path::Path; @@ -129,25 +123,6 @@ impl Default for CompactionProfile { } } -/// Given output of df command return Linux rotational flag file path. -#[cfg(target_os = "linux")] -pub fn rotational_from_df_output(df_out: Vec) -> Option { - str::from_utf8(df_out.as_slice()) - .ok() - // Get the drive name. - .and_then(|df_str| Regex::new(r"/dev/(sd[:alpha:]{1,2})") - .ok() - .and_then(|re| re.captures(df_str)) - .and_then(|captures| captures.at(1))) - // Generate path e.g. /sys/block/sda/queue/rotational - .map(|drive_path| { - let mut p = PathBuf::from("/sys/block"); - p.push(drive_path); - p.push("queue/rotational"); - p - }) -} - impl CompactionProfile { /// Default profile suitable for SSD storage