From: WeiXiong Liao <liaoweixiong@allwinnertech.com>
To: Kees Cook <keescook@chromium.org>
Cc: Rob Herring <robh@kernel.org>, Tony Luck <tony.luck@intel.com>,
Vignesh Raghavendra <vigneshr@ti.com>,
Jonathan Corbet <corbet@lwn.net>,
Richard Weinberger <richard@nod.at>,
Anton Vorontsov <anton@enomsg.org>,
linux-doc@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, Colin Cross <ccross@android.com>,
linux-mtd@lists.infradead.org,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH v3 02/11] pstore/blk: new support logger for block devices
Date: Fri, 8 May 2020 20:46:52 +0800 [thread overview]
Message-ID: <6dcadbb0-8720-7973-8b33-747ae0579567@allwinnertech.com> (raw)
In-Reply-To: <202005072301.57F73B61CC@keescook>
hi Kees Cook,
On 2020/5/8 PM 2:07, Kees Cook wrote:
> On Wed, Mar 25, 2020 at 04:54:57PM +0800, WeiXiong Liao wrote:
>> pstore/blk is similar to pstore/ram, but dump log to block device
>> rather than persistent ram.
>> [...]
>> +int psblk_register_blkdev(unsigned int major, psblk_panic_write_op panic_write)
>> +{
>> + struct block_device *bdev;
>> + struct psblk_device dev = {0};
>> + struct bdev_info *binfo;
>> + int ret = -ENODEV;
>> + void *holder = blkdev;
>> +
>> + binfo = psblk_get_bdev_info();
>> + if (IS_ERR(binfo))
>> + return PTR_ERR(binfo);
>> +
>> + /* only allow driver matching the @blkdev */
>> + if (!binfo->devt || MAJOR(binfo->devt) != major) {
>> + pr_debug("invalid major %u (expect %u)\n",
>> + major, MAJOR(binfo->devt));
>> + return -ENODEV;
>> + }
>> +
>> + /* hold bdev exclusively */
>> + bdev = psblk_get_bdev(holder);
>> + if (IS_ERR(bdev)) {
>> + pr_err("failed to open '%s'!\n", blkdev);
>> + return PTR_ERR(bdev);
>> + }
>> +
>> + /* psblk_bdev must be assigned before register to pstore/blk */
>> + psblk_bdev = bdev;
>> + blkdev_panic_write = panic_write;
>> +
>> + dev.total_size = psblk_bdev_size(bdev);
>> + dev.panic_write = panic_write ? psblk_blk_panic_write : NULL;
>> + dev.read = psblk_generic_blk_read;
>> + dev.write = psblk_generic_blk_write;
>> +
>> + ret = psblk_register_do(&dev);
>> + if (ret)
>> + goto err_put_bdev;
>> +
>> + pr_info("using '%s'\n", blkdev);
>> + return 0;
>> +
>> +err_put_bdev:
>> + psblk_bdev = NULL;
>> + blkdev_panic_write = NULL;
>> + psblk_put_bdev(bdev, holder);
>> + return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(psblk_register_blkdev);
>
> I've gotten this series refactored on top of current pstore, and I've
> been making various bikeshed changes to names, etc, and as I went to go
> start testing, I realized that nothing actually uses
> psblk_register_blkdev().
>
> It seems like it should be possible to just start using this on any
> block device of the user's choosing. I assume the idea is to allow for
> drivers to register panic_write handlers, but even without that, it'd be
> nice to just be able to test this with something like /dev/loop0.
>
Yes. psblk_register_blkdev() is there for block drivers to register
panic_write()
handlers. The panic_wrire() is used only when panic occurs. Not only the
panic
log, but also all data on dirty zones. I implement the panic_write() of mmc
and nand on the platform of Allwinner, but I think it is not ready to
submit to
community.
All other front-ends but dmesg for panic are available since pstore/blk
provides
the general write/read through IO stack. That's why /dev/loop0 seemed to
works well.
> What's your thinking on how this would happen? It seems like if
> pstore/blk uses pstore/zone, and mtdpstore uses pstore/blk, there should
> be a blkoops that uses pstore/blk too? I guess I need to learn a bit> more about how block device probing works so pstore/blk can notice
> devices as they're brought online, etc.
>
pstore/blk provides all user options and register function for device
drivers.
The mtdpstore is the implementation case using pstore/blk. How about
'mmc_pstore' for mmc and *_pstore for others block device?
I guess I need to learn more about how pstore/blk can notice devices too.
I think pstore/blk can be better if block device can do like mtd device that
not only notifies but also provides generic panic_write().
--
WeiXiong Liao
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2020-05-08 12:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-25 8:54 [PATCH v3 00/11] pstore: mtd: support crash log to block and mtd device WeiXiong Liao
2020-03-25 8:54 ` [PATCH v3 01/11] pstore/zone: a common layer to manage storage as zones WeiXiong Liao
2020-04-14 1:42 ` WeiXiong Liao
2020-03-25 8:54 ` [PATCH v3 02/11] pstore/blk: new support logger for block devices WeiXiong Liao
2020-05-08 6:07 ` Kees Cook
2020-05-08 12:46 ` WeiXiong Liao [this message]
2020-03-25 8:54 ` [PATCH v3 03/11] pstore/blk: respect for driver to pick pstore front-ends WeiXiong Liao
2020-03-25 8:54 ` [PATCH v3 04/11] pstore/blk: pstore/zone: support pmsg recorder WeiXiong Liao
2020-03-25 8:55 ` [PATCH v3 05/11] pstore/blk: blkoops: support console recorder WeiXiong Liao
2020-04-14 2:13 ` WeiXiong Liao
2020-03-25 8:55 ` [PATCH v3 06/11] pstore/blk: blkoops: support ftrace recorder WeiXiong Liao
2020-03-25 8:55 ` [PATCH v3 07/11] Documentation: create document for pstore/blk WeiXiong Liao
2020-03-25 8:55 ` [PATCH v3 08/11] pstore/zone: skip broken zone for MTD device WeiXiong Liao
2020-03-25 8:55 ` [PATCH v3 09/11] pstore/blk: a way to get user configure about pstore front-ends WeiXiong Liao
2020-03-25 8:55 ` [PATCH v3 10/11] pstore/zone: pstore/blk: support non-block devices WeiXiong Liao
2020-03-25 8:55 ` [PATCH v3 11/11] mtd: new support oops logger based on pstore/blk WeiXiong Liao
2020-05-07 19:45 ` [PATCH v3 00/11] pstore: mtd: support crash log to block and mtd device Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6dcadbb0-8720-7973-8b33-747ae0579567@allwinnertech.com \
--to=liaoweixiong@allwinnertech.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=anton@enomsg.org \
--cc=ccross@android.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=keescook@chromium.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=mchehab+samsung@kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=robh@kernel.org \
--cc=tony.luck@intel.com \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).