linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Ming Lei <ming.lei@redhat.com>
Subject: [PATCH 7/8] loop: remove lo->use_dio
Date: Mon, 25 Oct 2021 17:44:36 +0800	[thread overview]
Message-ID: <20211025094437.2837701-8-ming.lei@redhat.com> (raw)
In-Reply-To: <20211025094437.2837701-1-ming.lei@redhat.com>

lo->use_dio is just a copy of (lo->lo_flags & LO_FLAGS_DIRECT_IO), no
necessary to keep it.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 drivers/block/loop.c | 12 +++++-------
 drivers/block/loop.h |  1 -
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index f42630246758..e42c0e3601ac 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -226,13 +226,12 @@ static void __loop_update_dio(struct loop_device *lo, bool dio)
 		use_dio = false;
 	}
 
-	if (lo->use_dio == use_dio)
+	if (!!(lo->lo_flags & LO_FLAGS_DIRECT_IO) == use_dio)
 		return;
 
 	/* flush dirty pages before changing direct IO */
 	vfs_fsync(file, 0);
 
-	lo->use_dio = use_dio;
 	if (use_dio) {
 		blk_queue_flag_clear(QUEUE_FLAG_NOMERGES, lo->lo_queue);
 		lo->lo_flags |= LO_FLAGS_DIRECT_IO;
@@ -622,7 +621,7 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq)
 static inline void loop_update_dio(struct loop_device *lo)
 {
 	__loop_update_dio(lo, (lo->lo_backing_file->f_flags & O_DIRECT) |
-				lo->use_dio);
+				(lo->lo_flags & LO_FLAGS_DIRECT_IO));
 }
 
 static void loop_reread_partitions(struct loop_device *lo)
@@ -1207,7 +1206,6 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
 	lo->worker_tree = RB_ROOT;
 	timer_setup(&lo->timer, loop_free_idle_workers,
 		TIMER_DEFERRABLE);
-	lo->use_dio = lo->lo_flags & LO_FLAGS_DIRECT_IO;
 	lo->lo_device = bdev;
 	lo->lo_backing_file = file;
 	lo->old_gfp_mask = mapping_gfp_mask(mapping);
@@ -1495,7 +1493,7 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
 	loop_config_discard(lo);
 
 	/* update dio if lo_offset or transfer is changed */
-	__loop_update_dio(lo, lo->use_dio);
+	__loop_update_dio(lo, lo->lo_flags & LO_FLAGS_DIRECT_IO);
 
 out_unfreeze:
 	blk_mq_unfreeze_queue(lo->lo_queue);
@@ -1682,7 +1680,7 @@ static int loop_set_dio(struct loop_device *lo, unsigned long arg)
 		goto out;
 
 	__loop_update_dio(lo, !!arg);
-	if (lo->use_dio == !!arg)
+	if (!!(lo->lo_flags & LO_FLAGS_DIRECT_IO) == !!arg)
 		return 0;
 	error = -EINVAL;
  out:
@@ -2094,7 +2092,7 @@ static blk_status_t loop_queue_rq(struct blk_mq_hw_ctx *hctx,
 		break;
 	default:
 		cmd->use_aio = !lo->transfer;
-		cmd->use_dio = lo->use_dio && cmd->use_aio;
+		cmd->use_dio = (lo->lo_flags & LO_FLAGS_DIRECT_IO) && cmd->use_aio;
 		break;
 	}
 
diff --git a/drivers/block/loop.h b/drivers/block/loop.h
index b7d611e4f517..feb92efb3b57 100644
--- a/drivers/block/loop.h
+++ b/drivers/block/loop.h
@@ -61,7 +61,6 @@ struct loop_device {
 	struct list_head        idle_worker_list;
 	struct rb_root          worker_tree;
 	struct timer_list       timer;
-	bool			use_dio;
 	bool			sysfs_inited;
 
 	struct request_queue	*lo_queue;
-- 
2.31.1


  parent reply	other threads:[~2021-10-25  9:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-25  9:44 [PATCH 0/8] loop: improve dio on backing file Ming Lei
2021-10-25  9:44 ` [PATCH 1/8] loop: move flush_dcache_page to ->complete of request Ming Lei
2021-10-26  7:21   ` Christoph Hellwig
2021-10-25  9:44 ` [PATCH 2/8] loop: remove always true check Ming Lei
2021-10-26  7:31   ` Christoph Hellwig
2021-10-25  9:44 ` [PATCH 3/8] loop: add one helper for submitting IO on backing file Ming Lei
2021-10-25  9:44 ` [PATCH 4/8] loop: cover simple read/write via lo_rw_aio() Ming Lei
2021-10-26  7:35   ` Christoph Hellwig
2021-10-25  9:44 ` [PATCH 5/8] loop: fallback to buffered IO in case of dio submission Ming Lei
2021-10-26  7:36   ` Christoph Hellwig
2021-10-25  9:44 ` [PATCH 6/8] loop: relax loop dio use condition Ming Lei
2021-10-26  7:37   ` Christoph Hellwig
2021-10-27  0:20   ` kernel test robot
2021-10-25  9:44 ` Ming Lei [this message]
2021-10-25  9:44 ` [RFC PATCH 8/8] loop: use backing dio at default Ming Lei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211025094437.2837701-8-ming.lei@redhat.com \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).