Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:74886 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87428 invoked from network); 13 Jun 2014 14:20:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jun 2014 14:20:49 -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.128.169 as permitted sender) X-PHP-List-Original-Sender: julienpauli@gmail.com X-Host-Fingerprint: 209.85.128.169 mail-ve0-f169.google.com Received: from [209.85.128.169] ([209.85.128.169:37481] helo=mail-ve0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BA/51-09966-0C80B935 for ; Fri, 13 Jun 2014 10:20:48 -0400 Received: by mail-ve0-f169.google.com with SMTP id pa12so3495350veb.0 for ; Fri, 13 Jun 2014 07:20:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:content-type; bh=+iwJU8hhV+2x2H2vCJ/nDR1M4jZtREUYpn/Pz2C2yuU=; b=MnuIs/JRjBUzBrjNXyHMockrurFyG7fcUbCNQYwDActOACgKqPY37ZgfC9xKGYQ3T6 OAU92yGC4vUA6bJ4ELoHlyqCcjut8+sp9feHPBnPubpldXh1R6eYnr5Uew0Wz0DQ3nkz XOyDh4FAMxKMN2oyeF/kXUIhAVTOl1+fUoU6NJsC4UAhOYKS5364Dhxa4oVAM7r5ic63 JpdKh982OzSvwFNlvsTn59/MF1enqlRa15ubIx3pn2Fw0zQAy3lcZp7uKx+fnZoQCo6+ RCF4S1WrvvkXYoCaUh/PJPB/fnFIWAG3xO3V/htHiRwO9FhMKi6OpKpfkbIdvLL6/n7M iKlQ== X-Received: by 10.52.114.105 with SMTP id jf9mr76326vdb.79.1402669244618; Fri, 13 Jun 2014 07:20:44 -0700 (PDT) MIME-Version: 1.0 Sender: julienpauli@gmail.com Received: by 10.220.81.68 with HTTP; Fri, 13 Jun 2014 07:20:03 -0700 (PDT) Date: Fri, 13 Jun 2014 16:20:03 +0200 X-Google-Sender-Auth: ghEU8mj1_ssq67RFzuNOJkUYeNo Message-ID: To: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Implemented fallocate() syscall in streams From: jpauli@php.net (Julien Pauli) Hi, 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 - 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 ? Julien Pauli