<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-stable.git/drivers/md/raid1.c, branch v3.1.2</title>
<subtitle>Linux kernel stable tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/'/>
<entry>
<title>md: Avoid waking up a thread after it has been freed.</title>
<updated>2011-09-21T05:30:20+00:00</updated>
<author>
<name>NeilBrown</name>
<email>neilb@suse.de</email>
</author>
<published>2011-09-21T05:30:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=01f96c0a9922cd9919baf9d16febdf7016177a12'/>
<id>01f96c0a9922cd9919baf9d16febdf7016177a12</id>
<content type='text'>
Two related problems:

1/ some error paths call "md_unregister_thread(mddev-&gt;thread)"
   without subsequently clearing -&gt;thread.  A subsequent call
   to mddev_unlock will try to wake the thread, and crash.

2/ Most calls to md_wakeup_thread are protected against the thread
   disappeared either by:
      - holding the -&gt;mutex
      - having an active request, so something else must be keeping
        the array active.
   However mddev_unlock calls md_wakeup_thread after dropping the
   mutex and without any certainty of an active request, so the
   -&gt;thread could theoretically disappear.
   So we need a spinlock to provide some protections.

So change md_unregister_thread to take a pointer to the thread
pointer, and ensure that it always does the required locking, and
clears the pointer properly.

Reported-by: "Moshe Melnikov" &lt;moshe@zadarastorage.com&gt;
Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
cc: stable@kernel.org
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Two related problems:

1/ some error paths call "md_unregister_thread(mddev-&gt;thread)"
   without subsequently clearing -&gt;thread.  A subsequent call
   to mddev_unlock will try to wake the thread, and crash.

2/ Most calls to md_wakeup_thread are protected against the thread
   disappeared either by:
      - holding the -&gt;mutex
      - having an active request, so something else must be keeping
        the array active.
   However mddev_unlock calls md_wakeup_thread after dropping the
   mutex and without any certainty of an active request, so the
   -&gt;thread could theoretically disappear.
   So we need a spinlock to provide some protections.

So change md_unregister_thread to take a pointer to the thread
pointer, and ensure that it always does the required locking, and
clears the pointer properly.

Reported-by: "Moshe Melnikov" &lt;moshe@zadarastorage.com&gt;
Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
cc: stable@kernel.org
</pre>
</div>
</content>
</entry>
<entry>
<title>md/raid1,10: Remove use-after-free bug in make_request.</title>
<updated>2011-09-10T07:21:23+00:00</updated>
<author>
<name>NeilBrown</name>
<email>neilb@suse.de</email>
</author>
<published>2011-09-10T07:21:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=079fa166a2874985ae58b2e21e26e1cbc91127d4'/>
<id>079fa166a2874985ae58b2e21e26e1cbc91127d4</id>
<content type='text'>
A single request to RAID1 or RAID10 might result in multiple
requests if there are known bad blocks that need to be avoided.

