From owner-svn-src-head@FreeBSD.ORG Tue Jul 22 17:42:45 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D47123F2 for ; Tue, 22 Jul 2014 17:42:45 +0000 (UTC) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com [209.85.215.49]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 58AE020A3 for ; Tue, 22 Jul 2014 17:42:45 +0000 (UTC) Received: by mail-la0-f49.google.com with SMTP id hz20so6233562lab.8 for ; Tue, 22 Jul 2014 10:42:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=sEP8FK3/IytSD/lw18c36wnTbBARHlGVahTWGsazclI=; b=IznFfGMrB7w4Pq/V9OO9VTiAVFzONSjM1k8vDU59QXvf+/exWE6QfrTV03l+mCfkdv DdS1v2Z2iX0pKbO3Q3muWF58JBpFBOMNUGwRFSHwEFf1fPpggIRm9P2vDI/OIN3ydQvR YcBWKKD39xOuLJT1gtViSaQoaw5YIGwolctXg0b85hbXzGJHxrZGdXBIijPYMTNt7NWH w1eImUIBUaFD79n85TfWTDWr7UtLsKbp0PzXS+WEHvm/ISlBfIGUz/U5erda++wS2nos +PBw1DfSnnejikSDEoYrQUU63wfUDHoltEEZg5Jmr3rPn3RZG+ta19ilNFkLXqNXzFWw eXIw== X-Gm-Message-State: ALoCoQnr0NRw4SGKaMtlh5ajUZcadpuJJx+2AfGW1w1iXOoqR0UpLutuR6EdOxLm82DXg/jXjV7/ X-Received: by 10.112.202.39 with SMTP id kf7mr34982350lbc.37.1406050962880; Tue, 22 Jul 2014 10:42:42 -0700 (PDT) Received: from [192.168.1.2] ([89.169.173.68]) by mx.google.com with ESMTPSA id uo5sm1488403lbb.6.2014.07.22.10.42.42 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Jul 2014 10:42:42 -0700 (PDT) Message-ID: <53CEA28A.3040106@freebsd.org> Date: Tue, 22 Jul 2014 21:42:34 +0400 From: Andrey Chernov User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: "Pedro F. Giffuni" , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r268984 - head/lib/libc/stdio References: <201407221619.s6MGJ10G068003@svn.freebsd.org> <53CE94F6.3090003@freebsd.org> <53CE9A77.4060000@freebsd.org> In-Reply-To: <53CE9A77.4060000@freebsd.org> Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jul 2014 17:42:46 -0000 On 22.07.2014 21:08, Andrey Chernov wrote: > On 22.07.2014 20:44, Andrey Chernov wrote: >> Producing physical writes on ftell cause great performance degradation. >> You should check for __SAPP flag before calling sflush to do this only >> for append-mode files. > > BTW, I believe that sflush() should be completely eliminated even for > _SAPP case. Something like that instead: Proper patch to the old version: --- ftell.c.bak 2014-07-22 21:25:46.000000000 +0400 +++ ftell.c 2014-07-22 21:28:01.000000000 +0400 @@ -118,6 +118,11 @@ if (HASUB(fp)) pos -= fp->_r; /* Can be negative at this point. */ } else if ((fp->_flags & __SWR) && fp->_p != NULL) { + if (fp->_flags & __SAPP) { + pos = _sseek(fp, (fpos_t)0, SEEK_END); + if (pos == -1) + return (1); + } /* * Writing. Any buffered characters cause the * position to be greater than that in the Forget the code below, it breaks reading: > if (fp->_flags & __SAPP) { > pos = _sseek(fp, (fpos_t)0, SEEK_END); > if (pos == -1) > return (1); > } else if (fp->_flags & __SOFF) > pos = fp->_offset; > else { > pos = _sseek(fp, (fpos_t)0, SEEK_CUR); > if (pos == -1) > return (1); > } > >> >> On 22.07.2014 20:19, Pedro F. Giffuni wrote: >>> Author: pfg >>> Date: Tue Jul 22 16:19:01 2014 >>> New Revision: 268984 >>> URL: http://svnweb.freebsd.org/changeset/base/268984 >>> >>> Log: >>> ftello: return 1 when seeking offset on an append stream. >>> >>> Obtained from: Apple Inc. (Libc 997.90.3) >>> Phabric: D442 >>> MFC after: 2 weeks >>> >>> Modified: >>> head/lib/libc/stdio/ftell.c >>> >>> Modified: head/lib/libc/stdio/ftell.c >>> ============================================================================== >>> --- head/lib/libc/stdio/ftell.c Tue Jul 22 16:10:56 2014 (r268983) >>> +++ head/lib/libc/stdio/ftell.c Tue Jul 22 16:19:01 2014 (r268984) >>> @@ -97,6 +97,8 @@ _ftello(FILE *fp, fpos_t *offset) >>> * Find offset of underlying I/O object, then >>> * adjust for buffered bytes. >>> */ >>> + if (__sflush(fp)) /* may adjust seek offset on append stream */ >>> + return (1); >>> if (fp->_flags & __SOFF) >>> pos = fp->_offset; >>> else { >>> >> >> > > -- http://ache.vniz.net/