From patchwork Fri May 18 22:24:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 8818 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 29E0E23EB5 for ; Fri, 18 May 2012 22:25:50 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id D81F4A183D8 for ; Fri, 18 May 2012 22:25:49 +0000 (UTC) Received: by yenq6 with SMTP id q6so4104355yen.11 for ; Fri, 18 May 2012 15:25:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:date:from :to:cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent:x-gm-message-state; bh=Pt+yTtzjpFl0htMYkS5VqkhUfSEkspemU9CIdZTmeyQ=; b=Ldkz4nbkeWfLDJfI03hBREcKPh+6QZnZAx9gAfsBNowbDxgmELmCxC+drsR9paF7oS kDX87EluCIWrnnMA05g2OEyFo2ztNjW5ypvrBd+Ih+iDSUlaUxE66Yz9wmFNwnUd9vZb wtdqPcU9AVZL09QAWGZ9A2weomvS37e6uAWC+7zkSBweTNYMNLyVI84D2Ldkkp62BM0J qnrS9m+UlXhbL15elypsgFqd/bvWQbtuC2/UKQBaX1HO5ABgTwJ2cvwMJ+HmAwDlA1C9 EBG9ypXrkHnQORgqxAX9lq5Tki+t+hemOBxc6MKH93A8l9KNRqXUjpT2y1SPC5nD4JJr /cDA== Received: by 10.50.185.233 with SMTP id ff9mr1949602igc.57.1337379949164; Fri, 18 May 2012 15:25:49 -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.231.35.72 with SMTP id o8csp135231ibd; Fri, 18 May 2012 15:25:48 -0700 (PDT) Received: by 10.68.134.228 with SMTP id pn4mr42476486pbb.78.1337379948513; Fri, 18 May 2012 15:25:48 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id rb7si9097982pbc.289.2012.05.18.15.25.48 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 18 May 2012 15:25:48 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by mail-pz0-f50.google.com with SMTP id h15so5258074dan.37 for ; Fri, 18 May 2012 15:25:48 -0700 (PDT) Received: by 10.68.211.234 with SMTP id nf10mr43077675pbc.121.1337379948159; Fri, 18 May 2012 15:25:48 -0700 (PDT) Received: from localhost (c-71-204-165-222.hsd1.ca.comcast.net. [71.204.165.222]) by mx.google.com with ESMTPS id vg3sm14119943pbc.71.2012.05.18.15.25.45 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 18 May 2012 15:25:47 -0700 (PDT) Date: Fri, 18 May 2012 15:24:18 -0700 From: Anton Vorontsov To: Greg Kroah-Hartman , Kees Cook , Colin Cross , Tony Luck Cc: Arnd Bergmann , John Stultz , Shuah Khan , arve@android.com, Rebecca Schultz Zavin , Jesper Juhl , Randy Dunlap , Stephen Boyd , Thomas Meyer , Andrew Morton , Marco Stornelli , WANG Cong , linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, linaro-kernel@lists.linaro.org, patches@linaro.org, kernel-team@android.com Subject: [PATCH 02/14] pstore/ram: Should update old dmesg buffer before reading Message-ID: <20120518222418.GB23089@lizard> References: <20120518222314.GA9425@lizard> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120518222314.GA9425@lizard> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQkqF0I+IU6tjXgW09TCePV18uFZaNVEhcPwhunf/741nhccSZGw5yO0p1TtmfaENmHJnVxi Without the update, we'll only see the new dmesg buffer after the reboot, but previously we could see it right away. Making an oops visible in pstore filesystem before reboot is a somewhat dubious feature, but removing it wasn't an intentional change, so let's restore it for now. Signed-off-by: Anton Vorontsov --- fs/pstore/ram.c | 2 ++ fs/pstore/ram_core.c | 21 +++++++++++++++++++-- include/linux/pstore_ram.h | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 9123cce..3a7724b 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -106,6 +106,8 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type, time->tv_sec = 0; time->tv_nsec = 0; + /* Update old/shadowed buffer. */ + persistent_ram_copy_old(prz); size = persistent_ram_old_size(prz); *buf = kmalloc(size, GFP_KERNEL); if (*buf == NULL) diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c index 31f8d18..849a542 100644 --- a/fs/pstore/ram_core.c +++ b/fs/pstore/ram_core.c @@ -250,8 +250,7 @@ static void notrace persistent_ram_update(struct persistent_ram_zone *prz, persistent_ram_update_ecc(prz, start, count); } -static void __init -persistent_ram_save_old(struct persistent_ram_zone *prz) +static void persistent_ram_save_old(struct persistent_ram_zone *prz) { struct persistent_ram_buffer *buffer = prz->buffer; size_t size = buffer_size(prz); @@ -272,6 +271,24 @@ persistent_ram_save_old(struct persistent_ram_zone *prz) memcpy(prz->old_log + size - start, &buffer->data[0], start); } +void persistent_ram_copy_old(struct persistent_ram_zone *prz) +{ + struct persistent_ram_buffer *buffer = prz->buffer; + size_t size = buffer_size(prz); + size_t start = buffer_start(prz); + + if (!size) + return; + + if (!prz->old_log) { + persistent_ram_save_old(prz); + return; + } + prz->old_log_size = size; + memcpy(prz->old_log, &buffer->data[start], size - start); + memcpy(prz->old_log + size - start, &buffer->data[0], start); +} + int notrace persistent_ram_write(struct persistent_ram_zone *prz, const void *s, unsigned int count) { diff --git a/include/linux/pstore_ram.h b/include/linux/pstore_ram.h index 7ed7fd4..07d59b7 100644 --- a/include/linux/pstore_ram.h +++ b/include/linux/pstore_ram.h @@ -75,6 +75,7 @@ struct persistent_ram_zone *persistent_ram_init_ringbuffer(struct device *dev, int persistent_ram_write(struct persistent_ram_zone *prz, const void *s, unsigned int count); +void persistent_ram_copy_old(struct persistent_ram_zone *prz); size_t persistent_ram_old_size(struct persistent_ram_zone *prz); void *persistent_ram_old(struct persistent_ram_zone *prz); void persistent_ram_free_old(struct persistent_ram_zone *prz);