All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 22/22] mpool: add Kconfig and Makefile
  2020-10-12 16:27 [PATCH v2 00/22] add Object Storage Media Pool (mpool) Nabeel M Mohamed
  2020-10-12 16:27   ` Nabeel M Mohamed
@ 2020-10-12 16:27   ` Nabeel M Mohamed
  0 siblings, 0 replies; 4+ messages in thread
From: Nabeel M Mohamed @ 2020-10-12 16:27 UTC (permalink / raw)
  To: linux-kernel, linux-block, linux-nvme, linux-mm, linux-nvdimm
  Cc: smoyer, gbecker, plabat, jgroves, Nabeel M Mohamed

This adds the Kconfig and Makefile for mpool.

Co-developed-by: Greg Becker <gbecker@micron.com>
Signed-off-by: Greg Becker <gbecker@micron.com>
Co-developed-by: Pierre Labat <plabat@micron.com>
Signed-off-by: Pierre Labat <plabat@micron.com>
Co-developed-by: John Groves <jgroves@micron.com>
Signed-off-by: John Groves <jgroves@micron.com>
Signed-off-by: Nabeel M Mohamed <nmeeramohide@micron.com>
---
 drivers/Kconfig        |  2 ++
 drivers/Makefile       |  1 +
 drivers/mpool/Kconfig  | 28 ++++++++++++++++++++++++++++
 drivers/mpool/Makefile | 11 +++++++++++
 4 files changed, 42 insertions(+)
 create mode 100644 drivers/mpool/Kconfig
 create mode 100644 drivers/mpool/Makefile

diff --git a/drivers/Kconfig b/drivers/Kconfig
index dcecc9f6e33f..547ac47a10eb 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -235,4 +235,6 @@ source "drivers/interconnect/Kconfig"
 source "drivers/counter/Kconfig"
 
 source "drivers/most/Kconfig"
+
+source "drivers/mpool/Kconfig"
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index c0cd1b9075e3..e2477288e761 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -188,3 +188,4 @@ obj-$(CONFIG_GNSS)		+= gnss/
 obj-$(CONFIG_INTERCONNECT)	+= interconnect/
 obj-$(CONFIG_COUNTER)		+= counter/
 obj-$(CONFIG_MOST)		+= most/
