Skip to content

Commit 5affe49

Browse files
keithbuschaxboe
authored andcommitted
block: blkdev_issue_secure_erase loop style
Use consistent coding style in this file. All the other loops for the same purpose use "while (nr_sects)", so they win. Reviewed-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Link: https://lore.kernel.org/r/20240223155910.3622666-2-kbusch@meta.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 03f1212 commit 5affe49

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

block/blk-lib.c

+5-6
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ int blkdev_issue_secure_erase(struct block_device *bdev, sector_t sector,
322322
return -EPERM;
323323

324324
blk_start_plug(&plug);
325-
for (;;) {
325+
while (nr_sects) {
326326
unsigned int len = min_t(sector_t, nr_sects, max_sectors);
327327

328328
bio = blk_next_bio(bio, bdev, 0, REQ_OP_SECURE_ERASE, gfp);
@@ -331,13 +331,12 @@ int blkdev_issue_secure_erase(struct block_device *bdev, sector_t sector,
331331

332332
sector += len;
333333
nr_sects -= len;
334-
if (!nr_sects) {
335-
ret = submit_bio_wait(bio);
336-
bio_put(bio);
337-
break;
338-
}
339334
cond_resched();
340335
}
336+
if (bio) {
337+
ret = submit_bio_wait(bio);
338+
bio_put(bio);
339+
}
341340
blk_finish_plug(&plug);
342341

343342
return ret;

0 commit comments

Comments
 (0)