Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f98a13f authored by Jens Axboe's avatar Jens Axboe
Browse files

bio: first step in sanitizing the bio->bi_rw flag testing



Get rid of any functions that test for these bits and make callers
use bio_rw_flagged() directly. Then it is at least directly apparent
what variable and flag they check.

Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent e7e503ae
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -1114,24 +1114,24 @@ void init_request_from_bio(struct request *req, struct bio *bio)
	 * Inherit FAILFAST from bio (for read-ahead, and explicit
	 * FAILFAST).  FAILFAST flags are identical for req and bio.
	 */
	if (bio_rw_ahead(bio))
	if (bio_rw_flagged(bio, BIO_RW_AHEAD))
		req->cmd_flags |= REQ_FAILFAST_MASK;
	else
		req->cmd_flags |= bio->bi_rw & REQ_FAILFAST_MASK;

	if (unlikely(bio_discard(bio))) {
	if (unlikely(bio_rw_flagged(bio, BIO_RW_DISCARD))) {
		req->cmd_flags |= REQ_DISCARD;
		if (bio_barrier(bio))
		if (bio_rw_flagged(bio, BIO_RW_BARRIER))
			req->cmd_flags |= REQ_SOFTBARRIER;
		req->q->prepare_discard_fn(req->q, req);
	} else if (unlikely(bio_barrier(bio)))
	} else if (unlikely(bio_rw_flagged(bio, BIO_RW_BARRIER)))
		req->cmd_flags |= REQ_HARDBARRIER;

	if (bio_sync(bio))
	if (bio_rw_flagged(bio, BIO_RW_SYNCIO))
		req->cmd_flags |= REQ_RW_SYNC;
	if (bio_rw_meta(bio))
	if (bio_rw_flagged(bio, BIO_RW_META))
		req->cmd_flags |= REQ_RW_META;
	if (bio_noidle(bio))
	if (bio_rw_flagged(bio, BIO_RW_NOIDLE))
		req->cmd_flags |= REQ_NOIDLE;

	req->errors = 0;
@@ -1155,12 +1155,12 @@ static int __make_request(struct request_queue *q, struct bio *bio)
	int el_ret;
	unsigned int bytes = bio->bi_size;
	const unsigned short prio = bio_prio(bio);
	const int sync = bio_sync(bio);
	const int unplug = bio_unplug(bio);
	const bool sync = bio_rw_flagged(bio, BIO_RW_SYNCIO);
	const bool unplug = bio_rw_flagged(bio, BIO_RW_UNPLUG);
	const unsigned int ff = bio->bi_rw & REQ_FAILFAST_MASK;
	int rw_flags;

	if (bio_barrier(bio) && bio_has_data(bio) &&
	if (bio_rw_flagged(bio, BIO_RW_BARRIER) && bio_has_data(bio) &&
	    (q->next_ordered == QUEUE_ORDERED_NONE)) {
		bio_endio(bio, -EOPNOTSUPP);
		return 0;
@@ -1174,7 +1174,7 @@ static int __make_request(struct request_queue *q, struct bio *bio)

	spin_lock_irq(q->queue_lock);

	if (unlikely(bio_barrier(bio)) || elv_queue_empty(q))
	if (unlikely(bio_rw_flagged(bio, BIO_RW_BARRIER)) || elv_queue_empty(q))
		goto get_rq;

	el_ret = elv_merge(q, &req, bio);
@@ -1470,7 +1470,8 @@ static inline void __generic_make_request(struct bio *bio)
		if (bio_check_eod(bio, nr_sectors))
			goto end_io;

		if (bio_discard(bio) && !q->prepare_discard_fn) {
		if (bio_rw_flagged(bio, BIO_RW_DISCARD) &&
		    !q->prepare_discard_fn) {
			err = -EOPNOTSUPP;
			goto end_io;
		}
+1 −1
Original line number Diff line number Diff line
@@ -257,7 +257,7 @@ static inline void cic_set_cfqq(struct cfq_io_context *cic,
 */
static inline int cfq_bio_sync(struct bio *bio)
{
	if (bio_data_dir(bio) == READ || bio_sync(bio))
	if (bio_data_dir(bio) == READ || bio_rw_flagged(bio, BIO_RW_SYNCIO))
		return 1;

	return 0;
+2 −1
Original line number Diff line number Diff line
@@ -79,7 +79,8 @@ int elv_rq_merge_ok(struct request *rq, struct bio *bio)
	/*
	 * Don't merge file system requests and discard requests
	 */
	if (bio_discard(bio) != bio_discard(rq->bio))
	if (bio_rw_flagged(bio, BIO_RW_DISCARD) !=
	    bio_rw_flagged(rq->bio, BIO_RW_DISCARD))
		return 0;

	/*
+1 −1
Original line number Diff line number Diff line
@@ -475,7 +475,7 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio)
	pos = ((loff_t) bio->bi_sector << 9) + lo->lo_offset;

	if (bio_rw(bio) == WRITE) {
		int barrier = bio_barrier(bio);
		bool barrier = bio_rw_flagged(bio, BIO_RW_BARRIER);
		struct file *file = lo->lo_backing_file;

		if (barrier) {
+1 −1
Original line number Diff line number Diff line
@@ -1129,7 +1129,7 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio,
	if (error == -EOPNOTSUPP)
		goto out;

	if ((error == -EWOULDBLOCK) && bio_rw_ahead(bio))
	if ((error == -EWOULDBLOCK) && bio_rw_flagged(bio, BIO_RW_AHEAD))
		goto out;

	if (unlikely(error)) {
Loading