* btrfs filesystem defragment exits with non-zero return code (20) upon success
@ 2012-06-27 12:05 Lenz Grimmer
2012-06-27 12:15 ` Hugo Mills
0 siblings, 1 reply; 2+ messages in thread
From: Lenz Grimmer @ 2012-06-27 12:05 UTC (permalink / raw)
To: Btrfs mailing list
[-- Attachment #1: Type: text/plain, Size: 1555 bytes --]
Hi,
running "btrfs filesystem defrag" somehow always returns a non-zero exit code,
even when it succeeds:
[lenz@metis btrfs-progs]% sudo ./btrfs filesystem defrag -v /mnt
/mnt
Btrfs v0.19-102-g2482539-dirty
[lenz@metis btrfs-progs]% echo $?
20
[lenz@metis btrfs-progs]% sudo ./btrfs filesystem defrag -v /dev/loop0
/dev/loop0
ERROR: defrag failed on /dev/loop0 - Invalid argument
Btrfs v0.19-102-g2482539-dirty
total 1 failures
[lenz@metis btrfs-progs]% echo $?
1
[lenz@metis btrfs-progs]% sudo ./btrfs filesystem defrag -v /dev/loop0 /dev/loop1
/dev/loop0
ERROR: defrag failed on /dev/loop0 - Invalid argument
/dev/loop1
ERROR: defrag failed on /dev/loop1 - Invalid argument
Btrfs v0.19-102-g2482539-dirty
total 2 failures
[lenz@metis btrfs-progs]% echo $?
1
[lenz@metis btrfs-progs]% sudo ./btrfs filesystem defrag -v /tmp
/tmp
ERROR: defrag failed on /tmp - Inappropriate ioctl for device
Btrfs v0.19-102-g2482539-dirty
total 1 failures
[lenz@metis btrfs-progs]% echo $?
1
I'm no C programmer, but looking at the end of the do_defrag function in
btrfs_cmds.c, I wonder if the last "return errors + 20" is correct? In case
that errors is greater than zero, the function would be left via the exit(1)
anyway, wouldn't it? In that case, wouldn't "return 0" at the end be more
appropriate?
[SNIP]
if (errors) {
fprintf(stderr, "total %d failures\n", errors);
exit(1);
}
free(av);
return errors + 20;
[SNIP]
Thanks!
--
Lenz Grimmer <lenz@grimmer.com> - http://www.lenzg.net/
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: btrfs filesystem defragment exits with non-zero return code (20) upon success
2012-06-27 12:05 btrfs filesystem defragment exits with non-zero return code (20) upon success Lenz Grimmer
@ 2012-06-27 12:15 ` Hugo Mills
0 siblings, 0 replies; 2+ messages in thread
From: Hugo Mills @ 2012-06-27 12:15 UTC (permalink / raw)
To: Lenz Grimmer; +Cc: Btrfs mailing list
[-- Attachment #1: Type: text/plain, Size: 1179 bytes --]
On Wed, Jun 27, 2012 at 02:05:55PM +0200, Lenz Grimmer wrote:
> Hi,
>
> running "btrfs filesystem defrag" somehow always returns a non-zero exit code,
> even when it succeeds:
Yes, this is a known problem, and one that's on my list of things
to deal with. Thanks for the reminder, though.
> I'm no C programmer, but looking at the end of the do_defrag function in
> btrfs_cmds.c, I wonder if the last "return errors + 20" is correct? In case
> that errors is greater than zero, the function would be left via the exit(1)
> anyway, wouldn't it? In that case, wouldn't "return 0" at the end be more
> appropriate?
Yeah, basically, it's doing something silly and unexpected with
return codes.
Hugo.
> [SNIP]
> if (errors) {
> fprintf(stderr, "total %d failures\n", errors);
> exit(1);
> }
>
> free(av);
> return errors + 20;
> [SNIP]
>
> Thanks!
>
--
=== 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
--- Mixing mathematics and alcohol is dangerous. Don't ---
drink and derive.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-06-27 12:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-27 12:05 btrfs filesystem defragment exits with non-zero return code (20) upon success Lenz Grimmer
2012-06-27 12:15 ` Hugo Mills
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.