4
4
//! a small piece cache. It fully manages farming and plotting process, including listening to node
5
5
//! notifications, producing solutions and singing rewards.
6
6
7
+ pub mod direct_io_file;
7
8
pub mod farming;
8
9
pub mod identity;
9
10
mod metrics;
@@ -13,7 +14,6 @@ pub mod plot_cache;
13
14
mod plotted_sectors;
14
15
mod plotting;
15
16
mod reward_signing;
16
- pub mod unbuffered_io_file_windows;
17
17
18
18
use crate :: disk_piece_cache:: { DiskPieceCache , DiskPieceCacheError } ;
19
19
use crate :: farm:: {
@@ -22,6 +22,7 @@ use crate::farm::{
22
22
} ;
23
23
use crate :: node_client:: NodeClient ;
24
24
use crate :: plotter:: Plotter ;
25
+ use crate :: single_disk_farm:: direct_io_file:: { DirectIoFile , DISK_SECTOR_SIZE } ;
25
26
use crate :: single_disk_farm:: farming:: rayon_files:: RayonFiles ;
26
27
use crate :: single_disk_farm:: farming:: {
27
28
farming, slot_notification_forwarder, FarmingOptions , PlotAudit ,
@@ -37,9 +38,6 @@ use crate::single_disk_farm::plotting::{
37
38
plotting, plotting_scheduler, PlottingOptions , PlottingSchedulerOptions , SectorPlottingOptions ,
38
39
} ;
39
40
use crate :: single_disk_farm:: reward_signing:: reward_signing;
40
- #[ cfg( windows) ]
41
- use crate :: single_disk_farm:: unbuffered_io_file_windows:: UnbufferedIoFileWindows ;
42
- use crate :: single_disk_farm:: unbuffered_io_file_windows:: DISK_SECTOR_SIZE ;
43
41
use crate :: utils:: { tokio_rayon_spawn_handler, AsyncJoinOnDrop } ;
44
42
use crate :: { farm, KNOWN_PEERS_CACHE_SIZE } ;
45
43
use async_lock:: { Mutex as AsyncMutex , RwLock as AsyncRwLock } ;
@@ -75,8 +73,6 @@ use subspace_core_primitives::{
75
73
} ;
76
74
use subspace_erasure_coding:: ErasureCoding ;
77
75
use subspace_farmer_components:: file_ext:: FileExt ;
78
- #[ cfg( not( windows) ) ]
79
- use subspace_farmer_components:: file_ext:: OpenOptionsExt ;
80
76
use subspace_farmer_components:: reading:: ReadSectorRecordChunksMode ;
81
77
use subspace_farmer_components:: sector:: { sector_size, SectorMetadata , SectorMetadataChecksummed } ;
82
78
use subspace_farmer_components:: { FarmerProtocolInfo , ReadAtSync } ;
@@ -753,14 +749,8 @@ struct SingleDiskFarmInit {
753
749
identity : Identity ,
754
750
single_disk_farm_info : SingleDiskFarmInfo ,
755
751
single_disk_farm_info_lock : Option < SingleDiskFarmInfoLock > ,
756
- #[ cfg( not( windows) ) ]
757
- plot_file : Arc < File > ,
758
- #[ cfg( windows) ]
759
- plot_file : Arc < UnbufferedIoFileWindows > ,
760
- #[ cfg( not( windows) ) ]
761
- metadata_file : File ,
762
- #[ cfg( windows) ]
763
- metadata_file : UnbufferedIoFileWindows ,
752
+ plot_file : Arc < DirectIoFile > ,
753
+ metadata_file : DirectIoFile ,
764
754
metadata_header : PlotMetadataHeader ,
765
755
target_sector_count : u16 ,
766
756
sectors_metadata : Arc < AsyncRwLock < Vec < SectorMetadataChecksummed > > > ,
@@ -993,17 +983,7 @@ impl SingleDiskFarm {
993
983
let farming_plot_fut = task:: spawn_blocking ( || {
994
984
farming_thread_pool
995
985
. install ( move || {
996
- #[ cfg( windows) ]
997
- {
998
- RayonFiles :: open_with (
999
- & directory. join ( Self :: PLOT_FILE ) ,
1000
- UnbufferedIoFileWindows :: open,
1001
- )
1002
- }
1003
- #[ cfg( not( windows) ) ]
1004
- {
1005
- RayonFiles :: open ( & directory. join ( Self :: PLOT_FILE ) )
1006
- }
986
+ RayonFiles :: open_with ( & directory. join ( Self :: PLOT_FILE ) , DirectIoFile :: open)
1007
987
} )
1008
988
. map ( |farming_plot| ( farming_plot, farming_thread_pool) )
1009
989
} ) ;
@@ -1474,19 +1454,7 @@ impl SingleDiskFarm {
1474
1454
let target_sector_count = allocated_space_distribution. target_sector_count ;
1475
1455
1476
1456
let metadata_file_path = directory. join ( Self :: METADATA_FILE ) ;
1477
- #[ cfg( not( windows) ) ]
1478
- let metadata_file = OpenOptions :: new ( )
1479
- . read ( true )
1480
- . write ( true )
1481
- . create ( true )
1482
- . advise_random_access ( )
1483
- . open ( & metadata_file_path) ?;
1484
-
1485
- #[ cfg( not( windows) ) ]
1486
- metadata_file. advise_random_access ( ) ?;
1487
-
1488
- #[ cfg( windows) ]
1489
- let metadata_file = UnbufferedIoFileWindows :: open ( & metadata_file_path) ?;
1457
+ let metadata_file = DirectIoFile :: open ( & metadata_file_path) ?;
1490
1458
1491
1459
let metadata_size = metadata_file. size ( ) ?;
1492
1460
let expected_metadata_size = allocated_space_distribution. metadata_file_size ;
@@ -1576,19 +1544,7 @@ impl SingleDiskFarm {
1576
1544
Arc :: new ( AsyncRwLock :: new ( sectors_metadata) )
1577
1545
} ;
1578
1546
1579
- #[ cfg( not( windows) ) ]
1580
- let plot_file = OpenOptions :: new ( )
1581
- . read ( true )
1582
- . write ( true )
1583
- . create ( true )
1584
- . advise_random_access ( )
1585
- . open ( directory. join ( Self :: PLOT_FILE ) ) ?;
1586
-
1587
- #[ cfg( not( windows) ) ]
1588
- plot_file. advise_random_access ( ) ?;
1589
-
1590
- #[ cfg( windows) ]
1591
- let plot_file = UnbufferedIoFileWindows :: open ( & directory. join ( Self :: PLOT_FILE ) ) ?;
1547
+ let plot_file = DirectIoFile :: open ( & directory. join ( Self :: PLOT_FILE ) ) ?;
1592
1548
1593
1549
if plot_file. size ( ) ? != allocated_space_distribution. plot_file_size {
1594
1550
// Allocating the whole file (`set_len` below can create a sparse file, which will cause
@@ -1731,13 +1687,7 @@ impl SingleDiskFarm {
1731
1687
pub fn read_all_sectors_metadata (
1732
1688
directory : & Path ,
1733
1689
) -> io:: Result < Vec < SectorMetadataChecksummed > > {
1734
- #[ cfg( not( windows) ) ]
1735
- let metadata_file = OpenOptions :: new ( )
1736
- . read ( true )
1737
- . open ( directory. join ( Self :: METADATA_FILE ) ) ?;
1738
-
1739
- #[ cfg( windows) ]
1740
- let metadata_file = UnbufferedIoFileWindows :: open ( & directory. join ( Self :: METADATA_FILE ) ) ?;
1690
+ let metadata_file = DirectIoFile :: open ( & directory. join ( Self :: METADATA_FILE ) ) ?;
1741
1691
1742
1692
let metadata_size = metadata_file. size ( ) ?;
1743
1693
let sector_metadata_size = SectorMetadataChecksummed :: encoded_size ( ) ;
0 commit comments