If we call "btrfs quota rescan -w", it will attempt to start the rescan
operation, wait for it, and then print the "quota rescan started" message.
The wait could last an arbitrary amount of time, so printing it after
the wait isn't very helpful.
This patch reworks how we print the rescan started message as well as the
printing of the messages, including adding an error message for status
query failures (which could be EPERM/EFAULT/ENOMEM, not just no rescan
in progress) and wait failures.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Commands that do not take any options do not use getopt, which means the
standard option separator "--" does not work. Update all command
handlers that need it, argv needs to be referenced using the optind that
is correctly pointed after the separator.
Signed-off-by: David Sterba <dsterba@suse.com>
We can use btrfs_open_dir() to check whether target dir is
in btrfs's mount point before open, instead of checking it in
kernel space of ioctl, and return fuzzy error message.
Before patch:
# ./btrfs quota enable /mnt/tmp1
ERROR: quota command failed: Inappropriate ioctl for device
# ./btrfs quota disable /mnt/tmp1
ERROR: quota command failed: Inappropriate ioctl for device
# ./btrfs quota rescan /mnt/tmp1
ERROR: quota rescan failed: Inappropriate ioctl for device
#
After patch:
# ./btrfs quota enable /mnt/tmp1
ERROR: not a btrfs filesystem: /mnt/tmp1
# ./btrfs quota disable /mnt/tmp1
ERROR: not a btrfs filesystem: /mnt/tmp1
# ./btrfs quota rescan /mnt/tmp1
ERROR: not a btrfs filesystem: /mnt/tmp1
#
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
PPC64 arch use such following IOC values "
\#define _IOC_NONE 1U
\#define _IOC_READ 2U
\#define _IOC_WRITE 4U
" comparing to the default IOC values "
\#define _IOC_NONE 0U
\#define _IOC_READ 2U
\#define _IOC_WRITE 1U"
This means the value "_IOW*" will be negative when we store it in the int
variables. Such as the "BTRFS_IOC_QGROUP_CREATE", it will be "0x4010942e" on
X86_64, but "0x8010942e" on PPC64.
Notice that the IOC values are the "unsigned long" type, so we use the
"unsigned long" to store it, and this can insure the comparison between the
variable and BTRFS_IOC_* valid.
Signed-off-by: George Wang <xuw2015@gmail.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
[manpage states that it's int, kernel uses unsigned int, glibc wants
unsigned long int]
Tested-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
These were mostly in option structs but there were a few gross string
pointer arguments given as 0.
Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Mark many functions as static, and remove any resulting dead code.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
With -w one can wait for a rescan operation to finish. It can be used when
starting a rescan operation or later to wait for the currently running
rescan operation to finish. Waiting is interruptible.
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
valgrind complains open_file_or_dir() causes a memory leak.That is because
if we open a directoy by opendir(), and then we should call closedir()
to free memory.
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
This adds the quota rescan command to be used if qgroup tracking should get
out of sync. Can also be used to query the status of a running rescan
operation.
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Extending usage messages with some info on the quota functionality:
- The -i option of "subvol create" and "subvol snapshot" was not
documented
- The -c option of "qgroup limit" is the default option
- The "qouta rescan" command is not yet implemented, while it should be
executed after enabling quota on a non-empty filesystem.
Signed-off-by: Koen De Wit <koen.de.wit@oracle.com>
The definition of the function open_file_or_dir() is moved from common.c
to utils.c in order to be able to share some common code between scrub
and the device stats in the following step. That common code uses
open_file_or_dir(). Since open_file_or_dir() makes use of the function
dirfd(3), the required XOPEN version was raised from 6 to 7.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Original-Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>