Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pstore/blk: remove {un,}register_pstore_blk

This interface is entirely unused, so remove them and various bits of
unreachable code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20201016132047.3068029-4-hch@lst.de

authored by

Christoph Hellwig and committed by
Kees Cook
b6f8ed33 45a8af44

+11 -119
+1 -4
Documentation/admin-guide/pstore-blk.rst
··· 151 151 Configurations for driver 152 152 ------------------------- 153 153 154 - Only a block device driver cares about these configurations. A block device 155 - driver uses ``register_pstore_blk`` to register to pstore/blk. 156 - 157 - A non-block device driver uses ``register_pstore_device`` with 154 + A device driver uses ``register_pstore_device`` with 158 155 ``struct pstore_device_info`` to register to pstore/blk. 159 156 160 157 .. kernel-doc:: fs/pstore/blk.c
+10 -73
fs/pstore/blk.c
··· 90 90 static DEFINE_MUTEX(pstore_blk_lock); 91 91 static struct block_device *psblk_bdev; 92 92 static struct pstore_zone_info *pstore_zone_info; 93 - static pstore_blk_panic_write_op blkdev_panic_write; 94 93 95 94 struct bdev_info { 96 95 dev_t devt; ··· 340 341 return ret; 341 342 } 342 343 343 - static ssize_t psblk_blk_panic_write(const char *buf, size_t size, 344 - loff_t off) 345 - { 346 - int ret; 347 - 348 - if (!blkdev_panic_write) 349 - return -EOPNOTSUPP; 350 - 351 - /* size and off must align to SECTOR_SIZE for block device */ 352 - ret = blkdev_panic_write(buf, off >> SECTOR_SHIFT, 353 - size >> SECTOR_SHIFT); 354 - /* try next zone */ 355 - if (ret == -ENOMSG) 356 - return ret; 357 - return ret ? -EIO : size; 358 - } 359 - 360 - static int __register_pstore_blk(struct pstore_blk_info *info) 344 + /* 345 + * This takes its configuration only from the module parameters now. 346 + * See psblk_get_bdev() and blkdev. 347 + */ 348 + static int __register_pstore_blk(void) 361 349 { 362 350 char bdev_name[BDEVNAME_SIZE]; 363 351 struct block_device *bdev; ··· 364 378 } 365 379 366 380 /* only allow driver matching the @blkdev */ 367 - if (!binfo.devt || (!best_effort && 368 - MAJOR(binfo.devt) != info->major)) { 369 - pr_debug("invalid major %u (expect %u)\n", 370 - info->major, MAJOR(binfo.devt)); 381 + if (!binfo.devt) { 382 + pr_debug("no major\n"); 371 383 ret = -ENODEV; 372 384 goto err_put_bdev; 373 385 } 374 386 375 387 /* psblk_bdev must be assigned before register to pstore/blk */ 376 388 psblk_bdev = bdev; 377 - blkdev_panic_write = info->panic_write; 378 - 379 - /* Copy back block device details. */ 380 - info->devt = binfo.devt; 381 - info->nr_sects = binfo.nr_sects; 382 - info->start_sect = binfo.start_sect; 383 389 384 390 memset(&dev, 0, sizeof(dev)); 385 - dev.total_size = info->nr_sects << SECTOR_SHIFT; 386 - dev.flags = info->flags; 391 + dev.total_size = binfo.nr_sects << SECTOR_SHIFT; 387 392 dev.read = psblk_generic_blk_read; 388 393 dev.write = psblk_generic_blk_write; 389 - dev.erase = NULL; 390 - dev.panic_write = info->panic_write ? psblk_blk_panic_write : NULL; 391 394 392 395 ret = __register_pstore_device(&dev); 393 396 if (ret) 394 397 goto err_put_bdev; 395 398 396 399 bdevname(bdev, bdev_name); 397 - pr_info("attached %s%s\n", bdev_name, 398 - info->panic_write ? "" : " (no dedicated panic_write!)"); 400 + pr_info("attached %s (no dedicated panic_write!)\n", bdev_name); 399 401 return 0; 400 402 401 403 err_put_bdev: 402 404 psblk_bdev = NULL; 403 - blkdev_panic_write = NULL; 404 405 psblk_put_bdev(bdev, holder); 405 406 return ret; 406 407 } 407 - 408 - /** 409 - * register_pstore_blk() - register block device to pstore/blk 410 - * 411 - * @info: details on the desired block device interface 412 - * 413 - * Return: 414 - * * 0 - OK 415 - * * Others - something error. 416 - */ 417 - int register_pstore_blk(struct pstore_blk_info *info) 418 - { 419 - int ret; 420 - 421 - mutex_lock(&pstore_blk_lock); 422 - ret = __register_pstore_blk(info); 423 - mutex_unlock(&pstore_blk_lock); 424 - 425 - return ret; 426 - } 427 - EXPORT_SYMBOL_GPL(register_pstore_blk); 428 408 429 409 static void __unregister_pstore_blk(unsigned int major) 430 410 { ··· 401 449 if (psblk_bdev && MAJOR(psblk_bdev->bd_dev) == major) { 402 450 __unregister_pstore_device(&dev); 403 451 psblk_put_bdev(psblk_bdev, holder); 404 - blkdev_panic_write = NULL; 405 452 psblk_bdev = NULL; 406 453 } 407 454 } 408 - 409 - /** 410 - * unregister_pstore_blk() - unregister block device from pstore/blk 411 - * 412 - * @major: the major device number of device 413 - */ 414 - void unregister_pstore_blk(unsigned int major) 415 - { 416 - mutex_lock(&pstore_blk_lock); 417 - __unregister_pstore_blk(major); 418 - mutex_unlock(&pstore_blk_lock); 419 - } 420 - EXPORT_SYMBOL_GPL(unregister_pstore_blk); 421 455 422 456 /* get information of pstore/blk */ 423 457 int pstore_blk_get_config(struct pstore_blk_config *info) ··· 421 483 422 484 static int __init pstore_blk_init(void) 423 485 { 424 - struct pstore_blk_info info = { }; 425 486 int ret = 0; 426 487 427 488 mutex_lock(&pstore_blk_lock); 428 489 if (!pstore_zone_info && best_effort && blkdev[0]) 429 - ret = __register_pstore_blk(&info); 490 + ret = __register_pstore_blk(); 430 491 mutex_unlock(&pstore_blk_lock); 431 492 432 493 return ret;
-42
include/linux/pstore_blk.h
··· 8 8 #include <linux/pstore_zone.h> 9 9 10 10 /** 11 - * typedef pstore_blk_panic_write_op - panic write operation to block device 12 - * 13 - * @buf: the data to write 14 - * @start_sect: start sector to block device 15 - * @sects: sectors count on buf 16 - * 17 - * Return: On success, zero should be returned. Others excluding -ENOMSG 18 - * mean error. -ENOMSG means to try next zone. 19 - * 20 - * Panic write to block device must be aligned to SECTOR_SIZE. 21 - */ 22 - typedef int (*pstore_blk_panic_write_op)(const char *buf, sector_t start_sect, 23 - sector_t sects); 24 - 25 - /** 26 - * struct pstore_blk_info - pstore/blk registration details 27 - * 28 - * @major: Which major device number to support with pstore/blk 29 - * @flags: The supported PSTORE_FLAGS_* from linux/pstore.h. 30 - * @panic_write:The write operation only used for the panic case. 31 - * This can be NULL, but is recommended to avoid losing 32 - * crash data if the kernel's IO path or work queues are 33 - * broken during a panic. 34 - * @devt: The dev_t that pstore/blk has attached to. 35 - * @nr_sects: Number of sectors on @devt. 36 - * @start_sect: Starting sector on @devt. 37 - */ 38 - struct pstore_blk_info { 39 - unsigned int major; 40 - unsigned int flags; 41 - pstore_blk_panic_write_op panic_write; 42 - 43 - /* Filled in by pstore/blk after registration. */ 44 - dev_t devt; 45 - sector_t nr_sects; 46 - sector_t start_sect; 47 - }; 48 - 49 - int register_pstore_blk(struct pstore_blk_info *info); 50 - void unregister_pstore_blk(unsigned int major); 51 - 52 - /** 53 11 * struct pstore_device_info - back-end pstore/blk driver structure. 54 12 * 55 13 * @total_size: The total size in bytes pstore/blk can use. It must be greater