Commit Graph

71 Commits

Author SHA1 Message Date
pjd
4a6bed76ea Fix provider's size check for 'insert' command.
Before this fix one was able to insert one sector too small provider.

MFC after:	3 days
2005-04-25 10:41:26 +00:00
pjd
2fe06962aa Remove the hack which allowed to use gmirror for root file system,
use root_mount KPI instead.
2005-04-19 21:47:25 +00:00
pjd
65028f364f Make the code more obvious - when an error occurs in g_mirror_connect_disk(),
detach and destroy consumer before returning.
2005-03-26 17:23:01 +00:00
pjd
adbc064c96 Check for return values.
Submitted by:	sam
Found by:	Coverity Prevent analysis tool
2005-03-26 16:51:19 +00:00
pjd
18d61ee28a - Add md_provsize field to metadata, which will help with
shared-last-sector problem.
  After this change, even if there is more than one provider with the same
  last sector, the proper one will be chosen based on its size.
  It still doesn't fix the 'c' partition problem (when da0s1 can be confused
  with da0s1c) and situation when 'a' partition starts at offset 0
  (then da0s1a can be confused with da0s1 and da0s1c). One can use '-h'
  option there, when creating device or avoid sharing last sector.
  Actually, when providers share the same last sector and their size is equal,
  they provide exactly the same data, so the name (da0s1, da0s1a, da0s1c)
  isn't important at all.
- Provide backward compatibility.
- Update copyright's year.

MFC after:	1 week
2005-02-27 23:07:47 +00:00
pjd
9c7ddd23db Update copyright in files changed this year. 2005-02-16 22:14:52 +00:00
pjd
ffdea2b7ba Increase default synchronization speed.
MFC after: 3 days
2005-01-09 14:43:39 +00:00
pjd
46ef753dfc Spoiling is now not possible, because we keep consumers open for writing
all the time. Remove unused code then.

