Linux RAID subsystem development
 help / color / mirror / Atom feed
* Re: [PATCH 12/23] xfs: remove uuid_getnodeuniq and xfs_uu_t
From: Brian Foster @ 2017-05-18 13:27 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linux-xfs-u79uwXL29TY76Z2rM5mHXA,
	linux-raid-u79uwXL29TY76Z2rM5mHXA,
	linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw, Mimi Zohar, Amir Goldstein,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, David Howells,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA, Andy Shevchenko, Shaohua Li,
	Steven Whitehouse
In-Reply-To: <20170518062705.25902-13-hch-jcswGhMUV9g@public.gmane.org>

On Thu, May 18, 2017 at 08:26:54AM +0200, Christoph Hellwig wrote:
> Directly use the v1 intepretation of uuid_t instead.
> 
> Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
> ---

Reviewed-by: Brian Foster <bfoster-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

>  fs/xfs/uuid.c      | 25 -------------------------
>  fs/xfs/uuid.h      |  1 -
>  fs/xfs/xfs_mount.c |  6 +++++-
>  3 files changed, 5 insertions(+), 27 deletions(-)
> 
> diff --git a/fs/xfs/uuid.c b/fs/xfs/uuid.c
> index 29ed78c8637b..737c186ea98b 100644
> --- a/fs/xfs/uuid.c
> +++ b/fs/xfs/uuid.c
> @@ -17,31 +17,6 @@
>   */
>  #include <xfs.h>
>  
> -/* IRIX interpretation of an uuid_t */
> -typedef struct {
> -	__be32	uu_timelow;
> -	__be16	uu_timemid;
> -	__be16	uu_timehi;
> -	__be16	uu_clockseq;
> -	__be16	uu_node[3];
> -} xfs_uu_t;
> -
> -/*
> - * uuid_getnodeuniq - obtain the node unique fields of a UUID.
> - *
> - * This is not in any way a standard or condoned UUID function;
> - * it just something that's needed for user-level file handles.
> - */
> -void
> -uuid_getnodeuniq(uuid_t *uuid, int fsid [2])
> -{
> -	xfs_uu_t *uup = (xfs_uu_t *)uuid;
> -
> -	fsid[0] = (be16_to_cpu(uup->uu_clockseq) << 16) |
> -		   be16_to_cpu(uup->uu_timemid);
> -	fsid[1] = be32_to_cpu(uup->uu_timelow);
> -}
> -
>  int
>  uuid_is_nil(uuid_t *uuid)
>  {
> diff --git a/fs/xfs/uuid.h b/fs/xfs/uuid.h
> index 86bbed071e79..5aea49bf0963 100644
> --- a/fs/xfs/uuid.h
> +++ b/fs/xfs/uuid.h
> @@ -19,6 +19,5 @@
>  #define __XFS_SUPPORT_UUID_H__
>  
>  extern int uuid_is_nil(uuid_t *uuid);
> -extern void uuid_getnodeuniq(uuid_t *uuid, int fsid [2]);
>  
>  #endif	/* __XFS_SUPPORT_UUID_H__ */
> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> index 2eaf81859166..742e4a61c0bc 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -793,7 +793,11 @@ xfs_mountfs(
>  	 *  Copies the low order bits of the timestamp and the randomly
>  	 *  set "sequence" number out of a UUID.
>  	 */
> -	uuid_getnodeuniq(&sbp->sb_uuid, mp->m_fixedfsid);
> +	mp->m_fixedfsid[0] =
> +		((u32)sbp->sb_uuid.v1.clock_seq_hi_and_reserved << 24) |
> +		((u32)sbp->sb_uuid.v1.clock_seq_low << 16) |
> +		 be16_to_cpu(sbp->sb_uuid.v1.time_mid);
> +	mp->m_fixedfsid[1] = be32_to_cpu(sbp->sb_uuid.v1.time_low);
>  
>  	mp->m_dmevmask = 0;	/* not persistent; set after each mount */
>  
> -- 
> 2.11.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH 14/23] xfs: use the common helper uuid_is_null()
From: Brian Foster @ 2017-05-18 13:27 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linux-xfs-u79uwXL29TY76Z2rM5mHXA,
	linux-raid-u79uwXL29TY76Z2rM5mHXA,
	linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw, Mimi Zohar, Amir Goldstein,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, David Howells,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA, Andy Shevchenko, Shaohua Li,
	Steven Whitehouse
In-Reply-To: <20170518062705.25902-15-hch-jcswGhMUV9g@public.gmane.org>

On Thu, May 18, 2017 at 08:26:56AM +0200, Christoph Hellwig wrote:
> From: Amir Goldstein <amir73il-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> 
> Use the common helper uuid_is_null() and remove the xfs specific
> helper uuid_is_nil().
> 
> The common helper does not check for the NULL pointer value as
> xfs helper did, but xfs code never calls the helper with a pointer
> that can be NULL.
> 
> Conform comments and warning strings to use the term 'null uuid'
> instead of 'nil uuid', because this is the terminology used by
> lib/uuid.c and its users. It is also the terminology used in
> userspace by libuuid and xfsprogs.
> 
> Signed-off-by: Amir Goldstein <amir73il-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> [hch: remove now unused uuid.[ch]]
> Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
> ---

Reviewed-by: Brian Foster <bfoster-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

>  fs/xfs/Makefile          |  3 +--
>  fs/xfs/uuid.c            | 32 --------------------------------
>  fs/xfs/uuid.h            | 23 -----------------------
>  fs/xfs/xfs_linux.h       |  1 -
>  fs/xfs/xfs_log_recover.c |  6 +++---
>  fs/xfs/xfs_mount.c       |  8 ++++----
>  6 files changed, 8 insertions(+), 65 deletions(-)
>  delete mode 100644 fs/xfs/uuid.c
>  delete mode 100644 fs/xfs/uuid.h
> 
> diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
> index 5c90f82b8f6b..a6e955bfead8 100644
> --- a/fs/xfs/Makefile
> +++ b/fs/xfs/Makefile
> @@ -98,8 +98,7 @@ xfs-y				+= xfs_aops.o \
>  				   xfs_sysfs.o \
>  				   xfs_trans.o \
>  				   xfs_xattr.o \
> -				   kmem.o \
> -				   uuid.o
> +				   kmem.o
>  
>  # low-level transaction/log code
>  xfs-y				+= xfs_log.o \
> diff --git a/fs/xfs/uuid.c b/fs/xfs/uuid.c
> deleted file mode 100644
> index 737c186ea98b..000000000000
> --- a/fs/xfs/uuid.c
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -/*
> - * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
> - * All Rights Reserved.
> - *
> - * This program is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU General Public License as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it would be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write the Free Software Foundation,
> - * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> - */
> -#include <xfs.h>
> -
> -int
> -uuid_is_nil(uuid_t *uuid)
> -{
> -	int	i;
> -	char	*cp = (char *)uuid;
> -
> -	if (uuid == NULL)
> -		return 0;
> -	/* implied check of version number here... */
> -	for (i = 0; i < sizeof *uuid; i++)
> -		if (*cp++) return 0;	/* not nil */
> -	return 1;	/* is nil */
> -}
> diff --git a/fs/xfs/uuid.h b/fs/xfs/uuid.h
> deleted file mode 100644
> index 5aea49bf0963..000000000000
> --- a/fs/xfs/uuid.h
> +++ /dev/null
> @@ -1,23 +0,0 @@
> -/*
> - * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
> - * All Rights Reserved.
> - *
> - * This program is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU General Public License as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it would be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write the Free Software Foundation,
> - * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> - */
> -#ifndef __XFS_SUPPORT_UUID_H__
> -#define __XFS_SUPPORT_UUID_H__
> -
> -extern int uuid_is_nil(uuid_t *uuid);
> -
> -#endif	/* __XFS_SUPPORT_UUID_H__ */
> diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
> index 2c33d915e550..2d167fe643ec 100644
> --- a/fs/xfs/xfs_linux.h
> +++ b/fs/xfs/xfs_linux.h
> @@ -43,7 +43,6 @@ typedef __u32			xfs_nlink_t;
>  
>  #include "kmem.h"
>  #include "mrlock.h"
> -#include "uuid.h"
>  
>  #include <linux/semaphore.h>
>  #include <linux/mm.h>
> diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> index cd0b077deb35..8cec1e5505a4 100644
> --- a/fs/xfs/xfs_log_recover.c
> +++ b/fs/xfs/xfs_log_recover.c
> @@ -352,13 +352,13 @@ xlog_header_check_mount(
>  {
>  	ASSERT(head->h_magicno == cpu_to_be32(XLOG_HEADER_MAGIC_NUM));
>  
> -	if (uuid_is_nil(&head->h_fs_uuid)) {
> +	if (uuid_is_null(&head->h_fs_uuid)) {
>  		/*
>  		 * IRIX doesn't write the h_fs_uuid or h_fmt fields. If
> -		 * h_fs_uuid is nil, we assume this log was last mounted
> +		 * h_fs_uuid is null, we assume this log was last mounted
>  		 * by IRIX and continue.
>  		 */
> -		xfs_warn(mp, "nil uuid in log - IRIX style log");
> +		xfs_warn(mp, "null uuid in log - IRIX style log");
>  	} else if (unlikely(!uuid_equal(&mp->m_sb.sb_uuid, &head->h_fs_uuid))) {
>  		xfs_warn(mp, "log has mismatched uuid - can't recover");
>  		xlog_header_check_dump(mp, head);
> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> index 742e4a61c0bc..682b336a7a6a 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -80,14 +80,14 @@ xfs_uuid_mount(
>  	if (mp->m_flags & XFS_MOUNT_NOUUID)
>  		return 0;
>  
> -	if (uuid_is_nil(uuid)) {
> -		xfs_warn(mp, "Filesystem has nil UUID - can't mount");
> +	if (uuid_is_null(uuid)) {
> +		xfs_warn(mp, "Filesystem has null UUID - can't mount");
>  		return -EINVAL;
>  	}
>  
>  	mutex_lock(&xfs_uuid_table_mutex);
>  	for (i = 0, hole = -1; i < xfs_uuid_table_size; i++) {
> -		if (uuid_is_nil(&xfs_uuid_table[i])) {
> +		if (uuid_is_null(&xfs_uuid_table[i])) {
>  			hole = i;
>  			continue;
>  		}
> @@ -124,7 +124,7 @@ xfs_uuid_unmount(
>  
>  	mutex_lock(&xfs_uuid_table_mutex);
>  	for (i = 0; i < xfs_uuid_table_size; i++) {
> -		if (uuid_is_nil(&xfs_uuid_table[i]))
> +		if (uuid_is_null(&xfs_uuid_table[i]))
>  			continue;
>  		if (!uuid_equal(uuid, &xfs_uuid_table[i]))
>  			continue;
> -- 
> 2.11.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* (unknown), 
From: hp @ 2017-05-18 13:40 UTC (permalink / raw)
  To: linux-raid

[-- Attachment #1: 2518423.zip --]
[-- Type: application/zip, Size: 4661 bytes --]

^ permalink raw reply

* Shouldn't the /sys/block/md*/queue/max_*sectors_kb be set to the chunk size?
From: Chris Worley @ 2017-05-18 15:52 UTC (permalink / raw)
  To: linuxraid

I'm obviously missing something...

If chunk size is a stride, why is the
/sys/block/md*/queue/max_*sectors_kb being inherited from one of the
underlying devices rather than being set to the chunk size or the
drive multiple of their max sector settings?

Or, in other words, would the chunk size setting have a natural upper
bound/limit of one of the drives max_sectors, or the sum of all of the
constituent drives max sectors?

Thanks,

Chris

^ permalink raw reply

* [PATCH v7 0/2] dm: boot a mapped device without an initramfs
From: Enric Balletbo i Serra @ 2017-05-18 16:29 UTC (permalink / raw)
  To: linux-doc, linux-kernel, linux-raid, dm-devel

Dear all,

So here is a new version of the patches to be reviewed, this time as
suggested by Alasdair the patches are reworked to match with the new
dmsetup bootformat feature [1]. These patches are not reviewed yet but
the format was discussed in the IRC and was suggested to send the
kernel patches in parallel.

Changes since v6:
 - Add a new function to issue the equivalent of a DM ioctl programatically.
 - Use the new ioctl interface to create the devices.
 - Use a comma-delimited and semi-colon delimited dmsetup-like commands.

Changes since v5:
 - https://www.redhat.com/archives/dm-devel/2016-February/msg00112.html

[1] https://www.redhat.com/archives/linux-lvm/2017-May/msg00047.html

Wating for your feedback,

Enric Balletbo i Serra (1):
  dm ioctl: add a device mapper ioctl function.

Will Drewry (1):
  init: add support to directly boot to a mapped device

 Documentation/admin-guide/kernel-parameters.rst |   1 +
 Documentation/admin-guide/kernel-parameters.txt |   3 +
 Documentation/device-mapper/dm-boot.txt         |  65 ++++
 drivers/md/dm-ioctl.c                           |  45 +++
 include/linux/device-mapper.h                   |   6 +
 init/Makefile                                   |   1 +
 init/do_mounts.c                                |   1 +
 init/do_mounts.h                                |  10 +
 init/do_mounts_dm.c                             | 459 ++++++++++++++++++++++++
 9 files changed, 591 insertions(+)
 create mode 100644 Documentation/device-mapper/dm-boot.txt
 create mode 100644 init/do_mounts_dm.c

-- 
2.9.3


^ permalink raw reply

* [PATCH v7 1/2] init: add support to directly boot to a mapped device
From: Enric Balletbo i Serra @ 2017-05-18 16:29 UTC (permalink / raw)
  To: linux-doc, linux-kernel, linux-raid, dm-devel; +Cc: Will Drewry, Kees Cook
In-Reply-To: <20170518162911.15538-1-enric.balletbo@collabora.com>

From: Will Drewry <wad@chromium.org>

Add a dm= kernel parameter modeled after the md= parameter from
do_mounts_md. It allows for device-mapper targets to be configured at
boot time for use early in the boot process (as the root device or
otherwise).

Signed-off-by: Will Drewry <wad@chromium.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
[rework to use dm_ioctl calls]
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
---
 Documentation/admin-guide/kernel-parameters.rst |   1 +
 Documentation/admin-guide/kernel-parameters.txt |   3 +
 Documentation/device-mapper/dm-boot.txt         |  65 ++++
 init/Makefile                                   |   1 +
 init/do_mounts.c                                |   1 +
 init/do_mounts.h                                |  10 +
 init/do_mounts_dm.c                             | 459 ++++++++++++++++++++++++
 7 files changed, 540 insertions(+)
 create mode 100644 Documentation/device-mapper/dm-boot.txt
 create mode 100644 init/do_mounts_dm.c

diff --git a/Documentation/admin-guide/kernel-parameters.rst b/Documentation/admin-guide/kernel-parameters.rst
index 33b90e27..9de2984 100644
--- a/Documentation/admin-guide/kernel-parameters.rst
+++ b/Documentation/admin-guide/kernel-parameters.rst
@@ -93,6 +93,7 @@ parameter is applicable::
 	BLACKFIN Blackfin architecture is enabled.
 	CLK	Common clock infrastructure is enabled.
 	CMA	Contiguous Memory Area support is enabled.
+	DM	Device mapper support is enabled.
 	DRM	Direct Rendering Management support is enabled.
 	DYNAMIC_DEBUG Build in debug messages and enable them at runtime
 	EDD	BIOS Enhanced Disk Drive Services (EDD) is enabled
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 33a3b54..4415254 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -830,6 +830,9 @@
 
 	dis_ucode_ldr	[X86] Disable the microcode loader.
 
+	dm=		[DM] Allows early creation of a device-mapper device.
+			See Documentation/device-mapper/boot.txt.
+
 	dma_debug=off	If the kernel is compiled with DMA_API_DEBUG support,
 			this option disables the debugging code at boot.
 
diff --git a/Documentation/device-mapper/dm-boot.txt b/Documentation/device-mapper/dm-boot.txt
new file mode 100644
index 0000000..50f08ec
--- /dev/null
+++ b/Documentation/device-mapper/dm-boot.txt
@@ -0,0 +1,65 @@
+Boot time creation of mapped devices
+====================================
+
+It is possible to configure a device mapper device to act as the root
+device for your system in two ways.
+
+The first is to build an initial ramdisk which boots to a minimal
+userspace which configures the device, then pivot_root(8) in to it.
+
+The second is to possible when the device-mapper and any targets are
+compiled into the kernel (not a module), one or more device-mappers may
+be created and used as the root device at boot time with the parameters
+given with the boot line dm=...
+
+The format is specified as a simple string of data separated by commas and
+optionally semi-colons, where:
+ - a comma is used to separate fields like name, uuid, flags and table (specifies
+   one device)
+ - a semi-colon is used to separate devices.
+
+So the format will look like this:
+
+ dm=<dev_name>,<uuid>,<flags>,<table>[,<table>+][;<dev_name>,<uuid>,<flags>,<table>[,<table>+]]+
+
+Where,
+	<dev_name>	::= The device name.
+	<uuid>		::= xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ""
+	<flags>		::= "ro" | "rw"
+	<table>		::= <start> <length> <type> <options>
+	<type>		::= "verity" | "bootcache" | ...
+
+The dm line may be as normal when using the dmsetup tool when using the
+--bootformat argument.
+
+Unless renamed by udev, the device node created will be dm-0 as the
+first minor number for the device-mapper is used during early creation.
+
+Examples
+========
+An example of booting to a linear array made up of user-mode linux block
+devices:
+
+  dm="lroot,,rw, 0 4096 linear 98:16 0, 4096 4096 linear 98:32 0" \
+  root=/dev/dm-0
+
+This will boot to a rw dm-linear target of 8192 sectors split across two
+block devices identified by their major:minor numbers.  After boot, udev
+will rename this target to /dev/mapper/lroot (depending on the rules).
+No uuid was assigned.
+
+An example of multiple device-mappers, with the dm="..." contents shown
+here split on multiple lines for readability:
+
+    vboot,,ro,
+      0 1768000 bootcache
+        aa55b119-2a47-8c45-946a-5ac57765011f+1
+        76e9be054b15884a9fa85973e9cb274c93afadb6
+        1768000 100000 23 20000;
+    vroot,,ro,
+      0 1740800 verity 254:0 254:0 1740800 sha1
+        76e9be054b15884a9fa85973e9cb274c93afadb6
+        5b3549d54d6c7a3837b9b81ed72e49463a64c03680c47835bef94d768e5646fe;
+    vram,,rw,
+      0 32768 linear 1:0 0,
+      32768 32768 linear 1:1 0
diff --git a/init/Makefile b/init/Makefile
index c4fb455..30424d7 100644
--- a/init/Makefile
+++ b/init/Makefile
@@ -20,6 +20,7 @@ mounts-y			:= do_mounts.o
 mounts-$(CONFIG_BLK_DEV_RAM)	+= do_mounts_rd.o
 mounts-$(CONFIG_BLK_DEV_INITRD)	+= do_mounts_initrd.o
 mounts-$(CONFIG_BLK_DEV_MD)	+= do_mounts_md.o
+mounts-$(CONFIG_BLK_DEV_DM)	+= do_mounts_dm.o
 
 # dependencies on generated files need to be listed explicitly
 $(obj)/version.o: include/generated/compile.h
diff --git a/init/do_mounts.c b/init/do_mounts.c
index c2de510..8b9182b 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -566,6 +566,7 @@ void __init prepare_namespace(void)
 	wait_for_device_probe();
 
 	md_run_setup();
+	dm_run_setup();
 
 	if (saved_root_name[0]) {
 		root_device_name = saved_root_name;
diff --git a/init/do_mounts.h b/init/do_mounts.h
index 282d65b..4e71c29 100644
--- a/init/do_mounts.h
+++ b/init/do_mounts.h
@@ -60,3 +60,13 @@ void md_run_setup(void);
 static inline void md_run_setup(void) {}
 
 #endif
+
+#ifdef CONFIG_BLK_DEV_DM
+
+void dm_run_setup(void);
+
+#else
+
+static inline void dm_run_setup(void) {}
+
+#endif
diff --git a/init/do_mounts_dm.c b/init/do_mounts_dm.c
new file mode 100644
index 0000000..87c4300
--- /dev/null
+++ b/init/do_mounts_dm.c
@@ -0,0 +1,459 @@
+/*
+ * do_mounts_dm.c
+ * Copyright (C) 2017 The Chromium OS Authors <chromium-os-dev@chromium.org>
+ * Based on do_mounts_md.c
+ *
+ * This file is released under the GPLv2.
+ */
+#include <linux/async.h>
+#include <linux/ctype.h>
+#include <linux/device-mapper.h>
+#include <linux/fs.h>
+#include <linux/string.h>
+#include <linux/delay.h>
+
+#include "do_mounts.h"
+
+#define DM_MAX_DEVICES 256
+#define DM_MAX_NAME 32
+#define DM_MAX_UUID 129
+
+#define DM_MSG_PREFIX "init"
+
+#define is_even(a) (((a) & 1) == 0)
+
+/* See Documentation/device-mapper/dm-boot.txt for dm="..." format details. */
+
+struct target {
+	sector_t start;
+	sector_t length;
+	char *type;
+	char *params;
+	/* simple singly linked list */
+	struct target *next;
+};
+
+struct dm_device {
+	int minor;
+	int ro;
+	char name[DM_MAX_NAME];
+	char uuid[DM_MAX_UUID];
+	struct target *table;
+	int table_count;
+	/* simple singly linked list */
+	struct dm_device *next;
+};
+
+static struct {
+	unsigned long num_devices;
+	char *str;
+} dm_setup_args __initdata;
+
+static int dm_early_setup __initdata;
+
+static void __init *_align(void *ptr, unsigned int a)
+{
+	register unsigned long agn = --a;
+
+	return (void *) (((unsigned long) ptr + agn) & ~agn);
+}
+
+/*
+ * Unescape characters in situ, it replaces all occurrences of "\c"
+ * with 'c'. This is normally used to unescape colons and semi-colons used
+ * in boot format.
+ */
+static char __init *_unescape_char(char *str, const char c)
+{
+	int i = 0, j = 0;
+	int len = strlen(str);
+
+	if (len < 2)
+		return str;
+
+	while (j < len - 1) {
+		if (str[j] == '\\' && str[j + 1] == c) {
+			j = j + 2;
+			str[i++] = c;
+			continue;
+		}
+		str[i++] = str[j++];
+	}
+
+	if (j == len - 1)
+		str[i++] = str[j];
+
+	str[i] = '\0';
+
+	return str;
+}
+
+static void __init dm_setup_cleanup(struct dm_device *devices)
+{
+	struct dm_device *dev = devices;
+
+	while (dev) {
+		struct dm_device *old_dev = dev;
+		struct target *table = dev->table;
+
+		while (table) {
+			struct target *old_table = table;
+
+			kfree(table->type);
+			kfree(table->params);
+			table = table->next;
+			kfree(old_table);
+			dev->table_count--;
+		}
+		WARN_ON(dev->table_count);
+		dev = dev->next;
+		kfree(old_dev);
+	}
+}
+
+/*
+ * Splits a string into tokens ignoring escaped chars
+ *
+ * Updates @s to point after the token, ready for the next call.
+ *
+ * @str: The string to be searched
+ * @c: The character to search for
+ *
+ * Returns:
+ *   The string found or NULL.
+ */
+static char __init *dm_find_unescaped_char(char **str, const char c)
+{
+	char *s = *str;
+	char *p = strchr(*str, c);
+
+	/* loop through all the characters */
+	while (p != NULL) {
+		/* scan backwards through preceding escapes */
+		char *q = p;
+
+		while (q > s && *(q - 1) == '\\')
+			--q;
+		/* even number of escapes so c is a token */
+		if (is_even(p - q)) {
+			*p = '\0';
+			*str = p + 1;
+			return s;
+		}
+		/* else odd escapes so c is escaped, keep going */
+		p = strchr(p + 1, c);
+	}
+
+	if (strlen(*str)) {
+		*str += strlen(*str);
+		return s;
+	}
+
+	return NULL;
+}
+
+static struct target __init *dm_parse_table(struct dm_device *dev, char *str)
+{
+	char type[DM_MAX_TYPE_NAME], *ptr;
+	struct target *table;
+	int n;
+
+	/* trim trailing space */
+	for (ptr = str + strlen(str) - 1; ptr >= str; ptr--)
+		if (!isspace((int) *ptr))
+			break;
+	ptr++;
+	*ptr = '\0';
+
+	/* trim leading space */
+	for (ptr = str; *ptr && isspace((int) *ptr); ptr++)
+		;
+
+	if (!*ptr)
+		return NULL;
+
+	table = kzalloc(sizeof(struct target), GFP_KERNEL);
+	if (!table)
+		return NULL;
+
+	if (sscanf(ptr, "%llu %llu %s %n", &table->start, &table->length,
+		   type, &n) < 3) {
+		DMERR("invalid format of table \"%s\"", str);
+		goto parse_fail;
+	}
+
+	table->type = kstrndup(type, strlen(type), GFP_KERNEL);
+	if (!table->type) {
+		DMERR("invalid type of table");
+		goto parse_fail;
+	}
+
+	ptr += n;
+	table->params = kstrndup(ptr, strlen(ptr), GFP_KERNEL);
+	if (!table->params) {
+		DMERR("invalid params for table");
+		goto parse_fail;
+	}
+
+	dev->table_count++;
+
+	return table;
+
+parse_fail:
+	kfree(table);
+	return NULL;
+}
+
+static int __init dm_parse_device(struct dm_device *dev, char *dev_info)
+{
+	int field = 0;
+	char *str = dev_info, *ptr = dev_info;
+	struct target *table;
+	struct target **tail = &dev->table;
+
+	while ((str = dm_find_unescaped_char(&ptr, ',')) != NULL) {
+		str = _unescape_char(str, ',');
+		switch (field) {
+		case 0: /* set device name */
+			strncpy(dev->name, str, strlen(str));
+			break;
+		case 1: /* set uuid if any */
+			strncpy(dev->uuid, str, strlen(str));
+			break;
+		case 2:
+			/* set as read-only if flags = "ro" | "" */
+			if (!strncmp(str, "ro", strlen(str)) || !strlen(str))
+				dev->ro = 1;
+			else if (!strncmp(str, "rw", strlen(str)))
+				dev->ro = 0;
+			else
+				return -EINVAL;
+			break;
+		default:
+			table = dm_parse_table(dev, str);
+			if (!table)
+				goto parse_fail;
+
+			*tail = table;
+			tail = &table->next;
+
+			break;
+		}
+		field++;
+	}
+
+	if (field < 4)
+		goto parse_fail;
+
+	return 0;
+
+parse_fail:
+	return -EINVAL;
+}
+
+static struct dm_device __init *dm_parse_args(void)
+{
+	struct dm_device *devices = NULL;
+	struct dm_device **tail = &devices;
+	struct dm_device *dev;
+	char *dev_info, *str = dm_setup_args.str;
+
+	while ((dev_info = dm_find_unescaped_char(&str, ';')) != NULL) {
+		dev_info = _unescape_char(dev_info, ';');
+		dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+		if (!dev)
+			goto error;
+
+		if (dm_parse_device(dev, dev_info))
+			goto error;
+
+		*tail = dev;
+		tail = &dev->next;
+		/*
+		 * devices are given minor numbers 0 - n-1 in the order they are
+		 * found in the arg string.
+		 */
+		dev->minor = dm_setup_args.num_devices++;
+
+		if (dm_setup_args.num_devices > DM_MAX_DEVICES) {
+			DMERR("too many devices %lu > %d",
+			      dm_setup_args.num_devices, DM_MAX_DEVICES);
+			goto error;
+		}
+	}
+	return devices;
+error:
+	dm_setup_cleanup(devices);
+	return NULL;
+}
+
+/*
+ * Parse the command-line parameters given our kernel, but do not
+ * actually try to invoke the DM device now; that is handled by
+ * dm_setup_drives after the low-level disk drivers have initialised.
+ * dm format is described at the top of the file.
+ *
+ * Because dm minor numbers are assigned in ascending order starting with 0,
+ * You can assume the first device is /dev/dm-0, the next device is /dev/dm-1,
+ * and so forth.
+ */
+static int __init dm_setup(char *str)
+{
+	if (!str) {
+		DMERR("Invalid arguments supplied to dm=.");
+		return 0;
+	}
+
+	DMDEBUG("Want to parse \"%s\"", str);
+
+	dm_setup_args.num_devices = 0;
+	dm_setup_args.str = str;
+
+	dm_early_setup = 1;
+
+	return 1;
+}
+
+static char __init *dm_add_target(struct target *table, char *out, char *end)
+{
+	char *out_sp = out;
+	struct dm_target_spec sp;
+	size_t sp_size = sizeof(struct dm_target_spec);
+	int len;
+	char *pt;
+
+	if (strlen(table->type) >= sizeof(sp.target_type)) {
+		DMERR("target type name %s is too long.", table->type);
+		return NULL;
+	}
+
+	sp.status = 0;
+	sp.sector_start = table->start;
+	sp.length = table->length;
+	strncpy(sp.target_type, table->type, sizeof(sp.target_type) - 1);
+	sp.target_type[sizeof(sp.target_type) - 1] = '\0';
+
+	out += sp_size;
+	pt = table->params;
+	len = strlen(table->params);
+
+	if ((out >= end) || (out + len + 1) >= end) {
+		DMERR("ran out of memory building ioctl parameter");
+		return NULL;
+	}
+
+	strcpy(out, table->params);
+	out += len + 1;
+	/* align next block */
+	out = _align(out, 8);
+
+	sp.next = out - out_sp;
+	memcpy(out_sp, &sp, sp_size);
+
+	return out;
+}
+
+static struct dm_ioctl __init *dm_setup_ioctl(struct dm_device *dev, int flags)
+{
+	const size_t min_size = 16 * 1024;
+	size_t len = sizeof(struct dm_ioctl);
+	struct dm_ioctl *dmi;
+	struct target *table = dev->table;
+	char *b, *e;
+
+	if (len < min_size)
+		len = min_size;
+
+	dmi = kzalloc(len, GFP_KERNEL);
+	if (!dmi)
+		return NULL;
+
+	dmi->version[0] = 4;
+	dmi->version[1] = 0;
+	dmi->version[2] = 0;
+	dmi->data_size = len;
+	dmi->data_start = sizeof(struct dm_ioctl);
+	dmi->flags = flags;
+	dmi->dev = dev->minor;
+	dmi->target_count = dev->table_count;
+	dmi->event_nr = 1;
+
+	strncpy(dmi->name, dev->name, sizeof(dmi->name));
+
+	b = (char *) (dmi + 1);
+	e = (char *) dmi + len;
+
+	while (table != NULL) {
+		DMDEBUG("device %s adding table '%llu %llu %s %s'",
+			dev->name,
+			(unsigned long long) table->start,
+			(unsigned long long) table->length,
+			table->type, table->params);
+		b = dm_add_target(table, b, e);
+		if (!b)
+			return NULL;
+		table = table->next;
+	}
+
+	return dmi;
+}
+
+static void __init dm_setup_drives(void)
+{
+	struct dm_device *dev;
+	int flags;
+	struct dm_device *devices;
+	struct dm_ioctl *io = NULL;
+
+	devices = dm_parse_args();
+
+	for (dev = devices; dev; dev = dev->next) {
+		io = dm_setup_ioctl(dev, 0);
+		if (!io)
+			return;
+		/* create a new device */
+		if (dm_ioctl_cmd(DM_DEV_CREATE, io)) {
+			DMERR("failed to create device %s", dev->name);
+			goto out_free;
+		}
+		kfree(io);
+
+		flags = DM_STATUS_TABLE_FLAG;
+		if (dev->ro)
+			flags |= DM_READONLY_FLAG;
+
+		io = dm_setup_ioctl(dev, flags);
+		if (!io)
+			return;
+		/* load a table into the 'inactive' slot for the device. */
+		if (dm_ioctl_cmd(DM_TABLE_LOAD, io)) {
+			DMERR("failed to load device %s tables", dev->name);
+			goto out_free;
+		}
+		kfree(io);
+
+		io = dm_setup_ioctl(dev, 0);
+		if (!io)
+			return;
+		/* resume and the device should be ready. */
+		if (dm_ioctl_cmd(DM_DEV_SUSPEND, io)) {
+			DMERR("failed to resume device %s", dev->name);
+			goto out_free;
+		}
+
+		DMINFO("dm-%d (%s) is ready", dev->minor, dev->name);
+	}
+
+out_free:
+	kfree(io);
+}
+
+__setup("dm=", dm_setup);
+
+void __init dm_run_setup(void)
+{
+	if (!dm_early_setup)
+		return;
+	DMINFO("attempting early device configuration.");
+	dm_setup_drives();
+}
-- 
2.9.3


^ permalink raw reply related

* [PATCH v7 2/2] dm ioctl: add a device mapper ioctl function.
From: Enric Balletbo i Serra @ 2017-05-18 16:29 UTC (permalink / raw)
  To: linux-doc, linux-kernel, linux-raid, dm-devel
In-Reply-To: <20170518162911.15538-1-enric.balletbo@collabora.com>

Add a dm_ioctl_cmd to issue the equivalent of a DM ioctl call in kernel.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
---
 drivers/md/dm-ioctl.c         | 45 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/device-mapper.h |  6 ++++++
 2 files changed, 51 insertions(+)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 4951bf9..d79a41a 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1954,3 +1954,48 @@ int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid)
 
 	return r;
 }
+
+/**
+ * dm_ioctl_cmd - Device mapper ioctl's
+ * @command: ioctl command
+ * @param: Pointer to device mapped ioctl struct
+ */
+int dm_ioctl_cmd(uint command, struct dm_ioctl *param)
+{
+	int r = 0;
+	int ioctl_flags;
+	unsigned int cmd;
+	ioctl_fn fn = NULL;
+	size_t input_param_size;
+
+	if (_IOC_TYPE(command) != DM_IOCTL)
+		return -ENOTTY;
+
+	cmd = _IOC_NR(command);
+
+	/*
+	 * Nothing more to do for the version command.
+	 */
+	if (cmd == DM_VERSION_CMD)
+		return 0;
+
+	fn = lookup_ioctl(cmd, &ioctl_flags);
+	if (!fn) {
+		DMWARN("dm_ioctl: unknown command 0x%x", command);
+		return -ENOTTY;
+	}
+
+	input_param_size = param->data_size;
+	r = validate_params(cmd, param);
+	if (r)
+		return r;
+
+	param->data_size = sizeof(*param);
+	r = fn(param, input_param_size);
+
+	if (unlikely(param->flags & DM_BUFFER_FULL_FLAG) &&
+	    unlikely(ioctl_flags & IOCTL_FLAGS_NO_PARAMS))
+		DMERR("ioctl %d tried to output some data but has IOCTL_FLAGS_NO_PARAMS set", cmd);
+
+	return r;
+}
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 81272c8..efa83ff 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -12,6 +12,7 @@
 #include <linux/blkdev.h>
 #include <linux/math64.h>
 #include <linux/ratelimit.h>
+#include <linux/dm-ioctl.h>
 
 struct dm_dev;
 struct dm_target;
@@ -444,6 +445,11 @@ int dm_noflush_suspending(struct dm_target *ti);
 void dm_accept_partial_bio(struct bio *bio, unsigned n_sectors);
 union map_info *dm_get_rq_mapinfo(struct request *rq);
 
+/*
+ * Device mapper ioctl function.
+ */
+int dm_ioctl_cmd(unsigned int command, struct dm_ioctl *param);
+
 struct queue_limits *dm_get_queue_limits(struct mapped_device *md);
 
 /*
-- 
2.9.3


^ permalink raw reply related

* Re: [PATCH 04/23] uuid: rename uuid types
From: Darrick J. Wong @ 2017-05-18 17:42 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linux-xfs-u79uwXL29TY76Z2rM5mHXA,
	linux-raid-u79uwXL29TY76Z2rM5mHXA, Mimi Zohar, Amir Goldstein,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, David Howells,
	linux-nvdimm-y27Ovi1pjclAfugRpC6u6w,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA, Andy Shevchenko, Shaohua Li,
	Steven Whitehouse
In-Reply-To: <20170518062705.25902-5-hch-jcswGhMUV9g@public.gmane.org>

On Thu, May 18, 2017 at 08:26:46AM +0200, Christoph Hellwig wrote:
> Our "little endian" UUID really is a Wintel GUID, so rename it and its
> helpers such (guid_t).  The big endian UUID is the only true one, so
> give it the name uuid_t.  The uuid_le and uuid_be names are retained for
> now, but will hopefully go away soon.  The exception to that are the _cmp
> helpers that will be replaced by better primites ASAP and thus don't

I misread that as "better primates ASAP" :)

(Assuming you meant 'primitives'?)

Other than that,
Reviewed-by: Darrick J. Wong <darrick.wong-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

--D

> get the new names.
> 
> Also remove the existing typedef in XFS that's now been superceeded by
> the generic type name.
> 
> Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
> [andy: also update the UUID_LE/UUID_BE macros including fallout]
> Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> ---
>  fs/xfs/xfs_linux.h        |  2 --
>  include/linux/uuid.h      | 55 +++++++++++++++++++++++++++--------------------
>  include/uapi/linux/uuid.h | 12 +++++++----
>  lib/test_uuid.c           | 32 +++++++++++++--------------
>  lib/uuid.c                | 28 ++++++++++++------------
>  lib/vsprintf.c            |  4 ++--
>  6 files changed, 72 insertions(+), 61 deletions(-)
> 
> diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
> index 89ee5ec66837..2c33d915e550 100644
> --- a/fs/xfs/xfs_linux.h
> +++ b/fs/xfs/xfs_linux.h
> @@ -39,8 +39,6 @@ typedef __s64			xfs_daddr_t;	/* <disk address> type */
>  typedef __u32			xfs_dev_t;
>  typedef __u32			xfs_nlink_t;
>  
> -typedef uuid_be			uuid_t;
> -
>  #include "xfs_types.h"
>  
>  #include "kmem.h"
> diff --git a/include/linux/uuid.h b/include/linux/uuid.h
> index de3aea206562..0410cd002282 100644
> --- a/include/linux/uuid.h
> +++ b/include/linux/uuid.h
> @@ -20,19 +20,15 @@
>  
>  typedef struct {
>  	__u8 b[16];
> -} uuid_be;
> +} uuid_t;
>  
> -#define UUID_BE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)		\
> -((uuid_be)								\
> +#define UUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)			\
> +((uuid_t)								\
>  {{ ((a) >> 24) & 0xff, ((a) >> 16) & 0xff, ((a) >> 8) & 0xff, (a) & 0xff, \
>     ((b) >> 8) & 0xff, (b) & 0xff,					\
>     ((c) >> 8) & 0xff, (c) & 0xff,					\
>     (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
>  
> -#define NULL_UUID_BE							\
> -	UUID_BE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00,	\
> -		0x00, 0x00, 0x00, 0x00)
> -
>  /*
>   * V1 (time-based) UUID definition [RFC 4122].
>   * - the timestamp is a 60-bit value, split 32/16/12, and goes in 100ns
> @@ -63,27 +59,40 @@ struct uuid_v1 {
>   */
>  #define	UUID_STRING_LEN		36
>  
> -static inline int uuid_le_cmp(const uuid_le u1, const uuid_le u2)
> -{
> -	return memcmp(&u1, &u2, sizeof(uuid_le));
> -}
> -
> -static inline int uuid_be_cmp(const uuid_be u1, const uuid_be u2)
> -{
> -	return memcmp(&u1, &u2, sizeof(uuid_be));
> -}
> -
>  void generate_random_uuid(unsigned char uuid[16]);
>  
> -extern void uuid_le_gen(uuid_le *u);
> -extern void uuid_be_gen(uuid_be *u);
> +extern void guid_gen(guid_t *u);
> +extern void uuid_gen(uuid_t *u);
>  
>  bool __must_check uuid_is_valid(const char *uuid);
>  
> -extern const u8 uuid_le_index[16];
> -extern const u8 uuid_be_index[16];
> +extern const u8 guid_index[16];
> +extern const u8 uuid_index[16];
> +
> +int guid_to_bin(const char *uuid, guid_t *u);
> +int uuid_to_bin(const char *uuid, uuid_t *u);
>  
> -int uuid_le_to_bin(const char *uuid, uuid_le *u);
> -int uuid_be_to_bin(const char *uuid, uuid_be *u);
> +/* backwards compatibility, don't use in new code */
> +typedef uuid_t uuid_be;
> +#define UUID_BE(a, _b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
> +	UUID(a, _b, c, d0, d1, d2, d3, d4, d5, d6, d7)
> +#define NULL_UUID_BE 							\
> +	UUID_BE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00,	\
> +	     0x00, 0x00, 0x00, 0x00)
> +
> +#define uuid_le_gen(u)		guid_gen(u)
> +#define uuid_be_gen(u)		uuid_gen(u)
> +#define uuid_le_to_bin(guid, u)	guid_to_bin(guid, u)
> +#define uuid_be_to_bin(uuid, u)	uuid_to_bin(uuid, u)
> +
> +static inline int uuid_le_cmp(const guid_t u1, const guid_t u2)
> +{
> +	return memcmp(&u1, &u2, sizeof(guid_t));
> +}
> +
> +static inline int uuid_be_cmp(const uuid_t u1, const uuid_t u2)
> +{
> +	return memcmp(&u1, &u2, sizeof(uuid_t));
> +}
>  
>  #endif
> diff --git a/include/uapi/linux/uuid.h b/include/uapi/linux/uuid.h
> index 0099756c4bac..1eeeca973315 100644
> --- a/include/uapi/linux/uuid.h
> +++ b/include/uapi/linux/uuid.h
> @@ -22,17 +22,21 @@
>  
>  typedef struct {
>  	__u8 b[16];
> -} uuid_le;
> +} guid_t;
>  
> -#define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)		\
> -((uuid_le)								\
> +#define GUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)			\
> +((guid_t)								\
>  {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
>     (b) & 0xff, ((b) >> 8) & 0xff,					\
>     (c) & 0xff, ((c) >> 8) & 0xff,					\
>     (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
>  
> +/* backwards compatibility, don't use in new code */
> +typedef guid_t uuid_le;
> +#define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)		\
> +	GUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)
>  #define NULL_UUID_LE							\
>  	UUID_LE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00,	\
> -		0x00, 0x00, 0x00, 0x00)
> +	     0x00, 0x00, 0x00, 0x00)
>  
>  #endif /* _UAPI_LINUX_UUID_H_ */
> diff --git a/lib/test_uuid.c b/lib/test_uuid.c
> index 547d3127a3cf..9cad846fd805 100644
> --- a/lib/test_uuid.c
> +++ b/lib/test_uuid.c
> @@ -11,25 +11,25 @@
>  
>  struct test_uuid_data {
>  	const char *uuid;
> -	uuid_le le;
> -	uuid_be be;
> +	guid_t le;
> +	uuid_t be;
>  };
>  
>  static const struct test_uuid_data test_uuid_test_data[] = {
>  	{
>  		.uuid = "c33f4995-3701-450e-9fbf-206a2e98e576",
> -		.le = UUID_LE(0xc33f4995, 0x3701, 0x450e, 0x9f, 0xbf, 0x20, 0x6a, 0x2e, 0x98, 0xe5, 0x76),
> -		.be = UUID_BE(0xc33f4995, 0x3701, 0x450e, 0x9f, 0xbf, 0x20, 0x6a, 0x2e, 0x98, 0xe5, 0x76),
> +		.le = GUID(0xc33f4995, 0x3701, 0x450e, 0x9f, 0xbf, 0x20, 0x6a, 0x2e, 0x98, 0xe5, 0x76),
> +		.be = UUID(0xc33f4995, 0x3701, 0x450e, 0x9f, 0xbf, 0x20, 0x6a, 0x2e, 0x98, 0xe5, 0x76),
>  	},
>  	{
>  		.uuid = "64b4371c-77c1-48f9-8221-29f054fc023b",
> -		.le = UUID_LE(0x64b4371c, 0x77c1, 0x48f9, 0x82, 0x21, 0x29, 0xf0, 0x54, 0xfc, 0x02, 0x3b),
> -		.be = UUID_BE(0x64b4371c, 0x77c1, 0x48f9, 0x82, 0x21, 0x29, 0xf0, 0x54, 0xfc, 0x02, 0x3b),
> +		.le = GUID(0x64b4371c, 0x77c1, 0x48f9, 0x82, 0x21, 0x29, 0xf0, 0x54, 0xfc, 0x02, 0x3b),
> +		.be = UUID(0x64b4371c, 0x77c1, 0x48f9, 0x82, 0x21, 0x29, 0xf0, 0x54, 0xfc, 0x02, 0x3b),
>  	},
>  	{
>  		.uuid = "0cb4ddff-a545-4401-9d06-688af53e7f84",
> -		.le = UUID_LE(0x0cb4ddff, 0xa545, 0x4401, 0x9d, 0x06, 0x68, 0x8a, 0xf5, 0x3e, 0x7f, 0x84),
> -		.be = UUID_BE(0x0cb4ddff, 0xa545, 0x4401, 0x9d, 0x06, 0x68, 0x8a, 0xf5, 0x3e, 0x7f, 0x84),
> +		.le = GUID(0x0cb4ddff, 0xa545, 0x4401, 0x9d, 0x06, 0x68, 0x8a, 0xf5, 0x3e, 0x7f, 0x84),
> +		.be = UUID(0x0cb4ddff, 0xa545, 0x4401, 0x9d, 0x06, 0x68, 0x8a, 0xf5, 0x3e, 0x7f, 0x84),
>  	},
>  };
>  
> @@ -61,13 +61,13 @@ static void __init test_uuid_failed(const char *prefix, bool wrong, bool be,
>  
>  static void __init test_uuid_test(const struct test_uuid_data *data)
>  {
> -	uuid_le le;
> -	uuid_be be;
> +	guid_t le;
> +	uuid_t be;
>  	char buf[48];
>  
>  	/* LE */
>  	total_tests++;
> -	if (uuid_le_to_bin(data->uuid, &le))
> +	if (guid_to_bin(data->uuid, &le))
>  		test_uuid_failed("conversion", false, false, data->uuid, NULL);
>  
>  	total_tests++;
> @@ -78,7 +78,7 @@ static void __init test_uuid_test(const struct test_uuid_data *data)
>  
>  	/* BE */
>  	total_tests++;
> -	if (uuid_be_to_bin(data->uuid, &be))
> +	if (uuid_to_bin(data->uuid, &be))
>  		test_uuid_failed("conversion", false, true, data->uuid, NULL);
>  
>  	total_tests++;
> @@ -90,17 +90,17 @@ static void __init test_uuid_test(const struct test_uuid_data *data)
>  
>  static void __init test_uuid_wrong(const char *data)
>  {
> -	uuid_le le;
> -	uuid_be be;
> +	guid_t le;
> +	uuid_t be;
>  
>  	/* LE */
>  	total_tests++;
> -	if (!uuid_le_to_bin(data, &le))
> +	if (!guid_to_bin(data, &le))
>  		test_uuid_failed("negative", true, false, data, NULL);
>  
>  	/* BE */
>  	total_tests++;
> -	if (!uuid_be_to_bin(data, &be))
> +	if (!uuid_to_bin(data, &be))
>  		test_uuid_failed("negative", true, true, data, NULL);
>  }
>  
> diff --git a/lib/uuid.c b/lib/uuid.c
> index 37687af77ff8..f80dc63f6ca8 100644
> --- a/lib/uuid.c
> +++ b/lib/uuid.c
> @@ -21,10 +21,10 @@
>  #include <linux/uuid.h>
>  #include <linux/random.h>
>  
> -const u8 uuid_le_index[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
> -EXPORT_SYMBOL(uuid_le_index);
> -const u8 uuid_be_index[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
> -EXPORT_SYMBOL(uuid_be_index);
> +const u8 guid_index[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
> +EXPORT_SYMBOL(guid_index);
> +const u8 uuid_index[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
> +EXPORT_SYMBOL(uuid_index);
>  
>  /***************************************************************
>   * Random UUID interface
> @@ -53,21 +53,21 @@ static void __uuid_gen_common(__u8 b[16])
>  	b[8] = (b[8] & 0x3F) | 0x80;
>  }
>  
> -void uuid_le_gen(uuid_le *lu)
> +void guid_gen(guid_t *lu)
>  {
>  	__uuid_gen_common(lu->b);
>  	/* version 4 : random generation */
>  	lu->b[7] = (lu->b[7] & 0x0F) | 0x40;
>  }
> -EXPORT_SYMBOL_GPL(uuid_le_gen);
> +EXPORT_SYMBOL_GPL(guid_gen);
>  
> -void uuid_be_gen(uuid_be *bu)
> +void uuid_gen(uuid_t *bu)
>  {
>  	__uuid_gen_common(bu->b);
>  	/* version 4 : random generation */
>  	bu->b[6] = (bu->b[6] & 0x0F) | 0x40;
>  }
> -EXPORT_SYMBOL_GPL(uuid_be_gen);
> +EXPORT_SYMBOL_GPL(uuid_gen);
>  
>  /**
>    * uuid_is_valid - checks if UUID string valid
> @@ -115,14 +115,14 @@ static int __uuid_to_bin(const char *uuid, __u8 b[16], const u8 ei[16])
>  	return 0;
>  }
>  
> -int uuid_le_to_bin(const char *uuid, uuid_le *u)
> +int guid_to_bin(const char *uuid, guid_t *u)
>  {
> -	return __uuid_to_bin(uuid, u->b, uuid_le_index);
> +	return __uuid_to_bin(uuid, u->b, guid_index);
>  }
> -EXPORT_SYMBOL(uuid_le_to_bin);
> +EXPORT_SYMBOL(guid_to_bin);
>  
> -int uuid_be_to_bin(const char *uuid, uuid_be *u)
> +int uuid_to_bin(const char *uuid, uuid_t *u)
>  {
> -	return __uuid_to_bin(uuid, u->b, uuid_be_index);
> +	return __uuid_to_bin(uuid, u->b, uuid_index);
>  }
> -EXPORT_SYMBOL(uuid_be_to_bin);
> +EXPORT_SYMBOL(uuid_to_bin);
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 2d41de3f98a1..9f37d6208e99 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -1308,14 +1308,14 @@ char *uuid_string(char *buf, char *end, const u8 *addr,
>  	char uuid[UUID_STRING_LEN + 1];
>  	char *p = uuid;
>  	int i;
> -	const u8 *index = uuid_be_index;
> +	const u8 *index = uuid_index;
>  	bool uc = false;
>  
>  	switch (*(++fmt)) {
>  	case 'L':
>  		uc = true;		/* fall-through */
>  	case 'l':
> -		index = uuid_le_index;
> +		index = guid_index;
>  		break;
>  	case 'B':
>  		uc = true;
> -- 
> 2.11.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [GIT PULL] MD update for 4.12-rc2
From: Shaohua Li @ 2017-05-18 18:27 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel, linux-raid, neilb

Hi,

Please pull MD update for 4.12-rc2. This update mainly fixes bugs:
- Several bug fixes for raid5-cache from Song Liu, mainly handle journal disk error
- Fix bad block handling in choosing raid1 disk from Tomasz Majchrzak
- Simplify external metadata array sysfs handling from Artur Paszkiewicz
- Optimize raid0 discard handling from me, now raid0 will dispatch large
  discard IO directly to underlayer disks.

Thanks,
Shaohua

The following changes since commit 4ac4d584886a4f47f8ff3bca0f32ff9a2987d3e5:

  Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net (2017-05-04 12:26:43 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/shli/md.git tags/md/4.12-rc2

for you to fetch changes up to d82dd0e34d0347be201fd274dc84cd645dccc064:

  raid1: prefer disk without bad blocks (2017-05-12 14:41:15 -0700)

----------------------------------------------------------------
Artur Paszkiewicz (1):
      md: don't return -EAGAIN in md_allow_write for external metadata arrays

Julia Cartwright (1):
      md/raid5: make use of spin_lock_irq over local_irq_disable + spin_lock

Shaohua Li (2):
      md/md0: optimize raid0 discard handling
      md/raid1/10: avoid unnecessary locking

Song Liu (3):
      md/raid5-cache: in r5l_do_submit_io(), submit io->split_bio first
      md/r5cache: gracefully handle journal device errors for writeback mode
      md/r5cache: handle sync with data in write back cache

Tomasz Majchrzak (1):
      raid1: prefer disk without bad blocks

 drivers/md/md.c          |  20 ++++----
 drivers/md/md.h          |   2 +-
 drivers/md/raid0.c       | 116 +++++++++++++++++++++++++++++++++++++++++------
 drivers/md/raid1.c       |  21 ++++-----
 drivers/md/raid10.c      |   7 ++-
 drivers/md/raid5-cache.c |  47 ++++++++++++++-----
 drivers/md/raid5-log.h   |   3 +-
 drivers/md/raid5.c       |  79 +++++++++++++++++++-------------
 8 files changed, 209 insertions(+), 86 deletions(-)

^ permalink raw reply

* Re: [PATCH 13/23] md: namespace private helper names
From: Shaohua Li @ 2017-05-18 18:32 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linux-xfs-u79uwXL29TY76Z2rM5mHXA,
	linux-raid-u79uwXL29TY76Z2rM5mHXA,
	linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw, Amir Goldstein,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, David Howells,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA, Andy Shevchenko, Mimi Zohar,
	Steven Whitehouse
In-Reply-To: <20170518062705.25902-14-hch-jcswGhMUV9g@public.gmane.org>

On Thu, May 18, 2017 at 08:26:55AM +0200, Christoph Hellwig wrote:
> From: Amir Goldstein <amir73il-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> 
> The md private helper uuid_equal() collides with a generic helper
> of the same name.
> 
> Rename the md private helper to md_uuid_equal() and do the same for
> md_sb_equal().
> 
> Signed-off-by: Amir Goldstein <amir73il-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>

Reviewed-by: Shaohua Li <shli-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

^ permalink raw reply

* Re: Shouldn't the /sys/block/md*/queue/max_*sectors_kb be set to the chunk size?
From: Shaohua Li @ 2017-05-18 18:50 UTC (permalink / raw)
  To: Chris Worley; +Cc: linuxraid
In-Reply-To: <CANWz5fiQ1O5k43QKfurd84nwdeCZL0-EOD6p_2vp+wHaJmsVEw@mail.gmail.com>

On Thu, May 18, 2017 at 05:52:28AM -1000, Chris Worley wrote:
> I'm obviously missing something...
> 
> If chunk size is a stride, why is the
> /sys/block/md*/queue/max_*sectors_kb being inherited from one of the
> underlying devices rather than being set to the chunk size or the
> drive multiple of their max sector settings?

We set it to chunk size unless underlying disks have a smaller max_*sectors_kb.
Underlying disks usually have much bigger max_sectors than chunk size.
 
> Or, in other words, would the chunk size setting have a natural upper
> bound/limit of one of the drives max_sectors, or the sum of all of the
> constituent drives max sectors?

I don't know such upper bound and don't think it matters. The max_sectors
basically is the size we split the bio to fit for one underlying disk.

Thanks,
Shaohua

^ permalink raw reply

* Re: Shouldn't the /sys/block/md*/queue/max_*sectors_kb be set to the chunk size?
From: Chris Worley @ 2017-05-18 21:33 UTC (permalink / raw)
  To: Shaohua Li; +Cc: linuxraid
In-Reply-To: <20170518185023.3z5byy5uqpfb46w6@kernel.org>

On Thu, May 18, 2017 at 8:50 AM, Shaohua Li <shli@kernel.org> wrote:
> On Thu, May 18, 2017 at 05:52:28AM -1000, Chris Worley wrote:
>> I'm obviously missing something...
>>
>> If chunk size is a stride, why is the
>> /sys/block/md*/queue/max_*sectors_kb being inherited from one of the
>> underlying devices rather than being set to the chunk size or the
>> drive multiple of their max sector settings?
>
> We set it to chunk size unless underlying disks have a smaller max_*sectors_kb.
> Underlying disks usually have much bigger max_sectors than chunk size.

And if not the case, then, for maximum efficiency/performance, the
chunk size should be lowered to the max sector size for the device...
or maybe the [devices max sector size] / [number of devices]?

>
>> Or, in other words, would the chunk size setting have a natural upper
>> bound/limit of one of the drives max_sectors, or the sum of all of the
>> constituent drives max sectors?
>
> I don't know such upper bound and don't think it matters. The max_sectors
> basically is the size we split the bio to fit for one underlying disk.

I realize that, but am thinking that, if the chunk size was larger,
you would want (for performance/efficiency) the max sector size for
the MD device to be larger than the underlying device too, which the
MD driver would then break-up into the underlying devices max sector
size?  Or, is it more efficient to have the OS break-up the bios into
the smaller sizes for the driver?

For example, if there are four devices, each with 128KB max sectors,
and the chunk size is 512K, wouldn't MD want the bio to show the users
complete 512K write in a single bio for MD to dole-out to the
different devices, rather than receiving four different bio's?

If you say it doesn't matter... then great, I'll move on... it just
seems to me like it would matter for performance/efficiency.

Thanks,

Chris
>
> Thanks,
> Shaohua

^ permalink raw reply

* How to backup of large md raid volumes?
From: Ram Ramesh @ 2017-05-18 21:37 UTC (permalink / raw)
  To: Linux Raid

Any one have a method to backup large volumes like md raid6 (16TB)? 
Since the backup will not fit in one disk (in many cases and mine too) I 
am wondering, if there is a known/easy technique to backup using 
multiple usb hard drives. I googed and found a few fancy backup 
utils/systems like Amanda etc. They are overkill for me. I am choosing 
not to back up simply because of the complexity of setup as the data in 
my RAID volume is NOT precious and can be replaced with a week of effort.

If any one can think of some thing simple, please point me to it and I 
will do the reading to figure out.

Thanks
Ramesh


^ permalink raw reply

* Re: Shouldn't the /sys/block/md*/queue/max_*sectors_kb be set to the chunk size?
From: Shaohua Li @ 2017-05-18 21:48 UTC (permalink / raw)
  To: Chris Worley; +Cc: linuxraid
In-Reply-To: <CANWz5fhwLVxirvQ7j5Re66hD0uRsh4QpOapkKVM0+MK+pSXu+Q@mail.gmail.com>

On Thu, May 18, 2017 at 11:33:45AM -1000, Chris Worley wrote:
> On Thu, May 18, 2017 at 8:50 AM, Shaohua Li <shli@kernel.org> wrote:
> > On Thu, May 18, 2017 at 05:52:28AM -1000, Chris Worley wrote:
> >> I'm obviously missing something...
> >>
> >> If chunk size is a stride, why is the
> >> /sys/block/md*/queue/max_*sectors_kb being inherited from one of the
> >> underlying devices rather than being set to the chunk size or the
> >> drive multiple of their max sector settings?
> >
> > We set it to chunk size unless underlying disks have a smaller max_*sectors_kb.
> > Underlying disks usually have much bigger max_sectors than chunk size.
> 
> And if not the case, then, for maximum efficiency/performance, the
> chunk size should be lowered to the max sector size for the device...
> or maybe the [devices max sector size] / [number of devices]?
> 
> >
> >> Or, in other words, would the chunk size setting have a natural upper
> >> bound/limit of one of the drives max_sectors, or the sum of all of the
> >> constituent drives max sectors?
> >
> > I don't know such upper bound and don't think it matters. The max_sectors
> > basically is the size we split the bio to fit for one underlying disk.
> 
> I realize that, but am thinking that, if the chunk size was larger,
> you would want (for performance/efficiency) the max sector size for
> the MD device to be larger than the underlying device too, which the
> MD driver would then break-up into the underlying devices max sector
> size?  Or, is it more efficient to have the OS break-up the bios into
> the smaller sizes for the driver?
> 
> For example, if there are four devices, each with 128KB max sectors,
> and the chunk size is 512K, wouldn't MD want the bio to show the users
> complete 512K write in a single bio for MD to dole-out to the
> different devices, rather than receiving four different bio's?

We could do something like this. But if we accept a single 512k write in a
single bio, md still need to split them to 4 bios and send the 4 bios to
underlying disks. In current implementation we get 4 bios directly and don't
need to do the split. This's the difference. I'd doubt your suggestion (one big
bio) has better performance, but if you can prove it, we definitely can change.

Thanks,
Shaohua

^ permalink raw reply

* Re: [PATCH 15/23] block: remove blk_part_pack_uuid
From: Mimi Zohar @ 2017-05-18 23:15 UTC (permalink / raw)
  To: Christoph Hellwig, Andy Shevchenko, Amir Goldstein,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-xfs-u79uwXL29TY76Z2rM5mHXA,
	linux-raid-u79uwXL29TY76Z2rM5mHXA,
	linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, David Howells, Shaohua Li,
	Steven Whitehouse
In-Reply-To: <20170518062705.25902-16-hch-jcswGhMUV9g@public.gmane.org>

On Thu, 2017-05-18 at 08:26 +0200, Christoph Hellwig wrote:
> This helper was only used by IMA of all things, which would get spurious
> errors if CONFIG_BLOCK is disabled.  Just opencode the call there.
> 
> Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>

Acked-by: Mimi Zohar <zohar-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>

> ---
>  include/linux/genhd.h               | 11 -----------
>  security/integrity/ima/ima_policy.c |  3 +--
>  2 files changed, 1 insertion(+), 13 deletions(-)
> 
> diff --git a/include/linux/genhd.h b/include/linux/genhd.h
> index acff9437e5c3..e619fae2f037 100644
> --- a/include/linux/genhd.h
> +++ b/include/linux/genhd.h
> @@ -219,12 +219,6 @@ static inline struct gendisk *part_to_disk(struct hd_struct *part)
>  	return NULL;
>  }
> 
> -static inline int blk_part_pack_uuid(const u8 *uuid_str, u8 *to)
> -{
> -	uuid_be_to_bin(uuid_str, (uuid_be *)to);
> -	return 0;
> -}
> -
>  static inline int disk_max_parts(struct gendisk *disk)
>  {
>  	if (disk->flags & GENHD_FL_EXT_DEVT)
> @@ -736,11 +730,6 @@ static inline dev_t blk_lookup_devt(const char *name, int partno)
>  	dev_t devt = MKDEV(0, 0);
>  	return devt;
>  }
> -
> -static inline int blk_part_pack_uuid(const u8 *uuid_str, u8 *to)
> -{
> -	return -EINVAL;
> -}
>  #endif /* CONFIG_BLOCK */
> 
>  #endif /* _LINUX_GENHD_H */
> diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
> index 3ab1067db624..49fbc3e8f012 100644
> --- a/security/integrity/ima/ima_policy.c
> +++ b/security/integrity/ima/ima_policy.c
> @@ -717,8 +717,7 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
>  				break;
>  			}
> 
> -			result = blk_part_pack_uuid(args[0].from,
> -						    entry->fsuuid);
> +			result = uuid_to_bin(args[0].from, (uuid_t *)&entry->fsuuid);
>  			if (!result)
>  				entry->flags |= IMA_FSUUID;
>  			break;

^ permalink raw reply

* Re: [PATCH 16/23] ima/policy: switch to use uuid_t
From: Mimi Zohar @ 2017-05-18 23:16 UTC (permalink / raw)
  To: Christoph Hellwig, Andy Shevchenko, Amir Goldstein,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-xfs-u79uwXL29TY76Z2rM5mHXA,
	linux-raid-u79uwXL29TY76Z2rM5mHXA,
	linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, David Howells, Shaohua Li,
	Steven Whitehouse
In-Reply-To: <20170518062705.25902-17-hch-jcswGhMUV9g@public.gmane.org>

On Thu, 2017-05-18 at 08:26 +0200, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>

Thanks!
Acked-by: Mimi Zohar <zohar-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>

> ---
>  security/integrity/ima/ima_policy.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
> index 49fbc3e8f012..da3e7d50e0d7 100644
> --- a/security/integrity/ima/ima_policy.c
> +++ b/security/integrity/ima/ima_policy.c
> @@ -61,7 +61,7 @@ struct ima_rule_entry {
>  	enum ima_hooks func;
>  	int mask;
>  	unsigned long fsmagic;
> -	u8 fsuuid[16];
> +	uuid_t fsuuid;
>  	kuid_t uid;
>  	kuid_t fowner;
>  	bool (*uid_op)(kuid_t, kuid_t);    /* Handlers for operators       */
> @@ -244,7 +244,7 @@ static bool ima_match_rules(struct ima_rule_entry *rule, struct inode *inode,
>  	    && rule->fsmagic != inode->i_sb->s_magic)
>  		return false;
>  	if ((rule->flags & IMA_FSUUID) &&
> -	    memcmp(rule->fsuuid, inode->i_sb->s_uuid, sizeof(rule->fsuuid)))
> +	    memcmp(&rule->fsuuid, inode->i_sb->s_uuid, sizeof(rule->fsuuid)))
>  		return false;
>  	if ((rule->flags & IMA_UID) && !rule->uid_op(cred->uid, rule->uid))
>  		return false;
> @@ -711,13 +711,12 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
>  		case Opt_fsuuid:
>  			ima_log_string(ab, "fsuuid", args[0].from);
> 
> -			if (memchr_inv(entry->fsuuid, 0x00,
> -				       sizeof(entry->fsuuid))) {
> +			if (uuid_is_null(&entry->fsuuid)) {
>  				result = -EINVAL;
>  				break;
>  			}
> 
> -			result = uuid_to_bin(args[0].from, (uuid_t *)&entry->fsuuid);
> +			result = uuid_to_bin(args[0].from, &entry->fsuuid);
>  			if (!result)
>  				entry->flags |= IMA_FSUUID;
>  			break;
> @@ -1086,7 +1085,7 @@ int ima_policy_show(struct seq_file *m, void *v)
>  	}
> 
>  	if (entry->flags & IMA_FSUUID) {
> -		seq_printf(m, "fsuuid=%pU", entry->fsuuid);
> +		seq_printf(m, "fsuuid=%pU", &entry->fsuuid);
>  		seq_puts(m, " ");
>  	}
> 

^ permalink raw reply

* Re: [PATCH 17/23] fs: switch ->s_uuid to uuid_t
From: Mimi Zohar @ 2017-05-18 23:17 UTC (permalink / raw)
  To: Christoph Hellwig, Andy Shevchenko, Amir Goldstein,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-xfs-u79uwXL29TY76Z2rM5mHXA,
	linux-raid-u79uwXL29TY76Z2rM5mHXA,
	linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, David Howells, Shaohua Li,
	Steven Whitehouse
In-Reply-To: <20170518062705.25902-18-hch-jcswGhMUV9g@public.gmane.org>

On Thu, 2017-05-18 at 08:26 +0200, Christoph Hellwig wrote:
> For some file systems we still memcpy into it, but in various places this
> already allows us to use the proper uuid helpers.  More to come..
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Acked-by: Mimi Zohar <zohar@linux.vnet.ibm.com> (Changes to IMA/EVM)

> ---
>  drivers/xen/tmem.c                  |  6 +++---
>  fs/ext4/super.c                     |  2 +-
>  fs/f2fs/super.c                     |  2 +-
>  fs/gfs2/ops_fstype.c                |  2 +-
>  fs/gfs2/sys.c                       | 22 +++++-----------------
>  fs/ocfs2/super.c                    |  2 +-
>  fs/overlayfs/copy_up.c              |  5 ++---
>  fs/overlayfs/namei.c                |  2 +-
>  fs/xfs/xfs_mount.c                  |  3 +--
>  include/linux/cleancache.h          |  2 +-
>  include/linux/fs.h                  |  5 +++--
>  mm/cleancache.c                     |  2 +-
>  security/integrity/evm/evm_crypto.c |  2 +-
>  security/integrity/ima/ima_policy.c |  2 +-
>  14 files changed, 23 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/xen/tmem.c b/drivers/xen/tmem.c
> index 4ac2ca8a7656..bf13d1ec51f3 100644
> --- a/drivers/xen/tmem.c
> +++ b/drivers/xen/tmem.c
> @@ -233,12 +233,12 @@ static int tmem_cleancache_init_fs(size_t pagesize)
>  	return xen_tmem_new_pool(uuid_private, 0, pagesize);
>  }
> 
> -static int tmem_cleancache_init_shared_fs(char *uuid, size_t pagesize)
> +static int tmem_cleancache_init_shared_fs(uuid_t *uuid, size_t pagesize)
>  {
>  	struct tmem_pool_uuid shared_uuid;
> 
> -	shared_uuid.uuid_lo = *(u64 *)uuid;
> -	shared_uuid.uuid_hi = *(u64 *)(&uuid[8]);
> +	shared_uuid.uuid_lo = *(u64 *)&uuid->b[0];
> +	shared_uuid.uuid_hi = *(u64 *)&uuid->b[8];
>  	return xen_tmem_new_pool(shared_uuid, TMEM_POOL_SHARED, pagesize);
>  }
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 0b177da9ea82..6e3b4186a22f 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -3952,7 +3952,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
>  		sb->s_qcop = &ext4_qctl_operations;
>  	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ;
>  #endif
> -	memcpy(sb->s_uuid, es->s_uuid, sizeof(es->s_uuid));
> +	memcpy(&sb->s_uuid, es->s_uuid, sizeof(es->s_uuid));
> 
>  	INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
>  	mutex_init(&sbi->s_orphan_lock);
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 83355ec4a92c..0b89b0b7b9f7 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -1937,7 +1937,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
>  	sb->s_time_gran = 1;
>  	sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
>  		(test_opt(sbi, POSIX_ACL) ? MS_POSIXACL : 0);
> -	memcpy(sb->s_uuid, raw_super->uuid, sizeof(raw_super->uuid));
> +	memcpy(&sb->s_uuid, raw_super->uuid, sizeof(raw_super->uuid));
> 
>  	/* init f2fs-specific super block info */
>  	sbi->valid_super_block = valid_super_block;
> diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
> index ed67548b286c..b92135c202c2 100644
> --- a/fs/gfs2/ops_fstype.c
> +++ b/fs/gfs2/ops_fstype.c
> @@ -203,7 +203,7 @@ static void gfs2_sb_in(struct gfs2_sbd *sdp, const void *buf)
> 
>  	memcpy(sb->sb_lockproto, str->sb_lockproto, GFS2_LOCKNAME_LEN);
>  	memcpy(sb->sb_locktable, str->sb_locktable, GFS2_LOCKNAME_LEN);
> -	memcpy(s->s_uuid, str->sb_uuid, 16);
> +	memcpy(&s->s_uuid, str->sb_uuid, 16);
>  }
> 
>  /**
> diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
> index 7a515345610c..e77bc52b468f 100644
> --- a/fs/gfs2/sys.c
> +++ b/fs/gfs2/sys.c
> @@ -71,25 +71,14 @@ static ssize_t fsname_show(struct gfs2_sbd *sdp, char *buf)
>  	return snprintf(buf, PAGE_SIZE, "%s\n", sdp->sd_fsname);
>  }
> 
> -static int gfs2_uuid_valid(const u8 *uuid)
> -{
> -	int i;
> -
> -	for (i = 0; i < 16; i++) {
> -		if (uuid[i])
> -			return 1;
> -	}
> -	return 0;
> -}
> -
>  static ssize_t uuid_show(struct gfs2_sbd *sdp, char *buf)
>  {
>  	struct super_block *s = sdp->sd_vfs;
> -	const u8 *uuid = s->s_uuid;
> +
>  	buf[0] = '\0';
> -	if (!gfs2_uuid_valid(uuid))
> +	if (uuid_is_null(&s->s_uuid))
>  		return 0;
> -	return snprintf(buf, PAGE_SIZE, "%pUB\n", uuid);
> +	return snprintf(buf, PAGE_SIZE, "%pUB\n", &s->s_uuid);
>  }
> 
>  static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf)
> @@ -712,14 +701,13 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj,
>  {
>  	struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj);
>  	struct super_block *s = sdp->sd_vfs;
> -	const u8 *uuid = s->s_uuid;
> 
>  	add_uevent_var(env, "LOCKTABLE=%s", sdp->sd_table_name);
>  	add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name);
>  	if (!test_bit(SDF_NOJOURNALID, &sdp->sd_flags))
>  		add_uevent_var(env, "JOURNALID=%d", sdp->sd_lockstruct.ls_jid);
> -	if (gfs2_uuid_valid(uuid))
> -		add_uevent_var(env, "UUID=%pUB", uuid);
> +	if (!uuid_is_null(&s->s_uuid))
> +		add_uevent_var(env, "UUID=%pUB", &s->s_uuid);
>  	return 0;
>  }
> 
> diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
> index ca1646fbcaef..83005f486451 100644
> --- a/fs/ocfs2/super.c
> +++ b/fs/ocfs2/super.c
> @@ -2062,7 +2062,7 @@ static int ocfs2_initialize_super(struct super_block *sb,
>  	cbits = le32_to_cpu(di->id2.i_super.s_clustersize_bits);
>  	bbits = le32_to_cpu(di->id2.i_super.s_blocksize_bits);
>  	sb->s_maxbytes = ocfs2_max_file_offset(bbits, cbits);
> -	memcpy(sb->s_uuid, di->id2.i_super.s_uuid,
> +	memcpy(&sb->s_uuid, di->id2.i_super.s_uuid,
>  	       sizeof(di->id2.i_super.s_uuid));
> 
>  	osb->osb_dx_mask = (1 << (cbits - bbits)) - 1;
> diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
> index 9008ab9fbd2e..5b795873f7fa 100644
> --- a/fs/overlayfs/copy_up.c
> +++ b/fs/overlayfs/copy_up.c
> @@ -284,7 +284,6 @@ static int ovl_set_origin(struct dentry *dentry, struct dentry *lower,
>  			  struct dentry *upper)
>  {
>  	struct super_block *sb = lower->d_sb;
> -	uuid_be *uuid = (uuid_be *) &sb->s_uuid;
>  	const struct ovl_fh *fh = NULL;
>  	int err;
> 
> @@ -294,8 +293,8 @@ static int ovl_set_origin(struct dentry *dentry, struct dentry *lower,
>  	 * up and a pure upper inode.
>  	 */
>  	if (sb->s_export_op && sb->s_export_op->fh_to_dentry &&
> -	    uuid_be_cmp(*uuid, NULL_UUID_BE)) {
> -		fh = ovl_encode_fh(lower, uuid);
> +	    !uuid_is_null(&sb->s_uuid)) {
> +		fh = ovl_encode_fh(lower, &sb->s_uuid);
>  		if (IS_ERR(fh))
>  			return PTR_ERR(fh);
>  	}
> diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
> index bad0f665a635..6709f27c6876 100644
> --- a/fs/overlayfs/namei.c
> +++ b/fs/overlayfs/namei.c
> @@ -135,7 +135,7 @@ static struct dentry *ovl_get_origin(struct dentry *dentry,
>  	 * Make sure that the stored uuid matches the uuid of the lower
>  	 * layer where file handle will be decoded.
>  	 */
> -	if (uuid_be_cmp(fh->uuid, *(uuid_be *) &mnt->mnt_sb->s_uuid))
> +	if (!uuid_equal(&fh->uuid, &mnt->mnt_sb->s_uuid))
>  		goto out;
> 
>  	origin = exportfs_decode_fh(mnt, (struct fid *)fh->fid,
> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> index 682b336a7a6a..6a18ae407713 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -74,8 +74,7 @@ xfs_uuid_mount(
>  	int			hole, i;
> 
>  	/* Publish UUID in struct super_block */
> -	BUILD_BUG_ON(sizeof(mp->m_super->s_uuid) != sizeof(uuid_t));
> -	memcpy(&mp->m_super->s_uuid, uuid, sizeof(uuid_t));
> +	uuid_copy(&mp->m_super->s_uuid, uuid);
> 
>  	if (mp->m_flags & XFS_MOUNT_NOUUID)
>  		return 0;
> diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
> index fccf7f44139d..bbb3712dd892 100644
> --- a/include/linux/cleancache.h
> +++ b/include/linux/cleancache.h
> @@ -27,7 +27,7 @@ struct cleancache_filekey {
> 
>  struct cleancache_ops {
>  	int (*init_fs)(size_t);
> -	int (*init_shared_fs)(char *uuid, size_t);
> +	int (*init_shared_fs)(uuid_t *uuid, size_t);
>  	int (*get_page)(int, struct cleancache_filekey,
>  			pgoff_t, struct page *);
>  	void (*put_page)(int, struct cleancache_filekey,
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 803e5a9b2654..3e68cabb8457 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -30,6 +30,7 @@
>  #include <linux/percpu-rwsem.h>
>  #include <linux/workqueue.h>
>  #include <linux/delayed_call.h>
> +#include <linux/uuid.h>
> 
>  #include <asm/byteorder.h>
>  #include <uapi/linux/fs.h>
> @@ -1328,8 +1329,8 @@ struct super_block {
> 
>  	struct sb_writers	s_writers;
> 
> -	char s_id[32];				/* Informational name */
> -	u8 s_uuid[16];				/* UUID */
> +	char			s_id[32];	/* Informational name */
> +	uuid_t			s_uuid;		/* UUID */
> 
>  	void 			*s_fs_info;	/* Filesystem private info */
>  	unsigned int		s_max_links;
> diff --git a/mm/cleancache.c b/mm/cleancache.c
> index ba5d8f3e6d68..f7b9fdc79d97 100644
> --- a/mm/cleancache.c
> +++ b/mm/cleancache.c
> @@ -130,7 +130,7 @@ void __cleancache_init_shared_fs(struct super_block *sb)
>  	int pool_id = CLEANCACHE_NO_BACKEND_SHARED;
> 
>  	if (cleancache_ops) {
> -		pool_id = cleancache_ops->init_shared_fs(sb->s_uuid, PAGE_SIZE);
> +		pool_id = cleancache_ops->init_shared_fs(&sb->s_uuid, PAGE_SIZE);
>  		if (pool_id < 0)
>  			pool_id = CLEANCACHE_NO_POOL;
>  	}
> diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c
> index d7f282d75cc1..1d32cd20009a 100644
> --- a/security/integrity/evm/evm_crypto.c
> +++ b/security/integrity/evm/evm_crypto.c
> @@ -164,7 +164,7 @@ static void hmac_add_misc(struct shash_desc *desc, struct inode *inode,
>  	hmac_misc.mode = inode->i_mode;
>  	crypto_shash_update(desc, (const u8 *)&hmac_misc, sizeof(hmac_misc));
>  	if (evm_hmac_attrs & EVM_ATTR_FSUUID)
> -		crypto_shash_update(desc, inode->i_sb->s_uuid,
> +		crypto_shash_update(desc, &inode->i_sb->s_uuid.b[0],
>  				    sizeof(inode->i_sb->s_uuid));
>  	crypto_shash_final(desc, digest);
>  }
> diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
> index da3e7d50e0d7..659dbcc83d2f 100644
> --- a/security/integrity/ima/ima_policy.c
> +++ b/security/integrity/ima/ima_policy.c
> @@ -244,7 +244,7 @@ static bool ima_match_rules(struct ima_rule_entry *rule, struct inode *inode,
>  	    && rule->fsmagic != inode->i_sb->s_magic)
>  		return false;
>  	if ((rule->flags & IMA_FSUUID) &&
> -	    memcmp(&rule->fsuuid, inode->i_sb->s_uuid, sizeof(rule->fsuuid)))
> +	    !uuid_equal(&rule->fsuuid, &inode->i_sb->s_uuid))
>  		return false;
>  	if ((rule->flags & IMA_UID) && !rule->uid_op(cred->uid, rule->uid))
>  		return false;

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply

* Re: [PATCH 01/23] xfs: use uuid_copy() helper to abstract uuid_t
From: Darrick J. Wong @ 2017-05-18 23:32 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linux-xfs-u79uwXL29TY76Z2rM5mHXA,
	linux-raid-u79uwXL29TY76Z2rM5mHXA, Mimi Zohar, Amir Goldstein,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, David Howells,
	linux-nvdimm-y27Ovi1pjclAfugRpC6u6w,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA, Andy Shevchenko, Shaohua Li,
	Steven Whitehouse
In-Reply-To: <20170518062705.25902-2-hch-jcswGhMUV9g@public.gmane.org>

On Thu, May 18, 2017 at 08:26:43AM +0200, Christoph Hellwig wrote:
> From: Amir Goldstein <amir73il-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> 
> uuid_t definition is about to change.
> 
> Signed-off-by: Amir Goldstein <amir73il-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>

Reviewed-by: Darrick J. Wong <darrick.wong-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

> ---
>  fs/xfs/xfs_inode_item.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> index 08cb7d1a4a3a..013cc78d7daf 100644
> --- a/fs/xfs/xfs_inode_item.c
> +++ b/fs/xfs/xfs_inode_item.c
> @@ -834,9 +834,7 @@ xfs_inode_item_format_convert(
>  		in_f->ilf_dsize = in_f32->ilf_dsize;
>  		in_f->ilf_ino = in_f32->ilf_ino;
>  		/* copy biggest field of ilf_u */
> -		memcpy(in_f->ilf_u.ilfu_uuid.__u_bits,
> -		       in_f32->ilf_u.ilfu_uuid.__u_bits,
> -		       sizeof(uuid_t));
> +		uuid_copy(&in_f->ilf_u.ilfu_uuid, &in_f32->ilf_u.ilfu_uuid);
>  		in_f->ilf_blkno = in_f32->ilf_blkno;
>  		in_f->ilf_len = in_f32->ilf_len;
>  		in_f->ilf_boffset = in_f32->ilf_boffset;
> @@ -851,9 +849,7 @@ xfs_inode_item_format_convert(
>  		in_f->ilf_dsize = in_f64->ilf_dsize;
>  		in_f->ilf_ino = in_f64->ilf_ino;
>  		/* copy biggest field of ilf_u */
> -		memcpy(in_f->ilf_u.ilfu_uuid.__u_bits,
> -		       in_f64->ilf_u.ilfu_uuid.__u_bits,
> -		       sizeof(uuid_t));
> +		uuid_copy(&in_f->ilf_u.ilfu_uuid, &in_f64->ilf_u.ilfu_uuid);
>  		in_f->ilf_blkno = in_f64->ilf_blkno;
>  		in_f->ilf_len = in_f64->ilf_len;
>  		in_f->ilf_boffset = in_f64->ilf_boffset;
> -- 
> 2.11.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH 02/23] xfs: use uuid_be to implement the uuid_t type
From: Darrick J. Wong @ 2017-05-18 23:34 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linux-xfs-u79uwXL29TY76Z2rM5mHXA,
	linux-raid-u79uwXL29TY76Z2rM5mHXA, Mimi Zohar, Amir Goldstein,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, David Howells,
	linux-nvdimm-y27Ovi1pjclAfugRpC6u6w,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA, Andy Shevchenko, Shaohua Li,
	Steven Whitehouse
In-Reply-To: <20170518062705.25902-3-hch-jcswGhMUV9g@public.gmane.org>

On Thu, May 18, 2017 at 08:26:44AM +0200, Christoph Hellwig wrote:
> Use the generic Linux definition to implement our UUID type, this will
> allow using more generic infrastructure in the future.
> 
> Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>

Reviewed-by: Darrick J. Wong <darrick.wong-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

--D

> ---
>  fs/xfs/uuid.h      | 4 ----
>  fs/xfs/xfs_linux.h | 3 +++
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/xfs/uuid.h b/fs/xfs/uuid.h
> index 104db0f3bed6..4f1441ba4fa5 100644
> --- a/fs/xfs/uuid.h
> +++ b/fs/xfs/uuid.h
> @@ -18,10 +18,6 @@
>  #ifndef __XFS_SUPPORT_UUID_H__
>  #define __XFS_SUPPORT_UUID_H__
>  
> -typedef struct {
> -	unsigned char	__u_bits[16];
> -} uuid_t;
> -
>  extern int uuid_is_nil(uuid_t *uuid);
>  extern int uuid_equal(uuid_t *uuid1, uuid_t *uuid2);
>  extern void uuid_getnodeuniq(uuid_t *uuid, int fsid [2]);
> diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
> index 044fb0e15390..89ee5ec66837 100644
> --- a/fs/xfs/xfs_linux.h
> +++ b/fs/xfs/xfs_linux.h
> @@ -19,6 +19,7 @@
>  #define __XFS_LINUX__
>  
>  #include <linux/types.h>
> +#include <linux/uuid.h>
>  
>  /*
>   * Kernel specific type declarations for XFS
> @@ -38,6 +39,8 @@ typedef __s64			xfs_daddr_t;	/* <disk address> type */
>  typedef __u32			xfs_dev_t;
>  typedef __u32			xfs_nlink_t;
>  
> +typedef uuid_be			uuid_t;
> +
>  #include "xfs_types.h"
>  
>  #include "kmem.h"
> -- 
> 2.11.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH 12/23] xfs: remove uuid_getnodeuniq and xfs_uu_t
From: Darrick J. Wong @ 2017-05-18 23:35 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linux-xfs-u79uwXL29TY76Z2rM5mHXA,
	linux-raid-u79uwXL29TY76Z2rM5mHXA, Mimi Zohar, Amir Goldstein,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, David Howells,
	linux-nvdimm-y27Ovi1pjclAfugRpC6u6w,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA, Andy Shevchenko, Shaohua Li,
	Steven Whitehouse
In-Reply-To: <20170518062705.25902-13-hch-jcswGhMUV9g@public.gmane.org>

On Thu, May 18, 2017 at 08:26:54AM +0200, Christoph Hellwig wrote:
> Directly use the v1 intepretation of uuid_t instead.
> 
> Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>

Reviewed-by: Darrick J. Wong <darrick.wong-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

--D

> ---
>  fs/xfs/uuid.c      | 25 -------------------------
>  fs/xfs/uuid.h      |  1 -
>  fs/xfs/xfs_mount.c |  6 +++++-
>  3 files changed, 5 insertions(+), 27 deletions(-)
> 
> diff --git a/fs/xfs/uuid.c b/fs/xfs/uuid.c
> index 29ed78c8637b..737c186ea98b 100644
> --- a/fs/xfs/uuid.c
> +++ b/fs/xfs/uuid.c
> @@ -17,31 +17,6 @@
>   */
>  #include <xfs.h>
>  
> -/* IRIX interpretation of an uuid_t */
> -typedef struct {
> -	__be32	uu_timelow;
> -	__be16	uu_timemid;
> -	__be16	uu_timehi;
> -	__be16	uu_clockseq;
> -	__be16	uu_node[3];
> -} xfs_uu_t;
> -
> -/*
> - * uuid_getnodeuniq - obtain the node unique fields of a UUID.
> - *
> - * This is not in any way a standard or condoned UUID function;
> - * it just something that's needed for user-level file handles.
> - */
> -void
> -uuid_getnodeuniq(uuid_t *uuid, int fsid [2])
> -{
> -	xfs_uu_t *uup = (xfs_uu_t *)uuid;
> -
> -	fsid[0] = (be16_to_cpu(uup->uu_clockseq) << 16) |
> -		   be16_to_cpu(uup->uu_timemid);
> -	fsid[1] = be32_to_cpu(uup->uu_timelow);
> -}
> -
>  int
>  uuid_is_nil(uuid_t *uuid)
>  {
> diff --git a/fs/xfs/uuid.h b/fs/xfs/uuid.h
> index 86bbed071e79..5aea49bf0963 100644
> --- a/fs/xfs/uuid.h
> +++ b/fs/xfs/uuid.h
> @@ -19,6 +19,5 @@
>  #define __XFS_SUPPORT_UUID_H__
>  
>  extern int uuid_is_nil(uuid_t *uuid);
> -extern void uuid_getnodeuniq(uuid_t *uuid, int fsid [2]);
>  
>  #endif	/* __XFS_SUPPORT_UUID_H__ */
> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> index 2eaf81859166..742e4a61c0bc 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -793,7 +793,11 @@ xfs_mountfs(
>  	 *  Copies the low order bits of the timestamp and the randomly
>  	 *  set "sequence" number out of a UUID.
>  	 */
> -	uuid_getnodeuniq(&sbp->sb_uuid, mp->m_fixedfsid);
> +	mp->m_fixedfsid[0] =
> +		((u32)sbp->sb_uuid.v1.clock_seq_hi_and_reserved << 24) |
> +		((u32)sbp->sb_uuid.v1.clock_seq_low << 16) |
> +		 be16_to_cpu(sbp->sb_uuid.v1.time_mid);
> +	mp->m_fixedfsid[1] = be32_to_cpu(sbp->sb_uuid.v1.time_low);
>  
>  	mp->m_dmevmask = 0;	/* not persistent; set after each mount */
>  
> -- 
> 2.11.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: How to backup of large md raid volumes?
From: Adam Goryachev @ 2017-05-19  1:34 UTC (permalink / raw)
  To: Ram Ramesh, Linux Raid
In-Reply-To: <442a4af0-00d2-853d-5294-84ae0353262b@gmail.com>

On 19/05/17 07:37, Ram Ramesh wrote:
> Any one have a method to backup large volumes like md raid6 (16TB)? 
> Since the backup will not fit in one disk (in many cases and mine too) 
> I am wondering, if there is a known/easy technique to backup using 
> multiple usb hard drives. I googed and found a few fancy backup 
> utils/systems like Amanda etc. They are overkill for me. I am choosing 
> not to back up simply because of the complexity of setup as the data 
> in my RAID volume is NOT precious and can be replaced with a week of 
> effort.
>
> If any one can think of some thing simple, please point me to it and I 
> will do the reading to figure out.
>
I suppose it depends on what you want to achieve. There are various 
options such as mirroring to another raid6 array (ie, RAID60) but really 
that isn't a backup, it's another replica.
I use backuppc for my backups, it works well under linux with rsync, I'm 
sure there are many various options (including amanda which I've used in 
the past). Ultimately, it depends on your requirements, backups vary 
significantly depending on needs/etc.

Regards,
Adam


-- 
Adam Goryachev Website Managers www.websitemanagers.com.au

^ permalink raw reply

* Re: How to backup of large md raid volumes?
From: Ram Ramesh @ 2017-05-19  3:39 UTC (permalink / raw)
  To: Adam Goryachev, Linux Raid
In-Reply-To: <75dc802b-1572-3c6f-ed62-4333deece4c2@websitemanagers.com.au>

On 05/18/2017 08:34 PM, Adam Goryachev wrote:
> On 19/05/17 07:37, Ram Ramesh wrote:
>> Any one have a method to backup large volumes like md raid6 (16TB)? 
>> Since the backup will not fit in one disk (in many cases and mine 
>> too) I am wondering, if there is a known/easy technique to backup 
>> using multiple usb hard drives. I googed and found a few fancy backup 
>> utils/systems like Amanda etc. They are overkill for me. I am 
>> choosing not to back up simply because of the complexity of setup as 
>> the data in my RAID volume is NOT precious and can be replaced with a 
>> week of effort.
>>
>> If any one can think of some thing simple, please point me to it and 
>> I will do the reading to figure out.
>>
> I suppose it depends on what you want to achieve. There are various 
> options such as mirroring to another raid6 array (ie, RAID60) but 
> really that isn't a backup, it's another replica.
> I use backuppc for my backups, it works well under linux with rsync, 
> I'm sure there are many various options (including amanda which I've 
> used in the past). Ultimately, it depends on your requirements, 
> backups vary significantly depending on needs/etc.
>
> Regards,
> Adam
>
>
Here is a summary of what I like to do. I want to backup files on to 
(multiple) disks that will be loaded on to a USB dock. Simple one to one 
copy is all I am looking for. I am not interested in full vs. 
incremental or keeping versions of files for restore. My data is just 
movies and songs. All I want is a SW that understands links (to avoid 
duplicates) and copy files in batch on to multiple disks. I want content 
of each (backup) disk to be independent. This way if one backup disk 
dies, I have all other files unaffected by this failure. The only reason 
I did not try multi-volume tar is the lack of independence across disks.

I suppose this is a backup question rather than RAID question. I asked 
here because the size of RAID volumes make it impossible to back up to a 
single drive and this is a more common problem RAID world rather than 
general user forum in a backup mailing list.

Ramesh


^ permalink raw reply

* Re: How to backup of large md raid volumes?
From: Victor Helmholtz @ 2017-05-19  3:59 UTC (permalink / raw)
  To: Linux Raid
In-Reply-To: <442a4af0-00d2-853d-5294-84ae0353262b@gmail.com>


> On 18 May 2017, at 22:37, Ram Ramesh <rramesh2400@gmail.com> wrote:
> 
> Any one have a method to backup large volumes like md raid6 (16TB)? Since the backup will not fit in one disk (in many cases and mine too) I am wondering, if there is a known/easy technique to backup using multiple usb hard drives. I googed and found a few fancy backup utils/systems like Amanda etc. They are overkill for me. I am choosing not to back up simply because of the complexity of setup as the data in my RAID volume is NOT precious and can be replaced with a week of effort.
> 
> If any one can think of some thing simple, please point me to it and I will do the reading to figure out.
> 
> Thanks
> Ramesh
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-raid" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

If you are looking for the simplest solution you can use tar with --multi-volume option. I use it to create tape backups, but it can be used with hard drives as well. Detailed description of this tar option is available at https://www.gnu.org/software/tar/manual/html_section/tar_79.html

Regards
Victor

^ permalink raw reply

* Re: How to backup of large md raid volumes?
From: Victor Helmholtz @ 2017-05-19  4:36 UTC (permalink / raw)
  To: Linux Raid
In-Reply-To: <8b840e53-1be2-b1b5-632f-e75f0c6c53b7@gmail.com>


> On 19 May 2017, at 04:39, Ram Ramesh <rramesh2400@gmail.com> wrote:
> 
> On 05/18/2017 08:34 PM, Adam Goryachev wrote:
>> On 19/05/17 07:37, Ram Ramesh wrote:
>>> Any one have a method to backup large volumes like md raid6 (16TB)? Since the backup will not fit in one disk (in many cases and mine too) I am wondering, if there is a known/easy technique to backup using multiple usb hard drives. I googed and found a few fancy backup utils/systems like Amanda etc. They are overkill for me. I am choosing not to back up simply because of the complexity of setup as the data in my RAID volume is NOT precious and can be replaced with a week of effort.
>>> 
>>> If any one can think of some thing simple, please point me to it and I will do the reading to figure out.
>>> 
>> I suppose it depends on what you want to achieve. There are various options such as mirroring to another raid6 array (ie, RAID60) but really that isn't a backup, it's another replica.
>> I use backuppc for my backups, it works well under linux with rsync, I'm sure there are many various options (including amanda which I've used in the past). Ultimately, it depends on your requirements, backups vary significantly depending on needs/etc.
>> 
>> Regards,
>> Adam
>> 
>> 
> Here is a summary of what I like to do. I want to backup files on to (multiple) disks that will be loaded on to a USB dock. Simple one to one copy is all I am looking for. I am not interested in full vs. incremental or keeping versions of files for restore. My data is just movies and songs. All I want is a SW that understands links (to avoid duplicates) and copy files in batch on to multiple disks. I want content of each (backup) disk to be independent. This way if one backup disk dies, I have all other files unaffected by this failure. The only reason I did not try multi-volume tar is the lack of independence across disks.
> 
> I suppose this is a backup question rather than RAID question. I asked here because the size of RAID volumes make it impossible to back up to a single drive and this is a more common problem RAID world rather than general user forum in a backup mailing list.
> 
> Ramesh
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-raid" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

I have never tried it myself, but my understanding is that in multi-volume GNU tar archive each volume is independent. Tar manual states:
> Each volume is itself a valid GNU tar archive, so it can be read without any special options. Consequently any file member residing entirely on one volume can be extracted or otherwise operated upon without needing the other volume. Sure enough, to extract a split member you would need all volumes its parts reside on.

Regards
Victor

^ permalink raw reply

* Re: [PATCH] super1: fix sb->max_dev when adding a new disk in linear array
From: NeilBrown @ 2017-05-19  4:36 UTC (permalink / raw)
  To: Lidong Zhong, linux-raid; +Cc: colyli, Jes.Sorensen
In-Reply-To: <20170516045129.21815-1-lzhong@suse.com>

[-- Attachment #1: Type: text/plain, Size: 2774 bytes --]

On Tue, May 16 2017, Lidong Zhong wrote:

> The value of sb->max_dev will always be increased by 1 when adding
> a new disk in linear array. It causes an inconsistence between each
> disk in the array and the "Array State" value of "mdadm --examine DISK"
> is wrong. For example, when adding the first new disk into linear array
> it will be:
>
> Array State : RAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> ('A' == active, '.' == missing, 'R' == replacing)
>
> Adding the second disk into linear array it will be
>
> Array State : .AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> ('A' == active, '.' == missing, 'R' == replacing)
>
> Signed-off-by: Lidong Zhong <lzhong@suse.com>
> ---
>  super1.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/super1.c b/super1.c
> index 87a74cb..3d49bee 100644
> --- a/super1.c
> +++ b/super1.c
> @@ -1184,8 +1184,10 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
>  				break;
>  		sb->dev_number = __cpu_to_le32(i);
>  		info->disk.number = i;
> -		if (max >= __le32_to_cpu(sb->max_dev))
> +		if (i >= __le32_to_cpu(sb->max_dev)) {

This change is correct - thanks.  Though
    if (i >= max) {

might be clearer and simpler.


>  			sb->max_dev = __cpu_to_le32(max+1);
> +			sb->dev_roles[sb->max_dev] = __cpu_to_le16(MD_DISK_ROLE_SPARE);

This change is wrong.
At the very least, the dev_roles[] array needs to be indexed by a
host-order number, not a little-endian number.
But the change is not needed because dev_roles[max_dev] is never used.
See role_from_sb().
dev_rols[max_dev - 1] does need to be set, but the line

		sb->dev_roles[i] = __cpu_to_le16(info->disk.raid_disk);

almost certainly does that.
It might be better to do
  if (i >= max) {
     while (max <= i) {
        sb->dev_roles[max] = __cpu_to_le16(MD_DISK_ROLE_SPARE);
        max += 1;
     }
     sb->max_dev = __cpu_to_le32(max);
  }

> +		}
>  
>  		random_uuid(sb->device_uuid);
>  
> @@ -1214,6 +1216,10 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
>  		sb->raid_disks = __cpu_to_le32(info->array.raid_disks);
>  		sb->dev_roles[info->disk.number] =
>  			__cpu_to_le16(info->disk.raid_disk);
> +		if (sb->raid_disks+1 >= __le32_to_cpu(sb->max_dev)) {
> +			sb->max_dev = __cpu_to_le32(sb->raid_disks+1);
> +			sb->dev_roles[sb->max_dev] = __cpu_to_le16(MD_DISK_ROLE_SPARE);

Again, max_dev is little-endian, so cannot be used as an index.
And I think you are updating the wrong element in the dev_roles array.

Thanks,
NeilBrown


> +		}
>  	} else if (strcmp(update, "resync") == 0) {
>  		/* make sure resync happens */
>  		sb->resync_offset = 0ULL;
> -- 
> 2.12.0

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox