From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <laurent@vivier.eu>,
Filip Bozuta <Filip.Bozuta@syrmia.com>
Subject: [PULL 13/14] linux-user: Add support for btrfs ioctls used to scrub a filesystem
Date: Thu, 13 Aug 2020 08:49:22 +0200 [thread overview]
Message-ID: <20200813064923.263565-14-laurent@vivier.eu> (raw)
In-Reply-To: <20200813064923.263565-1-laurent@vivier.eu>
From: Filip Bozuta <Filip.Bozuta@syrmia.com>
This patch implements functionality for following ioctls:
BTRFS_IOC_SCRUB - Starting a btrfs filesystem scrub
Start a btrfs filesystem scrub. The third ioctls argument
is a pointer to a following type:
struct btrfs_ioctl_scrub_args {
__u64 devid; /* in */
__u64 start; /* in */
__u64 end; /* in */
__u64 flags; /* in */
struct btrfs_scrub_progress progress; /* out */
/* pad to 1k */
__u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8];
};
Before calling this ioctl, field 'devid' should be filled
with value that represents the device id of the btrfs filesystem
for which the scrub is to be started.
BTRFS_IOC_SCRUB_CANCEL - Canceling scrub of a btrfs filesystem
Cancel a btrfs filesystem scrub if it is running. The third
ioctls argument is ignored.
BTRFS_IOC_SCRUB_PROGRESS - Getting status of a running scrub
Read the status of a running btrfs filesystem scrub. The third
ioctls argument is a pointer to the above mentioned
'struct btrfs_ioctl_scrub_args'. Similarly as with 'BTRFS_IOC_SCRUB',
the 'devid' field should be filled with value that represents the
id of the btrfs device for which the scrub has started. The status
of a running scrub is returned in the field 'progress' which is
of type 'struct btrfs_scrub_progress' and its definition can be
found at:
https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/btrfs.h#L150
Implementation nots:
Ioctls in this patch use type 'struct btrfs_ioctl_scrub_args' as their
third argument. That is the reason why an aproppriate thunk type
definition is added in file 'syscall_types.h'.
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200803094629.21898-9-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/ioctls.h | 11 +++++++++++
linux-user/syscall_defs.h | 3 +++
linux-user/syscall_types.h | 27 +++++++++++++++++++++++++++
3 files changed, 41 insertions(+)
diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 882bfb3e8854..e3bfe7877433 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -215,6 +215,17 @@
#ifdef BTRFS_IOC_SUBVOL_SETFLAGS
IOCTL(BTRFS_IOC_SUBVOL_SETFLAGS, IOC_W, MK_PTR(TYPE_ULONGLONG))
#endif
+#ifdef BTRFS_IOC_SCRUB
+ IOCTL(BTRFS_IOC_SCRUB, IOC_RW,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_scrub_args)))
+#endif
+#ifdef BTRFS_IOC_SCRUB_CANCEL
+ IOCTL(BTRFS_IOC_SCRUB_CANCEL, 0, TYPE_NULL)
+#endif
+#ifdef BTRFS_IOC_SCRUB_PROGRESS
+ IOCTL(BTRFS_IOC_SCRUB_PROGRESS, IOC_RW,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_scrub_args)))
+#endif
#ifdef BTRFS_IOC_DEV_INFO
IOCTL(BTRFS_IOC_DEV_INFO, IOC_RW,
MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_dev_info_args)))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 8ae54f6946ed..d4fe0085bef4 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -987,6 +987,9 @@ struct target_rtc_pll_info {
abi_ullong)
#define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAGIC, 26,\
abi_ullong)
+#define TARGET_BTRFS_IOC_SCRUB TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 27)
+#define TARGET_BTRFS_IOC_SCRUB_CANCEL TARGET_IO(BTRFS_IOCTL_MAGIC, 28)
+#define TARGET_BTRFS_IOC_SCRUB_PROGRESS TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 29)
#define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 30)
#define TARGET_BTRFS_IOC_INO_PATHS TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 35)
#define TARGET_BTRFS_IOC_LOGICAL_INO TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 36)
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index 51743bb75237..8d4b5b3e921a 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -406,6 +406,33 @@ STRUCT(btrfs_ioctl_ino_lookup_user_args,
MK_ARRAY(TYPE_CHAR, BTRFS_VOL_NAME_MAX + 1), /* name */
MK_ARRAY(TYPE_CHAR, BTRFS_INO_LOOKUP_USER_PATH_MAX)) /* path */
+STRUCT(btrfs_scrub_progress,
+ TYPE_ULONGLONG, /* data_extents_scrubbed */
+ TYPE_ULONGLONG, /* tree_extents_scrubbed */
+ TYPE_ULONGLONG, /* data_bytes_scrubbed */
+ TYPE_ULONGLONG, /* tree_bytes_scrubbed */
+ TYPE_ULONGLONG, /* read_errors */
+ TYPE_ULONGLONG, /* csum_errors */
+ TYPE_ULONGLONG, /* verify_errors */
+ TYPE_ULONGLONG, /* no_csum */
+ TYPE_ULONGLONG, /* csum_discards */
+ TYPE_ULONGLONG, /* super_errors */
+ TYPE_ULONGLONG, /* malloc_errors */
+ TYPE_ULONGLONG, /* uncorrectable_errors */
+ TYPE_ULONGLONG, /* corrected_er */
+ TYPE_ULONGLONG, /* last_physical */
+ TYPE_ULONGLONG) /* unverified_errors */
+
+STRUCT(btrfs_ioctl_scrub_args,
+ TYPE_ULONGLONG, /* devid */
+ TYPE_ULONGLONG, /* start */
+ TYPE_ULONGLONG, /* end */
+ TYPE_ULONGLONG, /* flags */
+ MK_STRUCT(STRUCT_btrfs_scrub_progress), /* progress */
+ MK_ARRAY(TYPE_ULONGLONG,
+ (1024 - 32 -
+ sizeof(struct btrfs_scrub_progress)) / 8)) /* unused */
+
STRUCT(btrfs_ioctl_dev_info_args,
TYPE_ULONGLONG, /* devid */
MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* uuid */
--
2.26.2
next prev parent reply other threads:[~2020-08-13 6:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-13 6:49 [PULL 00/14] Linux user for 5.2 patches Laurent Vivier
2020-08-13 6:49 ` [PULL 01/14] linux-user: Fix "print_fdset()" in "strace.c" to not print ", " after last value Laurent Vivier
2020-08-13 6:49 ` [PULL 02/14] linux-user: Validate mmap/mprotect prot value Laurent Vivier
2020-08-13 6:49 ` [PULL 03/14] linux-user: Adjust guest page protection for the host Laurent Vivier
2020-08-13 6:49 ` [PULL 04/14] linux-user: Modify 'target_to_host/host_to_target_itimerspec()' Laurent Vivier
2020-08-13 6:49 ` [PULL 05/14] linux-user: Add support for a group of 2038 safe syscalls Laurent Vivier
2020-08-13 6:49 ` [PULL 06/14] linux-user: Add support for a group of btrfs ioctls used for subvolumes Laurent Vivier
2020-08-13 6:49 ` [PULL 07/14] linux-user: Add support for a group of btrfs ioctls used for snapshots Laurent Vivier
2020-08-13 6:49 ` [PULL 08/14] linux-user: Add support for btrfs ioctls used to manipulate with devices Laurent Vivier
2020-08-13 6:49 ` [PULL 09/14] linux-user: Add support for btrfs ioctls used to get/set features Laurent Vivier
2020-08-13 6:49 ` [PULL 10/14] linux-user: Add support for a group of btrfs inode ioctls Laurent Vivier
2020-08-13 6:49 ` [PULL 11/14] linux-user: Add support for two btrfs ioctls used for subvolume Laurent Vivier
2020-08-13 6:49 ` [PULL 12/14] linux-user: Add support for btrfs ioctls used to manage quota Laurent Vivier
2020-08-13 6:49 ` Laurent Vivier [this message]
2020-08-13 6:49 ` [PULL 14/14] linux-user: Fix 'utimensat()' implementation Laurent Vivier
2020-08-21 16:23 ` [PULL 00/14] Linux user for 5.2 patches Peter Maydell
2020-08-21 18:45 ` Laurent Vivier
2020-08-21 19:12 ` Filip Bozuta
2020-08-21 19:08 ` Laurent Vivier
2020-08-23 8:21 ` Laurent Vivier
2020-08-23 13:28 ` Laurent Vivier
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=20200813064923.263565-14-laurent@vivier.eu \
--to=laurent@vivier.eu \
--cc=Filip.Bozuta@syrmia.com \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).