All of lore.kernel.org
 help / color / mirror / Atom feed
* + zram-rework-reset-and-destroy-path-fix.patch added to -mm tree
@ 2015-02-03 23:11 akpm
  2015-02-04  1:07 ` Sergey Senozhatsky
  0 siblings, 1 reply; 6+ messages in thread
From: akpm @ 2015-02-03 23:11 UTC (permalink / raw)
  To: akpm, jmarchan, minchan, ngupta, opensource.ganesh,
	sergey.senozhatsky, mm-commits


The patch titled
     Subject: zram-rework-reset-and-destroy-path-fix
has been added to the -mm tree.  Its filename is
     zram-rework-reset-and-destroy-path-fix.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/zram-rework-reset-and-destroy-path-fix.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/zram-rework-reset-and-destroy-path-fix.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Andrew Morton <akpm@linux-foundation.org>
Subject: zram-rework-reset-and-destroy-path-fix

tweak comment

Cc: Ganesh Mahendran <opensource.ganesh@gmail.com>
Cc: Jerome Marchand <jmarchan@redhat.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/block/zram/zram_drv.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff -puN drivers/block/zram/zram_drv.c~zram-rework-reset-and-destroy-path-fix drivers/block/zram/zram_drv.c
--- a/drivers/block/zram/zram_drv.c~zram-rework-reset-and-destroy-path-fix
+++ a/drivers/block/zram/zram_drv.c
@@ -1119,8 +1119,10 @@ static void destroy_devices(unsigned int
 
 	for (i = 0; i < nr; i++) {
 		zram = &zram_devices[i];
-		/* remove sysfs first, so no one will perform disksize
-		 * store while we destroying devices */
+		/*
+		 * Remove sysfs first, so no one will perform a disksize
+		 * store while we destroy the devices
+		 */
 		sysfs_remove_group(&disk_to_dev(zram->disk)->kobj,
 				&zram_disk_attr_group);
 
_

Patches currently in -mm which might be from akpm@linux-foundation.org are

i-need-old-gcc.patch
arch-alpha-kernel-systblss-remove-debug-check.patch
fanotify-dont-recalculate-a-marks-mask-if-only-the-ignored-mask-changed-checkpatch-fixes.patch
fanotify-dont-set-fan_ondir-implicitly-on-a-marks-ignored-mask-checkpatch-fixes.patch
input-route-kbd-leds-through-the-generic-leds-layer.patch
o2dlm-fix-null-pointer-dereference-in-o2dlm_blocking_ast_wrapper.patch
mm.patch
mm-vmstatc-fix-cleanup-ifdefs.patch
mm-replace-remap_file_pages-syscall-with-emulation.patch
mm-drop-vm_ops-remap_pages-and-generic_file_remap_pages-stub-fix.patch
mm-page_allocc-__alloc_pages_nodemask-dont-alter-arg-gfp_mask.patch
vmscan-force-scan-offline-memory-cgroups-fix.patch
mm-memcontrol-default-hierarchy-interface-for-memory.patch
mm-memcontrol-fold-move_anon-and-move_file-fix.patch
fs-shrinker-always-scan-at-least-one-object-of-each-type-fix.patch
mm-compaction-enhance-tracepoint-output-for-compaction-begin-end-v4-fix.patch
mm-vmscan-fix-the-page-state-calculation-in-too_many_isolated-fix.patch
mm-thp-allocate-transparent-hugepages-on-local-node-fix.patch
docs-procs-describe-proc-pid-map_files-entry-fix.patch
mm-page_ext-remove-unnecessary-stack_trace-field-fix.patch
mm-fix-arithmetic-overflow-in-__vm_enough_memory-fix.patch
x86-add-pmd_-for-thp-fix.patch
sparc-add-pmd_-for-thp-fix.patch
zram-rework-reset-and-destroy-path-fix.patch
task_mmu-add-user-space-support-for-resetting-mm-hiwater_rss-peak-rss.patch
powerpc-add-running_clock-for-powerpc-to-prevent-spurious-softlockup-warnings-checkpatch-fixes.patch
lib-bitmap-update-bitmap_onto-to-unsigned-checkpatch-fixes.patch
lib-bitmap-change-parameters-of-bitmap_fold-to-unsigned-fix.patch
hexdump-makes-it-return-amount-of-bytes-placed-in-buffer-fix.patch
mm-slab-convert-cache-name-allocations-to-kstrdup_const-fix.patch
rtc-rk808-fix-the-rtc-time-reading-issue-fix.patch
fs-befs-linuxvfsc-remove-unnecessary-casting-fix.patch
samples-seccomp-improve-label-helper-fix.patch
linux-next.patch
linux-next-rejects.patch
mm-fix-xip-fault-vs-truncate-race-fix.patch
mm-fix-xip-fault-vs-truncate-race-fix-fix.patch
mm-allow-page-fault-handlers-to-perform-the-cow-fix.patch
mm-allow-page-fault-handlers-to-perform-the-cow-fix-fix-3.patch
mm-allow-page-fault-handlers-to-perform-the-cow-fix-fix.patch
daxext2-replace-the-xip-page-fault-handler-with-the-dax-page-fault-handler-fix.patch
daxext2-replace-the-xip-page-fault-handler-with-the-dax-page-fault-handler-fix-2.patch
daxext2-replace-the-xip-page-fault-handler-with-the-dax-page-fault-handler-fix-3.patch
dax-add-dax_zero_page_range-fix.patch
ext4-add-dax-functionality-fix.patch
ocfs2-add-functions-to-add-and-remove-inode-in-orphan-dir-fix.patch
ocfs2-implement-ocfs2_direct_io_write-fix.patch
lib-kconfig-fix-up-have_arch_bitreverse-help-text.patch
do_shared_fault-check-that-mmap_sem-is-held.patch
journal_add_journal_head-debug.patch
journal_add_journal_head-debug-fix.patch
kernel-forkc-export-kernel_thread-to-modules.patch
mutex-subsystem-synchro-test-module.patch
slab-leaks3-default-y.patch


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

* Re: + zram-rework-reset-and-destroy-path-fix.patch added to -mm tree
  2015-02-03 23:11 + zram-rework-reset-and-destroy-path-fix.patch added to -mm tree akpm
@ 2015-02-04  1:07 ` Sergey Senozhatsky
  2015-02-04 22:29   ` Andrew Morton
  2015-02-04 22:29   ` Andrew Morton
  0 siblings, 2 replies; 6+ messages in thread
