All of lore.kernel.org
 help / color / mirror / Atom feed
* 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
* [PATCH v2 00/22] add Object Storage Media Pool (mpool)
@ 2020-10-12 16:27 Nabeel M Mohamed
  2020-10-12 16:27   ` Nabeel M Mohamed
  0 siblings, 1 reply; 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 patch series introduces the mpool object storage media pool driver.
Mpool implements a simple transactional object store on top of block
storage devices.

Mpool was developed for the Heterogeneous-Memory Storage Engine (HSE)
project, which is a high-performance key-value storage engine designed
for SSDs. HSE stores its data exclusively in mpool.

Mpool is readily applicable to other storage systems built on immutable
objects. For example, the many databases that store records in
immutable SSTables organized as an LSM-tree or similar data structure.

We developed mpool for HSE storage, versus using a file system or raw
block device, for several reasons.

A primary motivator was the need for a storage model that maps naturally
to conventional block storage devices, as well as to emerging device
interfaces we plan to support in the future, such as
* NVMe Zoned Namespaces (ZNS)
* NVMe Streams
* Persistent memory accessed via CXL or similar technologies

Another motivator was the need for a storage model that readily supports
multiple classes of storage devices or media in a single storage pool,
such as
* QLC SSDs for storing the bulk of objects, and
* 3DXP SSDs or persistent memory for storing objects requiring
  low-latency access

The mpool object storage model meets these needs. It also provides
other features that benefit storage systems built on immutable objects,
including
* Facilities to memory-map a specified collection of objects into a
  linear address space
* Concurrent access to object data directly and memory-mapped to greatly
  reduce page cache pollution from background operations such as
  LSM-tree compaction
* Proactive eviction of object data from the page cache, based on
  object-level metrics, to avoid excessive memory pressure and its
  associated performance impacts
* High concurrency and short code paths for efficient access to
  low-latency storage devices

HSE takes advantage of all these mpool features to achieve high
throughput with low tail-latencies.

Mpool is implemented as a character device driver where
* /dev/mpoolctl is the control file (minor number 0) supporting mpool
  management ioctls
* /dev/mpool/<mpool-name> are mpool files (minor numbers >0), one per
  mpool, supporting object management ioctls

CLI/UAPI access to /dev/mpoolctl and /dev/mpool/<mpool-name> are
controlled by their UID, GID, and mode bits. To provide a familiar look
and feel, the mpool management model and CLI are intentionally aligned
to those of LVM to the degree practical.

An mpool is created with a block storage device specified for its
required capacity media class, and optionally a second block storage
device specified for its staging media class. We recommend virtual
block devices (such as LVM logical volumes) to aggregate the performance
and capacity of multiple physical block devices, to enable sharing of
physical block devices between mpools (or for other uses), and to
support extending the size of a block device used for an mpool media
class. The libblkid library recognizes mpool formatted block devices as
of util-linux v2.32.

Mpool implements a transactional object store with two simple object
abstractions: mblocks and mlogs.

Mblock objects are containers comprising a linear sequence of bytes that
can be written exactly once, are immutable after writing, and can be
read in whole or in part as needed until deleted. Mblocks in a media
class are currently fixed size, which is configured when an mpool is
created, though the amount of data written to mblocks will differ.

Mlog objects are containers for record logging. Records of arbitrary
size can be appended to an mlog until it is full. Once full, an mlog
must be erased before additional records can be appended. Mlog records
can be read sequentially from the beginning at any time. Mlogs in a
media class are always a multiple of the mblock size for that media
class.

Mblock and mlog writes avoid the page cache. Mblocks are written,
committed, and made immutable before they can be read either directly
(avoiding the page cache) or mmaped. Mlogs are always read and updated
directly (avoiding the page cache) and cannot be mmaped.

Mpool also provides the metadata container (MDC) APIs that clients can
use to simplify storing and maintaining metadata. These MDC APIs are
helper functions built on a pair of mlogs per MDC.

The mpool Wiki contains full details on the
* Management model in the "Configure mpools" section
* Object model in the "Develop mpool Applications" section
* Kernel module architecture in the "Explore mpool Internals" section,
  which provides context for reviewing this patch series

See https://github.com/hse-project/mpool/wiki

The mpool UAPI and kernel module (not the patchset) are available on
GitHub at:

https://github.com/hse-project/mpool

https://github.com/hse-project/mpool-kmod

The HSE key-value storage engine is available on GitHub at:

https://github.com/hse-project/hse

Changes in v2:

- Fixes build errors/warnings reported by bot on ARCH=m68k
Reported-by: kernel test robot <lkp@intel.com>

- Addresses review comments from Randy and Hillf:
  * Updates ioctl-number.rst file with mpool driver's ioctl code
  * Fixes issues in the usage of printk_timed_ratelimit()

- Fixes a readahead issue found by internal testing

Nabeel M Mohamed (22):
  mpool: add utility routines and ioctl definitions
  mpool: add in-memory struct definitions
  mpool: add on-media struct definitions
  mpool: add pool drive component which handles mpool IO using the block
    layer API
  mpool: add space map component which manages free space on mpool
    devices
  mpool: add on-media pack, unpack and upgrade routines
  mpool: add superblock management routines
  mpool: add pool metadata routines to manage object lifecycle and IO
  mpool: add mblock lifecycle management and IO routines
  mpool: add mlog IO utility routines
  mpool: add mlog lifecycle management and IO routines
  mpool: add metadata container or mlog-pair framework
  mpool: add utility routines for mpool lifecycle management
  mpool: add pool metadata routines to create persistent mpools
  mpool: add mpool lifecycle management routines
  mpool: add mpool control plane utility routines
  mpool: add mpool lifecycle management ioctls
  mpool: add object lifecycle management ioctls
  mpool: add support to mmap arbitrary collection of mblocks
  mpool: add support to proactively evict cached mblock data from the
    page-cache
  mpool: add documentation
  mpool: add Kconfig and Makefile

 .../userspace-api/ioctl/ioctl-number.rst      |    3 +-
 drivers/Kconfig                               |    2 +
 drivers/Makefile                              |    1 +
 drivers/mpool/Kconfig                         |   28 +
 drivers/mpool/Makefile                        |   11 +
 drivers/mpool/assert.h                        |   25 +
 drivers/mpool/init.c                          |  126 +
 drivers/mpool/init.h                          |   17 +
 drivers/mpool/mblock.c                        |  432 +++
 drivers/mpool/mblock.h                        |  161 +
 drivers/mpool/mcache.c                        | 1072 +++++++
 drivers/mpool/mcache.h                        |  104 +
 drivers/mpool/mclass.c                        |  103 +
 drivers/mpool/mclass.h                        |  137 +
 drivers/mpool/mdc.c                           |  486 +++
 drivers/mpool/mdc.h                           |  106 +
 drivers/mpool/mlog.c                          | 1667 ++++++++++
 drivers/mpool/mlog.h                          |  212 ++
 drivers/mpool/mlog_utils.c                    | 1352 ++++++++
 drivers/mpool/mlog_utils.h                    |   63 +
 drivers/mpool/mp.c                            | 1086 +++++++
 drivers/mpool/mp.h                            |  231 ++
 drivers/mpool/mpcore.c                        |  987 ++++++
 drivers/mpool/mpcore.h                        |  354 +++
 drivers/mpool/mpctl.c                         | 2747 +++++++++++++++++
 drivers/mpool/mpctl.h                         |   58 +
 drivers/mpool/mpool-locking.rst               |   90 +
 drivers/mpool/mpool_ioctl.h                   |  636 ++++
 drivers/mpool/mpool_printk.h                  |   43 +
 drivers/mpool/omf.c                           | 1316 ++++++++
 drivers/mpool/omf.h                           |  593 ++++
 drivers/mpool/omf_if.h                        |  381 +++
 drivers/mpool/params.h                        |  116 +
 drivers/mpool/pd.c                            |  424 +++
 drivers/mpool/pd.h                            |  202 ++
 drivers/mpool/pmd.c                           | 2046 ++++++++++++
 drivers/mpool/pmd.h                           |  379 +++
 drivers/mpool/pmd_obj.c                       | 1569 ++++++++++
 drivers/mpool/pmd_obj.h                       |  499 +++
 drivers/mpool/reaper.c                        |  686 ++++
 drivers/mpool/reaper.h                        |   71 +
 drivers/mpool/sb.c                            |  625 ++++
 drivers/mpool/sb.h                            |  162 +
 drivers/mpool/smap.c                          | 1031 +++++++
 drivers/mpool/smap.h                          |  334 ++
 drivers/mpool/sysfs.c                         |   48 +
 drivers/mpool/sysfs.h                         |   48 +
 drivers/mpool/upgrade.c                       |  138 +
 drivers/mpool/upgrade.h                       |  128 +
 drivers/mpool/uuid.h                          |   59 +
 50 files changed, 23194 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mpool/Kconfig
 create mode 100644 drivers/mpool/Makefile
 create mode 100644 drivers/mpool/assert.h
 create mode 100644 drivers/mpool/init.c
 create mode 100644 drivers/mpool/init.h
 create mode 100644 drivers/mpool/mblock.c
 create mode 100644 drivers/mpool/mblock.h
 create mode 100644 drivers/mpool/mcache.c
 create mode 100644 drivers/mpool/mcache.h
 create mode 100644 drivers/mpool/mclass.c
 create mode 100644 drivers/mpool/mclass.h
 create mode 100644 drivers/mpool/mdc.c
 create mode 100644 drivers/mpool/mdc.h
 create mode 100644 drivers/mpool/mlog.c
 create mode 100644 drivers/mpool/mlog.h
 create mode 100644 drivers/mpool/mlog_utils.c
 create mode 100644 drivers/mpool/mlog_utils.h
 create mode 100644 drivers/mpool/mp.c
 create mode 100644 drivers/mpool/mp.h
 create mode 100644 drivers/mpool/mpcore.c
 create mode 100644 drivers/mpool/mpcore.h
 create mode 100644 drivers/mpool/mpctl.c
 create mode 100644 drivers/mpool/mpctl.h
 create mode 100644 drivers/mpool/mpool-locking.rst
 create mode 100644 drivers/mpool/mpool_ioctl.h
 create mode 100644 drivers/mpool/mpool_printk.h
 create mode 100644 drivers/mpool/omf.c
 create mode 100644 drivers/mpool/omf.h
 create mode 100644 drivers/mpool/omf_if.h
 create mode 100644 drivers/mpool/params.h
 create mode 100644 drivers/mpool/pd.c
 create mode 100644 drivers/mpool/pd.h
 create mode 100644 drivers/mpool/pmd.c
 create mode 100644 drivers/mpool/pmd.h
 create mode 100644 drivers/mpool/pmd_obj.c
 create mode 100644 drivers/mpool/pmd_obj.h
 create mode 100644 drivers/mpool/reaper.c
 create mode 100644 drivers/mpool/reaper.h
 create mode 100644 drivers/mpool/sb.c
 create mode 100644 drivers/mpool/sb.h
 create mode 100644 drivers/mpool/smap.c
 create mode 100644 drivers/mpool/smap.h
 create mode 100644 drivers/mpool/sysfs.c
 create mode 100644 drivers/mpool/sysfs.h
 create mode 100644 drivers/mpool/upgrade.c
 create mode 100644 drivers/mpool/upgrade.h
 create mode 100644 drivers/mpool/uuid.h

-- 
2.17.2


^ 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.