From owner-freebsd-fs@FreeBSD.ORG Mon Dec 14 22:43:25 2009 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7442E106568D; Mon, 14 Dec 2009 22:43:25 +0000 (UTC) (envelope-from mattjreimer@gmail.com) Received: from mail-gx0-f218.google.com (mail-gx0-f218.google.com [209.85.217.218]) by mx1.freebsd.org (Postfix) with ESMTP id 1E45B8FC0C; Mon, 14 Dec 2009 22:43:24 +0000 (UTC) Received: by gxk10 with SMTP id 10so3488889gxk.3 for ; Mon, 14 Dec 2009 14:43:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:cc:content-type; bh=JK2crlEySHKpVtSAqAtn3NbktNUrvtsLoM744dTGqoA=; b=gedjIzB87oUzkyynR6bA08joYnTh/nLT6hZH9tmoztlUhbJf+FOq1MwgKpzf0B7euZ WW6sAIkTufr2ytoETQYWfUALSAZIt0OzqXRyoOX5vpcO3FDr0Z7cJqCWMcEQhAWCpmsm y5N6LhAmiFpdkJ9tuGa4jBh3TxDUSyvOlRSkI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=k5A32xU3jat6mXsdHsB5jZuz7cjXyArs3z4nOrfTBotkM4QH4AyS8/enqv1mgOUkw5 q+27kBY6ZpZkCTEOkMvpgnZzUZp0vjpcYzy88sj9od//CHgNtIwj3wH36OthQHtpVcw9 VdPBtUAv2hbkaruRCtlhYuH7EOHIQgDzuUVmU= MIME-Version: 1.0 Received: by 10.150.117.3 with SMTP id p3mr8238515ybc.287.1260830604382; Mon, 14 Dec 2009 14:43:24 -0800 (PST) Date: Mon, 14 Dec 2009 14:43:24 -0800 Message-ID: From: Matt Reimer To: freebsd-fs Content-Type: multipart/mixed; boundary=000e0cd72a504bd44d047ab800e3 Cc: Pawel Jakub Dawidek Subject: PATCH: more efficient raidz memory usage for (gpt)zfsboot X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Dec 2009 22:43:25 -0000 --000e0cd72a504bd44d047ab800e3 Content-Type: text/plain; charset=ISO-8859-1 Teach the (gpt)zfsboot and zfsloader raidz code to use its buffers more efficiently. Before this patch, in the worst case memory use would increase exponentially on the number of drives in the raidz vdev. Sponsored by: VPOP Technologies, Inc. Matt Reimer --000e0cd72a504bd44d047ab800e3 Content-Type: application/octet-stream; name="raidz-mem.patch" Content-Disposition: attachment; filename="raidz-mem.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_g37tvwgu0 LS0tIC9zeXMvY2RkbC9ib290L3pmcy96ZnNzdWJyLmMuT1JJRwkyMDA5LTExLTE0IDA4OjE0OjUx LjAwMDAwMDAwMCAtMDgwMAorKysgL3N5cy9jZGRsL2Jvb3QvemZzL3pmc3N1YnIuYwkyMDA5LTEy LTA3IDE1OjI3OjQ5LjAwMDAwMDAwMCAtMDgwMApAQCAtNDU0LDcgKzQ1NCw3IEBACiAKIHN0YXRp YyB2b2lkCiB2ZGV2X3JhaWR6X3JlY29uc3RydWN0X3BxKHJhaWR6X2NvbF90ICpjb2xzLCBpbnQg bnBhcml0eSwgaW50IGFjb2xzLAotICAgIGludCB4LCBpbnQgeSkKKyAgICBpbnQgeCwgaW50IHks IHZvaWQgKnRlbXBfcCwgdm9pZCAqdGVtcF9xKQogewogCXVpbnQ4X3QgKnAsICpxLCAqcHh5LCAq cXh5LCAqeGQsICp5ZCwgdG1wLCBhLCBiLCBhZXhwLCBiZXhwOwogCXZvaWQgKnBkYXRhLCAqcWRh dGE7CkBAIC00NzgsMTAgKzQ3OCw4IEBACiAJeHNpemUgPSBjb2xzW3hdLnJjX3NpemU7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