Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4062797imu; Sat, 19 Jan 2019 01:24:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN5es+P1B6amSqBbHdmUooFpXu2S2m9Ct4yMFPrFNrbw2G8feA0AatK6aXAOYR2yTAZvMZeX X-Received: by 2002:a17:902:161:: with SMTP id 88mr22763766plb.306.1547889862188; Sat, 19 Jan 2019 01:24:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547889862; cv=none; d=google.com; s=arc-20160816; b=FnCJ/bcd4ZZpccVush39J85M0dBjkgbzns/57Y9JV18Fg4gHtKYR1n5jar798gG6rD CxA3MNazCO//XjrxlGIIDPby6ouWigwb7h9D7dgP6bIgWRkHaI9x7GpE1zKiArnBowOr atgZLLU0CHNEXA7lsPI1AkSbQn2PYN0QMonLZpA1JUr+2/1cs88WPzdwdTg7ITL2YtTF R1dBIk5qATuY1dbe7uf0tX9nS6r0a2FQS6zC1VlYmOlrGkn0oj+YzY/VtDnKaggKYuj/ DrmDtKZwv5Jv/a3JgpYw+6MxEVXy30QD+BZt4AEygCdxIGQYG8u4OkERPD+if+PKzz47 uljw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=4/KJep3ZV8/1uoA/8Qt7Tb16IUsgvgMlvBHYYq+23Uo=; b=DhYE864b3mjWOA6PRGFkWlvk40T8e1hEItNG9IQEFi6JiAnq7HKDVLxVv6ykHp61PS OyRhSZKsoD5CNKwAR2R3i4jOK0idb2Ou0ZCIDDiEQ6sP22rqfsAWw0WirMlRZHQYGYdQ qnAAeG/ijZxisVEC5mgIy6Lo7u+eSeR32FmMT1NGyuoaHAwJOxmblXcx5M8OYJGP8Bk4 +28irvUKlnGhClJJrx+eePPgQ1PyVFk4SPXDhIPsDGhXB1mrI55ylXVuMPCc2oU9T8Qw S91x+223vKBG8pP9cjK76QpeTUDY7fMjfMvraAOpFEoPceBd9ZhYVOKOYr/QLD1QqIhG rCag== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3si6340461pll.161.2019.01.19.01.23.52; Sat, 19 Jan 2019 01:24:22 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727709AbfASJUX (ORCPT + 99 others); Sat, 19 Jan 2019 04:20:23 -0500 Received: from smtp2207-205.mail.aliyun.com ([121.197.207.205]:38704 "EHLO smtp2207-205.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727644AbfASJUW (ORCPT ); Sat, 19 Jan 2019 04:20:22 -0500 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.07457527|-1;CH=green;FP=0|0|0|0|0|-1|-1|-1;HT=e01l07440;MF=liaoweixiong@allwinnertech.com;NM=1;PH=DS;RN=13;RT=13;SR=0;TI=SMTPD_---.DnpktYB_1547889617; Received: from 172.16.10.102(mailfrom:liaoweixiong@allwinnertech.com fp:SMTPD_---.DnpktYB_1547889617) by smtp.aliyun-inc.com(10.147.42.22); Sat, 19 Jan 2019 17:20:17 +0800 Subject: Re: [RFC v5 2/4] pstore/blk: add sample for pstore_blk To: Kees Cook 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 References: <1546862462-19640-1-git-send-email-liaoweixiong@allwinnertech.com> <1546862462-19640-3-git-send-email-liaoweixiong@allwinnertech.com> From: liaoweixiong Message-ID: <853df536-a86d-de14-47f4-244f60d9eceb@allwinnertech.com> Date: Sat, 19 Jan 2019 17:20:19 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-01-18 08:15, Kees Cook wrote: > 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? It just a sample for pstore_blk, which can used to record OOPS log on ram buffer. This module make it easier for device, without panic apis, to record oops log only. > i.e. without bzinfo->part_path, won't blkz_sample_write() just return -EINVAL, etc? Sure, blkz_sample_write (named blkz_default_general_write now) just return -EINVAL without bzinfo->part_path. How is the write path? It is blkoops_pstore_write->blkz_dmesg_write->blkz_zone_write->blkz_default_general_write. The blkz_zone_write will save the log to ram buffer even blkz_default_general_write return failure. >> >> 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 >> > >