linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: Make blkdev_issue_discard() interruptible
@ 2010-09-15 14:32 Lukas Czerner
  2010-09-15 14:59 ` Mike Snitzer
  0 siblings, 1 reply; 7+ messages in thread
From: Lukas Czerner @ 2010-09-15 14:32 UTC (permalink / raw)
  To: linux-ext4; +Cc: tytso, sandeen, lczerner, linux-kernel

Since the discard may take quite long time, especially with really big
extents (like the whole device for example), it would be nice to give to
users the opportunity to abort it. This is especially useful for mkfs,
when user can not know in advance how long it will take.

In conjunction with mke2fs patch "Inform user about ongoing discard"
it gives the user all the comfort of being informed about discard and
being able to abort the operation.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 block/blk-lib.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/block/blk-lib.c b/block/blk-lib.c
index d0216b9..4f54a1a 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -102,6 +102,11 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
 		else if (!bio_flagged(bio, BIO_UPTODATE))
 			ret = -EIO;
 		bio_put(bio);
+
+		if (signal_pending(current)) {
+			ret = -ERESTARTSYS;
+			break;
+		}
 	}
 	return ret;
 out_free_page:
-- 
1.7.2.2


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

* Re: [PATCH] block: Make blkdev_issue_discard() interruptible
  2010-09-15 14:32 Lukas Czerner
@ 2010-09-15 14:59 ` Mike Snitzer
  2010-09-15 16:16   ` Lukas Czerner
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Snitzer @ 2010-09-15 14:59 UTC (permalink / raw)
  To: Lukas Czerner; +Cc: linux-ext4, tytso, sandeen, linux-kernel

On Wed, Sep 15, 2010 at 10:32 AM, Lukas Czerner <lczerner@redhat.com> wrote:
> Since the discard may take quite long time, especially with really big
> extents (like the whole device for example), it would be nice to give to
> users the opportunity to abort it. This is especially useful for mkfs,
> when user can not know in advance how long it will take.
>
> In conjunction with mke2fs patch "Inform user about ongoing discard"
> it gives the user all the comfort of being informed about discard and
> being able to abort the operation.
>
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> ---
>  block/blk-lib.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/block/blk-lib.c b/block/blk-lib.c
> index d0216b9..4f54a1a 100644
> --- a/block/blk-lib.c
> +++ b/block/blk-lib.c
> @@ -102,6 +102,11 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
>                else if (!bio_flagged(bio, BIO_UPTODATE))
>                        ret = -EIO;
>                bio_put(bio);
> +
> +               if (signal_pending(current)) {
> +                       ret = -ERESTARTSYS;
> +                       break;
> +               }
>        }
>        return ret;
>  out_free_page:

Neil Brown recently suggested the use of fatal_signal_pending() rather
than signal_epnding() in another thread:
http://lkml.org/lkml/2010/9/12/232

I think Neil's suggestion applies here too?

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

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

* Re: [PATCH] block: Make blkdev_issue_discard() interruptible
  2010-09-15 14:59 ` Mike Snitzer
@ 2010-09-15 16:16   ` Lukas Czerner
  0 siblings, 0 replies; 7+ messages in thread
From: Lukas Czerner @ 2010-09-15 16:16 UTC (permalink / raw)
  To: Mike Snitzer; +Cc: Lukas Czerner, linux-ext4, tytso, sandeen, linux-kernel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1622 bytes --]

On Wed, 15 Sep 2010, Mike Snitzer wrote:

> On Wed, Sep 15, 2010 at 10:32 AM, Lukas Czerner <lczerner@redhat.com> wrote:
> > Since the discard may take quite long time, especially with really big
> > extents (like the whole device for example), it would be nice to give to
> > users the opportunity to abort it. This is especially useful for mkfs,
> > when user can not know in advance how long it will take.
> >
> > In conjunction with mke2fs patch "Inform user about ongoing discard"
> > it gives the user all the comfort of being informed about discard and
> > being able to abort the operation.
> >
> > Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> > ---
> >  block/blk-lib.c |    5 +++++
> >  1 files changed, 5 insertions(+), 0 deletions(-)
> >
> > diff --git a/block/blk-lib.c b/block/blk-lib.c
> > index d0216b9..4f54a1a 100644
> > --- a/block/blk-lib.c
> > +++ b/block/blk-lib.c
> > @@ -102,6 +102,11 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
> >                else if (!bio_flagged(bio, BIO_UPTODATE))
> >                        ret = -EIO;
> >                bio_put(bio);
> > +
> > +               if (signal_pending(current)) {
> > +                       ret = -ERESTARTSYS;
> > +                       break;
> > +               }
> >        }
> >        return ret;
> >  out_free_page:
> 
> Neil Brown recently suggested the use of fatal_signal_pending() rather
> than signal_epnding() in another thread:
> http://lkml.org/lkml/2010/9/12/232
> 
> I think Neil's suggestion applies here too?
> 
> Mike

Good to know, thanks a lot. I'll resend the patch shortly.

-Lukas

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

* [PATCH] block: Make blkdev_issue_discard() interruptible
@ 2010-10-21 14:34 Lukas Czerner
  2010-10-21 15:54 ` Lukas Czerner
  0 siblings, 1 reply; 7+ messages in thread
From: Lukas Czerner @ 2010-10-21 14:34 UTC (permalink / raw)
  To: linux-ext4; +Cc: tytso, sandeen, adilger, axboe, linux-kernel, lczerner

Since the discard may take quite long time, especially with really big
extents (like the whole device for example), it would be nice to give to
users the opportunity to abort it. This is especially useful for mkfs,
when user can not know in advance how long it will take.