+obj-$(CONFIG_MPOOL)		+= mpool/
diff --git a/drivers/mpool/Kconfig b/drivers/mpool/Kconfig
new file mode 100644
index 000000000000..33380f497473
--- /dev/null
+++ b/drivers/mpool/Kconfig
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Object Storage Media Pool (mpool) configuration
+#
+
+config MPOOL
+	tristate "Object Storage Media Pool"
+	depends on BLOCK
+	default n
+	help
+	  This module implements a simple transactional object store on top of
+	  block storage devices.
+
+	  Mpool provides a high-performance alternative to file systems or
+	  raw block devices for applications that can benefit from its simple
+	  object storage model and unique features.
+
+	  If you want to use mpool, choose M here: the module will be called mpool.
+
+config MPOOL_ASSERT
+	bool "Object Storage Media Pool assert support"
+	depends on MPOOL
+	default n
+	help
+	  Enables runtime assertion checking for mpool.
+
+	  This is a developer only config. If this config is enabled and any of the
+	  asserts trigger, it results in a panic.
diff --git a/drivers/mpool/Makefile b/drivers/mpool/Makefile
new file mode 100644
index 000000000000..374bbe5bcfa0
--- /dev/null
+++ b/drivers/mpool/Makefile
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Makefile for Object Storage Media Pool (mpool)
+#
+
+obj-$(CONFIG_MPOOL) += mpool.o
+
+mpool-y             := init.o pd.o mclass.o smap.o omf.o \
+		       upgrade.o sb.o pmd_obj.o mblock.o  \
+		       mlog_utils.o mlog.o mdc.o mpcore.o pmd.o \
+		       mp.o mpctl.o sysfs.o mcache.o reaper.o
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 22/22] mpool: add Kconfig and Makefile
@ 2020-10-12 16:27   ` Nabeel M Mohamed
  0 siblings, 0 replies; 4+ messages in thread
From: Nabeel M Mohamed @ 2020-10-12 16:27 UTC (permalink / raw)
  To: linux-kernel, linux-block, linux-nvme, linux-mm, linux-nvdimm
  Cc: smoyer, gbecker, plabat, jgroves, Nabeel M Mohamed

This adds the Kconfig and Makefile for mpool.

Co-developed-by: Greg Becker <gbecker@micron.com>
Signed-off-by: Greg Becker <gbecker@micron.com>
Co-developed-by: Pierre Labat <plabat@micron.com>
Signed-off-by: Pierre Labat <plabat@micron.com>
Co-developed-by: John Groves <jgroves@micron.com>
Signed-off-by: John Groves <jgroves@micron.com>
Signed-off-by: Nabeel M Mohamed <nmeeramohide@micron.com>
---
 drivers/Kconfig        |  2 ++
 drivers/Makefile       |  1 +
 drivers/mpool/Kconfig  | 28 ++++++++++++++++++++++++++++
 drivers/mpool/Makefile | 11 +++++++++++
 4 files changed, 42 insertions(+)
 create mode 100644 drivers/mpool/Kconfig
 create mode 100644 drivers/mpool/Makefile

diff --git a/drivers/Kconfig b/drivers/Kconfig
index dcecc9f6e33f..547ac47a10eb 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -235,4 +235,6 @@ source "drivers/interconnect/Kconfig"
 source "drivers/counter/Kconfig"
 
 source "drivers/most/Kconfig"
+
+source "drivers/mpool/Kconfig"
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index c0cd1b9075e3..e2477288e761 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -188,3 +188,4 @@ obj-$(CONFIG_GNSS)		+= gnss/
 obj-$(CONFIG_INTERCONNECT)	+= interconnect/
 obj-$(CONFIG_COUNTER)		+= counter/
 obj-$(CONFIG_MOST)		+= most/
+obj-$(CONFIG_MPOOL)		+= mpool/
diff --git a/drivers/mpool/Kconfig b/drivers/mpool/Kconfig
new file mode 100644
index 000000000000..33380f497473
--- /dev/null
+++ b/drivers/mpool/Kconfig
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Object Storage Media Pool (mpool) configuration
+#
+
+config MPOOL
+	tristate "Object Storage Media Pool"
+	depends on BLOCK
+	default n
+	help
+	  This module implements a simple transactional object store on top of
+	  block storage devices.
+
+	  Mpool provides a high-performance alternative to file systems or
+	  raw block devices for applications that can benefit from its simple
+	  object storage model and unique features.
+
+	  If you want to use mpool, choose M here: the module will be called mpool.
+
+config MPOOL_ASSERT
+	bool "Object Storage Media Pool assert support"
+	depends on MPOOL
+	default n
+	help
+	  Enables runtime assertion checking for mpool.
+
+	  This is a developer only config. If this config is enabled and any of the
+	  asserts trigger, it results in a panic.
diff --git a/drivers/mpool/Makefile b/drivers/mpool/Makefile
new file mode 100644
index 000000000000..374bbe5bcfa0
--- /dev/null
+++ b/drivers/mpool/Makefile
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Makefile for Object Storage Media Pool (mpool)
+#
+
+obj-$(CONFIG_MPOOL) += mpool.o
+
+mpool-y             := init.o pd.o mclass.o smap.o omf.o \
+		       upgrade.o sb.o pmd_obj.o mblock.o  \
+		       mlog_utils.o mlog.o mdc.o mpcore.o pmd.o \
+		       mp.o mpctl.o sysfs.o mcache.o reaper.o
-- 
2.17.2
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 22/22] mpool: add Kconfig and Makefile
@ 2020-10-12 16:27   ` Nabeel M Mohamed
  0 siblings, 0 replies; 4+ messages in thread
From: Nabeel M Mohamed @ 2020-10-12 16:27 UTC (permalink / raw)
  To: linux-kernel, linux-block, linux-nvme, linux-mm, linux-nvdimm
  Cc: plabat, smoyer, jgroves, gbecker, Nabeel M Mohamed

This adds the Kconfig and Makefile for mpool.

