Re: [PATCH v1 15/15] ceph: use put_user_pages() instead of ceph_put_page_vector()

From: Yan, Zheng
Date: Mon Apr 15 2019 - 03:47:21 EST


On 4/12/19 5:08 AM, jglisse@xxxxxxxxxx wrote:
From: JÃrÃme Glisse <jglisse@xxxxxxxxxx>

When page reference were taken through GUP (get_user_page*()) we need
to drop them with put_user_pages().

Signed-off-by: JÃrÃme Glisse <jglisse@xxxxxxxxxx>
Cc: linux-fsdevel@xxxxxxxxxxxxxxx
Cc: linux-block@xxxxxxxxxxxxxxx
Cc: linux-mm@xxxxxxxxx
Cc: John Hubbard <jhubbard@xxxxxxxxxx>
Cc: Jan Kara <jack@xxxxxxx>
Cc: Dan Williams <dan.j.williams@xxxxxxxxx>
Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>
Cc: Johannes Thumshirn <jthumshirn@xxxxxxx>
Cc: Christoph Hellwig <hch@xxxxxx>
Cc: Jens Axboe <axboe@xxxxxxxxx>
Cc: Ming Lei <ming.lei@xxxxxxxxxx>
Cc: Dave Chinner <david@xxxxxxxxxxxxx>
Cc: Jason Gunthorpe <jgg@xxxxxxxx>
Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
Cc: Yan Zheng <zyan@xxxxxxxxxx>
Cc: Sage Weil <sage@xxxxxxxxxx>
Cc: Ilya Dryomov <idryomov@xxxxxxxxx>
Cc: ceph-devel@xxxxxxxxxxxxxxx
---
fs/ceph/file.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 6c5b85f01721..5842ad3a4218 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -667,7 +667,8 @@ static ssize_t ceph_sync_read(struct kiocb *iocb, struct iov_iter *to,
} else {
iov_iter_advance(to, 0);
}
- ceph_put_page_vector(pages, num_pages, false);
+ /* iov_iter_get_pages_alloc() did call GUP */
+ put_user_pages(pages, num_pages);

pages in pipe were not from get_user_pages(). Am I missing anything?

Regards
Yan, Zheng

} else {
int idx = 0;
size_t left = ret > 0 ? ret : 0;