Skip to contentSkip to conversation

block: Make blkdev_issue_discard() interruptible

PATCH Superseded Lukas Czerner 2 participants 4 messages Sep 15, 2010 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: Make blkdev_issue_discard() interruptible

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.

---
 block/blk-lib.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
block/blk-lib.c +5 -0
index d0216b9..4f54a1a 100644
@@ -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:
Signature · 1 line
1.7.2.2
#1 lore raw
Quoted 29 lines · Lukas Czerner

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.

---
 block/blk-lib.c |    5 +++++

 1 files changed, 5 insertions(+), 0 deletions(-)
block/blk-lib.c +5 -0
index d0216b9..4f54a1a 100644
@@ -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;
Quoted 1 line

 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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 36 lines · Mike Snitzer
Quoted 29 lines · Lukas Czerner

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.

---
 block/blk-lib.c |    5 +++++

 1 files changed, 5 insertions(+), 0 deletions(-)
block/blk-lib.c +5 -0
index d0216b9..4f54a1a 100644
@@ -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;
Quoted 1 line

 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

Quoted 3 lines

I think Neil's suggestion applies here too?

Mike

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

-Lukas

#3 lore raw

PATCH v2 1/1 block: Make blkdev_issue_discard() interruptible

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.

---
 block/blk-lib.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
block/blk-lib.c +5 -0
index d0216b9..f1eb78e 100644
@@ -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 (fatal_signal_pending(current)) {
+			ret = -ERESTARTSYS;
+			break;
+		}
 	}
 	return ret;
 out_free_page:
Signature · 1 line
1.7.2.2