Co-developed-by: Greg Becker <gbecker@micron.com>
Signed-off-by: Greg Becker <gbecker@micron.com>
Co-developed-by: Pierre Labat <plabat@micron.com>
Signed-off-by: Pierre Labat <plabat@micron.com>
Co-developed-by: John Groves <jgroves@micron.com>
Signed-off-by: John Groves <jgroves@micron.com>
Signed-off-by: Nabeel M Mohamed <nmeeramohide@micron.com>
---
 drivers/Kconfig        |  2 ++
 drivers/Makefile       |  1 +
 drivers/mpool/Kconfig  | 28 ++++++++++++++++++++++++++++
 drivers/mpool/Makefile | 11 +++++++++++
 4 files changed, 42 insertions(+)
 create mode 100644 drivers/mpool/Kconfig
 create mode 100644 drivers/mpool/Makefile

diff --git a/drivers/Kconfig b/drivers/Kconfig
index dcecc9f6e33f..547ac47a10eb 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -235,4 +235,6 @@ source "drivers/interconnect/Kconfig"
 source "drivers/counter/Kconfig"
 
 source "drivers/most/Kconfig"
+
+source "drivers/mpool/Kconfig"
 endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index c0cd1b9075e3..e2477288e761 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -188,3 +188,4 @@ obj-$(CONFIG_GNSS)		+= gnss/
 obj-$(CONFIG_INTERCONNECT)	+= interconnect/
 obj-$(CONFIG_COUNTER)		+= counter/
 obj-$(CONFIG_MOST)		+= most/
+obj-$(CONFIG_MPOOL)		+= mpool/
diff --git a/drivers/mpool/Kconfig b/drivers/mpool/Kconfig
new file mode 100644
index 000000000000..33380f497473
--- /dev/null
+++ b/drivers/mpool/Kconfig
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Object Storage Media Pool (mpool) configuration
+#
+
+config MPOOL
+	tristate "Object Storage Media Pool"
+	depends on BLOCK
+	default n
+	help
+	  This module implements a simple transactional object store on top of
+	  block storage devices.
+
+	  Mpool provides a high-performance alternative to file systems or
+	  raw block devices for applications that can benefit from its simple
+	  object storage model and unique features.
+
+	  If you want to use mpool, choose M here: the module will be called mpool.
+
+config MPOOL_ASSERT
+	bool "Object Storage Media Pool assert support"
+	depends on MPOOL
+	default n
+	help
+	  Enables runtime assertion checking for mpool.
+
+	  This is a developer only config. If this config is enabled and any of the
+	  asserts trigger, it results in a panic.
diff --git a/drivers/mpool/Makefile b/drivers/mpool/Makefile
new file mode 100644
index 000000000000..374bbe5bcfa0
--- /dev/null
+++ b/drivers/mpool/Makefile
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Makefile for Object Storage Media Pool (mpool)
+#
+
+obj-$(CONFIG_MPOOL) += mpool.o
+
+mpool-y             := init.o pd.o mclass.o smap.o omf.o \
+		       upgrade.o sb.o pmd_obj.o mblock.o  \
+		       mlog_utils.o mlog.o mdc.o mpcore.o pmd.o \
+		       mp.o mpctl.o sysfs.o mcache.o reaper.o
-- 
2.17.2


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 22/22] mpool: add Kconfig and Makefile
@ 2020-10-23  0:30 kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2020-10-23  0:30 UTC (permalink / raw)
  To: kbuild

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

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20201012162736.65241-23-nmeeramohide@micron.com>
References: <20201012162736.65241-23-nmeeramohide@micron.com>
TO: Nabeel M Mohamed <nmeeramohide@micron.com>
TO: linux-kernel(a)vger.kernel.org
TO: linux-block(a)vger.kernel.org
TO: linux-nvme(a)lists.infradead.org
TO: linux-mm(a)kvack.org
TO: linux-nvdimm(a)lists.01.org
CC: smoyer(a)micron.com
CC: gbecker(a)micron.com
CC: plabat(a)micron.com
CC: jgroves(a)micron.com
CC: Nabeel M Mohamed <nmeeramohide@micron.com>

