linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: linux-raid@vger.kernel.org
Subject: [md PATCH 11/13] md: Don't let implementation detail of curr_resync leak out through sysfs.
Date: Wed, 12 Jan 2011 09:12:47 +1100	[thread overview]
Message-ID: <20110111221247.12732.76833.stgit@notabene.brown> (raw)
In-Reply-To: <20110111221050.12732.31647.stgit@notabene.brown>

mddev->curr_resync has artificial values of '1' and '2' which are used
by the which ensures only one resync is happening at a time on any
given device.

These values are internal and should never be exposed to user-space
(except when translated appropriately as in the 'pending' status in
/proc/mdstat).

Unfortunately they are as ->curr_resync is assigned to
->curr_resync_completed and that value is directly visible through
sysfs.

So change the assignments to ->curr_resync_completed to get the same
valued from elsewhere in a form that doesn't have the magic '1' or '2'
values.

Signed-off-by: NeilBrown <neilb@suse.de>
---

 drivers/md/bitmap.c |    2 +-
 drivers/md/md.c     |    5 ++---
 drivers/md/raid5.c  |    4 ++--
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 6cf5871..9a35320 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1546,7 +1546,7 @@ void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector)
 	wait_event(bitmap->mddev->recovery_wait,
 		   atomic_read(&bitmap->mddev->recovery_active) == 0);
 
-	bitmap->mddev->curr_resync_completed = bitmap->mddev->curr_resync;
+	bitmap->mddev->curr_resync_completed = sector;
 	set_bit(MD_CHANGE_CLEAN, &bitmap->mddev->flags);
 	sector &= ~((1ULL << CHUNK_BLOCK_SHIFT(bitmap)) - 1);
 	s = 0;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index b98a85f..42b1d9e 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6824,7 +6824,7 @@ void md_do_sync(mddev_t *mddev)
 		       desc, mdname(mddev));
 		mddev->curr_resync = j;
 	}
-	mddev->curr_resync_completed = mddev->curr_resync;
+	mddev->curr_resync_completed = j;
 
 	while (j < max_sectors) {
 		sector_t sectors;
@@ -6842,8 +6842,7 @@ void md_do_sync(mddev_t *mddev)
 			md_unplug(mddev);
 			wait_event(mddev->recovery_wait,
 				   atomic_read(&mddev->recovery_active) == 0);
-			mddev->curr_resync_completed =
-				mddev->curr_resync;
+			mddev->curr_resync_completed = j;
 			set_bit(MD_CHANGE_CLEAN, &mddev->flags);
 			sysfs_notify(&mddev->kobj, NULL, "sync_completed");
 		}
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 9212c07..d223a6c 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -4236,7 +4236,7 @@ static sector_t reshape_request(mddev_t *mddev, sector_t sector_nr, int *skipped
 		wait_event(conf->wait_for_overlap,
 			   atomic_read(&conf->reshape_stripes)==0);
 		mddev->reshape_position = conf->reshape_progress;
-		mddev->curr_resync_completed = mddev->curr_resync;
+		mddev->curr_resync_completed = sector_nr;
 		conf->reshape_checkpoint = jiffies;
 		set_bit(MD_CHANGE_DEVS, &mddev->flags);
 		md_wakeup_thread(mddev->thread);
@@ -4337,7 +4337,7 @@ static sector_t reshape_request(mddev_t *mddev, sector_t sector_nr, int *skipped
 		wait_event(conf->wait_for_overlap,
 			   atomic_read(&conf->reshape_stripes) == 0);
 		mddev->reshape_position = conf->reshape_progress;
-		mddev->curr_resync_completed = mddev->curr_resync + reshape_sectors;
+		mddev->curr_resync_completed = sector_nr;
 		conf->reshape_checkpoint = jiffies;
 		set_bit(MD_CHANGE_DEVS, &mddev->flags);
 		md_wakeup_thread(mddev->thread);



  parent reply	other threads:[~2011-01-11 22:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-11 22:12 [md PATCH 00/13] md patches for the current merge window NeilBrown
2011-01-11 22:12 ` [md PATCH 05/13] md/raid5: use sysfs_notify_dirent_safe to avoid NULL pointer NeilBrown
2011-01-11 22:12 ` [md PATCH 07/13] md: Be more careful about clearing flags bit in ->recovery NeilBrown
2011-01-11 22:12 ` [md PATCH 01/13] md: fix regression with re-adding devices to arrays with no metadata NeilBrown
2011-01-11 22:12 ` [md PATCH 04/13] md: Ensure no IO request to get md device before it is properly initialised NeilBrown
2011-01-11 22:12 ` [md PATCH 06/13] md: md_stop_writes requires mddev_lock NeilBrown
2011-01-11 22:12 ` [md PATCH 02/13] md: fix regression resulting in delays in clearing bits in a bitmap NeilBrown
2011-01-11 22:12 ` [md PATCH 03/13] md: Fix single printks with multiple KERN_<level>s NeilBrown
2011-01-11 22:12 ` [md PATCH 13/13] md: fix sync_completed reporting for very large drives (>2TB) NeilBrown
2011-01-11 22:12 ` [md PATCH 12/13] md: allow suspend_lo and suspend_hi to decrease as well as increase NeilBrown
2011-01-11 22:12 ` [md PATCH 09/13] md-new-param-to_sync_page_io NeilBrown
2011-01-11 22:12 ` NeilBrown [this message]
2011-01-11 22:12 ` [md PATCH 10/13] md: separate meta and data devs NeilBrown
2011-01-11 22:12 ` [md PATCH 08/13] md-new-param-to-calc_dev_sboffset NeilBrown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110111221247.12732.76833.stgit@notabene.brown \
    --to=neilb@suse.de \
    --cc=linux-raid@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).