From patchwork Mon Jan 30 09:21:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13120650 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8462FC64EC3 for ; Mon, 30 Jan 2023 09:25:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 19F106B007D; Mon, 30 Jan 2023 04:25:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 128296B0073; Mon, 30 Jan 2023 04:25:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F0A796B007D; Mon, 30 Jan 2023 04:25:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DB83D6B0073 for ; Mon, 30 Jan 2023 04:25:22 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AFA3D1C3B90 for ; Mon, 30 Jan 2023 09:25:22 +0000 (UTC) X-FDA: 80410932084.19.EE182E2 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf23.hostedemail.com (Postfix) with ESMTP id 018FC140015 for ; Mon, 30 Jan 2023 09:25:20 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=ykPzBC64; dmarc=none; spf=none (imf23.hostedemail.com: domain of BATV+3ca177389f0c7d0d5156+7099+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+3ca177389f0c7d0d5156+7099+infradead.org+hch@bombadil.srs.infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675070721; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=H1w/sob2deIb9pxt4pAEZWp01So4kETnigr7yzrrzGg=; b=EvVqG1iA5mBJSkVAS/RvHvnaDgQwqOZWFcU4acSlMeTAUElwdS3I/Xk6Cwg2HO5Lghadv6 2b6qgav/Nsj2HuxkYD3U4Wk2WtMJSlpPZd1T7yJNXoegTH4vqD9s2A8YPr11E1ae8l0gCV 8ErCvjyM+ZOsqGTZOqT/B+1dMuE06Hk= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=ykPzBC64; dmarc=none; spf=none (imf23.hostedemail.com: domain of BATV+3ca177389f0c7d0d5156+7099+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+3ca177389f0c7d0d5156+7099+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675070721; a=rsa-sha256; cv=none; b=XuK74+wE96BTRH9x1+wJgMEBy62Rw/+0g/9tOx74yXl1FXRrCS/tkb1KiU6qAVXIheI1LI DSApZdfiyVDifgbPozeP/ocIAfPoxgbEKUDW1JubURJOWLfDxkCkFzd8kNJZMoPMRD/tAg wDj9iED6AtkdZcuku1cb7f5RlYWEh3g= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=H1w/sob2deIb9pxt4pAEZWp01So4kETnigr7yzrrzGg=; b=ykPzBC64zt0+24f/idcoY5rPHl IsFgekhQQBB15Wh2AupkIyS/+sF/MEgiCkwkAzgtsu3rOUsznVfVUdBr0/uyOlhk5rx+h6DR0d9Oq gLrt+9Bh4LcQxj8juVhz0PYX3bpL3oDqD7A7afZtVPoATxq+y4I8dtDm7Fx4FySiMWhyJMVEXE5S5 IeDwhKFrXApv9OFQJhn1/to8z+gpYIhjxn4yvN9X71cbtbfi5fbILaUAJrrmpPdUhZHmWkHIRSHQb LJjeyTDO81kNei1tQOu95oSLdNf1G2DlmwqbKXJcHxLcuUQRAtvvSjB9dI7ZC0svAqSMARkOGYONl UAzlVl5Q==; Received: from [2001:4bb8:19a:272a:732e:e417:47d7:2f4a] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMQNy-002oTE-C6; Mon, 30 Jan 2023 09:23:34 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Ilya Dryomov , "Michael S. Tsirkin" , Jason Wang , Minchan Kim , Sergey Senozhatsky , Keith Busch , Sagi Grimberg , Chaitanya Kulkarni , "Martin K. Petersen" , David Howells , Marc Dionne , Xiubo Li , Steve French , Trond Myklebust , Anna Schumaker , Mike Marshall , Andrew Morton , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Chuck Lever , linux-block@vger.kernel.org, ceph-devel@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, kvm@vger.kernel.org, netdev@vger.kernel.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, devel@lists.orangefs.org, io-uring@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 23/23] net-ceph: use bvec_set_page to initialize bvecs Date: Mon, 30 Jan 2023 10:21:57 +0100 Message-Id: <20230130092157.1759539-24-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230130092157.1759539-1-hch@lst.de> References: <20230130092157.1759539-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 018FC140015 X-Stat-Signature: 8j7epdmdesace9gfepeyaqw8413ixi3z X-HE-Tag: 1675070720-482903 X-HE-Meta: U2FsdGVkX1+UswI7y997EzIxJtHsghj1ExWQd89aqTadwVwL/+oqWhH5MJJjpOD2WY2f+6h8FHVW2UzpOpmKfKpKy2m5lCjRbeOJACpCpKSxfp4UkGAtc2FJiXm6NWstCptXqMu4jtAJy2wfZZsXN4xfHZVf7CHi0xFsb2Gc+R6VaKwTH/s9hHR16ZlYyUZrZYxVBDF7yKEYzTJIPnLn2kmWsea7n0HVx/RWMhwCvlfvC+cufXJmCKSlLQr5/3XNwvC+9B/hoM9IeDqnzGd9tLkWrxpoPDOlkkvLi0mUS1JkwzKwe3imGWgFz7npZ9SAicW8yTL5IiuYmunYp7OkZFKv05F90hJJCjqhRY5ZIIR5EgfKUi84OHkSn9nlecXJXmi0KhBERfhfQW0aRbLTzYAneLB14d+Vt0cn9mQ13Tdh8ctMyXs/JVsF+RTBJumLKglMcs0uVebr4KZUx3wM3XkDeY8vGPSyB1kw+vKEkUj22IlQcoZknAV+4ZQapRJj6yVsST5+XUR+ptMo091YlXZGB/+dB5RRz2eIdbNh9RGvpQCuXgB6JoxFH+Cx9rxQiID0yJBCheICIa3aZAxnCJCRNt5mKIdaakY+//VmBtgHb4HXAoUy+RQ5ya6HvPlCfYZmCLAemTcJUYqPS0dqSuvdTjvC6MFyko7fWta0evTCIbOFgcAMSO9lHC9hp21khVB3bZ+vsFgffNNkjUna+YXhHkH7mH9+tkYcc/cH+J8GsE/YyLYIEG52uDbJzlHu907Ea/9Fv9BZJTGw+BoNPtJMCQroXYp5q6DH4GBkXvXKvtd04uythXD9KFDRUO27ZOl0r1sIxhpG31YBW+pc34yI9MwqpxcdWlGvbCT4Lg+pISD0GPElb7/pK9WbmZjHEel6mqBX7KSWiW97P7J7S8v7yF3VYhkqRQJvSILzxifaFtX6BFje2c/bhVXJ86HpBgWnhGpOhnyiM+3MbiH XOWhWAXL /h0hqc0MvjtQ8476P7w21YApCsDmYfF/3I9NyEBHa/3v2buYnIUTT2ZTMwB/arRlS887Zhv4H8L5beq2g4tJPZnX9OngbHFft3i8C3YQ/NgbxFdEEi2wif+3dKHbrGZtt4UXzzfC61bHJ5Wz+mRnK7KRMez5pc01z3dUaN8elTgxVuHzD/htSPZmN6paENHFhUCVbHg6MzS3LAa1abIvfdkiaWHJfZ8/ZbBCx+lgzaX67vUeTwncrt7At7Od0Dn+LgYjID1xSwPh7R7mY+bpcdRproOLuzXQlC/8g+dU3EqvHFcEI5VMivXsnCEyhuYLELw92ou4WIEPo4pfPY92+BcHK4IjWLH/me+ULJUdplaGXgX7MUVudPOtrhzvpdx2KWuAwASYJYnyn1eEl7XTe/1Gg4GUdHyWw9HCc1znB8tJX6+ptLLkmJ5mKk2U6Zzd1epWQG2RKlMipPcqHSzWP3axpae2Dn7Rxi1a8 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Use the bvec_set_page helper to initialize bvecs. Signed-off-by: Christoph Hellwig Reviewed-by: Ilya Dryomov --- net/ceph/messenger_v1.c | 7 ++----- net/ceph/messenger_v2.c | 28 +++++++++++----------------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/net/ceph/messenger_v1.c b/net/ceph/messenger_v1.c index d1787d7d33ef9a..d664cb1593a777 100644 --- a/net/ceph/messenger_v1.c +++ b/net/ceph/messenger_v1.c @@ -40,15 +40,12 @@ 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; struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL }; int r; BUG_ON(page_offset + length > PAGE_SIZE); + bvec_set_page(&bvec, page, length, page_offset); iov_iter_bvec(&msg.msg_iter, ITER_DEST, &bvec, 1, length); r = sock_recvmsg(sock, &msg, msg.msg_flags); if (r == -EAGAIN) diff --git a/net/ceph/messenger_v2.c b/net/ceph/messenger_v2.c index 3009028c4fa28f..301a991dc6a68e 100644 --- a/net/ceph/messenger_v2.c +++ b/net/ceph/messenger_v2.c @@ -149,10 +149,10 @@ static int do_try_sendpage(struct socket *sock, struct iov_iter *it) while (iov_iter_count(it)) { /* iov_iter_iovec() for ITER_BVEC */ - bv.bv_page = it->bvec->bv_page; - bv.bv_offset = it->bvec->bv_offset + it->iov_offset; - bv.bv_len = min(iov_iter_count(it), - it->bvec->bv_len - it->iov_offset); + bvec_set_page(&bv, it->bvec->bv_page, + min(iov_iter_count(it), + it->bvec->bv_len - it->iov_offset), + it->bvec->bv_offset + it->iov_offset); /* * sendpage cannot properly handle pages with @@ -286,9 +286,8 @@ static void set_out_bvec_zero(struct ceph_connection *con) WARN_ON(iov_iter_count(&con->v2.out_iter)); WARN_ON(!con->v2.out_zero); - con->v2.out_bvec.bv_page = ceph_zero_page; - con->v2.out_bvec.bv_offset = 0; - con->v2.out_bvec.bv_len = min(con->v2.out_zero, (int)PAGE_SIZE); + bvec_set_page(&con->v2.out_bvec, ceph_zero_page, + min(con->v2.out_zero, (int)PAGE_SIZE), 0); con->v2.out_iter_sendpage = true; iov_iter_bvec(&con->v2.out_iter, ITER_SOURCE, &con->v2.out_bvec, 1, con->v2.out_bvec.bv_len); @@ -863,10 +862,7 @@ static void get_bvec_at(struct ceph_msg_data_cursor *cursor, /* get a piece of data, cursor isn't advanced */ page = ceph_msg_data_next(cursor, &off, &len); - - bv->bv_page = page; - bv->bv_offset = off; - bv->bv_len = len; + bvec_set_page(bv, page, len, off); } static int calc_sg_cnt(void *buf, int buf_len) @@ -1855,9 +1851,8 @@ static void prepare_read_enc_page(struct ceph_connection *con) con->v2.in_enc_resid); WARN_ON(!con->v2.in_enc_resid); - bv.bv_page = con->v2.in_enc_pages[con->v2.in_enc_i]; - bv.bv_offset = 0; - bv.bv_len = min(con->v2.in_enc_resid, (int)PAGE_SIZE); + bvec_set_page(&bv, con->v2.in_enc_pages[con->v2.in_enc_i], + min(con->v2.in_enc_resid, (int)PAGE_SIZE), 0); set_in_bvec(con, &bv); con->v2.in_enc_i++; @@ -2998,9 +2993,8 @@ static void queue_enc_page(struct ceph_connection *con) con->v2.out_enc_resid); WARN_ON(!con->v2.out_enc_resid); - bv.bv_page = con->v2.out_enc_pages[con->v2.out_enc_i]; - bv.bv_offset = 0; - bv.bv_len = min(con->v2.out_enc_resid, (int)PAGE_SIZE); + bvec_set_page(&bv, con->v2.out_enc_pages[con->v2.out_enc_i], + min(con->v2.out_enc_resid, (int)PAGE_SIZE), 0); set_out_bvec(con, &bv, false); con->v2.out_enc_i++;