Hi Nabeel,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on linux/master v5.9 next-20201022]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Nabeel-M-Mohamed/add-Object-Storage-Media-Pool-mpool/20201013-002941
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git bbf5c979011a099af5dc76498918ed7df445635b
:::::: branch date: 10 days ago
:::::: commit date: 10 days ago
config: x86_64-randconfig-m001-20201022 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/mpool/pd.c:110 pd_bio_discard() warn: should '1 << (dparm->dpr_prop.pdp_sectorsz)' be a 64 bit type?
drivers/mpool/pd.c:239 pd_bio_rw() warn: should '1 << (dparm->dpr_prop.pdp_sectorsz)' be a 64 bit type?
drivers/mpool/pd.c:258 pd_bio_rw() warn: argument 6 to %lx specifier is cast from pointer
drivers/mpool/smap.c:424 smap_alloc() error: double unlocked '*rmlock' (orig line 413)
drivers/mpool/mlog.c:66 mlog_alloc_cmn() error: we previously assumed 'layout' could be null (see line 45)
drivers/mpool/pmd.c:1940 pmd_mdc_cap() warn: should '(layout->eld_ld.ol_zcnt * zonepg) << 12' be a 64 bit type?
drivers/mpool/mpctl.c:2596 mpc_ioctl() warn: possible memory leak of 'argp'

Old smatch warnings:
drivers/mpool/smap.c:446 smap_alloc() error: double unlocked '*rmlock' (orig line 413)
drivers/mpool/smap.c:457 smap_alloc() error: double unlocked '*rmlock' (orig line 413)

vim +110 drivers/mpool/pd.c

