Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2534770imu; Thu, 17 Jan 2019 16:27:39 -0800 (PST) X-Google-Smtp-Source: ALg8bN4zdv895x3u9Sa8W0kaWRs0ymNgxf+Lwvyo/jMuWEjOeuRU4ZH4OrXDujZiyL2AqW+1FCtU X-Received: by 2002:a17:902:6b09:: with SMTP id o9mr17004845plk.208.1547771258973; Thu, 17 Jan 2019 16:27:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547771258; cv=none; d=google.com; s=arc-20160816; b=iR4bsbmB0bU1wvR3pWRQMJBcuv57Tk9FyPWDyMShGa4kOH48YghWHSBwKTgZWateo4 5b5PU1eXjz+/wW3yc6P3Jhnpqtj0FJMaQdPDjJ7IC6sgpjpLarHC9VCTaFydsSJwRx22 wx1QQzaFeXtCYtBeyVGM1nK1/OofvzSgc+oD8/tvGB1JFcrK1CcCLXcXKvWOEwFpzSy/ k0cHLV/ZHRr2SbaFjIIudtSJHwELuR78655sNn67sUFup6lfDC4LAK19er1gqpQcgH0+ HhbcAs9hRL5j1MYL9uWk28/Mdu9/t/0+W7GtNBtBsoNKhvxyzy8doyhwnHapzT2571TP 0oMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=62OxJKS1GUqnP0lfZQEqSZI1ytuOXouAQZ7DJcGC17o=; b=kqgVJBQK318S3a7xA+SYmkpgojtH+++VIT/sU3lcn80hLQVDTJwsWgJsP0auydOco3 WqMlftAC59ciMrpud9gfzeSoFMdGQAfOH0UNbXn9WqmGpR47gWCkNxKCTzEKaslpKb6z GBStsDU7xL+VYFse2YRSdoFQzRUsSB0Tti4OLcy2Zj8pt/Dk3/zlyLcdVQP/m/YNMcID G0q+hIaDn30yFCwKqe8c8uxW2MCbYAjQtiVeiSBY1zD++AkeQYs4vitRiV3G5SDw78yc 1WM+wBtBC/DGARogt1TpJQrgua9VkRSDNJi6QjU7ejx18JYvJ5SJpR9OLXIdNI7G5z0+ d1CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WOnLq1dS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v2si2813661plz.53.2019.01.17.16.27.22; Thu, 17 Jan 2019 16:27:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WOnLq1dS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726329AbfARAQD (ORCPT + 99 others); Thu, 17 Jan 2019 19:16:03 -0500 Received: from mail-vk1-f195.google.com ([209.85.221.195]:43688 "EHLO mail-vk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725938AbfARAQC (ORCPT ); Thu, 17 Jan 2019 19:16:02 -0500 Received: by mail-vk1-f195.google.com with SMTP id o130so2693249vke.10 for ; Thu, 17 Jan 2019 16:16:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=62OxJKS1GUqnP0lfZQEqSZI1ytuOXouAQZ7DJcGC17o=; b=WOnLq1dSIuQKUTS9G45AuEvhtX1JPiGC62PP7QHbwv1Z8ydJC+q6uPpyI6iCxf+rJq haAn7TmxKnvWUmnd/hhP8g6XzJFzJYIdgT9VAerS/+kPGpMu4Qvy2Veeiv70vBHgTPST ZZM3YEw+CnSB3O3DynCeJxp54p3f4zKW4+3rw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=62OxJKS1GUqnP0lfZQEqSZI1ytuOXouAQZ7DJcGC17o=; b=pJ1vKxjzxIYlW285vRnR15w4a8dWDf39fG7syYeAgjv09y99uk0B3Yer4oVKgqFBA8 frsmIbESqccY+cf/l4Nc6fB2rf1sXMGs6+U/maZ6vSb2phNsIAhcfIzcYE2oevlbfM4K YI+1YlQmaorg/4fwcLNE73FZui4b4FcSbtzFGw9KAmq3q5gCjn8z/sk6nw5X2TJmS4zU JCtNEHlYeRjkx38zcDbX7rJBfzYwSj3FwAl0NKBxCPhL2HluHf4IVkH+RxlEYn4KWK1N TFPzh+aZFxaakxTDzZT2q5oJ2G9pUsuPzwz7AGBrQghXZRr6yD/hBcuM4Vxp6X0CXruY PqTg== X-Gm-Message-State: AJcUukdcirqXapm7WMCmpe/oBKt1prpVEgIbz4UsQ8+yZlsrrfPgsAEh fadV8GfY6ebQTCGiF6yLf0nBqIO+BIQ= X-Received: by 2002:a1f:91cb:: with SMTP id t194mr6368507vkd.74.1547770561022; Thu, 17 Jan 2019 16:16:01 -0800 (PST) Received: from mail-vs1-f45.google.com (mail-vs1-f45.google.com. [209.85.217.45]) by smtp.gmail.com with ESMTPSA id w65sm8203430vsc.16.2019.01.17.16.15.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Jan 2019 16:15:59 -0800 (PST) Received: by mail-vs1-f45.google.com with SMTP id h78so7401160vsi.6 for ; Thu, 17 Jan 2019 16:15:59 -0800 (PST) X-Received: by 2002:a67:848a:: with SMTP id g132mr6650286vsd.222.1547770558450; Thu, 17 Jan 2019 16:15:58 -0800 (PST) MIME-Version: 1.0 References: <1546862462-19640-1-git-send-email-liaoweixiong@allwinnertech.com> <1546862462-19640-3-git-send-email-liaoweixiong@allwinnertech.com> In-Reply-To: <1546862462-19640-3-git-send-email-liaoweixiong@allwinnertech.com> From: Kees Cook Date: Thu, 17 Jan 2019 16:15:46 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC v5 2/4] pstore/blk: add sample for pstore_blk To: liaoweixiong Cc: Anton Vorontsov , Colin Cross , Tony Luck , Jonathan Corbet , Mauro Carvalho Chehab , Greg Kroah-Hartman , "David S. Miller" , Andrew Morton , Nicolas Ferre , Arnd Bergmann , "open list:DOCUMENTATION" , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 7, 2019 at 4:01 AM liaoweixiong wrote: > > It is a sample for pstore_blk, using general ram rather than block device. > According to pstore_blk, the data will be saved to ram buffer if not > register device path and apis for panic. So, it can only used to dump > Oops and some things will not reboot. I'm not sure I see the purpose of this implementation? Doesn't this just cause all the pstore machinery to skip any actions? i.e. without bzinfo->part_path, won't blkz_sample_write() just return -EINVAL, etc? > > Signed-off-by: liaoweixiong > --- > fs/pstore/Kconfig | 9 +++++++++ > fs/pstore/Makefile | 2 ++ > fs/pstore/blkbuf.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 57 insertions(+) > create mode 100644 fs/pstore/blkbuf.c > > diff --git a/fs/pstore/Kconfig b/fs/pstore/Kconfig > index a881c53..18b1fe6 100644 > --- a/fs/pstore/Kconfig > +++ b/fs/pstore/Kconfig > @@ -159,3 +159,12 @@ config PSTORE_BLK > help > This enables panic and oops message to be logged to a block dev > where it can be read back at some later point. > + > +config PSTORE_BLKBUF > + tristate "pstore block buffer sample" > + depends on PSTORE_BLK > + help > + This is a sample for pstore block, but do NOT have a block dev. > + According to pstore_blk, the data will be saved to ram buffer and > + dropped when reboot. So, it can only used to dump Oops and some > + things will not reboot. > diff --git a/fs/pstore/Makefile b/fs/pstore/Makefile > index c431700..4a6cde1 100644 > --- a/fs/pstore/Makefile > +++ b/fs/pstore/Makefile > @@ -15,3 +15,5 @@ obj-$(CONFIG_PSTORE_RAM) += ramoops.o > > obj-$(CONFIG_PSTORE_BLK) += pstore_blk.o > pstore_blk-y += blkzone.o > + > +obj-$(CONFIG_PSTORE_BLKBUF) += blkbuf.o > diff --git a/fs/pstore/blkbuf.c b/fs/pstore/blkbuf.c > new file mode 100644 > index 0000000..f1c6f57 > --- /dev/null > +++ b/fs/pstore/blkbuf.c > @@ -0,0 +1,46 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * > + * blkbuf.c: Block device Oops/Panic logger > + * > + * Copyright (C) 2019 liaoweixiong > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 as > + * published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + */ > +#define pr_fmt(fmt) "blkbuf: " fmt > + > +#include > +#include > +#include > + > +struct blkz_info blkbuf_info = { > + .owner = THIS_MODULE, > + .name = "blkbuf", > + .part_size = 512 * 1024, > + .dmesg_size = 64 * 1024, > + .dump_oops = true, > +}; > + > +static int __init blkbuf_init(void) > +{ > + return blkz_register(&blkbuf_info); > +} > +module_init(blkbuf_init); > + > +static void __exit blkbuf_exit(void) > +{ > + blkz_unregister(&blkbuf_info); > +} > +module_exit(blkbuf_exit); > + > +MODULE_LICENSE("GPL"); > +MODULE_AUTHOR("liaoweixiong "); > +MODULE_DESCRIPTION("Sample for Pstore BLK with Oops logger"); > -- > 1.9.1 > -- Kees Cook