From: Sergey Senozhatsky @ 2015-02-04  1:07 UTC (permalink / raw)
  To: linux-kernel
  Cc: akpm, jmarchan, minchan, ngupta, opensource.ganesh,
	sergey.senozhatsky, mm-commits

On (02/03/15 15:11), akpm@linux-foundation.org wrote:
> tweak comment
> 

Thank you, sir.

Andrew, can you please squash the following patch?

---

>From 22f0be96df55513a3d764ea880d5b3e99669f8f7 Mon Sep 17 00:00:00 2001
From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Date: Wed, 4 Feb 2015 09:59:06 +0900
Subject: [PATCH] zram: set default dev_id value to zero in zram_init()

Set dev_id to zero and fix zram_devices allocation error handling
path, can pass uninit dev_id to destroy_devices().

cosmetic:
change destroy_devices() message from pr_debug() to pr_info(), as
proposed by Minchan Kim.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
 drivers/block/zram/zram_drv.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 79c5da9..0bb4fa0 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1138,12 +1138,12 @@ static void destroy_devices(unsigned int nr)
 
 	kfree(zram_devices);
 	unregister_blkdev(zram_major, "zram");
-	pr_debug("Destroyed %u device(s)\n", nr);
+	pr_info("Destroyed %u device(s)\n", nr);
 }
 
 static int __init zram_init(void)
 {
-	int ret, dev_id;
+	int ret = -ENOMEM, dev_id = 0;
 
 	if (num_devices > max_num_devices) {
 		pr_warn("Invalid value for num_devices: %u\n",
@@ -1159,10 +1159,8 @@ static int __init zram_init(void)
 
 	/* Allocate the device array and initialize each one */
 	zram_devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL);
-	if (!zram_devices) {
-		ret = -ENOMEM;
+	if (!zram_devices)
 		goto out_error;
-	}
 
 	for (dev_id = 0; dev_id < num_devices; dev_id++) {
 		ret = create_device(&zram_devices[dev_id], dev_id);
-- 
2.3.0.rc2


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

* Re: + zram-rework-reset-and-destroy-path-fix.patch added to -mm tree
  2015-02-04  1:07 ` Sergey Senozhatsky
  2015-02-04 22:29   ` Andrew Morton
@ 2015-02-04 22:29   ` Andrew Morton
  1 sibling, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2015-02-04 22:29 UTC (permalink / raw)
  To: Sergey Senozhatsky
  Cc: linux-kernel, jmarchan, minchan, ngupta, opensource.ganesh,
	sergey.senozhatsky, mm-commits

On Wed, 4 Feb 2015 10:07:20 +0900 Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> wrote:

> Set dev_id to zero and fix zram_devices allocation error handling
> path, can pass uninit dev_id to destroy_devices().
> 
> cosmetic:
> change destroy_devices() message from pr_debug() to pr_info(), as
> proposed by Minchan Kim.
> 

Seems unnecessarily complicated.  What about

--- a/drivers/block/zram/zram_drv.c~zram-rework-reset-and-destroy-path-fix-2-fix
+++ a/drivers/block/zram/zram_drv.c
@@ -1141,7 +1141,8 @@ static void destroy_devices(unsigned int
 
 static int __init zram_init(void)
 {
-	int ret = -ENOMEM, dev_id = 0;
+	int ret;
+	int dev_id;
 
 	if (num_devices > max_num_devices) {
 		pr_warn("Invalid value for num_devices: %u\n",
@@ -1157,20 +1158,23 @@ static int __init zram_init(void)
 
 	/* Allocate the device array and initialize each one */
 	zram_devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL);
-	if (!zram_devices)
-		goto out_error;
+	if (!zram_devices) {
+		ret = -ENOMEM;
+		goto out;
+	}
 
 	for (dev_id = 0; dev_id < num_devices; dev_id++) {
 		ret = create_device(&zram_devices[dev_id], dev_id);
 		if (ret)
-			goto out_error;
+			goto out_devices;
 	}
 
 	pr_info("Created %u device(s)\n", num_devices);
 	return 0;
 
-out_error:
+out_devices:
 	destroy_devices(dev_id);
+out:
 	return ret;
 }

which yields

static int __init zram_init(void)
{
	int ret;
	int dev_id;

	if (num_devices > max_num_devices) {
		pr_warn("Invalid value for num_devices: %u\n",
				num_devices);
		return -EINVAL;
	}

	zram_major = register_blkdev(0, "zram");
	if (zram_major <= 0) {
		pr_warn("Unable to get major number\n");
		return -EBUSY;
	}

	/* Allocate the device array and initialize each one */
	zram_devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL);
	if (!zram_devices) {
		ret = -ENOMEM;
		goto out;
	}

	for (dev_id = 0; dev_id < num_devices; dev_id++) {
		ret = create_device(&zram_devices[dev_id], dev_id);
		if (ret)
			goto out_devices;
	}

	pr_info("Created %u device(s)\n", num_devices);
	return 0;

out_devices:
	destroy_devices(dev_id);
out:
	return ret;
}

 
_


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

* Re: + zram-rework-reset-and-destroy-path-fix.patch added to -mm tree
  2015-02-04  1:07 ` Sergey Senozhatsky
@ 2015-02-04 22:29   ` Andrew Morton
  2015-02-05  0:20     ` Sergey Senozhatsky
  2015-02-05  0:36     ` Sergey Senozhatsky
  2015-02-04 22:29   ` Andrew Morton
  1 sibling, 2 replies; 6+ messages in thread
From: Andrew Morton @ 2015-02-04 22:29 UTC (permalink / raw)
  To: Sergey Senozhatsky
  Cc: linux-kernel, jmarchan, minchan, ngupta, opensource.ganesh,
	sergey.senozhatsky, mm-commits

On Wed, 4 Feb 2015 10:07:20 +0900 Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> wrote:

> Set dev_id to zero and fix zram_devices allocation error handling
> path, can pass uninit dev_id to destroy_devices().
> 
> cosmetic:
> change destroy_devices() message from pr_debug() to pr_info(), as
> proposed by Minchan Kim.
> 

Seems unnecessarily complicated.  What about

--- a/drivers/block/zram/zram_drv.c~zram-rework-reset-and-destroy-path-fix-2-fix
+++ a/drivers/block/zram/zram_drv.c
@@ -1141,7 +1141,8 @@ static void destroy_devices(unsigned int
 
 static int __init zram_init(void)
 {
-	int ret = -ENOMEM, dev_id = 0;
+	int ret;
+	int dev_id;
 
 	if (num_devices > max_num_devices) {
 		pr_warn("Invalid value for num_devices: %u\n",
@@ -1157,20 +1158,23 @@ static int __init zram_init(void)
 
 	/* Allocate the device array and initialize each one */
 	zram_devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL);
-	if (!zram_devices)
-		goto out_error;
+	if (!zram_devices) {
+		ret = -ENOMEM;
+		goto out;
+	}
 
 	for (dev_id = 0; dev_id < num_devices; dev_id++) {
 		ret = create_device(&zram_devices[dev_id], dev_id);
 		if (ret)
-			goto out_error;
+			goto out_devices;
 	}
 
 	pr_info("Created %u device(s)\n", num_devices);
 	return 0;
 
-out_error:
+out_devices:
 	destroy_devices(dev_id);
+out:
 	return ret;
 }

which yields

static int __init zram_init(void)
{
	int ret;
	int dev_id;

	if (num_devices > max_num_devices) {
		pr_warn("Invalid value for num_devices: %u\n",
				num_devices);
		return -EINVAL;
	}

	zram_major = register_blkdev(0, "zram");
	if (zram_major <= 0) {
		pr_warn("Unable to get major number\n");
		return -EBUSY;
	}

	/* Allocate the device array and initialize each one */
	zram_devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL);
	if (!zram_devices) {
		ret = -ENOMEM;
		goto out;
	}

	for (dev_id = 0; dev_id < num_devices; dev_id++) {
		ret = create_device(&zram_devices[dev_id], dev_id);
		if (ret)
			goto out_devices;
	}

	pr_info("Created %u device(s)\n", num_devices);
	return 0;

out_devices:
	destroy_devices(dev_id);
out:
	return ret;
}

 
_


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

* Re: + zram-rework-reset-and-destroy-path-fix.patch added to -mm tree
  2015-02-04 22:29   ` Andrew Morton
@ 2015-02-05  0:20     ` Sergey Senozhatsky
  2015-02-05  0:36     ` Sergey Senozhatsky
  1 sibling, 0 replies; 6+ messages in thread
From: Sergey Senozhatsky @ 2015-02-05  0:20 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Sergey Senozhatsky, linux-kernel, jmarchan, minchan, ngupta,
	opensource.ganesh, sergey.senozhatsky, mm-commits

Hello,
sorry for late response

On (02/04/15 14:29), Andrew Morton wrote:
> Seems unnecessarily complicated.  What about
> 
> --- a/drivers/block/zram/zram_drv.c~zram-rework-reset-and-destroy-path-fix-2-fix
> +++ a/drivers/block/zram/zram_drv.c
> @@ -1141,7 +1141,8 @@ static void destroy_devices(unsigned int
>  
>  static int __init zram_init(void)
>  {
> -	int ret = -ENOMEM, dev_id = 0;
> +	int ret;
> +	int dev_id;
>  
>  	if (num_devices > max_num_devices) {
>  		pr_warn("Invalid value for num_devices: %u\n",
> @@ -1157,20 +1158,23 @@ static int __init zram_init(void)
>  
>  	/* Allocate the device array and initialize each one */
>  	zram_devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL);
> -	if (!zram_devices)
> -		goto out_error;
> +	if (!zram_devices) {
> +		ret = -ENOMEM;

we need to rollback `zram_major = register_blkdev(0, "zram");'
which is done in destroy_devices().

	-ss

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

* Re: + zram-rework-reset-and-destroy-path-fix.patch added to -mm tree
  2015-02-04 22:29   ` Andrew Morton
  2015-02-05  0:20     ` Sergey Senozhatsky
@ 2015-02-05  0:36     ` Sergey Senozhatsky
  1 sibling, 0 replies; 6+ messages in thread
From: Sergey Senozhatsky @ 2015-02-05  0:36 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Sergey Senozhatsky, linux-kernel, jmarchan, minchan, ngupta,
	opensource.ganesh, sergey.senozhatsky, mm-commits

On (02/04/15 14:29), Andrew Morton wrote:
> which yields
> 

/* not sure if my previous email has been delived, seems there are some
connectivity problems on my side */


we need to unregister_blkdev(), 'out' label does not do it.

how about the following one (looks simple):

> static int __init zram_init(void)
> {
> 	int ret;
> 	int dev_id;
> 
> 	if (num_devices > max_num_devices) {
> 		pr_warn("Invalid value for num_devices: %u\n",
> 				num_devices);
> 		return -EINVAL;
> 	}
> 
> 	zram_major = register_blkdev(0, "zram");
> 	if (zram_major <= 0) {
> 		pr_warn("Unable to get major number\n");
> 		return -EBUSY;
> 	}
> 
> 	/* Allocate the device array and initialize each one */
> 	zram_devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL);
> 	if (!zram_devices) {
-               ret = -ENOMEM;
-               goto out_error;
+               unregister_blkdev(zram_major, "zram");
+               return -ENOMEM;
> 	}
> 
> 	for (dev_id = 0; dev_id < num_devices; dev_id++) {
> 		ret = create_device(&zram_devices[dev_id], dev_id);
> 		if (ret)
> 			goto out_devices;
> 	}
> 
> 	pr_info("Created %u device(s)\n", num_devices);
> 	return 0;
> 
> out_devices:
> 	destroy_devices(dev_id);
- out:
> 	return ret;
> }

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

end of thread, other threads:[~2015-02-05  0:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-03 23:11 + zram-rework-reset-and-destroy-path-fix.patch added to -mm tree akpm
2015-02-04  1:07 ` Sergey Senozhatsky
2015-02-04 22:29   ` Andrew Morton
2015-02-05  0:20     ` Sergey Senozhatsky
2015-02-05  0:36     ` Sergey Senozhatsky
2015-02-04 22:29   ` Andrew Morton

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.