93efb0dc85ec75d Nabeel M Mohamed 2020-10-12   88  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12   89  /**
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12   90   * pd_bio_discard() - issue discard command to erase a byte-aligned region
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12   91   * @dparm:
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12   92   * @off:
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12   93   * @len:
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12   94   */
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12   95  static int pd_bio_discard(struct pd_dev_parm *dparm, loff_t off, size_t len)
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12   96  {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12   97  	struct block_device *bdev;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12   98  	int rc;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12   99  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  100  	bdev = dparm->dpr_dev_private;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  101  	if (!bdev) {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  102  		rc = -EINVAL;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  103  		mp_pr_err("bdev %s not registered", rc, dparm->dpr_name);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  104  		return rc;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  105  	}
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  106  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  107  	/* Validate I/O offset is sector-aligned */
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  108  	if (off & PD_SECTORMASK(&dparm->dpr_prop)) {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  109  		rc = -EINVAL;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12 @110  		mp_pr_err("bdev %s, offset 0x%lx not multiple of sec size %u",
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  111  			  rc, dparm->dpr_name, (ulong)off, (1 << PD_SECTORSZ(&dparm->dpr_prop)));
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  112  		return rc;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  113  	}
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  114  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  115  	if (off > PD_LEN(&dparm->dpr_prop)) {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  116  		rc = -EINVAL;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  117  		mp_pr_err("bdev %s, offset 0x%lx past end 0x%lx",
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  118  			  rc, dparm->dpr_name, (ulong)off, (ulong)PD_LEN(&dparm->dpr_prop));
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  119  		return rc;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  120  	}
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  121  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  122  	rc = blkdev_issue_discard(bdev, off >> SECTOR_SHIFT, len >> SECTOR_SHIFT, GFP_NOIO, 0);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  123  	if (rc)
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  124  		mp_pr_err("bdev %s, offset 0x%lx len 0x%lx, discard faiure",
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  125  			  rc, dparm->dpr_name, (ulong)off, (ulong)len);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  126  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  127  	return rc;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  128  }
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  129  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  130  /**
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  131   * pd_zone_erase() - issue write-zeros or discard commands to erase PD
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  132   * @dparm:
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  133   * @zaddr:
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  134   * @zonecnt:
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  135   * @flag:
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  136   * @afp:
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  137   */
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  138  int pd_zone_erase(struct pd_dev_parm *dparm, u64 zaddr, u32 zonecnt, bool reads_erased)
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  139  {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  140  	int rc = 0;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  141  	u64 cmdopt;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  142  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  143  	/* Validate args against zone param */
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  144  	if (zaddr >= dparm->dpr_zonetot)
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  145  		return -EINVAL;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  146  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  147  	if (zonecnt == 0)
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  148  		zonecnt = dparm->dpr_zonetot - zaddr;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  149  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  150  	if (zonecnt > (dparm->dpr_zonetot - zaddr))
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  151  		return -EINVAL;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  152  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  153  	if (zonecnt == 0)
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  154  		return 0;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  155  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  156  	/*
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  157  	 * When both DIF and SED are enabled, read from a discared block
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  158  	 * would fail, so we can't discard blocks if both DIF and SED are
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  159  	 * enabled AND we need to read blocks after erase.
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  160  	 */
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  161  	cmdopt = dparm->dpr_cmdopt;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  162  	if ((cmdopt & PD_CMD_DISCARD) &&
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  163  	    !(reads_erased && (cmdopt & PD_CMD_DIF_ENABLED) && (cmdopt & PD_CMD_SED_ENABLED))) {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  164  		size_t zlen;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  165  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  166  		zlen = dparm->dpr_zonepg << PAGE_SHIFT;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  167  		rc = pd_bio_discard(dparm, zaddr * zlen, zonecnt * zlen);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  168  	}
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  169  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  170  	return rc;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  171  }
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  172  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  173  static void pd_bio_init(struct bio *bio, struct block_device *bdev, int rw, loff_t off, int flags)
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  174  {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  175  	bio_set_op_attrs(bio, rw, flags);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  176  	bio->bi_iter.bi_sector = off >> SECTOR_SHIFT;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  177  	bio_set_dev(bio, bdev);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  178  }
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  179  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  180  static struct bio *pd_bio_chain(struct bio *target, unsigned int nr_pages, gfp_t gfp)
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  181  {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  182  	struct bio *new;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  183  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  184  	new = bio_alloc_bioset(gfp, nr_pages, &mpool_bioset);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  185  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  186  	if (!target)
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  187  		return new;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  188  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  189  	if (new) {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  190  		bio_chain(target, new);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  191  		submit_bio(target);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  192  	} else {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  193  		submit_bio_wait(target);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  194  		bio_put(target);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  195  	}
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  196  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  197  	return new;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  198  }
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  199  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  200  /**
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  201   * pd_bio_rw() -
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  202   * @dparm:
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  203   * @iov:
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  204   * @iovcnt:
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  205   * @off: offset in bytes on disk
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  206   * @rw:
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  207   * @opflags:
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  208   *
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  209   * pd_bio_rw() expects a list of kvecs wherein each base ptr is sector
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  210   * aligned and each length is multiple of sectors.
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  211   *
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  212   * If the IO is bigger than 1MiB (BIO_MAX_PAGES pages) or chunk_size_kb,
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  213   * it is split in several IOs.
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  214   */
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  215  static int pd_bio_rw(struct pd_dev_parm *dparm, const struct kvec *iov,
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  216  		     int iovcnt, loff_t off, int rw, int opflags)
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  217  {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  218  	struct block_device *bdev;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  219  	struct page *page;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  220  	struct bio *bio;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  221  	uintptr_t iov_base;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  222  	u64 sector_mask;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  223  	u32 tot_pages, tot_len, len, iov_len, left, iolimit;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  224  	int i, cc, rc = 0;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  225  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  226  	if (iovcnt < 1)
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  227  		return 0;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  228  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  229  	bdev = dparm->dpr_dev_private;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  230  	if (!bdev) {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  231  		rc = -EINVAL;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  232  		mp_pr_err("bdev %s not registered", rc, dparm->dpr_name);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  233  		return rc;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  234  	}
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  235  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  236  	sector_mask = PD_SECTORMASK(&dparm->dpr_prop);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  237  	if (off & sector_mask) {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  238  		rc = -EINVAL;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12 @239  		mp_pr_err("bdev %s, %s offset 0x%lx not multiple of sector size %u",
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  240  			  rc, dparm->dpr_name, (rw == REQ_OP_READ) ? "read" : "write",
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  241  			  (ulong)off, (1 << PD_SECTORSZ(&dparm->dpr_prop)));
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  242  		return rc;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  243  	}
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  244  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  245  	if (off > PD_LEN(&dparm->dpr_prop)) {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  246  		rc = -EINVAL;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  247  		mp_pr_err("bdev %s, %s offset 0x%lx past device end 0x%lx",
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  248  			  rc, dparm->dpr_name, (rw == REQ_OP_READ) ? "read" : "write",
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  249  			  (ulong)off, (ulong)PD_LEN(&dparm->dpr_prop));
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  250  		return rc;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  251  	}
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  252  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  253  	tot_pages = 0;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  254  	tot_len = 0;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  255  	for (i = 0; i < iovcnt; i++) {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  256  		if (!PAGE_ALIGNED((uintptr_t)iov[i].iov_base) || (iov[i].iov_len & sector_mask)) {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  257  			rc = -EINVAL;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12 @258  			mp_pr_err("bdev %s, %s off 0x%lx, misaligned kvec, base 0x%lx, len 0x%lx",
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  259  				  rc, dparm->dpr_name, (rw == REQ_OP_READ) ? "read" : "write",
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  260  				  (ulong)off, (ulong)iov[i].iov_base, (ulong)iov[i].iov_len);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  261  			return rc;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  262  		}
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  263  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  264  		iov_len = iov[i].iov_len;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  265  		tot_len += iov_len;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  266  		while (iov_len > 0) {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  267  			len = min_t(size_t, PAGE_SIZE, iov_len);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  268  			iov_len -= len;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  269  			tot_pages++;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  270  		}
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  271  	}
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  272  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  273  	if (off + tot_len > PD_LEN(&dparm->dpr_prop)) {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  274  		rc = -EINVAL;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  275  		mp_pr_err("bdev %s, %s I/O end past device end 0x%lx, 0x%lx:0x%x",
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  276  			  rc, dparm->dpr_name, (rw == REQ_OP_READ) ? "read" : "write",
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  277  			  (ulong)PD_LEN(&dparm->dpr_prop), (ulong)off, tot_len);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  278  		return rc;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  279  	}
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  280  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  281  	if (tot_len == 0)
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  282  		return 0;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  283  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  284  	/* IO size for each bio is determined by the chunk size. */
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  285  	iolimit = chunk_size_kb >> (PAGE_SHIFT - 10);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  286  	iolimit = clamp_t(u32, iolimit, 32, BIO_MAX_PAGES);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  287  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  288  	left = 0;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  289  	bio = NULL;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  290  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  291  	for (i = 0; i < iovcnt; i++) {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  292  		iov_base = (uintptr_t)iov[i].iov_base;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  293  		iov_len = iov[i].iov_len;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  294  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  295  		while (iov_len > 0) {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  296  			if (left == 0) {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  297  				left = min_t(size_t, tot_pages, iolimit);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  298  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  299  				bio = pd_bio_chain(bio, left, GFP_NOIO);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  300  				if (!bio)
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  301  					return -ENOMEM;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  302  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  303  				pd_bio_init(bio, bdev, rw, off, opflags);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  304  			}
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  305  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  306  			len = min_t(size_t, PAGE_SIZE, iov_len);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  307  			page = virt_to_page(iov_base);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  308  			cc = -1;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  309  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  310  			if (page)
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  311  				cc = bio_add_page(bio, page, len, 0);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  312  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  313  			if (cc != len) {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  314  				if (cc == 0 && bio->bi_vcnt > 0) {
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  315  					left = 0;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  316  					continue;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  317  				}
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  318  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  319  				bio_io_error(bio);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  320  				bio_put(bio);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  321  				return -ENOTRECOVERABLE;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  322  			}
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  323  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  324  			iov_len -= len;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  325  			iov_base += len;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  326  			off += len;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  327  			left--;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  328  			tot_pages--;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  329  		}
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  330  	}
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  331  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  332  	ASSERT(bio);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  333  	ASSERT(tot_pages == 0);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  334  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  335  	rc = submit_bio_wait(bio);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  336  	bio_put(bio);
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  337  
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  338  	return rc;
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  339  }
93efb0dc85ec75d Nabeel M Mohamed 2020-10-12  340  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 36005 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-10-23  0:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-23  0:30 [PATCH v2 22/22] mpool: add Kconfig and Makefile kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2020-10-12 16:27 [PATCH v2 00/22] add Object Storage Media Pool (mpool) Nabeel M Mohamed
2020-10-12 16:27 ` [PATCH v2 22/22] mpool: add Kconfig and Makefile Nabeel M Mohamed
2020-10-12 16:27   ` Nabeel M Mohamed
2020-10-12 16:27   ` Nabeel M Mohamed

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.