From: Neil Brown <neilb@suse.de>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-raid@vger.kernel.org
Subject: Re: [PATCH 1/3] md: ping userspace on 'write-pending' events
Date: Thu, 1 May 2008 14:44:48 +1000 [thread overview]
Message-ID: <18457.19136.168378.816525@notabene.brown> (raw)
In-Reply-To: message from Dan Williams on Tuesday April 29
On Tuesday April 29, dan.j.williams@intel.com wrote:
> Also, when userspace writes 'active', clear all mddev->flags to satisfy
> md_write_start (the other bits do not matter to external-metadata arrays).
>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Thanks Dan.
There are two things that I don't like about this patch.
1/ I don't think clearing all the flags in array_state_store is really
right. You do that to make sure that MD_CHANGE_DEVS is clear, but
there is no guarantee that it won't be set again before it is
tested in md_write_start.
I think it is best to just get md_write_start (and md_allow_write)
to just test the bits they are really interested in.
2/ having the tests of mddev->external isn't necessary. I really want
"array_state" to get a notification whenever it changes, no matter
what sort of metadata is being used.
Change the patch based on those observations I get:
---------------------------------
Signed-off-by: Neil Brown <neilb@suse.de>
### Diffstat output
./drivers/md/md.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff .prev/drivers/md/md.c ./drivers/md/md.c
--- .prev/drivers/md/md.c 2008-04-29 12:27:58.000000000 +1000
+++ ./drivers/md/md.c 2008-05-01 14:35:16.000000000 +1000
@@ -5434,8 +5434,11 @@ void md_write_start(mddev_t *mddev, stru
md_wakeup_thread(mddev->thread);
}
spin_unlock_irq(&mddev->write_lock);
+ sysfs_notify(&mddev->kobj, NULL, "array_state");
}
- wait_event(mddev->sb_wait, mddev->flags==0);
+ wait_event(mddev->sb_wait,
+ !test_bit(MD_CHANGE_CLEAN, &mddev->flags) &&
+ !test_bit(MD_CHANGE_PENDING, &mddev->flags));
}
void md_write_end(mddev_t *mddev)
@@ -5470,6 +5473,12 @@ void md_allow_write(mddev_t *mddev)
mddev->safemode = 1;
spin_unlock_irq(&mddev->write_lock);
md_update_sb(mddev, 0);
+
+ sysfs_notify(&mddev->kobj, NULL, "array_state");
+ /* wait for the dirty state to be recorded in the metadata */
+ wait_event(mddev->sb_wait,
+ !test_bit(MD_CHANGE_CLEAN, &mddev->flags) &&
+ !test_bit(MD_CHANGE_PENDING, &mddev->flags));
} else
spin_unlock_irq(&mddev->write_lock);
}
----------------------------
Look OK ??
Thanks,
NeilBrown
> ---
>
> drivers/md/md.c | 19 +++++++++++++++----
> 1 files changed, 15 insertions(+), 4 deletions(-)
>
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 6859bcd..ad53035 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -2664,7 +2664,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len)
> if (mddev->pers) {
> restart_array(mddev);
> if (mddev->external)
> - clear_bit(MD_CHANGE_CLEAN, &mddev->flags);
> + mddev->flags = 0;
> wake_up(&mddev->sb_wait);
> err = 0;
> } else {
> @@ -5413,9 +5413,14 @@ void md_write_start(mddev_t *mddev, struct bio *bi)
> if (mddev->in_sync) {
> mddev->in_sync = 0;
> set_bit(MD_CHANGE_CLEAN, &mddev->flags);
> + spin_unlock_irq(&mddev->write_lock);
> +
> + /* notify userspace to handle clean->dirty */
> + if (mddev->external)
> + sysfs_notify(&mddev->kobj, NULL, "array_state");
> md_wakeup_thread(mddev->thread);
> - }
> - spin_unlock_irq(&mddev->write_lock);
> + } else
> + spin_unlock_irq(&mddev->write_lock);
> }
> wait_event(mddev->sb_wait, mddev->flags==0);
> }
> @@ -5451,7 +5456,13 @@ void md_allow_write(mddev_t *mddev)
> mddev->safemode == 0)
> mddev->safemode = 1;
> spin_unlock_irq(&mddev->write_lock);
> - md_update_sb(mddev, 0);
> +
> + /* wait for the dirty state to be recorded in the metadata */
> + if (mddev->external) {
> + sysfs_notify(&mddev->kobj, NULL, "array_state");
> + wait_event(mddev->sb_wait, mddev->flags == 0);
> + } else
> + md_update_sb(mddev, 0);
> } else
> spin_unlock_irq(&mddev->write_lock);
> }
next prev parent reply other threads:[~2008-05-01 4:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-30 1:19 [PATCH 0/3] A few more md patches for 2.6.26 Dan Williams
2008-04-30 1:19 ` [PATCH 1/3] md: ping userspace on 'write-pending' events Dan Williams
2008-05-01 4:44 ` Neil Brown [this message]
2008-05-01 20:57 ` Dan Williams
2008-05-02 2:10 ` Neil Brown
2008-04-30 1:19 ` [PATCH 2/3] md: ping userspace on 'stop' events Dan Williams
2008-05-01 4:50 ` Neil Brown
2008-04-30 1:19 ` [PATCH 3/3] md: add new / required locking for calls to blk_remove_plug and blk_plug_queue Dan Williams
2008-05-01 0:36 ` Neil Brown
2008-05-01 0:50 ` Dan Williams
2008-05-01 2:33 ` Neil Brown
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=18457.19136.168378.816525@notabene.brown \
--to=neilb@suse.de \
--cc=dan.j.williams@intel.com \
--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).