lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190411210834.4105-10-jglisse@redhat.com>
Date:   Thu, 11 Apr 2019 17:08:28 -0400
From:   jglisse@...hat.com
To:     linux-kernel@...r.kernel.org
Cc:     Jérôme Glisse <jglisse@...hat.com>,
        linux-fsdevel@...r.kernel.org, linux-block@...r.kernel.org,
        linux-mm@...ck.org, John Hubbard <jhubbard@...dia.com>,
        Jan Kara <jack@...e.cz>,
        Dan Williams <dan.j.williams@...el.com>,
        Alexander Viro <viro@...iv.linux.org.uk>,
        Johannes Thumshirn <jthumshirn@...e.de>,
        Christoph Hellwig <hch@....de>, Jens Axboe <axboe@...nel.dk>,
        Ming Lei <ming.lei@...hat.com>,
        Dave Chinner <david@...morbit.com>,
        Jason Gunthorpe <jgg@...pe.ca>,
        Matthew Wilcox <willy@...radead.org>
Subject: [PATCH v1 09/15] block: bvec_put_page_dirty* instead of set_page_dirty* and bvec_put_page

From: Jérôme Glisse <jglisse@...hat.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@...hat.com>
Cc: linux-fsdevel@...r.kernel.org
Cc: linux-block@...r.kernel.org
Cc: linux-mm@...ck.org
Cc: John Hubbard <jhubbard@...dia.com>
Cc: Jan Kara <jack@...e.cz>
Cc: Dan Williams <dan.j.williams@...el.com>
Cc: Alexander Viro <viro@...iv.linux.org.uk>
Cc: Johannes Thumshirn <jthumshirn@...e.de>
Cc: Christoph Hellwig <hch@....de>
Cc: Jens Axboe <axboe@...nel.dk>
Cc: Ming Lei <ming.lei@...hat.com>
Cc: Dave Chinner <david@...morbit.com>
Cc: Jason Gunthorpe <jgg@...pe.ca>
Cc: Matthew Wilcox <willy@...radead.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 --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);
 	}
 
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