In conjunction with mke2fs patch "Inform user about ongoing discard"
it gives the user all the comfort of being informed about discard and
being able to abort the operation.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 block/blk-lib.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/block/blk-lib.c b/block/blk-lib.c
index c392029..204839b 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -101,6 +101,11 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
 		else if (!bio_flagged(bio, BIO_UPTODATE))
 			ret = -EIO;
 		bio_put(bio);
+
+		if (fatal_signal_pending(current)) {
+			ret = -ERESTARTSYS;
+			break;
+		}
 	}
 
 	return ret;
-- 
1.7.2.3


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

* [PATCH] block: Make blkdev_issue_discard() interruptible
  2010-10-21 14:34 [PATCH] block: Make blkdev_issue_discard() interruptible Lukas Czerner
@ 2010-10-21 15:54 ` Lukas Czerner
  2010-10-21 16:52   ` Jeff Moyer
  0 siblings, 1 reply; 7+ messages in thread
From: Lukas Czerner @ 2010-10-21 15:54 UTC (permalink / raw)
  To: linux-ext4; +Cc: tytso, sandeen, adilger, axboe, linux-kernel, lczerner

Since the discard may take quite long time, especially with really big
extents (like the whole device for example), it would be nice to give to
users the opportunity to abort it. This is especially useful for mkfs,
when user can not know in advance how long it will take.

In conjunction with mke2fs patch "Inform user about ongoing discard"
it gives the user all the comfort of being informed about discard and
being able to abort the operation.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 block/blk-lib.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/block/blk-lib.c b/block/blk-lib.c
index 1a320d2..db44671 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -91,6 +91,9 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
 		bio_get(bio);
 		submit_bio(type, bio);
 
+		if (unlikely(fatal_signal_pending(current)))
+			ret = -ERESTARTSYS;
+
 		wait_for_completion(&wait);
 
 		if (bio_flagged(bio, BIO_EOPNOTSUPP))
-- 
1.7.2.3


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

* Re: [PATCH] block: Make blkdev_issue_discard() interruptible
  2010-10-21 15:54 ` Lukas Czerner
@ 2010-10-21 16:52   ` Jeff Moyer
  2010-10-22 11:06     ` Lukas Czerner
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff Moyer @ 2010-10-21 16:52 UTC (permalink / raw)
  To: Lukas Czerner; +Cc: linux-ext4, tytso, sandeen, adilger, axboe, linux-kernel

Lukas Czerner <lczerner@redhat.com> writes:

> Since the discard may take quite long time, especially with really big
> extents (like the whole device for example), it would be nice to give to
> users the opportunity to abort it. This is especially useful for mkfs,
> when user can not know in advance how long it will take.
>
> In conjunction with mke2fs patch "Inform user about ongoing discard"
> it gives the user all the comfort of being informed about discard and
> being able to abort the operation.

For others reviewing, this is against the block tree's for-next branch.

> ---
>  block/blk-lib.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/block/blk-lib.c b/block/blk-lib.c
> index 1a320d2..db44671 100644
> --- a/block/blk-lib.c
> +++ b/block/blk-lib.c
> @@ -91,6 +91,9 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
>  		bio_get(bio);
>  		submit_bio(type, bio);
>  
> +		if (unlikely(fatal_signal_pending(current)))
> +			ret = -ERESTARTSYS;
> +
>  		wait_for_completion(&wait);
>  
>  		if (bio_flagged(bio, BIO_EOPNOTSUPP))

Given that you're still doing the wait_for_completion, wouldn't it be
better to check for a pending signal after that?

What testing did you perform?

Cheers,
Jeff

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

* [PATCH] block: Make blkdev_issue_discard() interruptible
  2010-10-21 16:52   ` Jeff Moyer
@ 2010-10-22 11:06     ` Lukas Czerner
  0 siblings, 0 replies; 7+ messages in thread
From: Lukas Czerner @ 2010-10-22 11:06 UTC (permalink / raw)
  To: linux-ext4; +Cc: jmoyer, tytso, sandeen, adilger, axboe, linux-kernel, lczerner

Since the discard may take quite long time, especially with really big
extents (like the whole device for example), it would be nice to give to
users the opportunity to abort it. This is especially useful for mkfs,
when user can not know in advance how long it will take.

In conjunction with mke2fs patch "Inform user about ongoing discard"
it gives the user all the comfort of being informed about discard and
being able to abort the operation.

It has been tested on SSD device where mkfs.ext4 without -K takes rally
long due to discarding whole device. With this patch I am able to
successfully terminate that with ctrl+c. Aside that discard functionality
remains unchanged.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 block/blk-lib.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/block/blk-lib.c b/block/blk-lib.c
index c392029..54994e7 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -101,6 +101,9 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
 		else if (!bio_flagged(bio, BIO_UPTODATE))
 			ret = -EIO;
 		bio_put(bio);
+
+		if (unlikely(fatal_signal_pending(current)))
+			ret = -ERESTARTSYS;
 	}
 
 	return ret;
-- 
1.7.2.3


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

end of thread, other threads:[~2010-10-22 11:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-21 14:34 [PATCH] block: Make blkdev_issue_discard() interruptible Lukas Czerner
2010-10-21 15:54 ` Lukas Czerner
2010-10-21 16:52   ` Jeff Moyer
2010-10-22 11:06     ` Lukas Czerner
  -- strict thread matches above, loose matches on Subject: below --
2010-09-15 14:32 Lukas Czerner
2010-09-15 14:59 ` Mike Snitzer
2010-09-15 16:16   ` Lukas Czerner

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).