From: Eric Sandeen <sandeen@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: ext4 development <linux-ext4@vger.kernel.org>, xfs-oss <xfs@oss.sgi.com>
Subject: Re: sparsify - utility to punch out blocks of 0s in a file
Date: Sun, 05 Feb 2012 17:55:41 -0600 [thread overview]
Message-ID: <4F2F16FD.2090400@redhat.com> (raw)
In-Reply-To: <4F2F146B.6050003@msgid.tls.msk.ru>
On 2/5/12 5:44 PM, Michael Tokarev wrote:
> On 05.02.2012 00:10, Eric Sandeen wrote:
> []
>
> Just a very quick look:
>
>> * sparsify - utility to punch out blocks of 0s in a file
>> int main(int argc, char **argv)
>> {
> []
>> if (optind == argc) {
>> printf("Error: no filename specified\n");
>> usage();
>> }
>>
>> fname = argv[optind++];
>
> There's no handling of the case when there are more than one file
> specified on the command line.
ok
>
>> /*
>> * Normalize to blocksize-aligned range:
>> * round start down, round end up - get all blocks including the range specified
>> */
>>
>> punch_range_start = round_down(punch_range_start, blocksize);
>> punch_range_end = round_up(punch_range_end, blocksize);
>> min_hole = round_up(min_hole, blocksize);
>> if (!min_hole)
>> min_hole = blocksize;
>
> I think this deserves some bold warning if punch_range_start
> or punch_hole_end is not a multiple of blocksize.
well, we can only punch on block boundaries. But I suppose I should swap
round_up and round_down, so that we never punch anything that isn't *inside*
the specified range.
> []
>> /*
>> * Read through the file, finding block-aligned regions of 0s.
>> * If the region is at least min_hole, punch it out.
>> * This should be starting at a block-aligned offset
>> */
>>
>> while ((ret = read(fd, readbuf, min_hole)) > 0) {
>>
>> if (!memcmp(readbuf, zerobuf, min_hole)) {
>
> Now this is interesting. Can ret be < min_hole? Can a read
> in a middle of a file be shorter than specified?
yes, and yes (but unlikely i think)...
> How it will work together with some other operation being done
> at the same file -- ftruncate anyone?
I probably have some boundary condition & error checking to do yet :)
Thanks for the review,
-Eric
> Thanks!
>
> /mjt
WARNING: multiple messages have this Message-ID (diff)
From: Eric Sandeen <sandeen@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: ext4 development <linux-ext4@vger.kernel.org>, xfs-oss <xfs@oss.sgi.com>
Subject: Re: sparsify - utility to punch out blocks of 0s in a file
Date: Sun, 05 Feb 2012 17:55:41 -0600 [thread overview]
Message-ID: <4F2F16FD.2090400@redhat.com> (raw)
In-Reply-To: <4F2F146B.6050003@msgid.tls.msk.ru>
On 2/5/12 5:44 PM, Michael Tokarev wrote:
> On 05.02.2012 00:10, Eric Sandeen wrote:
> []
>
> Just a very quick look:
>
>> * sparsify - utility to punch out blocks of 0s in a file
>> int main(int argc, char **argv)
>> {
> []
>> if (optind == argc) {
>> printf("Error: no filename specified\n");
>> usage();
>> }
>>
>> fname = argv[optind++];
>
> There's no handling of the case when there are more than one file
> specified on the command line.
ok
>
>> /*
>> * Normalize to blocksize-aligned range:
>> * round start down, round end up - get all blocks including the range specified
>> */
>>
>> punch_range_start = round_down(punch_range_start, blocksize);
>> punch_range_end = round_up(punch_range_end, blocksize);
>> min_hole = round_up(min_hole, blocksize);
>> if (!min_hole)
>> min_hole = blocksize;
>
> I think this deserves some bold warning if punch_range_start
> or punch_hole_end is not a multiple of blocksize.
well, we can only punch on block boundaries. But I suppose I should swap
round_up and round_down, so that we never punch anything that isn't *inside*
the specified range.
> []
>> /*
>> * Read through the file, finding block-aligned regions of 0s.
>> * If the region is at least min_hole, punch it out.
>> * This should be starting at a block-aligned offset
>> */
>>
>> while ((ret = read(fd, readbuf, min_hole)) > 0) {
>>
>> if (!memcmp(readbuf, zerobuf, min_hole)) {
>
> Now this is interesting. Can ret be < min_hole? Can a read
> in a middle of a file be shorter than specified?
yes, and yes (but unlikely i think)...
> How it will work together with some other operation being done
> at the same file -- ftruncate anyone?
I probably have some boundary condition & error checking to do yet :)
Thanks for the review,
-Eric
> Thanks!
>
> /mjt
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2012-02-05 23:55 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-04 20:04 sparsify - utility to punch out blocks of 0s in a file Eric Sandeen
2012-02-04 20:04 ` Eric Sandeen
2012-02-04 20:10 ` Eric Sandeen
2012-02-04 20:10 ` Eric Sandeen
2012-02-04 20:17 ` Eric Sandeen
2012-02-04 20:17 ` Eric Sandeen
2012-02-05 15:05 ` Raghavendra D Prabhu
2012-02-05 15:05 ` Raghavendra D Prabhu
2012-02-05 23:44 ` Michael Tokarev
2012-02-05 23:44 ` Michael Tokarev
2012-02-05 23:55 ` Eric Sandeen [this message]
2012-02-05 23:55 ` Eric Sandeen
2012-02-05 9:33 ` Ron Yorston
2012-02-05 9:33 ` Ron Yorston
2012-02-05 16:36 ` Eric Sandeen
2012-02-05 16:36 ` Eric Sandeen
2012-02-05 16:55 ` Andreas Dilger
2012-02-05 16:55 ` Andreas Dilger
2012-02-05 17:23 ` Matthias Schniedermeyer
2012-02-05 17:23 ` Eric Sandeen
2012-02-05 17:23 ` Eric Sandeen
2012-02-05 19:24 ` Andreas Dilger
2012-02-05 19:24 ` Andreas Dilger
2012-02-05 17:19 ` Ron Yorston
2012-02-05 17:19 ` Ron Yorston
2012-02-05 17:21 ` Eric Sandeen
2012-02-05 17:21 ` Eric Sandeen
2012-02-06 18:40 ` Sunil Mushran
2012-02-06 18:40 ` [Ocfs2-devel] " Sunil Mushran
2012-02-06 18:40 ` Sunil Mushran
2012-02-06 21:41 ` Ted Ts'o
2012-02-06 21:41 ` Ted Ts'o
2012-02-06 21:47 ` Eric Sandeen
2012-02-06 21:47 ` Eric Sandeen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F2F16FD.2090400@redhat.com \
--to=sandeen@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=mjt@tls.msk.ru \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.