linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] introduce new put_getdisk() call
@ 2016-02-01 14:51 Roman Pen
  2016-02-01 14:51 ` [PATCH 4/4] hibernate: fix disk and module leak on successfull resume Roman Pen
  2016-02-01 17:16 ` [PATCH 0/4] introduce new put_getdisk() call Tejun Heo
  0 siblings, 2 replies; 4+ messages in thread
From: Roman Pen @ 2016-02-01 14:51 UTC (permalink / raw)
  Cc: Roman Pen, Martin K. Petersen, Rafael J. Wysocki, Alexander Viro,
	Dan Williams, Gi-Oh Kim, Jens Axboe, Len Brown, Ming Lei,
	Pavel Machek, Sagi Grimberg, Tejun Heo, Vishal Verma, linux-block,
	linux-fsdevel, linux-kernel, linux-pm

Hello.

In this patchset in the first patch I fixed module reference leak inside
blk-cgroup.c.  In other patches I switched to a new put_getdisk() call,
which should be used if the disk was received by get_disk() or get_gendisk()
functions, which internally increase module reference.

The idea is to avoid confusion in the future and to have symmetric calls:

	alloc_disk() -> put_disk() [as it is done in all the block drivers]

and

	get_gendisk() -> put_gendisk() [if you need to find a disk by minor,major]

The second sequence internally increases disk owner module reference on
get and decreases it on put.

Roman Pen (4):
  block: fix module reference leak on put_disk() call for cgroups
    throttle
  block: introduce new call put_gendisk() in genhd.c
  block,fs: switch to a new put_gendisk() call
  hibernate: fix disk and module leak on successfull resume

 block/blk-cgroup.c       |  6 ++---
 block/genhd.c            | 59 +++++++++++++++++++++++++++++++++++++++++++++---
 fs/block_dev.c           | 24 ++++++--------------
 include/linux/genhd.h    |  1 +
 kernel/power/hibernate.c |  5 +++-
 5 files changed, 71 insertions(+), 24 deletions(-)

Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Gi-Oh Kim <gi-oh.kim@profitbricks.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Len Brown <len.brown@intel.com>
Cc: Ming Lei <tom.leiming@gmail.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Sagi Grimberg <sagig@mellanox.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: linux-block@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-pm@vger.kernel.org

-- 
2.6.2

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

* [PATCH 4/4] hibernate: fix disk and module leak on successfull resume
  2016-02-01 14:51 [PATCH 0/4] introduce new put_getdisk() call Roman Pen
@ 2016-02-01 14:51 ` Roman Pen
  2016-02-03  1:37   ` Rafael J. Wysocki
  2016-02-01 17:16 ` [PATCH 0/4] introduce new put_getdisk() call Tejun Heo
  1 sibling, 1 reply; 4+ messages in thread
From: Roman Pen @ 2016-02-01 14:51 UTC (permalink / raw)
  Cc: Roman Pen, Gi-Oh Kim, Rafael J. Wysocki, Len Brown, Pavel Machek,
	linux-pm, linux-kernel

Do not forget to put the disk back.

Signed-off-by: Roman Pen <roman.penyaev@profitbricks.com>
Cc: Gi-Oh Kim <gi-oh.kim@profitbricks.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Len Brown <len.brown@intel.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 kernel/power/hibernate.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index b7342a2..1f53dc2 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -785,8 +785,11 @@ static int software_resume(void)
 	 */
 	if (isdigit(resume_file[0]) && resume_wait) {
 		int partno;
-		while (!get_gendisk(swsusp_resume_device, &partno))
+		struct gendisk *disk;
+
+		while (!(disk = get_gendisk(swsusp_resume_device, &partno)))
 			msleep(10);
+		put_gendisk(disk);
 	}
 
 	if (!swsusp_resume_device) {
-- 
2.6.2

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

* Re: [PATCH 0/4] introduce new put_getdisk() call
  2016-02-01 14:51 [PATCH 0/4] introduce new put_getdisk() call Roman Pen
  2016-02-01 14:51 ` [PATCH 4/4] hibernate: fix disk and module leak on successfull resume Roman Pen
@ 2016-02-01 17:16 ` Tejun Heo
  1 sibling, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2016-02-01 17:16 UTC (permalink / raw)
  To: Roman Pen
  Cc: Martin K. Petersen, Rafael J. Wysocki, Alexander Viro,
	Dan Williams, Gi-Oh Kim, Jens Axboe, Len Brown, Ming Lei,
	Pavel Machek, Sagi Grimberg, Vishal Verma, linux-block,
	linux-fsdevel, linux-kernel, linux-pm

On Mon, Feb 01, 2016 at 03:51:51PM +0100, Roman Pen wrote:
> Hello.
> 
> In this patchset in the first patch I fixed module reference leak inside
> blk-cgroup.c.  In other patches I switched to a new put_getdisk() call,
> which should be used if the disk was received by get_disk() or get_gendisk()
> functions, which internally increase module reference.
> 
> The idea is to avoid confusion in the future and to have symmetric calls:
> 
> 	alloc_disk() -> put_disk() [as it is done in all the block drivers]
> 
> and
> 
> 	get_gendisk() -> put_gendisk() [if you need to find a disk by minor,major]
> 
> The second sequence internally increases disk owner module reference on
> get and decreases it on put.

For the entire series,

 Acked-by: Tejun Heo <tj@kernel.org>

Nice catch, thanks!

-- 
tejun

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

* Re: [PATCH 4/4] hibernate: fix disk and module leak on successfull resume
  2016-02-01 14:51 ` [PATCH 4/4] hibernate: fix disk and module leak on successfull resume Roman Pen
@ 2016-02-03  1:37   ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2016-02-03  1:37 UTC (permalink / raw)
  To: Roman Pen; +Cc: Gi-Oh Kim, Len Brown, Pavel Machek, linux-pm, linux-kernel

On Monday, February 01, 2016 03:51:55 PM Roman Pen wrote:
> Do not forget to put the disk back.
> 
> Signed-off-by: Roman Pen <roman.penyaev@profitbricks.com>
> Cc: Gi-Oh Kim <gi-oh.kim@profitbricks.com>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Len Brown <len.brown@intel.com>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: linux-pm@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  kernel/power/hibernate.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
> index b7342a2..1f53dc2 100644
> --- a/kernel/power/hibernate.c
> +++ b/kernel/power/hibernate.c
> @@ -785,8 +785,11 @@ static int software_resume(void)
>  	 */
>  	if (isdigit(resume_file[0]) && resume_wait) {
>  		int partno;
> -		while (!get_gendisk(swsusp_resume_device, &partno))
> +		struct gendisk *disk;
> +
> +		while (!(disk = get_gendisk(swsusp_resume_device, &partno)))
>  			msleep(10);
> +		put_gendisk(disk);
>  	}
>  
>  	if (!swsusp_resume_device) {
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

end of thread, other threads:[~2016-02-03  1:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-01 14:51 [PATCH 0/4] introduce new put_getdisk() call Roman Pen
2016-02-01 14:51 ` [PATCH 4/4] hibernate: fix disk and module leak on successfull resume Roman Pen
2016-02-03  1:37   ` Rafael J. Wysocki
2016-02-01 17:16 ` [PATCH 0/4] introduce new put_getdisk() call Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).