From: Lenz Grimmer <lenz@grimmer.com>
To: Btrfs mailing list <linux-btrfs@vger.kernel.org>
Subject: btrfs filesystem defragment exits with non-zero return code (20) upon success
Date: Wed, 27 Jun 2012 14:05:55 +0200 [thread overview]
Message-ID: <4FEAF723.1070601@grimmer.com> (raw)
[-- 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 --]
next reply other threads:[~2012-06-27 12:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-27 12:05 Lenz Grimmer [this message]
2012-06-27 12:15 ` btrfs filesystem defragment exits with non-zero return code (20) upon success Hugo Mills
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=4FEAF723.1070601@grimmer.com \
--to=lenz@grimmer.com \
--cc=linux-btrfs@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox