Sparsify / hole punching tool
I wrote a little tool you can use to scan a file and punch holes, so make it sparse. Confirmed to work on 3.7.0-rc6 Feel free to use it in any way you like, and of course improve it. http://pastebin.com/8SjEsBLD Remco Hosman-- To unsubscribe from this list: send the line unsubscribe linux-btrfs in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Sparsify / hole punching tool
On Sun, Nov 18, 2012 at 10:04:29PM +0100, Remco Hosman - Yerf IT wrote: I wrote a little tool you can use to scan a file and punch holes, so make it sparse. Confirmed to work on 3.7.0-rc6 Feel free to use it in any way you like, and of course improve it. http://pastebin.com/8SjEsBLD For archival purposes, it's probably better to put the whole thing inline in the text of your mail. This also makes it far easier to make comments on it, should anyone feel moved to do so. Hugo. -- === Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk === PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk --- In theory, theory and practice are the same. In --- practice, they're different. signature.asc Description: Digital signature
Re: Sparsify / hole punching tool
as requested. like this? ---begin #define _GNU_SOURCE /* See feature_test_macros(7) */ #include fcntl.h #include sys/types.h #include sys/stat.h #include errno.h #include stdio.h #include string.h #include linux/falloc.h #include unistd.h #define BLOCKSIZE 4096 int main(int argc, char** argv) { ssize_t rsize; int fh, result; char buff[BLOCKSIZE], ebuff[BLOCKSIZE]; off_t curpos, pstart, psize; int freed; if (argc 2) { printf(%s [file...]\n, argv[0]); return 0; } memset(ebuff, 0, BLOCKSIZE);// prepare a block of 0's for (int i = 1; i argc; i++) { char* file=argv[i]; curpos = 0; pstart = 0; psize = 0; freed = 0; fh = open(file, O_RDWR, O_NOATIME); if (fh == -1) { perror(open()); return -1; } printf(sparseifying %s , file); fflush(stdout); while ((rsize = read(fh, buff, BLOCKSIZE)) 0) { result = memcmp(buff, ebuff,rsize); if (result == 0) { // block is empty if (pstart == 0) { // previous block as not empty? pstart = curpos; psize = rsize; // save for later punching } else { psize += rsize; // previous block was empty too, add size } freed += rsize; } else if (pstart) { // block is not empty and we have a block that we still need to punch result = fallocate(fh, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, pstart, psize); if (result == -1) { perror(fallocate()); return -1; } pstart = 0; psize = 0; } curpos += rsize; } if (pstart) { // still a block to do ? result = fallocate(fh, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, pstart, psize); if (result == -1) { perror(fallocate()); return -1; } } if (rsize == 0) { printf(done. freed %i bytes\n, freed); continue; } if (rsize == -1) { perror(read()); return -1; } } return -1; } ---end Remco Hosman On Nov 18, 2012, at 10:19 PM, Hugo Mills h...@carfax.org.uk wrote: On Sun, Nov 18, 2012 at 10:04:29PM +0100, Remco Hosman - Yerf IT wrote: I wrote a little tool you can use to scan a file and punch holes, so make it sparse. Confirmed to work on 3.7.0-rc6 Feel free to use it in any way you like, and of course improve it. http://pastebin.com/8SjEsBLD For archival purposes, it's probably better to put the whole thing inline in the text of your mail. This also makes it far easier to make comments on it, should anyone feel moved to do so. Hugo. -- === Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk === PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk --- In theory, theory and practice are the same. In --- practice, they're different. -- To unsubscribe from this list: send the line unsubscribe linux-btrfs in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
btrfs crash - Null dereference - 3.7.0-rc5-00068-gc5e35d6
Hi, my system suddenly crashed and gave me this dump: http://imgur.com/oO6S0 I checked and there is not btrfs commit in linus' tree since I compiled this kernel. Gustavo -- To unsubscribe from this list: send the line unsubscribe linux-btrfs in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] Btrfs: fix a deadlock in aborting transaction due to ENOSPC
On Fri, Nov 16, 2012 at 03:19:49PM +0100, David Sterba wrote: On Mon, Nov 05, 2012 at 08:42:08PM +0800, Liu Bo wrote: When committing a transaction, we may bail out of running delayed refs due to ENOSPC, and then abort the current transaction to flip into readonly. But we'll hit a deadlock on ref head's lock since we forget to release its lock and other cleanup stuff. Miao sent a patch for this on Tue, 08 May 2012 http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg16361.html and it does more things than just the unlock, I can't tell which one of the patches is the right one, only letting you know. Thanks for pointing that, David. Yes, that patch will work. Miao, can you send it here again? [PATCH] Btrfs: fix deadlock when the process of delayed refs fails thanks, liubo david -- To unsubscribe from this list: send the line unsubscribe linux-btrfs in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line unsubscribe linux-btrfs in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html