Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75334 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20647 invoked from network); 8 Jul 2014 09:09:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jul 2014 09:09:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=julienpauli@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=julienpauli@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.169 as permitted sender) X-PHP-List-Original-Sender: julienpauli@gmail.com X-Host-Fingerprint: 209.85.220.169 mail-vc0-f169.google.com Received: from [209.85.220.169] ([209.85.220.169:33840] helo=mail-vc0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E3/50-19184-C45BBB35 for ; Tue, 08 Jul 2014 05:09:32 -0400 Received: by mail-vc0-f169.google.com with SMTP id la4so5148423vcb.14 for ; Tue, 08 Jul 2014 02:09:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=sOHLa6Ji1Y8f1go5Wz+LVTrfv9By8v/PU+BpW1ckKmc=; b=oBleIzEWP8kC0t/PIV27bHFm+9oowHzdpwaD3yu45ooAf3rH5yGBSNNXjVvhM/aB/z 9R05OATVz7rChfKm8XLDyh42aLTSQg18rIWrp8xasiDvF0BXIZx25I/OBJJbY95sS2j0 9Iw3/fSRD6aNEanA5v5EKgQFBjYoUgNo5dAEzfXwCBQV9enSfdKrRwZG7AiHPxE9ydJm wLOj3AFCW6OcwVoQfOICzxbxIrCC7DqyrRYTkUrdmAyzbUlrFJa1/1ejxqiZN3KcRslz dqCeHyWxvKwayr7vcIjsTAAKpqbr2VU17DmntpdStq0UV38ijhd7EdLJqxxngpUVhOAG uByQ== X-Received: by 10.52.253.140 with SMTP id aa12mr5192377vdd.11.1404810569745; Tue, 08 Jul 2014 02:09:29 -0700 (PDT) MIME-Version: 1.0 Sender: julienpauli@gmail.com Received: by 10.220.81.68 with HTTP; Tue, 8 Jul 2014 02:08:49 -0700 (PDT) In-Reply-To: <53BB9F9C.20308@hoa-project.net> References: <53BB9F9C.20308@hoa-project.net> Date: Tue, 8 Jul 2014 11:08:49 +0200 X-Google-Sender-Auth: F-k2_-7ztecR3tA3i0Q31iRMTs4 Message-ID: To: "Ivan Enderlin @ Hoa" Cc: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Implemented fallocate() syscall in streams From: jpauli@php.net (Julien Pauli) On Tue, Jul 8, 2014 at 9:37 AM, Ivan Enderlin @ Hoa wrote: > On 13/06/2014 16:20, Julien Pauli wrote: >> >> Hi, > > Hello :-), > > > >> I just wrote a patch to add fallocate() syscall support for streams. >> It relies on posix_fallocate(), so that it should support many Unixes. >> Linux's got a specification with a fallocate() function, more powerful >> than the posix call. >> >> fallocate() does write blocks to the underlying filesystem (not so >> many are supported, but the ones not supported should proxy to >> ftruncate()) and prevents sparse file creation whereas ftruncate() >> just updates inode information, leading to possible future out of >> space errors. >> >> I got a POC showing the diffs between both calls here : >> https://gist.github.com/jpauli/8afec7c4fc2b38f8ff27 >> >> I propose two APIs for PHP : >> - One that adds a function : fallocate() >> https://github.com/jpauli/php-src/tree/fallocate > > I prefer this one. > > > >> - One that relies on ftruncate() , and adds a $use_fallocate >> flag https://github.com/jpauli/php-src/tree/fallocate_flag >> >> Please, note that the latest proposal requires patches in different >> extensions, as I changed a PHP_API function signature. >> >> I don't know if Windows can support that. Pierre, Anatol ? :-) >> >> Tests are beeing written at the moment. >> >> I didn't implement this is user stream handlers, as this really is a >> low level implementation design that is kind of useless for usage in >> user streams. >> >> Thoughts ? > > If the first one is used, please, consider exposing it on the user-land of > stream wrappers (exemple: `stream_allocate`) if possible. I find it very useless as user stream already have the ftruncate exposed to them. The difference between ftruncate and fallocate is meaningless in userland. Julien.P