simplify pstore-blk
Subsystems (3)
Hi all,
this series cleans up and massively simplifies the pstore-blk code, please take a look.
PATCH 1/9 pstore/zone: cap the maximum device size
Introduce an abritrary 128MiB cap to avoid malloc failures when using a larger block device.
--- fs/pstore/zone.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/pstore/zone.c +4 -0
@@ -1299,6 +1299,10 @@ int register_pstore_zone(struct pstore_zone_info *info)pr_warn ("total_size must be >= 4096\n" );return -EINVAL ; } +if (info->total_size >SZ_128M ) { +pr_warn ("capping size to 128MiB\n" ); + info->total_size =SZ_128M ; + }if (!info->kmsg_size && !info->pmsg_size && !info->console_size && !info->ftrace_size) {
Signature · 1 line
2.28.0
Re: [PATCH 1/9] pstore/zone: cap the maximum device size
Quoted 14 lines · Christoph Hellwig
Introduce an abritrary 128MiB cap to avoid malloc failures when using a larger block device.
Signed-off-by Christoph Hellwig <[email protected]>--- fs/pstore/zone.c | 4 ++++ 1 file changed, 4 insertions(+)fs/pstore/zone.c +0
-0
fs/pstore/zone.c int register_pstore_zone(struct pstore_zone_info *info) · line 1306
Quoted 8 lines
fs/pstore/zone.c +4
-0@@ -1299,6 +1299,10 @@ int register_pstore_zone(struct pstore_zone_info *info)pr_warn ("total_size must be >= 4096\n" );return -EINVAL ; } +if (info->total_size >SZ_128M ) { +pr_warn ("capping size to 128MiB\n" ); + info->total_size =SZ_128M ; + }
Quoted 5 lines
fs/pstore/zone.c +0
-1if (!info->kmsg_size && !info->pmsg_size && !info->console_size && !info->ftrace_size) { --2.28.0
Re: [PATCH 1/9] pstore/zone: cap the maximum device size
In reply to Christoph HellwigQuoted 4 lines · Christoph Hellwig
Introduce an abritrary 128MiB cap to avoid malloc failures when using a larger block device.
Signed-off-by Christoph Hellwig <[email protected]>
Yeah, this seems reasonable. I'm always worried about arbitrary size limits, but if 128M is needed for pstore, something is likely very very wrong. :)
Signature · 1 line
Kees Cook
Kees Cook
AppliedRe: [PATCH 1/9] pstore/zone: cap the maximum device size
In reply to Christoph HellwigQuoted 2 lines · Christoph Hellwig
Introduce an abritrary 128MiB cap to avoid malloc failures when using a larger block device.
I've applied 1-3 of the series to for-next/pstore, thanks!
[1/9] pstore/zone: cap the maximum device size
https://git.kernel.org/kees/c/cbf82e35031b [2/9] pstore/blk: update the command line example https://git.kernel.org/kees/c/45a8af4412b1 [3/9] pstore/blk: remove {un,}register_pstore_blk https://git.kernel.org/kees/c/b6f8ed33ab2b
(I tweaked #3 with a small added comment.)
Signature · 1 line
Kees Cook
PATCH 2/9 pstore/blk: update the command line example
In reply to Christoph HellwigUse the human readable device name instead of the device number, and add the required best_effort parameter.
--- Documentation/admin-guide/pstore-blk.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/admin-guide/pstore-blk.rst +1 -1
@@ -35,7 +35,7 @@ module parameters have priority over Kconfig. Here is an example for module parameters:: - pstore_blk.blkdev=179:7 pstore_blk.kmsg_size=64 + pstore_blk.blkdev=/dev/mmcblk0p7 pstore_blk.kmsg_size=64 best_effort=y The detail of each configurations may be of interest to you.
Signature · 1 line
2.28.0
Re: [PATCH 2/9] pstore/blk: update the command line example
Quoted 14 lines · Christoph Hellwig
Use the human readable device name instead of the device number, and add the required
best_effortparameter.Signed-off-by Christoph Hellwig <[email protected]>--- Documentation/admin-guide/pstore-blk.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Documentation/admin-guide/pstore-blk.rst +0
-0
Documentation/admin-guide/pstore-blk.rst module parameters have priority over Kconfig. · line 39
Quoted 6 lines
Documentation/admin-guide/pstore-blk.rst +1
-1@@ -35,7 +35,7 @@ module parameters have priority over Kconfig. Here is an example for module parameters:: - pstore_blk.blkdev=179:7 pstore_blk.kmsg_size=64 + pstore_blk.blkdev=/dev/mmcblk0p7 pstore_blk.kmsg_size=64 best_effort=y
Quoted 5 lines
Documentation/admin-guide/pstore-blk.rst +0
-1The detail of each configurations may be of interest to you. --2.28.0
Re: [PATCH 2/9] pstore/blk: update the command line example
In reply to Christoph HellwigQuoted 4 lines · Christoph Hellwig
Use the human readable device name instead of the device number, and add the required
best_effortparameter.Signed-off-by Christoph Hellwig <[email protected]>
Yeah, best_effort is needed here. I think changing from major:minor to a path is also fine.
Quoted 20 lines
--- Documentation/admin-guide/pstore-blk.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Documentation/admin-guide/pstore-blk.rst +1
-1@@ -35,7 +35,7 @@ module parameters have priority over Kconfig. Here is an example for module parameters:: - pstore_blk.blkdev=179:7 pstore_blk.kmsg_size=64 + pstore_blk.blkdev=/dev/mmcblk0p7 pstore_blk.kmsg_size=64 best_effort=y The detail of each configurations may be of interest to you.Signature · 1 line
2.28.0
Signature · 5 lines
Kees Cook ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 3/9 pstore/blk: remove {un,}register_pstore_blk
In reply to Christoph HellwigThis interface is entirely unused, so remove them and various bits of unreachable code.
--- Documentation/admin-guide/pstore-blk.rst | 8 +-- fs/pstore/blk.c | 79 ++---------------------- include/linux/pstore_blk.h | 42 ------------- 3 files changed, 7 insertions(+), 122 deletions(-)
Documentation/admin-guide/pstore-blk.rst +1 -7
@@ -151,13 +151,7 @@ otherwise KMSG_DUMP_MAX. Configurations for driver ------------------------- -Only a block device driver cares about these configurations. A block device -driver uses ``register_pstore_blk`` to register to pstore/blk. - -.. kernel-doc:: fs/pstore/blk.c - :identifiers: register_pstore_blk - -A non-block device driver uses ``register_pstore_device`` with +A device driver uses ``register_pstore_device`` with ``struct pstore_device_info`` to register to pstore/blk. .. kernel-doc:: fs/pstore/blk.c
fs/pstore/blk.c +6 -73
141 lines not on this page · raw message
include/linux/pstore_blk.h +0 -42
48 lines not on this page · raw message
Signature · 1 line
2.28.0
Re: [PATCH 3/9] pstore/blk: remove {un,}register_pstore_blk
Quoted 2 lines · Christoph Hellwig
This interface is entirely unused, so remove them and various bits of unreachable code.
Yeah, this is fair to remove -- there are no users. I'm not a fan of dropping it, but it can come back if anyone wants to provide a full generic block device implementation.
Quoted 233 lines
Signed-off-by Christoph Hellwig <[email protected]>--- Documentation/admin-guide/pstore-blk.rst | 8 +-- fs/pstore/blk.c | 79 ++---------------------- include/linux/pstore_blk.h | 42 ------------- 3 files changed, 7 insertions(+), 122 deletions(-)Documentation/admin-guide/pstore-blk.rst +1
-7@@ -151,13 +151,7 @@ otherwise KMSG_DUMP_MAX. Configurations for driver ------------------------- -Only a block device driver cares about these configurations. A block device -driver uses ``register_pstore_blk`` to register to pstore/blk. - -.. kernel-doc:: fs/pstore/blk.c - :identifiers: register_pstore_blk - -A non-block device driver uses ``register_pstore_device`` with +A device driver uses ``register_pstore_device`` with ``struct pstore_device_info`` to register to pstore/blk. .. kernel-doc:: fs/pstore/blk.cfs/pstore/blk.c +6
-73@@ -90,7 +90,6 @@ MODULE_PARM_DESC(blkdev, "block device for pstore storage");static DEFINE_MUTEX (pstore_blk_lock);static struct block_device *psblk_bdev;static struct pstore_zone_info *pstore_zone_info; -static pstore_blk_panic_write_op blkdev_panic_write;struct bdev_info {dev_t devt;@@ -341,24 +340,7 @@ static ssize_t psblk_generic_blk_write(const char *buf, size_t bytes,return ret; } -static ssize_t psblk_blk_panic_write (const char *buf,size_t size, -loff_t off) -{ -int ret; - -if (!blkdev_panic_write) -return -EOPNOTSUPP ; - -/* size and off must align to SECTOR_SIZE for block device */ - ret =blkdev_panic_write (buf, off >>SECTOR_SHIFT , - size >>SECTOR_SHIFT ); -/* try next zone */ -if (ret == -ENOMSG ) -return ret; -return ret ? -EIO : size; -} - -static int __register_pstore_blk (struct pstore_blk_info *info) +static int __register_pstore_blk (void ) {char bdev_name[BDEVNAME_SIZE ];struct block_device *bdev;@@ -378,68 +360,34 @@ static int __register_pstore_blk(struct pstore_blk_info *info) }/* only allow driver matching the @blkdev */ -if (!binfo.devt || (!best_effort && -MAJOR (binfo.devt) != info->major)) { -pr_debug ("invalid major %u (expect %u)\n" , - info->major,MAJOR (binfo.devt)); +if (!binfo.devt) { +pr_debug ("no major\n" ); ret = -ENODEV ; goto err_put_bdev; }/* psblk_bdev must be assigned before register to pstore/blk */ psblk_bdev = bdev; - blkdev_panic_write = info->panic_write; - -/* Copy back block device details. */ - info->devt = binfo.devt; - info->nr_sects = binfo.nr_sects; - info->start_sect = binfo.start_sect;memset (&dev,0 ,sizeof (dev)); - dev.total_size = info->nr_sects <<SECTOR_SHIFT ; - dev.flags = info->flags; + dev.total_size = binfo.nr_sects <<SECTOR_SHIFT ; dev.read = psblk_generic_blk_read; dev.write = psblk_generic_blk_write; - dev.erase =NULL ; - dev.panic_write = info->panic_write ? psblk_blk_panic_write :NULL ; ret =__register_pstore_device (&dev);if (ret) goto err_put_bdev;bdevname (bdev, bdev_name); -pr_info ("attached %s%s\n" , bdev_name, - info->panic_write ?"" :" (no dedicated panic_write!)" ); +pr_info ("attached %s (no dedicated panic_write!)\n" , bdev_name);return 0 ; err_put_bdev: psblk_bdev =NULL ; - blkdev_panic_write =NULL ;psblk_put_bdev (bdev, holder);return ret; } -/** -* register_pstore_blk() - register block device to pstore/blk -* -* @info: details on the desired block device interface -* -* Return: -* * 0 - OK -* * Others - something error. -*/ -int register_pstore_blk (struct pstore_blk_info *info) -{ -int ret; - -mutex_lock (&pstore_blk_lock); - ret =__register_pstore_blk (info); -mutex_unlock (&pstore_blk_lock); - -return ret; -} -EXPORT_SYMBOL_GPL (register_pstore_blk); -static void __unregister_pstore_blk (unsigned int major) {struct pstore_device_info dev = { .read = psblk_generic_blk_read };@@ -449,24 +397,10 @@ static void __unregister_pstore_blk(unsigned int major)if (psblk_bdev &&MAJOR (psblk_bdev->bd_dev) == major) {__unregister_pstore_device (&dev);psblk_put_bdev (psblk_bdev, holder); - blkdev_panic_write =NULL ; psblk_bdev =NULL ; } } -/** -* unregister_pstore_blk() - unregister block device from pstore/blk -* -* @major: the major device number of device -*/ -void unregister_pstore_blk (unsigned int major) -{ -mutex_lock (&pstore_blk_lock); -__unregister_pstore_blk (major); -mutex_unlock (&pstore_blk_lock); -} -EXPORT_SYMBOL_GPL (unregister_pstore_blk); -/* get information of pstore/blk */ int pstore_blk_get_config (struct pstore_blk_config *info) {@@ -483,12 +417,11 @@ EXPORT_SYMBOL_GPL(pstore_blk_get_config);static int __init pstore_blk_init (void ) { -struct pstore_blk_info info = { };int ret =0 ;mutex_lock (&pstore_blk_lock);if (!pstore_zone_info && best_effort && blkdev[0 ]) - ret =__register_pstore_blk (&info); + ret =__register_pstore_blk ();mutex_unlock (&pstore_blk_lock);return ret;include/linux/pstore_blk.h +0
-42@@ -7,48 +7,6 @@#include <linux/pstore.h> #include <linux/pstore_zone.h> -/** -* typedef pstore_blk_panic_write_op - panic write operation to block device -* -* @buf: the data to write -* @start_sect: start sector to block device -* @sects: sectors count on buf -* -* Return: On success, zero should be returned. Others excluding -ENOMSG -* mean error. -ENOMSG means to try next zone. -* -* Panic write to block device must be aligned to SECTOR_SIZE. -*/ -typedef int (*pstore_blk_panic_write_op )(const char *buf,sector_t start_sect, -sector_t sects); - -/** -* struct pstore_blk_info - pstore/blk registration details -* -* @major: Which major device number to support with pstore/blk -* @flags: The supported PSTORE_FLAGS_* from linux/pstore.h. -* @panic_write:The write operation only used for the panic case. -* This can be NULL, but is recommended to avoid losing -* crash data if the kernel's IO path or work queues are -* broken during a panic. -* @devt: The dev_t that pstore/blk has attached to. -* @nr_sects: Number of sectors on @devt. -* @start_sect: Starting sector on @devt. -*/ -struct pstore_blk_info { -unsigned int major; -unsigned int flags; -pstore_blk_panic_write_op panic_write; - -/* Filled in by pstore/blk after registration. */ -dev_t devt; -sector_t nr_sects; -sector_t start_sect; -}; - -int register_pstore_blk (struct pstore_blk_info *info); -void unregister_pstore_blk (unsigned int major); -/** * struct pstore_device_info - back-end pstore/blk driver structure. * Signature · 1 line
2.28.0
Signature · 5 lines
Kees Cook ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 4/9 pstore/blk: remove __unregister_pstore_blk
In reply to Christoph HellwigFold __unregister_pstore_blk into its only caller, and merge the two identical calls to __unregister_pstore_device that exist in the caller now.
--- fs/pstore/blk.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-)
fs/pstore/blk.c +6 -21
@@ -388,19 +388,6 @@ static int __register_pstore_blk(void)return ret; } -static void __unregister_pstore_blk (unsigned int major) -{ -struct pstore_device_info dev = { .read = psblk_generic_blk_read }; -void *holder = blkdev; - -lockdep_assert_held (&pstore_blk_lock); -if (psblk_bdev &&MAJOR (psblk_bdev->bd_dev) == major) { -__unregister_pstore_device (&dev); -psblk_put_bdev (psblk_bdev, holder); - psblk_bdev =NULL ; - } -} -/* get information of pstore/blk */ int pstore_blk_get_config (struct pstore_blk_config *info) {
@@ -430,16 +417,14 @@ late_initcall(pstore_blk_init); static void __exit pstore_blk_exit(void) { +struct pstore_device_info dev = { }; +mutex_lock (&pstore_blk_lock); +if (pstore_zone_info) + dev.read = pstore_zone_info->read; +__unregister_pstore_device (&dev);if (psblk_bdev) -__unregister_pstore_blk (MAJOR (psblk_bdev->bd_dev)); -else { -struct pstore_device_info dev = { }; - -if (pstore_zone_info) - dev.read = pstore_zone_info->read; -__unregister_pstore_device (&dev); - } +psblk_put_bdev (psblk_bdev, blkdev);mutex_unlock (&pstore_blk_lock); }module_exit (pstore_blk_exit);
Signature · 1 line
2.28.0
Re: [PATCH 4/9] pstore/blk: remove __unregister_pstore_blk
Quoted 3 lines · Christoph Hellwig
Fold
__unregister_pstore_blkinto its only caller, and merge the two identical calls to__unregister_pstore_devicethat exist in the caller now.
Meh, I'm not a fan of this. I like it in a separate function. Pushing it into the _exit() routine feels weird to me.
Quoted 56 lines
Signed-off-by Christoph Hellwig <[email protected]>--- fs/pstore/blk.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-)fs/pstore/blk.c +6
-21@@ -388,19 +388,6 @@ static int __register_pstore_blk(void)return ret; } -static void __unregister_pstore_blk (unsigned int major) -{ -struct pstore_device_info dev = { .read = psblk_generic_blk_read }; -void *holder = blkdev; - -lockdep_assert_held (&pstore_blk_lock); -if (psblk_bdev &&MAJOR (psblk_bdev->bd_dev) == major) { -__unregister_pstore_device (&dev); -psblk_put_bdev (psblk_bdev, holder); - psblk_bdev =NULL ; - } -} -/* get information of pstore/blk */ int pstore_blk_get_config (struct pstore_blk_config *info) {@@ -430,16 +417,14 @@ late_initcall(pstore_blk_init); static void __exit pstore_blk_exit(void) { +struct pstore_device_info dev = { }; +mutex_lock (&pstore_blk_lock); +if (pstore_zone_info) + dev.read = pstore_zone_info->read; +__unregister_pstore_device (&dev);if (psblk_bdev) -__unregister_pstore_blk (MAJOR (psblk_bdev->bd_dev)); -else { -struct pstore_device_info dev = { }; - -if (pstore_zone_info) - dev.read = pstore_zone_info->read; -__unregister_pstore_device (&dev); - } +psblk_put_bdev (psblk_bdev, blkdev);mutex_unlock (&pstore_blk_lock); }module_exit (pstore_blk_exit);Signature · 1 line
2.28.0
Signature · 5 lines
Kees Cook ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 5/9 pstore/blk: simplify the block device open / close path
In reply to Christoph HellwigRemove the pointless psblk_get_bdev and psblk_put_bdev helper, and don't bother holding pstore_blk_lock over the block device open / close interactions given that they only happen first thing during module init and last thing during module exit. Also don't bother with unregistering a zone info that did not come from the actually block backed code, as users like mtd have to unregister it themselves already.
--- fs/pstore/blk.c | 156 ++++++++++++------------------------------------ 1 file changed, 38 insertions(+), 118 deletions(-)
fs/pstore/blk.c +38 -118
@@ -91,12 +91,6 @@ static DEFINE_MUTEX(pstore_blk_lock);static struct block_device *psblk_bdev;static struct pstore_zone_info *pstore_zone_info; -struct bdev_info { -dev_t devt; -sector_t nr_sects; -sector_t start_sect; -}; -#define check_size (name, alignsize) ({ \ long _##name_ = (name); \ _##name_ = _##name_ <= 0 ? 0 : (_##name_ * 1024); \
@@ -205,75 +199,6 @@ void unregister_pstore_device(struct pstore_device_info *dev) }EXPORT_SYMBOL_GPL (unregister_pstore_device); -/** -* psblk_get_bdev() - open block device -* -* @holder: Exclusive holder identifier -* @info: Information about bdev to fill in -* -* Return: pointer to block device on success and others on error. -* -* On success, the returned block_device has reference count of one. -*/ -static struct block_device *psblk_get_bdev (void *holder, -struct bdev_info *info) -{ -struct block_device *bdev =ERR_PTR (-ENODEV ); -fmode_t mode =FMODE_READ |FMODE_WRITE ; -sector_t nr_sects; - -lockdep_assert_held (&pstore_blk_lock); - -if (pstore_zone_info) -return ERR_PTR (-EBUSY ); - -if (!blkdev[0 ]) -return ERR_PTR (-ENODEV ); - -if (holder) - mode |=FMODE_EXCL ; - bdev =blkdev_get_by_path (blkdev, mode, holder); -if (IS_ERR (bdev)) { -dev_t devt; - - devt =name_to_dev_t (blkdev); -if (devt ==0 ) -return ERR_PTR (-ENODEV ); - bdev =blkdev_get_by_dev (devt, mode, holder); -if (IS_ERR (bdev)) -return bdev; - } - - nr_sects =part_nr_sects_read (bdev->bd_part); -if (!nr_sects) { -pr_err ("not enough space for '%s'\n" , blkdev); -blkdev_put (bdev, mode); -return ERR_PTR (-ENOSPC ); - } - -if (info) { - info->devt = bdev->bd_dev; - info->nr_sects = nr_sects; - info->start_sect =get_start_sect (bdev); - } - -return bdev; -} - -static void psblk_put_bdev (struct block_device *bdev,void *holder) -{ -fmode_t mode =FMODE_READ |FMODE_WRITE ; - -lockdep_assert_held (&pstore_blk_lock); - -if (!bdev) -return ; - -if (holder) - mode |=FMODE_EXCL ; -blkdev_put (bdev, mode); -} -static ssize_t psblk_generic_blk_read (char *buf,size_t bytes,loff_t pos) {struct block_device *bdev = psblk_bdev;
@@ -340,29 +265,39 @@ static ssize_t psblk_generic_blk_write(const char *buf, size_t bytes,return ret; } -static int __register_pstore_blk (void ) +static int __init pstore_blk_init (void ) {char bdev_name[BDEVNAME_SIZE ];struct block_device *bdev;struct pstore_device_info dev; -struct bdev_info binfo; -void *holder = blkdev;int ret = -ENODEV ; - -lockdep_assert_held (&pstore_blk_lock); +fmode_t mode =FMODE_READ |FMODE_WRITE |FMODE_EXCL ; +sector_t nr_sects; + +if (!best_effort || !blkdev[0 ]) +return 0 ;/* hold bdev exclusively */ -memset (&binfo,0 ,sizeof (binfo)); - bdev =psblk_get_bdev (holder, &binfo); + bdev =blkdev_get_by_path (blkdev, mode, blkdev);if (IS_ERR (bdev)) { -pr_err ("failed to open '%s'!\n" , blkdev); -return PTR_ERR (bdev); +dev_t devt; + + devt =name_to_dev_t (blkdev); +if (devt ==0 ) { +pr_err ("failed to open '%s'!\n" , blkdev); +return -ENODEV ; + } + bdev =blkdev_get_by_dev (devt, mode, blkdev); +if (IS_ERR (bdev)) { +pr_err ("failed to open '%s'!\n" , blkdev); +return PTR_ERR (bdev); + } } -/* only allow driver matching the @blkdev */ -if (!binfo.devt) { -pr_debug ("no major\n" ); - ret = -ENODEV ; + nr_sects =part_nr_sects_read (bdev->bd_part); +if (!nr_sects) { +pr_err ("not enough space for '%s'\n" , blkdev); + ret = -ENOSPC ; goto err_put_bdev; }
@@ -370,11 +305,11 @@ static int __register_pstore_blk(void) psblk_bdev = bdev;memset (&dev,0 ,sizeof (dev)); - dev.total_size = binfo.nr_sects <<SECTOR_SHIFT ; + dev.total_size = nr_sects <<SECTOR_SHIFT ; dev.read = psblk_generic_blk_read; dev.write = psblk_generic_blk_write; - ret =__register_pstore_device (&dev); + ret =register_pstore_device (&dev);if (ret) goto err_put_bdev;
@@ -383,10 +318,22 @@ static int __register_pstore_blk(void)return 0 ; err_put_bdev: +blkdev_put (bdev,FMODE_READ |FMODE_WRITE |FMODE_EXCL ); psblk_bdev =NULL ; -psblk_put_bdev (bdev, holder);return ret; } +late_initcall (pstore_blk_init); + +static void __exit pstore_blk_exit(void) +{ +struct pstore_device_info dev = { .read = psblk_generic_blk_read }; + +if (!psblk_bdev) +return ; +unregister_pstore_device (&dev); +blkdev_put (psblk_bdev,FMODE_READ |FMODE_WRITE |FMODE_EXCL ); +} +module_exit (pstore_blk_exit);/* get information of pstore/blk */ int pstore_blk_get_config (struct pstore_blk_config *info)
@@ -402,33 +349,6 @@ int pstore_blk_get_config(struct pstore_blk_config *info) }EXPORT_SYMBOL_GPL (pstore_blk_get_config); -static int __init pstore_blk_init (void ) -{ -int ret =0 ; - -mutex_lock (&pstore_blk_lock); -if (!pstore_zone_info && best_effort && blkdev[0 ]) - ret =__register_pstore_blk (); -mutex_unlock (&pstore_blk_lock); - -return ret; -} -late_initcall (pstore_blk_init); - -static void __exit pstore_blk_exit(void) -{ -struct pstore_device_info dev = { }; - -mutex_lock (&pstore_blk_lock); -if (pstore_zone_info) - dev.read = pstore_zone_info->read; -__unregister_pstore_device (&dev); -if (psblk_bdev) -psblk_put_bdev (psblk_bdev, blkdev); -mutex_unlock (&pstore_blk_lock); -} -module_exit (pstore_blk_exit); -MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("WeiXiong Liao <[email protected]>" );MODULE_AUTHOR ("Kees Cook <[email protected]>" );
Signature · 1 line
2.28.0
Re: [PATCH 5/9] pstore/blk: simplify the block device open / close path
Quoted 7 lines · Christoph Hellwig
Remove the pointless
psblk_get_bdevandpsblk_put_bdevhelper, and don't bother holdingpstore_blk_lockover the block device open / close interactions given that they only happen first thing during module init and last thing during module exit. Also don't bother with unregistering a zone info that did not come from the actually block backed code, as users like mtd have to unregister it themselves already.
I don't like this because it's changing too many things at once. Of the stuff I don't want is:
- removal of checking for already-active zoneinfo (there can be only one)
- collapsing register_blk into _init (it seems clearer to me to keep them separate)
-Kees
Quoted 227 lines
Signed-off-by Christoph Hellwig <[email protected]>--- fs/pstore/blk.c | 156 ++++++++++++------------------------------------ 1 file changed, 38 insertions(+), 118 deletions(-)fs/pstore/blk.c +38
-118@@ -91,12 +91,6 @@ static DEFINE_MUTEX(pstore_blk_lock);static struct block_device *psblk_bdev;static struct pstore_zone_info *pstore_zone_info; -struct bdev_info { -dev_t devt; -sector_t nr_sects; -sector_t start_sect; -}; -#define check_size (name, alignsize) ({ \ long _##name_ = (name); \ _##name_ = _##name_ <= 0 ? 0 : (_##name_ * 1024); \@@ -205,75 +199,6 @@ void unregister_pstore_device(struct pstore_device_info *dev) }EXPORT_SYMBOL_GPL (unregister_pstore_device); -/** -* psblk_get_bdev() - open block device -* -* @holder: Exclusive holder identifier -* @info: Information about bdev to fill in -* -* Return: pointer to block device on success and others on error. -* -* On success, the returned block_device has reference count of one. -*/ -static struct block_device *psblk_get_bdev (void *holder, -struct bdev_info *info) -{ -struct block_device *bdev =ERR_PTR (-ENODEV ); -fmode_t mode =FMODE_READ |FMODE_WRITE ; -sector_t nr_sects; - -lockdep_assert_held (&pstore_blk_lock); - -if (pstore_zone_info) -return ERR_PTR (-EBUSY ); - -if (!blkdev[0 ]) -return ERR_PTR (-ENODEV ); - -if (holder) - mode |=FMODE_EXCL ; - bdev =blkdev_get_by_path (blkdev, mode, holder); -if (IS_ERR (bdev)) { -dev_t devt; - - devt =name_to_dev_t (blkdev); -if (devt ==0 ) -return ERR_PTR (-ENODEV ); - bdev =blkdev_get_by_dev (devt, mode, holder); -if (IS_ERR (bdev)) -return bdev; - } - - nr_sects =part_nr_sects_read (bdev->bd_part); -if (!nr_sects) { -pr_err ("not enough space for '%s'\n" , blkdev); -blkdev_put (bdev, mode); -return ERR_PTR (-ENOSPC ); - } - -if (info) { - info->devt = bdev->bd_dev; - info->nr_sects = nr_sects; - info->start_sect =get_start_sect (bdev); - } - -return bdev; -} - -static void psblk_put_bdev (struct block_device *bdev,void *holder) -{ -fmode_t mode =FMODE_READ |FMODE_WRITE ; - -lockdep_assert_held (&pstore_blk_lock); - -if (!bdev) -return ; - -if (holder) - mode |=FMODE_EXCL ; -blkdev_put (bdev, mode); -} -static ssize_t psblk_generic_blk_read (char *buf,size_t bytes,loff_t pos) {struct block_device *bdev = psblk_bdev;@@ -340,29 +265,39 @@ static ssize_t psblk_generic_blk_write(const char *buf, size_t bytes,return ret; } -static int __register_pstore_blk (void ) +static int __init pstore_blk_init (void ) {char bdev_name[BDEVNAME_SIZE ];struct block_device *bdev;struct pstore_device_info dev; -struct bdev_info binfo; -void *holder = blkdev;int ret = -ENODEV ; - -lockdep_assert_held (&pstore_blk_lock); +fmode_t mode =FMODE_READ |FMODE_WRITE |FMODE_EXCL ; +sector_t nr_sects; + +if (!best_effort || !blkdev[0 ]) +return 0 ;/* hold bdev exclusively */ -memset (&binfo,0 ,sizeof (binfo)); - bdev =psblk_get_bdev (holder, &binfo); + bdev =blkdev_get_by_path (blkdev, mode, blkdev);if (IS_ERR (bdev)) { -pr_err ("failed to open '%s'!\n" , blkdev); -return PTR_ERR (bdev); +dev_t devt; + + devt =name_to_dev_t (blkdev); +if (devt ==0 ) { +pr_err ("failed to open '%s'!\n" , blkdev); +return -ENODEV ; + } + bdev =blkdev_get_by_dev (devt, mode, blkdev); +if (IS_ERR (bdev)) { +pr_err ("failed to open '%s'!\n" , blkdev); +return PTR_ERR (bdev); + } } -/* only allow driver matching the @blkdev */ -if (!binfo.devt) { -pr_debug ("no major\n" ); - ret = -ENODEV ; + nr_sects =part_nr_sects_read (bdev->bd_part); +if (!nr_sects) { +pr_err ("not enough space for '%s'\n" , blkdev); + ret = -ENOSPC ; goto err_put_bdev; }@@ -370,11 +305,11 @@ static int __register_pstore_blk(void) psblk_bdev = bdev;memset (&dev,0 ,sizeof (dev)); - dev.total_size = binfo.nr_sects <<SECTOR_SHIFT ; + dev.total_size = nr_sects <<SECTOR_SHIFT ; dev.read = psblk_generic_blk_read; dev.write = psblk_generic_blk_write; - ret =__register_pstore_device (&dev); + ret =register_pstore_device (&dev);if (ret) goto err_put_bdev;@@ -383,10 +318,22 @@ static int __register_pstore_blk(void)return 0 ; err_put_bdev: +blkdev_put (bdev,FMODE_READ |FMODE_WRITE |FMODE_EXCL ); psblk_bdev =NULL ; -psblk_put_bdev (bdev, holder);return ret; } +late_initcall (pstore_blk_init); + +static void __exit pstore_blk_exit(void) +{ +struct pstore_device_info dev = { .read = psblk_generic_blk_read }; + +if (!psblk_bdev) +return ; +unregister_pstore_device (&dev); +blkdev_put (psblk_bdev,FMODE_READ |FMODE_WRITE |FMODE_EXCL ); +} +module_exit (pstore_blk_exit);/* get information of pstore/blk */ int pstore_blk_get_config (struct pstore_blk_config *info)@@ -402,33 +349,6 @@ int pstore_blk_get_config(struct pstore_blk_config *info) }EXPORT_SYMBOL_GPL (pstore_blk_get_config); -static int __init pstore_blk_init (void ) -{ -int ret =0 ; - -mutex_lock (&pstore_blk_lock); -if (!pstore_zone_info && best_effort && blkdev[0 ]) - ret =__register_pstore_blk (); -mutex_unlock (&pstore_blk_lock); - -return ret; -} -late_initcall (pstore_blk_init); - -static void __exit pstore_blk_exit(void) -{ -struct pstore_device_info dev = { }; - -mutex_lock (&pstore_blk_lock); -if (pstore_zone_info) - dev.read = pstore_zone_info->read; -__unregister_pstore_device (&dev); -if (psblk_bdev) -psblk_put_bdev (psblk_bdev, blkdev); -mutex_unlock (&pstore_blk_lock); -} -module_exit (pstore_blk_exit); -MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("WeiXiong Liao <[email protected]>" );MODULE_AUTHOR ("Kees Cook <[email protected]>" );Signature · 1 line
2.28.0
Signature · 1 line
Kees Cook
PATCH 6/9 pstore/zone: split struct pstore_zone_info
In reply to Christoph HellwigSplit out a new pstore_zone_ops structure for static function pointers plus the name. Also remove the unused owner field entirely.
--- drivers/mtd/mtdpstore.c | 13 +++++++---- fs/pstore/blk.c | 23 ++++++++++--------- fs/pstore/zone.c | 46 +++++++++++++++++++------------------ include/linux/pstore_blk.h | 23 ++----------------- include/linux/pstore_zone.h | 41 ++++++++++++++++++--------------- 5 files changed, 69 insertions(+), 77 deletions(-)
drivers/mtd/mtdpstore.c +9 -4
@@ -378,6 +378,14 @@ static ssize_t mtdpstore_panic_write(const char *buf, size_t size, loff_t off)return retlen; } +static const struct pstore_zone_ops mtdpstore_ops = { + .name =KBUILD_MODNAME , + .read = mtdpstore_read, + .write = mtdpstore_write, + .erase = mtdpstore_erase, + .panic_write = mtdpstore_panic_write, +}; +static void mtdpstore_notify_add (struct mtd_info *mtd) {int ret;
@@ -426,10 +434,7 @@ static void mtdpstore_notify_add(struct mtd_info *mtd) cxt->dev.total_size = mtd->size;/* just support dmesg right now */ cxt->dev.flags =PSTORE_FLAGS_DMESG ; - cxt->dev.read = mtdpstore_read; - cxt->dev.write = mtdpstore_write; - cxt->dev.erase = mtdpstore_erase; - cxt->dev.panic_write = mtdpstore_panic_write; + cxt->dev.ops = &mtdpstore_ops; ret =register_pstore_device (&cxt->dev);if (ret) {
fs/pstore/blk.c +12 -11
@@ -108,7 +108,8 @@ static int __register_pstore_device(struct pstore_device_info *dev)lockdep_assert_held (&pstore_blk_lock); -if (!dev || !dev->total_size || !dev->read || !dev->write) +if (!dev || !dev->total_size || !dev->ops || + !dev->ops->read || !dev->ops->write)return -EINVAL ;/* someone already registered before */
@@ -141,12 +142,7 @@ static int __register_pstore_device(struct pstore_device_info *dev) pstore_zone_info->total_size = dev->total_size; pstore_zone_info->max_reason = max_reason; - pstore_zone_info->read = dev->read; - pstore_zone_info->write = dev->write; - pstore_zone_info->erase = dev->erase; - pstore_zone_info->panic_write = dev->panic_write; - pstore_zone_info->name =KBUILD_MODNAME ; - pstore_zone_info->owner =THIS_MODULE ; + pstore_zone_info->ops = dev->ops; ret =register_pstore_zone (pstore_zone_info);if (ret) {
@@ -179,7 +175,7 @@ EXPORT_SYMBOL_GPL(register_pstore_device);static void __unregister_pstore_device (struct pstore_device_info *dev) {lockdep_assert_held (&pstore_blk_lock); -if (pstore_zone_info && pstore_zone_info->read == dev->read) { +if (pstore_zone_info && pstore_zone_info->ops == dev->ops) {unregister_pstore_zone (pstore_zone_info);kfree (pstore_zone_info); pstore_zone_info =NULL ;
@@ -265,6 +261,12 @@ static ssize_t psblk_generic_blk_write(const char *buf, size_t bytes,return ret; } +static const struct pstore_zone_ops pstore_blk_zone_ops = { + .name =KBUILD_MODNAME , + .read = psblk_generic_blk_read, + .write = psblk_generic_blk_write, +}; +static int __init pstore_blk_init (void ) {char bdev_name[BDEVNAME_SIZE ];
@@ -305,9 +307,8 @@ static int __init pstore_blk_init(void) psblk_bdev = bdev;memset (&dev,0 ,sizeof (dev)); + dev.ops = &pstore_blk_zone_ops; dev.total_size = nr_sects <<SECTOR_SHIFT ; - dev.read = psblk_generic_blk_read; - dev.write = psblk_generic_blk_write; ret =register_pstore_device (&dev);if (ret)
@@ -326,7 +327,7 @@ late_initcall(pstore_blk_init); static void __exit pstore_blk_exit(void) { -struct pstore_device_info dev = { .read = psblk_generic_blk_read }; +struct pstore_device_info dev = { .ops = &pstore_blk_zone_ops };if (!psblk_bdev)return ;
fs/pstore/zone.c +24 -22
148 lines not on this page · raw message
include/linux/pstore_blk.h +2 -21
@@ -15,31 +15,12 @@* @flags: Refer to macro starting with PSTORE_FLAGS defined in * linux/pstore.h. It means what front-ends this device support. * Zero means all backends for compatible. -* @read: The general read operation. Both of the function parameters -* @size and @offset are relative value to bock device (not the -* whole disk). -* On success, the number of bytes should be returned, others -* means error. -* @write: The same as @read, but the following error number: -* -EBUSY means try to write again later. -* -ENOMSG means to try next zone. -* @erase: The general erase operation for device with special removing -* job. Both of the function parameters @size and @offset are -* relative value to storage. -* Return 0 on success and others on failure. -* @panic_write:The write operation only used for panic case. It's optional -* if you do not care panic log. The parameters are relative -* value to storage. -* On success, the number of bytes should be returned, others -* excluding -ENOMSG mean error. -ENOMSG means to try next zone. +* @ops: operations to access the device. */ struct pstore_device_info {unsigned long total_size;unsigned int flags; -pstore_zone_read_op read; -pstore_zone_write_op write; -pstore_zone_erase_op erase; -pstore_zone_write_op panic_write; +const struct pstore_zone_ops *ops; };int register_pstore_device (struct pstore_device_info *dev);
include/linux/pstore_zone.h +22 -19
64 lines not on this page · raw message
Signature · 1 line
2.28.0
Re: [PATCH 6/9] pstore/zone: split struct pstore_zone_info
Quoted 4 lines · Christoph Hellwig
Split out a new
pstore_zone_opsstructure for static function pointers plus the name. Also remove the unused owner field entirely.Signed-off-by Christoph Hellwig <[email protected]>
On the face of it, this seems fine, but I don't think it's really useful to split the structure up. There's a lot of churn here.
-Kees
Quoted 386 lines
--- drivers/mtd/mtdpstore.c | 13 +++++++---- fs/pstore/blk.c | 23 ++++++++++--------- fs/pstore/zone.c | 46 +++++++++++++++++++------------------ include/linux/pstore_blk.h | 23 ++----------------- include/linux/pstore_zone.h | 41 ++++++++++++++++++--------------- 5 files changed, 69 insertions(+), 77 deletions(-)drivers/mtd/mtdpstore.c +9
-4@@ -378,6 +378,14 @@ static ssize_t mtdpstore_panic_write(const char *buf, size_t size, loff_t off)return retlen; } +static const struct pstore_zone_ops mtdpstore_ops = { + .name =KBUILD_MODNAME , + .read = mtdpstore_read, + .write = mtdpstore_write, + .erase = mtdpstore_erase, + .panic_write = mtdpstore_panic_write, +}; +static void mtdpstore_notify_add (struct mtd_info *mtd) {int ret;@@ -426,10 +434,7 @@ static void mtdpstore_notify_add(struct mtd_info *mtd) cxt->dev.total_size = mtd->size;/* just support dmesg right now */ cxt->dev.flags =PSTORE_FLAGS_DMESG ; - cxt->dev.read = mtdpstore_read; - cxt->dev.write = mtdpstore_write; - cxt->dev.erase = mtdpstore_erase; - cxt->dev.panic_write = mtdpstore_panic_write; + cxt->dev.ops = &mtdpstore_ops; ret =register_pstore_device (&cxt->dev);if (ret) {fs/pstore/blk.c +12
-11@@ -108,7 +108,8 @@ static int __register_pstore_device(struct pstore_device_info *dev)lockdep_assert_held (&pstore_blk_lock); -if (!dev || !dev->total_size || !dev->read || !dev->write) +if (!dev || !dev->total_size || !dev->ops || + !dev->ops->read || !dev->ops->write)return -EINVAL ;/* someone already registered before */ @@ -141,12 +142,7 @@ static int __register_pstore_device(struct pstore_device_info *dev) pstore_zone_info->total_size = dev->total_size; pstore_zone_info->max_reason = max_reason; - pstore_zone_info->read = dev->read; - pstore_zone_info->write = dev->write; - pstore_zone_info->erase = dev->erase; - pstore_zone_info->panic_write = dev->panic_write; - pstore_zone_info->name =KBUILD_MODNAME ; - pstore_zone_info->owner =THIS_MODULE ; + pstore_zone_info->ops = dev->ops; ret =register_pstore_zone (pstore_zone_info);if (ret) {@@ -179,7 +175,7 @@ EXPORT_SYMBOL_GPL(register_pstore_device);static void __unregister_pstore_device (struct pstore_device_info *dev) {lockdep_assert_held (&pstore_blk_lock); -if (pstore_zone_info && pstore_zone_info->read == dev->read) { +if (pstore_zone_info && pstore_zone_info->ops == dev->ops) {unregister_pstore_zone (pstore_zone_info);kfree (pstore_zone_info); pstore_zone_info =NULL ;@@ -265,6 +261,12 @@ static ssize_t psblk_generic_blk_write(const char *buf, size_t bytes,return ret; } +static const struct pstore_zone_ops pstore_blk_zone_ops = { + .name =KBUILD_MODNAME , + .read = psblk_generic_blk_read, + .write = psblk_generic_blk_write, +}; +static int __init pstore_blk_init (void ) {char bdev_name[BDEVNAME_SIZE ];@@ -305,9 +307,8 @@ static int __init pstore_blk_init(void) psblk_bdev = bdev;memset (&dev,0 ,sizeof (dev)); + dev.ops = &pstore_blk_zone_ops; dev.total_size = nr_sects <<SECTOR_SHIFT ; - dev.read = psblk_generic_blk_read; - dev.write = psblk_generic_blk_write; ret =register_pstore_device (&dev);if (ret)@@ -326,7 +327,7 @@ late_initcall(pstore_blk_init); static void __exit pstore_blk_exit(void) { -struct pstore_device_info dev = { .read = psblk_generic_blk_read }; +struct pstore_device_info dev = { .ops = &pstore_blk_zone_ops };if (!psblk_bdev)return ;fs/pstore/zone.c +24
-22@@ -218,7 +218,7 @@ static int psz_zone_write(struct pstore_zone *zone,if (!is_on_panic () && !atomic_read (&pstore_zone_cxt.recovered)) goto dirty; - writeop =is_on_panic () ? info->panic_write : info->write; + writeop =is_on_panic () ? info->ops->panic_write : info->ops->write;if (!writeop) goto dirty;@@ -337,7 +337,7 @@ static int psz_kmsg_recover_data(struct psz_context *cxt)unsigned long i;ssize_t rcnt; -if (!info->read) +if (!info->ops->read)return -EINVAL ;for (i =0 ; i < cxt->kmsg_max_cnt; i++) {@@ -360,8 +360,8 @@ static int psz_kmsg_recover_data(struct psz_context *cxt)if (!zone->should_recover)continue ; buf = zone->buffer; - rcnt = info->read ((char *)buf, zone->buffer_size +sizeof (*buf), - zone->off); + rcnt = info->ops->read ((char *)buf, zone->buffer_size + +sizeof (*buf), zone->off);if (rcnt != zone->buffer_size +sizeof (*buf))return (int )rcnt <0 ? (int )rcnt : -EIO ; }@@ -383,7 +383,7 @@ static int psz_kmsg_recover_meta(struct psz_context *cxt)*/ char buffer_header[sizeof (*buf) +sizeof (*hdr)] = {0 }; -if (!info->read) +if (!info->ops->read)return -EINVAL ; len =sizeof (*buf) +sizeof (*hdr);@@ -393,13 +393,14 @@ static int psz_kmsg_recover_meta(struct psz_context *cxt)if (unlikely (!zone))return -EINVAL ; - rcnt = info->read ((char *)buf, len, zone->off); + rcnt = info->ops->read ((char *)buf, len, zone->off);if (rcnt == -ENOMSG ) {pr_debug ("%s with id %lu may be broken, skip\n" , zone->name, i);continue ; }else if (rcnt != len) { -pr_err ("read %s with id %lu failed\n" , zone->name, i); +pr_err ("read %s with id %lu failed\n" , zone->name, + i);return (int )rcnt <0 ? (int )rcnt : -EIO ; }@@ -495,11 +496,11 @@ static int psz_recover_zone(struct psz_context *cxt, struct pstore_zone *zone)return 0 ; } -if (unlikely (!info->read)) +if (unlikely (!info->ops->read))return -EINVAL ; len =sizeof (struct psz_buffer ); - rcnt = info->read ((char *)&tmpbuf, len, zone->off); + rcnt = info->ops->read ((char *)&tmpbuf, len, zone->off);if (rcnt != len) {pr_debug ("read zone %s failed\n" , zone->name);return (int )rcnt <0 ? (int )rcnt : -EIO ;@@ -541,7 +542,7 @@ static int psz_recover_zone(struct psz_context *cxt, struct pstore_zone *zone) off = zone->off +sizeof (*oldbuf);/* get part of data */ - rcnt = info->read (buf, len - start, off + start); + rcnt = info->ops->read (buf, len - start, off + start);if (rcnt != len - start) {pr_err ("read zone %s failed\n" , zone->name); ret = (int )rcnt <0 ? (int )rcnt : -EIO ;@@ -549,7 +550,7 @@ static int psz_recover_zone(struct psz_context *cxt, struct pstore_zone *zone) }/* get the rest of data */ - rcnt = info->read (buf + len - start, start, off); + rcnt = info->ops->read (buf + len - start, start, off);if (rcnt != start) {pr_err ("read zone %s failed\n" , zone->name); ret = (int )rcnt <0 ? (int )rcnt : -EIO ;@@ -671,8 +672,8 @@ static inline int psz_kmsg_erase(struct psz_context *cxt, size =buffer_datalen (zone) +sizeof (*zone->buffer);atomic_set (&zone->buffer->datalen,0 ); -if (cxt->pstore_zone_info->erase) -return cxt->pstore_zone_info->erase (size, zone->off); +if (cxt->pstore_zone_info->ops->erase) +return cxt->pstore_zone_info->ops->erase (size, zone->off);else return psz_zone_write (zone,FLUSH_META ,NULL ,0 ,0 ); }@@ -1185,8 +1186,9 @@ static struct pstore_zone *psz_init_zone(enum pstore_type_id type, *off += size; -pr_debug ("pszone %s: off 0x%llx, %zu header, %zu data\n" , zone->name, - zone->off,sizeof (*zone->buffer), zone->buffer_size); +pr_debug ("pszone %s: off 0x%llx, %zu header, %zu data\n" , + zone->name, zone->off,sizeof (*zone->buffer), + zone->buffer_size);return zone; }@@ -1310,7 +1312,7 @@ int register_pstore_zone(struct pstore_zone_info *info)return -EINVAL ; } -if (!info->name || !info->name[0 ]) +if (!info->ops->name || !info->ops->name[0 ])return -EINVAL ;#define check_size (name, size) { \@@ -1338,7 +1340,7 @@ int register_pstore_zone(struct pstore_zone_info *info)* if no @read, pstore may mount failed. * if no @write, pstore do not support to remove record file. */ -if (!info->read || !info->write) { +if (!info->ops || !info->ops->read || !info->ops->write) {pr_err ("no valid general read/write interface\n" );return -EINVAL ; }@@ -1346,13 +1348,13 @@ int register_pstore_zone(struct pstore_zone_info *info)mutex_lock (&cxt->pstore_zone_info_lock);if (cxt->pstore_zone_info) {pr_warn ("'%s' already loaded: ignoring '%s'\n" , - cxt->pstore_zone_info->name, info->name); + cxt->pstore_zone_info->ops->name, info->ops->name);mutex_unlock (&cxt->pstore_zone_info_lock);return -EBUSY ; } cxt->pstore_zone_info = info; -pr_debug ("register %s with properties:\n" , info->name); +pr_debug ("register %s with properties:\n" , info->ops->name);pr_debug ("\ttotal size : %ld Bytes\n" , info->total_size);pr_debug ("\tkmsg size : %ld Bytes\n" , info->kmsg_size);pr_debug ("\tpmsg size : %ld Bytes\n" , info->pmsg_size);@@ -1376,14 +1378,14 @@ int register_pstore_zone(struct pstore_zone_info *info) } cxt->pstore.data = cxt; -pr_info ("registered %s as backend for" , info->name); +pr_info ("registered %s as backend for" , info->ops->name); cxt->pstore.max_reason = info->max_reason; - cxt->pstore.name = info->name; + cxt->pstore.name = info->ops->name;if (info->kmsg_size) { cxt->pstore.flags |=PSTORE_FLAGS_DMESG ;pr_cont (" kmsg(%s" ,kmsg_dump_reason_str (cxt->pstore.max_reason)); -if (cxt->pstore_zone_info->panic_write) +if (cxt->pstore_zone_info->ops->panic_write)pr_cont (",panic_write" );pr_cont (")" ); }include/linux/pstore_blk.h +2
-21@@ -15,31 +15,12 @@* @flags: Refer to macro starting with PSTORE_FLAGS defined in * linux/pstore.h. It means what front-ends this device support. * Zero means all backends for compatible. -* @read: The general read operation. Both of the function parameters -* @size and @offset are relative value to bock device (not the -* whole disk). -* On success, the number of bytes should be returned, others -* means error. -* @write: The same as @read, but the following error number: -* -EBUSY means try to write again later. -* -ENOMSG means to try next zone. -* @erase: The general erase operation for device with special removing -* job. Both of the function parameters @size and @offset are -* relative value to storage. -* Return 0 on success and others on failure. -* @panic_write:The write operation only used for panic case. It's optional -* if you do not care panic log. The parameters are relative -* value to storage. -* On success, the number of bytes should be returned, others -* excluding -ENOMSG mean error. -ENOMSG means to try next zone. +* @ops: operations to access the device. */ struct pstore_device_info {unsigned long total_size;unsigned int flags; -pstore_zone_read_op read; -pstore_zone_write_op write; -pstore_zone_erase_op erase; -pstore_zone_write_op panic_write; +const struct pstore_zone_ops *ops; };int register_pstore_device (struct pstore_device_info *dev);include/linux/pstore_zone.h +22
-19@@ -5,22 +5,10 @@#include <linux/types.h> -typedef ssize_t (*pstore_zone_read_op )(char *,size_t ,loff_t ); -typedef ssize_t (*pstore_zone_write_op )(const char *,size_t ,loff_t ); -typedef ssize_t (*pstore_zone_erase_op )(size_t ,loff_t );/** -* struct pstore_zone_info - pstore/zone back-end driver structure +* struct pstore_zone_ops - pstore/zone ops structure * -* @owner: Module which is responsible for this back-end driver. * @name: Name of the back-end driver. -* @total_size: The total size in bytes pstore/zone can use. It must be greater -* than 4096 and be multiple of 4096. -* @kmsg_size: The size of oops/panic zone. Zero means disabled, otherwise, -* it must be multiple of SECTOR_SIZE(512 Bytes). -* @max_reason: Maximum kmsg dump reason to store. -* @pmsg_size: The size of pmsg zone which is the same as @kmsg_size. -* @console_size:The size of console zone which is the same as @kmsg_size. -* @ftrace_size:The size of ftrace zone which is the same as @kmsg_size. * @read: The general read operation. Both of the function parameters * @size and @offset are relative value to storage. * On success, the number of bytes should be returned, others @@ -38,20 +26,35 @@ typedef ssize_t (*pstore_zone_erase_op)(size_t, loff_t);* On success, the number of bytes should be returned, others * excluding -ENOMSG mean error. -ENOMSG means to try next zone. */ -struct pstore_zone_info { -struct module *owner; +struct pstore_zone_ops {const char *name; +ssize_t (*read)(char *buf,size_t count,loff_t pos); +ssize_t (*write)(const char *buf,size_t bytes,loff_t pos); +ssize_t (*erase)(size_t byes,loff_t pos); +ssize_t (*panic_write)(const char *buf,size_t bytes,loff_t pos); +}; +/** +* struct pstore_zone_info - pstore/zone back-end driver structure +* +* @ops: Operations to access the zone. +* @total_size: The total size in bytes pstore/zone can use. It must be greater +* than 4096 and be multiple of 4096. +* @kmsg_size: The size of oops/panic zone. Zero means disabled, otherwise, +* it must be multiple of SECTOR_SIZE(512 Bytes). +* @max_reason: Maximum kmsg dump reason to store. +* @pmsg_size: The size of pmsg zone which is the same as @kmsg_size. +* @console_size:The size of console zone which is the same as @kmsg_size. +* @ftrace_size:The size of ftrace zone which is the same as @kmsg_size. +*/ +struct pstore_zone_info { +const struct pstore_zone_ops *ops;unsigned long total_size;unsigned long kmsg_size;int max_reason;unsigned long pmsg_size;unsigned long console_size;unsigned long ftrace_size; -pstore_zone_read_op read; -pstore_zone_write_op write; -pstore_zone_erase_op erase; -pstore_zone_write_op panic_write; };extern int register_pstore_zone (struct pstore_zone_info *info);Signature · 1 line
2.28.0
Signature · 1 line
Kees Cook
PATCH 7/9 pstore/blk: remove struct pstore_device_info
In reply to Christoph HellwigThe total_size and flags are only needed at registrations time, so just pass them to register_pstore_device directly.
--- drivers/mtd/mtdpstore.c | 10 ++-- fs/pstore/blk.c | 98 ++++++++++++++++---------------------- include/linux/pstore_blk.h | 21 ++------ 3 files changed, 47 insertions(+), 82 deletions(-)
drivers/mtd/mtdpstore.c +3 -7
@@ -12,7 +12,6 @@ static struct mtdpstore_context { int index; struct pstore_blk_config info; - struct pstore_device_info dev; struct mtd_info *mtd; unsigned long *rmmap; /* removed bit map */ unsigned long *usedmap; /* used bit map */
@@ -431,12 +430,9 @@ static void mtdpstore_notify_add(struct mtd_info *mtd) longcnt =BITS_TO_LONGS (div_u64 (mtd->size, mtd->erasesize)); cxt->badmap =kcalloc (longcnt,sizeof (long ),GFP_KERNEL ); - cxt->dev.total_size = mtd->size;/* just support dmesg right now */ - cxt->dev.flags =PSTORE_FLAGS_DMESG ; - cxt->dev.ops = &mtdpstore_ops; - - ret =register_pstore_device (&cxt->dev); + ret =register_pstore_device (&mtdpstore_ops, mtd->size, +PSTORE_FLAGS_DMESG );if (ret) {dev_err (&mtd->dev,"mtd%d register to psblk failed\n" , mtd->index);
@@ -531,7 +527,7 @@ static void mtdpstore_notify_remove(struct mtd_info *mtd)mtdpstore_flush_removed (cxt); -unregister_pstore_device (&cxt->dev); +unregister_pstore_device (&mtdpstore_ops);kfree (cxt->badmap);kfree (cxt->usedmap);kfree (cxt->rmmap);
fs/pstore/blk.c +41 -57
160 lines not on this page · raw message
include/linux/pstore_blk.h +3 -18
@@ -7,24 +7,9 @@#include <linux/pstore.h> #include <linux/pstore_zone.h> -/** -* struct pstore_device_info - back-end pstore/blk driver structure. -* -* @total_size: The total size in bytes pstore/blk can use. It must be greater -* than 4096 and be multiple of 4096. -* @flags: Refer to macro starting with PSTORE_FLAGS defined in -* linux/pstore.h. It means what front-ends this device support. -* Zero means all backends for compatible. -* @ops: operations to access the device. -*/ -struct pstore_device_info { -unsigned long total_size; -unsigned int flags; -const struct pstore_zone_ops *ops; -}; - -int register_pstore_device (struct pstore_device_info *dev); -void unregister_pstore_device (struct pstore_device_info *dev); +int register_pstore_device (const struct pstore_zone_ops *ops, +unsigned long total_size,unsigned int flags); +void unregister_pstore_device (const struct pstore_zone_ops *ops);/** * struct pstore_blk_config - the pstore_blk backend configuration
Signature · 1 line
2.28.0
Re: [PATCH 7/9] pstore/blk: remove struct pstore_device_info
Quoted 4 lines · Christoph Hellwig
The
total_sizeand flags are only needed at registrations time, so just pass them toregister_pstore_devicedirectly.Signed-off-by Christoph Hellwig <[email protected]>
Full NAK on this -- pstore was mess of function argument passing, and I vowed to pass everything in structures after I finally cleaned all of that up. I don't want anything that looks like this getting back into the pstore code.
-Kees
Quoted 246 lines
--- drivers/mtd/mtdpstore.c | 10 ++-- fs/pstore/blk.c | 98 ++++++++++++++++---------------------- include/linux/pstore_blk.h | 21 ++------ 3 files changed, 47 insertions(+), 82 deletions(-)drivers/mtd/mtdpstore.c +3
-7@@ -12,7 +12,6 @@ static struct mtdpstore_context { int index; struct pstore_blk_config info; - struct pstore_device_info dev; struct mtd_info *mtd; unsigned long *rmmap; /* removed bit map */ unsigned long *usedmap; /* used bit map */@@ -431,12 +430,9 @@ static void mtdpstore_notify_add(struct mtd_info *mtd) longcnt =BITS_TO_LONGS (div_u64 (mtd->size, mtd->erasesize)); cxt->badmap =kcalloc (longcnt,sizeof (long ),GFP_KERNEL ); - cxt->dev.total_size = mtd->size;/* just support dmesg right now */ - cxt->dev.flags =PSTORE_FLAGS_DMESG ; - cxt->dev.ops = &mtdpstore_ops; - - ret =register_pstore_device (&cxt->dev); + ret =register_pstore_device (&mtdpstore_ops, mtd->size, +PSTORE_FLAGS_DMESG );if (ret) {dev_err (&mtd->dev,"mtd%d register to psblk failed\n" , mtd->index);@@ -531,7 +527,7 @@ static void mtdpstore_notify_remove(struct mtd_info *mtd)mtdpstore_flush_removed (cxt); -unregister_pstore_device (&cxt->dev); +unregister_pstore_device (&mtdpstore_ops);kfree (cxt->badmap);kfree (cxt->usedmap);kfree (cxt->rmmap);fs/pstore/blk.c +41
-57@@ -102,27 +102,40 @@ static struct pstore_zone_info *pstore_zone_info; _##name_; \ }) -static int __register_pstore_device (struct pstore_device_info *dev) +/** +* register_pstore_device() - register device to pstore/blk +* +* @ops: operations to access the device. +* @total_size: The total size in bytes pstore/blk can use. It must be greater +* than 4096 and be multiple of 4096. +* @flags: Refer to macro starting with PSTORE_FLAGS defined in +* linux/pstore.h. It means what front-ends this device support. +* Zero means all backends for compatible. +*/ +int register_pstore_device (const struct pstore_zone_ops *ops, +unsigned long total_size,unsigned int flags) {int ret; -lockdep_assert_held (&pstore_blk_lock); - -if (!dev || !dev->total_size || !dev->ops || - !dev->ops->read || !dev->ops->write) +if (!ops || !ops->read || !ops->write || !total_size)return -EINVAL ;/* someone already registered before */ -if (pstore_zone_info) -return -EBUSY ; +mutex_lock (&pstore_blk_lock); +if (pstore_zone_info) { + ret = -EBUSY ; + goto out_unlock; + } pstore_zone_info =kzalloc (sizeof (struct pstore_zone_info ),GFP_KERNEL ); -if (!pstore_zone_info) -return -ENOMEM ; +if (!pstore_zone_info) { + ret = -ENOMEM ; + goto out_unlock; + }/* zero means not limit on which backends to attempt to store. */ -if (!dev->flags) - dev->flags =UINT_MAX ; +if (!flags) + flags =UINT_MAX ;#define verify_size (name, alignsize, enabled) { \ long _##name_; \@@ -134,63 +147,40 @@ static int __register_pstore_device(struct pstore_device_info *dev) pstore_zone_info->name = _##name_; \ } -verify_size (kmsg_size,4096 , dev->flags &PSTORE_FLAGS_DMESG ); -verify_size (pmsg_size,4096 , dev->flags &PSTORE_FLAGS_PMSG ); -verify_size (console_size,4096 , dev->flags &PSTORE_FLAGS_CONSOLE ); -verify_size (ftrace_size,4096 , dev->flags &PSTORE_FLAGS_FTRACE ); +verify_size (kmsg_size,4096 , flags &PSTORE_FLAGS_DMESG ); +verify_size (pmsg_size,4096 , flags &PSTORE_FLAGS_PMSG ); +verify_size (console_size,4096 , flags &PSTORE_FLAGS_CONSOLE ); +verify_size (ftrace_size,4096 , flags &PSTORE_FLAGS_FTRACE );#undef verify_size - pstore_zone_info->total_size = dev->total_size; + pstore_zone_info->total_size = total_size; pstore_zone_info->max_reason = max_reason; - pstore_zone_info->ops = dev->ops; + pstore_zone_info->ops = ops; ret =register_pstore_zone (pstore_zone_info);if (ret) {kfree (pstore_zone_info); pstore_zone_info =NULL ; } +out_unlock: +mutex_unlock (&pstore_blk_lock);return ret; } +EXPORT_SYMBOL_GPL (register_pstore_device); +/** -* register_pstore_device() - register non-block device to pstore/blk -* -* @dev: non-block device information +* unregister_pstore_device() - unregister a device from pstore/blk * -* Return: -* * 0 - OK -* * Others - something error. +* @ops: device operations */ -int register_pstore_device (struct pstore_device_info *dev) +void unregister_pstore_device (const struct pstore_zone_ops *ops) { -int ret; -mutex_lock (&pstore_blk_lock); - ret =__register_pstore_device (dev); -mutex_unlock (&pstore_blk_lock); - -return ret; -} -EXPORT_SYMBOL_GPL (register_pstore_device); - -static void __unregister_pstore_device (struct pstore_device_info *dev) -{ -lockdep_assert_held (&pstore_blk_lock); -if (pstore_zone_info && pstore_zone_info->ops == dev->ops) { +if (pstore_zone_info && pstore_zone_info->ops == ops) {unregister_pstore_zone (pstore_zone_info);kfree (pstore_zone_info); pstore_zone_info =NULL ; } -} - -/** -* unregister_pstore_device() - unregister non-block device from pstore/blk -* -* @dev: non-block device information -*/ -void unregister_pstore_device (struct pstore_device_info *dev) -{ -mutex_lock (&pstore_blk_lock); -__unregister_pstore_device (dev);mutex_unlock (&pstore_blk_lock); }EXPORT_SYMBOL_GPL (unregister_pstore_device);@@ -271,7 +261,6 @@ static int __init pstore_blk_init(void) {char bdev_name[BDEVNAME_SIZE ];struct block_device *bdev; -struct pstore_device_info dev;int ret = -ENODEV ;fmode_t mode =FMODE_READ |FMODE_WRITE |FMODE_EXCL ;sector_t nr_sects;@@ -306,11 +295,8 @@ static int __init pstore_blk_init(void)/* psblk_bdev must be assigned before register to pstore/blk */ psblk_bdev = bdev; -memset (&dev,0 ,sizeof (dev)); - dev.ops = &pstore_blk_zone_ops; - dev.total_size = nr_sects <<SECTOR_SHIFT ; - - ret =register_pstore_device (&dev); + ret =register_pstore_device (&pstore_blk_zone_ops, + nr_sects <<SECTOR_SHIFT ,0 );if (ret) goto err_put_bdev;@@ -327,11 +313,9 @@ late_initcall(pstore_blk_init); static void __exit pstore_blk_exit(void) { -struct pstore_device_info dev = { .ops = &pstore_blk_zone_ops }; -if (!psblk_bdev)return ; -unregister_pstore_device (&dev); +unregister_pstore_device (&pstore_blk_zone_ops);blkdev_put (psblk_bdev,FMODE_READ |FMODE_WRITE |FMODE_EXCL ); }module_exit (pstore_blk_exit);include/linux/pstore_blk.h +3
-18@@ -7,24 +7,9 @@#include <linux/pstore.h> #include <linux/pstore_zone.h> -/** -* struct pstore_device_info - back-end pstore/blk driver structure. -* -* @total_size: The total size in bytes pstore/blk can use. It must be greater -* than 4096 and be multiple of 4096. -* @flags: Refer to macro starting with PSTORE_FLAGS defined in -* linux/pstore.h. It means what front-ends this device support. -* Zero means all backends for compatible. -* @ops: operations to access the device. -*/ -struct pstore_device_info { -unsigned long total_size; -unsigned int flags; -const struct pstore_zone_ops *ops; -}; - -int register_pstore_device (struct pstore_device_info *dev); -void unregister_pstore_device (struct pstore_device_info *dev); +int register_pstore_device (const struct pstore_zone_ops *ops, +unsigned long total_size,unsigned int flags); +void unregister_pstore_device (const struct pstore_zone_ops *ops);/** * struct pstore_blk_config - the pstore_blk backend configuration Signature · 1 line
2.28.0
Signature · 5 lines
Kees Cook ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 8/9 pstore/blk: use the normal block device I/O path
In reply to Christoph HellwigStop poking into block layer internals and just open the block device file an use kernel_read and kernel_write on it. Note that this means the transformation from name_to_dev_t can't be used anymore, and proper block device file names must be used.
--- fs/pstore/blk.c | 152 +++++++++++++------------------------ include/linux/pstore_blk.h | 2 + init/main.c | 4 + 3 files changed, 57 insertions(+), 101 deletions(-)
fs/pstore/blk.c +51 -101
@@ -8,15 +8,13 @@#include <linux/kernel.h> #include <linux/module.h> -#include "../../block/blk.h" #include <linux/blkdev.h> #include <linux/string.h> -#include <linux/of.h> -#include <linux/of_address.h> -#include <linux/platform_device.h> #include <linux/pstore_blk.h> +#include <linux/fs.h> +#include <linux/file.h> +#include <linux/init_syscalls.h> #include <linux/mount.h> -#include <linux/uio.h> static long kmsg_size =CONFIG_PSTORE_BLK_KMSG_SIZE ;module_param (kmsg_size, long,0400 );
@@ -88,7 +86,6 @@ MODULE_PARM_DESC(blkdev, "block device for pstore storage");* during the register/unregister functions. */ static DEFINE_MUTEX (pstore_blk_lock); -static struct block_device *psblk_bdev;static struct pstore_zone_info *pstore_zone_info;#define check_size (name, alignsize) ({ \
@@ -185,70 +182,20 @@ void unregister_pstore_device(const struct pstore_zone_ops *ops) }EXPORT_SYMBOL_GPL (unregister_pstore_device); +static struct file *psblk_file; +static ssize_t psblk_generic_blk_read (char *buf,size_t bytes,loff_t pos) { -struct block_device *bdev = psblk_bdev; -struct file file; -struct kiocb kiocb; -struct iov_iter iter; -struct kvec iov = {.iov_base = buf, .iov_len = bytes}; - -if (!bdev) -return -ENODEV ; - -memset (&file,0 ,sizeof (struct file )); - file.f_mapping = bdev->bd_inode->i_mapping; - file.f_flags =O_DSYNC | __O_SYNC |O_NOATIME ; - file.f_inode = bdev->bd_inode; -file_ra_state_init (&file.f_ra, file.f_mapping); - -init_sync_kiocb (&kiocb, &file); - kiocb.ki_pos = pos; -iov_iter_kvec (&iter,READ , &iov,1 , bytes); - -return generic_file_read_iter (&kiocb, &iter); +return kernel_read (psblk_file, buf, bytes, &pos); }static ssize_t psblk_generic_blk_write (const char *buf,size_t bytes,loff_t pos) { -struct block_device *bdev = psblk_bdev; -struct iov_iter iter; -struct kiocb kiocb; -struct file file; -ssize_t ret; -struct kvec iov = {.iov_base = (void *)buf, .iov_len = bytes}; - -if (!bdev) -return -ENODEV ; -/* Console/Ftrace backend may handle buffer until flush dirty zones */ if (in_interrupt () ||irqs_disabled ())return -EBUSY ; - -memset (&file,0 ,sizeof (struct file )); - file.f_mapping = bdev->bd_inode->i_mapping; - file.f_flags =O_DSYNC | __O_SYNC |O_NOATIME ; - file.f_inode = bdev->bd_inode; - -init_sync_kiocb (&kiocb, &file); - kiocb.ki_pos = pos; -iov_iter_kvec (&iter,WRITE , &iov,1 , bytes); - -inode_lock (bdev->bd_inode); - ret =generic_write_checks (&kiocb, &iter); -if (ret >0 ) - ret =generic_perform_write (&file, &iter, pos); -inode_unlock (bdev->bd_inode); - -if (likely (ret >0 )) { -const struct file_operations f_op = {.fsync = blkdev_fsync}; - - file.f_op = &f_op; - kiocb.ki_pos += ret; - ret =generic_write_sync (&kiocb, ret); - } -return ret; +return kernel_write (psblk_file, buf, bytes, &pos); }static const struct pstore_zone_ops pstore_blk_zone_ops = {
@@ -257,68 +204,71 @@ static const struct pstore_zone_ops pstore_blk_zone_ops = { .write = psblk_generic_blk_write, }; -static int __init pstore_blk_init (void ) +static int __init __pstore_blk_init (const char *name) { -char bdev_name[BDEVNAME_SIZE ]; -struct block_device *bdev; -int ret = -ENODEV ; -fmode_t mode =FMODE_READ |FMODE_WRITE |FMODE_EXCL ; -sector_t nr_sects; - +int ret = -EINVAL ; +if (!best_effort || !blkdev[0 ])return 0 ; -/* hold bdev exclusively */ - bdev =blkdev_get_by_path (blkdev, mode, blkdev); -if (IS_ERR (bdev)) { -dev_t devt; - - devt =name_to_dev_t (blkdev); -if (devt ==0 ) { -pr_err ("failed to open '%s'!\n" , blkdev); -return -ENODEV ; - } - bdev =blkdev_get_by_dev (devt, mode, blkdev); -if (IS_ERR (bdev)) { -pr_err ("failed to open '%s'!\n" , blkdev); -return PTR_ERR (bdev); - } + psblk_file =filp_open (name,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" , name, ret); + goto out; } - - nr_sects =part_nr_sects_read (bdev->bd_part); -if (!nr_sects) { -pr_err ("not enough space for '%s'\n" , blkdev); - ret = -ENOSPC ; - goto err_put_bdev; +if (!S_ISBLK (file_inode (psblk_file)->i_mode)) { +pr_err ("'%s' is not block device!\n" , blkdev); + goto out_fput; } -/* psblk_bdev must be assigned before register to pstore/blk */ - psblk_bdev = bdev; - ret =register_pstore_device (&pstore_blk_zone_ops, - nr_sects <<SECTOR_SHIFT ,0 ); +file_inode (psblk_file)->i_bdev->bd_inode->i_size,0 );if (ret) - goto err_put_bdev; + goto out_fput; -bdevname (bdev, bdev_name); -pr_info ("attached %s (no dedicated panic_write!)\n" , bdev_name); +pr_info ("using device '%s'\n" , blkdev);return 0 ; - -err_put_bdev: -blkdev_put (bdev,FMODE_READ |FMODE_WRITE |FMODE_EXCL ); - psblk_bdev =NULL ; +out_fput: +fput (psblk_file); +out: + psblk_file =NULL ;return ret; } + +#ifdef MODULE +static int __init pstore_blk_init (void ) +{ +return __pstore_blk_init (blkdev); +}late_initcall (pstore_blk_init); static void __exit pstore_blk_exit(void) { -if (!psblk_bdev) +if (!psblk_file)return ;unregister_pstore_device (&pstore_blk_zone_ops); -blkdev_put (psblk_bdev,FMODE_READ |FMODE_WRITE |FMODE_EXCL ); +fput (psblk_file); }module_exit (pstore_blk_exit); +#else /* MODULE */ +/* +* During early boot the real root file system hasn't been mounted yet, +* and not device nodes are present yet. Use the same scheme to find +* the device that we use for mounting the root file system. +*/ +void __init pstore_blk_early_init (void ) +{ +const char devname[] ="/dev/pstore-blk" ; +dev_t dev =name_to_dev_t (blkdev); + +if (!dev) +return ; +init_unlink (devname); +init_mknod (devname,S_IFBLK |0600 ,new_encode_dev (dev)); +__pstore_blk_init (devname); +} +#endif /* MODULE */ /* get information of pstore/blk */ int pstore_blk_get_config (struct pstore_blk_config *info)
include/linux/pstore_blk.h +2 -0
@@ -39,4 +39,6 @@ struct pstore_blk_config {*/ int pstore_blk_get_config (struct pstore_blk_config *info); +void __init pstore_blk_early_init (void ); +#endif
init/main.c +4 -0
@@ -98,6 +98,7 @@#include <linux/mem_encrypt.h> #include <linux/kcsan.h> #include <linux/init_syscalls.h> +#include <linux/pstore_blk.h> #include <asm/io.h> #include <asm/bugs.h>
@@ -1524,6 +1525,9 @@ static noinline void __init kernel_init_freeable(void)prepare_namespace (); } +if (IS_BUILTIN (CONFIG_PSTORE_BLK )) +pstore_blk_early_init (); +/* * Ok, we have completed the initial bootup, and * we're essentially up and running. Get rid of the
Signature · 1 line
2.28.0
Re: [PATCH 8/9] pstore/blk: use the normal block device I/O path
Quoted 217 lines · Christoph Hellwig
Stop poking into block layer internals and just open the block device file an use
kernel_readandkernel_writeon it. Note that this means the transformation fromname_to_dev_tcan't be used anymore, and proper block device file names must be used.Signed-off-by Christoph Hellwig <[email protected]>--- fs/pstore/blk.c | 152 +++++++++++++------------------------ include/linux/pstore_blk.h | 2 + init/main.c | 4 + 3 files changed, 57 insertions(+), 101 deletions(-)fs/pstore/blk.c +39
-101@@ -8,15 +8,13 @@#include <linux/kernel.h> #include <linux/module.h> -#include "../../block/blk.h" #include <linux/blkdev.h> #include <linux/string.h> -#include <linux/of.h> -#include <linux/of_address.h> -#include <linux/platform_device.h> #include <linux/pstore_blk.h> +#include <linux/fs.h> +#include <linux/file.h> +#include <linux/init_syscalls.h> #include <linux/mount.h> -#include <linux/uio.h> static long kmsg_size =CONFIG_PSTORE_BLK_KMSG_SIZE ;module_param (kmsg_size, long,0400 );@@ -88,7 +86,6 @@ MODULE_PARM_DESC(blkdev, "block device for pstore storage");* during the register/unregister functions. */ static DEFINE_MUTEX (pstore_blk_lock); -static struct block_device *psblk_bdev;static struct pstore_zone_info *pstore_zone_info;#define check_size (name, alignsize) ({ \@@ -185,70 +182,20 @@ void unregister_pstore_device(const struct pstore_zone_ops *ops) }EXPORT_SYMBOL_GPL (unregister_pstore_device); +static struct file *psblk_file; +static ssize_t psblk_generic_blk_read (char *buf,size_t bytes,loff_t pos) { -struct block_device *bdev = psblk_bdev; -struct file file; -struct kiocb kiocb; -struct iov_iter iter; -struct kvec iov = {.iov_base = buf, .iov_len = bytes}; - -if (!bdev) -return -ENODEV ; - -memset (&file,0 ,sizeof (struct file )); - file.f_mapping = bdev->bd_inode->i_mapping; - file.f_flags =O_DSYNC | __O_SYNC |O_NOATIME ; - file.f_inode = bdev->bd_inode; -file_ra_state_init (&file.f_ra, file.f_mapping); - -init_sync_kiocb (&kiocb, &file); - kiocb.ki_pos = pos; -iov_iter_kvec (&iter,READ , &iov,1 , bytes); - -return generic_file_read_iter (&kiocb, &iter); +return kernel_read (psblk_file, buf, bytes, &pos); }static ssize_t psblk_generic_blk_write (const char *buf,size_t bytes,loff_t pos) { -struct block_device *bdev = psblk_bdev; -struct iov_iter iter; -struct kiocb kiocb; -struct file file; -ssize_t ret; -struct kvec iov = {.iov_base = (void *)buf, .iov_len = bytes}; - -if (!bdev) -return -ENODEV ; -/* Console/Ftrace backend may handle buffer until flush dirty zones */ if (in_interrupt () ||irqs_disabled ())return -EBUSY ; - -memset (&file,0 ,sizeof (struct file )); - file.f_mapping = bdev->bd_inode->i_mapping; - file.f_flags =O_DSYNC | __O_SYNC |O_NOATIME ; - file.f_inode = bdev->bd_inode; - -init_sync_kiocb (&kiocb, &file); - kiocb.ki_pos = pos; -iov_iter_kvec (&iter,WRITE , &iov,1 , bytes); - -inode_lock (bdev->bd_inode); - ret =generic_write_checks (&kiocb, &iter); -if (ret >0 ) - ret =generic_perform_write (&file, &iter, pos); -inode_unlock (bdev->bd_inode); - -if (likely (ret >0 )) { -const struct file_operations f_op = {.fsync = blkdev_fsync}; - - file.f_op = &f_op; - kiocb.ki_pos += ret; - ret =generic_write_sync (&kiocb, ret); - } -return ret; +return kernel_write (psblk_file, buf, bytes, &pos); }static const struct pstore_zone_ops pstore_blk_zone_ops = {@@ -257,68 +204,71 @@ static const struct pstore_zone_ops pstore_blk_zone_ops = { .write = psblk_generic_blk_write, }; -static int __init pstore_blk_init (void ) +static int __init __pstore_blk_init (const char *name) { -char bdev_name[BDEVNAME_SIZE ]; -struct block_device *bdev; -int ret = -ENODEV ; -fmode_t mode =FMODE_READ |FMODE_WRITE |FMODE_EXCL ; -sector_t nr_sects; - +int ret = -EINVAL ; +if (!best_effort || !blkdev[0 ])return 0 ; -/* hold bdev exclusively */ - bdev =blkdev_get_by_path (blkdev, mode, blkdev); -if (IS_ERR (bdev)) { -dev_t devt; - - devt =name_to_dev_t (blkdev); -if (devt ==0 ) { -pr_err ("failed to open '%s'!\n" , blkdev); -return -ENODEV ; - } - bdev =blkdev_get_by_dev (devt, mode, blkdev); -if (IS_ERR (bdev)) { -pr_err ("failed to open '%s'!\n" , blkdev); -return PTR_ERR (bdev); - } + psblk_file =filp_open (name,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" , name, ret); + goto out; } - - nr_sects =part_nr_sects_read (bdev->bd_part); -if (!nr_sects) { -pr_err ("not enough space for '%s'\n" , blkdev); - ret = -ENOSPC ; - goto err_put_bdev; +if (!S_ISBLK (file_inode (psblk_file)->i_mode)) { +pr_err ("'%s' is not block device!\n" , blkdev); + goto out_fput; } -/* psblk_bdev must be assigned before register to pstore/blk */ - psblk_bdev = bdev; - ret =register_pstore_device (&pstore_blk_zone_ops, - nr_sects <<SECTOR_SHIFT ,0 ); +file_inode (psblk_file)->i_bdev->bd_inode->i_size,0 );if (ret) - goto err_put_bdev; + goto out_fput; -bdevname (bdev, bdev_name); -pr_info ("attached %s (no dedicated panic_write!)\n" , bdev_name); +pr_info ("using device '%s'\n" , blkdev);return 0 ; - -err_put_bdev: -blkdev_put (bdev,FMODE_READ |FMODE_WRITE |FMODE_EXCL ); - psblk_bdev =NULL ; +out_fput: +fput (psblk_file); +out: + psblk_file =NULL ;return ret; } + +#ifdef MODULE +static int __init pstore_blk_init (void ) +{ +return __pstore_blk_init (blkdev); +}late_initcall (pstore_blk_init); static void __exit pstore_blk_exit(void) { -if (!psblk_bdev) +if (!psblk_file)return ;unregister_pstore_device (&pstore_blk_zone_ops); -blkdev_put (psblk_bdev,FMODE_READ |FMODE_WRITE |FMODE_EXCL ); +fput (psblk_file); }module_exit (pstore_blk_exit); +#else /* MODULE */ +/* +* During early boot the real root file system hasn't been mounted yet, +* and not device nodes are present yet. Use the same scheme to find +* the device that we use for mounting the root file system. +*/
fs/pstore/blk.c static const struct pstore_zone_ops pstore_blk_zone_ops = { · line 269
Quoted 10 lines
fs/pstore/blk.c +10
-0+void __init pstore_blk_early_init (void ) +{ +const char devname[] ="/dev/pstore-blk" ; +dev_t dev =name_to_dev_t (blkdev); + +if (!dev) +return ; +init_unlink (devname); +init_mknod (devname,S_IFBLK |0600 ,new_encode_dev (dev)); +__pstore_blk_init (devname);
How about pstore/blk making /dev/pstore-blk node no matter build-in or module. Then pstore/blk always opens /dev/pstore-blk. By this way, blkdev can also be a device number if pstore/blk built as a module.
Quoted 41 lines
fs/pstore/blk.c +2
-0+} +#endif /* MODULE */ /* get information of pstore/blk */ int pstore_blk_get_config (struct pstore_blk_config *info)include/linux/pstore_blk.h +2
-0@@ -39,4 +39,6 @@ struct pstore_blk_config {*/ int pstore_blk_get_config (struct pstore_blk_config *info); +void __init pstore_blk_early_init (void ); +#endif init/main.c +4
-1@@ -98,6 +98,7 @@#include <linux/mem_encrypt.h> #include <linux/kcsan.h> #include <linux/init_syscalls.h> +#include <linux/pstore_blk.h> #include <asm/io.h> #include <asm/bugs.h> @@ -1524,6 +1525,9 @@ static noinline void __init kernel_init_freeable(void)prepare_namespace (); } +if (IS_BUILTIN (CONFIG_PSTORE_BLK )) +pstore_blk_early_init (); +/* * Ok, we have completed the initial bootup, and * we're essentially up and running. Get rid of the -- 2.28.0
Re: [PATCH 8/9] pstore/blk: use the normal block device I/O path
Quoted 9 lines · 廖威雄
fs/pstore/blk.c static const struct pstore_zone_ops pstore_blk_zone_ops = { · line 269
Quoted 8 lines
fs/pstore/blk.c +8
-0+const char devname[] ="/dev/pstore-blk" ; +dev_t dev =name_to_dev_t (blkdev); + +if (!dev) +return ; +init_unlink (devname); +init_mknod (devname,S_IFBLK |0600 ,new_encode_dev (dev)); +__pstore_blk_init (devname);
Quoted 3 lines
How about pstore/blk making
/dev/pstore-blknode no matter build-in or module. Then pstore/blk always opens/dev/pstore-blk. By this way, blkdev can also be a device number if pstore/blk built as a module.
Please read the comment above blkdev_get_by_dev on why no one should add new interfaces based on the device number.
Re: [PATCH 8/9] pstore/blk: use the normal block device I/O path
In reply to Christoph HellwigQuoted 33 lines · Christoph Hellwig
Stop poking into block layer internals and just open the block device file an use
kernel_readandkernel_writeon it. Note that this means the transformation fromname_to_dev_tcan't be used anymore, and proper block device file names must be used.Signed-off-by Christoph Hellwig <[email protected]>[...]fs/pstore/blk.c +16
-2+ +#ifdef MODULE +static int __init pstore_blk_init (void ) +{ +return __pstore_blk_init (blkdev); +}late_initcall (pstore_blk_init); static void __exit pstore_blk_exit(void) { -if (!psblk_bdev) +if (!psblk_file)return ;unregister_pstore_device (&pstore_blk_zone_ops); -blkdev_put (psblk_bdev,FMODE_READ |FMODE_WRITE |FMODE_EXCL ); +fput (psblk_file); }module_exit (pstore_blk_exit); +#else /* MODULE */ +/* +* During early boot the real root file system hasn't been mounted yet, +* and not device nodes are present yet. Use the same scheme to find +* the device that we use for mounting the root file system. +*/ +void __init pstore_blk_early_init (void ) +{
fs/pstore/blk.c static const struct pstore_zone_ops pstore_blk_zone_ops = { · line 271
Quoted 10 lines
fs/pstore/blk.c +10
-0+const char devname[] ="/dev/pstore-blk" ; +dev_t dev =name_to_dev_t (blkdev); + +if (!dev) +return ; +init_unlink (devname); +init_mknod (devname,S_IFBLK |0600 ,new_encode_dev (dev)); + __pstore_blk_init(devname); +} +#endif /* MODULE */
That the allowed naming conventions change based on _how_ pstore is built seems very wrong to me.
While I do like the clean up to simplify the read/write activities, this seems like totally the wrong approach here.
Quoted 27 lines
/* get information of pstore/blk */
intpstore_blk_get_config(struct pstore_blk_config *info)include/linux/pstore_blk.h +2
-0@@ -39,4 +39,6 @@ struct pstore_blk_config {*/ int pstore_blk_get_config (struct pstore_blk_config *info); +void __init pstore_blk_early_init (void ); +#endif init/main.c +1
-0@@ -98,6 +98,7 @@#include <linux/mem_encrypt.h> #include <linux/kcsan.h> #include <linux/init_syscalls.h> +#include <linux/pstore_blk.h> #include <asm/io.h> #include <asm/bugs.h>
init/main.c static noinline void __init kernel_init_freeable(void) · line 1530
Quoted 6 lines
init/main.c +3
-0@@ -1524,6 +1525,9 @@ static noinline void __init kernel_init_freeable(void)prepare_namespace (); } +if (IS_BUILTIN (CONFIG_PSTORE_BLK )) +pstore_blk_early_init (); +
I hate this being a special-case in kernel_init. For ramoops, we use:
postcore_initcall(ramoops_init);
which is much better than open coding this here.
Quoted 6 lines
init/main.c +0
-0/* * Ok, we have completed the initial bootup, and * we're essentially up and running. Get rid of the Signature · 1 line
2.28.0
Signature · 5 lines
Kees Cook ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 9/9 pstore/blk: don't depend on CONFIG_BLOCK
In reply to Christoph Hellwigpstore-blk contains of two different layers:
a) a tiny layer of sugar coating ontop of pstore-zone. This part has no dependencies on the block layer, and can be used e.g. by mtd
b) an implementation of a default fallback pstore zone backend for block devices
Add an ifdef for the latter so that pstore-blk itself does not have to depend on CONFIG_BLOCK.
--- fs/pstore/Kconfig | 2 +- fs/pstore/blk.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
fs/pstore/Kconfig +1 -1
@@ -164,7 +164,7 @@ config PSTORE_ZONE config PSTORE_BLK tristate "Log panic/oops to a block device" depends on PSTORE - depends on BLOCK + depends on BLOCK || !BLOCK select PSTORE_ZONE default n help
fs/pstore/blk.c +2 -0
@@ -182,6 +182,7 @@ void unregister_pstore_device(const struct pstore_zone_ops *ops) }EXPORT_SYMBOL_GPL (unregister_pstore_device); +#ifdef CONFIG_BLOCK static struct file *psblk_file;static ssize_t psblk_generic_blk_read (char *buf,size_t bytes,loff_t pos)
@@ -269,6 +270,7 @@ void __init pstore_blk_early_init(void)__pstore_blk_init (devname); }#endif /* MODULE */ +#endif /* CONFIG_BLOCK */ /* get information of pstore/blk */ int pstore_blk_get_config (struct pstore_blk_config *info)
Signature · 1 line
2.28.0
kernel test robot
build botRe: [PATCH 9/9] pstore/blk: don't depend on CONFIG_BLOCK
I love your patch! Yet something to improve:
Hi Christoph,
I love your patch! Yet something to improve:
[auto build test ERROR on kees/for-next/pstore]
[also build test ERROR on ia64/next linus/master v5.9] [cannot apply to next-20201016]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Christoph-Hellwig/pstore-zone-cap-the-maximum-device-size/20201016-222110 base: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/pstore config: m68k-randconfig-r004-20201016 (attached as .config) compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/a5c145d5f37504bf661cea0d7ac72d45b88ebbcc
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Christoph-Hellwig/pstore-zone-cap-the-maximum-device-size/20201016-222110 git checkout a5c145d5f37504bf661cea0d7ac72d45b88ebbcc
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
m68k-linux-ld: init/main.o: in function `kernel_init_freeable':
>> init/main.c:1527: undefined reference to `pstore_blk_early_init'
vim +1527 init/main.c
b49a733d684e00 Dominik Brodowski 2018-10-23 1478
f80b0c904da93b Vineet Gupta 2012-12-21 1479 static noinline void __init kernel_init_freeable(void)
^1da177e4c3f41 Linus Torvalds 2005-04-16 1480 {
b433c3d4549ae7 Peter Zijlstra 2010-06-28 1481 /*
b433c3d4549ae7 Peter Zijlstra 2010-06-28 1482 * Wait until kthreadd is all set-up.
b433c3d4549ae7 Peter Zijlstra 2010-06-28 1483 */
b433c3d4549ae7 Peter Zijlstra 2010-06-28 1484 wait_for_completion(&kthreadd_done);
31a67102f4762d Linus Torvalds 2012-05-21 1485
31a67102f4762d Linus Torvalds 2012-05-21 1486 /* Now the scheduler is fully set up and can do blocking allocations */
31a67102f4762d Linus Torvalds 2012-05-21 1487 gfp_allowed_mask = __GFP_BITS_MASK;
31a67102f4762d Linus Torvalds 2012-05-21 1488
58568d2a8215cb Miao Xie 2009-06-16 1489 /*
58568d2a8215cb Miao Xie 2009-06-16 1490 * init can allocate pages on any node
58568d2a8215cb Miao Xie 2009-06-16 1491 */
3c466d46a9f38d Lai Jiangshan 2012-12-12 1492 set_mems_allowed(node_states[N_MEMORY]);
^1da177e4c3f41 Linus Torvalds 2005-04-16 1493
9ec52099e4b867 Cedric Le Goater 2006-10-02 1494 cad_pid = task_pid(current);
9ec52099e4b867 Cedric Le Goater 2006-10-02 1495
ca74a6f84e68b4 Andi Kleen 2008-01-30 1496 smp_prepare_cpus(setup_max_cpus);
^1da177e4c3f41 Linus Torvalds 2005-04-16 1497
3347fa0928210d Tejun Heo 2016-09-16 1498 workqueue_init();
3347fa0928210d Tejun Heo 2016-09-16 1499
597b7305dd8baf Michal Hocko 2017-03-31 1500 init_mm_internals();
597b7305dd8baf Michal Hocko 2017-03-31 1501
^1da177e4c3f41 Linus Torvalds 2005-04-16 1502 do_pre_smp_initcalls();
004417a6d468e2 Peter Zijlstra 2010-11-25 1503 lockup_detector_init();
^1da177e4c3f41 Linus Torvalds 2005-04-16 1504
^1da177e4c3f41 Linus Torvalds 2005-04-16 1505 smp_init();
^1da177e4c3f41 Linus Torvalds 2005-04-16 1506 sched_init_smp();
^1da177e4c3f41 Linus Torvalds 2005-04-16 1507
f1b192b117cd41 Daniel Jordan 2020-06-03 1508 padata_init();
0e1cc95b4cc729 Mel Gorman 2015-06-30 1509 page_alloc_init_late();
2f1ee0913ce58e Qian Cai 2019-02-12 1510 /* Initialize page ext after all struct pages are initialized. */
2f1ee0913ce58e Qian Cai 2019-02-12 1511 page_ext_init();
0e1cc95b4cc729 Mel Gorman 2015-06-30 1512
^1da177e4c3f41 Linus Torvalds 2005-04-16 1513 do_basic_setup();
^1da177e4c3f41 Linus Torvalds 2005-04-16 1514
b49a733d684e00 Dominik Brodowski 2018-10-23 1515 console_on_rootfs();
2bd3a997befc22 Eric W. Biederman 2010-03-02 1516
^1da177e4c3f41 Linus Torvalds 2005-04-16 1517 /*
^1da177e4c3f41 Linus Torvalds 2005-04-16 1518 * check if there is an early userspace init. If yes, let it do all
^1da177e4c3f41 Linus Torvalds 2005-04-16 1519 * the work
^1da177e4c3f41 Linus Torvalds 2005-04-16 1520 */
eb9d7d390e5110 Christoph Hellwig 2020-07-22 1521 if (init_eaccess(ramdisk_execute_command) != 0) {
ffdfc40976dda1 Olof Johansson 2005-09-06 1522 ramdisk_execute_command = NULL;
^1da177e4c3f41 Linus Torvalds 2005-04-16 1523 prepare_namespace();
ffdfc40976dda1 Olof Johansson 2005-09-06 1524 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 1525
796d214cf62d9b Christoph Hellwig 2020-10-16 1526 if (IS_BUILTIN(CONFIG_PSTORE_BLK))796d214cf62d9b Christoph Hellwig 2020-10-16 @1527 pstore_blk_early_init();
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Re: [PATCH 9/9] pstore/blk: don't depend on CONFIG_BLOCK
In reply to Christoph HellwigQuoted 11 lines · Christoph Hellwig
pstore-blk contains of two different layers:
a) a tiny layer of sugar coating ontop of pstore-zone. This part has no dependencies on the block layer, and can be used e.g. by mtd
b) an implementation of a default fallback pstore zone backend for block devicesAdd an ifdef for the latter so that pstore-blk itself does not have to depend on
CONFIG_BLOCK.Signed-off-by Christoph Hellwig <[email protected]>
AFAIU, this can't be done until the read/write changes from patch 8 are adopted, so, for now, I'm not taking this either.
-Kees
Quoted 41 lines
--- fs/pstore/Kconfig | 2 +- fs/pstore/blk.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)fs/pstore/Kconfig +1
-1@@ -164,7 +164,7 @@ config PSTORE_ZONE config PSTORE_BLK tristate "Log panic/oops to a block device" depends on PSTORE - depends on BLOCK + depends on BLOCK || !BLOCK select PSTORE_ZONE default n helpfs/pstore/blk.c +2
-0@@ -182,6 +182,7 @@ void unregister_pstore_device(const struct pstore_zone_ops *ops) }EXPORT_SYMBOL_GPL (unregister_pstore_device); +#ifdef CONFIG_BLOCK static struct file *psblk_file;static ssize_t psblk_generic_blk_read (char *buf,size_t bytes,loff_t pos)@@ -269,6 +270,7 @@ void __init pstore_blk_early_init(void)__pstore_blk_init (devname); }#endif /* MODULE */ +#endif /* CONFIG_BLOCK */ /* get information of pstore/blk */ int pstore_blk_get_config (struct pstore_blk_config *info)Signature · 1 line
2.28.0
Signature · 5 lines
Kees Cook ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 2 lines · Christoph Hellwig
this series cleans up and massively simplifies the pstore-blk code, please take a look.
Cool! Thanks for doing this work. I have a few things I'd like to see done differently, and while I'm not a huge fan of the general reduction in utility, I can live with it as long as it doesn't make other things worse. :) I'll get this reviewed with specific feedback soon, but I'm about to be EOW. ;)
Signature · 1 line
Kees Cook
Quoted 9 lines · Kees Cook
Quoted 2 lines · Christoph Hellwig
this series cleans up and massively simplifies the pstore-blk code, please take a look.
Cool! Thanks for doing this work. I have a few things I'd like to see done differently, and while I'm not a huge fan of the general reduction in utility, I can live with it as long as it doesn't make other things worse. :) I'll get this reviewed with specific feedback soon, but I'm about to be EOW. ;)
Any progress on this in the last five weeks?
Quoted 5 lines · Christoph Hellwig
Quoted 4 lines · Kees Cook
Quoted 2 lines · Christoph Hellwig
this series cleans up and massively simplifies the pstore-blk code, please take a look.
Quoted 7 lines
Quoted 5 lines
Cool! Thanks for doing this work. I have a few things I'd like to see done differently, and while I'm not a huge fan of the general reduction in utility, I can live with it as long as it doesn't make other things worse. :) I'll get this reviewed with specific feedback soon, but I'm about to be EOW. ;)
Any progress on this in the last five weeks?
Hi! Sorry, no, I keep getting distracted by other stuff. I'll try to make time for it again next week (I'm soon AFK for Turkey Day).
Signature · 1 line
Kees Cook
hi Christoph,
Quoted 5 lines · Christoph Hellwig
Hi all,
this series cleans up and massively simplifies the pstore-blk code, please take a look.
Thanks for your code. I am going to redesign pstore/blk referred to your idea.
I want to split pstore/blk into two parts, pstore/dev and pstore/blk. pstore/dev is a common layer that handles all configurations for users. All devices including block devices, ram devices and mtd devices register to pstore/dev with operations and some flags.
Besides that, we can delete the codes for the block device to register a panic_wirte() interface since there is no block device needed. But it should be easy to implement registering if necessary.