From patchwork Fri Feb 3 15:06:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13127859 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 83A1EC05027 for ; Fri, 3 Feb 2023 15:08:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1983C6B007D; Fri, 3 Feb 2023 10:08:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 123036B0078; Fri, 3 Feb 2023 10:08:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB5AC6B0095; Fri, 3 Feb 2023 10:08:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D91306B0071 for ; Fri, 3 Feb 2023 10:08:48 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 809BD410BD for ; Fri, 3 Feb 2023 15:08:48 +0000 (UTC) X-FDA: 80426312736.12.75AA121 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf30.hostedemail.com (Postfix) with ESMTP id B6C058001E for ; Fri, 3 Feb 2023 15:08:46 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=BFKATpqt; spf=none (imf30.hostedemail.com: domain of BATV+416129e804eec9e75a33+7103+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+416129e804eec9e75a33+7103+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675436926; a=rsa-sha256; cv=none; b=ZHy+xh8SfhxjgyHX1iaC4NujW60A+iBvdfVUhRXSoAzPLfDnnElHuU5uQQtVmdZ5pSQNW+ vuGUBd2YSPLKE8sq9/xKA9P1FIjoNRd/4vE8HQANcZIp1GGGDq5737N23956uqmgZSb5Vo +Ayu4jOf80MQwqtpLgO+xNPYk0Au8Qk= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=BFKATpqt; spf=none (imf30.hostedemail.com: domain of BATV+416129e804eec9e75a33+7103+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+416129e804eec9e75a33+7103+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675436926; 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=hrqLS9VRJdwWgQKPMrZrcg15ZPJuMvt1hsLhaUGAnIc=; b=aLkdr6VFLmKa7NKtir6PlSaCdhS4fojTNMs6q7Ro6MI07lwLHansIKh+sQKf1KFO0yrb+b jxPNQiX90CdP436SKfpnyUotgP7AUDxP73aUMKNMTERybzbCwymCvxE95cQUQrkdg8cm6D nN4qu+dcSTdgKJNMr+xXR2Hx9KCfKnE= 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=hrqLS9VRJdwWgQKPMrZrcg15ZPJuMvt1hsLhaUGAnIc=; b=BFKATpqtVunXubdNNkJ5PWdGdR w5eGqcr1X3knNS9rr6k9oWENyIENlbi6OonNovYL8ZHpJJjUDwpcHhHTonjJY90oiMj+zCg0GCLCT ZgNdYtwQXm0LQxe0W+f7iZTRogn9U/K+/3e+BH4ejOUB6/fIsWrQ9/00S1gnU4+Kd1mny+mtvIcKf JBQbwIHCn96cgHxD69nkGyasiOfbHuKn0hnE8rzKpZB3qBEEW9iNbSwkEF+umPMiYEN99kqyv25Ra OyRlO6fWHiMfP1LpyRoEaKpRG1PL6hAcJNC4/vgMJdlJJBo2kCaI7cWoF5XwWHzsLSZZ3Jn/itg0Q 3+X6SEYg==; Received: from [2001:4bb8:19a:272a:910:bb67:7287:f956] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNxfT-002bcT-3j; Fri, 03 Feb 2023 15:07:59 +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] libceph: use bvec_set_page to initialize bvecs Date: Fri, 3 Feb 2023 16:06:34 +0100 Message-Id: <20230203150634.3199647-24-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230203150634.3199647-1-hch@lst.de> References: <20230203150634.3199647-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-Queue-Id: B6C058001E X-Rspamd-Server: rspam01 X-Stat-Signature: 3mb7nmeh6998fno554cu63h1s8aspk94 X-HE-Tag: 1675436926-752480 X-HE-Meta: U2FsdGVkX1+3tNbVegRw3TWNsRDL66kixdq3A0c2jVNNBJn6zZtFSymz2rKTJZECEm4CqgsD3vU+HbzRPLNhrwu6PyGappCxlnoQDUloUvJp6870xmvHTRmMpN7U7PQzhmQfos7b9pIe5m1Cz8yTBaXkAVTQfTbGNMC+JsGwNoc+ol5kUogmv2Uv8hREKQO9ipONnZoMdY7jzrAP7vnR4Q1KT0ZAYT62PQrBkGqbDTVxkBJ4w1knKGfYQ5uuT2Y540Fvr6NIEdz/T9EcC+e/INlxTf3K2p34dEZX3DjFtru/eTaYYWX+reMPRAh8FQBpdkgx6jqZeizxBPkUeoS4181Y96EG8LSBnKVccVlzYJsMCfl2D1e/sntdOasTwLOizXSt4OZMqBCaolB1Av1UNWqFGg0ZYOPnYAcVErocy/NEUQfmgFsWkfOS91v9FmL3eaguU0rK97EGPpfiMc74CipKkdk0G5PQAz6/yEPT3OA53adXjJ93mfJwB8ZuI7qJrJaP100M7xOhb3K/s+g4vyF+/NgR352Bc9szsMT9SILy5CMOZa873qKnD6thbkreAyXwnog57T2Yq7rN5+GEWS6YiPrImUgkEO+BhFoBRy+ugKpTdsce+tBwnqHXmc8EkVwJ0NPuztPlt+N76UheKSdsOfMmJmcKarB+Ji9RM522rsSeproGc/fDUYctbjKWVhKV76KgeF70fstFrP1HRgvQMbslOK/Ai2bQo58DkXQQJtjZQ3arsReMjSAfxg2N3M7S5cFozHmmLaakQKg15YYHReucXjJjmSIi8rZCh3V9M/DOw6UfULZOcMUms3kq66x2icZdAiUKEbbV0KEylFwbdFEdCjoSokztDTrHrzj1xddVLGSXIzrXALTCp+s46k4wDAug+c/H6RROueT4NqotKw9fKhlNfNKGLhcxct+h3ddZzGy3KJBdnJbUAU5VHI4LZe3GP9CuBSBSzFd 35co0Jif sOSxcZd62M4nbow0eGAkPCqo2Vu6y+321Ca+uqRyLbN/YuSEJ+elFfcUGt2lU2Hr/ZGO1YzcCovPey37zFLwX95a7be8wKvqEkh9H9HuljOjakHqJ7IeaBsvHpSYS+i9kXWWtlJUhnSYiNzLxcMP049hbsNU8gptEFIsAG0YgVmxXQbkIm9uAQeXIdeWIVZhAd/WVR+p5eH9frdZPUflpA+464hinqPFotOwKJwRQ1FLW3nuNdRRV33NfEMrpKHblyRgEvhlqe0xvYwBT9nD2tUt8gLPIgAncs4ZJ4q/Y8KEss+CJonGAwhKGxoLDJjfyjlLK6XtQ70+wWq8ucMLIeKT3WE0rJ0A7RbPUpWdI1rjXcEyRYLqwk8932WO9uuf1Y0IpAUt3qMdLpgYrccZ1Qx7U35bL1icmnzVk3AEWI41t+3RWdx6kX9NSM77yoaZDZa7MRki7q6NFzFLVDsjDeshouzDk+pzrLzYMHBbLUadRCy65GZdhHHK18cT9gfc/1BKB 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++;