From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jens Axboe Subject: Re: [PATCH v2] splice: sendfile() at once fails for big files Date: Wed, 06 May 2015 09:07:11 -0600 Message-ID: <554A2E1F.7010102@kernel.dk> References: <20150423150308.8782B1A2439@localhost.localdomain> <20150427070131.GA21190@gondor.apana.org.au> <554A23F4.7010004@kernel.dk> <554A276D.2080209@c-s.fr> <554A27F6.10800@kernel.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Al Viro , Linux Kernel Mailing List , linux-fsdevel , Linux Crypto Mailing List To: leroy christophe , Linus Torvalds , Herbert Xu Return-path: Received: from mail-ig0-f177.google.com ([209.85.213.177]:33214 "EHLO mail-ig0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750816AbbEFPHP (ORCPT ); Wed, 6 May 2015 11:07:15 -0400 Received: by igbpi8 with SMTP id pi8so100122990igb.0 for ; Wed, 06 May 2015 08:07:14 -0700 (PDT) In-Reply-To: <554A27F6.10800@kernel.dk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 05/06/2015 08:40 AM, Jens Axboe wrote: > On 05/06/2015 08:38 AM, leroy christophe wrote: >> >> Le 06/05/2015 16:23, Jens Axboe a =C3=A9crit : >>> On 05/05/2015 09:41 PM, Linus Torvalds wrote: >>>> Jens, ping? >>>> >>>> The test results should make this a no-brainer, but I hate how ran= dom >>>> these flag ops. >>> >>> Missed the original, apparently. I too am confused how this is a >>> correctness fix and not just an optimization. >>> >>> + if (read_len < len) >>> + sd->flags |=3D SPLICE_F_MORE; >>> + else if (!more) >>> + sd->flags &=3D ~SPLICE_F_MORE; >>> >>> Should that check be for 'more', not '!more'? >>> >>> >> @@ -1204,6 +1204,7 @@ ssize_t splice_direct_to_actor(struct file *in= , >> struct splice_desc *sd, >> * Don't block on output, we have to drain the direct pipe. >> */ >> sd->flags &=3D ~SPLICE_F_NONBLOCK; >> + more =3D sd->flags & SPLICE_F_MORE; >> >> while (len) { >> size_t read_len; >> @@ -1216,6 +1217,10 @@ ssize_t splice_direct_to_actor(struct file *i= n, >> struct splice_desc *sd, >> read_len =3D ret; >> sd->total_len =3D read_len; >> >> + if (read_len < len) >> + sd->flags |=3D SPLICE_F_MORE; >> + else if (!more) >> + sd->flags &=3D ~SPLICE_F_MORE; >> >> >> >> 'more' contains whether sendfile() has been called with SPLICE_F_MOR= E or >> not. >> Until all bytes are processed, we have to force SPLICE_F_MORE regard= less >> of how sendfile() was called. >> Once all bytes have been read, we have to reset the flags according = to >> how sendfile() was called, so if 'more' is NOT set, we have to clear >> SPLICE_F_MORE from sd->flags (which was unconditionaly set for >> processing the first bytes) > > Ah gotcha, that looks correct. Patch is fine with me then. Needs a comment added to that effect, imho. --=20 Jens Axboe -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html