MFC after:	4 days
2005-01-04 12:11:49 +00:00
pjd
fa8519dd34 Fix 'rebuild' command (we ignore retaste event now, so don't relay on it). 2005-01-03 19:42:37 +00:00
jhb
4d789f1bcc Stop explicitly touching td_base_pri outside of the scheduler and simply
set a thread's priority via sched_prio() when that is the desired action.
The schedulers will start managing td_base_pri internally shortly.
2004-12-30 20:29:58 +00:00
pjd
36e0540d02 Update disk->d_genid field when increasing sc->sc_genid. 2004-12-23 21:15:15 +00:00
pjd
d3e546cde3 - Add genid field to the metadata which will allow to improve reliability a bit.
After this change, when component is disconnected because of an I/O error,
  it will not be connected and synchronized automatically, it will be logged
  as broken and skipped. Autosynchronization can occur, when component is
  disconnected (on orphan event) and connected again - there were no I/O
  error, so there is no need to not connected the component, but when there were
  writes while it wasn't connected, it will be synchronized.
  This fix cases, when component is disconnected because of I/O error and can be
  connected again and again.
- Bump version number.
- Add version change history.
- Implement backward compatibility mechanism. After this change when metadata in
  old version is detected, it is automatically upgraded to the new (current)
  version.
2004-12-22 23:09:32 +00:00
pjd
35c9063e5c Now, when force device destruction is done on shutdown, hide warning,
that device cannot be destroyed immediately, under debug=1.

Suggested by:	simon
2004-12-21 19:50:18 +00:00
pjd
cf9ab518ae This should not be permitted, but some GEOM classes held the topology lock
while doing g_(read|write)_data() (e.g. BSD). This can cause a deadlock
in MIRROR class. Not sure if this is safe to drop the topology lock in BSD
class, so change the code in MIRROR class to avoid this deadlock.
2004-12-21 18:42:51 +00:00
pjd
6dcac96172 Remove unused variables. 2004-12-19 23:55:49 +00:00
pjd
f91c4203d1 - Argument 'flags' in g_mirror_destroy_consumer() function is unsed -
mark it as such.
- Before closing consumer check if it is open. It can be closed here
  when g_mirror_connect_disk() fails on g_access().
2004-12-19 23:33:59 +00:00
pjd
fb782f2a8e Some major cleanups.
Keeping consumers open when device is closed is very hard. We need to
open consumers sometimes to update metadata, etc.
Many hacks was introduced in the past to made it possible. You cannot
be sure that you can open consumer for writing always, even if you think
it should be allowed. If one of the mirror components is for example da0
and you try to open it, you can get EPERM when da0s1 is opened for reading
(because BSD class opens consumers (da0) with an extra 'e' bit set).
Waiting for the events queue to be empty may do the trick, but it makes
code much uglier (as you cannot always call g_waitidle()), it doesn't
solve all edge cases and it can introduce deadlocks if there are events
in the queue that wait for gmirror.

I removed those hacks. Now all consumers are open r1w1e1 always, even if
device is closed. Maybe it is less clean from GEOM perspective, but simpify
code a lot and make it much more reliable.
The only issue was retaste event which is sent when we close consumers
opened for writing. I ignore retaste event by not detaching consumer
immediately (so retaste event is not send to my class) and sending event
right after it to detach and destroy consumer.
2004-12-19 23:12:00 +00:00
pjd
4f942b3e93 Don't quit on first failure, just skip failures. 2004-12-19 22:58:25 +00:00
pjd
f4f1a65a32 Before trying to update metadata (so open consumer for writing), be sure
that the events queue is empty. In other case we're able to hit the race
where for example da0s1 is tasted by some other class, which means that
da0 is open with exclusive bit set, which means that we can't open da0
for writing if it is our component.

Reported by:	Attila Nagy <bra@fsn.hu> (and somebody else sometime ago,
		                          but I cannot find who it was)
2004-11-09 23:27:21 +00:00
pjd
f84ab9080d Don't rely on DIRTY flag to be sure that consumer if open, because
DIRTY flag can be removed in idle process. Use consumer's acw field
instead to avoid opening consumer twice.
2004-11-09 23:15:40 +00:00
pjd
ab05b26be9 Drop Giant lock before grabbing the topology lock. 2004-11-09 00:35:08 +00:00
pjd
774c8e9301 If device is marked as beeing destroyed, deny all access requests. 2004-11-08 20:23:53 +00:00
pjd
250e9b1d6b Don't forget to make sure that there are no not-finished requests before
marking components as clean.

Pointed out by:	scottl
2004-11-05 17:18:39 +00:00
pjd
68654cd607 Use shutdown hooks to mark mirrors as clean after all file systems are
unmounted.

Suggested by:	scottl
2004-11-05 12:35:21 +00:00
pjd
1549c29ccb Remove unused #include. 2004-11-05 12:31:32 +00:00
pjd
672a23e8d8 - Add a sysctl kern.geom.mirror.idletime, so one can specify after how many
seconds of idling, DRITY flags are removed.
- If mirror is in idle state or is not open for writing, sleep without
  timeout when waiting for I/O requests.
- Don't use atomic operations, for now sysctls are protected by Giant.
- Update debugs.
2004-11-05 10:55:04 +00:00
pjd
3c548cd5e8 MFp4:
- Fix for good (I hope) force-stopping mirrors and some filure cases
  (e.g. the last good component dies when synchronization is in progress).
  Don't use ->nstart/->nend consumer's fields, as this could be racy,
  because those fields are used in g_down/g_up, use ->index consumer's
  field instead for tracking number of not finished requests.

  Reported by:	marcel

- After 5 seconds of idle time (this should be configurable) mark all
  dirty providers as clean, so when mirror is not used in 5 seconds
  and there will be power failure, no synchronization on boot is needed.

  Idea from:	sorry, I can't find who suggested this

- When there are no ACTIVE components and no NEW components destroy whole
  mirror, not only provider.

- Fix one debug to show information about I/O request, before we change
  its command.
2004-11-05 09:05:15 +00:00
pjd
0c38517975 Ehh. Introduce a hack: Wait for 3 seconds, so GEOM is able to give us
providers for tasting. Before this hack, race below is possible:
	SI_SUB_RAID (no not-fully-configured geoms, so don't block)
	GEOM tasting (now geoms are created)
	SI_SUB_MOUNT_ROOT (if root file system is placed on a mirror, it is
		possible that this mirror is not fully configured yet)
There is a lot of work to do to avoid such hacks and I need a working
solution before 5.3, sorry.

Reported by:	John Hay <jhay@icomtek.csir.co.za>
2004-10-14 07:55:29 +00:00
pjd
6da51fd1e6 Be sure to always return 0 for negative access requests.
Reported by:	Maciej Kucharz <qk@comp.waw.pl>
2004-10-07 20:13:23 +00:00
pjd
8fa69f9606 Geoms without softc are geoms which are initialized, so wait for them. 2004-10-06 18:47:15 +00:00
pjd
99ab51eea1 Look out for geoms without softc.
Reported by:	tegge
2004-10-06 14:15:47 +00:00
pjd
60eef69bf8 Before root file system is mounted, wait for mirrors in degraded state. 2004-10-05 11:17:08 +00:00
pjd
db55d5e5fa Just use MAXPHYS as maximum I/O request size, instead of using my own
#define for this purpose.
No functional change.
2004-09-28 07:33:37 +00:00
pjd
a7be71d74a Minor, but very important condition fix. The current one can never be true. 2004-09-27 19:32:26 +00:00
pjd
85dc8597f1 Decrease kern.geom.mirror.timeout to 4, so it is smaller than
vfs.root.mountdelay by default.
2004-09-27 13:47:37 +00:00
pjd
1bc5ff219b Forgot to commit addition of ds_resync field. 2004-09-26 20:42:35 +00:00
pjd
9f006019db Avoid race while synchronizing components. It is very hard to bump into,
but it is possible:
1. Read data from good component for synchronization.
2. Write data to the same area.
3. Write synchronization data, which are now stale.

Found by:	tegge
2004-09-26 20:41:07 +00:00
pjd
bd8d6d4575 Simplify code a bit. 2004-09-26 20:30:15 +00:00
pjd
3b78a0c3e7 This is not needed anymore, it is forced in GEOM now.
Actually, it can even cause some problems, because GEOM requires sectorsize
to be more than 0 on first access, not on provider creation, so we can skip
valid providers by doing this check here.

Reported by:	Divacky Roman <xdivac02@stud.fit.vutbr.cz>
		Sven Willenberger <sven@dmv.com>
2004-09-20 17:26:25 +00:00
pjd
af512db7ec Show current status of mirror device directly.
Suggested by:	Krzysztof Ciep³ucha <kris@home.pl>
2004-09-08 16:37:22 +00:00
pjd
48de94741d Allow to configure debug level from /boot/loader.conf. 2004-08-30 18:50:06 +00:00
pjd
bd7f4be14b GCC, ehh. 2004-08-29 14:29:30 +00:00
pjd
01b2d4305a Skip providers with not defined sector size.
Reported by:	kuriyama
2004-08-26 12:42:47 +00:00
pjd
c3c288bf08 Allow to set kern.geom.mirror.timeout from /boot/loader.conf. 2004-08-23 20:42:34 +00:00
pjd
89834287f1 We really don't want to receive spoil event for synchroniztion consumers. 2004-08-18 23:33:37 +00:00
pjd
dc6052fa45 Bump synchronization ID if we are sure, that we have ACTIVE components. 2004-08-18 07:28:48 +00:00
pjd
fe086dc9ba Avoid code duplication by introducing g_mirror_write_metadata() function,
which is used now by g_mirror_clear_metadata() function and
g_mirror_update_metadata() function.
2004-08-15 13:58:29 +00:00
pjd
bad883ba77 MFp4: Simplify code a bit:
- Remove kern.geom.mirror.sync_block_size sysctl. It is quite obvious that we
  want to use the biggest size possible.
- Do not use UMA zone for sync data allocations. There could be only one
  synchronization request per synchronized disk at a time, so allocate memory
  for one request on whole synchronization process related to one disk.

Tested by synchronizing one component (out of three) and by synchronizing
two components (out of three) in parallel.
2004-08-11 23:41:53 +00:00
pjd
152eff9f85 Actually, HARDCODED flag isn't stored in metadata, so don't bother
dumping it.
2004-08-11 22:16:42 +00:00
pjd
3e56d6e95f - Fix typo.
- Dump HARDCODED flag.
2004-08-11 22:12:44 +00:00