diff mbox

brd: remove support for BLKFLSBUF

Message ID 20161025143719.GA51266@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mike Snitzer Oct. 25, 2016, 2:37 p.m. UTC
On Tue, Oct 25 2016 at  9:07P -0400,
Christoph Hellwig <hch@infradead.org> wrote:

> I think the right fix is to kill off the BLKFLSBUF special case in
> brd.  Yes, it break compatibility - but in this case the compatibility
> breaks more than it helps.

Jens, please pick up this patch:

From: Mike Snitzer <snitzer@redhat.com>
Date: Tue, 25 Oct 2016 10:25:07 -0400
Subject: [PATCH] brd: remove support for BLKFLSBUF

Discontinue having the brd driver destructively free all pages in the
ramdisk in response to the BLKFLSBUF ioctl.  Doing so allows a BLKFLSBUF
ioctl issued to a logical partition to destroy pages of the parent brd
device (and all other partitions of that brd device).

This change breaks compatibility - but in this case the compatibility
breaks more than it helps.

Reported-by: Mikulas Patocka <mpatocka@redhat.com>
Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
 drivers/block/brd.c | 35 -----------------------------------
 1 file changed, 35 deletions(-)

Comments

Jens Axboe Oct. 25, 2016, 2:46 p.m. UTC | #1
On 10/25/2016 08:37 AM, Mike Snitzer wrote:
> On Tue, Oct 25 2016 at  9:07P -0400,
> Christoph Hellwig <hch@infradead.org> wrote:
>
>> I think the right fix is to kill off the BLKFLSBUF special case in
>> brd.  Yes, it break compatibility - but in this case the compatibility
>> breaks more than it helps.
>
> Jens, please pick up this patch:
>
> From: Mike Snitzer <snitzer@redhat.com>
> Date: Tue, 25 Oct 2016 10:25:07 -0400
> Subject: [PATCH] brd: remove support for BLKFLSBUF

Added, thanks.
Mikulas Patocka Oct. 26, 2016, 8:25 p.m. UTC | #2
On Tue, 25 Oct 2016, Jens Axboe wrote:

> On 10/25/2016 08:37 AM, Mike Snitzer wrote:
> > On Tue, Oct 25 2016 at  9:07P -0400,
> > Christoph Hellwig <hch@infradead.org> wrote:
> > 
> > > I think the right fix is to kill off the BLKFLSBUF special case in
> > > brd.  Yes, it break compatibility - but in this case the compatibility
> > > breaks more than it helps.
> > 
> > Jens, please pick up this patch:
> > 
> > From: Mike Snitzer <snitzer@redhat.com>
> > Date: Tue, 25 Oct 2016 10:25:07 -0400
> > Subject: [PATCH] brd: remove support for BLKFLSBUF
> 
> Added, thanks.
> 
> -- 
> Jens Axboe

Hi

With the removal of BLKFLSBUF, there is no way to free memory allocated by 
ramdisk, so I created these 4 patches that add DISCARD support for 
ramdisk.

Mikulas
--
To unsubscribe from this list: send the line "unsubscribe linux-block" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 0c76d40..45c998a 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -395,44 +395,9 @@  static long brd_direct_access(struct block_device *bdev, sector_t sector,
 #define brd_direct_access NULL
 #endif
 
-static int brd_ioctl(struct block_device *bdev, fmode_t mode,
-			unsigned int cmd, unsigned long arg)
-{
-	int error;
-	struct brd_device *brd = bdev->bd_disk->private_data;
-
-	if (cmd != BLKFLSBUF)
-		return -ENOTTY;
-
-	/*
-	 * ram device BLKFLSBUF has special semantics, we want to actually
-	 * release and destroy the ramdisk data.
-	 */
-	mutex_lock(&brd_mutex);
-	mutex_lock(&bdev->bd_mutex);
-	error = -EBUSY;
-	if (bdev->bd_openers <= 1) {
-		/*
-		 * Kill the cache first, so it isn't written back to the
-		 * device.
-		 *
-		 * Another thread might instantiate more buffercache here,
-		 * but there is not much we can do to close that race.
-		 */
-		kill_bdev(bdev);
-		brd_free_pages(brd);
-		error = 0;
-	}
-	mutex_unlock(&bdev->bd_mutex);
-	mutex_unlock(&brd_mutex);
-
-	return error;
-}
-
 static const struct block_device_operations brd_fops = {
 	.owner =		THIS_MODULE,
 	.rw_page =		brd_rw_page,
-	.ioctl =		brd_ioctl,
 	.direct_access =	brd_direct_access,
 };