diff mbox series

[v1,09/15] block: bvec_put_page_dirty* instead of set_page_dirty* and bvec_put_page

Message ID 20190411210834.4105-10-jglisse@redhat.com (mailing list archive)
State New, archived
Headers show
Series Keep track of GUPed pages in fs and block | expand

Commit Message

Jerome Glisse April 11, 2019, 9:08 p.m. UTC
From: Jérôme Glisse <jglisse@redhat.com>

Use bvec_put_page_dirty*() instead of set_page_dirty*() followed by a call
to bvec_put_page(). With this change we can use the proper put_user_page*()
helpers.

Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-block@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Matthew Wilcox <willy@infradead.org>
---
 block/bio.c    | 8 ++------
 fs/block_dev.c | 8 +++-----
 fs/ceph/file.c | 6 +-----
 fs/cifs/misc.c | 8 +++-----
 4 files changed, 9 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/block/bio.c b/block/bio.c
index b74b81085f3a..efd254c90974 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1448,12 +1448,8 @@  static void __bio_unmap_user(struct bio *bio)
 	/*
 	 * make sure we dirty pages we wrote to
 	 */
-	bio_for_each_segment_all(bvec, bio, i, iter_all) {
-		if (bio_data_dir(bio) == READ)
-			set_page_dirty_lock(bvec_page(bvec));
-
-		bvec_put_page(bvec);
-	}
+	bio_for_each_segment_all(bvec, bio, i, iter_all)
+		bvec_put_page_dirty_lock(bvec, bio_data_dir(bio) == READ);
 
 	bio_put(bio);
 }
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 9761f7943774..16a17fae6694 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -261,11 +261,9 @@  __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
 	}
 	__set_current_state(TASK_RUNNING);
 
-	bio_for_each_segment_all(bvec, &bio, i, iter_all) {
-		if (should_dirty && !PageCompound(bvec_page(bvec)))
-			set_page_dirty_lock(bvec_page(bvec));
-		bvec_put_page(bvec);
-	}
+	bio_for_each_segment_all(bvec, &bio, i, iter_all)
+		bvec_put_page_dirty_lock(bvec, should_dirty &&
+				!PageCompound(bvec_page(bvec)));
 
 	if (unlikely(bio.bi_status))
 		ret = blk_status_to_errno(bio.bi_status);
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 6a39347f4956..d5561662b902 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -160,11 +160,7 @@  static void put_bvecs(struct bio_vec *bvecs, int num_bvecs, bool should_dirty)
 	int i;
 
 	for (i = 0; i < num_bvecs; i++) {
-		if (bvec_page(&bvecs[i])) {
-			if (should_dirty)
-				set_page_dirty_lock(bvec_page(&bvecs[i]));
-			bvec_put_page(&bvecs[i]);
-		}
+		bvec_put_page_dirty_lock(&bvecs[i], should_dirty);
 	}
 	kvfree(bvecs);
 }
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index 86d78f297526..bc77a4a5f1af 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -800,11 +800,9 @@  cifs_aio_ctx_release(struct kref *refcount)
 	if (ctx->bv) {
 		unsigned i;
 
-		for (i = 0; i < ctx->npages; i++) {
-			if (ctx->should_dirty)
-				set_page_dirty(bvec_page(&ctx->bv[i]));
-			bvec_put_page(&ctx->bv[i]);
-		}
+		for (i = 0; i < ctx->npages; i++)
+			bvec_put_page_dirty_lock(&ctx->bv[i],
+					  ctx->should_dirty);
 		kvfree(ctx->bv);
 	}