To detect if we need to submit another write request we test:
 	if (sectors_handled &lt; (bio-&gt;bi_size &gt;&gt; 9)) {

However this is after we call **_write_done() so the 'bio' no longer
belongs to us - the writes could have completed and the bio freed.

So move the **_write_done call until after the test against
bio-&gt;bi_size.

This addresses https://bugzilla.kernel.org/show_bug.cgi?id=41862

Reported-by: Bruno Wolff III &lt;bruno@wolff.to&gt;
Tested-by: Bruno Wolff III &lt;bruno@wolff.to&gt;
Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A single request to RAID1 or RAID10 might result in multiple
requests if there are known bad blocks that need to be avoided.

To detect if we need to submit another write request we test:
 	if (sectors_handled &lt; (bio-&gt;bi_size &gt;&gt; 9)) {

However this is after we call **_write_done() so the 'bio' no longer
belongs to us - the writes could have completed and the bio freed.

So move the **_write_done call until after the test against
bio-&gt;bi_size.

This addresses https://bugzilla.kernel.org/show_bug.cgi?id=41862

Reported-by: Bruno Wolff III &lt;bruno@wolff.to&gt;
Tested-by: Bruno Wolff III &lt;bruno@wolff.to&gt;
Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>md/raid1: factor several functions out or raid1d()</title>
<updated>2011-07-28T01:38:13+00:00</updated>
<author>
<name>NeilBrown</name>
<email>neilb@suse.de</email>
</author>
<published>2011-07-28T01:38:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=62096bce231b3760882ed91205fc84682d6b0529'/>
<id>62096bce231b3760882ed91205fc84682d6b0529</id>
<content type='text'>
raid1d is too big with several deep branches.
So separate them out into their own functions.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
raid1d is too big with several deep branches.
So separate them out into their own functions.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>md/raid1: improve handling of read failure during recovery.</title>
<updated>2011-07-28T01:33:42+00:00</updated>
<author>
<name>NeilBrown</name>
<email>neilb@suse.de</email>
</author>
<published>2011-07-28T01:33:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=3a9f28a5117e00a868dd8b4395f9a707ae56764b'/>
<id>3a9f28a5117e00a868dd8b4395f9a707ae56764b</id>
<content type='text'>
If we cannot read a block from anywhere during recovery, there is
now a better approach than just giving up.
We can record a bad block on each device and keep going - being
careful not to clear the bad block when a write succeeds as it might -
it will be a write of incorrect data.

We have now reached the state where - for raid1 - we only call
md_error if md_set_badblocks has failed.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If we cannot read a block from anywhere during recovery, there is
now a better approach than just giving up.
We can record a bad block on each device and keep going - being
careful not to clear the bad block when a write succeeds as it might -
it will be a write of incorrect data.

We have now reached the state where - for raid1 - we only call
md_error if md_set_badblocks has failed.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>md/raid1: record badblocks found during resync etc.</title>
<updated>2011-07-28T01:33:00+00:00</updated>
<author>
<name>NeilBrown</name>
<email>neilb@suse.de</email>
</author>
<published>2011-07-28T01:33:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=d8f05d2995d467a91db1af01637e6ffd94660ca8'/>
<id>d8f05d2995d467a91db1af01637e6ffd94660ca8</id>
<content type='text'>
If we find a bad block while writing as part of resync/recovery we
need to report that back to raid1d which must record the bad block,
or fail the device.

Similarly when fixing a read error, a further error should just
record a bad block if possible rather than failing the device.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If we find a bad block while writing as part of resync/recovery we
need to report that back to raid1d which must record the bad block,
or fail the device.

Similarly when fixing a read error, a further error should just
record a bad block if possible rather than failing the device.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>md/raid1:  Handle write errors by updating badblock log.</title>
<updated>2011-07-28T01:32:41+00:00</updated>
<author>
<name>NeilBrown</name>
<email>neilb@suse.de</email>
</author>
<published>2011-07-28T01:32:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=cd5ff9a16f0831f68c1024d5d776075b5123b034'/>
<id>cd5ff9a16f0831f68c1024d5d776075b5123b034</id>
<content type='text'>
When we get a write error (in the data area, not in metadata),
update the badblock log rather than failing the whole device.

As the write may well be many blocks, we trying writing each
block individually and only log the ones which fail.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When we get a write error (in the data area, not in metadata),
update the badblock log rather than failing the whole device.

As the write may well be many blocks, we trying writing each
block individually and only log the ones which fail.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>md/raid1: store behind-write pages in bi_vecs.</title>
<updated>2011-07-28T01:32:10+00:00</updated>
<author>
<name>NeilBrown</name>
<email>neilb@suse.de</email>
</author>
<published>2011-07-28T01:32:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=2ca68f5ed7383733102ee53cd8fa4021ecc3b275'/>
<id>2ca68f5ed7383733102ee53cd8fa4021ecc3b275</id>
<content type='text'>
When performing write-behind we allocate pages to store the data
during write.
Previously we just keep a list of pages.  Now we keep a list of
bi_vec which includes offset and size.
This means that the r1bio has complete information to create a new
bio which will be needed for retrying after write errors.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When performing write-behind we allocate pages to store the data
during write.
Previously we just keep a list of pages.  Now we keep a list of
bi_vec which includes offset and size.
This means that the r1bio has complete information to create a new
bio which will be needed for retrying after write errors.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>md/raid1: clear bad-block record when write succeeds.</title>
<updated>2011-07-28T01:31:49+00:00</updated>
<author>
<name>NeilBrown</name>
<email>neilb@suse.de</email>
</author>
<published>2011-07-28T01:31:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=4367af556133723d0f443e14ca8170d9447317cb'/>
<id>4367af556133723d0f443e14ca8170d9447317cb</id>
<content type='text'>
If we succeed in writing to a block that was recorded as
being bad, we clear the bad-block record.

This requires some delayed handling as the bad-block-list update has
to happen in process-context.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If we succeed in writing to a block that was recorded as
being bad, we clear the bad-block record.

This requires some delayed handling as the bad-block-list update has
to happen in process-context.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>md/raid1: avoid writing to known-bad blocks on known-bad drives.</title>
<updated>2011-07-28T01:31:48+00:00</updated>
<author>
<name>NeilBrown</name>
<email>neilb@suse.de</email>
</author>
<published>2011-07-28T01:31:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=1f68f0c4b677ccd6935ff61e4e6888787505f8dc'/>
<id>1f68f0c4b677ccd6935ff61e4e6888787505f8dc</id>
<content type='text'>
If we have seen any write error on a drive, then don't write to
any known-bad blocks on that drive.
If necessary, we divide the write request up into pieces just
like we do for reads, so each piece is either all written or
all not written to any given drive.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If we have seen any write error on a drive, then don't write to
any known-bad blocks on that drive.
If necessary, we divide the write request up into pieces just
like we do for reads, so each piece is either all written or
all not written to any given drive.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Namhyung Kim &lt;namhyung@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>md: make it easier to wait for bad blocks to be acknowledged.</title>
<updated>2011-07-28T01:31:48+00:00</updated>
<author>
<name>NeilBrown</name>
<email>neilb@suse.de</email>
</author>
<published>2011-07-28T01:31:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=de393cdea66cbd63c90725663f400c76faf1b255'/>
<id>de393cdea66cbd63c90725663f400c76faf1b255</id>
<content type='text'>
It is only safe to choose not to write to a bad block if that bad
block is safely recorded in metadata - i.e. if it has been
'acknowledged'.

If it hasn't we need to wait for the acknowledgement.

We support that using rdev-&gt;blocked wait and
md_wait_for_blocked_rdev by introducing a new device flag
'BlockedBadBlock'.

This flag is only advisory.
It is cleared whenever we acknowledge a bad block, so that a waiter
can re-check the particular bad blocks that it is interested it.

It should be set by a caller when they find they need to wait.
This (set after test) is inherently racy, but as
md_wait_for_blocked_rdev already has a timeout, losing the race will
have minimal impact.

When we clear "Blocked" was also clear "BlockedBadBlocks" incase it
was set incorrectly (see above race).

We also modify the way we manage 'Blocked' to fit better with the new
handling of 'BlockedBadBlocks' and to make it consistent between
externally managed and internally managed metadata.   This requires
that each raidXd loop checks if the metadata needs to be written and
triggers a write (md_check_recovery) if needed.  Otherwise a queued
write request might cause raidXd to wait for the metadata to write,
and only that thread can write it.

Before writing metadata, we set FaultRecorded for all devices that
are Faulty, then after writing the metadata we clear Blocked for any
device for which the Fault was certainly Recorded.

The 'faulty' device flag now appears in sysfs if the device is faulty
*or* it has unacknowledged bad blocks.  So user-space which does not
understand bad blocks can continue to function correctly.
User space which does, should not assume a device is faulty until it
sees the 'faulty' flag, and then sees the list of unacknowledged bad
blocks is empty.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It is only safe to choose not to write to a bad block if that bad
block is safely recorded in metadata - i.e. if it has been
'acknowledged'.

If it hasn't we need to wait for the acknowledgement.

We support that using rdev-&gt;blocked wait and
md_wait_for_blocked_rdev by introducing a new device flag
'BlockedBadBlock'.

This flag is only advisory.
It is cleared whenever we acknowledge a bad block, so that a waiter
can re-check the particular bad blocks that it is interested it.

It should be set by a caller when they find they need to wait.
This (set after test) is inherently racy, but as
md_wait_for_blocked_rdev already has a timeout, losing the race will
have minimal impact.

When we clear "Blocked" was also clear "BlockedBadBlocks" incase it
was set incorrectly (see above race).

We also modify the way we manage 'Blocked' to fit better with the new
handling of 'BlockedBadBlocks' and to make it consistent between
externally managed and internally managed metadata.   This requires
that each raidXd loop checks if the metadata needs to be written and
triggers a write (md_check_recovery) if needed.  Otherwise a queued
write request might cause raidXd to wait for the metadata to write,
and only that thread can write it.

Before writing metadata, we set FaultRecorded for all devices that
are Faulty, then after writing the metadata we clear Blocked for any
device for which the Fault was certainly Recorded.

The 'faulty' device flag now appears in sysfs if the device is faulty
*or* it has unacknowledged bad blocks.  So user-space which does not
understand bad blocks can continue to function correctly.
User space which does, should not assume a device is faulty until it
sees the 'faulty' flag, and then sees the list of unacknowledged bad
blocks is empty.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
</pre>
</div>
</content>
</entry>
</feed>
