From patchwork Thu Dec 18 12:29:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 5513391 Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EED219F434 for ; Thu, 18 Dec 2014 12:29:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EA18C20A14 for ; Thu, 18 Dec 2014 12:29:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2CF27209FD for ; Thu, 18 Dec 2014 12:29:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752093AbaLRM3J (ORCPT ); Thu, 18 Dec 2014 07:29:09 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:10116 "EHLO mailhub1.si.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751944AbaLRM3I (ORCPT ); Thu, 18 Dec 2014 07:29:08 -0500 X-Greylist: delayed 405 seconds by postgrey-1.27 at vger.kernel.org; Thu, 18 Dec 2014 07:29:08 EST Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4F0011C808E; Thu, 18 Dec 2014 13:29:07 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from mailhub1.si.c-s.fr ([192.168.12.234]) by localhost (mailhub1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MuYGKqxjC8f6; Thu, 18 Dec 2014 13:29:07 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 36A711C808D; Thu, 18 Dec 2014 13:29:07 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 20AAAC73C5; Thu, 18 Dec 2014 13:29:07 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 5BJypi7pu4LY; Thu, 18 Dec 2014 13:29:07 +0100 (CET) Received: from PO10863.localdomain (unknown [172.25.231.75]) by messagerie.si.c-s.fr (Postfix) with ESMTP id E9ACAC73C4; Thu, 18 Dec 2014 13:29:06 +0100 (CET) Received: by localhost.localdomain (Postfix, from userid 0) id 6A11F1A5E0F; Thu, 18 Dec 2014 13:29:06 +0100 (CET) From: Christophe Leroy To: Alexander Viro CC: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-crypto@vger.kernel.org Subject: [PATCH resending] splice: sendfile() at once fails for big files Message-Id: <20141218122906.6A11F1A5E0F@localhost.localdomain> Date: Thu, 18 Dec 2014 13:29:06 +0100 (CET) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When big files (over 64kbytes) are sent with sendfile(), they are sent by blocks of 64kbytes. In that case, the target must be informed that the current block is not the last one, otherwise it might take wrong actions. The issue was observed while sending a file to an AF_ALG socket for hashing. The hash was reset at each 64k block. This patch adds SPLICE_F_MORE to the flags when more data is pending. Signed-off-by: Christophe Leroy --- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: b/fs/splice.c =================================================================== --- a/fs/splice.c +++ b/fs/splice.c @@ -1171,7 +1171,7 @@ long ret, bytes; umode_t i_mode; size_t len; - int i, flags; + int i, flags, more; /* * We require the input being a regular file, as we don't want to @@ -1214,6 +1214,7 @@ * Don't block on output, we have to drain the direct pipe. */ sd->flags &= ~SPLICE_F_NONBLOCK; + more = sd->flags & SPLICE_F_MORE; while (len) { size_t read_len; @@ -1226,6 +1227,10 @@ read_len = ret; sd->total_len = read_len; + if (read_len < len) + sd->flags |= SPLICE_F_MORE; + else if (!more) + sd->flags &= ~SPLICE_F_MORE; /* * NOTE: nonblocking mode only applies to the input. We * must not do the output in nonblocking mode as then we