[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190411210834.4105-5-jglisse@redhat.com>
Date: Thu, 11 Apr 2019 17:08:23 -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>,
Ilya Dryomov <idryomov@...il.com>, Sage Weil <sage@...hat.com>,
Alex Elder <elder@...nel.org>, ceph-devel@...r.kernel.org,
Eric Van Hensbergen <ericvh@...il.com>,
Latchesar Ionkov <lucho@...kov.net>,
Steve French <sfrench@...ba.org>, linux-cifs@...r.kernel.org,
Mike Marshall <hubcap@...ibond.com>,
Martin Brandenburg <martin@...ibond.com>,
devel@...ts.orangefs.org,
Dominique Martinet <asmadeus@...ewreck.org>,
v9fs-developer@...ts.sourceforge.net
Subject: [PATCH v1 04/15] block: introduce BIO_VEC_INIT() macro to initialize bio_vec structure
From: Jérôme Glisse <jglisse@...hat.com>
This add a macro to initialize bio_vec structure. We want to convert
all initialization with that macro so that it is easier to change the
bvec->page fields in latter patch.
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>
Cc: Ilya Dryomov <idryomov@...il.com>
Cc: Sage Weil <sage@...hat.com>
Cc: Alex Elder <elder@...nel.org>
Cc: ceph-devel@...r.kernel.org
Cc: Eric Van Hensbergen <ericvh@...il.com>
Cc: Latchesar Ionkov <lucho@...kov.net>
Cc: Steve French <sfrench@...ba.org>
Cc: linux-cifs@...r.kernel.org
Cc: Mike Marshall <hubcap@...ibond.com>
Cc: Martin Brandenburg <martin@...ibond.com>
Cc: devel@...ts.orangefs.org
Cc: Dominique Martinet <asmadeus@...ewreck.org>
Cc: v9fs-developer@...ts.sourceforge.net
---
block/blk-integrity.c | 4 ++--
block/blk-merge.c | 2 +-
fs/9p/vfs_addr.c | 2 +-
fs/ceph/file.c | 8 +++-----
fs/cifs/connect.c | 4 ++--
fs/orangefs/inode.c | 2 +-
include/linux/bvec.h | 2 ++
mm/page_io.c | 6 +-----
net/ceph/messenger.c | 6 +-----
9 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index d1ab089e0919..916a5406649d 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -40,7 +40,7 @@
*/
int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio)
{
- struct bio_vec iv, ivprv = { NULL };
+ struct bio_vec iv, ivprv = BIO_VEC_INIT(NULL, 0, 0);
unsigned int segments = 0;
unsigned int seg_size = 0;
struct bvec_iter iter;
@@ -82,7 +82,7 @@ EXPORT_SYMBOL(blk_rq_count_integrity_sg);
int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio,
struct scatterlist *sglist)
{
- struct bio_vec iv, ivprv = { NULL };
+ struct bio_vec iv, ivprv = BIO_VEC_INIT(NULL, 0, 0);
struct scatterlist *sg = NULL;
unsigned int segments = 0;
struct bvec_iter iter;
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 1c9d4f0f96ea..c355fb9e9e8e 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -447,7 +447,7 @@ void blk_recount_segments(struct request_queue *q, struct bio *bio)
static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio,
struct bio *nxt)
{
- struct bio_vec end_bv = { NULL }, nxt_bv;
+ struct bio_vec end_bv = BIO_VEC_INIT(NULL, 0, 0), nxt_bv;
if (bio->bi_seg_back_size + nxt->bi_seg_front_size >
queue_max_segment_size(q))
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index 0bcbcc20f769..b626b28f0ce9 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -53,7 +53,7 @@
static int v9fs_fid_readpage(struct p9_fid *fid, struct page *page)
{
struct inode *inode = page->mapping->host;
- struct bio_vec bvec = {.bv_page = page, .bv_len = PAGE_SIZE};
+ struct bio_vec bvec = BIO_VEC_INIT(page, PAGE_SIZE, 0);
struct iov_iter to;
int retval, err;
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 9f53c3d99304..d3c8035335a2 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -100,11 +100,9 @@ static ssize_t __iter_get_bvecs(struct iov_iter *iter, size_t maxsize,
size += bytes;
for ( ; bytes; idx++, bvec_idx++) {
- struct bio_vec bv = {
- .bv_page = pages[idx],
- .bv_len = min_t(int, bytes, PAGE_SIZE - start),
- .bv_offset = start,
- };
+ struct bio_vec bv = BIO_VEC_INIT(pages[idx],
+ min_t(int, bytes, PAGE_SIZE - start),
+ start);
bvecs[bvec_idx] = bv;
bytes -= bv.bv_len;
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 4c0e44489f21..86438f3933a9 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -809,8 +809,8 @@ cifs_read_page_from_socket(struct TCP_Server_Info *server, struct page *page,
unsigned int page_offset, unsigned int to_read)
{
struct msghdr smb_msg;
- struct bio_vec bv = {
- .bv_page = page, .bv_len = to_read, .bv_offset = page_offset};
+ struct bio_vec bv = BIO_VEC_INIT(page, to_read, page_offset);
+
iov_iter_bvec(&smb_msg.msg_iter, READ, &bv, 1, to_read);
return cifs_readv_from_socket(server, &smb_msg);
}
diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
index c3334eca18c7..5ebd2da4c093 100644
--- a/fs/orangefs/inode.c
+++ b/fs/orangefs/inode.c
@@ -23,7 +23,7 @@ static int read_one_page(struct page *page)
const __u32 blocksize = PAGE_SIZE;
const __u32 blockbits = PAGE_SHIFT;
struct iov_iter to;
- struct bio_vec bv = {.bv_page = page, .bv_len = PAGE_SIZE};
+ struct bio_vec bv = BIO_VEC_INIT(page, PAGE_SIZE, 0);
iov_iter_bvec(&to, READ, &bv, 1, PAGE_SIZE);
diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index 44866555258a..8f8fb528ce53 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -70,6 +70,8 @@ static inline struct page *bvec_nth_page(struct page *page, int idx)
* various member access, note that bio_data should of course not be used
* on highmem page vectors
*/
+#define BIO_VEC_INIT(p, l, o) {.bv_page = (p), .bv_len = (l), .bv_offset = (o)}
+
#define __bvec_iter_bvec(bvec, iter) (&(bvec)[(iter).bi_idx])
/* multi-page (mp_bvec) helpers */
diff --git a/mm/page_io.c b/mm/page_io.c
index 2e8019d0e048..6b3be0445c61 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -287,11 +287,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
struct kiocb kiocb;
struct file *swap_file = sis->swap_file;
struct address_space *mapping = swap_file->f_mapping;
- struct bio_vec bv = {
- .bv_page = page,
- .bv_len = PAGE_SIZE,
- .bv_offset = 0
- };
+ struct bio_vec bv = BIO_VEC_INIT(page, PAGE_SIZE, 0);
struct iov_iter from;
iov_iter_bvec(&from, WRITE, &bv, 1, PAGE_SIZE);
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 3083988ce729..3e16187491d8 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -523,11 +523,7 @@ static int ceph_tcp_recvmsg(struct socket *sock, void *buf, size_t len)
static int ceph_tcp_recvpage(struct socket *sock, struct page *page,
int page_offset, size_t length)
{
- struct bio_vec bvec = {
- .bv_page = page,
- .bv_offset = page_offset,
- .bv_len = length
- };
+ struct bio_vec bvec = BIO_VEC_INIT(page, length, page_offset);
struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL };
int r;
--
2.20.1
Powered by blists - more mailing lists