Instead of overloading the discard support with the REQ_SECURE flag. Use the opportunity to rename the queue flag as well, and remove the dead checks for this flag in the RAID 1 and RAID 10 drivers that don't claim support for secure erase.
Unified · Split
| @@ -1977,16 +1977,21 @@ generic_make_request_checks(struct bio *bio) · 1976 unmodified lines | |||
| 1977 | } | 1977 | } |
| 1978 | } | 1978 | } |
| 1979 | 1979 | ||
| 1980 | if ((bio_op(bio) == REQ_OP_DISCARD) && | 1980 | switch (bio_op(bio)) { |
| 1981 | (!blk_queue_discard(q) || | 1981 | case REQ_OP_DISCARD: |
| 1982 | ((bio->bi_rw & REQ_SECURE) && !blk_queue_secdiscard(q)))) { | 1982 | if (!blk_queue_discard(q)) |
| 1983 | err = -EOPNOTSUPP; | 1983 | goto not_supported; |
| 1984 | goto end_io; | 1984 | break; |
| 1985 | } | 1985 | case REQ_OP_SECURE_ERASE: |
| 1986 | 1986 | if (!blk_queue_secure_erase(q)) | |
| 1987 | if (bio_op(bio) == REQ_OP_WRITE_SAME && !bdev_write_same(bio->bi_bdev)) { | 1987 | goto not_supported; |
| 1988 | err = -EOPNOTSUPP; | 1988 | break; |
| 1989 | goto end_io; | 1989 | case REQ_OP_WRITE_SAME: |
| 1990 | if (!bdev_write_same(bio->bi_bdev)) | ||
| 1991 | goto not_supported; | ||
| 1992 | break; | ||
| 1993 | default: | ||
| 1994 | break; | ||
| 1990 | } | 1995 | } |
| 1991 | 1996 | ||
| 1992 | /* | 1997 | /* |
| @@ -2003,6 +2008,8 @@ generic_make_request_checks(struct bio *bio) · 10 unmodified lines | |||
| 2003 | trace_block_bio_queue(q, bio); | 2008 | trace_block_bio_queue(q, bio); |
| 2004 | return true; | 2009 | return true; |
| 2005 | 2010 | ||
| 2011 | not_supported: | ||
| 2012 | err = -EOPNOTSUPP; | ||
| 2006 | end_io: | 2013 | end_io: |
| 2007 | bio->bi_error = err; | 2014 | bio->bi_error = err; |
| 2008 | bio_endio(bio); | 2015 | bio_endio(bio); |
| @@ -23,20 +23,27 @@ static struct bio *next_bio(struct bio *bio, unsigned int nr_pages, · 22 unmodified lines | |||
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, | 25 | int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, |
| 26 | sector_t nr_sects, gfp_t gfp_mask, int op_flags, | 26 | sector_t nr_sects, gfp_t gfp_mask, int flags, |
| 27 | struct bio **biop) | 27 | struct bio **biop) |
| 28 | { | 28 | { |
| 29 | struct request_queue *q = bdev_get_queue(bdev); | 29 | struct request_queue *q = bdev_get_queue(bdev); |
| 30 | struct bio *bio = *biop; | 30 | struct bio *bio = *biop; |
| 31 | unsigned int granularity; | 31 | unsigned int granularity; |
| 32 | enum req_op op; | ||
| 32 | int alignment; | 33 | int alignment; |
| 33 | 34 | ||
| 34 | if (!q) | 35 | if (!q) |
| 35 | return -ENXIO; | 36 | return -ENXIO; |
| 36 | if (!blk_queue_discard(q)) | 37 | |
| 37 | return -EOPNOTSUPP; | 38 | if (flags & BLKDEV_DISCARD_SECURE) { |
| 38 | if ((op_flags & REQ_SECURE) && !blk_queue_secdiscard(q)) | 39 | if (!blk_queue_secure_erase(q)) |
| 39 | return -EOPNOTSUPP; | 40 | return -EOPNOTSUPP; |
| 41 | op = REQ_OP_SECURE_ERASE; | ||
| 42 | } else { | ||
| 43 | if (!blk_queue_discard(q)) | ||
| 44 | return -EOPNOTSUPP; | ||
| 45 | op = REQ_OP_DISCARD; | ||
| 46 | } | ||
| 40 | 47 | ||
| 41 | /* Zero-sector (unknown) and one-sector granularities are the same. */ | 48 | /* Zero-sector (unknown) and one-sector granularities are the same. */ |
| 42 | granularity = max(q->limits.discard_granularity >> 9, 1U); | 49 | granularity = max(q->limits.discard_granularity >> 9, 1U); |
| @@ -66,7 +73,7 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, · 23 unmodified lines | |||
| 66 | bio = next_bio(bio, 1, gfp_mask); | 73 | bio = next_bio(bio, 1, gfp_mask); |
| 67 | bio->bi_iter.bi_sector = sector; | 74 | bio->bi_iter.bi_sector = sector; |
| 68 | bio->bi_bdev = bdev; | 75 | bio->bi_bdev = bdev; |
| 69 | bio_set_op_attrs(bio, REQ_OP_DISCARD, op_flags); | 76 | bio_set_op_attrs(bio, op, 0); |
| 70 | 77 | ||
| 71 | bio->bi_iter.bi_size = req_sects << 9; | 78 | bio->bi_iter.bi_size = req_sects << 9; |
| 72 | nr_sects -= req_sects; | 79 | nr_sects -= req_sects; |
| @@ -100,16 +107,12 @@ EXPORT_SYMBOL(__blkdev_issue_discard); · 27 unmodified lines | |||
| 100 | int blkdev_issue_discard(struct block_device *bdev, sector_t sector, | 107 | int blkdev_issue_discard(struct block_device *bdev, sector_t sector, |
| 101 | sector_t nr_sects, gfp_t gfp_mask, unsigned long flags) | 108 | sector_t nr_sects, gfp_t gfp_mask, unsigned long flags) |
| 102 | { | 109 | { |
| 103 | int op_flags = 0; | ||
| 104 | struct bio *bio = NULL; | 110 | struct bio *bio = NULL; |
| 105 | struct blk_plug plug; | 111 | struct blk_plug plug; |
| 106 | int ret; | 112 | int ret; |
| 107 | 113 | ||
| 108 | if (flags & BLKDEV_DISCARD_SECURE) | ||
| 109 | op_flags |= REQ_SECURE; | ||
| 110 | |||
| 111 | blk_start_plug(&plug); | 114 | blk_start_plug(&plug); |
| 112 | ret = __blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, op_flags, | 115 | ret = __blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, flags, |
| 113 | &bio); | 116 | &bio); |
| 114 | if (!ret && bio) { | 117 | if (!ret && bio) { |
| 115 | ret = submit_bio_wait(bio); | 118 | ret = submit_bio_wait(bio); |
| @@ -649,8 +649,7 @@ static int attempt_merge(struct request_queue *q, struct request *req, · 648 unmodified lines | |||
| 649 | if (!rq_mergeable(req) || !rq_mergeable(next)) | 649 | if (!rq_mergeable(req) || !rq_mergeable(next)) |
| 650 | return 0; | 650 | return 0; |
| 651 | 651 | ||
| 652 | if (!blk_check_merge_flags(req->cmd_flags, req_op(req), next->cmd_flags, | 652 | if (req_op(req) != req_op(next)) |
| 653 | req_op(next))) | ||
| 654 | return 0; | 653 | return 0; |
| 655 | 654 | ||
| 656 | /* | 655 | /* |
| @@ -752,8 +751,7 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio) · 95 unmodified lines | |||
| 752 | if (!rq_mergeable(rq) || !bio_mergeable(bio)) | 751 | if (!rq_mergeable(rq) || !bio_mergeable(bio)) |
| 753 | return false; | 752 | return false; |
| 754 | 753 | ||
| 755 | if (!blk_check_merge_flags(rq->cmd_flags, req_op(rq), bio->bi_rw, | 754 | if (req_op(rq) != bio_op(bio)) |
| 756 | bio_op(bio))) | ||
| 757 | return false; | 755 | return false; |
| 758 | 756 | ||
| 759 | /* different data direction or already started, don't merge */ | 757 | /* different data direction or already started, don't merge */ |
| @@ -480,7 +480,7 @@ static int xen_vbd_create(struct xen_blkif *blkif, blkif_vdev_t handle, · 479 unmodified lines | |||
| 480 | if (q && test_bit(QUEUE_FLAG_WC, &q->queue_flags)) | 480 | if (q && test_bit(QUEUE_FLAG_WC, &q->queue_flags)) |
| 481 | vbd->flush_support = true; | 481 | vbd->flush_support = true; |
| 482 | 482 | ||
| 483 | if (q && blk_queue_secdiscard(q)) | 483 | if (q && blk_queue_secure_erase(q)) |
| 484 | vbd->discard_secure = true; | 484 | vbd->discard_secure = true; |
| 485 | 485 | ||
| 486 | pr_debug("Successful creation of handle=%04x (dom=%u)\n", | 486 | pr_debug("Successful creation of handle=%04x (dom=%u)\n", |
| @@ -545,7 +545,7 @@ static int blkif_queue_discard_req(struct request *req, struct blkfront_ring_inf · 544 unmodified lines | |||
| 545 | ring_req->u.discard.nr_sectors = blk_rq_sectors(req); | 545 | ring_req->u.discard.nr_sectors = blk_rq_sectors(req); |
| 546 | ring_req->u.discard.id = id; | 546 | ring_req->u.discard.id = id; |
| 547 | ring_req->u.discard.sector_number = (blkif_sector_t)blk_rq_pos(req); | 547 | ring_req->u.discard.sector_number = (blkif_sector_t)blk_rq_pos(req); |
| 548 | if ((req->cmd_flags & REQ_SECURE) && info->feature_secdiscard) | 548 | if (req_op(req) == REQ_OP_SECURE_ERASE && info->feature_secdiscard) |
| 549 | ring_req->u.discard.flag = BLKIF_DISCARD_SECURE; | 549 | ring_req->u.discard.flag = BLKIF_DISCARD_SECURE; |
| 550 | else | 550 | else |
| 551 | ring_req->u.discard.flag = 0; | 551 | ring_req->u.discard.flag = 0; |
| @@ -841,7 +841,7 @@ static int blkif_queue_request(struct request *req, struct blkfront_ring_info *r · 289 unmodified lines | |||
| 841 | return 1; | 841 | return 1; |
| 842 | 842 | ||
| 843 | if (unlikely(req_op(req) == REQ_OP_DISCARD || | 843 | if (unlikely(req_op(req) == REQ_OP_DISCARD || |
| 844 | req->cmd_flags & REQ_SECURE)) | 844 | req_op(req) == REQ_OP_SECURE_ERASE)) |
| 845 | return blkif_queue_discard_req(req, rinfo); | 845 | return blkif_queue_discard_req(req, rinfo); |
| 846 | else | 846 | else |
| 847 | return blkif_queue_rw_req(req, rinfo); | 847 | return blkif_queue_rw_req(req, rinfo); |
| @@ -955,7 +955,7 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size, · 107 unmodified lines | |||
| 955 | rq->limits.discard_granularity = info->discard_granularity; | 955 | rq->limits.discard_granularity = info->discard_granularity; |
| 956 | rq->limits.discard_alignment = info->discard_alignment; | 956 | rq->limits.discard_alignment = info->discard_alignment; |
| 957 | if (info->feature_secdiscard) | 957 | if (info->feature_secdiscard) |
| 958 | queue_flag_set_unlocked(QUEUE_FLAG_SECDISCARD, rq); | 958 | queue_flag_set_unlocked(QUEUE_FLAG_SECERASE, rq); |
| 959 | } | 959 | } |
| 960 | 960 | ||
| 961 | /* Hard sector size and max sectors impersonate the equiv. hardware. */ | 961 | /* Hard sector size and max sectors impersonate the equiv. hardware. */ |
| @@ -1595,7 +1595,7 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id) · 633 unmodified lines | |||
| 1595 | info->feature_discard = 0; | 1595 | info->feature_discard = 0; |
| 1596 | info->feature_secdiscard = 0; | 1596 | info->feature_secdiscard = 0; |
| 1597 | queue_flag_clear(QUEUE_FLAG_DISCARD, rq); | 1597 | queue_flag_clear(QUEUE_FLAG_DISCARD, rq); |
| 1598 | queue_flag_clear(QUEUE_FLAG_SECDISCARD, rq); | 1598 | queue_flag_clear(QUEUE_FLAG_SECERASE, rq); |
| 1599 | } | 1599 | } |
| 1600 | blk_mq_complete_request(req, error); | 1600 | blk_mq_complete_request(req, error); |
| 1601 | break; | 1601 | break; |
| @@ -2052,10 +2052,14 @@ static int blkif_recover(struct blkfront_info *info) · 450 unmodified lines | |||
| 2052 | */ | 2052 | */ |
| 2053 | if (req_op(copy[i].request) == REQ_OP_FLUSH || | 2053 | if (req_op(copy[i].request) == REQ_OP_FLUSH || |
| 2054 | req_op(copy[i].request) == REQ_OP_DISCARD || | 2054 | req_op(copy[i].request) == REQ_OP_DISCARD || |
| 2055 | copy[i].request->cmd_flags & (REQ_FUA | REQ_SECURE)) { | 2055 | req_op(copy[i].request) == REQ_OP_SECURE_ERASE || |
| 2056 | copy[i].request->cmd_flags & REQ_FUA) { | ||
| 2056 | /* | 2057 | /* |
| 2057 | * Flush operations don't contain bios, so | 2058 | * Flush operations don't contain bios, so |
| 2058 | * we need to requeue the whole request | 2059 | * we need to requeue the whole request |
| 2060 | * | ||
| 2061 | * XXX: but this doesn't make any sense for a | ||
| 2062 | * write with the FUA flag set.. | ||
| 2059 | */ | 2063 | */ |
| 2060 | list_add(©[i].request->queuelist, &requests); | 2064 | list_add(©[i].request->queuelist, &requests); |
| 2061 | continue; | 2065 | continue; |
| @@ -1058,7 +1058,6 @@ static void raid1_make_request(struct mddev *mddev, struct bio * bio) · 1057 unmodified lines | |||
| 1058 | const unsigned long do_sync = (bio->bi_rw & REQ_SYNC); | 1058 | const unsigned long do_sync = (bio->bi_rw & REQ_SYNC); |
| 1059 | const unsigned long do_flush_fua = (bio->bi_rw & | 1059 | const unsigned long do_flush_fua = (bio->bi_rw & |
| 1060 | (REQ_PREFLUSH | REQ_FUA)); | 1060 | (REQ_PREFLUSH | REQ_FUA)); |
| 1061 | const unsigned long do_sec = (bio->bi_rw & REQ_SECURE); | ||
| 1062 | struct md_rdev *blocked_rdev; | 1061 | struct md_rdev *blocked_rdev; |
| 1063 | struct blk_plug_cb *cb; | 1062 | struct blk_plug_cb *cb; |
| 1064 | struct raid1_plug_cb *plug = NULL; | 1063 | struct raid1_plug_cb *plug = NULL; |
| @@ -1376,7 +1375,7 @@ read_again: · 311 unmodified lines | |||
| 1376 | conf->mirrors[i].rdev->data_offset); | 1375 | conf->mirrors[i].rdev->data_offset); |
| 1377 | mbio->bi_bdev = conf->mirrors[i].rdev->bdev; | 1376 | mbio->bi_bdev = conf->mirrors[i].rdev->bdev; |
| 1378 | mbio->bi_end_io = raid1_end_write_request; | 1377 | mbio->bi_end_io = raid1_end_write_request; |
| 1379 | bio_set_op_attrs(mbio, op, do_flush_fua | do_sync | do_sec); | 1378 | bio_set_op_attrs(mbio, op, do_flush_fua | do_sync); |
| 1380 | mbio->bi_private = r1_bio; | 1379 | mbio->bi_private = r1_bio; |
| 1381 | 1380 | ||
| 1382 | atomic_inc(&r1_bio->remaining); | 1381 | atomic_inc(&r1_bio->remaining); |
| @@ -1062,7 +1062,6 @@ static void __make_request(struct mddev *mddev, struct bio *bio) · 1061 unmodified lines | |||
| 1062 | const int rw = bio_data_dir(bio); | 1062 | const int rw = bio_data_dir(bio); |
| 1063 | const unsigned long do_sync = (bio->bi_rw & REQ_SYNC); | 1063 | const unsigned long do_sync = (bio->bi_rw & REQ_SYNC); |
| 1064 | const unsigned long do_fua = (bio->bi_rw & REQ_FUA); | 1064 | const unsigned long do_fua = (bio->bi_rw & REQ_FUA); |
| 1065 | const unsigned long do_sec = (bio->bi_rw & REQ_SECURE); | ||
| 1066 | unsigned long flags; | 1065 | unsigned long flags; |
| 1067 | struct md_rdev *blocked_rdev; | 1066 | struct md_rdev *blocked_rdev; |
| 1068 | struct blk_plug_cb *cb; | 1067 | struct blk_plug_cb *cb; |
| @@ -1362,7 +1361,7 @@ retry_write: · 293 unmodified lines | |||
| 1362 | rdev)); | 1361 | rdev)); |
| 1363 | mbio->bi_bdev = rdev->bdev; | 1362 | mbio->bi_bdev = rdev->bdev; |
| 1364 | mbio->bi_end_io = raid10_end_write_request; | 1363 | mbio->bi_end_io = raid10_end_write_request; |
| 1365 | bio_set_op_attrs(mbio, op, do_sync | do_fua | do_sec); | 1364 | bio_set_op_attrs(mbio, op, do_sync | do_fua); |
| 1366 | mbio->bi_private = r10_bio; | 1365 | mbio->bi_private = r10_bio; |
| 1367 | 1366 | ||
| 1368 | atomic_inc(&r10_bio->remaining); | 1367 | atomic_inc(&r10_bio->remaining); |
| @@ -1404,7 +1403,7 @@ retry_write: · 35 unmodified lines | |||
| 1404 | r10_bio, rdev)); | 1403 | r10_bio, rdev)); |
| 1405 | mbio->bi_bdev = rdev->bdev; | 1404 | mbio->bi_bdev = rdev->bdev; |
| 1406 | mbio->bi_end_io = raid10_end_write_request; | 1405 | mbio->bi_end_io = raid10_end_write_request; |
| 1407 | bio_set_op_attrs(mbio, op, do_sync | do_fua | do_sec); | 1406 | bio_set_op_attrs(mbio, op, do_sync | do_fua); |
| 1408 | mbio->bi_private = r10_bio; | 1407 | mbio->bi_private = r10_bio; |
| 1409 | 1408 | ||
| 1410 | atomic_inc(&r10_bio->remaining); | 1409 | atomic_inc(&r10_bio->remaining); |
| @@ -2167,10 +2167,12 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) · 2166 unmodified lines | |||
| 2167 | /* complete ongoing async transfer before issuing discard */ | 2167 | /* complete ongoing async transfer before issuing discard */ |
| 2168 | if (card->host->areq) | 2168 | if (card->host->areq) |
| 2169 | mmc_blk_issue_rw_rq(mq, NULL); | 2169 | mmc_blk_issue_rw_rq(mq, NULL); |
| 2170 | if (req->cmd_flags & REQ_SECURE) | 2170 | ret = mmc_blk_issue_discard_rq(mq, req); |
| 2171 | ret = mmc_blk_issue_secdiscard_rq(mq, req); | 2171 | } else if (req && req_op(req) == REQ_OP_SECURE_ERASE) { |
| 2172 | else | 2172 | /* complete ongoing async transfer before issuing secure erase*/ |
| 2173 | ret = mmc_blk_issue_discard_rq(mq, req); | 2173 | if (card->host->areq) |
| 2174 | mmc_blk_issue_rw_rq(mq, NULL); | ||
| 2175 | ret = mmc_blk_issue_secdiscard_rq(mq, req); | ||
| 2174 | } else if (req && req_op(req) == REQ_OP_FLUSH) { | 2176 | } else if (req && req_op(req) == REQ_OP_FLUSH) { |
| 2175 | /* complete ongoing async transfer before issuing flush */ | 2177 | /* complete ongoing async transfer before issuing flush */ |
| 2176 | if (card->host->areq) | 2178 | if (card->host->areq) |
| @@ -171,7 +171,7 @@ static void mmc_queue_setup_discard(struct request_queue *q, · 170 unmodified lines | |||
| 171 | if (card->pref_erase > max_discard) | 171 | if (card->pref_erase > max_discard) |
| 172 | q->limits.discard_granularity = 0; | 172 | q->limits.discard_granularity = 0; |
| 173 | if (mmc_can_secure_erase_trim(card)) | 173 | if (mmc_can_secure_erase_trim(card)) |
| 174 | queue_flag_set_unlocked(QUEUE_FLAG_SECDISCARD, q); | 174 | queue_flag_set_unlocked(QUEUE_FLAG_SECERASE, q); |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | /** | 177 | /** |
| @@ -163,7 +163,6 @@ enum rq_flag_bits { · 162 unmodified lines | |||
| 163 | __REQ_SYNC, /* request is sync (sync write or read) */ | 163 | __REQ_SYNC, /* request is sync (sync write or read) */ |
| 164 | __REQ_META, /* metadata io request */ | 164 | __REQ_META, /* metadata io request */ |
| 165 | __REQ_PRIO, /* boost priority in cfq */ | 165 | __REQ_PRIO, /* boost priority in cfq */ |
| 166 | __REQ_SECURE, /* secure discard (used with REQ_OP_DISCARD) */ | ||
| 167 | 166 | ||
| 168 | __REQ_NOIDLE, /* don't anticipate more IO after this one */ | 167 | __REQ_NOIDLE, /* don't anticipate more IO after this one */ |
| 169 | __REQ_INTEGRITY, /* I/O includes block integrity payload */ | 168 | __REQ_INTEGRITY, /* I/O includes block integrity payload */ |
| @@ -212,7 +211,7 @@ enum rq_flag_bits { · 42 unmodified lines | |||
| 212 | (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER) | 211 | (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER) |
| 213 | #define REQ_COMMON_MASK \ | 212 | #define REQ_COMMON_MASK \ |
| 214 | (REQ_FAILFAST_MASK | REQ_SYNC | REQ_META | REQ_PRIO | REQ_NOIDLE | \ | 213 | (REQ_FAILFAST_MASK | REQ_SYNC | REQ_META | REQ_PRIO | REQ_NOIDLE | \ |
| 215 | REQ_PREFLUSH | REQ_FUA | REQ_SECURE | REQ_INTEGRITY | REQ_NOMERGE) | 214 | REQ_PREFLUSH | REQ_FUA | REQ_INTEGRITY | REQ_NOMERGE) |
| 216 | #define REQ_CLONE_MASK REQ_COMMON_MASK | 215 | #define REQ_CLONE_MASK REQ_COMMON_MASK |
| 217 | 216 | ||
| 218 | /* This mask is used for both bio and request merge checking */ | 217 | /* This mask is used for both bio and request merge checking */ |
| @@ -239,7 +238,6 @@ enum rq_flag_bits { · 20 unmodified lines | |||
| 239 | #define REQ_FLUSH_SEQ (1ULL << __REQ_FLUSH_SEQ) | 238 | #define REQ_FLUSH_SEQ (1ULL << __REQ_FLUSH_SEQ) |
| 240 | #define REQ_IO_STAT (1ULL << __REQ_IO_STAT) | 239 | #define REQ_IO_STAT (1ULL << __REQ_IO_STAT) |
| 241 | #define REQ_MIXED_MERGE (1ULL << __REQ_MIXED_MERGE) | 240 | #define REQ_MIXED_MERGE (1ULL << __REQ_MIXED_MERGE) |
| 242 | #define REQ_SECURE (1ULL << __REQ_SECURE) | ||
| 243 | #define REQ_PM (1ULL << __REQ_PM) | 241 | #define REQ_PM (1ULL << __REQ_PM) |
| 244 | #define REQ_HASHED (1ULL << __REQ_HASHED) | 242 | #define REQ_HASHED (1ULL << __REQ_HASHED) |
| 245 | #define REQ_MQ_INFLIGHT (1ULL << __REQ_MQ_INFLIGHT) | 243 | #define REQ_MQ_INFLIGHT (1ULL << __REQ_MQ_INFLIGHT) |
| @@ -248,6 +246,7 @@ enum req_op { · 2 unmodified lines | |||
| 248 | REQ_OP_READ, | 246 | REQ_OP_READ, |
| 249 | REQ_OP_WRITE, | 247 | REQ_OP_WRITE, |
| 250 | REQ_OP_DISCARD, /* request to discard sectors */ | 248 | REQ_OP_DISCARD, /* request to discard sectors */ |
| 249 | REQ_OP_SECURE_ERASE, /* request to securely erase sectors */ | ||
| 251 | REQ_OP_WRITE_SAME, /* write same block many times */ | 250 | REQ_OP_WRITE_SAME, /* write same block many times */ |
| 252 | REQ_OP_FLUSH, /* request for cache flush */ | 251 | REQ_OP_FLUSH, /* request for cache flush */ |
| 253 | }; | 252 | }; |
| @@ -497,7 +497,7 @@ struct request_queue { · 496 unmodified lines | |||
| 497 | #define QUEUE_FLAG_DISCARD 14 /* supports DISCARD */ | 497 | #define QUEUE_FLAG_DISCARD 14 /* supports DISCARD */ |
| 498 | #define QUEUE_FLAG_NOXMERGES 15 /* No extended merges */ | 498 | #define QUEUE_FLAG_NOXMERGES 15 /* No extended merges */ |
| 499 | #define QUEUE_FLAG_ADD_RANDOM 16 /* Contributes to random pool */ | 499 | #define QUEUE_FLAG_ADD_RANDOM 16 /* Contributes to random pool */ |
| 500 | #define QUEUE_FLAG_SECDISCARD 17 /* supports SECDISCARD */ | 500 | #define QUEUE_FLAG_SECERASE 17 /* supports secure erase */ |
| 501 | #define QUEUE_FLAG_SAME_FORCE 18 /* force complete on same CPU */ | 501 | #define QUEUE_FLAG_SAME_FORCE 18 /* force complete on same CPU */ |
| 502 | #define QUEUE_FLAG_DEAD 19 /* queue tear-down finished */ | 502 | #define QUEUE_FLAG_DEAD 19 /* queue tear-down finished */ |
| 503 | #define QUEUE_FLAG_INIT_DONE 20 /* queue is initialized */ | 503 | #define QUEUE_FLAG_INIT_DONE 20 /* queue is initialized */ |
| @@ -593,8 +593,8 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q) · 89 unmodified lines | |||
| 593 | #define blk_queue_stackable(q) \ | 593 | #define blk_queue_stackable(q) \ |
| 594 | test_bit(QUEUE_FLAG_STACKABLE, &(q)->queue_flags) | 594 | test_bit(QUEUE_FLAG_STACKABLE, &(q)->queue_flags) |
| 595 | #define blk_queue_discard(q) test_bit(QUEUE_FLAG_DISCARD, &(q)->queue_flags) | 595 | #define blk_queue_discard(q) test_bit(QUEUE_FLAG_DISCARD, &(q)->queue_flags) |
| 596 | #define blk_queue_secdiscard(q) (blk_queue_discard(q) && \ | 596 | #define blk_queue_secure_erase(q) \ |
| 597 | test_bit(QUEUE_FLAG_SECDISCARD, &(q)->queue_flags)) | 597 | (test_bit(QUEUE_FLAG_SECERASE, &(q)->queue_flags)) |
| 598 | 598 | ||
| 599 | #define blk_noretry_request(rq) \ | 599 | #define blk_noretry_request(rq) \ |
| 600 | ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \ | 600 | ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \ |
| @@ -675,21 +675,6 @@ static inline bool rq_mergeable(struct request *rq) · 74 unmodified lines | |||
| 675 | return true; | 675 | return true; |
| 676 | } | 676 | } |
| 677 | 677 | ||
| 678 | static inline bool blk_check_merge_flags(unsigned int flags1, unsigned int op1, | ||
| 679 | unsigned int flags2, unsigned int op2) | ||
| 680 | { | ||
| 681 | if ((op1 == REQ_OP_DISCARD) != (op2 == REQ_OP_DISCARD)) | ||
| 682 | return false; | ||
| 683 | |||
| 684 | if ((flags1 & REQ_SECURE) != (flags2 & REQ_SECURE)) | ||
| 685 | return false; | ||
| 686 | |||
| 687 | if ((op1 == REQ_OP_WRITE_SAME) != (op2 == REQ_OP_WRITE_SAME)) | ||
| 688 | return false; | ||
| 689 | |||
| 690 | return true; | ||
| 691 | } | ||
| 692 | |||
| 693 | static inline bool blk_write_same_mergeable(struct bio *a, struct bio *b) | 678 | static inline bool blk_write_same_mergeable(struct bio *a, struct bio *b) |
| 694 | { | 679 | { |
| 695 | if (bio_data(a) == bio_data(b)) | 680 | if (bio_data(a) == bio_data(b)) |
| @@ -1158,7 +1143,7 @@ extern int blkdev_issue_flush(struct block_device *, gfp_t, sector_t *); · 462 unmodified lines | |||
| 1158 | extern int blkdev_issue_discard(struct block_device *bdev, sector_t sector, | 1143 | extern int blkdev_issue_discard(struct block_device *bdev, sector_t sector, |
| 1159 | sector_t nr_sects, gfp_t gfp_mask, unsigned long flags); | 1144 | sector_t nr_sects, gfp_t gfp_mask, unsigned long flags); |
| 1160 | extern int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, | 1145 | extern int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, |
| 1161 | sector_t nr_sects, gfp_t gfp_mask, int op_flags, | 1146 | sector_t nr_sects, gfp_t gfp_mask, int flags, |
| 1162 | struct bio **biop); | 1147 | struct bio **biop); |
| 1163 | extern int blkdev_issue_write_same(struct block_device *bdev, sector_t sector, | 1148 | extern int blkdev_issue_write_same(struct block_device *bdev, sector_t sector, |
| 1164 | sector_t nr_sects, gfp_t gfp_mask, struct page *page); | 1149 | sector_t nr_sects, gfp_t gfp_mask, struct page *page); |
| @@ -1791,6 +1791,10 @@ void blk_fill_rwbs(char *rwbs, int op, u32 rw, int bytes) · 1790 unmodified lines | |||
| 1791 | case REQ_OP_DISCARD: | 1791 | case REQ_OP_DISCARD: |
| 1792 | rwbs[i++] = 'D'; | 1792 | rwbs[i++] = 'D'; |
| 1793 | break; | 1793 | break; |
| 1794 | case REQ_OP_SECURE_ERASE: | ||
| 1795 | rwbs[i++] = 'D'; | ||
| 1796 | rwbs[i++] = 'E'; | ||
| 1797 | break; | ||
| 1794 | case REQ_OP_FLUSH: | 1798 | case REQ_OP_FLUSH: |
| 1795 | rwbs[i++] = 'F'; | 1799 | rwbs[i++] = 'F'; |
| 1796 | break; | 1800 | break; |
| @@ -1809,8 +1813,6 @@ void blk_fill_rwbs(char *rwbs, int op, u32 rw, int bytes) · 12 unmodified lines | |||
| 1809 | rwbs[i++] = 'S'; | 1813 | rwbs[i++] = 'S'; |
| 1810 | if (rw & REQ_META) | 1814 | if (rw & REQ_META) |
| 1811 | rwbs[i++] = 'M'; | 1815 | rwbs[i++] = 'M'; |
| 1812 | if (rw & REQ_SECURE) | ||
| 1813 | rwbs[i++] = 'E'; | ||
| 1814 | 1816 | ||
| 1815 | rwbs[i] = '\0'; | 1817 | rwbs[i] = '\0'; |
| 1816 | } | 1818 | } |