From patchwork Sat Dec 5 14:13:52 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Dongyang X-Patchwork-Id: 65048 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nB5EDkib021593 for ; Sat, 5 Dec 2009 14:13:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755106AbZLEONa (ORCPT ); Sat, 5 Dec 2009 09:13:30 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754969AbZLEONa (ORCPT ); Sat, 5 Dec 2009 09:13:30 -0500 Received: from mail-yx0-f187.google.com ([209.85.210.187]:42406 "EHLO mail-yx0-f187.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754654AbZLEON3 (ORCPT ); Sat, 5 Dec 2009 09:13:29 -0500 Received: by yxe17 with SMTP id 17so2816567yxe.33 for ; Sat, 05 Dec 2009 06:13:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=6SDeWd26tQbjK+Hx0ivssvVEbceudd9ewt3WcEm/uMU=; b=oxHrLLma7i6i+sZZ7pszTPjKB3rpbwgIQur8ZqklkSS+zqe2d3aWGOB0FudN8Kz8vA +Gero/r7bzgoSczVgpC6JnUNRsKkzZVb0y9kv4Gd+NoIDqL6kuJY6fbo5DxkQm/Nr/4E /VVQUlMo9SLUrJQ3tQQ/SNNzWtLQogvK4ZIOE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=XYykxa8PVdgzK+Qd/45RWo9cNnfIVNICM2xuZ+EHon2VWXTUC37YOsm7H8otCxmL4r WVTuTP5kgk3a+4guHv7kiVX+H1eLd8comQVsKoMaAJDKsIB7WcAL3g3JTjlOcfrLNeS7 oTz3qrgUR8UkeA8iWixsKnKNk4JxAXCKuEgS0= Received: by 10.150.129.25 with SMTP id b25mr7495304ybd.308.1260022415024; Sat, 05 Dec 2009 06:13:35 -0800 (PST) Received: from localhost ([123.122.91.227]) by mx.google.com with ESMTPS id 7sm1487953ywc.51.2009.12.05.06.13.32 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 05 Dec 2009 06:13:34 -0800 (PST) Date: Sat, 5 Dec 2009 22:13:52 +0800 From: Li Dongyang To: linux-btrfs@vger.kernel.org Cc: chris.mason@oracle.com Subject: [PATCH]btrfs: don't remove device on a raid0 array when device number is 2 Message-ID: <20091205141352.GA8277@Archlinux> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 20cbd2e..801b8d0 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1150,6 +1150,14 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) goto out; } + if ((all_avail & BTRFS_BLOCK_GROUP_RAID0) && + root->fs_info->fs_devices->rw_devices <= 2) { + printk(KERN_ERR "btrfs: unable to go below two " + "devices on raid0\n"); + ret = -EINVAL; + goto out; + } + if (strcmp(device_path, "missing") == 0) { struct list_head *devices; struct btrfs_device *tmp;