From patchwork Fri Nov 23 12:40:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 10695751 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4AA5D15A7 for ; Fri, 23 Nov 2018 12:40:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B10B2C013 for ; Fri, 23 Nov 2018 12:40:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F7D42C018; Fri, 23 Nov 2018 12:40:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B458F2C080 for ; Fri, 23 Nov 2018 12:40:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2409866AbeKWXYp (ORCPT ); Fri, 23 Nov 2018 18:24:45 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:35159 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405500AbeKWXYp (ORCPT ); Fri, 23 Nov 2018 18:24:45 -0500 Received: by mail-wm1-f68.google.com with SMTP id c126so11836756wmh.0 for ; Fri, 23 Nov 2018 04:40:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=JyWduGT42lpp+GmDS7+UVatnQsk6KZz0kFiRaNmIeBk=; b=n1JQR8GJtphd3Vuxm61BLj0tc444oOg1CsrNXjIEM7DSO5J3lrTFky/2+Kp2MLteEk v1L9Q4FJNA4kvw/ubKfugyZVzVkI3z9hOeVbH4VvkowUHYWBS8HXE7S9eNwa7dToaWBu JpI2M8kQNTDm9gdtC7U2qPTcux77P37uHs+Nw91Qy5qR1Oicaf1TyY37MOV+zsoOofqx wL2OZIZsckl/VnB0HdXcTxsMmOgru6xexhsWlLgzVThMtw469xtDdrHD4xK9C4m8Tzqb yiZ1S4VqhieTvkJGgNb5Ie1zzu2BOwunDab+uzjsqn1lOFPB1G7yh4JPn7h4hQHJNwFe DrjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=JyWduGT42lpp+GmDS7+UVatnQsk6KZz0kFiRaNmIeBk=; b=YAQEQ8berQFE9+DKm4WW+TtTMd4BpSYKDOAyPLFnpbHRzJW7uk3gDwdiDbfa0ZsVJ/ wpOuk9KYfCFL7bPW9xIvR2uahaa6Ufzjron+6k/LBPoAtyrLV49sNUyGXbZgJ3xDePyB xo39zXdA22XMDwrws8+yNpCnu4Dgbj9CvzNb9D3wGZO5RKW7P58qVzsShfMV/BD/S/zG qHkTritpN3GflqDY55/a6zhn5gxcRxB9hFOs6ZN5iH4zbFBE6m0N7Gek0gk8B+UeRkhW esuic+sv1sC1bjLkjsqF9Kf/fRuizpAN6LLGEldntNKWRj+1mChd0aXM2bemkcRvx5EX Lw6A== X-Gm-Message-State: AGRZ1gJOZVIxrA1rRPA3dxD6RJ/0ESVS5JAdKZGfI/XOSw42qY0W7SWP NdanbXsCJ7cdAbCwG1MvdRsEezPD X-Google-Smtp-Source: AJdET5etQKHfxNKuBX0ZMQAbwo+QIId0rxr7VedGWHicKMfvA+QBzTJKvCokIsoXGR8xFlUY6D6bZA== X-Received: by 2002:a1c:2d90:: with SMTP id t138-v6mr3347671wmt.0.1542976840061; Fri, 23 Nov 2018 04:40:40 -0800 (PST) Received: from orange.local (ip-94-112-136-201.net.upcbroadband.cz. [94.112.136.201]) by smtp.gmail.com with ESMTPSA id l3sm31077857wru.36.2018.11.23.04.40.39 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 23 Nov 2018 04:40:39 -0800 (PST) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 2/4] libceph: use sock_no_sendpage() as a fallback in ceph_tcp_sendpage() Date: Fri, 23 Nov 2018 13:40:18 +0100 Message-Id: <20181123124020.4637-3-idryomov@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20181123124020.4637-1-idryomov@gmail.com> References: <20181123124020.4637-1-idryomov@gmail.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP sock_no_sendpage() makes the code cleaner. Also, don't set MSG_EOR. sendpage doesn't act on MSG_EOR on its own, it just honors the setting from the preceding sendmsg call by looking at ->eor in tcp_skb_can_collapse_to(). Signed-off-by: Ilya Dryomov --- net/ceph/messenger.c | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index cca96d32ac64..21a743a3bd29 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -560,24 +560,12 @@ static int ceph_tcp_sendmsg(struct socket *sock, struct kvec *iov, return r; } -static int __ceph_tcp_sendpage(struct socket *sock, struct page *page, - int offset, size_t size, bool more) -{ - int flags = MSG_DONTWAIT | MSG_NOSIGNAL | (more ? MSG_MORE : MSG_EOR); - int ret; - - ret = kernel_sendpage(sock, page, offset, size, flags); - if (ret == -EAGAIN) - ret = 0; - - return ret; -} - static int ceph_tcp_sendpage(struct socket *sock, struct page *page, int offset, size_t size, bool more) { - struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL }; - struct bio_vec bvec; + ssize_t (*sendpage)(struct socket *sock, struct page *page, + int offset, size_t size, int flags); + int flags = MSG_DONTWAIT | MSG_NOSIGNAL | (more ? MSG_MORE : 0); int ret; /* @@ -589,19 +577,11 @@ static int ceph_tcp_sendpage(struct socket *sock, struct page *page, * triggers one of hardened usercopy checks. */ if (page_count(page) >= 1 && !PageSlab(page)) - return __ceph_tcp_sendpage(sock, page, offset, size, more); - - bvec.bv_page = page; - bvec.bv_offset = offset; - bvec.bv_len = size; - - if (more) - msg.msg_flags |= MSG_MORE; + sendpage = sock->ops->sendpage; else - msg.msg_flags |= MSG_EOR; /* superfluous, but what the hell */ + sendpage = sock_no_sendpage; - iov_iter_bvec(&msg.msg_iter, WRITE, &bvec, 1, size); - ret = sock_sendmsg(sock, &msg); + ret = sendpage(sock, page, offset, size, flags); if (ret == -EAGAIN) ret = 0;