clean up block ops defintions
Subsystems (14)
Christoph Hellwig
maintainerHi Jens,
this series takes advantage of the the new REQ_OP* scheme to further clean up the way how we classify bios and requests.
After the series both the bio and request have a field where the REQ_OP operation is stored in directly without any shiting around, and the coomon REQ_* flags can be ORed into directly as well. All the bio flags are now in the existing bi_flags field, and the many request-only flags are moved into a new field in struct request, which is split off cmd_flags.
Last but not least this series ensures that we can encode the operational direction of a command in it's code. Currently the op_is_write, bio_data_dir and rq_data_dir helpers all assume that everything but a READ is a data out command. This surprisingly actually was true until this week, but the new shingled driver support conflicts with it - it's just that the relevant path didn't use any of these helpers so that issue wasn't noticed.
Christoph Hellwig
maintainerPATCH 1/7 block: remove bio_is_rw
With the addition of the zoned operations the tests in this function became incorrect. But I think it's much better to just open code the allow operations in the only caller anyway.
--- block/bio-integrity.c | 2 +- include/linux/bio.h | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-)
block/bio-integrity.c +1 -1
@@ -172,7 +172,7 @@ bool bio_integrity_enabled(struct bio *bio) {struct blk_integrity *bi =bdev_get_integrity (bio->bi_bdev); -if (!bio_is_rw (bio)) +if (bio_op (bio) !=REQ_OP_READ &&bio_op (bio) !=REQ_OP_WRITE )return false;/* Already protected? */
include/linux/bio.h +0 -11
@@ -83,17 +83,6 @@ static inline bool bio_no_advance_iter(struct bio *bio)bio_op (bio) ==REQ_OP_WRITE_SAME ; } -static inline bool bio_is_rw (struct bio *bio) -{ -if (!bio_has_data (bio)) -return false; - -if (bio_no_advance_iter (bio)) -return false; - -return true; -} -static inline bool bio_mergeable (struct bio *bio) {if (bio->bi_opf &REQ_NOMERGE_FLAGS )
Signature · 1 line
2.1.4
Christoph Hellwig
maintainerPATCH 2/7 block: REQ_NOMERGE is common to the bio and request
In reply to Christoph HellwigSo move it into the common setion of the request flags.
--- include/linux/blk_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/blk_types.h +1 -1
@@ -158,6 +158,7 @@ enum rq_flag_bits { __REQ_META,/* metadata io request */ __REQ_PRIO,/* boost priority in cfq */ + __REQ_NOMERGE,/* don't touch this for merging */ __REQ_NOIDLE,/* don't anticipate more IO after this one */ __REQ_INTEGRITY,/* I/O includes block integrity payload */ __REQ_FUA, /* forced unit access */
@@ -171,7 +172,6 @@ enum rq_flag_bits {/* request only flags */ __REQ_SORTED,/* elevator knows about this request */ __REQ_SOFTBARRIER,/* may not be passed by ioscheduler */ - __REQ_NOMERGE,/* don't touch this for merging */ __REQ_STARTED,/* drive already may have started this one */ __REQ_DONTPREP,/* don't call prep for this one */ __REQ_QUEUED, /* uses queueing */
Signature · 1 line
2.1.4
Christoph Hellwig
maintainerPATCH 3/7 block: move REQ_RAHEAD to common flags
In reply to Christoph HellwigThe information that am I/O is a read-ahead can be useful for drivers. In fact the NVMe driver already checks it, even if it won't ever be set at the moment.
--- include/linux/blk_types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/blk_types.h +2 -2
@@ -163,9 +163,9 @@ enum rq_flag_bits { __REQ_INTEGRITY,/* I/O includes block integrity payload */ __REQ_FUA,/* forced unit access */ __REQ_PREFLUSH,/* request for cache flush */ + __REQ_RAHEAD,/* read ahead, can fail anytime */ /* bio only flags */ - __REQ_RAHEAD,/* read ahead, can fail anytime */ __REQ_THROTTLED, /* This bio has already been subjected to* throttling rules. Don't do it again. */
@@ -205,7 +205,7 @@ enum rq_flag_bits { (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER)#define REQ_COMMON_MASK \ (REQ_FAILFAST_MASK | REQ_SYNC | REQ_META | REQ_PRIO | REQ_NOIDLE | \ - REQ_PREFLUSH | REQ_FUA | REQ_INTEGRITY | REQ_NOMERGE) + REQ_PREFLUSH | REQ_FUA | REQ_INTEGRITY | REQ_NOMERGE | REQ_RAHEAD)#define REQ_CLONE_MASK REQ_COMMON_MASK/* This mask is used for both bio and request merge checking */
Signature · 1 line
2.1.4
Christoph Hellwig
maintainerPATCH 4/7 block: replace REQ_THROTTLED with a bio flag
In reply to Christoph HellwigIt's the last bio-only REQ_* flag, and we have space for it in the bio bi_flags field.
--- block/blk-throttle.c | 10 +++++----- include/linux/blk_types.h | 8 ++------ 2 files changed, 7 insertions(+), 11 deletions(-)
block/blk-throttle.c +5 -5
@@ -818,13 +818,13 @@ static void throtl_charge_bio(struct throtl_grp *tg, struct bio *bio) tg->io_disp[rw]++;/* -* REQ_THROTTLED is used to prevent the same bio to be throttled +* BIO_THROTTLED is used to prevent the same bio to be throttled * more than once as a throttled bio will go through blk-throtl the * second time when it eventually gets issued. Set it when a bio * is being charged to a tg. */ -if (!(bio->bi_opf &REQ_THROTTLED )) - bio->bi_opf |=REQ_THROTTLED ; +if (!bio_flagged (bio,BIO_THROTTLED )) +bio_set_flag (bio,BIO_THROTTLED ); }/**
@@ -1401,7 +1401,7 @@ bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,WARN_ON_ONCE (!rcu_read_lock_held ());/* see throtl_charge_bio() */ -if ((bio->bi_opf &REQ_THROTTLED ) || !tg->has_rules[rw]) +if (bio_flagged (bio,BIO_THROTTLED ) || !tg->has_rules[rw]) goto out;spin_lock_irq (q->queue_lock);
@@ -1480,7 +1480,7 @@ bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,* being issued. */ if (!throttled) - bio->bi_opf &= ~REQ_THROTTLED ; +bio_clear_flag (bio,BIO_THROTTLED );return throttled; }
include/linux/blk_types.h +2 -6
@@ -119,6 +119,8 @@ struct bio {#define BIO_QUIET 6/* Make BIO Quiet */ #define BIO_CHAIN 7/* chained bio, ->bi_remaining in effect */ #define BIO_REFFED 8/* bio has elevated ->bi_cnt */ +#define BIO_THROTTLED 9/* This bio has already been subjected to +* throttling rules. Don't do it again. */ /* * Flags starting here get preserved by bio_reset() - this includes
@@ -165,10 +167,6 @@ enum rq_flag_bits { __REQ_PREFLUSH,/* request for cache flush */ __REQ_RAHEAD,/* read ahead, can fail anytime */ -/* bio only flags */ - __REQ_THROTTLED,/* This bio has already been subjected to -* throttling rules. Don't do it again. */ -/* request only flags */ __REQ_SORTED,/* elevator knows about this request */ __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */
@@ -213,8 +211,6 @@ enum rq_flag_bits { (REQ_NOMERGE | REQ_STARTED | REQ_SOFTBARRIER | REQ_PREFLUSH | REQ_FUA | REQ_FLUSH_SEQ)#define REQ_RAHEAD (1ULL << __REQ_RAHEAD) -#define REQ_THROTTLED (1ULL << __REQ_THROTTLED) -#define REQ_SORTED (1ULL << __REQ_SORTED)#define REQ_SOFTBARRIER (1ULL << __REQ_SOFTBARRIER)#define REQ_FUA (1ULL << __REQ_FUA)
Signature · 1 line
2.1.4
Christoph Hellwig
maintainerPATCH 5/7 block: split out request-only flags into a new namespace
In reply to Christoph HellwigA lot of the REQ_* flags are only used on struct requests, and only of use to the block layer and a few drivers that dig into struct request internals.
This patch adds a new req_flags_t rq_flags field to struct request for them, and thus dramatically shrinks the number of common requests. It also removes the unfortunate situation where we have to fit the fields from the same enum into 32 bits for struct bio and 64 bits for struct request.
--- Documentation/block/biodoc.txt | 2 +- block/blk-core.c | 71 ++++++++++++++------------- block/blk-exec.c | 2 +- block/blk-flush.c | 9 ++-- block/blk-map.c | 4 +- block/blk-merge.c | 8 +-- block/blk-mq.c | 19 ++++---- block/blk-tag.c | 6 +-- block/blk.h | 4 +- block/elevator.c | 32 ++++++------ drivers/block/pktcdvd.c | 2 +- drivers/ide/ide-atapi.c | 6 +-- drivers/ide/ide-cd.c | 46 +++++++++--------- drivers/ide/ide-cd.h | 2 +- drivers/ide/ide-cd_ioctl.c | 6 +-- drivers/ide/ide-io.c | 6 +-- drivers/ide/ide-pm.c | 4 +- drivers/md/dm-rq.c | 12 ++--- drivers/memstick/core/ms_block.c | 2 +- drivers/memstick/core/mspro_block.c | 2 +- drivers/mmc/card/block.c | 4 +- drivers/mmc/card/queue.c | 4 +- drivers/nvme/host/pci.c | 4 +- drivers/scsi/device_handler/scsi_dh_alua.c | 8 +-- drivers/scsi/device_handler/scsi_dh_emc.c | 2 +- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 2 +- drivers/scsi/device_handler/scsi_dh_rdac.c | 2 +- drivers/scsi/osd/osd_initiator.c | 2 +- drivers/scsi/osst.c | 2 +- drivers/scsi/scsi_error.c | 2 +- drivers/scsi/scsi_lib.c | 75 +++++++++++++++++------------ drivers/scsi/sd.c | 6 +-- drivers/scsi/sd_zbc.c | 2 +- drivers/scsi/st.c | 2 +- drivers/scsi/ufs/ufshcd.c | 6 +-- include/linux/blk_types.h | 39 +-------------- include/linux/blkdev.h | 49 ++++++++++++++++++- include/scsi/scsi_device.h | 4 +- 38 files changed, 242 insertions(+), 218 deletions(-)
Documentation/block/biodoc.txt +1 -1
@@ -348,7 +348,7 @@ Drivers can now specify a request prepare function (q->prep_rq_fn) that the block layer would invoke to pre-build device commands for a given request, or perform other preparatory processing for the request. This is routine is called by elv_next_request(), i.e. typically just before servicing a request. -(The prepare function would not be called for requests that have REQ_DONTPREP +(The prepare function would not be called for requests that have RQF_DONTPREP enabled) Aside:
block/blk-core.c +37 -34
259 lines not on this page · raw message
block/blk-exec.c +1 -1
@@ -72,7 +72,7 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,spin_lock_irq (q->queue_lock);if (unlikely (blk_queue_dying (q))) { - rq->cmd_flags |=REQ_QUIET ; + rq->rq_flags |=RQF_QUIET ; rq->errors = -ENXIO ;__blk_end_request_all (rq, rq->errors);spin_unlock_irq (q->queue_lock);
block/blk-flush.c +5 -4
@@ -56,7 +56,7 @@* Once while executing DATA and again after the whole sequence is * complete. The first completion updates the contained bio but doesn't * finish it so that the bio submitter is notified only after the whole -* sequence is complete. This is implemented by testing REQ_FLUSH_SEQ in +* sequence is complete. This is implemented by testing RQF_FLUSH_SEQ in * req_bio_endio(). * * The above peculiarity requires that each FLUSH/FUA request has only one
@@ -127,7 +127,7 @@ static void blk_flush_restore_request(struct request *rq) rq->bio = rq->biotail;/* make @rq a normal request */ - rq->cmd_flags &= ~REQ_FLUSH_SEQ ; + rq->rq_flags &= ~RQF_FLUSH_SEQ ; rq->end_io = rq->flush.saved_end_io; }
@@ -330,7 +330,8 @@ static bool blk_kick_flush(struct request_queue *q, struct blk_flush_queue *fq) } flush_rq->cmd_type =REQ_TYPE_FS ; -req_set_op_attrs (flush_rq,REQ_OP_FLUSH ,WRITE_FLUSH |REQ_FLUSH_SEQ ); +req_set_op_attrs (flush_rq,REQ_OP_FLUSH ,WRITE_FLUSH ); + flush_rq->rq_flags |=RQF_FLUSH_SEQ ; flush_rq->rq_disk = first_rq->rq_disk; flush_rq->end_io = flush_end_io;
@@ -433,7 +434,7 @@ void blk_insert_flush(struct request *rq)*/ memset (&rq->flush,0 ,sizeof (rq->flush));INIT_LIST_HEAD (&rq->flush.list); - rq->cmd_flags |=REQ_FLUSH_SEQ ; + rq->rq_flags |=RQF_FLUSH_SEQ ; rq->flush.saved_end_io = rq->end_io;/* Usually NULL */ if (q->mq_ops) { rq->end_io = mq_flush_data_end_io;
block/blk-map.c +2 -2
@@ -135,7 +135,7 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq, }while (iov_iter_count (&i));if (!bio_flagged (bio,BIO_USER_MAPPED )) - rq->cmd_flags |=REQ_COPY_USER ; + rq->rq_flags |=RQF_COPY_USER ;return 0 ; unmap_rq:
@@ -232,7 +232,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,bio_set_op_attrs (bio,REQ_OP_WRITE ,0 );if (do_copy) - rq->cmd_flags |=REQ_COPY_USER ; + rq->rq_flags |=RQF_COPY_USER ; ret =blk_rq_append_bio (rq, bio);if (unlikely (ret)) {
block/blk-merge.c +4 -4
@@ -456,7 +456,7 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq,if (rq->bio) nsegs =__blk_bios_map_sg (q, rq->bio, sglist, &sg); -if (unlikely (rq->cmd_flags &REQ_COPY_USER ) && +if (unlikely (rq->rq_flags &RQF_COPY_USER ) && (blk_rq_bytes (rq) & q->dma_pad_mask)) {unsigned int pad_len = (q->dma_pad_mask & ~blk_rq_bytes (rq)) +1 ;
@@ -634,7 +634,7 @@ void blk_rq_set_mixed_merge(struct request *rq)unsigned int ff = rq->cmd_flags &REQ_FAILFAST_MASK ;struct bio *bio; -if (rq->cmd_flags &REQ_MIXED_MERGE ) +if (rq->rq_flags &RQF_MIXED_MERGE )return ;/*
@@ -647,7 +647,7 @@ void blk_rq_set_mixed_merge(struct request *rq) (bio->bi_opf & REQ_FAILFAST_MASK) != ff); bio->bi_opf |= ff; } - rq->cmd_flags |=REQ_MIXED_MERGE ; + rq->rq_flags |=RQF_MIXED_MERGE ; }static void blk_account_io_merge (struct request *req)
@@ -709,7 +709,7 @@ static int attempt_merge(struct request_queue *q, struct request *req,* makes sure that all involved bios have mixable attributes * set properly. */ -if ((req->cmd_flags | next->cmd_flags) &REQ_MIXED_MERGE || +if (((req->rq_flags | next->rq_flags) &RQF_MIXED_MERGE ) || (req->cmd_flags &REQ_FAILFAST_MASK ) != (next->cmd_flags &REQ_FAILFAST_MASK )) {blk_rq_set_mixed_merge (req);
block/blk-mq.c +9 -10
@@ -142,14 +142,13 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx, struct request *rq, int op, unsigned int op_flags) { - if (blk_queue_io_stat(q)) - op_flags |= REQ_IO_STAT; - INIT_LIST_HEAD(&rq->queuelist);/* csd/requeue_work/fifo_time is initialized before use */ rq->q = q; rq->mq_ctx = ctx;req_set_op_attrs (rq, op, op_flags); +if (blk_queue_io_stat (q)) + rq->rq_flags |=RQF_IO_STAT ;/* do not touch atomic flags, it needs atomic ops against the timer */ rq->cpu =-1 ;INIT_HLIST_NODE (&rq->hash);
@@ -198,7 +197,7 @@ __blk_mq_alloc_request(struct blk_mq_alloc_data *data, int op, int op_flags) rq = data->hctx->tags->rqs[tag];if (blk_mq_tag_busy (data->hctx)) { - rq->cmd_flags =REQ_MQ_INFLIGHT ; + rq->rq_flags =RQF_MQ_INFLIGHT ;atomic_inc (&data->hctx->nr_active); }
@@ -298,9 +297,9 @@ static void __blk_mq_free_request(struct blk_mq_hw_ctx *hctx,const int tag = rq->tag;struct request_queue *q = rq->q; -if (rq->cmd_flags &REQ_MQ_INFLIGHT ) +if (rq->rq_flags &RQF_MQ_INFLIGHT )atomic_dec (&hctx->nr_active); - rq->cmd_flags =0 ; + rq->rq_flags =0 ;clear_bit (REQ_ATOM_STARTED , &rq->atomic_flags);blk_mq_put_tag (hctx, ctx, tag);
@@ -489,10 +488,10 @@ static void blk_mq_requeue_work(struct work_struct *work)spin_unlock_irqrestore (&q->requeue_lock, flags);list_for_each_entry_safe (rq, next, &rq_list, queuelist) { -if (!(rq->cmd_flags &REQ_SOFTBARRIER )) +if (!(rq->rq_flags &RQF_SOFTBARRIER ))continue ; - rq->cmd_flags &= ~REQ_SOFTBARRIER ; + rq->rq_flags &= ~RQF_SOFTBARRIER ;list_del_init (&rq->queuelist);blk_mq_insert_request (rq, true, false, false); }
@@ -519,11 +518,11 @@ void blk_mq_add_to_requeue_list(struct request *rq, bool at_head)* We abuse this flag that is otherwise used by the I/O scheduler to * request head insertation from the workqueue. */ -BUG_ON (rq->cmd_flags &REQ_SOFTBARRIER ); +BUG_ON (rq->rq_flags &RQF_SOFTBARRIER );spin_lock_irqsave (&q->requeue_lock, flags);if (at_head) { - rq->cmd_flags |=REQ_SOFTBARRIER ; + rq->rq_flags |=RQF_SOFTBARRIER ;list_add (&rq->queuelist, &q->requeue_list); }else {list_add_tail (&rq->queuelist, &q->requeue_list);
block/blk-tag.c +3 -3
@@ -270,7 +270,7 @@ void blk_queue_end_tag(struct request_queue *q, struct request *rq)BUG_ON (tag >= bqt->real_max_depth);list_del_init (&rq->queuelist); - rq->cmd_flags &= ~REQ_QUEUED ; + rq->rq_flags &= ~RQF_QUEUED ; rq->tag =-1 ;if (unlikely (bqt->tag_index[tag] ==NULL ))
@@ -316,7 +316,7 @@ int blk_queue_start_tag(struct request_queue *q, struct request *rq)unsigned max_depth;int tag; -if (unlikely ((rq->cmd_flags &REQ_QUEUED ))) { +if (unlikely ((rq->rq_flags &RQF_QUEUED ))) { printk(KERN_ERR "%s: request %p for device [%s] already tagged %d", __func__, rq,
@@ -371,7 +371,7 @@ int blk_queue_start_tag(struct request_queue *q, struct request *rq)*/ bqt->next_tag = (tag +1 ) % bqt->max_depth; - rq->cmd_flags |=REQ_QUEUED ; + rq->rq_flags |=RQF_QUEUED ; rq->tag = tag; bqt->tag_index[tag] = rq;blk_start_request (rq);
block/blk.h +2 -2
@@ -130,7 +130,7 @@ static inline void blk_clear_rq_complete(struct request *rq)/* * Internal elevator interface */ -#define ELV_ON_HASH (rq) ((rq)->cmd_flags & REQ_HASHED) +#define ELV_ON_HASH (rq) ((rq)->rq_flags & RQF_HASHED)void blk_insert_flush (struct request *rq);
@@ -247,7 +247,7 @@ extern int blk_update_nr_requests(struct request_queue *, unsigned int);static inline int blk_do_io_stat (struct request *rq) {return rq->rq_disk && - (rq->cmd_flags &REQ_IO_STAT ) && + (rq->rq_flags &RQF_IO_STAT ) && (rq->cmd_type ==REQ_TYPE_FS ); }
block/elevator.c +15 -17
@@ -245,7 +245,7 @@ EXPORT_SYMBOL(elevator_exit);static inline void __elv_rqhash_del (struct request *rq) {hash_del (&rq->hash); - rq->cmd_flags &= ~REQ_HASHED ; + rq->rq_flags &= ~RQF_HASHED ; }static void elv_rqhash_del (struct request_queue *q,struct request *rq)
@@ -260,7 +260,7 @@ static void elv_rqhash_add(struct request_queue *q, struct request *rq)BUG_ON (ELV_ON_HASH (rq));hash_add (e->hash, &rq->hash,rq_hash_key (rq)); - rq->cmd_flags |=REQ_HASHED ; + rq->rq_flags |=RQF_HASHED ; }static void elv_rqhash_reposition (struct request_queue *q,struct request *rq)
@@ -352,7 +352,6 @@ void elv_dispatch_sort(struct request_queue *q, struct request *rq) {sector_t boundary;struct list_head *entry; -int stop_flags;if (q->last_merge == rq) q->last_merge =NULL ;
@@ -362,7 +361,6 @@ void elv_dispatch_sort(struct request_queue *q, struct request *rq) q->nr_sorted--; boundary = q->end_sector; - stop_flags =REQ_SOFTBARRIER |REQ_STARTED ;list_for_each_prev (entry, &q->queue_head) {struct request *pos =list_entry_rq (entry);
@@ -370,7 +368,7 @@ void elv_dispatch_sort(struct request_queue *q, struct request *rq)break ;if (rq_data_dir (rq) !=rq_data_dir (pos))break ; -if (pos->cmd_flags & stop_flags) +if (pos->rq_flags & (RQF_STARTED |RQF_SOFTBARRIER ))break ;if (blk_rq_pos (rq) >= boundary) {if (blk_rq_pos (pos) < boundary)
@@ -510,7 +508,7 @@ void elv_merge_requests(struct request_queue *q, struct request *rq, struct request *next) {struct elevator_queue *e = q->elevator; -const int next_sorted = next->cmd_flags &REQ_SORTED ; +const int next_sorted = next->rq_flags &RQF_SORTED ;if (next_sorted && e->type->ops.elevator_merge_req_fn) e->type->ops.elevator_merge_req_fn (q, rq, next);
@@ -537,13 +535,13 @@ void elv_bio_merged(struct request_queue *q, struct request *rq,#ifdef CONFIG_PM static void blk_pm_requeue_request (struct request *rq) { -if (rq->q->dev && !(rq->cmd_flags &REQ_PM )) +if (rq->q->dev && !(rq->rq_flags &RQF_PM )) rq->q->nr_pending--; }static void blk_pm_add_request (struct request_queue *q,struct request *rq) { -if (q->dev && !(rq->cmd_flags &REQ_PM ) && q->nr_pending++ ==0 && +if (q->dev && !(rq->rq_flags &RQF_PM ) && q->nr_pending++ ==0 && (q->rpm_status ==RPM_SUSPENDED || q->rpm_status ==RPM_SUSPENDING ))pm_request_resume (q->dev); }
@@ -563,11 +561,11 @@ void elv_requeue_request(struct request_queue *q, struct request *rq)*/ if (blk_account_rq (rq)) { q->in_flight[rq_is_sync (rq)]--; -if (rq->cmd_flags &REQ_SORTED ) +if (rq->rq_flags &RQF_SORTED )elv_deactivate_rq (q, rq); } - rq->cmd_flags &= ~REQ_STARTED ; + rq->rq_flags &= ~RQF_STARTED ;blk_pm_requeue_request (rq);
@@ -597,13 +595,13 @@ void __elv_add_request(struct request_queue *q, struct request *rq, int where) rq->q = q; -if (rq->cmd_flags &REQ_SOFTBARRIER ) { +if (rq->rq_flags &RQF_SOFTBARRIER ) {/* barriers are scheduling boundary, update end_sector */ if (rq->cmd_type ==REQ_TYPE_FS ) { q->end_sector =rq_end_sector (rq); q->boundary_rq = rq; } - }else if (!(rq->cmd_flags &REQ_ELVPRIV ) && + }else if (!(rq->rq_flags &RQF_ELVPRIV ) && (where ==ELEVATOR_INSERT_SORT || where ==ELEVATOR_INSERT_SORT_MERGE )) where =ELEVATOR_INSERT_BACK ;
@@ -611,12 +609,12 @@ void __elv_add_request(struct request_queue *q, struct request *rq, int where)switch (where) {case ELEVATOR_INSERT_REQUEUE :case ELEVATOR_INSERT_FRONT : - rq->cmd_flags |=REQ_SOFTBARRIER ; + rq->rq_flags |=RQF_SOFTBARRIER ;list_add (&rq->queuelist, &q->queue_head);break ;case ELEVATOR_INSERT_BACK : - rq->cmd_flags |=REQ_SOFTBARRIER ; + rq->rq_flags |=RQF_SOFTBARRIER ;elv_drain_elevator (q);list_add_tail (&rq->queuelist, &q->queue_head);/*
@@ -642,7 +640,7 @@ void __elv_add_request(struct request_queue *q, struct request *rq, int where)break ;case ELEVATOR_INSERT_SORT :BUG_ON (rq->cmd_type !=REQ_TYPE_FS ); - rq->cmd_flags |=REQ_SORTED ; + rq->rq_flags |=RQF_SORTED ; q->nr_sorted++;if (rq_mergeable (rq)) {elv_rqhash_add (q, rq);
@@ -659,7 +657,7 @@ void __elv_add_request(struct request_queue *q, struct request *rq, int where)break ;case ELEVATOR_INSERT_FLUSH : - rq->cmd_flags |=REQ_SOFTBARRIER ; + rq->rq_flags |=RQF_SOFTBARRIER ;blk_insert_flush (rq);break ;default :
@@ -735,7 +733,7 @@ void elv_completed_request(struct request_queue *q, struct request *rq)*/ if (blk_account_rq (rq)) { q->in_flight[rq_is_sync (rq)]--; -if ((rq->cmd_flags &REQ_SORTED ) && +if ((rq->rq_flags &RQF_SORTED ) && e->type->ops.elevator_completed_req_fn) e->type->ops.elevator_completed_req_fn (q, rq); }
drivers/block/pktcdvd.c +1 -1
@@ -721,7 +721,7 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command * rq->timeout =60 *HZ ;if (cgc->quiet) - rq->cmd_flags |=REQ_QUIET ; + rq->rq_flags |=RQF_QUIET ;blk_execute_rq (rq->q, pd->bdev->bd_disk, rq,0 );if (rq->errors)
drivers/ide/ide-atapi.c +3 -3
@@ -211,7 +211,7 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq) sense_rq->cmd[0 ] =GPCMD_REQUEST_SENSE ; sense_rq->cmd[4 ] = cmd_len; sense_rq->cmd_type =REQ_TYPE_ATA_SENSE ; - sense_rq->cmd_flags |=REQ_PREEMPT ; + sense_rq->rq_flags |=RQF_PREEMPT ;if (drive->media == ide_tape) sense_rq->cmd[13 ] =REQ_IDETAPE_PC1 ;
@@ -295,7 +295,7 @@ int ide_cd_expiry(ide_drive_t *drive) wait =ATAPI_WAIT_PC ;break ;default : -if (!(rq->cmd_flags &REQ_QUIET )) +if (!(rq->rq_flags &RQF_QUIET )) printk(KERN_INFO PFX "cmd 0x%x timed out\n", rq->cmd[0 ]); wait =0 ;
@@ -375,7 +375,7 @@ int ide_check_ireason(ide_drive_t *drive, struct request *rq, int len, }if (dev_is_idecd (drive) && rq->cmd_type ==REQ_TYPE_ATA_PC ) - rq->cmd_flags |=REQ_FAILED ; + rq->rq_flags |=RQF_FAILED ;return 1 ; }
drivers/ide/ide-cd.c +23 -23
166 lines not on this page · raw message
drivers/ide/ide-cd.h +1 -1
@@ -101,7 +101,7 @@ void ide_cd_log_error(const char *, struct request *, struct request_sense *);/* ide-cd.c functions used by ide-cd_ioctl.c */ int ide_cd_queue_pc (ide_drive_t *,const unsigned char *,int ,void *, -unsigned *,struct request_sense *,int ,unsigned int ); +unsigned *,struct request_sense *,int ,req_flags_t );int ide_cd_read_toc (ide_drive_t *,struct request_sense *);int ide_cdrom_get_capabilities (ide_drive_t *,u8 *);void ide_cdrom_update_speed (ide_drive_t *,u8 *);
drivers/ide/ide-cd_ioctl.c +3 -3
@@ -305,7 +305,7 @@ int ide_cdrom_reset(struct cdrom_device_info *cdi) rq =blk_get_request (drive->queue,READ , __GFP_RECLAIM); rq->cmd_type =REQ_TYPE_DRV_PRIV ; - rq->cmd_flags =REQ_QUIET ; + rq->rq_flags =RQF_QUIET ; ret =blk_execute_rq (drive->queue, cd->disk, rq,0 );blk_put_request (rq);/*
@@ -449,7 +449,7 @@ int ide_cdrom_packet(struct cdrom_device_info *cdi, struct packet_command *cgc) {ide_drive_t *drive = cdi->handle; -unsigned int flags =0 ; +req_flags_t flags =0 ;unsigned len = cgc->buflen;if (cgc->timeout <=0 )
@@ -463,7 +463,7 @@ int ide_cdrom_packet(struct cdrom_device_info *cdi,memset (cgc->sense,0 ,sizeof (struct request_sense ));if (cgc->quiet) - flags |=REQ_QUIET ; + flags |=RQF_QUIET ; cgc->stat = ide_cd_queue_pc(drive, cgc->cmd, cgc->data_direction == CGC_DATA_WRITE,
drivers/ide/ide-io.c +3 -3
@@ -307,7 +307,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) {ide_startstop_t startstop; -BUG_ON (!(rq->cmd_flags &REQ_STARTED )); +BUG_ON (!(rq->rq_flags &RQF_STARTED ));#ifdef DEBUG printk("%s: start_request: current=0x%08lx\n",
@@ -316,7 +316,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)/* bail early if we've exceeded max_failures */ if (drive->max_failures && (drive->failures > drive->max_failures)) { - rq->cmd_flags |=REQ_FAILED ; + rq->rq_flags |=RQF_FAILED ; goto kill_rq; }
@@ -539,7 +539,7 @@ void do_ide_request(struct request_queue *q)*/ if ((drive->dev_flags &IDE_DFLAG_BLOCKED ) &&ata_pm_request (rq) ==0 && - (rq->cmd_flags &REQ_PREEMPT ) ==0 ) { + (rq->rq_flags &RQF_PREEMPT ) ==0 ) {/* there should be no pending command at this point */ ide_unlock_port (hwif); goto plug_device;
drivers/ide/ide-pm.c +2 -2
@@ -53,7 +53,7 @@ static int ide_pm_execute_rq(struct request *rq)spin_lock_irq (q->queue_lock);if (unlikely (blk_queue_dying (q))) { - rq->cmd_flags |=REQ_QUIET ; + rq->rq_flags |=RQF_QUIET ; rq->errors = -ENXIO ;__blk_end_request_all (rq, rq->errors);spin_unlock_irq (q->queue_lock);
@@ -90,7 +90,7 @@ int generic_ide_resume(struct device *dev)memset (&rqpm,0 ,sizeof (rqpm)); rq =blk_get_request (drive->queue,READ , __GFP_RECLAIM); rq->cmd_type =REQ_TYPE_ATA_PM_RESUME ; - rq->cmd_flags |=REQ_PREEMPT ; + rq->rq_flags |=RQF_PREEMPT ; rq->special = &rqpm; rqpm.pm_step =IDE_PM_START_RESUME ; rqpm.pm_state =PM_EVENT_ON ;
drivers/md/dm-rq.c +6 -6
@@ -313,7 +313,7 @@ static void dm_unprep_request(struct request *rq)if (!rq->q->mq_ops) { rq->special =NULL ; - rq->cmd_flags &= ~REQ_DONTPREP ; + rq->rq_flags &= ~RQF_DONTPREP ; }if (clone)
@@ -431,7 +431,7 @@ static void dm_softirq_done(struct request *rq)return ; } -if (rq->cmd_flags &REQ_FAILED ) +if (rq->rq_flags &RQF_FAILED ) mapped = false;dm_done (clone, tio->error, mapped);
@@ -460,7 +460,7 @@ static void dm_complete_request(struct request *rq, int error)*/ static void dm_kill_unmapped_request (struct request *rq,int error) { - rq->cmd_flags |=REQ_FAILED ; + rq->rq_flags |=RQF_FAILED ;dm_complete_request (rq, error); }
@@ -476,7 +476,7 @@ static void end_clone_request(struct request *clone, int error)* For just cleaning up the information of the queue in which * the clone was dispatched. * The clone is *NOT* freed actually here because it is alloced -* from dm own mempool (REQ_ALLOCED isn't set). +* from dm own mempool (RQF_ALLOCED isn't set). */ __blk_put_request (clone->q, clone); }
@@ -497,7 +497,7 @@ static void dm_dispatch_clone_request(struct request *clone, struct request *rq)int r;if (blk_queue_io_stat (clone->q)) - clone->cmd_flags |=REQ_IO_STAT ; + clone->rq_flags |=RQF_IO_STAT ; clone->start_time = jiffies; r =blk_insert_cloned_request (clone->q, clone);
@@ -633,7 +633,7 @@ static int dm_old_prep_fn(struct request_queue *q, struct request *rq)return BLKPREP_DEFER ; rq->special = tio; - rq->cmd_flags |=REQ_DONTPREP ; + rq->rq_flags |=RQF_DONTPREP ;return BLKPREP_OK ; }
drivers/memstick/core/ms_block.c +1 -1
@@ -2006,7 +2006,7 @@ static int msb_prepare_req(struct request_queue *q, struct request *req)blk_dump_rq_flags (req,"MS unsupported request" );return BLKPREP_KILL ; } - req->cmd_flags |=REQ_DONTPREP ; + req->rq_flags |=RQF_DONTPREP ;return BLKPREP_OK ; }
drivers/memstick/core/mspro_block.c +1 -1
@@ -834,7 +834,7 @@ static int mspro_block_prepare_req(struct request_queue *q, struct request *req)return BLKPREP_KILL ; } - req->cmd_flags |=REQ_DONTPREP ; + req->rq_flags |=RQF_DONTPREP ;return BLKPREP_OK ; }
drivers/mmc/card/block.c +2 -2
@@ -2117,7 +2117,7 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)mmc_blk_abort_packed_req (mq_rq); }else {if (mmc_card_removed (card)) - req->cmd_flags |=REQ_QUIET ; + req->rq_flags |=RQF_QUIET ;while (ret) ret =blk_end_request (req, -EIO ,blk_rq_cur_bytes (req));
@@ -2126,7 +2126,7 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) start_new_req:if (rqc) {if (mmc_card_removed (card)) { - rqc->cmd_flags |=REQ_QUIET ; + rqc->rq_flags |=RQF_QUIET ;blk_end_request_all (rqc, -EIO ); }else {/*
drivers/mmc/card/queue.c +2 -2
@@ -44,7 +44,7 @@ static int mmc_prep_request(struct request_queue *q, struct request *req)if (mq && (mmc_card_removed (mq->card) ||mmc_access_rpmb (mq)))return BLKPREP_KILL ; - req->cmd_flags |=REQ_DONTPREP ; + req->rq_flags |=RQF_DONTPREP ;return BLKPREP_OK ; }
@@ -120,7 +120,7 @@ static void mmc_request_fn(struct request_queue *q)if (!mq) {while ((req =blk_fetch_request (q)) !=NULL ) { - req->cmd_flags |=REQ_QUIET ; + req->rq_flags |=RQF_QUIET ;__blk_end_request_all (req, -EIO ); }return ;
drivers/nvme/host/pci.c +2 -2
@@ -323,9 +323,9 @@ static int nvme_init_iod(struct request *rq, unsigned size, iod->nents =0 ; iod->length = size; -if (!(rq->cmd_flags &REQ_DONTPREP )) { +if (!(rq->rq_flags &RQF_DONTPREP )) { rq->retries =0 ; - rq->cmd_flags |=REQ_DONTPREP ; + rq->rq_flags |=RQF_DONTPREP ; }return 0 ; }
drivers/scsi/device_handler/scsi_dh_alua.c +5 -3
@@ -154,7 +154,8 @@ static int submit_rtpg(struct scsi_device *sdev, unsigned char *buff,return scsi_execute_req_flags (sdev, cdb,DMA_FROM_DEVICE , buff, bufflen, sshdr,ALUA_FAILOVER_TIMEOUT *HZ , -ALUA_FAILOVER_RETRIES ,NULL , req_flags); +ALUA_FAILOVER_RETRIES ,NULL , + req_flags,0 ); }/*
@@ -187,7 +188,8 @@ static int submit_stpg(struct scsi_device *sdev, int group_id,return scsi_execute_req_flags (sdev, cdb,DMA_TO_DEVICE , stpg_data, stpg_len, sshdr,ALUA_FAILOVER_TIMEOUT *HZ , -ALUA_FAILOVER_RETRIES ,NULL , req_flags); +ALUA_FAILOVER_RETRIES ,NULL , + req_flags,0 ); } static struct alua_port_group *alua_find_get_pg(char *id_str, size_t id_size,
@@ -1063,7 +1065,7 @@ static int alua_prep_fn(struct scsi_device *sdev, struct request *req) state != SCSI_ACCESS_STATE_ACTIVE && state != SCSI_ACCESS_STATE_LBA) { ret =BLKPREP_KILL ; - req->cmd_flags |=REQ_QUIET ; + req->rq_flags |=RQF_QUIET ; }return ret;
drivers/scsi/device_handler/scsi_dh_emc.c +1 -1
@@ -452,7 +452,7 @@ static int clariion_prep_fn(struct scsi_device *sdev, struct request *req)if (h->lun_state !=CLARIION_LUN_OWNED ) { ret =BLKPREP_KILL ; - req->cmd_flags |=REQ_QUIET ; + req->rq_flags |=RQF_QUIET ; }return ret;
drivers/scsi/device_handler/scsi_dh_hp_sw.c +1 -1
@@ -266,7 +266,7 @@ static int hp_sw_prep_fn(struct scsi_device *sdev, struct request *req)if (h->path_state !=HP_SW_PATH_ACTIVE ) { ret =BLKPREP_KILL ; - req->cmd_flags |=REQ_QUIET ; + req->rq_flags |=RQF_QUIET ; }return ret;
drivers/scsi/device_handler/scsi_dh_rdac.c +1 -1
@@ -724,7 +724,7 @@ static int rdac_prep_fn(struct scsi_device *sdev, struct request *req)if (h->state !=RDAC_STATE_ACTIVE ) { ret =BLKPREP_KILL ; - req->cmd_flags |=REQ_QUIET ; + req->rq_flags |=RQF_QUIET ; }return ret;
drivers/scsi/osd/osd_initiator.c +1 -1
@@ -1595,7 +1595,7 @@ static int _init_blk_request(struct osd_request *or, } or->request = req; - req->cmd_flags |=REQ_QUIET ; + req->rq_flags |=RQF_QUIET ; req->timeout = or->timeout; req->retries = or->retries;
drivers/scsi/osst.c +1 -1
@@ -368,7 +368,7 @@ static int osst_execute(struct osst_request *SRpnt, const unsigned char *cmd,return DRIVER_ERROR <<24 ;blk_rq_set_block_pc (req); - req->cmd_flags |=REQ_QUIET ; + req->rq_flags |=RQF_QUIET ; SRpnt->bio =NULL ;
drivers/scsi/scsi_error.c +1 -1
@@ -1988,7 +1988,7 @@ static void scsi_eh_lock_door(struct scsi_device *sdev) req->cmd_len =COMMAND_SIZE (req->cmd[0 ]); - req->cmd_flags |=REQ_QUIET ; + req->rq_flags |=RQF_QUIET ; req->timeout =10 *HZ ; req->retries =5 ;
drivers/scsi/scsi_lib.c +43 -32
163 lines not on this page · raw message
drivers/scsi/sd.c +3 -3
@@ -1520,7 +1520,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp)*/ res =scsi_execute_req_flags (sdp, cmd,DMA_NONE ,NULL ,0 , &sshdr, timeout,SD_MAX_RETRIES , -NULL ,REQ_PM ); +NULL ,0 ,RQF_PM );if (res ==0 )break ; }
@@ -1879,7 +1879,7 @@ static int sd_done(struct scsi_cmnd *SCpnt) good_bytes =0 ; req->__data_len =blk_rq_bytes (req); - req->cmd_flags |=REQ_QUIET ; + req->rq_flags |=RQF_QUIET ; } } }
@@ -3278,7 +3278,7 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)return -ENODEV ; res =scsi_execute_req_flags (sdp, cmd,DMA_NONE ,NULL ,0 , &sshdr, -SD_TIMEOUT ,SD_MAX_RETRIES ,NULL ,REQ_PM ); +SD_TIMEOUT ,SD_MAX_RETRIES ,NULL ,0 ,RQF_PM );if (res) {sd_print_result (sdkp,"Start/Stop Unit failed" , res);if (driver_byte (res) &DRIVER_SENSE )
drivers/scsi/sd_zbc.c +1 -1
@@ -348,7 +348,7 @@ void sd_zbc_complete(struct scsi_cmnd *cmd,* this case, so be quiet about the error. */ if (req_op (rq) ==REQ_OP_ZONE_RESET ) - rq->cmd_flags |=REQ_QUIET ; + rq->rq_flags |=RQF_QUIET ;break ;case 0x21 :/*
drivers/scsi/st.c +1 -1
@@ -546,7 +546,7 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd,return DRIVER_ERROR <<24 ;blk_rq_set_block_pc (req); - req->cmd_flags |=REQ_QUIET ; + req->rq_flags |=RQF_QUIET ; mdata->null_mapped =1 ;
drivers/scsi/ufs/ufshcd.c +3 -3
@@ -5590,7 +5590,7 @@ ufshcd_send_request_sense(struct ufs_hba *hba, struct scsi_device *sdp) ret =scsi_execute_req_flags (sdp, cmd,DMA_FROM_DEVICE , buffer,SCSI_SENSE_BUFFERSIZE ,NULL , -msecs_to_jiffies (1000 ),3 ,NULL ,REQ_PM ); +msecs_to_jiffies (1000 ),3 ,NULL ,0 ,RQF_PM );if (ret)pr_err ("%s: failed with err %d\n" , __func__, ret);
@@ -5652,11 +5652,11 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,/* * Current function would be generally called from the power management -* callbacks hence set the REQ_PM flag so that it doesn't resume the +* callbacks hence set the RQF_PM flag so that it doesn't resume the * already suspended childs. */ ret =scsi_execute_req_flags (sdp, cmd,DMA_NONE ,NULL ,0 , &sshdr, -START_STOP_TIMEOUT ,0 ,NULL ,REQ_PM ); +START_STOP_TIMEOUT ,0 ,NULL ,0 ,RQF_PM );if (ret) { sdev_printk(KERN_WARNING, sdp, "START_STOP failed for power mode: %d, result %x\n",
include/linux/blk_types.h +1 -38
@@ -167,26 +167,6 @@ enum rq_flag_bits { __REQ_PREFLUSH,/* request for cache flush */ __REQ_RAHEAD,/* read ahead, can fail anytime */ -/* request only flags */ - __REQ_SORTED,/* elevator knows about this request */ - __REQ_SOFTBARRIER,/* may not be passed by ioscheduler */ - __REQ_STARTED,/* drive already may have started this one */ - __REQ_DONTPREP,/* don't call prep for this one */ - __REQ_QUEUED,/* uses queueing */ - __REQ_ELVPRIV,/* elevator private data attached */ - __REQ_FAILED,/* set if the request failed */ - __REQ_QUIET,/* don't worry about errors */ - __REQ_PREEMPT,/* set for "ide_preempt" requests and also -for requests for which the SCSI "quiesce" -state must be ignored. */ - __REQ_ALLOCED,/* request came from our alloc pool */ - __REQ_COPY_USER,/* contains copies of user pages */ - __REQ_FLUSH_SEQ,/* request for flush sequence */ - __REQ_IO_STAT,/* account I/O stat */ - __REQ_MIXED_MERGE,/* merge of different types, fail separately */ - __REQ_PM,/* runtime pm request */ - __REQ_HASHED,/* on IO scheduler merge hash */ - __REQ_MQ_INFLIGHT,/* track inflight for MQ */ __REQ_NR_BITS, /* stops here */ };
@@ -208,29 +188,12 @@ enum rq_flag_bits {/* This mask is used for both bio and request merge checking */ #define REQ_NOMERGE_FLAGS \ - (REQ_NOMERGE | REQ_STARTED | REQ_SOFTBARRIER | REQ_PREFLUSH | REQ_FUA | REQ_FLUSH_SEQ) + (REQ_NOMERGE | REQ_PREFLUSH | REQ_FUA)#define REQ_RAHEAD (1ULL << __REQ_RAHEAD) -#define REQ_SORTED (1ULL << __REQ_SORTED) -#define REQ_SOFTBARRIER (1ULL << __REQ_SOFTBARRIER)#define REQ_FUA (1ULL << __REQ_FUA)#define REQ_NOMERGE (1ULL << __REQ_NOMERGE) -#define REQ_STARTED (1ULL << __REQ_STARTED) -#define REQ_DONTPREP (1ULL << __REQ_DONTPREP) -#define REQ_QUEUED (1ULL << __REQ_QUEUED) -#define REQ_ELVPRIV (1ULL << __REQ_ELVPRIV) -#define REQ_FAILED (1ULL << __REQ_FAILED) -#define REQ_QUIET (1ULL << __REQ_QUIET) -#define REQ_PREEMPT (1ULL << __REQ_PREEMPT) -#define REQ_ALLOCED (1ULL << __REQ_ALLOCED) -#define REQ_COPY_USER (1ULL << __REQ_COPY_USER)#define REQ_PREFLUSH (1ULL << __REQ_PREFLUSH) -#define REQ_FLUSH_SEQ (1ULL << __REQ_FLUSH_SEQ) -#define REQ_IO_STAT (1ULL << __REQ_IO_STAT) -#define REQ_MIXED_MERGE (1ULL << __REQ_MIXED_MERGE) -#define REQ_PM (1ULL << __REQ_PM) -#define REQ_HASHED (1ULL << __REQ_HASHED) -#define REQ_MQ_INFLIGHT (1ULL << __REQ_MQ_INFLIGHT)enum req_op {REQ_OP_READ ,
include/linux/blkdev.h +48 -1
73 lines not on this page · raw message
include/scsi/scsi_device.h +2 -2
@@ -414,14 +414,14 @@ extern int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,extern int scsi_execute_req_flags (struct scsi_device *sdev,const unsigned char *cmd,int data_direction,void *buffer,unsigned bufflen,struct scsi_sense_hdr *sshdr,int timeout, -int retries,int *resid,u64 flags); +int retries,int *resid,u64 flags,req_flags_t rq_flags);static inline int scsi_execute_req (struct scsi_device *sdev,const unsigned char *cmd,int data_direction,void *buffer,unsigned bufflen,struct scsi_sense_hdr *sshdr,int timeout,int retries,int *resid) {return scsi_execute_req_flags (sdev, cmd, data_direction, buffer, - bufflen, sshdr, timeout, retries, resid,0 ); + bufflen, sshdr, timeout, retries, resid,0 ,0 ); }extern void sdev_disable_disk_events (struct scsi_device *sdev);extern void sdev_enable_disk_events (struct scsi_device *sdev);
Signature · 1 line
2.1.4
Christoph Hellwig
maintainerPATCH 6/7 block: better op and flags encoding
In reply to Christoph HellwigNow that we don't need the common flags to overflow outside the range of a 32-bit type we can encode them the same way for both the bio and request fields. This in addition allows us to place the operation first (and make some room for more ops while we're at it) and to stop having to shift around the operation values.
In addition this allows passing around only one value in the block layer instead of two (and eventuall also in the file systems, but we can do that later) and thus clean up a lot of code.
Last but not least this allows decreasing the size of the cmd_flags field in struct request to 32-bits. Various functions passing this value could also be updated, but I'd like to avoid the churn for now.
--- Documentation/block/biodoc.txt | 4 +- block/blk-core.c | 60 ++++++++++-------------------- block/blk-flush.c | 2 +- block/blk-lib.c | 2 +- block/blk-map.c | 2 + block/blk-mq.c | 28 ++++++-------- block/cfq-iosched.c | 66 ++++++++++++++++----------------- block/elevator.c | 4 +- drivers/md/dm-crypt.c | 2 +- drivers/scsi/sd.c | 3 +- fs/btrfs/inode.c | 5 +-- fs/buffer.c | 2 +- fs/f2fs/f2fs.h | 2 +- fs/gfs2/lops.c | 2 +- include/linux/blk-cgroup.h | 11 +++--- include/linux/blk_types.h | 83 +++++++++++++++++++----------------------- include/linux/blkdev.h | 26 +------------ include/linux/blktrace_api.h | 2 +- include/linux/dm-io.h | 2 +- include/linux/elevator.h | 4 +- include/trace/events/bcache.h | 12 ++---- include/trace/events/block.h | 31 ++++++---------- kernel/trace/blktrace.c | 14 +++---- 23 files changed, 148 insertions(+), 221 deletions(-)
Documentation/block/biodoc.txt +2 -2
@@ -553,8 +553,8 @@ struct request { struct request_list *rl; } -See the rq_flag_bits definitions for an explanation of the various flags -available. Some bits are used by the block layer or i/o scheduler. +See the req_ops and req_flag_bits definitions for an explanation of the various +flags available. Some bits are used by the block layer or i/o scheduler. The behaviour of the various sector counts are almost the same as before, except that since we have multi-segment bios, current_nr_sectors refers
block/blk-core.c +20 -40
162 lines not on this page · raw message
block/blk-flush.c +1 -1
@@ -330,7 +330,7 @@ static bool blk_kick_flush(struct request_queue *q, struct blk_flush_queue *fq) } flush_rq->cmd_type =REQ_TYPE_FS ; -req_set_op_attrs (flush_rq,REQ_OP_FLUSH ,WRITE_FLUSH ); + flush_rq->cmd_flags =REQ_OP_FLUSH |WRITE_FLUSH ; flush_rq->rq_flags |=RQF_FLUSH_SEQ ; flush_rq->rq_disk = first_rq->rq_disk; flush_rq->end_io = flush_end_io;
block/blk-lib.c +1 -1
@@ -29,7 +29,7 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,struct request_queue *q =bdev_get_queue (bdev);struct bio *bio = *biop;unsigned int granularity; -enum req_op op; +unsigned int op;int alignment;sector_t bs_mask;
block/blk-map.c +2 -0
@@ -16,6 +16,8 @@int blk_rq_append_bio (struct request *rq,struct bio *bio) {if (!rq->bio) { + rq->cmd_flags &=REQ_OP_MASK ; + rq->cmd_flags |= (bio->bi_opf &REQ_OP_MASK );blk_rq_bio_prep (rq->q, rq, bio); }else {if (!ll_back_merge_fn (rq->q, rq, bio))
block/blk-mq.c +11 -17
@@ -139,14 +139,13 @@ bool blk_mq_can_queue(struct blk_mq_hw_ctx *hctx)EXPORT_SYMBOL (blk_mq_can_queue);static void blk_mq_rq_ctx_init (struct request_queue *q,struct blk_mq_ctx *ctx, -struct request *rq,int op, -unsigned int op_flags) +struct request *rq,unsigned int op) {INIT_LIST_HEAD (&rq->queuelist);/* csd/requeue_work/fifo_time is initialized before use */ rq->q = q; rq->mq_ctx = ctx; -req_set_op_attrs (rq, op, op_flags); + rq->cmd_flags = op;if (blk_queue_io_stat (q)) rq->rq_flags |=RQF_IO_STAT ;/* do not touch atomic flags, it needs atomic ops against the timer */
@@ -183,11 +182,11 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx, rq->end_io_data =NULL ; rq->next_rq =NULL ; - ctx->rq_dispatched[rw_is_sync (op, op_flags)]++; + ctx->rq_dispatched[op_is_sync (op)]++; }static struct request * -__blk_mq_alloc_request (struct blk_mq_alloc_data *data,int op,int op_flags) +__blk_mq_alloc_request (struct blk_mq_alloc_data *data,unsigned int op) {struct request *rq;unsigned int tag;
@@ -202,7 +201,7 @@ __blk_mq_alloc_request(struct blk_mq_alloc_data *data, int op, int op_flags) } rq->tag = tag; -blk_mq_rq_ctx_init (data->q, data->ctx, rq, op, op_flags); +blk_mq_rq_ctx_init (data->q, data->ctx, rq, op);return rq; }
@@ -225,7 +224,7 @@ struct request *blk_mq_alloc_request(struct request_queue *q, int rw, ctx =blk_mq_get_ctx (q); hctx =blk_mq_map_queue (q, ctx->cpu);blk_mq_set_alloc_data (&alloc_data, q, flags, ctx, hctx); - rq =__blk_mq_alloc_request (&alloc_data, rw,0 ); + rq =__blk_mq_alloc_request (&alloc_data, rw);blk_mq_put_ctx (ctx);if (!rq) {
@@ -277,7 +276,7 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q, int rw, ctx =__blk_mq_get_ctx (q,cpumask_first (hctx->cpumask));blk_mq_set_alloc_data (&alloc_data, q, flags, ctx, hctx); - rq =__blk_mq_alloc_request (&alloc_data, rw,0 ); + rq =__blk_mq_alloc_request (&alloc_data, rw);if (!rq) { ret = -EWOULDBLOCK ; goto out_queue_exit;
@@ -1201,20 +1200,15 @@ static struct request *blk_mq_map_request(struct request_queue *q,struct blk_mq_hw_ctx *hctx;struct blk_mq_ctx *ctx;struct request *rq; -int op =bio_data_dir (bio); -int op_flags =0 ;struct blk_mq_alloc_data alloc_data;blk_queue_enter_live (q); ctx =blk_mq_get_ctx (q); hctx =blk_mq_map_queue (q, ctx->cpu); -if (rw_is_sync (bio_op (bio), bio->bi_opf)) - op_flags |=REQ_SYNC ; - -trace_block_getrq (q, bio, op); +trace_block_getrq (q, bio, bio->bi_opf);blk_mq_set_alloc_data (&alloc_data, q,0 , ctx, hctx); - rq =__blk_mq_alloc_request (&alloc_data, op, op_flags); + rq =__blk_mq_alloc_request (&alloc_data, bio->bi_opf); hctx->queued++; data->hctx = hctx;
@@ -1264,7 +1258,7 @@ static int blk_mq_direct_issue_request(struct request *rq, blk_qc_t *cookie)*/ static blk_qc_t blk_mq_make_request (struct request_queue *q,struct bio *bio) { -const int is_sync =rw_is_sync (bio_op (bio), bio->bi_opf); +const int is_sync =op_is_sync (bio->bi_opf);const int is_flush_fua = bio->bi_opf & (REQ_PREFLUSH |REQ_FUA );struct blk_map_ctx data;struct request *rq;
@@ -1358,7 +1352,7 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)*/ static blk_qc_t blk_sq_make_request (struct request_queue *q,struct bio *bio) { -const int is_sync =rw_is_sync (bio_op (bio), bio->bi_opf); +const int is_sync =op_is_sync (bio->bi_opf);const int is_flush_fua = bio->bi_opf & (REQ_PREFLUSH |REQ_FUA );struct blk_plug *plug;unsigned int request_count =0 ;
block/cfq-iosched.c +32 -34
165 lines not on this page · raw message
block/elevator.c +2 -2
@@ -714,12 +714,12 @@ void elv_put_request(struct request_queue *q, struct request *rq) e->type->ops.elevator_put_req_fn (rq); } -int elv_may_queue (struct request_queue *q,int op,int op_flags) +int elv_may_queue (struct request_queue *q,unsigned int op) {struct elevator_queue *e = q->elevator;if (e->type->ops.elevator_may_queue_fn) -return e->type->ops.elevator_may_queue_fn (q, op, op_flags); +return e->type->ops.elevator_may_queue_fn (q, op);return ELV_MQUEUE_MAY ; }
drivers/md/dm-crypt.c +1 -1
@@ -1135,7 +1135,7 @@ static void clone_init(struct dm_crypt_io *io, struct bio *clone) clone->bi_private = io; clone->bi_end_io = crypt_endio; clone->bi_bdev = cc->dev->bdev; -bio_set_op_attrs (clone,bio_op (io->base_bio),bio_flags (io->base_bio)); + clone->bi_opf = io->base_bio->bi_opf; }static int kcryptd_io_read (struct dm_crypt_io *io,gfp_t gfp)
drivers/scsi/sd.c +1 -2
@@ -1031,8 +1031,7 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt) }else if (rq_data_dir (rq) ==READ ) { SCpnt->cmnd[0 ] =READ_6 ; }else { -scmd_printk (KERN_ERR , SCpnt,"Unknown command %llu,%llx\n" , -req_op (rq), (unsigned long long ) rq->cmd_flags); +scmd_printk (KERN_ERR , SCpnt,"Unknown command %d\n" ,req_op (rq)); goto out; }
fs/btrfs/inode.c +2 -3
@@ -8427,7 +8427,7 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip,if (!bio)return -ENOMEM ; -bio_set_op_attrs (bio,bio_op (orig_bio),bio_flags (orig_bio)); + bio->bi_opf = orig_bio->bi_opf; bio->bi_private = dip; bio->bi_end_io = btrfs_end_dio_bio;btrfs_io_bio (bio)->logical = file_offset;
@@ -8465,8 +8465,7 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip, start_sector, GFP_NOFS);if (!bio) goto out_err; -bio_set_op_attrs (bio,bio_op (orig_bio), -bio_flags (orig_bio)); + bio->bi_opf = orig_bio->bi_opf; bio->bi_private = dip; bio->bi_end_io = btrfs_end_dio_bio;btrfs_io_bio (bio)->logical = file_offset;
fs/buffer.c +1 -1
@@ -3118,7 +3118,7 @@ EXPORT_SYMBOL(submit_bh);/** * ll_rw_block: low-level access to block devices (DEPRECATED) * @op: whether to %READ or %WRITE -* @op_flags: rq_flag_bits +* @op_flags: req_flag_bits * @nr: number of &struct buffer_heads in the array * @bhs: array of pointers to &struct buffer_head *
fs/f2fs/f2fs.h +1 -1
@@ -688,7 +688,7 @@ struct f2fs_io_info {struct f2fs_sb_info *sbi;/* f2fs_sb_info pointer */ enum page_type type;/* contains DATA/NODE/META/META_FLUSH */ int op;/* contains REQ_OP_ */ -int op_flags;/* rq_flag_bits */ +int op_flags;/* req_flag_bits */ block_t new_blkaddr;/* new block address to be written */ block_t old_blkaddr;/* old block address before Cow */ struct page *page;/* page to be written */
fs/gfs2/lops.c +1 -1
@@ -231,7 +231,7 @@ static void gfs2_end_log_write(struct bio *bio)* gfs2_log_flush_bio - Submit any pending log bio * @sdp: The superblock * @op: REQ_OP -* @op_flags: rq_flag_bits +* @op_flags: req_flag_bits * * Submit any pending part-built or full bio to the block device. If * there is no pending bio, then this is a no-op.
include/linux/blk-cgroup.h +5 -6
@@ -581,15 +581,14 @@ static inline void blkg_rwstat_exit(struct blkg_rwstat *rwstat)/** * blkg_rwstat_add - add a value to a blkg_rwstat * @rwstat: target blkg_rwstat -* @op: REQ_OP -* @op_flags: rq_flag_bits +* @op: REQ_OP and flags * @val: value to add * * Add @val to @rwstat. The counters are chosen according to @rw. The * caller is responsible for synchronizing calls to this function. */ static inline void blkg_rwstat_add (struct blkg_rwstat *rwstat, -int op,int op_flags,uint64_t val) +unsigned int op,uint64_t val) {struct percpu_counter *cnt;
@@ -600,7 +599,7 @@ static inline void blkg_rwstat_add(struct blkg_rwstat *rwstat,__percpu_counter_add (cnt, val,BLKG_STAT_CPU_BATCH ); -if (op_flags &REQ_SYNC ) +if (op &REQ_SYNC ) cnt = &rwstat->cpu_cnt[BLKG_RWSTAT_SYNC ];else cnt = &rwstat->cpu_cnt[BLKG_RWSTAT_ASYNC ];
@@ -705,9 +704,9 @@ static inline bool blkcg_bio_issue_check(struct request_queue *q,if (!throtl) { blkg = blkg ?: q->root_blkg; -blkg_rwstat_add (&blkg->stat_bytes,bio_op (bio), bio->bi_opf, +blkg_rwstat_add (&blkg->stat_bytes, bio->bi_opf, bio->bi_iter.bi_size); -blkg_rwstat_add (&blkg->stat_ios,bio_op (bio), bio->bi_opf,1 ); +blkg_rwstat_add (&blkg->stat_ios, bio->bi_opf,1 ); }rcu_read_unlock ();
include/linux/blk_types.h +37 -46
124 lines not on this page · raw message
include/linux/blkdev.h +2 -24
@@ -142,7 +142,7 @@ struct request {int cpu;unsigned cmd_type; -u64 cmd_flags; +unsigned int cmd_flags;/* op and common flags */ req_flags_t rq_flags;unsigned long atomic_flags;
@@ -244,20 +244,6 @@ struct request {struct request *next_rq; }; -#define REQ_OP_SHIFT (8 * sizeof(u64) - REQ_OP_BITS) -#define req_op (req) ((req)->cmd_flags >> REQ_OP_SHIFT) - -#define req_set_op (req, op) do { \ - WARN_ON(op >= (1 << REQ_OP_BITS)); \ - (req)->cmd_flags &= ((1ULL << REQ_OP_SHIFT) - 1); \ - (req)->cmd_flags |= ((u64) (op) << REQ_OP_SHIFT); \ -} while (0) - -#define req_set_op_attrs (req, op, flags) do { \ - req_set_op(req, op); \ - (req)->cmd_flags |= flags; \ -} while (0) -static inline unsigned short req_get_ioprio (struct request *req) {return req->ioprio;
@@ -741,17 +727,9 @@ static inline unsigned int blk_queue_zone_size(struct request_queue *q)return blk_queue_is_zoned (q) ? q->limits.chunk_sectors :0 ; } -/* -* We regard a request as sync, if either a read or a sync write -*/ -static inline bool rw_is_sync (int op,unsigned int rw_flags) -{ -return op ==REQ_OP_READ || (rw_flags &REQ_SYNC ); -} -static inline bool rq_is_sync (struct request *rq) { -return rw_is_sync (req_op (rq), rq->cmd_flags); +return op_is_sync (rq->cmd_flags); }static inline bool blk_rl_full (struct request_list *rl,bool sync)
include/linux/blktrace_api.h +1 -1
@@ -118,7 +118,7 @@ static inline int blk_cmd_buf_len(struct request *rq) }extern void blk_dump_cmd (char *buf,struct request *rq); -extern void blk_fill_rwbs (char *rwbs,int op,u32 rw,int bytes); +extern void blk_fill_rwbs (char *rwbs,unsigned int op,int bytes);#endif /* CONFIG_EVENT_TRACING && CONFIG_BLOCK */
include/linux/dm-io.h +1 -1
@@ -58,7 +58,7 @@ struct dm_io_notify {struct dm_io_client ;struct dm_io_request {int bi_op;/* REQ_OP */ -int bi_op_flags;/* rq_flag_bits */ +int bi_op_flags;/* req_flag_bits */ struct dm_io_memory mem;/* Memory to use for io */ struct dm_io_notify notify;/* Synchronous if notify.fn is NULL */ struct dm_io_client *client;/* Client memory handler */
include/linux/elevator.h +2 -2
@@ -30,7 +30,7 @@ typedef int (elevator_dispatch_fn) (struct request_queue *, int);typedef void (elevator_add_req_fn ) (struct request_queue *,struct request *);typedef struct request *(elevator_request_list_fn ) (struct request_queue *,struct request *);typedef void (elevator_completed_req_fn ) (struct request_queue *,struct request *); -typedef int (elevator_may_queue_fn ) (struct request_queue *,int ,int ); +typedef int (elevator_may_queue_fn ) (struct request_queue *,unsigned int );typedef void (elevator_init_icq_fn ) (struct io_cq *);typedef void (elevator_exit_icq_fn ) (struct io_cq *);
@@ -139,7 +139,7 @@ extern struct request *elv_former_request(struct request_queue *, struct requestextern struct request *elv_latter_request (struct request_queue *,struct request *);extern int elv_register_queue (struct request_queue *q);extern void elv_unregister_queue (struct request_queue *q); -extern int elv_may_queue (struct request_queue *,int ,int ); +extern int elv_may_queue (struct request_queue *,unsigned int );extern void elv_completed_request (struct request_queue *,struct request *);extern int elv_set_request (struct request_queue *q,struct request *rq,struct bio *bio,gfp_t gfp_mask);
include/trace/events/bcache.h +4 -8
@@ -27,8 +27,7 @@ DECLARE_EVENT_CLASS(bcache_request, __entry->sector = bio->bi_iter.bi_sector; __entry->orig_sector = bio->bi_iter.bi_sector -16 ; __entry->nr_sector = bio->bi_iter.bi_size >>9 ; -blk_fill_rwbs (__entry->rwbs,bio_op (bio), bio->bi_opf, - bio->bi_iter.bi_size); +blk_fill_rwbs (__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); ), TP_printk("%d,%d %s %llu + %u (from %d,%d @ %llu)",
@@ -102,8 +101,7 @@ DECLARE_EVENT_CLASS(bcache_bio, __entry->dev = bio->bi_bdev->bd_dev; __entry->sector = bio->bi_iter.bi_sector; __entry->nr_sector = bio->bi_iter.bi_size >>9 ; -blk_fill_rwbs (__entry->rwbs,bio_op (bio), bio->bi_opf, - bio->bi_iter.bi_size); +blk_fill_rwbs (__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); ), TP_printk("%d,%d %s %llu + %u",
@@ -138,8 +136,7 @@ TRACE_EVENT(bcache_read, __entry->dev = bio->bi_bdev->bd_dev; __entry->sector = bio->bi_iter.bi_sector; __entry->nr_sector = bio->bi_iter.bi_size >>9 ; -blk_fill_rwbs (__entry->rwbs,bio_op (bio), bio->bi_opf, - bio->bi_iter.bi_size); +blk_fill_rwbs (__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); __entry->cache_hit = hit; __entry->bypass = bypass; ),
@@ -170,8 +167,7 @@ TRACE_EVENT(bcache_write, __entry->inode = inode; __entry->sector = bio->bi_iter.bi_sector; __entry->nr_sector = bio->bi_iter.bi_size >>9 ; -blk_fill_rwbs (__entry->rwbs,bio_op (bio), bio->bi_opf, - bio->bi_iter.bi_size); +blk_fill_rwbs (__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); __entry->writeback = writeback; __entry->bypass = bypass; ),
include/trace/events/block.h +11 -20
@@ -84,8 +84,7 @@ DECLARE_EVENT_CLASS(block_rq_with_error, 0 : blk_rq_sectors(rq); __entry->errors = rq->errors; -blk_fill_rwbs (__entry->rwbs,req_op (rq), rq->cmd_flags, -blk_rq_bytes (rq)); +blk_fill_rwbs (__entry->rwbs, rq->cmd_flags,blk_rq_bytes (rq));blk_dump_cmd (__get_str (cmd), rq); ),
@@ -163,7 +162,7 @@ TRACE_EVENT(block_rq_complete, __entry->nr_sector = nr_bytes >>9 ; __entry->errors = rq->errors; -blk_fill_rwbs (__entry->rwbs,req_op (rq), rq->cmd_flags, nr_bytes); +blk_fill_rwbs (__entry->rwbs, rq->cmd_flags, nr_bytes);blk_dump_cmd (__get_str (cmd), rq); ),
@@ -199,8 +198,7 @@ DECLARE_EVENT_CLASS(block_rq, __entry->bytes = (rq->cmd_type ==REQ_TYPE_BLOCK_PC ) ?blk_rq_bytes (rq) :0 ; -blk_fill_rwbs (__entry->rwbs,req_op (rq), rq->cmd_flags, -blk_rq_bytes (rq)); +blk_fill_rwbs (__entry->rwbs, rq->cmd_flags,blk_rq_bytes (rq));blk_dump_cmd (__get_str (cmd), rq);memcpy (__entry->comm, current->comm,TASK_COMM_LEN ); ),
@@ -274,8 +272,7 @@ TRACE_EVENT(block_bio_bounce, bio->bi_bdev->bd_dev : 0; __entry->sector = bio->bi_iter.bi_sector; __entry->nr_sector =bio_sectors (bio); -blk_fill_rwbs (__entry->rwbs,bio_op (bio), bio->bi_opf, - bio->bi_iter.bi_size); +blk_fill_rwbs (__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size);memcpy (__entry->comm, current->comm,TASK_COMM_LEN ); ),
@@ -313,8 +310,7 @@ TRACE_EVENT(block_bio_complete, __entry->sector = bio->bi_iter.bi_sector; __entry->nr_sector =bio_sectors (bio); __entry->error = error; -blk_fill_rwbs (__entry->rwbs,bio_op (bio), bio->bi_opf, - bio->bi_iter.bi_size); +blk_fill_rwbs (__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); ), TP_printk("%d,%d %s %llu + %u [%d]",
@@ -341,8 +337,7 @@ DECLARE_EVENT_CLASS(block_bio_merge, __entry->dev = bio->bi_bdev->bd_dev; __entry->sector = bio->bi_iter.bi_sector; __entry->nr_sector =bio_sectors (bio); -blk_fill_rwbs (__entry->rwbs,bio_op (bio), bio->bi_opf, - bio->bi_iter.bi_size); +blk_fill_rwbs (__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size);memcpy (__entry->comm, current->comm,TASK_COMM_LEN ); ),
@@ -409,8 +404,7 @@ TRACE_EVENT(block_bio_queue, __entry->dev = bio->bi_bdev->bd_dev; __entry->sector = bio->bi_iter.bi_sector; __entry->nr_sector =bio_sectors (bio); -blk_fill_rwbs (__entry->rwbs,bio_op (bio), bio->bi_opf, - bio->bi_iter.bi_size); +blk_fill_rwbs (__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size);memcpy (__entry->comm, current->comm,TASK_COMM_LEN ); ),
@@ -438,7 +432,7 @@ DECLARE_EVENT_CLASS(block_get_rq, __entry->dev = bio ? bio->bi_bdev->bd_dev :0 ; __entry->sector = bio ? bio->bi_iter.bi_sector :0 ; __entry->nr_sector = bio ?bio_sectors (bio) :0 ; -blk_fill_rwbs (__entry->rwbs, bio ?bio_op (bio) :0 , +blk_fill_rwbs (__entry->rwbs, bio ? bio->bi_opf :0 , __entry->nr_sector);memcpy (__entry->comm, current->comm,TASK_COMM_LEN ); ),
@@ -573,8 +567,7 @@ TRACE_EVENT(block_split, __entry->dev = bio->bi_bdev->bd_dev; __entry->sector = bio->bi_iter.bi_sector; __entry->new_sector = new_sector; -blk_fill_rwbs (__entry->rwbs,bio_op (bio), bio->bi_opf, - bio->bi_iter.bi_size); +blk_fill_rwbs (__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size);memcpy (__entry->comm, current->comm,TASK_COMM_LEN ); ),
@@ -617,8 +610,7 @@ TRACE_EVENT(block_bio_remap, __entry->nr_sector =bio_sectors (bio); __entry->old_dev = dev; __entry->old_sector = from; -blk_fill_rwbs (__entry->rwbs,bio_op (bio), bio->bi_opf, - bio->bi_iter.bi_size); +blk_fill_rwbs (__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); ), TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
@@ -664,8 +656,7 @@ TRACE_EVENT(block_rq_remap, __entry->old_dev = dev; __entry->old_sector = from; __entry->nr_bios =blk_rq_count_bios (rq); -blk_fill_rwbs (__entry->rwbs,req_op (rq), rq->cmd_flags, -blk_rq_bytes (rq)); +blk_fill_rwbs (__entry->rwbs, rq->cmd_flags,blk_rq_bytes (rq)); ), TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu %u",
kernel/trace/blktrace.c +7 -7
@@ -1777,14 +1777,14 @@ void blk_dump_cmd(char *buf, struct request *rq) } } -void blk_fill_rwbs (char *rwbs,int op,u32 rw,int bytes) +void blk_fill_rwbs (char *rwbs,unsigned int op,int bytes) {int i =0 ; -if (rw &REQ_PREFLUSH ) +if (op &REQ_PREFLUSH ) rwbs[i++] ='F' ; -switch (op) { +switch (op &REQ_OP_MASK ) {case REQ_OP_WRITE :case REQ_OP_WRITE_SAME : rwbs[i++] ='W' ;
@@ -1806,13 +1806,13 @@ void blk_fill_rwbs(char *rwbs, int op, u32 rw, int bytes) rwbs[i++] ='N' ; } -if (rw &REQ_FUA ) +if (op &REQ_FUA ) rwbs[i++] ='F' ; -if (rw &REQ_RAHEAD ) +if (op &REQ_RAHEAD ) rwbs[i++] ='A' ; -if (rw &REQ_SYNC ) +if (op &REQ_SYNC ) rwbs[i++] ='S' ; -if (rw &REQ_META ) +if (op &REQ_META ) rwbs[i++] ='M' ; rwbs[i] ='\0' ;
Signature · 1 line
2.1.4
A message that is not in the archive (sent off-list or not yet received): CAJVOszBmN+=PD7MBEgkhO-jo3_R7rJ+5V1LGbWqDW8U+D=Dbgw@mail.gmail.com
Christoph Hellwig
maintainerRe: [PATCH 6/7] block: better op and flags encoding
Quoted 8 lines
block/blk-core.c unsigned int blk_plug_queued_count(struct request_queue *q) · line 1656
Quoted 5 lines
void
init_request_from_bio(struct request *req, struct bio *bio){ req->cmd_type = REQ_TYPE_FS;block/blk-core.c +0
-2- - req->cmd_flags |= bio->bi_opf &REQ_COMMON_MASK ;Don't we still have to init
cmd_flagsfrombi_opfat some point in the non-mq path?
We now pass all of bi_opf to get_request -> __get_request, so cmd_flags is initialized to the right value from the very beginning.
Quoted 11 lines
block/blk-map.c line 21
Quoted 9 lines
block/blk-map.c +2
-0@@ -16,6 +16,8 @@int blk_rq_append_bio (struct request *rq,struct bio *bio) {if (!rq->bio) { + rq->cmd_flags &=REQ_OP_MASK ; + rq->cmd_flags |= (bio->bi_opf &REQ_OP_MASK );blk_rq_bio_prep (rq->q, rq, bio);Should this be "&= ~REQ_OP_MASK" ?
No - blk_rq_bio_prep previous initialized just the op, and not the flags, and this keeps the behavior. In the long run we should stop setting the op here as well, though.
Christoph Hellwig
maintainerPATCH 7/7 block: add a proper block layer data direction encoding
In reply to Christoph HellwigCurrently the block layer op_is_write, bio_data_dir and rq_data_dir helper treat every operation that is not a READ as a data out operation. This worked surprisingly long, but the new REQ_OP_ZONE_REPORT operation actually adds a second operation that reads data from the device. Surprisingly nothing critical relied on this direction, but this might be a good opportunity to properly fix this issue up.
We take a little inspiration and use the least significant bit of the operation number to encode the data direction, which just requires us to renumber the operations to fix this scheme.
--- include/linux/blk_types.h | 38 ++++++++++++++++++++++++++++++-------- include/linux/fs.h | 5 ----- 2 files changed, 30 insertions(+), 13 deletions(-)
include/linux/blk_types.h +30 -8
@@ -131,20 +131,37 @@ struct bio {/* * Operations and flags common to the bio and request structures. * We use 8 bits for encoding the operation, and the remaining 24 for flags. +* +* The least significant bit of the operation number indicates the data +* transfer direction: +* +* - if the least significant bit is set transfers are TO the device +* - if the least significant bit is not set transfers are FROM the device +* +* If a operation does not transfer data the least significant bit has not +* meaning. */ #define REQ_OP_BITS 8#define REQ_OP_MASK ((1 << REQ_OP_BITS) - 1)#define REQ_FLAG_BITS 24enum req_opf { -REQ_OP_READ , -REQ_OP_WRITE , -REQ_OP_DISCARD ,/* request to discard sectors */ -REQ_OP_SECURE_ERASE ,/* request to securely erase sectors */ -REQ_OP_WRITE_SAME ,/* write same block many times */ -REQ_OP_FLUSH ,/* request for cache flush */ -REQ_OP_ZONE_REPORT ,/* Get zone information */ -REQ_OP_ZONE_RESET ,/* Reset a zone write pointer */ +/* read sectors from the device */ +REQ_OP_READ =0 , +/* write sectors to the device */ +REQ_OP_WRITE =1 , +/* flush the volatile write cache */ +REQ_OP_FLUSH =2 , +/* discard sectors */ +REQ_OP_DISCARD =3 , +/* get zone information */ +REQ_OP_ZONE_REPORT =4 , +/* securely erase sectors */ +REQ_OP_SECURE_ERASE =5 , +/* seset a zone write pointer */ +REQ_OP_ZONE_RESET =6 , +/* write the same sector many times */ +REQ_OP_WRITE_SAME =7 ,REQ_OP_LAST , };
@@ -194,6 +211,11 @@ enum req_flag_bits {#define bio_set_op_attrs (bio, op, op_flags) \ ((bio)->bi_opf |= (op | op_flags)) +static inline bool op_is_write (unsigned int op) +{ +return (op &1 ); +} +static inline bool op_is_sync (unsigned int op) {return (op &REQ_OP_MASK ) ==REQ_OP_READ || (op &REQ_SYNC );
include/linux/fs.h +0 -5
@@ -2499,11 +2499,6 @@ extern void make_bad_inode(struct inode *);extern bool is_bad_inode (struct inode *);#ifdef CONFIG_BLOCK -static inline bool op_is_write (unsigned int op) -{ -return op ==REQ_OP_READ ? false : true; -} -/* * return data direction, READ or WRITE */
Signature · 1 line
2.1.4
Christoph Hellwig
maintainerHi Jens,
any comments on this series? I addition to fixing up the zoned command direction issue it's also the base for some more work that I'm doing at the moment, so I'd really like to know if you're fine with the direction.
Quoted 5 lines · Christoph Hellwig
Hi Jens,
any comments on this series? I addition to fixing up the zoned command direction issue it's also the base for some more work that I'm doing at the moment, so I'd really like to know if you're fine with the direction.
I think it looks reasonable, currently the mess of what flags are shared, which ones are not, etc is a big pain in the ass. So making the distinction clearer is an improvement.
I'll work on getting this applied to 4.10/block.
Signature · 1 line
Jens Axboe