Skip to contentSkip to conversation

Recovery speed is wrong

PATCH In review Xiao Ni 2 participants 3 messages Aug 7, 2014 – Aug 8, 2014 1 message not in the archive MD RAID

lore
Share & tools
lore

Xiao Ni

author
#1 lore raw

PATCH 1/1 Recovery speed is wrong

In reply to a message not in the archive

Hi all

When we calculate the speed of recovery, the numerator that contains the recovery done sectors.
It's need to subtract the sectors which don't finish recovery.

md.c 2014-08-07 16:07:12.559503942 +0800 renamed from drivers/md/md.c 2014-07-30 14:36:37.327535805 +0800 +3 -2
diff -urN linux-stable/drivers/md/md.c fix/md.c
@@ -7376,7 +7376,7 @@
   struct mddev *mddev2;
   unsigned int currspeed = 0,
       window;
-  sector_t max_sectors,j, io_sectors;
+  sector_t max_sectors,j, io_sectors, recovery_done;
   unsigned long mark[SYNC_MARKS];
   unsigned long update_time;
   sector_t mark_cnt[SYNC_MARKS];
@@ -7652,7 +7652,8 @@
       */  
      cond_resched();
 
-     currspeed = ((unsigned long)(io_sectors-mddev->resync_mark_cnt))/2
+     recovery_done = io_sectors - atomic_read(&mddev->recovery_active);
+     currspeed = ((unsigned long)recovery_done - mddev->resync_mark_cnt)/2
         /((jiffies-mddev->resync_mark)/HZ +1) +1;
 
      if (currspeed > speed_min(mddev)) {
#2 lore raw
Quoted 4 lines · On Thu, 7 Aug 2014 09:37:41 -0400 (EDT) Xiao Ni <[email protected]> wrote:

Hi all

When we calculate the speed of recovery, the numerator that contains the recovery done sectors.
It's need to subtract the sectors which don't finish recovery.

Thanks,
I've applied the patch. However it needed some fixing up first. If you are going to be sending more patches, you need to get these details right.

I suggest using "quilt" to create patches. There are other options, I mostly use 'git' and 'stg' myself, but quilt is easy to get started with:

md.c 2014-08-07 16:07:12.559503942 +0800

Quoted 7 lines

diff -urN linux-stable/drivers/md/md.c fix/md.c

md.c 2014-08-07 16:07:12.559503942 +0800 renamed from drivers/md/md.c 2014-07-30 14:36:37.327535805 +0800 +0 -0

This makes it look like the file "fix/md.c" is being patched, which confuses programs that apply patches (like "git am").
If you really want to do it by hand, then:

cp drivers/md/md.c drivers/md/md.c.orig

  # edit drivers/md/md.c
  # compile and test
  diff -u drivers/md/md.c.orig drivers/md/md.c > /tmp/diff

and post /tmp/diff.

md.c 2014-08-07 16:07:12.559503942 +0800 line 7382

Quoted 9 lines
md.c 2014-08-07 16:07:12.559503942 +0800 renamed from drivers/md/md.c 2014-07-30 14:36:37.327535805 +0800 +1 -1
@@ -7376,7 +7376,7 @@
   struct mddev *mddev2;
   unsigned int currspeed = 0,
       window;
-  sector_t max_sectors,j, io_sectors;
+  sector_t max_sectors,j, io_sectors, recovery_done;
   unsigned long mark[SYNC_MARKS];
   unsigned long update_time;
   sector_t mark_cnt[SYNC_MARKS];

^^^^

There are spaces here. They should be 'tabs'. Probably your mail program thinks it knows better and is converting spaces to tabs.
If you cannot get it not to do that, then add the patch as an attachment. I MUCH prefer patches to be inline in the text, not as an attachment, but an attachment is MUCH better than converting all the tabs to spaces.

md.c 2014-08-07 16:07:12.559503942 +0800 line 7657

Quoted 8 lines
md.c 2014-08-07 16:07:12.559503942 +0800 renamed from drivers/md/md.c 2014-07-30 14:36:37.327535805 +0800 +2 -1
@@ -7652,7 +7652,8 @@
       */  
      cond_resched();
 
-     currspeed = ((unsigned long)(io_sectors-mddev->resync_mark_cnt))/2
+     recovery_done = io_sectors - atomic_read(&mddev->recovery_active);
+     currspeed = ((unsigned long)recovery_done - mddev->resync_mark_cnt)/2
         /((jiffies-mddev->resync_mark)/HZ +1) +1;

I also kept the inner brackets, so that reads:

md.c 2014-08-07 16:07:12.559503942 +0800 line 7658

Quoted 1 line
md.c 2014-08-07 16:07:12.559503942 +0800 renamed from drivers/md/md.c 2014-07-30 14:36:37.327535805 +0800 +1 -0
+     currspeed = ((unsigned long)(recovery_done - mddev->resync_mark_cnt))/2

I think the extra brackets make it clear that it is the difference that needs to be cast, not just the first value. The result is the same, but this very is (to me) more readable.

Thanks,
NeilBrown

Quoted 6 lines
md.c 2014-08-07 16:07:12.559503942 +0800 renamed from drivers/md/md.c 2014-07-30 14:36:37.327535805 +0800 +0 -1
      if (currspeed > speed_min(mddev)) {
--

To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#3 lore raw

----- Original Message -----

Quoted 70 lines

From: "NeilBrown" <[email protected]>
To: "Xiao Ni" <[email protected]>
Cc: [email protected]
Sent: Friday, August 8, 2014 10:21:55 AM
Subject: Re: [PATCH] Recovery speed is wrong

Quoted 5 lines · On Thu, 7 Aug 2014 09:37:41 -0400 (EDT) Xiao Ni <[email protected]> wrote:

Hi all

When we calculate the speed of recovery, the numerator that contains the recovery done sectors.
It's need to subtract the sectors which don't finish recovery.

Thanks,
I've applied the patch. However it needed some fixing up first. If you are going to be sending more patches, you need to get these details right.

I suggest using "quilt" to create patches. There are other options, I mostly use 'git' and 'stg' myself, but quilt is easy to get started with:

md.c 2014-08-07 16:07:12.559503942 +0800

Quoted 7 lines

diff -urN linux-stable/drivers/md/md.c fix/md.c

md.c 2014-08-07 16:07:12.559503942 +0800 renamed from drivers/md/md.c 2014-07-30 14:36:37.327535805 +0800 +0 -0

This makes it look like the file "fix/md.c" is being patched, which confuses programs that apply patches (like "git am").
If you really want to do it by hand, then:

cp drivers/md/md.c drivers/md/md.c.orig

  # edit drivers/md/md.c
  # compile and test
  diff -u drivers/md/md.c.orig drivers/md/md.c > /tmp/diff

and post /tmp/diff.

md.c 2014-08-07 16:07:12.559503942 +0800 line 7382

Quoted 9 lines
md.c 2014-08-07 16:07:12.559503942 +0800 renamed from drivers/md/md.c 2014-07-30 14:36:37.327535805 +0800 +1 -1
@@ -7376,7 +7376,7 @@
   struct mddev *mddev2;
   unsigned int currspeed = 0,
       window;
-  sector_t max_sectors,j, io_sectors;
+  sector_t max_sectors,j, io_sectors, recovery_done;
   unsigned long mark[SYNC_MARKS];
   unsigned long update_time;
   sector_t mark_cnt[SYNC_MARKS];

^^^^

There are spaces here. They should be 'tabs'. Probably your mail program thinks it knows better and is converting spaces to tabs.
If you cannot get it not to do that, then add the patch as an attachment. I MUCH prefer patches to be inline in the text, not as an attachment, but an attachment is MUCH better than converting all the tabs to spaces.

md.c 2014-08-07 16:07:12.559503942 +0800 line 7657

Quoted 8 lines
md.c 2014-08-07 16:07:12.559503942 +0800 renamed from drivers/md/md.c 2014-07-30 14:36:37.327535805 +0800 +2 -1
@@ -7652,7 +7652,8 @@
       */
      cond_resched();
 
-     currspeed = ((unsigned long)(io_sectors-mddev->resync_mark_cnt))/2
+     recovery_done = io_sectors - atomic_read(&mddev->recovery_active);
+     currspeed = ((unsigned long)recovery_done - mddev->resync_mark_cnt)/2
         /((jiffies-mddev->resync_mark)/HZ +1) +1;

I also kept the inner brackets, so that reads:

Quoted 2 lines
md.c 2014-08-07 16:07:12.559503942 +0800 renamed from drivers/md/md.c 2014-07-30 14:36:37.327535805 +0800 +1 -0
+     currspeed = ((unsigned long)(recovery_done -

mddev->resync_mark_cnt))/2

Quoted 16 lines

I think the extra brackets make it clear that it is the difference that needs to be cast, not just the first value. The result is the same, but this very is (to me) more readable.

Thanks,
NeilBrown

Quoted 6 lines
 
      if (currspeed > speed_min(mddev)) {

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hi Neil

Thanks very much for the detailed information. I need to study the git tools to create and sendmail
patches. I'll notice those problems.

Best Regards
Xiao