From nobody Fri May 17 22:00:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1598872100; cv=none; d=zohomail.com; s=zohoarc; b=NX0PFuoZ1K2ZzFsuxei6dXZI5D1fXF6iZYwLtLT6kvZQ23ALFtOdbO8nzBNfGnhvNhEvFQwBiQE/IwXCl5rpJWpGnvforQYbyesqUN75EenF9H/2U3QjxWB6mzgSiIgzGLNIGDsEXmuyH6lfcw83c0L8LvRUc24oX708i/i0qK0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598872100; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ukhpVBMCry3gFn8Sl+U6WSKKl9MYB4/IooFqj6EcRkM=; b=kjjBmCFv1mQjsKQIsRjifSfxBcnb1msy5h6JjWFVuqAOWRrg0BktzfxtAbObLlcDFnH/nL7uLMvqi+MSk5gEJH5r+pyQW/jrB6x7OCzHL6nIbzmOw6N09IqQ+yal6N/sandWfmAWne6kyfclTxU3+X81wGSHqAeixsGTNDra5o0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598872100705873.5683556390851; Mon, 31 Aug 2020 04:08:20 -0700 (PDT) Received: from localhost ([::1]:40894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kChff-0000Eg-9Y for importer@patchew.org; Mon, 31 Aug 2020 07:08:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCher-00070O-Bn for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:29 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:50495) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kChep-0000Qs-3O for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:28 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mna0x-1ktm6G3P5Z-00jczK; Mon, 31 Aug 2020 13:07:22 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 1/8] linux-user: Add support for a group of btrfs ioctls used for subvolumes Date: Mon, 31 Aug 2020 13:07:09 +0200 Message-Id: <20200831110716.536808-2-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200831110716.536808-1-laurent@vivier.eu> References: <20200831110716.536808-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:mDIX00i5rwNVd18k6fob77XJ0HwvkSafRmtQb1M9HWRLZ3xRHM2 eEYWG+r8bL+dPWHwTXX1d+tA9n2JKZtfP0xGNNpjphyBBgpPjKUV0/k1hESxpLgt1wNwmpo Ectb3F0azKxVhiwZpouYDgoJ1vz7qujeMBMNikItzkcta9gbL1pLu7ydaAEPAZgUHq+TUop cG2i+ossi2tDdEq7A4IVw== X-UI-Out-Filterresults: notjunk:1;V03:K0:NC5yaROxCxo=:irvFPG5r6XdTH+xxCp234a B6aiQmiVAbY3xeEnPn5Ve4YZmRrynslBY7J6MQSjrnuLH1VXLMHBQqHvOGz0ZVXicjnwzGQxa nelJd7oxo8K0wGPzmdaBwu+B1FAwQaygwNQe/zS4LePER4CSi0GM+bHMm0kSvwfSRxzsO2aYg 4F4go/jIhU3rw+JjwB87DwJbeVJDMif52k6ksnE4AEHCZKZbgVMybbZ/Jrdj9sTBXE7UVRcGR VF8559M4k0AB7UNqjaK1yfmc30/mq1PrECA6Ijt5pfz4VixP/lj3GDdziuAF932uiAJUlRSAq 1qEVyoQkC8b9SQMVouy2fQQ81IjkoOgmTfydUEmzLU/qhs+32X+sqsRl8XZJrbuyO6gvdqZD+ C1Kis+N/Raz/6N5aPgGzDrC5K8yGa9Ke8FLyLn9iK36u0C/RhG7q7TcvQMVQjP9uXJgA891H5 Wd+rEL43Jf2SO+imcdZ2JnVOpkIpgnp4mpMMC80vSGHA6maMzZodMLUEFrw72qtYWQVt21pZp fBaXHFOFuZOoQSbPltu1IvmxITJvBvJT4byd52aX7EPiF5TlG7HI+tR3WrwimL8VgYg/I1u4+ CqKDbS/nd1xqFV5TIiqu3xhKUeL8qwfRabGvhsrI1eLq2b4Iy3UIoRRjrMFuxUzeHI7o4dabD +cAtILoFfIKMY+pZitNZLEv1Qn0DjwdUY/Sp5vQWlJ52lHmDBHRnGxUr0I86Gb/HPhNvYXog0 dmDOqHfQAlPu33MHoYvfxynfiJz8Z4SxQ9PdFstCg2GwnSZ9CJg7uSeGjYE6zz1hOYZZIjH7h lDiDcLikgFGiAV/qKfxySUoKiHYGJ4/BiDtfUKGa9JAERyE/FZAe1Ad/Yf1GXylanoD1lcG Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.10; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 07:07:21 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionality of following ioctls: BTRFS_IOC_SUBVOL_CREATE - Creating a btrfs subvolume Create a btrfs subvolume. The subvolume is created using the ioctl's third argument which represents a pointer to a following structure type: struct btrfs_ioctl_vol_args { __s64 fd; char name[BTRFS_PATH_NAME_MAX + 1]; }; Before calling this ioctl, the fields of this structure should be filled with aproppriate values. The fd field represents the file descriptor value of the subvolume and the name field represents the subvolume path. BTRFS_IOC_SUBVOL_GETFLAGS - Getting subvolume flags Read the flags of the btrfs subvolume. The flags are read using the ioctl's third argument that is a pointer of __u64 (unsigned long). The third argument represents a bit mask that can be composed of follow= ing values: BTRFS_SUBVOL_RDONLY (1ULL << 1) BTRFS_SUBVOL_QGROUP_INHERIT (1ULL << 2) BTRFS_DEVICE_SPEC_BY_ID (1ULL << 3) BTRFS_SUBVOL_SPEC_BY_ID (1ULL << 4) BTRFS_IOC_SUBVOL_SETFLAGS - Setting subvolume flags Set the flags of the btrfs subvolume. The flags are set using the ioctl's third argument that is a pointer of __u64 (unsigned long). The third argument represents a bit mask that can be composed of same values as in the case of previous ioctl (BTRFS_IOC_SUBVOL_GETFLAGS). BTRFS_IOC_SUBVOL_GETINFO - Getting subvolume information Read information about the subvolume. The subvolume information is returned in the ioctl's third argument which represents a pointer to a following structure type: struct btrfs_ioctl_get_subvol_info_args { /* Id of this subvolume */ __u64 treeid; /* Name of this subvolume, used to get the real name at mount point */ char name[BTRFS_VOL_NAME_MAX + 1]; /* * Id of the subvolume which contains this subvolume. * Zero for top-level subvolume or a deleted subvolume. */ __u64 parent_id; /* * Inode number of the directory which contains this subvolume. * Zero for top-level subvolume or a deleted subvolume */ __u64 dirid; /* Latest transaction id of this subvolume */ __u64 generation; /* Flags of this subvolume */ __u64 flags; /* UUID of this subvolume */ __u8 uuid[BTRFS_UUID_SIZE]; /* * UUID of the subvolume of which this subvolume is a snapshot. * All zero for a non-snapshot subvolume. */ __u8 parent_uuid[BTRFS_UUID_SIZE]; /* * UUID of the subvolume from which this subvolume was received. * All zero for non-received subvolume. */ __u8 received_uuid[BTRFS_UUID_SIZE]; /* Transaction id indicating when change/create/send/receive happened */ __u64 ctransid; __u64 otransid; __u64 stransid; __u64 rtransid; /* Time corresponding to c/o/s/rtransid */ struct btrfs_ioctl_timespec ctime; struct btrfs_ioctl_timespec otime; struct btrfs_ioctl_timespec stime; struct btrfs_ioctl_timespec rtime; /* Must be zero */ __u64 reserved[8]; }; All of the fields of this structure are filled after the ioctl call. Implementation notes: Ioctls BTRFS_IOC_SUBVOL_CREATE and BTRFS_IOC_SUBVOL_GETINFO have struct= ure types as third arguments. That is the reason why a corresponding defini= tion are added in file 'linux-user/syscall_types.h'. The line '#include ' is added in file 'linux-user/syscal= l.c' to recognise preprocessor definitions for these ioctls. Since the file "li= nux/btrfs.h" was added in the kernel version 3.9, it is enwrapped in an #ifdef state= ment with parameter CONFIG_BTRFS which is defined in 'configure' if the header file is present. Signed-off-by: Filip Bozuta Tested-by: Daniel P. Berrang=C3=A9 Message-Id: <20200823195014.116226-2-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- configure | 9 +++++++++ linux-user/ioctls.h | 15 +++++++++++++++ linux-user/syscall.c | 3 +++ linux-user/syscall_defs.h | 8 ++++++++ linux-user/syscall_types.h | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 67 insertions(+) diff --git a/configure b/configure index 6ecaff429b1b..24a6146b14c7 100755 --- a/configure +++ b/configure @@ -4939,6 +4939,12 @@ if check_include sys/kcov.h ; then kcov=3Dyes fi =20 +# check for btrfs filesystem support (kernel must be 3.9+) +btrfs=3Dno +if check_include linux/btrfs.h ; then + btrfs=3Dyes +fi + # If we're making warnings fatal, apply this to Sphinx runs as well sphinx_werror=3D"" if test "$werror" =3D "yes"; then @@ -6918,6 +6924,9 @@ fi if test "$kcov" =3D "yes" ; then echo "CONFIG_KCOV=3Dy" >> $config_host_mak fi +if test "$btrfs" =3D "yes" ; then + echo "CONFIG_BTRFS=3Dy" >> $config_host_mak +fi if test "$inotify" =3D "yes" ; then echo "CONFIG_INOTIFY=3Dy" >> $config_host_mak fi diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index e2fc09b5a5ee..bf89b96d27b0 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -174,6 +174,21 @@ IOCTL(FS_IOC32_GETVERSION, IOC_R, MK_PTR(TYPE_INT)) IOCTL(FS_IOC32_SETVERSION, IOC_W, MK_PTR(TYPE_INT)) =20 +#ifdef BTRFS_IOC_SUBVOL_CREATE + IOCTL(BTRFS_IOC_SUBVOL_CREATE, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif +#ifdef BTRFS_IOC_SUBVOL_GETFLAGS + IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG)) +#endif +#ifdef BTRFS_IOC_SUBVOL_SETFLAGS + IOCTL(BTRFS_IOC_SUBVOL_SETFLAGS, IOC_W, MK_PTR(TYPE_ULONGLONG)) +#endif +#ifdef BTRFS_IOC_GET_SUBVOL_INFO + IOCTL(BTRFS_IOC_GET_SUBVOL_INFO, IOC_R, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args))) +#endif + #ifdef CONFIG_USBFS /* USB ioctls */ IOCTL(USBDEVFS_CONTROL, IOC_RW, diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d14d849a720c..93da3b972852 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -112,6 +112,9 @@ #include #include #include +#ifdef CONFIG_BTRFS +#include +#endif #ifdef HAVE_DRM_H #include #include diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 9d07991176b8..cae79f8492e1 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1005,6 +1005,14 @@ struct target_rtc_pll_info { #define TARGET_FS_IOC32_GETVERSION TARGET_IOR('v', 1, int) #define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int) =20 +/* btrfs ioctls */ +#define TARGET_BTRFS_IOC_SUBVOL_CREATE TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 14) +#define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAG= IC, 25,\ + abi_ullong) +#define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAG= IC, 26,\ + abi_ullong) +#define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IORU(BTRFS_IOCTL_MA= GIC, 60) + /* usb ioctls */ #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0) #define TARGET_USBDEVFS_BULK TARGET_IOWRU('U', 2) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 12bf3484e2bd..0ce58d77727c 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -358,6 +358,38 @@ STRUCT(blkpg_partition, MK_ARRAY(TYPE_CHAR, BLKPG_DEVNAMELTH), /* devname */ MK_ARRAY(TYPE_CHAR, BLKPG_VOLNAMELTH)) /* volname */ =20 +#ifdef BTRFS_IOC_SUBVOL_CREATE +STRUCT(btrfs_ioctl_vol_args, + TYPE_LONGLONG, /* fd */ + MK_ARRAY(TYPE_CHAR, BTRFS_PATH_NAME_MAX + 1)) /* name */ +#endif + +#ifdef BTRFS_IOC_GET_SUBVOL_INFO +STRUCT(btrfs_ioctl_timespec, + TYPE_ULONGLONG, /* sec */ + TYPE_INT) /* nsec */ + +STRUCT(btrfs_ioctl_get_subvol_info_args, + TYPE_ULONGLONG, /* treeid */ + MK_ARRAY(TYPE_CHAR, BTRFS_VOL_NAME_MAX + 1), + TYPE_ULONGLONG, /* parentid */ + TYPE_ULONGLONG, /* dirid */ + TYPE_ULONGLONG, /* generation */ + TYPE_ULONGLONG, /* flags */ + MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* uuid */ + MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* parent_uuid */ + MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* received_uuid */ + TYPE_ULONGLONG, /* ctransid */ + TYPE_ULONGLONG, /* otransid */ + TYPE_ULONGLONG, /* stransid */ + TYPE_ULONGLONG, /* rtransid */ + MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* ctime */ + MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* otime */ + MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* stime */ + MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* rtime */ + MK_ARRAY(TYPE_ULONGLONG, 8)) /* reserved */ +#endif + STRUCT(rtc_time, TYPE_INT, /* tm_sec */ TYPE_INT, /* tm_min */ --=20 2.26.2 From nobody Fri May 17 22:00:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1598872240; cv=none; d=zohomail.com; s=zohoarc; b=jv80eb4OnypilVIRCsRmfE8N58CWWeshqzgX9vF1ASd0XhT56t2g4/6eUXUEKKB4s1zmL0DGN+gF9yufO6A3f3theWlJz/z11W65Fvn/0fCzZFUy8s1WpM2KQ5HIk2d8d3G7Ega0YKii/NTyYUd/E9KQAqulAdqQOGXvF/dYU6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598872240; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2MRDbi4CMg/ROLB8DNgr67A8YOUZ3gLM0h08ZcZ1zTk=; b=OEs8Nbd+qA9pQQ1Hbce9f3eXPpnJnl+iH4b1MrY/HqsGA4brTUdz1XNAy0DaR/SusYsWOPz+STGhNhbspeUPVPhrXcMyBKS3uCpShDtTHoCR6Vgl/LAJOK+JCWVDQiIsiCLHIJUxwnTpy0vv9GWA9g+imWPU8r5fJ9D3Y6ndMs8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598872240154510.06604993971666; Mon, 31 Aug 2020 04:10:40 -0700 (PDT) Received: from localhost ([::1]:52380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kChhu-0004up-Fp for importer@patchew.org; Mon, 31 Aug 2020 07:10:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kChes-00072a-Bt for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:30 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:47647) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kChep-0000Qy-D2 for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:30 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MD9Gh-1kLoKJ1c2L-009BmA; Mon, 31 Aug 2020 13:07:22 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 2/8] linux-user: Add support for a group of btrfs ioctls used for snapshots Date: Mon, 31 Aug 2020 13:07:10 +0200 Message-Id: <20200831110716.536808-3-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200831110716.536808-1-laurent@vivier.eu> References: <20200831110716.536808-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:EzA98sguEbHWsaMgKalaPTLyEYD/KlsQ4v+9uyJDCi+wZ1+V2Ih iUCcgkBxqend/NaEu0CJ2K8OEbJXqbEnkTce+/alSJh5cIAfI2fa7rYeQxoiPUDmBnp2bcg 2AZP1SVTbhIoSrT7tA2i5RPPV9G9k0vwJeKxCoG1h8/6iHA19+d1wNx3uV+7lP8wDzuS2Kn CZ0lS0PaCeHgmZVS533Jw== X-UI-Out-Filterresults: notjunk:1;V03:K0:wyznPZP/ip4=:HPgBjFCkUwa3b3eVEEtpBx hZoDst76CmkRSp3uYMIIiZCZh50HH/YqObRCt/RXTa7RVZY2uhVBvkpR1Bkz3mjb1EytS1XLc YyELD3Uu2EJc/42HNrKSEsk20Fnr5FZTiJR6GbTaspxnykEjKMJXRPDrnYkgm1eYUntlsYiAX xBjO5hfpKl9HhbMQ4rn1vCpzS2SDKheHo5sn+X/uPHlEds+VypnCrEc+7CaDtgeCY/G9qph3a 3iqF6KNpvmu31N4Pi1LulQ3m97pCldWJ3IYYFctAi/DoOj2fl4XioDj5m5p7T5fkm2OrCWI38 VGdimf23pLb5GWkGpdAvuKxJ/8juE6DM0H/wqt6Vu6fduq/Ql27GfXX9CMaMz2aVwGlKZ5exB 2RLi47gqU4ZwnDo1W0MWSjJuYImGFh1Qv0Z8wMZOUeXX927ttXvGZpL3XZIGHo8rCwBQ77TPm vkDacS2AXHu6xHo0Y6o85CwlwHHpVZkZm4fWpPSWzqaFMlzKxR3OjcyE29TGIG0i25f1o/cTu A7sGL5xAc6i0+rRfa31sUCRAmqmAZxu2TgBWrZXM2kuaivR04OdFavCW9rVevYxXv07/TnWNl w2ZctmPnyvYHusgfwgTmMO2/nyWRUuoYY9AXLMVxh/ZbgXi6fY63cuubjTBHTRtmjxNzqVfSp Ww+JjKWnx2L3yvaZrv0k3uS6T+AVE7QL9EQQtLwm6tkBy8+kZ2LCP83ecVKXjWn0sK8MNmV6U 5mw4I0aw7Anlngw/iqPw951cPKzQMUK6zPnuwobzpKkNTYdW49ijK6PEUjNSsfn0hkkZHH4wG yvL5mUDE5AbzCaRPpNpvqFM/wUfE8J5bbqKC6sw3wQiSaT2vyMtjvxOcYuaK9Sh8k0yUppx Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.13; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 07:07:26 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionality for following ioctls: BTRFS_IOC_SNAP_CREATE - Creating a subvolume snapshot Create a snapshot of a btrfs subvolume. The snapshot is created using t= he ioctl's third argument that is a pointer to a 'struct btrfs_ioctl_vol_a= rgs' (which was mentioned in the previous patch). Before calling this ioctl, the fields of the structure should be filled with aproppriate values for the file descriptor and path of the subvolume for which the snapshot is= to be created. BTRFS_IOC_SNAP_DESTROY - Removing a subvolume snapshot Delete a snapshot of a btrfs subvolume. The snapshot is deleted using t= he ioctl's third argument that is a pointer to a 'struct btrfs_ioctl_vol_a= rgs' (which was mentioned in the previous patch). Before calling this ioctl, the fields of the structure should be filled with aproppriate values for the file descriptor and path of the subvolume for which the snapshot is= to be deleted. Implementation notes: Since the thunk type 'struct btrfs_ioctl_vol_args' is defined in the previous patch, the implementation for these ioctls was straightforward. Signed-off-by: Filip Bozuta Tested-by: Daniel P. Berrang=C3=A9 Message-Id: <20200823195014.116226-3-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 8 ++++++++ linux-user/syscall_defs.h | 2 ++ linux-user/syscall_types.h | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index bf89b96d27b0..bddeaca9e7ec 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -174,10 +174,18 @@ IOCTL(FS_IOC32_GETVERSION, IOC_R, MK_PTR(TYPE_INT)) IOCTL(FS_IOC32_SETVERSION, IOC_W, MK_PTR(TYPE_INT)) =20 +#ifdef BTRFS_IOC_SNAP_CREATE + IOCTL(BTRFS_IOC_SNAP_CREATE, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif #ifdef BTRFS_IOC_SUBVOL_CREATE IOCTL(BTRFS_IOC_SUBVOL_CREATE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) #endif +#ifdef BTRFS_IOC_SNAP_DESTROY + IOCTL(BTRFS_IOC_SNAP_DESTROY, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif #ifdef BTRFS_IOC_SUBVOL_GETFLAGS IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG)) #endif diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index cae79f8492e1..1519de7a5565 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1006,7 +1006,9 @@ struct target_rtc_pll_info { #define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int) =20 /* btrfs ioctls */ +#define TARGET_BTRFS_IOC_SNAP_CREATE TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 1) #define TARGET_BTRFS_IOC_SUBVOL_CREATE TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 14) +#define TARGET_BTRFS_IOC_SNAP_DESTROY TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 15) #define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAG= IC, 25,\ abi_ullong) #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAG= IC, 26,\ diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 0ce58d77727c..853b91d21275 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -358,7 +358,8 @@ STRUCT(blkpg_partition, MK_ARRAY(TYPE_CHAR, BLKPG_DEVNAMELTH), /* devname */ MK_ARRAY(TYPE_CHAR, BLKPG_VOLNAMELTH)) /* volname */ =20 -#ifdef BTRFS_IOC_SUBVOL_CREATE +#if defined(BTRFS_IOC_SUBVOL_CREATE) || defined(BTRFS_IOC_SNAP_CREATE) || \ + defined(BTRFS_IOC_SNAP_DESTROY) STRUCT(btrfs_ioctl_vol_args, TYPE_LONGLONG, /* fd */ MK_ARRAY(TYPE_CHAR, BTRFS_PATH_NAME_MAX + 1)) /* name */ --=20 2.26.2 From nobody Fri May 17 22:00:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1598872239; cv=none; d=zohomail.com; s=zohoarc; b=eaEp/D6ruAob0b5oeHhHFFPANXlJ9gcSG8tJqvwKoYt3EDAblzULmmRI2bYHUFd4R3mkQ1vnpax513ZkbIufuDUajpk6l0aom6oxmwZ6pzA5kPmHx2cmHCKj2y4DaQD143Cu2Y9/tjgl05zkzI7DyGsjx8E10IklxRa9lYPlHaE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598872239; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TCdARDsC7ikNojS33SDLz63mdPiEPl6NPGw3i22USlQ=; b=Vmc/hqySEGzgrOeepC4VEousEGVN/OcOr/61fkgb3GlEraLzov0Dvd6Vu43pWKc4uicZJ01YJ8Lhmg720BiDmeb2OrJxrObmxwkxcwyGn6mrtM56EaZXpaPg1yaEZVTyztWhv6RPppCuwt+6xjglvDFDFk/D3VRm8+XGE8Id2Xg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598872239844671.1810427887594; Mon, 31 Aug 2020 04:10:39 -0700 (PDT) Received: from localhost ([::1]:52332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kChhu-0004tI-4l for importer@patchew.org; Mon, 31 Aug 2020 07:10:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48222) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kChes-00073z-Tl for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:30 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:40581) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCheq-0000RK-Cn for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:30 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mqagw-1kyyle3g0W-00mfGR; Mon, 31 Aug 2020 13:07:23 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 3/8] linux-user: Add support for btrfs ioctls used to manipulate with devices Date: Mon, 31 Aug 2020 13:07:11 +0200 Message-Id: <20200831110716.536808-4-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200831110716.536808-1-laurent@vivier.eu> References: <20200831110716.536808-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:AoqtXYm4gOfLHQyFh3Z8V16sNyjb+Gu/lDH0zikFg0tOlRhl3tB 0B7y0yDa1OYu+i86bhDl0WgFe6ew8E3yRVmRTaTf/YCkCNNGEYpj0ZMYWCZLrYzy2rQ1GVM p0yXYX6v8zNZr6mfVAVIcU96WNbZPQppSQcUFnDRB1hF0JHzm8j+arMoIqFuozXgQony9Hv YAF7PTnQrA+DlYkFG/eMw== X-UI-Out-Filterresults: notjunk:1;V03:K0:AjuoLNEocDk=:7rdUShY4x/ln6Y4JOid2ux sQC+5GJN/IdjZuJRn0w9Y6rmapi3rk5RWQq+BKOARrkTuSnsOTyNVnZKQwb4OFqLrynqIYIIi C2LVPeF1dJzL7iBQkWqlCrXc4jVpq3KX/BcbBW4Kl7aP/98suHSP6GOmz9ygypKHq9EpSvl0B 5+LB7MvjLfifHUFjYONzMuKG66PdFOd4QPsgYslPE5KCOaz6HXASzqATXnxklXKebaSkKb/2u x/S/J5quW+e8UxadUbgL52GuhMaKWPwmbd0ACFHsHQ8LqNWMP2rp56GEHt0l9opnhCIhEXJgZ c2qE+wxavU24FdgoCqSpX6VkERT0UGL/M/gawJRz3pqZP1WLA/pi0A36QhQHZ5aoOGdVOA5Kn Wr0MKVoxwsxIXtgayLfIJ+iNZyGG1QoNuzbU4HcZpH7udZv0b+1IpleBNoA5AKvgm7SV0koRj 7TBZZUEyAhw7Jjo1EqXLWwY5BhztFiaF+/VFASjr+rQmtCZfVihNuxKd7UNCdvsCpUl3w5Yqh repn8QDESUJHHLH7cQEfcB68+d0DUTpI5bLfBAGOnbFT54Du6Bwl/3MPdqR7SqHSRi6yzpUW7 XV7LFdEoveY4lzCOhctwsDcB1l/ymTvSVmjnn8w+PKY/Z0KbL6ykhUIiYLdzivcKI/gdfFrwD ppW2iT70NWUVPBhpLuHK/I6wUqA9hK58jlJK1ro4jzj/eCt93q6si+O6T/t0I20iAuuziKr4S 2Ugpu4+B1qhvy1g+mI7KhKlZQ8QH6IFZ28CCwTVHFbZ10OcOxLoDMb1+EYMJsMBvFAf+CCWou Da3SYnz/T/AnEhpP7GmFPaJc11iBtwIv5x3xaZdiajZmrgRmTdpLPdFN5Osr4QKCX9r0gMN Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.74; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 07:07:27 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionality for following ioctls: BTRFS_IOC_SCAN_DEV - Scanning device for a btrfs filesystem Scan a device for a btrfs filesystem. The device that is to be scanned is passed in the ioctl's third argument which represents a pointer to a 'struct ioc_vol_args' (which was mentioned in a previous patch). Before calling this ioctl, the name field of this structure should be filled with the aproppriate name value which represents a path for the device. If the device contains a btrfs filesystem, the ioctl returns 0, otherwise a negative value is returned. BTRFS_IOC_ADD_DEV - Adding a device to a btrfs filesystem Add a device to a btrfs filesystem. The device that is to be added is passed in the ioctl's third argument which represents a pointer to a 'struct ioc_vol_args' (which was mentioned in a previous patch). Before calling this ioctl, the name field of this structure should be filled with the aproppriate name value which represents a path for the device. BTRFS_IOC_RM_DEV - Removing a device from a btrfs filesystem Remove a device from a btrfs filesystem. The device that is to be removed is passed in the ioctl's third argument which represents a pointer to a 'struct ioc_vol_args' (which was mentioned in a previous patch). Before calling this ioctl, the name field of this structure should be filled with the aproppriate name value which represents a path for the device. BTRFS_IOC_DEV_INFO - Getting information about a device Obtain information for device in a btrfs filesystem. The information is gathered in the ioctl's third argument which represents a pointer to a following structure type: struct btrfs_ioctl_dev_info_args { __u64 devid; /* in/out */ __u8 uuid[BTRFS_UUID_SIZE]; /* in/out */ __u64 bytes_used; /* out */ __u64 total_bytes; /* out */ __u64 unused[379]; /* pad to 4k */ __u8 path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */ }; Before calling this ioctl, field "devid" should be set with the id value for the device for which the information is to be obtained. If this fie= ld is not aproppriately set, the errno ENODEV ("No such device") is return= ed. BTRFS_IOC_GET_DEV_STATS - Getting device statistics Obtain stats informatin for device in a btrfs filesystem. The informati= on is gathered in the ioctl's third argument which represents a pointer to a following structure type: struct btrfs_ioctl_get_dev_stats { __u64 devid; /* in */ __u64 nr_items; /* in/out */ __u64 flags; /* in/out */ /* out values: */ __u64 values[BTRFS_DEV_STAT_VALUES_MAX]; /* * This pads the struct to 1032 bytes. It was originally meant to pad to * 1024 bytes, but when adding the flags field, the padding calculation * was not adjusted. */ __u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX]; }; Before calling this ioctl, field "devid" should be set with the id value for the device for which the information is to be obtained. If this fie= ld is not aproppriately set, the errno ENODEV ("No such device") is return= ed. BTRFS_IOC_FORGET_DEV - Remove unmounted devices Search and remove all stale devices (devices which are not mounted). The third ioctl argument is a pointer to a 'struct btrfs_ioctl_vol_args= '. The ioctl call will release all unmounted devices which match the path which is specified in the "name" field of the structure. If an empty path ("") is specified, all unmounted devices will be released. Implementation notes: Ioctls BTRFS_IOC_DEV_INFO and BTRFS_IOC_GET_DEV_STATS use types 'struct btrfs_ioctl_dev_info_args' and ' struct btrfs_ioctl_get_dev_sta= ts' as third argument types. That is the reason why corresponding structure definitions were added in file 'linux-user/syscall_types.h'. Since the thunk type for 'struct ioc_vol_args' was already added in a previous patch, the rest of the implementation was straightforward. Signed-off-by: Filip Bozuta Tested-by: Daniel P. Berrang=C3=A9 Message-Id: <20200823195014.116226-4-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 24 ++++++++++++++++++++++++ linux-user/syscall_defs.h | 6 ++++++ linux-user/syscall_types.h | 24 +++++++++++++++++++++++- 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index bddeaca9e7ec..74d73994f691 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -178,6 +178,22 @@ IOCTL(BTRFS_IOC_SNAP_CREATE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) #endif +#ifdef BTRFS_IOC_SCAN_DEV + IOCTL(BTRFS_IOC_SCAN_DEV, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif +#ifdef BTRFS_IOC_FORGET_DEV + IOCTL(BTRFS_IOC_FORGET_DEV, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif +#ifdef BTRFS_IOC_ADD_DEV + IOCTL(BTRFS_IOC_ADD_DEV, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif +#ifdef BTRFS_IOC_RM_DEV + IOCTL(BTRFS_IOC_RM_DEV, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) +#endif #ifdef BTRFS_IOC_SUBVOL_CREATE IOCTL(BTRFS_IOC_SUBVOL_CREATE, IOC_W, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) @@ -192,6 +208,14 @@ #ifdef BTRFS_IOC_SUBVOL_SETFLAGS IOCTL(BTRFS_IOC_SUBVOL_SETFLAGS, IOC_W, MK_PTR(TYPE_ULONGLONG)) #endif +#ifdef BTRFS_IOC_DEV_INFO + IOCTL(BTRFS_IOC_DEV_INFO, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_dev_info_args))) +#endif +#ifdef BTRFS_IOC_GET_DEV_STATS + IOCTL(BTRFS_IOC_GET_DEV_STATS, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_dev_stats))) +#endif #ifdef BTRFS_IOC_GET_SUBVOL_INFO IOCTL(BTRFS_IOC_GET_SUBVOL_INFO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args))) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 1519de7a5565..d11279b78bbe 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1007,12 +1007,18 @@ struct target_rtc_pll_info { =20 /* btrfs ioctls */ #define TARGET_BTRFS_IOC_SNAP_CREATE TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 1) +#define TARGET_BTRFS_IOC_SCAN_DEV TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 4) +#define TARGET_BTRFS_IOC_FORGET_DEV TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 5) +#define TARGET_BTRFS_IOC_ADD_DEV TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 10) +#define TARGET_BTRFS_IOC_RM_DEV TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 11) #define TARGET_BTRFS_IOC_SUBVOL_CREATE TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 14) #define TARGET_BTRFS_IOC_SNAP_DESTROY TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 15) #define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAG= IC, 25,\ abi_ullong) #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAG= IC, 26,\ abi_ullong) +#define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 30) +#define TARGET_BTRFS_IOC_GET_DEV_STATS TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 52) #define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IORU(BTRFS_IOCTL_MA= GIC, 60) =20 /* usb ioctls */ diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 853b91d21275..7e52b7aec5d9 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -359,7 +359,9 @@ STRUCT(blkpg_partition, MK_ARRAY(TYPE_CHAR, BLKPG_VOLNAMELTH)) /* volname */ =20 #if defined(BTRFS_IOC_SUBVOL_CREATE) || defined(BTRFS_IOC_SNAP_CREATE) || \ - defined(BTRFS_IOC_SNAP_DESTROY) + defined(BTRFS_IOC_SNAP_DESTROY) || defined(BTRFS_IOC_SCAN_DEV) || \ + defined(BTRFS_IOC_FORGET_DEV) || defined(BTRFS_IOC_ADD_DEV) || \ + defined(BTRFS_IOC_RM_DEV) || defined(BTRFS_IOC_DEV_INFO) STRUCT(btrfs_ioctl_vol_args, TYPE_LONGLONG, /* fd */ MK_ARRAY(TYPE_CHAR, BTRFS_PATH_NAME_MAX + 1)) /* name */ @@ -391,6 +393,26 @@ STRUCT(btrfs_ioctl_get_subvol_info_args, MK_ARRAY(TYPE_ULONGLONG, 8)) /* reserved */ #endif =20 +#ifdef BTRFS_IOC_DEV_INFO +STRUCT(btrfs_ioctl_dev_info_args, + TYPE_ULONGLONG, /* devid */ + MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* uuid */ + TYPE_ULONGLONG, /* bytes_used */ + TYPE_ULONGLONG, /* total_bytes */ + MK_ARRAY(TYPE_ULONGLONG, 379), /* unused */ + MK_ARRAY(TYPE_CHAR, BTRFS_DEVICE_PATH_NAME_MAX)) /* path */ +#endif + +#ifdef BTRFS_IOC_GET_DEV_STATS +STRUCT(btrfs_ioctl_get_dev_stats, + TYPE_ULONGLONG, /* devid */ + TYPE_ULONGLONG, /* nr_items */ + TYPE_ULONGLONG, /* flags */ + MK_ARRAY(TYPE_ULONGLONG, BTRFS_DEV_STAT_VALUES_MAX), /* values */ + MK_ARRAY(TYPE_ULONGLONG, + 128 - 2 - BTRFS_DEV_STAT_VALUES_MAX)) /* unused */ +#endif + STRUCT(rtc_time, TYPE_INT, /* tm_sec */ TYPE_INT, /* tm_min */ --=20 2.26.2 From nobody Fri May 17 22:00:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1598872196; cv=none; d=zohomail.com; s=zohoarc; b=EawmgZV1yzIAPs0kMqZz9PJ68ooXH9Aqwv4ibqIoSr+rXycaEFB72/g9OmP1hym5bOB8FaRh6tskaQlvmEBVTB8T4ihv6dG2GX2OqZqn7B9UVbQoHEKD98/SMSgeZTsNWjzkJfxxkqJ3q3dTcQwdxrcvwOwnVT7j2LVSxIT+mGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598872196; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IkNIcixhqnZ5c7SiC5ENMi/KO3b8JahuHHNkcz+vqMg=; b=XVmujRkotGTzd5GqQgeszmKBFl/ncew+0qQ1gzM4xs6sVT0ovyZEtIIAydB1uxcKIZ8s8GYpk6xLc1rGC4irH7CnllO3yl1m7y8dkt/8TbP7ISqYYuRpBE/ihBBg58qd1EAGDwUipQzeGZhUbaTu9NS8jYw1a2RrsePeshq2g74= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598872196583166.3241047814272; Mon, 31 Aug 2020 04:09:56 -0700 (PDT) Received: from localhost ([::1]:49172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kChhC-0003bz-A8 for importer@patchew.org; Mon, 31 Aug 2020 07:09:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCheu-00077B-44 for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:32 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:60799) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCheq-0000RQ-P1 for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:31 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N6t3Z-1kepiW1t4p-018JXs; Mon, 31 Aug 2020 13:07:23 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 4/8] linux-user: Add support for btrfs ioctls used to get/set features Date: Mon, 31 Aug 2020 13:07:12 +0200 Message-Id: <20200831110716.536808-5-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200831110716.536808-1-laurent@vivier.eu> References: <20200831110716.536808-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:j7ljY1ww8JtvgeUo2cgQ8ZbxgFvaHXLSn/jZDDAC4x4mVl6qKvd r56KwoOnLAcQkE1El/MgVpqneMS4/G4nteP5EszreOlTT1IJwUXAY30rwlUz2z4JV+5aD0L hJrjqpwOSdxdn5f1ITySPlNq5BqR+lkyeXOt7IB9+K9tL8NFrIwpXUk2KZYNy6ef4g7DhRY q5cWd4jbYUA48bUO+A2zQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:2WQC4smgRqA=:4dMe/2waTPp/dgZZUUlVon opmtgt06MAfHNydlUmf4l1eE1fdwrfWodVxD5ZXu7hzc70gL/ABH3PbFO7hx+GWL/pgxrcPMS L09y/3K6Ik25dMf03C0R+z98EbKfTnUyOfn6If1n66VW+26xhiS27fdHMaRKV0qYSRWaa+kcg glYS0lN6X9nFcXFh1neFoHEwD8obDfeO7B/BvQF8Mf1Bpmlh6ap5CE82ENOgLJxh+eLGsEwjm 3IsRdXjDWCjxhhNbpwdcNj1vrV/q6DIhPjcZINpQMxj5Ocqx/mCNI3yu7SXGskOdA84W5yt8N J6O9zMgt7fm2vHk7j5JIVegArGE/i7VFJhH/9+7Eu1BsiCWRLm4AtyNAAnQ+zL99dakfWJ2ta W5ITEkMxBN5lU3b8geSIdA9KecuMZ35cipJgZsvTgZwnQaijV3RiEQ3IycNc+Y7V2/6g7je3k GpcPaxLWUCBrqxZnfyANw0EAJyNvf0nGJjIXQnyhsW4hpPxZ2mIcx4H2eGkT9+tLZIb0/Hzrj 8P4I+qqhJiWOG7MchAD4F3fKCrEQXjNWXd2IT+5fK8cfzEAnMtK7ggDaQiatGjaB79236CsQk qgjgPM8UFgOachEzuHEu38xgoE6ko5cOKunD1zJ8JAdXWqmgYYghW4cRHmkZ0NhdkkwtcrcyX MGS/B9qwK7QKhjoiS4Ne38oxjNJJgWV04Nvn4V76UJXUWpy/D/UVc6V/ajxEIb6sI1Z8cge2C HzlBjDNr8kqcOi6v11n3CbJdI3+ePpPP0DreH3y/1WFx2meVyVaufuKWvRU1Etd/WYSsufNT7 KkdX9wUwD6yGduxKcrraKrYsVId6wxc9mELtNDFJzsjKgQN6ssZVdFdq8kHVMXMl199cQxh Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 07:07:27 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionality for following ioctls: BTRFS_IOC_GET_FEATURES - Getting feature flags Read feature flags for a btrfs filesystem. The feature flags are returned inside the ioctl's third argument which represents a pointer to a following structure type: struct btrfs_ioctl_feature_flags { __u64 compat_flags; __u64 compat_ro_flags; __u64 incompat_flags; }; All of the structure field represent bit masks that can be composed of values which can be found on: https://elixir.bootlin.com/linux/latest/source/fs/btrfs/ctree.h#L282 BTRFS_IOC_SET_FEATURES - Setting feature flags Set and clear feature flags for a btrfs filesystem. The feature flags are set using the ioctl's third argument which represents a 'struct btrfs_ioctl_feature_flags[2]' array. The first element of the array represent flags which are to be cleared and the second element of the array represent flags which are to be set. The second element has t= he priority over the first, which means that if there are matching flags in the elements, they will be set in the filesystem. If the flag values in the third argument aren't correctly set to be composed of the availa= ble predefined flag values, errno ENOPERM ("Operation not permitted") is re= turned. BTRFS_IOC_GET_SUPPORTED_FEATURES - Getting supported feature flags Read supported feature flags for a btrfs filesystem. The supported feature flags are read using the ioctl's third argument which represents a 'struct btrfs_ioctl_feature_flags[3]' array. The first element of this array represents all of the supported flags in the btrfs filesystem. The second element represents flags that can be safely set and third el= ement represent flags that can be safely clearead. Implementation notes: All of the implemented ioctls use 'struct btrfs_ioctl_feature_flags' as third argument. That is the reason why a corresponding defintion was ad= ded in file 'linux-user/syscall_types.h'. Signed-off-by: Filip Bozuta Tested-by: Daniel P. Berrang=C3=A9 Message-Id: <20200823195014.116226-5-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 12 ++++++++++++ linux-user/syscall_defs.h | 3 +++ linux-user/syscall_types.h | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 74d73994f691..11d7361848dd 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -216,6 +216,18 @@ IOCTL(BTRFS_IOC_GET_DEV_STATS, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_dev_stats))) #endif +#ifdef BTRFS_IOC_GET_FEATURES + IOCTL(BTRFS_IOC_GET_FEATURES, IOC_R, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags))) +#endif +#ifdef BTRFS_IOC_SET_FEATURES + IOCTL(BTRFS_IOC_SET_FEATURES, IOC_W, + MK_PTR(MK_ARRAY(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags), 2)= )) +#endif +#ifdef BTRFS_IOC_GET_SUPPORTED_FEATURES + IOCTL(BTRFS_IOC_GET_SUPPORTED_FEATURES, IOC_R, + MK_PTR(MK_ARRAY(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags), 3)= )) +#endif #ifdef BTRFS_IOC_GET_SUBVOL_INFO IOCTL(BTRFS_IOC_GET_SUBVOL_INFO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args))) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index d11279b78bbe..f70138979704 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1019,6 +1019,9 @@ struct target_rtc_pll_info { abi_ullong) #define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 30) #define TARGET_BTRFS_IOC_GET_DEV_STATS TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 52) +#define TARGET_BTRFS_IOC_GET_FEATURES TARGET_IORU(BTRFS_IOCTL_MA= GIC, 57) +#define TARGET_BTRFS_IOC_SET_FEATURES TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 57) +#define TARGET_BTRFS_IOC_GET_SUPPORTED_FEATURES TARGET_IORU(BTRFS_IOCTL_MA= GIC, 57) #define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IORU(BTRFS_IOCTL_MA= GIC, 60) =20 /* usb ioctls */ diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 7e52b7aec5d9..eba0c43d4493 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -413,6 +413,11 @@ STRUCT(btrfs_ioctl_get_dev_stats, 128 - 2 - BTRFS_DEV_STAT_VALUES_MAX)) /* unused */ #endif =20 +STRUCT(btrfs_ioctl_feature_flags, + TYPE_ULONGLONG, /* compat_flags */ + TYPE_ULONGLONG, /* compat_ro_flags */ + TYPE_ULONGLONG) /* incompat_flags */ + STRUCT(rtc_time, TYPE_INT, /* tm_sec */ TYPE_INT, /* tm_min */ --=20 2.26.2 From nobody Fri May 17 22:00:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1598872341; cv=none; d=zohomail.com; s=zohoarc; b=R6uWDxiUkuhGpwwzw94rLNgK581tAK+htgzXd5CbLNEijTsAduEiBzYXJ6/iJjXRvnTeeWkn8s9BPPds8SWeF5jjx81HtJAq0I9D0UZu/cY7U3vUHybJ+REu82ynM1tC//Md92xB7c+zCba9Ppx+4Q//6cKAAkywchVPcjbdtx0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598872341; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kpBzyd9QQMOa3DUr9TvMPaJqakjVAsKkrlU6fIa6KCs=; b=V2NQGfexJjyUR9DpAf1+Tl4NtYknxncSp687j0npcl/Oe9pUfSQfAy+/9QNyiXMQFiPXNsmsBL4OAm8Np1jkjvpfFyTO6zEROXStUU+ehOu0uYYjRlNslTTxFPKAgpcrmdlAsAOBcPucxXVZx76evxseUyTiFw7ZhjRb983BNwI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598872341819494.86025428461676; Mon, 31 Aug 2020 04:12:21 -0700 (PDT) Received: from localhost ([::1]:60094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kChjY-00087j-AT for importer@patchew.org; Mon, 31 Aug 2020 07:12:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kChet-00075F-CE for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:31 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:47565) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCheq-0000RN-ND for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:31 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MvaO8-1kTYFh3yOU-00sb29; Mon, 31 Aug 2020 13:07:24 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 5/8] linux-user: Add support for a group of btrfs inode ioctls Date: Mon, 31 Aug 2020 13:07:13 +0200 Message-Id: <20200831110716.536808-6-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200831110716.536808-1-laurent@vivier.eu> References: <20200831110716.536808-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:YahWqIzfLLaLcM1gKYs4gubZlC155B+nnqbrUDUZTHoUz9x+PUf GO8tHUtyd24HOwdJUflp5yFP3cYYlyJ2/g2QSCq6sIkM8Dcl+xq/aK1AgRX5wpaY5mHnwc+ isYut4voHXUo2YsVfh45DpviINVmLojRLx/3iKqSjoXWKuJwEV13/kaXAavgrV4SJUCK66X LawlX0AJE2Ow2T0l7lw4w== X-UI-Out-Filterresults: notjunk:1;V03:K0:yTiZlOj97aE=:JRfklhmXTNy+vxzF4PG4nb 78hjw0DD+dYqF/cokQSCB4z/ZdGOWywjfWZjnNA74VZyJUjxbZiSWWgIs3iPIcPx77dbr+n3+ cwgHpEd1TOuOaBRtFDrwFY2WyP+Oa6X/7qQeYLTWLYtGo7z5OH2oPq65mWaLjekeNAjquaDdk CyzYnx7ZF+WQflkwN1FY1fQ+YrgMJHExCyvFGPsEDBZisnqp74w0qSIYsnt0dlQm/uPvYNtyP 0PKDxkhDhHAI88agwiQkEyu3KDzMVAIdswKu9jHFn9Qqy1BtqkTxWssUfT8OJhbISS5C2IHVU HDNQkZ5bvy/0tl+BhceAb5r0kJx4z4LW68Rom78NdoSRO3F0c+xKVKs5HE/nPD0rL9+uCpra7 BKWKFxJXksNFr/3W6a28Iez2FMwF0oKtg0JmFNVto3SkXo7ReuJkvuhkVvekR7Xmf84a52nlm exSz4hadlesCBg8Sqov+SPLdRjDlBRqHY6VDKbkbQ2dpSE5+CznuUVx0QOi2bpv2eAAuz+EJR 8HalO1uvQ8aqqL7gyG5rUyQvozBVyWnTaXTZ7WnbP7onvYIvbdWDxxL81k6HoGBGZUYkiBnNh qu5i26KMHKcStg8bBrRyCk33wJxlhiuvfR/pvml2WfmzHH7cE8yxS56I42CslNeJHhSnJseMi bgF/ByrBS3SO5B0kuE/6vmq3bezLT8YayUPUyM/IU1TtXUK0Rk+fiW+f9z2brK67VvtKdjukT RgmiQePTStFa2Yrjdc93SrP80gXJQuuLjd1/Puz6GQGibcqbhWYwFsTXYo8uxJHmApJD8Lz46 FvZgM6NUSY/tWskUW8zvwMj8O/inuTNyegqjOwvSowvymzWkjeHUFG82GKqcCmYibJJ2bAS Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.73; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 07:07:27 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionality of following ioctls: BTRFS_IOC_INO_LOOKUP - Reading tree root id and path Read tree root id and path for a given file or directory. The name and tree root id are returned in an ioctl's third argument that represents a pointer to a following type: struct btrfs_ioctl_ino_lookup_args { __u64 treeid; __u64 objectid; char name[BTRFS_INO_LOOKUP_PATH_MAX]; }; Before calling this ioctl, field 'objectid' should be filled with the object id value for which the tree id and path are to be read. Value 'BTRFS_FIRST_FREE_OBJECTID' represents the object id for the first available btrfs object (directory or file). BTRFS_IOC_INO_PATHS - Reading paths to all files Read path to all files with a certain inode number. The paths are returned in the ioctl's third argument which represents a pointer to a following type: struct btrfs_ioctl_ino_path_args { __u64 inum; /* in */ __u64 size; /* in */ __u64 reserved[4]; /* struct btrfs_data_container *fspath; out */ __u64 fspath; /* out */ }; Before calling this ioctl, the 'inum' and 'size' field should be filled with the aproppriate inode number and size of the directory where file paths should be looked for. For now, the paths are returned in an '__u64' (unsigned long long) value 'fspath'. BTRFS_IOC_LOGICAL_INO - Reading inode numbers Read inode numbers for files on a certain logical adress. The inode numbers are returned in the ioctl's third argument which represents a pointer to a following type: struct btrfs_ioctl_logical_ino_args { __u64 logical; /* in */ __u64 size; /* in */ __u64 reserved[3]; /* must be 0 for now */ __u64 flags; /* in, v2 only */ /* struct btrfs_data_container *inodes; out */ __u64 inodes; }; Before calling this ioctl, the 'logical' and 'size' field should be filled with the aproppriate logical adress and size of where the inode numbers of files should be looked for. For now, the inode numbers are returned in an '__u64' (unsigned long long) value 'inodes'. BTRFS_IOC_LOGICAL_INO_V2 - Reading inode numbers Same as the above mentioned ioctl except that it allows passing a flags 'BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET'. BTRFS_IOC_INO_LOOKUP_USER - Reading subvolume name and path Read name and path of a subvolume. The tree root id and path are read in an ioctl's third argument which represents a pointer to a following type: struct btrfs_ioctl_ino_lookup_user_args { /* in, inode number containing the subvolume of 'subvolid' */ __u64 dirid; /* in */ __u64 treeid; /* out, name of the subvolume of 'treeid' */ char name[BTRFS_VOL_NAME_MAX + 1]; /* * out, constructed path from the directory with which the ioctl is * called to dirid */ char path[BTRFS_INO_LOOKUP_USER_PATH_MAX]; }; Before calling this ioctl, the 'dirid' and 'treeid' field should be filled with aproppriate values which represent the inode number of the directory that contains the subvolume and treeid of the subvolume. Implementation notes: All of the ioctls in this patch use structure types as third arguments. That is the reason why aproppriate thunk definitions were added in file 'syscall_types.h'. Signed-off-by: Filip Bozuta Tested-by: Daniel P. Berrang=C3=A9 Message-Id: <20200823195014.116226-6-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 20 ++++++++++++++++++++ linux-user/syscall_defs.h | 5 +++++ linux-user/syscall_types.h | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 11d7361848dd..23807513eed1 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -202,6 +202,10 @@ IOCTL(BTRFS_IOC_SNAP_DESTROY, IOC_W, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args))) #endif +#ifdef BTRFS_IOC_INO_LOOKUP + IOCTL(BTRFS_IOC_INO_LOOKUP, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_args))) +#endif #ifdef BTRFS_IOC_SUBVOL_GETFLAGS IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG)) #endif @@ -212,6 +216,14 @@ IOCTL(BTRFS_IOC_DEV_INFO, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_dev_info_args))) #endif +#ifdef BTRFS_IOC_INO_PATHS + IOCTL(BTRFS_IOC_INO_PATHS, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_path_args))) +#endif +#ifdef BTRFS_IOC_LOGICAL_INO + IOCTL(BTRFS_IOC_LOGICAL_INO, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_logical_ino_args))) +#endif #ifdef BTRFS_IOC_GET_DEV_STATS IOCTL(BTRFS_IOC_GET_DEV_STATS, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_dev_stats))) @@ -228,10 +240,18 @@ IOCTL(BTRFS_IOC_GET_SUPPORTED_FEATURES, IOC_R, MK_PTR(MK_ARRAY(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags), 3)= )) #endif +#ifdef BTRFS_IOC_LOGICAL_INO_V2 + IOCTL(BTRFS_IOC_LOGICAL_INO_V2, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_logical_ino_args))) +#endif #ifdef BTRFS_IOC_GET_SUBVOL_INFO IOCTL(BTRFS_IOC_GET_SUBVOL_INFO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args))) #endif +#ifdef BTRFS_IOC_INO_LOOKUP_USER + IOCTL(BTRFS_IOC_INO_LOOKUP_USER, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_user_args))) +#endif =20 #ifdef CONFIG_USBFS /* USB ioctls */ diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index f70138979704..4929121956c6 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1013,16 +1013,21 @@ struct target_rtc_pll_info { #define TARGET_BTRFS_IOC_RM_DEV TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 11) #define TARGET_BTRFS_IOC_SUBVOL_CREATE TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 14) #define TARGET_BTRFS_IOC_SNAP_DESTROY TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 15) +#define TARGET_BTRFS_IOC_INO_LOOKUP TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 18) #define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAG= IC, 25,\ abi_ullong) #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAG= IC, 26,\ abi_ullong) #define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 30) +#define TARGET_BTRFS_IOC_INO_PATHS TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 35) +#define TARGET_BTRFS_IOC_LOGICAL_INO TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 36) #define TARGET_BTRFS_IOC_GET_DEV_STATS TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 52) #define TARGET_BTRFS_IOC_GET_FEATURES TARGET_IORU(BTRFS_IOCTL_MA= GIC, 57) #define TARGET_BTRFS_IOC_SET_FEATURES TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 57) #define TARGET_BTRFS_IOC_GET_SUPPORTED_FEATURES TARGET_IORU(BTRFS_IOCTL_MA= GIC, 57) +#define TARGET_BTRFS_IOC_LOGICAL_INO_V2 TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 59) #define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IORU(BTRFS_IOCTL_MA= GIC, 60) +#define TARGET_BTRFS_IOC_INO_LOOKUP_USER TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 62) =20 /* usb ioctls */ #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index eba0c43d4493..dab2c16bcac7 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -393,6 +393,38 @@ STRUCT(btrfs_ioctl_get_subvol_info_args, MK_ARRAY(TYPE_ULONGLONG, 8)) /* reserved */ #endif =20 +#ifdef BTRFS_IOC_INO_LOOKUP +STRUCT(btrfs_ioctl_ino_lookup_args, + TYPE_ULONGLONG, /* treeid */ + TYPE_ULONGLONG, /* objectid */ + MK_ARRAY(TYPE_CHAR, BTRFS_INO_LOOKUP_PATH_MAX)) /* name */ +#endif + +#ifdef BTRFS_IOC_INO_PATHS +STRUCT(btrfs_ioctl_ino_path_args, + TYPE_ULONGLONG, /* inum */ + TYPE_ULONGLONG, /* size */ + MK_ARRAY(TYPE_ULONGLONG, 4), /* reserved */ + TYPE_ULONGLONG) /* fspath */ +#endif + +#if defined(BTRFS_IOC_LOGICAL_INO) || defined(BTRFS_IOC_LOGICAL_INO_V2) +STRUCT(btrfs_ioctl_logical_ino_args, + TYPE_ULONGLONG, /* logical */ + TYPE_ULONGLONG, /* size */ + MK_ARRAY(TYPE_ULONGLONG, 3), /* reserved */ + TYPE_ULONGLONG, /* flags */ + TYPE_ULONGLONG) /* inodes */ +#endif + +#ifdef BTRFS_IOC_INO_LOOKUP_USER +STRUCT(btrfs_ioctl_ino_lookup_user_args, + TYPE_ULONGLONG, /* dirid */ + TYPE_ULONGLONG, /* treeid */ + MK_ARRAY(TYPE_CHAR, BTRFS_VOL_NAME_MAX + 1), /* name */ + MK_ARRAY(TYPE_CHAR, BTRFS_INO_LOOKUP_USER_PATH_MAX)) /* path */ +#endif + #ifdef BTRFS_IOC_DEV_INFO STRUCT(btrfs_ioctl_dev_info_args, TYPE_ULONGLONG, /* devid */ --=20 2.26.2 From nobody Fri May 17 22:00:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1598872409; cv=none; d=zohomail.com; s=zohoarc; b=VYCsdxq4BOr/7RCypwSn3UgkoOl4OmUZyLvjQ97+UB/LypA7fn6o+6hPE8q2Yxfk9qkuFaOo0qgkkjjNHLptOxJQYq7rZzwkWY/jmSXI1mPaYSXQgXa1ce2cv1Ey4e6UgNKQmxcPVuXMBJiPl0bSLsv0ZDRE5R1Sn3OfZ/drpLk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598872409; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DQPsfcxkNB1XjIeGOHIxa5n7iQj11oVsiS+a4iPb7Pc=; b=VuFh0Da8YvQb5lYdtIkdDr3xcoE5rcBwCoNgmdfsqwl+Vzypzu/VsPGwL4COjmaIh9NLxv4u13ND/IDqGLQWKeBxEMuGBch1u10cJDUqdB21xSBkOL4hifw9ZIvlSHIPKBFn5G8vT9UMdcpaUahkLPw4WWQVON2gZq0aFB+aCpA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159887240896258.15962464933034; Mon, 31 Aug 2020 04:13:28 -0700 (PDT) Received: from localhost ([::1]:36540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kChkc-0001dX-Nu for importer@patchew.org; Mon, 31 Aug 2020 07:13:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kChet-00075p-JP for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:31 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:59389) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCher-0000RW-DS for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:31 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MysBI-1kZ1u229ys-00vuQP; Mon, 31 Aug 2020 13:07:24 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 6/8] linux-user: Add support for two btrfs ioctls used for subvolume Date: Mon, 31 Aug 2020 13:07:14 +0200 Message-Id: <20200831110716.536808-7-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200831110716.536808-1-laurent@vivier.eu> References: <20200831110716.536808-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:gP++zb2zEvzLKP/z7C17sFUsRuzroIK7o/zvgwLUkJ3LcrP16Q8 PC6zF6Q1U68aD0u0DGYTOVYpQ81i8q0vbo/amUCFjdEMFtZUppGk8H/Sc18zlujxs1UBxDP 5NEtXz+kW5dQY0hacVOYB074jUbMH/nbEUV6OYKC5C5W1C6MXaRhD0Xq9XTOfAaHC9oyxUi jRUw9jIsfljQQKoJf0EVw== X-UI-Out-Filterresults: notjunk:1;V03:K0:IjocbBXNDL4=:5ukBYv1rloQ4USn/BB4HH8 L5lhkaM0AsDLJUJkdOClDoKaPviMYWeLv6DQEzyaLJQbAJoam2732OfxydXNS9I5Vo+JWpDpB 5iSUeu0UHYIfBxhI2bbipcCANg90B2z4N27d3wmfmRz5OhsZNKtkh0lw1PTvYWA6X4ZXr+doQ QA0AYEyLlGFs0Ptr5k8FtmNPns4y1IeiS5yxKPrU0kx4/9G0VNWD1aROPDr8xXJ1WZCAdQfcl ttlkAlnApjnQm0iQAVt5sQfjFWdZCRckgJk2HdZSvduFyldl3J3TkdC8HdF00Zt8hXVwXBmOg lYSxae+Stgjws0OJNTo1XX35RJJOY/jU5Es1o9MUTOSghmdvJGB4FuglXc7pFoarecbg9FJwI PSQF1P5l6MXb4c/Fws5IEbWdaTzWcCuDXhSZh1BnrlrH9ocJEbGVzgmt00WLPbBSDyb4Zikb3 SZha7pSLwH9peU3WeFdSMXuf2aX9HEXYmeSwFF2fTjHBD3skI9QRbIUuYAHj81kPgdz4Ssw49 YTyuu7YDBdwH2PadVN9iwvnOfeGIbq+/aMCe0lSV55XTF56Aa9EeyFlKhqAa8O9ftkgatkjsU QoELMKMcQcrGqauQM8ViI30X39BkluYEPUBGDNyPzkqAlFV7INodjU6weUhKFHlvoFLdKLtXt k2rULhWT9m4d8D89Oar5xHLtX6nlevRpICwKZXIvGHq2OjItr+OXaldYG6M4kfWWYG9cyyKTf QFLSZN9gLzdON7Q5xLkaXOOQZQ5bO3ezTQP1HIiKZpQY0L9W6TbLUKa+9AIXdpv+qFFkY3PeJ 6vTrXmzWJoYgeMRsr7O88vHhxncEDoqhjttnCYzhvp/zqacaShRC7lXkGnFhieHrVfeVrV2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.10; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 07:07:21 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionality for following ioctl: BTRFS_IOC_DEFAULT_SUBVOL - Setting a default subvolume Set a default subvolume for a btrfs filesystem. The third ioctl's argument is a '__u64' (unsigned long long) which represents the id of a subvolume that is to be set as the default. BTRFS_IOC_GET_SUBVOL_ROOTREF - Getting tree and directory id of subvolumes Read tree and directory id of subvolumes from a btrfs filesystem. The tree and directory id's are returned in the ioctl's third argument which represents a pointer to a following type: struct btrfs_ioctl_get_subvol_rootref_args { /* in/out, minimum id of rootref's treeid to be searched */ __u64 min_treeid; /* out */ struct { __u64 treeid; __u64 dirid; } rootref[BTRFS_MAX_ROOTREF_BUFFER_NUM]; /* out, number of found items */ __u8 num_items; __u8 align[7]; }; Before calling this ioctl, 'min_treeid' field should be filled with value that represent the minimum value for the tree id. Implementation notes: Ioctl BTRFS_IOC_GET_SUBVOL_ROOTREF uses the above mentioned structure type as third argument. That is the reason why a aproppriate thunk structure definition is added in file 'syscall_types.h'. Signed-off-by: Filip Bozuta Tested-by: Daniel P. Berrang=C3=A9 Message-Id: <20200823195014.116226-7-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 7 +++++++ linux-user/syscall_defs.h | 3 +++ linux-user/syscall_types.h | 13 +++++++++++++ 3 files changed, 23 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 23807513eed1..dc2f3d2413ed 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -206,6 +206,9 @@ IOCTL(BTRFS_IOC_INO_LOOKUP, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_args))) #endif +#ifdef BTRFS_IOC_DEFAULT_SUBVOL + IOCTL(BTRFS_IOC_DEFAULT_SUBVOL, IOC_W, MK_PTR(TYPE_ULONGLONG)) +#endif #ifdef BTRFS_IOC_SUBVOL_GETFLAGS IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG)) #endif @@ -248,6 +251,10 @@ IOCTL(BTRFS_IOC_GET_SUBVOL_INFO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args))) #endif +#ifdef BTRFS_IOC_GET_SUBVOL_ROOTREF + IOCTL(BTRFS_IOC_GET_SUBVOL_ROOTREF, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_rootref_args))) +#endif #ifdef BTRFS_IOC_INO_LOOKUP_USER IOCTL(BTRFS_IOC_INO_LOOKUP_USER, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_user_args))) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 4929121956c6..bb60c728d81a 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1014,6 +1014,8 @@ struct target_rtc_pll_info { #define TARGET_BTRFS_IOC_SUBVOL_CREATE TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 14) #define TARGET_BTRFS_IOC_SNAP_DESTROY TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 15) #define TARGET_BTRFS_IOC_INO_LOOKUP TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 18) +#define TARGET_BTRFS_IOC_DEFAULT_SUBVOL TARGET_IOW(BTRFS_IOCTL_MAG= IC, 19,\ + abi_ullong) #define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAG= IC, 25,\ abi_ullong) #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAG= IC, 26,\ @@ -1027,6 +1029,7 @@ struct target_rtc_pll_info { #define TARGET_BTRFS_IOC_GET_SUPPORTED_FEATURES TARGET_IORU(BTRFS_IOCTL_MA= GIC, 57) #define TARGET_BTRFS_IOC_LOGICAL_INO_V2 TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 59) #define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IORU(BTRFS_IOCTL_MA= GIC, 60) +#define TARGET_BTRFS_IOC_GET_SUBVOL_ROOTREF TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 61) #define TARGET_BTRFS_IOC_INO_LOOKUP_USER TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 62) =20 /* usb ioctls */ diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index dab2c16bcac7..73e36620cedc 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -435,6 +435,19 @@ STRUCT(btrfs_ioctl_dev_info_args, MK_ARRAY(TYPE_CHAR, BTRFS_DEVICE_PATH_NAME_MAX)) /* path */ #endif =20 +#ifdef BTRFS_IOC_GET_SUBVOL_ROOTREF +STRUCT(rootref, + TYPE_ULONGLONG, /* treeid */ + TYPE_ULONGLONG) /* dirid */ + +STRUCT(btrfs_ioctl_get_subvol_rootref_args, + TYPE_ULONGLONG, /* min_treeid */ + MK_ARRAY(MK_STRUCT(STRUCT_rootref), + BTRFS_MAX_ROOTREF_BUFFER_NUM), /* rootref */ + TYPE_CHAR, /* num_items */ + MK_ARRAY(TYPE_CHAR, 7)) /* align */ +#endif + #ifdef BTRFS_IOC_GET_DEV_STATS STRUCT(btrfs_ioctl_get_dev_stats, TYPE_ULONGLONG, /* devid */ --=20 2.26.2 From nobody Fri May 17 22:00:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1598872341; cv=none; d=zohomail.com; s=zohoarc; b=KPG8ThfvV1p0DCYgUvXdl58a5t5/WSvy074OBD4reced2K2eXOyrHQZBnpWJErd8npbRPCBTDQkWQn1a8hokd6WQhBpDfuhL0vww+VkuImJ5Haob8tXhpyR9n0Xraocanltizva7ITtho9XumfAD9HfeYIR4iXB0a4j6DxmPFoY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598872341; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=etRxsXLQa7eP33zwlO3AnelTIma4Zn5qmGZy3OvagNA=; b=WTiR3K9fl64rwWSF/B+gUk5yY9FVuqdy9kOMtMiWq9xbEd8Axedq3Le62esyavbDwo/RXm55EeIFF+Y2pTuZgQHGia0FFE5/83PbLbVDvj4GrrOCKpAXo97ZDz5YiDe15O3+qSYJ2Xoh5Xk9MX4pXnmzjoKH9ZCdzaGI66aTghM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598872341701535.6814117321519; Mon, 31 Aug 2020 04:12:21 -0700 (PDT) Received: from localhost ([::1]:60158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kChjY-000896-7u for importer@patchew.org; Mon, 31 Aug 2020 07:12:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kChev-00079o-4t for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:33 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:53643) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCher-0000Rh-OG for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:32 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MdNHa-1kllML079s-00ZPix; Mon, 31 Aug 2020 13:07:25 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 7/8] linux-user: Add support for btrfs ioctls used to manage quota Date: Mon, 31 Aug 2020 13:07:15 +0200 Message-Id: <20200831110716.536808-8-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200831110716.536808-1-laurent@vivier.eu> References: <20200831110716.536808-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:eQRL8ng3sFO02dHmjl5Jh9KzM7huJgDw+GIyyCxoah9t7gc1xXw txL+TjU/oR7j18KLcaH3vNCAbNlgnkqKJFszZotNeaV8rFmTpg1KnECDkAqS1abRNAOVeun NsJ93RTdN8sPhdvv/IczD9tlsL//MFhvWEQsz1LWjFF2zoNHZ03eQC0wUtztQLbpKXGckl5 gQu36aN1NVBZ6CcuTjmUQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:UQr/bFPXucE=:hKbx61uFuueEDmJ5H2Jqxn N6wptKCyoVt7heNUO8wc2bjer2tk8biD84yNt7yp3ouYXejKlihMgslorMTa5aGQNeLWaYvlZ IyLXJjTNDVgInLoB3GSPTKfRJdUOe9gUOxUUVWqGBCs5G3pAXQtAkxufIB0rVOJnn89EawLuA 8XEuxzLOwJku+rv/dh9PcjYcDo4DMRkdlY6XbW4ES4/T00o7fClQaKr4O2wO4ZYORvlFCAGrG d+g0eLApAwkJb0ku0cAnghjcQiV4NDo0s86+EN/utqcm7CxVvi5XCTyA7l/kVoDz6y1f11wEG hYjgtcQqwM3Sl7LnmWTWbDFNB54ghLl9V3AHGs+pRY365bqnZG4gGHKgyh75Z30t8bM+sFWuH 8qjHAgM+YQ/QeCHd6SOlu+pYK+PyZXVzm5wJgRKmez5Y8XTJC/yiZmFxEF26wBguho8TJ+LHd AXYP2+W7izhYdsy6tlXWhYqbvxTwnFrsMBMWYUkgkQN/IpvazXhQkTVIlyLvcQzSCriT2P6UW 2DBjzqR10sM/kGezOzjbGvKAfHGZOOxBJC2p+3sP706sbFdzKs5p9iG6n97Xb75VT1+vs3+Vq Yfj2S8Gt6j4WFdhk6bt3dfePU9kXTF6odqBL+cT8R82Riohyt+N0Gn+JXVbBPMGv0o7ChNr5w FBNh+MbeG7sjebiJ53ixpUHKvygc9chYeHxjQ86nVplWy6xgJgycU30ktOhCsXavd7/WqEwHO C5WAURI/+AWpIud6Db2vons67Ava+GLiJ/qLJEa4SnZYeBl+XqjBeGotPG9Mx/v00S++5MBXT y53bVi6Q9I8YNSX4v6smpkHhnt4Sx/q4n9zFunYNhuu/XhdccWCS2bnBOU4Uh3Kbevw3mBu Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 07:07:27 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionality for following ioctls: BTRFS_IOC_QUOTA_CTL - Enabling/Disabling quota support Enable or disable quota support for a btrfs filesystem. Quota support is enabled or disabled using the ioctls third argument which represents a pointer to a following type: struct btrfs_ioctl_quota_ctl_args { __u64 cmd; __u64 status; }; Before calling this ioctl, the 'cmd' field should be filled with one of the values 'BTRFS_QUOTA_CTL_ENABLE' (enabling quota) 'BTRFS_QUOTA_CTL_DISABLE' (disabling quota). BTRFS_IOC_QGROUP_CREATE - Creating/Removing a subvolume quota group Create or remove a subvolume quota group. The subvolume quota group is created or removed using the ioctl's third argument which represents a pointer to a following type: struct btrfs_ioctl_qgroup_create_args { __u64 create; __u64 qgroupid; }; Before calling this ioctl, the 'create' field should be filled with the aproppriate value depending on if the user wants to create or remove a quota group (0 for removing, everything else for creating). Also, the 'qgroupid' field should be filled with the value for the quota group id that is to be created. BTRFS_IOC_QGROUP_ASSIGN - Asigning or removing a quota group as child group Asign or remove a quota group as child quota group of another group in the btrfs filesystem. The asignment is done using the ioctl's third argument which represents a pointert to a following type: struct btrfs_ioctl_qgroup_assign_args { __u64 assign; __u64 src; __u64 dst; }; Before calling this ioctl, the 'assign' field should be filled with the aproppriate value depending on if the user wants to asign or remove a quota group as a child quota group of another group (0 for removing, everythin else for asigning). Also, the 'src' and 'dst' fields should be filled with the aproppriate quota group id values depending on which quota group needs to asigned or removed as child quota group of another group ('src' gets asigned or removed as child group of 'dst'). BTRFS_IOC_QGROUP_LIMIT - Limiting the size of a quota group Limit the size of a quota group. The size of the quota group is limited with the ioctls third argument which represents a pointer to a following type: struct btrfs_ioctl_qgroup_limit_args { __u64 qgroupid; struct btrfs_qgroup_limit lim; }; Before calling this ioctl, the 'qgroup' id field should be filled with aproppriate value of the quota group id for which the size is to be limited. The second field is of following type: struct btrfs_qgroup_limit { __u64 flags; __u64 max_rfer; __u64 max_excl; __u64 rsv_rfer; __u64 rsv_excl; }; The 'max_rfer' field should be filled with the size to which the quota group should be limited. The 'flags' field can be used for passing additional options and can have values which can be found on: https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/btrfs= .h#L67 BTRFS_IOC_QUOTA_RESCAN_STATUS - Checking status of running rescan operation Check status of a running rescan operation. The status is checked using the ioctl's third argument which represents a pointer to a following ty= pe: struct btrfs_ioctl_quota_rescan_args { __u64 flags; __u64 progress; __u64 reserved[6]; }; If there is a rescan operation running, 'flags' field is set to 1, and 'progress' field is set to aproppriate value which represents the progr= ess of the operation. BTRFS_IOC_QUOTA_RESCAN - Starting a rescan operation Start ar rescan operation to Trash all quota groups and scan the metada= ta again with the current config. Before calling this ioctl, BTRFS_IOC_QUOTA_RESCAN_STATUS sould be run to check if there is already= a rescan operation runing. After that ioctl call, the received 'struct btrfs_ioctl_quota_rescan_args' should be than passed as this io= ctls third argument. BTRFS_IOC_QUOTA_RESCAN_WAIT - Waiting for a rescan operation to finish Wait until a rescan operation is finished (if there is a rescan operati= on running). The third ioctls argument is ignored. Implementation notes: Almost all of the ioctls in this patch use structure types as third arg= uments. That is the reason why aproppriate thunk definitions were added in file 'syscall_types.h'. Signed-off-by: Filip Bozuta Tested-by: Daniel P. Berrang=C3=A9 Message-Id: <20200823195014.116226-8-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 27 +++++++++++++++++++++++++++ linux-user/syscall_defs.h | 7 +++++++ linux-user/syscall_types.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index dc2f3d2413ed..42759c0778b4 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -227,6 +227,33 @@ IOCTL(BTRFS_IOC_LOGICAL_INO, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_logical_ino_args))) #endif +#ifdef BTRFS_IOC_QUOTA_CTL + IOCTL(BTRFS_IOC_QUOTA_CTL, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_quota_ctl_args))) +#endif +#ifdef BTRFS_IOC_QGROUP_ASSIGN + IOCTL(BTRFS_IOC_QGROUP_ASSIGN, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_qgroup_assign_args))) +#endif +#ifdef BTRFS_IOC_QGROUP_CREATE + IOCTL(BTRFS_IOC_QGROUP_CREATE, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_qgroup_create_args))) +#endif +#ifdef BTRFS_IOC_QGROUP_LIMIT + IOCTL(BTRFS_IOC_QGROUP_LIMIT, IOC_R, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_qgroup_limit_args))) +#endif +#ifdef BTRFS_IOC_QUOTA_RESCAN + IOCTL(BTRFS_IOC_QUOTA_RESCAN, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_quota_rescan_args))) +#endif +#ifdef BTRFS_IOC_QUOTA_RESCAN_STATUS + IOCTL(BTRFS_IOC_QUOTA_RESCAN_STATUS, IOC_R, + MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_quota_rescan_args))) +#endif +#ifdef BTRFS_IOC_QUOTA_RESCAN_WAIT + IOCTL(BTRFS_IOC_QUOTA_RESCAN_WAIT, 0, TYPE_NULL) +#endif #ifdef BTRFS_IOC_GET_DEV_STATS IOCTL(BTRFS_IOC_GET_DEV_STATS, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_dev_stats))) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index bb60c728d81a..b557b07eec85 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1023,6 +1023,13 @@ struct target_rtc_pll_info { #define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 30) #define TARGET_BTRFS_IOC_INO_PATHS TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 35) #define TARGET_BTRFS_IOC_LOGICAL_INO TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 36) +#define TARGET_BTRFS_IOC_QUOTA_CTL TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 40) +#define TARGET_BTRFS_IOC_QGROUP_ASSIGN TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 41) +#define TARGET_BTRFS_IOC_QGROUP_CREATE TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 42) +#define TARGET_BTRFS_IOC_QGROUP_LIMIT TARGET_IORU(BTRFS_IOCTL_MA= GIC, 43) +#define TARGET_BTRFS_IOC_QUOTA_RESCAN TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 44) +#define TARGET_BTRFS_IOC_QUOTA_RESCAN_STATUS TARGET_IORU(BTRFS_IOCTL_MA= GIC, 45) +#define TARGET_BTRFS_IOC_QUOTA_RESCAN_WAIT TARGET_IO(BTRFS_IOCTL_MAGI= C, 46) #define TARGET_BTRFS_IOC_GET_DEV_STATS TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 52) #define TARGET_BTRFS_IOC_GET_FEATURES TARGET_IORU(BTRFS_IOCTL_MA= GIC, 57) #define TARGET_BTRFS_IOC_SET_FEATURES TARGET_IOWU(BTRFS_IOCTL_MA= GIC, 57) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 73e36620cedc..51d9931b9546 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -458,6 +458,35 @@ STRUCT(btrfs_ioctl_get_dev_stats, 128 - 2 - BTRFS_DEV_STAT_VALUES_MAX)) /* unused */ #endif =20 +STRUCT(btrfs_ioctl_quota_ctl_args, + TYPE_ULONGLONG, /* cmd */ + TYPE_ULONGLONG) /* status */ + +STRUCT(btrfs_ioctl_quota_rescan_args, + TYPE_ULONGLONG, /* flags */ + TYPE_ULONGLONG, /* progress */ + MK_ARRAY(TYPE_ULONGLONG, 6)) /* reserved */ + +STRUCT(btrfs_ioctl_qgroup_assign_args, + TYPE_ULONGLONG, /* assign */ + TYPE_ULONGLONG, /* src */ + TYPE_ULONGLONG) /* dst */ + +STRUCT(btrfs_ioctl_qgroup_create_args, + TYPE_ULONGLONG, /* create */ + TYPE_ULONGLONG) /* qgroupid */ + +STRUCT(btrfs_qgroup_limit, + TYPE_ULONGLONG, /* flags */ + TYPE_ULONGLONG, /* max_rfer */ + TYPE_ULONGLONG, /* max_excl */ + TYPE_ULONGLONG, /* rsv_rfer */ + TYPE_ULONGLONG) /* rsv_excl */ + +STRUCT(btrfs_ioctl_qgroup_limit_args, + TYPE_ULONGLONG, /* qgroupid */ + MK_STRUCT(STRUCT_btrfs_qgroup_limit)) /* lim */ + STRUCT(btrfs_ioctl_feature_flags, TYPE_ULONGLONG, /* compat_flags */ TYPE_ULONGLONG, /* compat_ro_flags */ --=20 2.26.2 From nobody Fri May 17 22:00:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1598872298; cv=none; d=zohomail.com; s=zohoarc; b=X5Jv3KuOqdM017N07QBsDfBlNzJjcmMprnvQvwsTsDoW2850NApoTIQ64SLBRjMdZoE4UORlijUC6oVITavZGQvNB5w9wEz7DR32gzGqxApRDNmR4rx2T4j4pFEg29gPpyG/DvvD/FPF63U5Ogc+9L59TrDwHn9fGeIemJl2XHo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598872298; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lq38q/yWJexjWSWlbOSHIjlkOi3TH7eMTMspaR3R84Y=; b=EASX8hL4uhS1gZUVbrfPBh05/QWTUNbHOvprl9jVn0NY8NUpXNpDh1XD8zZ9H0jLeM2hLgLNv6s6rM4Tfiw3CcvuB886QPn9fw7bADT/DZXok97nxVgwlXfcFlpEy3R09kQriHw6uQ1xKWxHE0LEnvtVCv0EA41xpTje92gOzGo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159887229805166.13566927008833; Mon, 31 Aug 2020 04:11:38 -0700 (PDT) Received: from localhost ([::1]:56876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kChiq-0006qJ-JE for importer@patchew.org; Mon, 31 Aug 2020 07:11:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48260) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kChew-0007CS-15 for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:34 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:45437) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kChet-0000Rx-6P for qemu-devel@nongnu.org; Mon, 31 Aug 2020 07:07:33 -0400 Received: from localhost.localdomain ([82.252.135.186]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Mt7x1-1kSA0S2TUX-00tPa2; Mon, 31 Aug 2020 13:07:25 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 8/8] linux-user: Add support for btrfs ioctls used to scrub a filesystem Date: Mon, 31 Aug 2020 13:07:16 +0200 Message-Id: <20200831110716.536808-9-laurent@vivier.eu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200831110716.536808-1-laurent@vivier.eu> References: <20200831110716.536808-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:CCW9AexK0GkcNm3W2pqEF7JSHqttkHMxdsJNxco1V5z4teWsW8f JAp+fG2Xl6x0wAyqbncqgZDiFcmGFUqKwPAgHemq3jsg24bYX3f+xrijgzXBnYU0zncOBm2 SyTZ7ae/kwU62f2Grn/urwLAAfsNoHO8GAFy+xid3/U/GdPwx3Oy8ciAuJ2iI+q/eR3cDgU KNUle8NeeKF3vLOiqWTXQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:RSIf1ZjGfas=:gDihn2HzM3RIlTRM+d4uDn 3I9tRWdiR4wa5Ok3n9o+viznjvkPnWgPb/36eL2RmXUrxgb7ohEoX5Vb5wBg5eEA04NiDc8PP DkCnFYcXND8Qt0FUGLQm7e0bLqSnXmRlHchkcEMLdLTaROmh5FsnsN/HNc6XUnwoXya25jZH9 vV+Ae6IKQoHkNyl2+WDvX3yNNslkcVTz8wE+IToukkV7aXhOe/PnvovmBl4O/7m56f94dn7Mu zfTKEHBquL2EQfbwPmDGoSkCArDmQi2RI6ufWy9aWZLISAkfd0px488+6aQOfJIygzVxphF0b 4lo8Z6TrhK85bGortJGGMKy5lA4EzGci7CbJcMZK2GimIMOR03Qxhgf0TP0qRfDFtnZnhJvf9 GsvUugwxwDIUAnN4THOM4Btre97W9oTXRNDg66y4D/VLt5AdrUBJX9Q2CmUHxKxP5kpAUAZiG pt0aLV88jfH/1m6Se1/jb+KeDQhA2ZzeIFTvWeUU7Gb3WEYqLQHltuqfIusdURJU3Yrv5+CrM 2JX2oWP2lQL33pX+U46OkXcDnt19wS6dlisJB/1mXK9+hcANiD58Fb07tC3MaSv6R1m6AaeuC VYRaSLPr/zgu4zcYepZUQJJDSB/EuJQC8fEjuo+yOHKFgdypCOpIx+ono/X4nIs76E73Cw1fn PSMnMDCYJIiNhgli3ADZG5UGvuq+5RZAYGDcxNPAIhq3srvyHo7QhpBs+dcZtZV58ytKPwX06 +xN26ZYX/1s2X5gmBY0ytOQw1lrqWPaME60eGxjuD9RX9Uc6/3z2k6LyPaODlRB2QZ9piEayH ai3P+5lQZgBVFNa6Yv1vdT7ZRPGUX877I/2tpfZg1wT6qCGVcbDnfWKQHzDMfEWW0xU/yyr Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/31 07:07:29 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta 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 Tested-by: Daniel P. Berrang=C3=A9 Message-Id: <20200823195014.116226-9-Filip.Bozuta@syrmia.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 11 +++++++++++ linux-user/syscall_defs.h | 3 +++ linux-user/syscall_types.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 42759c0778b4..585874f090ff 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 b557b07eec85..33a414c50f19 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -1020,6 +1020,9 @@ struct target_rtc_pll_info { abi_ullong) #define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAG= IC, 26,\ abi_ullong) +#define TARGET_BTRFS_IOC_SCRUB TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 27) +#define TARGET_BTRFS_IOC_SCRUB_CANCEL TARGET_IO(BTRFS_IOCTL_MAGI= C, 28) +#define TARGET_BTRFS_IOC_SCRUB_PROGRESS TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 29) #define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 30) #define TARGET_BTRFS_IOC_INO_PATHS TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 35) #define TARGET_BTRFS_IOC_LOGICAL_INO TARGET_IOWRU(BTRFS_IOCTL_M= AGIC, 36) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 51d9931b9546..ba2c1518eb5c 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -425,6 +425,35 @@ STRUCT(btrfs_ioctl_ino_lookup_user_args, MK_ARRAY(TYPE_CHAR, BTRFS_INO_LOOKUP_USER_PATH_MAX)) /* path */ #endif =20 +#if defined(BTRFS_IOC_SCRUB) || defined(BTRFS_IOC_SCRUB_PROGRESS) +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 */ +#endif + #ifdef BTRFS_IOC_DEV_INFO STRUCT(btrfs_ioctl_dev_info_args, TYPE_ULONGLONG, /* devid */ --=20 2.26.2