From c082905bb60ba980cfa81fb9a814331d0a116221 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Tue, 18 Apr 2006 13:52:11 +0000 Subject: [PATCH] Fix storing offset of already synchronized data. Offset in entire array was stored in metadata instead of an offset in single disk. After reboot/crash synchronization process started from a wrong offset skipping (not synchronizing) part of the component which can lead to data corrutpion (when synchronization process was interrupted on initial synchronization) or other strange situations like 'graid3 status' showing value more than 100%. Reported, reviewed and tested by: ru Reported by: Dmitry Morozovsky MFC after: 1 day --- sys/geom/raid3/g_raid3.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/geom/raid3/g_raid3.c b/sys/geom/raid3/g_raid3.c index 55687c6cf08b..71a839904ead 100644 --- a/sys/geom/raid3/g_raid3.c +++ b/sys/geom/raid3/g_raid3.c @@ -723,10 +723,12 @@ g_raid3_fill_metadata(struct g_raid3_disk *disk, struct g_raid3_metadata *md) md->md_no = disk->d_no; md->md_syncid = disk->d_sync.ds_syncid; md->md_dflags = (disk->d_flags & G_RAID3_DISK_FLAG_MASK); - if (disk->d_state == G_RAID3_DISK_STATE_SYNCHRONIZING) - md->md_sync_offset = disk->d_sync.ds_offset_done; - else + if (disk->d_state != G_RAID3_DISK_STATE_SYNCHRONIZING) md->md_sync_offset = 0; + else { + md->md_sync_offset = + disk->d_sync.ds_offset_done / (sc->sc_ndisks - 1); + } if (disk->d_consumer != NULL && disk->d_consumer->provider != NULL) pp = disk->d_consumer->provider; else