From: john.hubbard@gmail.com To: Andrew Morton <akpm@linux-foundation.org> Cc: "Alexander Viro" <viro@zeniv.linux.org.uk>, "Anna Schumaker" <anna.schumaker@netapp.com>, "David S . Miller" <davem@davemloft.net>, "Dominique Martinet" <asmadeus@codewreck.org>, "Eric Van Hensbergen" <ericvh@gmail.com>, "Jason Gunthorpe" <jgg@ziepe.ca>, "Jason Wang" <jasowang@redhat.com>, "Jens Axboe" <axboe@kernel.dk>, "Latchesar Ionkov" <lucho@ionkov.net>, "Michael S . Tsirkin" <mst@redhat.com>, "Miklos Szeredi" <miklos@szeredi.hu>, "Trond Myklebust" <trond.myklebust@hammerspace.com>, "Christoph Hellwig" <hch@lst.de>, "Matthew Wilcox" <willy@infradead.org>, linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>, ceph-devel@vger.kernel.org, kvm@vger.kernel.org, linux-block@vger.kernel.org, linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, samba-technical@lists.samba.org, v9fs-developer@lists.sourceforge.net, virtualization@lists.linux-foundation.org, "Jérôme Glisse" <jglisse@redhat.com>, "John Hubbard" <jhubbard@nvidia.com>, "Jan Kara" <jack@suse.cz>, "Dan Williams" <dan.j.williams@intel.com>, "Johannes Thumshirn" <jthumshirn@suse.de>, "Ming Lei" <ming.lei@redhat.com>, "Dave Chinner" <david@fromorbit.com>, "Boaz Harrosh" <boaz@plexistor.com>, "Steve French" <sfrench@samba.org> Subject: [PATCH 08/12] fs/cifs: convert put_page() to put_user_page*() Date: Tue, 23 Jul 2019 21:25:14 -0700 [thread overview] Message-ID: <20190724042518.14363-9-jhubbard@nvidia.com> (raw) In-Reply-To: <20190724042518.14363-1-jhubbard@nvidia.com> From: Jérôme Glisse <jglisse@redhat.com> For pages that were retained via get_user_pages*(), release those pages via the new put_user_page*() routines, instead of via put_page(). This is part a tree-wide conversion, as described in commit fc1d8e7cca2d ("mm: introduce put_user_page*(), placeholder versions"). Signed-off-by: Jérôme Glisse <jglisse@redhat.com> Signed-off-by: John Hubbard <jhubbard@nvidia.com> Cc: linux-fsdevel@vger.kernel.org Cc: linux-block@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-cifs@vger.kernel.org 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> Cc: Boaz Harrosh <boaz@plexistor.com> Cc: Steve French <sfrench@samba.org> --- fs/cifs/cifsglob.h | 3 +++ fs/cifs/file.c | 22 +++++++++++++++++----- fs/cifs/misc.c | 19 +++++++++++++++---- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index fe610e7e3670..e95cb82bfa50 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -1283,6 +1283,7 @@ struct cifs_aio_ctx { * If yes, iter is a copy of the user passed iov_iter */ bool direct_io; + bool from_gup; }; struct cifs_readdata; @@ -1317,6 +1318,7 @@ struct cifs_readdata { struct cifs_credits credits; unsigned int nr_pages; struct page **pages; + bool from_gup; }; struct cifs_writedata; @@ -1343,6 +1345,7 @@ struct cifs_writedata { struct cifs_credits credits; unsigned int nr_pages; struct page **pages; + bool from_gup; }; /* diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 97090693d182..84fa7e0a578f 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2571,8 +2571,13 @@ cifs_uncached_writedata_release(struct kref *refcount) struct cifs_writedata, refcount); kref_put(&wdata->ctx->refcount, cifs_aio_ctx_release); - for (i = 0; i < wdata->nr_pages; i++) - put_page(wdata->pages[i]); + if (wdata->from_gup) { + for (i = 0; i < wdata->nr_pages; i++) + put_user_page(wdata->pages[i]); + } else { + for (i = 0; i < wdata->nr_pages; i++) + put_page(wdata->pages[i]); + } cifs_writedata_release(refcount); } @@ -2781,7 +2786,7 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from, break; } - + wdata->from_gup = iov_iter_get_pages_use_gup(from); wdata->page_offset = start; wdata->tailsz = nr_pages > 1 ? @@ -2797,6 +2802,7 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from, add_credits_and_wake_if(server, credits, 0); break; } + wdata->from_gup = false; rc = cifs_write_allocate_pages(wdata->pages, nr_pages); if (rc) { @@ -3238,8 +3244,12 @@ cifs_uncached_readdata_release(struct kref *refcount) unsigned int i; kref_put(&rdata->ctx->refcount, cifs_aio_ctx_release); - for (i = 0; i < rdata->nr_pages; i++) { - put_page(rdata->pages[i]); + if (rdata->from_gup) { + for (i = 0; i < rdata->nr_pages; i++) + put_user_page(rdata->pages[i]); + } else { + for (i = 0; i < rdata->nr_pages; i++) + put_page(rdata->pages[i]); } cifs_readdata_release(refcount); } @@ -3502,6 +3512,7 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file, break; } + rdata->from_gup = iov_iter_get_pages_use_gup(&direct_iov); npages = (cur_len + start + PAGE_SIZE-1) / PAGE_SIZE; rdata->page_offset = start; rdata->tailsz = npages > 1 ? @@ -3519,6 +3530,7 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file, rc = -ENOMEM; break; } + rdata->from_gup = false; rc = cifs_read_allocate_pages(rdata, npages); if (rc) { diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index f383877a6511..5a04c34fea05 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c @@ -822,10 +822,18 @@ 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(ctx->bv[i].bv_page); - put_page(ctx->bv[i].bv_page); + if (ctx->from_gup) { + for (i = 0; i < ctx->npages; i++) { + if (ctx->should_dirty) + set_page_dirty(ctx->bv[i].bv_page); + put_user_page(ctx->bv[i].bv_page); + } + } else { + for (i = 0; i < ctx->npages; i++) { + if (ctx->should_dirty) + set_page_dirty(ctx->bv[i].bv_page); + put_page(ctx->bv[i].bv_page); + } } kvfree(ctx->bv); } @@ -881,6 +889,9 @@ setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw) saved_len = count; + /* This is only use by cifs_aio_ctx_release() */ + ctx->from_gup = iov_iter_get_pages_use_gup(iter); + while (count && npages < max_pages) { rc = iov_iter_get_pages(iter, pages, count, max_pages, &start); if (rc < 0) { -- 2.22.0
WARNING: multiple messages have this Message-ID (diff)
From: john.hubbard@gmail.com To: Andrew Morton <akpm@linux-foundation.org> Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Anna Schumaker <anna.schumaker@netapp.com>, "David S . Miller" <davem@davemloft.net>, Dominique Martinet <asmadeus@codewreck.org>, Eric Van Hensbergen <ericvh@gmail.com>, Jason Gunthorpe <jgg@ziepe.ca>, Jason Wang <jasowang@redhat.com>, Jens Axboe <axboe@kernel.dk>, Latchesar Ionkov <lucho@ionkov.net>, "Michael S . Tsirkin" <mst@redhat.com>, Miklos Szeredi <miklos@szeredi.hu>, Trond Myklebust <trond.myklebust@hammerspace.com>, Christoph Hellwig <hch@lst.de>, Matthew Wilcox <willy@infradead.org>, linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>, ceph-devel@vger.kernel.org, kvm@vger.kernel.org, linux-block@vger.kernel.org, linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.orglinu Subject: [PATCH 08/12] fs/cifs: convert put_page() to put_user_page*() Date: Tue, 23 Jul 2019 21:25:14 -0700 [thread overview] Message-ID: <20190724042518.14363-9-jhubbard@nvidia.com> (raw) In-Reply-To: <20190724042518.14363-1-jhubbard@nvidia.com> From: Jérôme Glisse <jglisse@redhat.com> For pages that were retained via get_user_pages*(), release those pages via the new put_user_page*() routines, instead of via put_page(). This is part a tree-wide conversion, as described in commit fc1d8e7cca2d ("mm: introduce put_user_page*(), placeholder versions"). Signed-off-by: Jérôme Glisse <jglisse@redhat.com> Signed-off-by: John Hubbard <jhubbard@nvidia.com> Cc: linux-fsdevel@vger.kernel.org Cc: linux-block@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-cifs@vger.kernel.org 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> Cc: Boaz Harrosh <boaz@plexistor.com> Cc: Steve French <sfrench@samba.org> --- fs/cifs/cifsglob.h | 3 +++ fs/cifs/file.c | 22 +++++++++++++++++----- fs/cifs/misc.c | 19 +++++++++++++++---- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index fe610e7e3670..e95cb82bfa50 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -1283,6 +1283,7 @@ struct cifs_aio_ctx { * If yes, iter is a copy of the user passed iov_iter */ bool direct_io; + bool from_gup; }; struct cifs_readdata; @@ -1317,6 +1318,7 @@ struct cifs_readdata { struct cifs_credits credits; unsigned int nr_pages; struct page **pages; + bool from_gup; }; struct cifs_writedata; @@ -1343,6 +1345,7 @@ struct cifs_writedata { struct cifs_credits credits; unsigned int nr_pages; struct page **pages; + bool from_gup; }; /* diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 97090693d182..84fa7e0a578f 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2571,8 +2571,13 @@ cifs_uncached_writedata_release(struct kref *refcount) struct cifs_writedata, refcount); kref_put(&wdata->ctx->refcount, cifs_aio_ctx_release); - for (i = 0; i < wdata->nr_pages; i++) - put_page(wdata->pages[i]); + if (wdata->from_gup) { + for (i = 0; i < wdata->nr_pages; i++) + put_user_page(wdata->pages[i]); + } else { + for (i = 0; i < wdata->nr_pages; i++) + put_page(wdata->pages[i]); + } cifs_writedata_release(refcount); } @@ -2781,7 +2786,7 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from, break; } - + wdata->from_gup = iov_iter_get_pages_use_gup(from); wdata->page_offset = start; wdata->tailsz = nr_pages > 1 ? @@ -2797,6 +2802,7 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from, add_credits_and_wake_if(server, credits, 0); break; } + wdata->from_gup = false; rc = cifs_write_allocate_pages(wdata->pages, nr_pages); if (rc) { @@ -3238,8 +3244,12 @@ cifs_uncached_readdata_release(struct kref *refcount) unsigned int i; kref_put(&rdata->ctx->refcount, cifs_aio_ctx_release); - for (i = 0; i < rdata->nr_pages; i++) { - put_page(rdata->pages[i]); + if (rdata->from_gup) { + for (i = 0; i < rdata->nr_pages; i++) + put_user_page(rdata->pages[i]); + } else { + for (i = 0; i < rdata->nr_pages; i++) + put_page(rdata->pages[i]); } cifs_readdata_release(refcount); } @@ -3502,6 +3512,7 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file, break; } + rdata->from_gup = iov_iter_get_pages_use_gup(&direct_iov); npages = (cur_len + start + PAGE_SIZE-1) / PAGE_SIZE; rdata->page_offset = start; rdata->tailsz = npages > 1 ? @@ -3519,6 +3530,7 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file, rc = -ENOMEM; break; } + rdata->from_gup = false; rc = cifs_read_allocate_pages(rdata, npages); if (rc) { diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index f383877a6511..5a04c34fea05 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c @@ -822,10 +822,18 @@ 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(ctx->bv[i].bv_page); - put_page(ctx->bv[i].bv_page); + if (ctx->from_gup) { + for (i = 0; i < ctx->npages; i++) { + if (ctx->should_dirty) + set_page_dirty(ctx->bv[i].bv_page); + put_user_page(ctx->bv[i].bv_page); + } + } else { + for (i = 0; i < ctx->npages; i++) { + if (ctx->should_dirty) + set_page_dirty(ctx->bv[i].bv_page); + put_page(ctx->bv[i].bv_page); + } } kvfree(ctx->bv); } @@ -881,6 +889,9 @@ setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw) saved_len = count; + /* This is only use by cifs_aio_ctx_release() */ + ctx->from_gup = iov_iter_get_pages_use_gup(iter); + while (count && npages < max_pages) { rc = iov_iter_get_pages(iter, pages, count, max_pages, &start); if (rc < 0) { -- 2.22.0
next prev parent reply other threads:[~2019-07-24 4:25 UTC|newest] Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-07-24 4:25 [PATCH 00/12] block/bio, fs: convert put_page() to put_user_page*() john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` [PATCH 01/12] mm/gup: add make_dirty arg to put_user_pages_dirty_lock() john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` [PATCH 02/12] iov_iter: add helper to test if an iter would use GUP v2 john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` [PATCH 03/12] block: bio_release_pages: use flags arg instead of bool john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 5:30 ` Christoph Hellwig 2019-07-24 5:30 ` Christoph Hellwig 2019-07-24 5:30 ` Christoph Hellwig 2019-07-29 20:57 ` Jerome Glisse 2019-07-29 20:57 ` Jerome Glisse 2019-07-30 10:25 ` Christoph Hellwig 2019-07-30 10:25 ` Christoph Hellwig 2019-07-30 15:57 ` Jerome Glisse 2019-07-30 15:57 ` Jerome Glisse 2019-07-30 15:57 ` Jerome Glisse 2019-08-01 8:20 ` Christoph Hellwig 2019-08-01 8:20 ` Christoph Hellwig 2019-08-01 8:20 ` Christoph Hellwig 2019-07-30 10:25 ` Christoph Hellwig 2019-07-29 20:57 ` Jerome Glisse 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` [PATCH 04/12] block: bio_release_pages: convert put_page() to put_user_page*() john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` [PATCH 05/12] block_dev: " john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` [PATCH 06/12] fs/nfs: " john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` [PATCH 07/12] vhost-scsi: " john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:34 ` John Hubbard 2019-07-24 4:34 ` John Hubbard 2019-07-24 4:34 ` John Hubbard 2019-07-24 8:07 ` Michael S. Tsirkin 2019-07-24 8:07 ` Michael S. Tsirkin 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` john.hubbard [this message] 2019-07-24 4:25 ` [PATCH 08/12] fs/cifs: " john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` [PATCH 09/12] fs/fuse: " john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` [PATCH 10/12] fs/ceph: " john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` [PATCH 11/12] 9p/net: " john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` [PATCH 12/12] fs/ceph: fix a build warning: returning a value from void function john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 4:25 ` john.hubbard 2019-07-24 6:17 ` [PATCH 00/12] block/bio, fs: convert put_page() to put_user_page*() Christoph Hellwig 2019-07-24 6:17 ` Christoph Hellwig 2019-07-24 6:17 ` Christoph Hellwig 2019-07-24 23:23 ` John Hubbard 2019-07-24 23:23 ` John Hubbard 2019-08-05 22:54 ` John Hubbard 2019-08-05 22:54 ` John Hubbard 2019-08-07 6:34 ` Christoph Hellwig 2019-08-07 6:34 ` Christoph Hellwig 2019-08-07 6:34 ` Christoph Hellwig 2019-08-07 6:38 ` John Hubbard 2019-08-07 6:38 ` John Hubbard 2019-07-25 0:41 ` Bob Liu 2019-07-25 0:41 ` Bob Liu 2019-07-26 1:24 ` John Hubbard 2019-07-26 1:24 ` John Hubbard
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=20190724042518.14363-9-jhubbard@nvidia.com \ --to=john.hubbard@gmail.com \ --cc=akpm@linux-foundation.org \ --cc=anna.schumaker@netapp.com \ --cc=asmadeus@codewreck.org \ --cc=axboe@kernel.dk \ --cc=boaz@plexistor.com \ --cc=ceph-devel@vger.kernel.org \ --cc=dan.j.williams@intel.com \ --cc=davem@davemloft.net \ --cc=david@fromorbit.com \ --cc=ericvh@gmail.com \ --cc=hch@lst.de \ --cc=jack@suse.cz \ --cc=jasowang@redhat.com \ --cc=jgg@ziepe.ca \ --cc=jglisse@redhat.com \ --cc=jhubbard@nvidia.com \ --cc=jthumshirn@suse.de \ --cc=kvm@vger.kernel.org \ --cc=linux-block@vger.kernel.org \ --cc=linux-cifs@vger.kernel.org \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=linux-nfs@vger.kernel.org \ --cc=linux-rdma@vger.kernel.org \ --cc=lucho@ionkov.net \ --cc=miklos@szeredi.hu \ --cc=ming.lei@redhat.com \ --cc=mst@redhat.com \ --cc=netdev@vger.kernel.org \ --cc=samba-technical@lists.samba.org \ --cc=sfrench@samba.org \ --cc=trond.myklebust@hammerspace.com \ --cc=v9fs-developer@lists.sourceforge.net \ --cc=viro@zeniv.linux.org.uk \ --cc=virtualization@lists.linux-foundation.org \ --cc=willy@infradead.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.