From nobody@FreeBSD.org  Tue May 12 16:09:35 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 18653106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 12 May 2009 16:09:35 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id E16228FC13
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 12 May 2009 16:09:34 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n4CG9Yrs098197
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 12 May 2009 16:09:34 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n4CG9Y1C098196;
	Tue, 12 May 2009 16:09:34 GMT
	(envelope-from nobody)
Message-Id: <200905121609.n4CG9Y1C098196@www.freebsd.org>
Date: Tue, 12 May 2009 16:09:34 GMT
From: Michel Bouissou <michel.bouissou@bioclinica.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ZFS: Hot spares are rather cold...
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         134491
>Category:       kern
>Synopsis:       [zfs] Hot spares are rather cold...
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-fs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 12 16:10:01 UTC 2009
>Closed-Date:    
>Last-Modified:  Sun Jan 19 11:00:00 UTC 2014
>Originator:     Michel Bouissou
>Release:        7.2
>Organization:
Bioclinica
>Environment:
>Description:
Although ZFS offers the possibility to define devices as "spares" for MIRROR / RAIDZ / RAIDZ2 storage pools, and FreeBSD will happily accept this, such "spare" devices will *NOT* automagically take over if a RAID pool device fails.

According to http://docs.sun.com/app/docs/doc/819-5461/gcvcw?a=view , I understand that the device replacement with a spare might not be performed by the kernel ZFS module but by an external agent/daemon ?
 Automatic replacement  When a fault is received, an FMA agent examines the pool to see if it has any available hot spares. If so, it replaces the faulted device with an available spare. 

I'm unable to find such a tool in FreeBSD, at least if it exists (?) it isn't active by default. So in the current status ZFS "spares" have to be activated / deactivated manually when a disk fails or is replaced.

Not only this is suboptimal but this presents a data loss risk for people who would assume that "spares" would just do what they are intended for in all usual RAID implementations... Where they won't and will just sit there idle if a disk dies, until the admin manually activates them.

This deserves preferably a fix, but at least a prominent WARNING note...

Also, although SUN doc states  Multiple pools can share devices that are designated as hot spares , in the current FreeBSD implementation ZFS will refuse to assign to a pool a "spare" which is already assigned to another, stating the device is "busy", i.e.:

# zpool status
  pool: syspool
 state: ONLINE
 (Blah-blah)

        NAME        STATE     READ WRITE CKSUM
        syspool     ONLINE       0     0     0
          mirror    ONLINE       0     0     0
            aacd1   ONLINE       0     0     0
            aacd2   ONLINE       0     0     0
        spares
          da15      AVAIL

(Blah-blah)

# zpool add vol01 spare da15
invalid vdev specification
use '-f' to override the following errors:
da15 is in use (r1w1e1)

# zpool add -f vol01 spare da15
invalid vdev specification
the following errors must be manually repaired:
da15 is in use (r1w1e1)
>How-To-Repeat:
Create any redundant ZFS storage pool with a spare device. Hot-remove (or manually "offline") an active device from the pool. The spare won't take over unless a manual "zpool replace <pool_name> <failed_device> <spare_device>" is issued.
>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue May 12 19:52:40 UTC 2009 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=134491 

From: Alex Keda <admin@lissyara.su>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/134491: [zfs] Hot spares are rather cold...
Date: Tue, 01 Dec 2009 00:11:55 +0300

 may be some zfs developers comment this?

From: daniel.subs@internode.on.net
To: <bug-followup@FreeBSD.org>, <michel.bouissou@bioclinica.com>
Cc:  
Subject: Re: kern/134491: [zfs] Hot spares are rather cold...
Date: Fri, 16 Apr 2010 08:52:47 +0900

 A partial/potential solution is described here:=20
 http://lists.freebsd.org/pipermail/freebsd-stable/2010-March/055686.html=20
 =20

From: Garrett Cooper <yanegomi@gmail.com>
To: bug-followup@FreeBSD.org, michel.bouissou@bioclinica.com
Cc:  
Subject: Re: kern/134491: [zfs] Hot spares are rather cold...
Date: Sun, 9 Oct 2011 12:20:09 -0700

     delphij and I have verified that this issue is resolved on the
 zfsd svn branch, but this hasn't been backported to CURRENT and
 contains a number of changes to geom, and a handful of changes to zfs.
 I'll leave it to the reader to determine where between geom and zfs
 things are getting hung up.
 Thanks,
 -Garrett

From: Miroslav Lachman <000.fbsd@quip.cz>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/134491: [zfs] Hot spares are rather cold...
Date: Sun, 11 Nov 2012 16:04:43 +0100

 Is this still that hard issue, which cannot be solved for 3 years, even 
 if there is possible zfsd solution in another branch?
 
 FreeBSD is used as ZFS storage more often, and many users are in false 
 feel they have hot spares configured and fully working.

From: Anton Sayetsky <vsjcfm@gmail.com>
To: bug-followup@freebsd.org, michel.bouissou@bioclinica.com
Cc:  
Subject: Re: kern/134491: [zfs] Hot spares are rather cold...
Date: Sun, 19 Jan 2014 12:52:03 +0200

 What is the purpose of ZFS spares on FreeBSD if they doesn't work at all?
 I cannot see any sense to use spare - I can just run "replace"
 subcommand, right?
>Unformatted:
