From patchwork Thu Feb 4 06:25:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 12066351 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58346C433E6 for ; Thu, 4 Feb 2021 06:26:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2B1064DE9 for ; Thu, 4 Feb 2021 06:26:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232109AbhBDG0K (ORCPT ); Thu, 4 Feb 2021 01:26:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231878AbhBDG0J (ORCPT ); Thu, 4 Feb 2021 01:26:09 -0500 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C3E1C061573; Wed, 3 Feb 2021 22:25:29 -0800 (PST) Received: by mail-lj1-x22b.google.com with SMTP id a25so2099349ljn.0; Wed, 03 Feb 2021 22:25:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=8BCgyPWgryxP/tPOgkCVquqADpYLO+SLhESdmPZvlaU=; b=ljb68kfuT/kr/btK4c2jNN/ZQGrslJp9V1MUyd6iUGTD97wQsU+E9fdpmi98w7moN8 mGrJGrqE7KgG2wPeC5//KGSatul99XyOCi8H4bOBMTKBRQVsTz87bjQa4/k2E4C98OKm 1my04kQjPKHHCl5+Ui7z317CnWI6yPD3yb2rzKkobHj3LvtHtQtsuzUmWAPDTY4R2/9j EnKCAJenT51+X9aUO2HzDBg4vGvY3NuXmTLydvPrh9WxHbC/AVaBCLpv2+321w4nJeAm gRyWH6KfdAykkrdiB3qnuW0SXdd8v2Y+8x+fjLqX7VATNeFeyI2kEiH/EvCNkW75SNtj p2eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=8BCgyPWgryxP/tPOgkCVquqADpYLO+SLhESdmPZvlaU=; b=F5ebyqEozYDUoBBnxKJXkR2F2jcQh1jCRQA9YUc039o5LCHXmqFhwFaqEuLTzAohg3 xqvTYTzucbCn2bhN//45+y0G0NUTPbPw68TBcNu3bhDkw+eaTq2Iu5TuDwDwDLO1xNIk PruHbHQHxIMSjVoj5es66DEY0/F+7pRbgIGApNtLAp88XyYh+GqQjVrwwmjyAucDav24 tc45QWFBhHxaYQQTLSq3A2afTqyMR4x1j8yf2s3F4YvpTOiiaqfxH10t95ntBSrWv5LY 4fFFNKe3fzE6GecmJXJ+js7+XWIaLfEiRAiWPDfhP+3LTGxlnM0tSS3pIfy6WGYqICLl unGw== X-Gm-Message-State: AOAM533uZxSx9EBDkL+CX+63ZQiH6zvqsi2TkHLxs7HEFwqY6SUdV0aX U2OYyewmDlybD5v3x78QNu3/3XUKbMJtIHLyYKNpAJf5JEmItw== X-Google-Smtp-Source: ABdhPJyzO2OIf3a6lVmDASi9DdnGK5WUD7GDjWFDEFM7ERU54E02H5CQ0z6lhLr00EdoyjOLxsQOFEy85PpHqTN8dzM= X-Received: by 2002:a2e:9d8e:: with SMTP id c14mr4005423ljj.477.1612419927349; Wed, 03 Feb 2021 22:25:27 -0800 (PST) MIME-Version: 1.0 From: Steve French Date: Thu, 4 Feb 2021 00:25:16 -0600 Message-ID: Subject: [PATCH] cifs: use discard iterator to discard unneeded network data more efficiently To: CIFS Cc: linux-fsdevel , David Howells Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org (cleanup patch, to make netfs merge easier) The iterator, ITER_DISCARD, that can only be used in READ mode and just discards any data copied to it, was added to allow a network filesystem to discard any unwanted data sent by a server. Convert cifs_discard_from_socket() to use this. Signed-off-by: David Howells Signed-off-by: Steve French Signed-off-by: David Howells Signed-off-by: Steve French --- fs/cifs/cifsproto.h | 2 ++ fs/cifs/cifssmb.c | 6 +++--- fs/cifs/connect.c | 10 ++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) unsigned int page_offset, unsigned int to_read) From c3a4621f56db8038b19844fa9d5f3951afaac4fd Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 4 Feb 2021 00:15:21 -0600 Subject: [PATCH] cifs: use discard iterator to discard unneeded network data more efficiently The iterator, ITER_DISCARD, that can only be used in READ mode and just discards any data copied to it, was added to allow a network filesystem to discard any unwanted data sent by a server. Convert cifs_discard_from_socket() to use this. Signed-off-by: David Howells Signed-off-by: Steve French --- fs/cifs/cifsproto.h | 2 ++ fs/cifs/cifssmb.c | 6 +++--- fs/cifs/connect.c | 10 ++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 32f7a013402e..75ce6f742b8d 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -232,6 +232,8 @@ extern unsigned int setup_special_user_owner_ACE(struct cifs_ace *pace); extern void dequeue_mid(struct mid_q_entry *mid, bool malformed); extern int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf, unsigned int to_read); +extern ssize_t cifs_discard_from_socket(struct TCP_Server_Info *server, + size_t to_read); extern int cifs_read_page_from_socket(struct TCP_Server_Info *server, struct page *page, unsigned int page_offset, diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 0496934feecb..c279527aae92 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1451,9 +1451,9 @@ cifs_discard_remaining_data(struct TCP_Server_Info *server) while (remaining > 0) { int length; - length = cifs_read_from_socket(server, server->bigbuf, - min_t(unsigned int, remaining, - CIFSMaxBufSize + MAX_HEADER_SIZE(server))); + length = cifs_discard_from_socket(server, + min_t(size_t, remaining, + CIFSMaxBufSize + MAX_HEADER_SIZE(server))); if (length < 0) return length; server->total_read += length; diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 10fe6d6d2dee..943f4eba027d 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -564,6 +564,16 @@ cifs_read_from_socket(struct TCP_Server_Info *server, char *buf, return cifs_readv_from_socket(server, &smb_msg); } +ssize_t +cifs_discard_from_socket(struct TCP_Server_Info *server, size_t to_read) +{ + struct msghdr smb_msg; + + iov_iter_discard(&smb_msg.msg_iter, READ, to_read); + + return cifs_readv_from_socket(server, &smb_msg); +} + int cifs_read_page_from_socket(struct TCP_Server_Info *server, struct page *page, unsigned int page_offset, unsigned int to_read) -- 2.27.0