staticbool best_effort;
module_param(best_effort, bool, 0400);
MODULE_PARM_DESC(best_effort, "use best effort to write (i.e. do not require storage driver pstore support, default: off)");
/* * blkdev - the block device to use for pstore storage * See Documentation/admin-guide/pstore-blk.rst for details.
*/ staticchar blkdev[80] = CONFIG_PSTORE_BLK_BLKDEV;
module_param_string(blkdev, blkdev, 80, 0400);
MODULE_PARM_DESC(blkdev, "block device for pstore storage");
/* * All globals must only be accessed under the pstore_blk_lock * during the register/unregister functions.
*/ static DEFINE_MUTEX(pstore_blk_lock); staticstruct file *psblk_file; staticstruct pstore_device_info *pstore_device_info;
static ssize_t psblk_generic_blk_write(constchar *buf, size_t bytes,
loff_t pos)
{ /* Console/Ftrace backend may handle buffer until flush dirty zones */ if (in_interrupt() || irqs_disabled()) return -EBUSY; return kernel_write(psblk_file, buf, bytes, &pos);
}
/* * This takes its configuration only from the module parameters now.
*/ staticint __register_pstore_blk(struct pstore_device_info *dev, constchar *devpath)
{ int ret = -ENODEV;
lockdep_assert_held(&pstore_blk_lock);
psblk_file = filp_open(devpath, O_RDWR | O_DSYNC | O_NOATIME | O_EXCL, 0); if (IS_ERR(psblk_file)) {
ret = PTR_ERR(psblk_file);
pr_err("failed to open '%s': %d!\n", devpath, ret); goto err;
}
if (!S_ISBLK(file_inode(psblk_file)->i_mode)) {
pr_err("'%s' is not block device!\n", devpath); goto err_fput;
}
#ifndef MODULE staticconstchar devname[] = "/dev/pstore-blk"; static __init constchar *early_boot_devpath(constchar *initial_devname)
{ /* * During early boot the real root file system hasn't been * mounted yet, and no device nodes are present yet. Use the * same scheme to find the device that we use for mounting * the root file system.
*/
dev_t dev;
if (early_lookup_bdev(initial_devname, &dev)) {
pr_err("failed to resolve '%s'!\n", initial_devname); return initial_devname;
}
ret = __register_pstore_blk(best_effort_dev,
early_boot_devpath(blkdev)); if (ret)
kfree(best_effort_dev); else
pr_info("attached %s (%lu) (no dedicated panic_write!)\n",
blkdev, best_effort_dev->zone.total_size);
return ret;
}
staticvoid __exit __best_effort_exit(void)
{ /* * Currently, the only user of psblk_file is best_effort, so * we can assume that pstore_device_info is associated with it. * Once there are "real" blk devices, there will need to be a * dedicated pstore_blk_info, etc.
*/ if (psblk_file) { struct pstore_device_info *dev = pstore_device_info;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.