summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--myraid.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/myraid.py b/myraid.py
index 4a6ad6a..fc240b1 100644
--- a/myraid.py
+++ b/myraid.py
@@ -198,6 +198,7 @@ class MyRaid():
segment_no = offset / self.raid_chunk_size
segment_off = offset % self.raid_chunk_size
stripe_no = segment_no / self.raid_disk_count
+ subraid_no = -1
par_disk = -1
data_disk = segment_no % self.raid_disk_count
off_disk = self.raid_start + stripe_no * self.raid_chunk_size + segment_off
@@ -207,6 +208,7 @@ class MyRaid():
segment_no = -1
segment_off = -1
stripe_no = -1
+ subraid_no = -1
par_disk = 1
data_disk = 0
off_disk = self.raid_start + offset
@@ -216,6 +218,7 @@ class MyRaid():
segment_no = offset / self.raid_chunk_size
segment_off = offset % self.raid_chunk_size
stripe_no = segment_no / (self.raid_disk_count-1)
+ subraid_no = -1
if self.raid_layout in ['ls','la']:
par_disk = (self.raid_disk_count-1) - (stripe_no % self.raid_disk_count)
@@ -262,8 +265,8 @@ class MyRaid():
else:
raise Exception('Unimplemented read_raid_result() for raid_type == %s', raid_type)
- logging.debug("raid.read_result(%s): offset=%d,segment_no=%d,segment_off=%d,stripe_no=%d,par_disk=%d,data_disk=%d,off_disk=%d,size2=%d,segment_off+size2=%d"
- % (raid_type,offset,segment_no,segment_off,stripe_no,par_disk,data_disk,off_disk,size2,segment_off+size2) )
+ logging.debug("raid.read_result(%s): offset=%d,segment_no=%d,segment_off=%d,stripe_no=%d,subraid_no=%d,par_disk=%d(disk%02d),data_disk=%d(disk%02d),off_disk=%d,size2=%d,segment_off+size2=%d"
+ % (raid_type,offset,segment_no,segment_off,stripe_no,subraid_no,par_disk,self.raid_disk_order[par_disk],data_disk,self.raid_disk_order[data_disk],off_disk,size2,segment_off+size2) )
data_fd = self.raid_disks[data_disk]
@@ -300,5 +303,9 @@ class MyRaid():
data_arr.append( '\0' * self.raid_sector_size)
data = ''.join(data_arr)
+ # Prevent short reads, seems mandatory for losetup'ing raid_result but kills performance
+ if size2 < size:
+ return ''.join( (data, self.read_raid_result(raid_type,offset+size2,size-size2) ) )
+
return data