Re: [Linux-nvdimm] [PATCH 19/21] nd: infrastructure for btt devices
On Tue, Apr 28, 2015 at 06:01:04AM -0700, Christoph Hellwig wrote: > Please don't add any of the nd-specific hacks into the pmem driver. > The rw_bytes functionality already is provided by the existing block > level ->rw_page method which pmem already implements, and any sort > of bus locking for different access methods should be in the bus > glue, not in pmem.c ->rw_page only lets you do an entire page, not a range of bytes within a page. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [Linux-nvdimm] [PATCH 19/21] nd: infrastructure for btt devices
On Fri, Apr 17, 2015 at 09:36:55PM -0400, Dan Williams wrote: > Block devices from an nd bus, in addition to accepting "struct bio" > based requests, also have the capability to perform byte-aligned > accesses. By default only the bio/block interface is used. However, if > another driver can make effective use of the byte-aligned capability it > can claim/disable the block interface and use the byte-aligned "nd_io" > interface. > > The BTT driver is the intended first consumer of this mechanism to allow > layering atomic sector update guarantees on top of nd_io capable > nd-bus-block-devices. Please don't add any of the nd-specific hacks into the pmem driver. The rw_bytes functionality already is provided by the existing block level ->rw_page method which pmem already implements, and any sort of bus locking for different access methods should be in the bus glue, not in pmem.c -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [Linux-nvdimm] [PATCH 19/21] nd: infrastructure for btt devices
On Fri, Apr 17, 2015 at 09:36:55PM -0400, Dan Williams wrote: Block devices from an nd bus, in addition to accepting struct bio based requests, also have the capability to perform byte-aligned accesses. By default only the bio/block interface is used. However, if another driver can make effective use of the byte-aligned capability it can claim/disable the block interface and use the byte-aligned nd_io interface. The BTT driver is the intended first consumer of this mechanism to allow layering atomic sector update guarantees on top of nd_io capable nd-bus-block-devices. Please don't add any of the nd-specific hacks into the pmem driver. The rw_bytes functionality already is provided by the existing block level -rw_page method which pmem already implements, and any sort of bus locking for different access methods should be in the bus glue, not in pmem.c -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [Linux-nvdimm] [PATCH 19/21] nd: infrastructure for btt devices
On Tue, Apr 28, 2015 at 06:01:04AM -0700, Christoph Hellwig wrote: Please don't add any of the nd-specific hacks into the pmem driver. The rw_bytes functionality already is provided by the existing block level -rw_page method which pmem already implements, and any sort of bus locking for different access methods should be in the bus glue, not in pmem.c -rw_page only lets you do an entire page, not a range of bytes within a page. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [Linux-nvdimm] [PATCH 19/21] nd: infrastructure for btt devices
On Wed, Apr 22, 2015 at 12:12 PM, Elliott, Robert (Server Storage) wrote: >> -Original Message- >> From: Linux-nvdimm [mailto:linux-nvdimm-boun...@lists.01.org] On Behalf Of >> Dan Williams >> Sent: Friday, April 17, 2015 8:37 PM >> To: linux-nvd...@lists.01.org >> Subject: [Linux-nvdimm] [PATCH 19/21] nd: infrastructure for btt devices >> > ... >> +/* >> + * btt_sb_checksum: compute checksum for btt info block >> + * >> + * Returns a fletcher64 checksum of everything in the given info block >> + * except the last field (since that's where the checksum lives). >> + */ >> +u64 btt_sb_checksum(struct btt_sb *btt_sb) >> +{ >> + u64 sum, sum_save; >> + >> + sum_save = btt_sb->checksum; >> + btt_sb->checksum = 0; >> + sum = nd_fletcher64(btt_sb, sizeof(*btt_sb)); >> + btt_sb->checksum = sum_save; >> + return sum; >> +} >> +EXPORT_SYMBOL(btt_sb_checksum); > ... > > Of all the functions with prototypes in nd.h, this is the only > function that doesn't have a name starting with nd_. > > Following such a convention helps ease setting up ftrace filters. Sure, I'll fix that up. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [Linux-nvdimm] [PATCH 19/21] nd: infrastructure for btt devices
> -Original Message- > From: Linux-nvdimm [mailto:linux-nvdimm-boun...@lists.01.org] On Behalf Of > Dan Williams > Sent: Friday, April 17, 2015 8:37 PM > To: linux-nvd...@lists.01.org > Subject: [Linux-nvdimm] [PATCH 19/21] nd: infrastructure for btt devices > ... > +/* > + * btt_sb_checksum: compute checksum for btt info block > + * > + * Returns a fletcher64 checksum of everything in the given info block > + * except the last field (since that's where the checksum lives). > + */ > +u64 btt_sb_checksum(struct btt_sb *btt_sb) > +{ > + u64 sum, sum_save; > + > + sum_save = btt_sb->checksum; > + btt_sb->checksum = 0; > + sum = nd_fletcher64(btt_sb, sizeof(*btt_sb)); > + btt_sb->checksum = sum_save; > + return sum; > +} > +EXPORT_SYMBOL(btt_sb_checksum); ... Of all the functions with prototypes in nd.h, this is the only function that doesn't have a name starting with nd_. Following such a convention helps ease setting up ftrace filters. --- Robert Elliott, HP Server Storage -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [Linux-nvdimm] [PATCH 19/21] nd: infrastructure for btt devices
On Wed, Apr 22, 2015 at 12:12 PM, Elliott, Robert (Server Storage) elli...@hp.com wrote: -Original Message- From: Linux-nvdimm [mailto:linux-nvdimm-boun...@lists.01.org] On Behalf Of Dan Williams Sent: Friday, April 17, 2015 8:37 PM To: linux-nvd...@lists.01.org Subject: [Linux-nvdimm] [PATCH 19/21] nd: infrastructure for btt devices ... +/* + * btt_sb_checksum: compute checksum for btt info block + * + * Returns a fletcher64 checksum of everything in the given info block + * except the last field (since that's where the checksum lives). + */ +u64 btt_sb_checksum(struct btt_sb *btt_sb) +{ + u64 sum, sum_save; + + sum_save = btt_sb-checksum; + btt_sb-checksum = 0; + sum = nd_fletcher64(btt_sb, sizeof(*btt_sb)); + btt_sb-checksum = sum_save; + return sum; +} +EXPORT_SYMBOL(btt_sb_checksum); ... Of all the functions with prototypes in nd.h, this is the only function that doesn't have a name starting with nd_. Following such a convention helps ease setting up ftrace filters. Sure, I'll fix that up. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
RE: [Linux-nvdimm] [PATCH 19/21] nd: infrastructure for btt devices
-Original Message- From: Linux-nvdimm [mailto:linux-nvdimm-boun...@lists.01.org] On Behalf Of Dan Williams Sent: Friday, April 17, 2015 8:37 PM To: linux-nvd...@lists.01.org Subject: [Linux-nvdimm] [PATCH 19/21] nd: infrastructure for btt devices ... +/* + * btt_sb_checksum: compute checksum for btt info block + * + * Returns a fletcher64 checksum of everything in the given info block + * except the last field (since that's where the checksum lives). + */ +u64 btt_sb_checksum(struct btt_sb *btt_sb) +{ + u64 sum, sum_save; + + sum_save = btt_sb-checksum; + btt_sb-checksum = 0; + sum = nd_fletcher64(btt_sb, sizeof(*btt_sb)); + btt_sb-checksum = sum_save; + return sum; +} +EXPORT_SYMBOL(btt_sb_checksum); ... Of all the functions with prototypes in nd.h, this is the only function that doesn't have a name starting with nd_. Following such a convention helps ease setting up ftrace filters. --- Robert Elliott, HP Server Storage -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 19/21] nd: infrastructure for btt devices
Block devices from an nd bus, in addition to accepting "struct bio" based requests, also have the capability to perform byte-aligned accesses. By default only the bio/block interface is used. However, if another driver can make effective use of the byte-aligned capability it can claim/disable the block interface and use the byte-aligned "nd_io" interface. The BTT driver is the intended first consumer of this mechanism to allow layering atomic sector update guarantees on top of nd_io capable nd-bus-block-devices. Cc: Greg KH Cc: Neil Brown Signed-off-by: Dan Williams --- drivers/block/nd/Kconfig |3 drivers/block/nd/Makefile |2 drivers/block/nd/btt.h| 45 drivers/block/nd/btt_devs.c | 442 + drivers/block/nd/bus.c| 128 drivers/block/nd/core.c | 80 +++ drivers/block/nd/nd-private.h | 28 +++ drivers/block/nd/nd.h | 94 + drivers/block/nd/pmem.c | 30 +++ include/uapi/linux/ndctl.h|2 10 files changed, 850 insertions(+), 4 deletions(-) create mode 100644 drivers/block/nd/btt.h create mode 100644 drivers/block/nd/btt_devs.c diff --git a/drivers/block/nd/Kconfig b/drivers/block/nd/Kconfig index 38eae5f0ae4b..faa756841773 100644 --- a/drivers/block/nd/Kconfig +++ b/drivers/block/nd/Kconfig @@ -89,4 +89,7 @@ config BLK_DEV_PMEM Say Y if you want to use a NVDIMM described by NFIT +config ND_BTT_DEVS + def_bool y + endif diff --git a/drivers/block/nd/Makefile b/drivers/block/nd/Makefile index 93856f1c9dbd..3e4878e0fe1d 100644 --- a/drivers/block/nd/Makefile +++ b/drivers/block/nd/Makefile @@ -29,4 +29,6 @@ nd-y += region.o nd-y += namespace_devs.o nd-y += label.o +nd-$(CONFIG_ND_BTT_DEVS) += btt_devs.o + nd_pmem-y := pmem.o diff --git a/drivers/block/nd/btt.h b/drivers/block/nd/btt.h new file mode 100644 index ..e8f6d8e0ddd3 --- /dev/null +++ b/drivers/block/nd/btt.h @@ -0,0 +1,45 @@ +/* + * Block Translation Table library + * Copyright (c) 2014-2015, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will 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. + */ + +#ifndef _LINUX_BTT_H +#define _LINUX_BTT_H + +#include + +#define BTT_SIG_LEN 16 +#define BTT_SIG "BTT_ARENA_INFO\0" + +struct btt_sb { + u8 signature[BTT_SIG_LEN]; + u8 uuid[16]; + u8 parent_uuid[16]; + __le32 flags; + __le16 version_major; + __le16 version_minor; + __le32 external_lbasize; + __le32 external_nlba; + __le32 internal_lbasize; + __le32 internal_nlba; + __le32 nfree; + __le32 infosize; + __le64 nextoff; + __le64 dataoff; + __le64 mapoff; + __le64 logoff; + __le64 info2off; + u8 padding[3968]; + __le64 checksum; +}; + +#endif diff --git a/drivers/block/nd/btt_devs.c b/drivers/block/nd/btt_devs.c new file mode 100644 index ..746d582910b6 --- /dev/null +++ b/drivers/block/nd/btt_devs.c @@ -0,0 +1,442 @@ +/* + * Copyright(c) 2013-2015 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will 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. + */ +#include +#include +#include +#include +#include +#include +#include "nd-private.h" +#include "btt.h" +#include "nd.h" + +static DEFINE_IDA(btt_ida); + +static void nd_btt_release(struct device *dev) +{ + struct nd_btt *nd_btt = to_nd_btt(dev); + + dev_dbg(dev, "%s\n", __func__); + WARN_ON(nd_btt->backing_dev); + ndio_del_claim(nd_btt->ndio_claim); + ida_simple_remove(_ida, nd_btt->id); + kfree(nd_btt->uuid); + kfree(nd_btt); +} + +static struct device_type nd_btt_device_type = { + .name = "nd_btt", + .release = nd_btt_release, +}; + +bool is_nd_btt(struct device *dev) +{ + return dev->type == _btt_device_type; +} + +struct nd_btt *to_nd_btt(struct device *dev) +{ + struct nd_btt *nd_btt = container_of(dev, struct nd_btt, dev); + + WARN_ON(!is_nd_btt(dev)); + return nd_btt; +} +EXPORT_SYMBOL(to_nd_btt); + +static const unsigned long btt_lbasize_supported[] = { 512, 4096, 0 }; + +static ssize_t sector_size_show(struct device *dev, + struct
[PATCH 19/21] nd: infrastructure for btt devices
Block devices from an nd bus, in addition to accepting struct bio based requests, also have the capability to perform byte-aligned accesses. By default only the bio/block interface is used. However, if another driver can make effective use of the byte-aligned capability it can claim/disable the block interface and use the byte-aligned nd_io interface. The BTT driver is the intended first consumer of this mechanism to allow layering atomic sector update guarantees on top of nd_io capable nd-bus-block-devices. Cc: Greg KH gre...@linuxfoundation.org Cc: Neil Brown ne...@suse.de Signed-off-by: Dan Williams dan.j.willi...@intel.com --- drivers/block/nd/Kconfig |3 drivers/block/nd/Makefile |2 drivers/block/nd/btt.h| 45 drivers/block/nd/btt_devs.c | 442 + drivers/block/nd/bus.c| 128 drivers/block/nd/core.c | 80 +++ drivers/block/nd/nd-private.h | 28 +++ drivers/block/nd/nd.h | 94 + drivers/block/nd/pmem.c | 30 +++ include/uapi/linux/ndctl.h|2 10 files changed, 850 insertions(+), 4 deletions(-) create mode 100644 drivers/block/nd/btt.h create mode 100644 drivers/block/nd/btt_devs.c diff --git a/drivers/block/nd/Kconfig b/drivers/block/nd/Kconfig index 38eae5f0ae4b..faa756841773 100644 --- a/drivers/block/nd/Kconfig +++ b/drivers/block/nd/Kconfig @@ -89,4 +89,7 @@ config BLK_DEV_PMEM Say Y if you want to use a NVDIMM described by NFIT +config ND_BTT_DEVS + def_bool y + endif diff --git a/drivers/block/nd/Makefile b/drivers/block/nd/Makefile index 93856f1c9dbd..3e4878e0fe1d 100644 --- a/drivers/block/nd/Makefile +++ b/drivers/block/nd/Makefile @@ -29,4 +29,6 @@ nd-y += region.o nd-y += namespace_devs.o nd-y += label.o +nd-$(CONFIG_ND_BTT_DEVS) += btt_devs.o + nd_pmem-y := pmem.o diff --git a/drivers/block/nd/btt.h b/drivers/block/nd/btt.h new file mode 100644 index ..e8f6d8e0ddd3 --- /dev/null +++ b/drivers/block/nd/btt.h @@ -0,0 +1,45 @@ +/* + * Block Translation Table library + * Copyright (c) 2014-2015, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will 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. + */ + +#ifndef _LINUX_BTT_H +#define _LINUX_BTT_H + +#include linux/types.h + +#define BTT_SIG_LEN 16 +#define BTT_SIG BTT_ARENA_INFO\0 + +struct btt_sb { + u8 signature[BTT_SIG_LEN]; + u8 uuid[16]; + u8 parent_uuid[16]; + __le32 flags; + __le16 version_major; + __le16 version_minor; + __le32 external_lbasize; + __le32 external_nlba; + __le32 internal_lbasize; + __le32 internal_nlba; + __le32 nfree; + __le32 infosize; + __le64 nextoff; + __le64 dataoff; + __le64 mapoff; + __le64 logoff; + __le64 info2off; + u8 padding[3968]; + __le64 checksum; +}; + +#endif diff --git a/drivers/block/nd/btt_devs.c b/drivers/block/nd/btt_devs.c new file mode 100644 index ..746d582910b6 --- /dev/null +++ b/drivers/block/nd/btt_devs.c @@ -0,0 +1,442 @@ +/* + * Copyright(c) 2013-2015 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will 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. + */ +#include linux/device.h +#include linux/genhd.h +#include linux/sizes.h +#include linux/slab.h +#include linux/fs.h +#include linux/mm.h +#include nd-private.h +#include btt.h +#include nd.h + +static DEFINE_IDA(btt_ida); + +static void nd_btt_release(struct device *dev) +{ + struct nd_btt *nd_btt = to_nd_btt(dev); + + dev_dbg(dev, %s\n, __func__); + WARN_ON(nd_btt-backing_dev); + ndio_del_claim(nd_btt-ndio_claim); + ida_simple_remove(btt_ida, nd_btt-id); + kfree(nd_btt-uuid); + kfree(nd_btt); +} + +static struct device_type nd_btt_device_type = { + .name = nd_btt, + .release = nd_btt_release, +}; + +bool is_nd_btt(struct device *dev) +{ + return dev-type == nd_btt_device_type; +} + +struct nd_btt *to_nd_btt(struct device *dev) +{ + struct nd_btt *nd_btt = container_of(dev, struct nd_btt, dev); + + WARN_ON(!is_nd_btt(dev)); + return nd_btt; +} +EXPORT_SYMBOL(to_nd_btt); + +static const unsigned