From: Dan Williams <dan.j.williams@intel.com> To: stable@vger.kernel.org Cc: linux-nvdimm@lists.01.org Subject: [4.6 stable PATCH 1/2] libnvdimm, dax: record the specified alignment of a dax-device instance Date: Wed, 03 Aug 2016 15:55:31 -0700 [thread overview] Message-ID: <147026493144.9715.5809217045641715960.stgit@dwillia2-desk3.amr.corp.intel.com> (raw) In-Reply-To: <147026492600.9715.5445676747822316537.stgit@dwillia2-desk3.amr.corp.intel.com> commit 45a0dac0451136fa7ae34a6fea53ef6a136287ce upstream. We want to use the alignment as the allocation and mapping unit. Previously this information was only useful for establishing the data offset, but now it is important to remember the granularity for the later use. Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- drivers/nvdimm/pfn.h | 4 +++- drivers/nvdimm/pfn_devs.c | 5 ++++- drivers/nvdimm/pmem.c | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/nvdimm/pfn.h b/drivers/nvdimm/pfn.h index 8e343a3ca873..9d2704c83fa7 100644 --- a/drivers/nvdimm/pfn.h +++ b/drivers/nvdimm/pfn.h @@ -33,7 +33,9 @@ struct nd_pfn_sb { /* minor-version-1 additions for section alignment */ __le32 start_pad; __le32 end_trunc; - u8 padding[4004]; + /* minor-version-2 record the base alignment of the mapping */ + __le32 align; + u8 padding[4000]; __le64 checksum; }; diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index e071e214feba..58bf68c9c414 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -360,6 +360,9 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn) pfn_sb->end_trunc = 0; } + if (__le16_to_cpu(pfn_sb->version_minor) < 2) + pfn_sb->align = 0; + switch (le32_to_cpu(pfn_sb->mode)) { case PFN_MODE_RAM: case PFN_MODE_PMEM: @@ -399,7 +402,7 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn) return -EBUSY; } - nd_pfn->align = 1UL << ilog2(offset); + nd_pfn->align = le32_to_cpu(pfn_sb->align); if (!is_power_of_2(offset) || offset < PAGE_SIZE) { dev_err(&nd_pfn->dev, "bad offset: %#llx dax disabled\n", offset); diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 92f536596b24..58ad81dcd1a5 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -426,9 +426,10 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn) memcpy(pfn_sb->uuid, nd_pfn->uuid, 16); memcpy(pfn_sb->parent_uuid, nd_dev_to_uuid(&ndns->dev), 16); pfn_sb->version_major = cpu_to_le16(1); - pfn_sb->version_minor = cpu_to_le16(1); + pfn_sb->version_minor = cpu_to_le16(2); pfn_sb->start_pad = cpu_to_le32(start_pad); pfn_sb->end_trunc = cpu_to_le32(end_trunc); + pfn_sb->align = cpu_to_le32(nd_pfn->align); checksum = nd_sb_checksum((struct nd_gen_sb *) pfn_sb); pfn_sb->checksum = cpu_to_le64(checksum); _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
WARNING: multiple messages have this Message-ID (diff)
From: Dan Williams <dan.j.williams@intel.com> To: stable@vger.kernel.org Cc: linux-nvdimm@lists.01.org Subject: [4.6 stable PATCH 1/2] libnvdimm, dax: record the specified alignment of a dax-device instance Date: Wed, 03 Aug 2016 15:55:31 -0700 [thread overview] Message-ID: <147026493144.9715.5809217045641715960.stgit@dwillia2-desk3.amr.corp.intel.com> (raw) In-Reply-To: <147026492600.9715.5445676747822316537.stgit@dwillia2-desk3.amr.corp.intel.com> commit 45a0dac0451136fa7ae34a6fea53ef6a136287ce upstream. We want to use the alignment as the allocation and mapping unit. Previously this information was only useful for establishing the data offset, but now it is important to remember the granularity for the later use. Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- drivers/nvdimm/pfn.h | 4 +++- drivers/nvdimm/pfn_devs.c | 5 ++++- drivers/nvdimm/pmem.c | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/nvdimm/pfn.h b/drivers/nvdimm/pfn.h index 8e343a3ca873..9d2704c83fa7 100644 --- a/drivers/nvdimm/pfn.h +++ b/drivers/nvdimm/pfn.h @@ -33,7 +33,9 @@ struct nd_pfn_sb { /* minor-version-1 additions for section alignment */ __le32 start_pad; __le32 end_trunc; - u8 padding[4004]; + /* minor-version-2 record the base alignment of the mapping */ + __le32 align; + u8 padding[4000]; __le64 checksum; }; diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index e071e214feba..58bf68c9c414 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -360,6 +360,9 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn) pfn_sb->end_trunc = 0; } + if (__le16_to_cpu(pfn_sb->version_minor) < 2) + pfn_sb->align = 0; + switch (le32_to_cpu(pfn_sb->mode)) { case PFN_MODE_RAM: case PFN_MODE_PMEM: @@ -399,7 +402,7 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn) return -EBUSY; } - nd_pfn->align = 1UL << ilog2(offset); + nd_pfn->align = le32_to_cpu(pfn_sb->align); if (!is_power_of_2(offset) || offset < PAGE_SIZE) { dev_err(&nd_pfn->dev, "bad offset: %#llx dax disabled\n", offset); diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 92f536596b24..58ad81dcd1a5 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -426,9 +426,10 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn) memcpy(pfn_sb->uuid, nd_pfn->uuid, 16); memcpy(pfn_sb->parent_uuid, nd_dev_to_uuid(&ndns->dev), 16); pfn_sb->version_major = cpu_to_le16(1); - pfn_sb->version_minor = cpu_to_le16(1); + pfn_sb->version_minor = cpu_to_le16(2); pfn_sb->start_pad = cpu_to_le32(start_pad); pfn_sb->end_trunc = cpu_to_le32(end_trunc); + pfn_sb->align = cpu_to_le32(nd_pfn->align); checksum = nd_sb_checksum((struct nd_gen_sb *) pfn_sb); pfn_sb->checksum = cpu_to_le64(checksum);
next prev parent reply other threads:[~2016-08-03 22:58 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-08-03 22:55 [4.6 stable PATCH 0/2] libnvdimm: fix initialization vs autodetect Dan Williams 2016-08-03 22:55 ` Dan Williams 2016-08-03 22:55 ` Dan Williams [this message] 2016-08-03 22:55 ` [4.6 stable PATCH 1/2] libnvdimm, dax: record the specified alignment of a dax-device instance Dan Williams 2016-08-03 22:55 ` [4.6 stable PATCH 2/2] libnvdimm, pfn, dax: fix initialization vs autodetect for mode + alignment Dan Williams 2016-08-03 22:55 ` Dan Williams 2016-08-11 16:47 ` [4.6 stable PATCH 0/2] libnvdimm: fix initialization vs autodetect Greg KH 2016-08-11 16:47 ` Greg KH
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=147026493144.9715.5809217045641715960.stgit@dwillia2-desk3.amr.corp.intel.com \ --to=dan.j.williams@intel.com \ --cc=linux-nvdimm@lists.01.org \ --cc=stable@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.