From patchwork Mon Apr 1 03:25:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 15789 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 015E423DEA for ; Mon, 1 Apr 2013 03:29:51 +0000 (UTC) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by fiordland.canonical.com (Postfix) with ESMTP id AAF2AA19BDF for ; Mon, 1 Apr 2013 03:29:50 +0000 (UTC) Received: by mail-ve0-f169.google.com with SMTP id d10so2179299vea.0 for ; Sun, 31 Mar 2013 20:29:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:sender:date:from:to:cc:subject:message-id :references:mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent:x-gm-message-state; bh=fapa5PKQhWFujxnO7qzp4AAhXaEe1rVXCSScErWI9ms=; b=jwb+yk61JhWxBpQmPomLQMrsBz9qj9Dn2QXOk12labymfO4Mb5LWVDLDG68L34lqKu dRUXX4PMIELUQIFaoMqMpofUTWBPcbHZsOl8TtRGNxfW1B/my7S/e8wHsa34enLhyLPs SjiR7dXvwniWNqckBgKdyVVhzlRVZh81Jnb6CXXU0uo7GDChhSRVmNCm6mtaovGfDbA2 S42hVf5JeL6yqK4nhwO7Fw8g9rNGOv4NkL3o2lqlb2/XFTpk0ByVpOv93xW+vJ3sfDEP aVKZYwpwGuyYLROCgkse4JvnsoPvQkW1j+NznSzLMKhkMyRIWd04vOZgZjkXB3kx9Ctw WcBg== X-Received: by 10.52.233.225 with SMTP id tz1mr7020410vdc.54.1364786990187; Sun, 31 Mar 2013 20:29:50 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.59.4.204 with SMTP id cg12csp66079ved; Sun, 31 Mar 2013 20:29:49 -0700 (PDT) X-Received: by 10.66.49.202 with SMTP id w10mr16503043pan.174.1364786989177; Sun, 31 Mar 2013 20:29:49 -0700 (PDT) Received: from mail-da0-x233.google.com (mail-da0-x233.google.com [2607:f8b0:400e:c00::233]) by mx.google.com with ESMTPS id fd8si12301195pad.46.2013.03.31.20.29.48 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 31 Mar 2013 20:29:49 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400e:c00::233 is neither permitted nor denied by best guess record for domain of anton@scarybugs.org) client-ip=2607:f8b0:400e:c00::233; Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400e:c00::233 is neither permitted nor denied by best guess record for domain of anton@scarybugs.org) smtp.mail=anton@scarybugs.org Received: by mail-da0-f51.google.com with SMTP id g27so889254dan.38 for ; Sun, 31 Mar 2013 20:29:48 -0700 (PDT) X-Received: by 10.68.244.1 with SMTP id xc1mr15561320pbc.165.1364786988760; Sun, 31 Mar 2013 20:29:48 -0700 (PDT) Received: from localhost (c-98-234-113-125.hsd1.ca.comcast.net. [98.234.113.125]) by mx.google.com with ESMTPS id qa6sm11997904pbc.46.2013.03.31.20.29.47 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 31 Mar 2013 20:29:48 -0700 (PDT) Sender: Anton Vorontsov Date: Sun, 31 Mar 2013 20:25:48 -0700 From: Anton Vorontsov To: linux-kernel@vger.kernel.org Cc: Tony Luck , Kees Cook , Colin Cross , Arve =?utf-8?B?SGrDuG5uZXbDpWc=?= , John Stultz , linaro-kernel@lists.linaro.org, patches@linaro.org, kernel-team@android.com Subject: [PATCH 3/3] pstore/ram: Restore ecc information block Message-ID: <20130401032548.GC17424@lizard> References: <20130401032256.GA13801@lizard> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130401032256.GA13801@lizard> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQlRhKzjFDhD20JLsy/DKTNjc+vhexsVVxA5fKt3sz0+/xFOH0mcuEaL+8Cc9n3rM8ZYLPrZ From: Arve Hjønnevåg This was lost when proc/last_kmsg moved to pstore/console-ramoops. Signed-off-by: Arve Hjønnevåg Signed-off-by: John Stultz Signed-off-by: Anton Vorontsov --- fs/pstore/ram.c | 12 ++++++++++-- fs/pstore/ram_core.c | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index a5ee252..32cbd7c 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -136,6 +136,7 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type, char **buf, struct pstore_info *psi) { ssize_t size; + ssize_t ecc_notice_size; struct ramoops_context *cxt = psi->data; struct persistent_ram_zone *prz; @@ -156,11 +157,18 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type, time->tv_nsec = 0; size = persistent_ram_old_size(prz); - *buf = kmemdup(persistent_ram_old(prz), size, GFP_KERNEL); + + /* ECC correction notice */ + ecc_notice_size = persistent_ram_ecc_string(prz, NULL, 0); + + *buf = kmalloc(size + ecc_notice_size + 1, GFP_KERNEL); if (*buf == NULL) return -ENOMEM; - return size; + memcpy(*buf, persistent_ram_old(prz), size); + persistent_ram_ecc_string(prz, *buf + size, ecc_notice_size + 1); + + return size + ecc_notice_size; } static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz) diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c index c6f641c..5933732 100644 --- a/fs/pstore/ram_core.c +++ b/fs/pstore/ram_core.c @@ -235,6 +235,9 @@ ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz, { ssize_t ret; + if (!prz->ecc_info.ecc_size) + return 0; + if (prz->corrected_bytes || prz->bad_blocks) ret = snprintf(str, len, "" "\n%d Corrected bytes, %d unrecoverable blocks\n",