mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Phillip Susi <psusi@ubuntu.com>
Cc: axboe@kernel.dk, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] loop: cleanup partitions when detaching loop device
Date: Thu, 14 Mar 2013 15:07:09 -0700	[thread overview]
Message-ID: <20130314150709.056aa4de5fadf3a5e94103d4@linux-foundation.org> (raw)
In-Reply-To: <1362336553-16880-1-git-send-email-psusi@ubuntu.com>

On Sun,  3 Mar 2013 13:49:13 -0500 Phillip Susi <psusi@ubuntu.com> wrote:

> Any partitions added by user space to the loop device were being
> left in place after detaching the loop device.  This was because
> the detach path issued a BLKRRPART to clean up partitions if
> LO_FLAGS_PARTSCAN was set, meaning that the partitions were auto
> scanned on attach.  Replace this BLKRRPART with code that
> unconditionally cleans up partitions on detach instead.

huh.  What is the user-visible effect of this bug?  Just a memory leak
or something more serious?

If "something more serious", why did this problem remain hidden for so
long?

> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -1039,12 +1039,24 @@ static int loop_clr_fd(struct loop_device *lo)
>  	lo->lo_state = Lo_unbound;
>  	/* This is safe: open() is still holding a reference. */
>  	module_put(THIS_MODULE);
> -	if (lo->lo_flags & LO_FLAGS_PARTSCAN && bdev)
> -		ioctl_by_bdev(bdev, BLKRRPART, 0);
>  	lo->lo_flags = 0;
>  	if (!part_shift)
>  		lo->lo_disk->flags |= GENHD_FL_NO_PART_SCAN;
>  	mutex_unlock(&lo->lo_ctl_mutex);
> +	if (bdev)
> +	{

scripts/checkpatch.pl is your friend.

Can you please suggest a code comment which we can slip in here to tell
readers what's going on and why we're doing this?

> +		struct disk_part_iter piter;
> +		struct hd_struct *part;
> +
> +		mutex_lock_nested(&bdev->bd_mutex, 1);
> +		invalidate_partition(bdev->bd_disk, 0);
> +		disk_part_iter_init(&piter, bdev->bd_disk, DISK_PITER_INCL_EMPTY);
> +		while ((part = disk_part_iter_next(&piter)))
> +			delete_partition(bdev->bd_disk, part->partno);
> +		disk_part_iter_exit(&piter);
> +		mutex_unlock(&bdev->bd_mutex);
> +	}


  reply	other threads:[~2013-03-14 22:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-03 18:49 Phillip Susi
2013-03-14 22:07 ` Andrew Morton [this message]
2013-03-15  1:45   ` Phillip Susi
  -- strict thread matches above, loose matches on Subject: below --
2011-12-02 23:54 Phillip Susi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130314150709.056aa4de5fadf3a5e94103d4@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=psusi@ubuntu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®