All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v7 00/18] pstore: mtd: support crash log to block and mtd device
@ 2020-05-10 20:24 ` Kees Cook
  0 siblings, 0 replies; 75+ messages in thread
From: Kees Cook @ 2020-05-10 20:24 UTC (permalink / raw)
  To: WeiXiong Liao
  Cc: Kees Cook, Anton Vorontsov, Colin Cross, Tony Luck,
	Jonathan Corbet, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Petr Mladek, Sergey Senozhatsky,
	Steven Rostedt, Rob Herring, Pavel Tatashin, linux-doc,
	linux-kernel, linux-mtd

Hi!

Well, I guess I spoke too soon. :) Here is v7. Hopefully this is
it. WeiXiong, can you test this and make sure you're happy with the
results?

Take care!

-Kees

v7:
- more renamings in the exported APIs and structs
- fix mtd build
- replace psblk_blkdev_info with passing in a struct to fill
- consolidate bdev opening/checking
- rename psblk_device -> pstore_device_info
- kerndoc for pstore_blk_get_config
- fix hunks in wrong patch
- add missing "static"s for local functions (0day)

v6: https://lore.kernel.org/lkml/20200509234103.46544-1-keescook@chromium.org/
v5: https://lore.kernel.org/lkml/1589022854-19821-1-git-send-email-liaoweixiong@allwinnertech.com/
v4: https://lore.kernel.org/lkml/20200508064004.57898-1-keescook@chromium.org/
v3: https://lore.kernel.org/lkml/1585126506-18635-1-git-send-email-liaoweixiong@allwinnertech.com/
v2: https://lore.kernel.org/lkml/1581078355-19647-1-git-send-email-liaoweixiong@allwinnertech.com/
v1: https://lore.kernel.org/lkml/1579482233-2672-1-git-send-email-liaoweixiong@allwinnertech.com/


Kees Cook (8):
  pstore/ram: Move dump_oops to end of module_param list
  pstore/platform: Switch pstore_info::name to const
  pstore/platform: Move module params after declarations
  pstore/platform: Use backend name for console registration
  pstore/ram: Refactor ftrace buffer merging
  pstore/ftrace: Provide ftrace log merging routine
  printk: Introduce kmsg_dump_reason_str()
  pstore/blk: Introduce "best_effort" mode

WeiXiong Liao (10):
  pstore/zone: Introduce common layer to manage storage zones
  pstore/blk: Introduce backend for block devices
  pstore/zone,blk: Add support for pmsg frontend
  pstore/zone,blk: Add console frontend support
  pstore/zone,blk: Add ftrace frontend support
  Documentation: Add details for pstore/blk
  pstore/zone: Provide way to skip "broken" zone for MTD devices
  pstore/blk: Provide way to query pstore configuration
  pstore/blk: Support non-block storage devices
  mtd: Support kmsg dumper based on pstore/blk

 Documentation/admin-guide/pstore-blk.rst |  243 ++++
 MAINTAINERS                              |    1 +
 drivers/mtd/Kconfig                      |   10 +
 drivers/mtd/Makefile                     |    1 +
 drivers/mtd/mtdpstore.c                  |  564 +++++++++
 fs/pstore/Kconfig                        |  109 ++
 fs/pstore/Makefile                       |    6 +
 fs/pstore/blk.c                          |  520 ++++++++
 fs/pstore/ftrace.c                       |   54 +
 fs/pstore/internal.h                     |    9 +
 fs/pstore/platform.c                     |   40 +-
 fs/pstore/ram.c                          |   70 +-
 fs/pstore/zone.c                         | 1463 ++++++++++++++++++++++
 include/linux/kmsg_dump.h                |    7 +
 include/linux/pstore.h                   |    2 +-
 include/linux/pstore_blk.h               |  118 ++
 include/linux/pstore_zone.h              |   60 +
 kernel/printk/printk.c                   |   21 +
 18 files changed, 3210 insertions(+), 88 deletions(-)
 create mode 100644 Documentation/admin-guide/pstore-blk.rst
 create mode 100644 drivers/mtd/mtdpstore.c
 create mode 100644 fs/pstore/blk.c
 create mode 100644 fs/pstore/zone.c
 create mode 100644 include/linux/pstore_blk.h
 create mode 100644 include/linux/pstore_zone.h

-- 
2.20.1


^ permalink raw reply	[flat|nested] 75+ messages in thread
* Re: [PATCH v7 09/18] pstore/blk: Introduce backend for block devices
@ 2020-05-10 22:14 kbuild test robot
  0 siblings, 0 replies; 75+ messages in thread
From: kbuild test robot @ 2020-05-10 22:14 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 18554 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20200510202436.63222-10-keescook@chromium.org>
References: <20200510202436.63222-10-keescook@chromium.org>
TO: Kees Cook <keescook@chromium.org>

Hi Kees,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on next-20200508]
[cannot apply to kees/for-next/pstore ia64/next linus/master v5.7-rc4 v5.7-rc3 v5.7-rc2 v5.7-rc4]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Kees-Cook/pstore-mtd-support-crash-log-to-block-and-mtd-device/20200511-043555
base:    30e2206e11ce27ae910cc0dab21472429e400a87
:::::: branch date: 2 hours ago
:::::: commit date: 2 hours ago

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>


cppcheck warnings: (new ones prefixed by >>)

>> fs/pstore/ram.c:927:19: warning: Variable 'pdata.max_reason' is reassigned a value before the old one has been used. [redundantAssignment]
    pdata.max_reason = ramoops_max_reason;
                     ^
   fs/pstore/ram.c:925:20: note: pdata.max_reason is assigned
     pdata.max_reason = ramoops_dump_oops ? KMSG_DUMP_OOPS
                      ^
   fs/pstore/ram.c:927:19: note: pdata.max_reason is overwritten
    pdata.max_reason = ramoops_max_reason;
                     ^
--
>> fs/pstore/zone.c:433:6: warning: Redundant initialization for 'ret'. The initialized value is overwritten before it is read. [redundantInitialization]
    ret = psz_kmsg_recover(cxt);
        ^
   fs/pstore/zone.c:428:10: note: ret is initialized
    int ret = -EBUSY;
            ^
   fs/pstore/zone.c:433:6: note: ret is overwritten
    ret = psz_kmsg_recover(cxt);
        ^
>> fs/pstore/zone.c:895:6: warning: Redundant initialization for 'err'. The initialized value is overwritten before it is read. [redundantInitialization]
    err = psz_alloc_zones(cxt);
        ^
   fs/pstore/zone.c:839:10: note: err is initialized
    int err = -EINVAL;
            ^
   fs/pstore/zone.c:895:6: note: err is overwritten
    err = psz_alloc_zones(cxt);
        ^
>> fs/pstore/blk.c:193:7: warning: Redundant initialization for 'bdev'. The initialized value is overwritten before it is read. [redundantInitialization]
    bdev = blkdev_get_by_path(blkdev, mode, holder);
         ^
   fs/pstore/blk.c:178:28: note: bdev is initialized
    struct block_device *bdev = ERR_PTR(-ENODEV);
                              ^
   fs/pstore/blk.c:193:7: note: bdev is overwritten
    bdev = blkdev_get_by_path(blkdev, mode, holder);
         ^
>> fs/pstore/blk.c:359:6: warning: Redundant initialization for 'ret'. The initialized value is overwritten before it is read. [redundantInitialization]
    ret = psblk_register_do(&dev);
        ^
   fs/pstore/blk.c:321:10: note: ret is initialized
    int ret = -ENODEV;
            ^
   fs/pstore/blk.c:359:6: note: ret is overwritten
    ret = psblk_register_do(&dev);
        ^

# https://github.com/0day-ci/linux/commit/1fe49524a73cc357622236b617f4ccf861dde190
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 1fe49524a73cc357622236b617f4ccf861dde190
vim +/bdev +193 fs/pstore/blk.c

1fe49524a73cc3 WeiXiong Liao 2020-05-10  164  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  165  /**
1fe49524a73cc3 WeiXiong Liao 2020-05-10  166   * psblk_get_bdev() - open block device
1fe49524a73cc3 WeiXiong Liao 2020-05-10  167   *
1fe49524a73cc3 WeiXiong Liao 2020-05-10  168   * @holder:	Exclusive holder identifier
1fe49524a73cc3 WeiXiong Liao 2020-05-10  169   * @info:	Information about bdev to fill in
1fe49524a73cc3 WeiXiong Liao 2020-05-10  170   *
1fe49524a73cc3 WeiXiong Liao 2020-05-10  171   * Return: pointer to block device on success and others on error.
1fe49524a73cc3 WeiXiong Liao 2020-05-10  172   *
1fe49524a73cc3 WeiXiong Liao 2020-05-10  173   * On success, the returned block_device has reference count of one.
1fe49524a73cc3 WeiXiong Liao 2020-05-10  174   */
1fe49524a73cc3 WeiXiong Liao 2020-05-10  175  static struct block_device *psblk_get_bdev(void *holder,
1fe49524a73cc3 WeiXiong Liao 2020-05-10  176  					   struct bdev_info *info)
1fe49524a73cc3 WeiXiong Liao 2020-05-10  177  {
1fe49524a73cc3 WeiXiong Liao 2020-05-10  178  	struct block_device *bdev = ERR_PTR(-ENODEV);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  179  	fmode_t mode = FMODE_READ | FMODE_WRITE;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  180  	sector_t nr_sects;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  181  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  182  	if (WARN_ON(!mutex_is_locked(&pstore_blk_lock)))
1fe49524a73cc3 WeiXiong Liao 2020-05-10  183  		return ERR_PTR(-EINVAL);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  184  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  185  	if (pstore_zone_info)
1fe49524a73cc3 WeiXiong Liao 2020-05-10  186  		return ERR_PTR(-EBUSY);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  187  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  188  	if (!blkdev[0])
1fe49524a73cc3 WeiXiong Liao 2020-05-10  189  		return ERR_PTR(-ENODEV);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  190  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  191  	if (holder)
1fe49524a73cc3 WeiXiong Liao 2020-05-10  192  		mode |= FMODE_EXCL;
1fe49524a73cc3 WeiXiong Liao 2020-05-10 @193  	bdev = blkdev_get_by_path(blkdev, mode, holder);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  194  	if (IS_ERR(bdev)) {
1fe49524a73cc3 WeiXiong Liao 2020-05-10  195  		dev_t devt;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  196  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  197  		devt = name_to_dev_t(blkdev);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  198  		if (devt == 0)
1fe49524a73cc3 WeiXiong Liao 2020-05-10  199  			return ERR_PTR(-ENODEV);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  200  		bdev = blkdev_get_by_dev(devt, mode, holder);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  201  	}
1fe49524a73cc3 WeiXiong Liao 2020-05-10  202  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  203  	nr_sects = part_nr_sects_read(bdev->bd_part);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  204  	if (!nr_sects) {
1fe49524a73cc3 WeiXiong Liao 2020-05-10  205  		pr_err("not enough space for '%s'\n", blkdev);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  206  		blkdev_put(bdev, mode);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  207  		return ERR_PTR(-ENOSPC);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  208  	}
1fe49524a73cc3 WeiXiong Liao 2020-05-10  209  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  210  	if (info) {
1fe49524a73cc3 WeiXiong Liao 2020-05-10  211  		info->devt = bdev->bd_dev;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  212  		info->nr_sects = nr_sects;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  213  		info->start_sect = get_start_sect(bdev);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  214  	}
1fe49524a73cc3 WeiXiong Liao 2020-05-10  215  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  216  	return bdev;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  217  }
1fe49524a73cc3 WeiXiong Liao 2020-05-10  218  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  219  static void psblk_put_bdev(struct block_device *bdev, void *holder)
1fe49524a73cc3 WeiXiong Liao 2020-05-10  220  {
1fe49524a73cc3 WeiXiong Liao 2020-05-10  221  	fmode_t mode = FMODE_READ | FMODE_WRITE;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  222  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  223  	if (!bdev)
1fe49524a73cc3 WeiXiong Liao 2020-05-10  224  		return;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  225  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  226  	if (WARN_ON(!mutex_is_locked(&pstore_blk_lock)))
1fe49524a73cc3 WeiXiong Liao 2020-05-10  227  		return;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  228  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  229  	if (holder)
1fe49524a73cc3 WeiXiong Liao 2020-05-10  230  		mode |= FMODE_EXCL;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  231  	blkdev_put(bdev, mode);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  232  }
1fe49524a73cc3 WeiXiong Liao 2020-05-10  233  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  234  static ssize_t psblk_generic_blk_read(char *buf, size_t bytes, loff_t pos)
1fe49524a73cc3 WeiXiong Liao 2020-05-10  235  {
1fe49524a73cc3 WeiXiong Liao 2020-05-10  236  	struct block_device *bdev = psblk_bdev;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  237  	struct file file;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  238  	struct kiocb kiocb;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  239  	struct iov_iter iter;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  240  	struct kvec iov = {.iov_base = buf, .iov_len = bytes};
1fe49524a73cc3 WeiXiong Liao 2020-05-10  241  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  242  	if (!bdev)
1fe49524a73cc3 WeiXiong Liao 2020-05-10  243  		return -ENODEV;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  244  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  245  	memset(&file, 0, sizeof(struct file));
1fe49524a73cc3 WeiXiong Liao 2020-05-10  246  	file.f_mapping = bdev->bd_inode->i_mapping;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  247  	file.f_flags = O_DSYNC | __O_SYNC | O_NOATIME;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  248  	file.f_inode = bdev->bd_inode;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  249  	file_ra_state_init(&file.f_ra, file.f_mapping);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  250  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  251  	init_sync_kiocb(&kiocb, &file);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  252  	kiocb.ki_pos = pos;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  253  	iov_iter_kvec(&iter, READ, &iov, 1, bytes);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  254  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  255  	return generic_file_read_iter(&kiocb, &iter);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  256  }
1fe49524a73cc3 WeiXiong Liao 2020-05-10  257  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  258  static ssize_t psblk_generic_blk_write(const char *buf, size_t bytes,
1fe49524a73cc3 WeiXiong Liao 2020-05-10  259  		loff_t pos)
1fe49524a73cc3 WeiXiong Liao 2020-05-10  260  {
1fe49524a73cc3 WeiXiong Liao 2020-05-10  261  	struct block_device *bdev = psblk_bdev;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  262  	struct iov_iter iter;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  263  	struct kiocb kiocb;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  264  	struct file file;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  265  	ssize_t ret;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  266  	struct kvec iov = {.iov_base = (void *)buf, .iov_len = bytes};
1fe49524a73cc3 WeiXiong Liao 2020-05-10  267  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  268  	if (!bdev)
1fe49524a73cc3 WeiXiong Liao 2020-05-10  269  		return -ENODEV;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  270  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  271  	/* Console/Ftrace backend may handle buffer until flush dirty zones */
1fe49524a73cc3 WeiXiong Liao 2020-05-10  272  	if (in_interrupt() || irqs_disabled())
1fe49524a73cc3 WeiXiong Liao 2020-05-10  273  		return -EBUSY;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  274  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  275  	memset(&file, 0, sizeof(struct file));
1fe49524a73cc3 WeiXiong Liao 2020-05-10  276  	file.f_mapping = bdev->bd_inode->i_mapping;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  277  	file.f_flags = O_DSYNC | __O_SYNC | O_NOATIME;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  278  	file.f_inode = bdev->bd_inode;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  279  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  280  	init_sync_kiocb(&kiocb, &file);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  281  	kiocb.ki_pos = pos;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  282  	iov_iter_kvec(&iter, WRITE, &iov, 1, bytes);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  283  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  284  	inode_lock(bdev->bd_inode);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  285  	ret = generic_write_checks(&kiocb, &iter);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  286  	if (ret > 0)
1fe49524a73cc3 WeiXiong Liao 2020-05-10  287  		ret = generic_perform_write(&file, &iter, pos);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  288  	inode_unlock(bdev->bd_inode);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  289  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  290  	if (likely(ret > 0)) {
1fe49524a73cc3 WeiXiong Liao 2020-05-10  291  		const struct file_operations f_op = {.fsync = blkdev_fsync};
1fe49524a73cc3 WeiXiong Liao 2020-05-10  292  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  293  		file.f_op = &f_op;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  294  		kiocb.ki_pos += ret;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  295  		ret = generic_write_sync(&kiocb, ret);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  296  	}
1fe49524a73cc3 WeiXiong Liao 2020-05-10  297  	return ret;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  298  }
1fe49524a73cc3 WeiXiong Liao 2020-05-10  299  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  300  static ssize_t psblk_blk_panic_write(const char *buf, size_t size,
1fe49524a73cc3 WeiXiong Liao 2020-05-10  301  		loff_t off)
1fe49524a73cc3 WeiXiong Liao 2020-05-10  302  {
1fe49524a73cc3 WeiXiong Liao 2020-05-10  303  	int ret;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  304  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  305  	if (!blkdev_panic_write)
1fe49524a73cc3 WeiXiong Liao 2020-05-10  306  		return -EOPNOTSUPP;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  307  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  308  	/* size and off must align to SECTOR_SIZE for block device */
1fe49524a73cc3 WeiXiong Liao 2020-05-10  309  	ret = blkdev_panic_write(buf, off >> SECTOR_SHIFT,
1fe49524a73cc3 WeiXiong Liao 2020-05-10  310  			size >> SECTOR_SHIFT);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  311  	return ret ? -EIO : size;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  312  }
1fe49524a73cc3 WeiXiong Liao 2020-05-10  313  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  314  static int __register_pstore_blk(struct pstore_blk_info *info)
1fe49524a73cc3 WeiXiong Liao 2020-05-10  315  {
1fe49524a73cc3 WeiXiong Liao 2020-05-10  316  	char bdev_name[BDEVNAME_SIZE];
1fe49524a73cc3 WeiXiong Liao 2020-05-10  317  	struct block_device *bdev;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  318  	struct pstore_device_info dev;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  319  	struct bdev_info binfo;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  320  	void *holder = blkdev;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  321  	int ret = -ENODEV;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  322  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  323  	if (WARN_ON(!mutex_is_locked(&pstore_blk_lock)))
1fe49524a73cc3 WeiXiong Liao 2020-05-10  324  		return -EINVAL;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  325  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  326  	/* hold bdev exclusively */
1fe49524a73cc3 WeiXiong Liao 2020-05-10  327  	memset(&binfo, 0, sizeof(binfo));
1fe49524a73cc3 WeiXiong Liao 2020-05-10  328  	bdev = psblk_get_bdev(holder, &binfo);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  329  	if (IS_ERR(bdev)) {
1fe49524a73cc3 WeiXiong Liao 2020-05-10  330  		pr_err("failed to open '%s'!\n", blkdev);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  331  		ret = PTR_ERR(bdev);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  332  		goto err_put_bdev;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  333  	}
1fe49524a73cc3 WeiXiong Liao 2020-05-10  334  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  335  	/* only allow driver matching the @blkdev */
1fe49524a73cc3 WeiXiong Liao 2020-05-10  336  	if (!binfo.devt || MAJOR(binfo.devt) != info->major) {
1fe49524a73cc3 WeiXiong Liao 2020-05-10  337  		pr_debug("invalid major %u (expect %u)\n",
1fe49524a73cc3 WeiXiong Liao 2020-05-10  338  				info->major, MAJOR(binfo.devt));
1fe49524a73cc3 WeiXiong Liao 2020-05-10  339  		ret = -ENODEV;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  340  		goto err_put_bdev;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  341  	}
1fe49524a73cc3 WeiXiong Liao 2020-05-10  342  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  343  	/* psblk_bdev must be assigned before register to pstore/blk */
1fe49524a73cc3 WeiXiong Liao 2020-05-10  344  	psblk_bdev = bdev;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  345  	blkdev_panic_write = info->panic_write;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  346  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  347  	/* Copy back block device details. */
1fe49524a73cc3 WeiXiong Liao 2020-05-10  348  	info->devt = binfo.devt;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  349  	info->nr_sects = binfo.nr_sects;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  350  	info->start_sect = binfo.start_sect;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  351  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  352  	memset(&dev, 0, sizeof(dev));
1fe49524a73cc3 WeiXiong Liao 2020-05-10  353  	dev.total_size = info->nr_sects << SECTOR_SHIFT;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  354  	dev.flags = info->flags;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  355  	dev.read = psblk_generic_blk_read;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  356  	dev.write = psblk_generic_blk_write;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  357  	dev.panic_write = info->panic_write ? psblk_blk_panic_write : NULL;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  358  
1fe49524a73cc3 WeiXiong Liao 2020-05-10 @359  	ret = psblk_register_do(&dev);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  360  	if (ret)
1fe49524a73cc3 WeiXiong Liao 2020-05-10  361  		goto err_put_bdev;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  362  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  363  	bdevname(bdev, bdev_name);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  364  	pr_info("attached %s%s\n", bdev_name,
1fe49524a73cc3 WeiXiong Liao 2020-05-10  365  		info->panic_write ? "" : " (no dedicated panic_write!)");
1fe49524a73cc3 WeiXiong Liao 2020-05-10  366  	return 0;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  367  
1fe49524a73cc3 WeiXiong Liao 2020-05-10  368  err_put_bdev:
1fe49524a73cc3 WeiXiong Liao 2020-05-10  369  	psblk_bdev = NULL;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  370  	blkdev_panic_write = NULL;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  371  	psblk_put_bdev(bdev, holder);
1fe49524a73cc3 WeiXiong Liao 2020-05-10  372  	return ret;
1fe49524a73cc3 WeiXiong Liao 2020-05-10  373  }
1fe49524a73cc3 WeiXiong Liao 2020-05-10  374  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 75+ messages in thread

end of thread, other threads:[~2020-05-13  5:08 UTC | newest]

Thread overview: 75+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-10 20:24 [PATCH v7 00/18] pstore: mtd: support crash log to block and mtd device Kees Cook
2020-05-10 20:24 ` Kees Cook
2020-05-10 20:24 ` [PATCH v7 01/18] pstore/ram: Move dump_oops to end of module_param list Kees Cook
2020-05-10 20:24   ` Kees Cook
2020-05-10 20:24 ` [PATCH v7 02/18] pstore/platform: Switch pstore_info::name to const Kees Cook
2020-05-10 20:24   ` Kees Cook
2020-05-10 20:24 ` [PATCH v7 03/18] pstore/platform: Move module params after declarations Kees Cook
2020-05-10 20:24   ` Kees Cook
2020-05-10 20:24 ` [PATCH v7 04/18] pstore/platform: Use backend name for console registration Kees Cook
2020-05-10 20:24   ` Kees Cook
2020-05-10 20:24 ` [PATCH v7 05/18] pstore/ram: Refactor ftrace buffer merging Kees Cook
2020-05-10 20:24   ` Kees Cook
2020-05-10 20:24 ` [PATCH v7 06/18] pstore/ftrace: Provide ftrace log merging routine Kees Cook
2020-05-10 20:24   ` Kees Cook
2020-05-10 20:24 ` [PATCH v7 07/18] printk: Introduce kmsg_dump_reason_str() Kees Cook
2020-05-10 20:24   ` Kees Cook
2020-05-12  8:44   ` Petr Mladek
2020-05-12  8:44     ` Petr Mladek
2020-05-12 19:44     ` Kees Cook
2020-05-12 19:44       ` Kees Cook
2020-05-13  5:08   ` Sergey Senozhatsky
2020-05-13  5:08     ` Sergey Senozhatsky
2020-05-10 20:24 ` [PATCH v7 08/18] pstore/zone: Introduce common layer to manage storage zones Kees Cook
2020-05-10 20:24   ` Kees Cook
2020-05-11  8:36   ` WeiXiong Liao
2020-05-11  8:36     ` WeiXiong Liao
2020-05-11 23:02     ` Kees Cook
2020-05-11 23:02       ` Kees Cook
2020-05-10 20:24 ` [PATCH v7 09/18] pstore/blk: Introduce backend for block devices Kees Cook
2020-05-10 20:24   ` Kees Cook
2020-05-11  8:36   ` WeiXiong Liao
2020-05-11  8:36     ` WeiXiong Liao
2020-05-11 23:08     ` Kees Cook
2020-05-11 23:08       ` Kees Cook
2020-05-11 15:36   ` Randy Dunlap
2020-05-11 15:36     ` Randy Dunlap
2020-05-11 23:11     ` Kees Cook
2020-05-11 23:11       ` Kees Cook
2020-05-10 20:24 ` [PATCH v7 10/18] pstore/zone,blk: Add support for pmsg frontend Kees Cook
2020-05-10 20:24   ` Kees Cook
2020-05-11  8:36   ` WeiXiong Liao
2020-05-11  8:36     ` WeiXiong Liao
2020-05-10 20:24 ` [PATCH v7 11/18] pstore/zone,blk: Add console frontend support Kees Cook
2020-05-10 20:24   ` Kees Cook
2020-05-11 15:38   ` Randy Dunlap
2020-05-11 15:38     ` Randy Dunlap
2020-05-11 23:14     ` Kees Cook
2020-05-11 23:14       ` Kees Cook
2020-05-10 20:24 ` [PATCH v7 12/18] pstore/zone,blk: Add ftrace " Kees Cook
2020-05-10 20:24   ` Kees Cook
2020-05-11 15:37   ` Randy Dunlap
2020-05-11 15:37     ` Randy Dunlap
2020-05-10 20:24 ` [PATCH v7 13/18] Documentation: Add details for pstore/blk Kees Cook
2020-05-10 20:24   ` Kees Cook
2020-05-10 20:24 ` [PATCH v7 14/18] pstore/zone: Provide way to skip "broken" zone for MTD devices Kees Cook
2020-05-10 20:24   ` Kees Cook
2020-05-10 20:24 ` [PATCH v7 15/18] pstore/blk: Provide way to query pstore configuration Kees Cook
2020-05-10 20:24   ` Kees Cook
2020-05-10 20:24 ` [PATCH v7 16/18] pstore/blk: Support non-block storage devices Kees Cook
2020-05-10 20:24   ` Kees Cook
2020-05-10 20:24 ` [PATCH v7 17/18] mtd: Support kmsg dumper based on pstore/blk Kees Cook
2020-05-10 20:24   ` Kees Cook
2020-05-11  9:01   ` WeiXiong Liao
2020-05-11  9:01     ` WeiXiong Liao
2020-05-11 23:16     ` Kees Cook
2020-05-11 23:16       ` Kees Cook
2020-05-10 20:24 ` [PATCH v7 18/18] pstore/blk: Introduce "best_effort" mode Kees Cook
2020-05-10 20:24   ` Kees Cook
2020-05-11 10:54 ` [PATCH v7 00/18] pstore: mtd: support crash log to block and mtd device WeiXiong Liao
2020-05-11 10:54   ` WeiXiong Liao
2020-05-11 23:17   ` Kees Cook
2020-05-11 23:17     ` Kees Cook
2020-05-11 22:39 ` Kees Cook
2020-05-11 22:39   ` Kees Cook
  -- strict thread matches above, loose matches on Subject: below --
2020-05-10 22:14 [PATCH v7 09/18] pstore/blk: Introduce backend for block devices kbuild test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.