From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by sourceware.org (Postfix) with ESMTPS id 566303858CDB for ; Fri, 1 Dec 2023 10:45:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 566303858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 566303858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701427510; cv=none; b=I+ZytjwQhsyCdMuPspwH6DymmMASGV9hwQEozW3M8zmT4XOXqQRvSNIUNkfWRHG3HCzWkjVJc9ZVEuEUxScDdQPU/FyxILyFV5Tl0UTcIRp6DOOFcUjHSsTWDWr+ayGhtHXyvZv5ddXpJwy87N8BKnfHNuV5cE3+nfR22FVY/wU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701427510; c=relaxed/simple; bh=xCkqPsaT8R/1z48yNw3db93j1t0P+pAjTgK86I3dJ3E=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=jZjn6eMjG75jA2sJHSZvz4ErZRAZ1mHudtfAKiasGck2nWP6J9J2xZw80nLgrqf6oSf+DIduf0aYtwvyIaU+h8FW0YILiIz4FrU5Fh4RwX7h3eXWLUhE5s+NkVRvqt7MnShRjLQTHkD3MS1/7PgOmwb7PJzWuRkFao+lc37ULXQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-54917ef6c05so2390045a12.1 for ; Fri, 01 Dec 2023 02:45:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701427506; x=1702032306; darn=cygwin.com; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=X0WsaXg9xqB3Ss8hhKoCYpqOHyX7IsAurcWxR+TKUPk=; b=akY6RGllGfqo5G9gc+nhsJqd0MKzRmz0MDxv/FI5IjsmeMVxdD6c6gXQaeTGuuh/e7 B+cFRbVom5yI1mn13DKBAMqPyugFcUvydMqt6zb5tq/9e7pH7oRHYPV6MWc0Dl+CQTiA 2vNTZKBe0SRCZzd6eWlt9g5vEX1Wgr9m9qRCkmGRJaVSq2EO338I8Ty114EOOhqIsmgy GRKOMmUW0rUltGYSGO6RwunRq/BzIPf5FEtLDFNeKWeCv8jWuFl4bcZmf3IHKaNikGBr lF8I11reXcbRQUDhqNRZVNhoiWImW/6HKczCQ1JHwjIaGene509IUVopd1RCOKLs2ohf ieRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701427506; x=1702032306; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=X0WsaXg9xqB3Ss8hhKoCYpqOHyX7IsAurcWxR+TKUPk=; b=kAV8E9ZWrZYmuCE1TZ5nPe5agnnvtjs7Cnm9BiBGRUUF3Nb8vvkfT4Ble+QeioGln4 wmakAUzgHNvKLfoYVlKAHTsYFwvXDArpQm6PjSuAC2jUS5AGRVrWjxfXmVP6h8m91kxU yYYCydWFAO1jMZeaS0VPDHDKlL73/Qfz4M/yABQoaatYQtqg6F/45y5SQPL+oFHhCTqI nU8crsXiWvcQMq7ha0K/af49xfNdblHp5R3mbnEsLFZszpsknz5dzTEdfkWn0DLygX2r Aqtk+9my6EXVXHzwek7UfEWbulDnZhFNgNWDROLrOj5OZ41CrcuvkhYCou0cY+ChJKue CshQ== X-Gm-Message-State: AOJu0YyZUzKbrDClAZWfb4Wte4+GLgza7Xj807VUf2lpPsIomyv72/dr PZK80aeSooMCOh7HK7kLXZdyFrYFgSvRRWzDWvFZHqP5BAA= X-Google-Smtp-Source: AGHT+IE9MSRRpFzaUHNjMkajdpqp0PQY/+u7zGusn2Jypic2wOMe+K2OHCLzcIlxU91oAD7/SC6Kdg3AA1vcFo7arBM= X-Received: by 2002:a50:ee14:0:b0:54c:4837:7d32 with SMTP id g20-20020a50ee14000000b0054c48377d32mr442485eds.113.1701427506613; Fri, 01 Dec 2023 02:45:06 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Cedric Blancher Date: Fri, 1 Dec 2023 11:44:30 +0100 Message-ID: Subject: _PC_MIN_HOLE_SIZE pathconf() Re: Cygwin api to punch a hole into a file? To: cygwin@cygwin.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, 28 Nov 2023 at 11:30, Corinna Vinschen via Cygwin wrote: > > On Nov 24 12:01, Corinna Vinschen via Cygwin wrote: > > On Nov 23 23:36, Cedric Blancher via Cygwin wrote: > > > Linux has fallocate(fd, FALLOC_FL_PUNCH_HOLE|FALLOC_FL_KEEP_SIZE, ...) > > > to punch a hole into a file, i.e. deallocate the blocks given and make > > > the file a "sparse file". > > > > We don't support the Linux-specific fallocate(2) call, only ftruncate(2) > > and posix_fallocate(3). Patches, as usual, thoughtfully considered. > > The next test release cygwin-3.5.0-0.485.g65831f88d6c4 introduces > the Linux-specific fallocate(2) call. Naturally we can't support > all flags, but the following flag combinations are allowed: > > - 0 same as posix_fallocate(3) > - FALLOC_FL_KEEP_SIZE > - FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE > - FALLOC_FL_ZERO_RANGE > - FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE > > A few comments: > > - With 0 and FALLOC_FL_KEEP_SIZE, sparse blocks in the given range > are re-allocated as per the POSIX requirements. For that, it uses > the same code as FALLOC_FL_ZERO_RANGE, but only for the holes within > the range. > > - With FALLOC_FL_KEEP_SIZE, over-allocation is done by setting > the allocation size of a file while keeping EOF the same. > However, in contrast to your typical Linux filesystem, over- > allocation on Windows filesystems is only temporary. The > over-allocated blocks are returned to free blocks as soon as > the last HANDLE to the file is closed. > > - With FALLOC_FL_KEEP_SIZE, no over-allocation is performed on sparse > files. The reason is that over-allocation on sparse files has no > effect on Windows. > > - FALLOC_FL_ZERO_RANGE is implemented as writing zeros to the > given range. For parts of the range which are already allocated > data blocks, as much zeros are written as necessary. For holes > in sparse files, only a single zero byte is written to the > hole per 64K chunk, which is the allocation granularity of > sparse files. > > - FALLOC_FL_ZERO_RANGE is NOT atomic. > > Please give it a try. Could you please implement _PC_MIN_HOLE_SIZE in pathconf(), so that people can query the minimum hole size for a (path in a) filesystem? Should return nothing for FAT and NFSv3, should work on NTFS and NFSv4.2 Ced -- Cedric Blancher [https://plus.google.com/u/0/+CedricBlancher/] Institute Pasteur