label.c (7cd35b2920500908eb3d9d00939f2aea3e8f8361) label.c (f56541a7122c68ef3074e41c2cb14182eb11d3a5)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
4 */
5#include <linux/device.h>
6#include <linux/ndctl.h>
7#include <linux/uuid.h>
8#include <linux/slab.h>

--- 884 unchanged lines hidden (view full) ---

893 if (resource_size(res) != nsl_get_rawsize(ndd, nd_label))
894 continue;
895 return res;
896 }
897
898 return NULL;
899}
900
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
4 */
5#include <linux/device.h>
6#include <linux/ndctl.h>
7#include <linux/uuid.h>
8#include <linux/slab.h>

--- 884 unchanged lines hidden (view full) ---

893 if (resource_size(res) != nsl_get_rawsize(ndd, nd_label))
894 continue;
895 return res;
896 }
897
898 return NULL;
899}
900
901static void nsl_set_blk_isetcookie(struct nvdimm_drvdata *ndd,
902 struct nd_namespace_label *nd_label,
903 u64 isetcookie)
904{
905 if (namespace_label_has(ndd, type_guid)) {
906 nsl_set_isetcookie(ndd, nd_label, isetcookie);
907 return;
908 }
909 nsl_set_isetcookie(ndd, nd_label, 0); /* N/A */
910}
911
912bool nsl_validate_blk_isetcookie(struct nvdimm_drvdata *ndd,
913 struct nd_namespace_label *nd_label,
914 u64 isetcookie)
915{
916 if (!namespace_label_has(ndd, type_guid))
917 return true;
918
919 if (nsl_get_isetcookie(ndd, nd_label) != isetcookie) {
920 dev_dbg(ndd->dev, "expect cookie %#llx got %#llx\n", isetcookie,
921 nsl_get_isetcookie(ndd, nd_label));
922 return false;
923 }
924
925 return true;
926}
927
901/*
902 * 1/ Account all the labels that can be freed after this update
903 * 2/ Allocate and write the label to the staging (next) index
904 * 3/ Record the resources in the namespace device
905 */
906static int __blk_label_update(struct nd_region *nd_region,
907 struct nd_mapping *nd_mapping, struct nd_namespace_blk *nsblk,
908 int num_labels)

--- 128 unchanged lines hidden (view full) ---

1037 if (namespace_label_has(ndd, type_guid)) {
1038 if (i == min_dpa_idx) {
1039 nsl_set_nlabel(ndd, nd_label, nsblk->num_resources);
1040 nsl_set_position(ndd, nd_label, 0);
1041 } else {
1042 nsl_set_nlabel(ndd, nd_label, 0xffff);
1043 nsl_set_position(ndd, nd_label, 0xffff);
1044 }
928/*
929 * 1/ Account all the labels that can be freed after this update
930 * 2/ Allocate and write the label to the staging (next) index
931 * 3/ Record the resources in the namespace device
932 */
933static int __blk_label_update(struct nd_region *nd_region,
934 struct nd_mapping *nd_mapping, struct nd_namespace_blk *nsblk,
935 int num_labels)

--- 128 unchanged lines hidden (view full) ---

1064 if (namespace_label_has(ndd, type_guid)) {
1065 if (i == min_dpa_idx) {
1066 nsl_set_nlabel(ndd, nd_label, nsblk->num_resources);
1067 nsl_set_position(ndd, nd_label, 0);
1068 } else {
1069 nsl_set_nlabel(ndd, nd_label, 0xffff);
1070 nsl_set_position(ndd, nd_label, 0xffff);
1071 }
1045 nsl_set_isetcookie(ndd, nd_label, nd_set->cookie2);
1046 } else {
1047 nsl_set_nlabel(ndd, nd_label, 0); /* N/A */
1048 nsl_set_position(ndd, nd_label, 0); /* N/A */
1072 } else {
1073 nsl_set_nlabel(ndd, nd_label, 0); /* N/A */
1074 nsl_set_position(ndd, nd_label, 0); /* N/A */
1049 nsl_set_isetcookie(ndd, nd_label, 0); /* N/A */
1050 }
1075 }
1076 nsl_set_blk_isetcookie(ndd, nd_label, nd_set->cookie2);
1051
1052 nsl_set_dpa(ndd, nd_label, res->start);
1053 nsl_set_rawsize(ndd, nd_label, resource_size(res));
1054 nsl_set_lbasize(ndd, nd_label, nsblk->lbasize);
1055 nsl_set_slot(ndd, nd_label, slot);
1056 if (namespace_label_has(ndd, type_guid))
1057 guid_copy(&nd_label->type_guid, &nd_set->type_guid);
1058 if (namespace_label_has(ndd, abstraction_guid))

--- 272 unchanged lines hidden ---
1077
1078 nsl_set_dpa(ndd, nd_label, res->start);
1079 nsl_set_rawsize(ndd, nd_label, resource_size(res));
1080 nsl_set_lbasize(ndd, nd_label, nsblk->lbasize);
1081 nsl_set_slot(ndd, nd_label, slot);
1082 if (namespace_label_has(ndd, type_guid))
1083 guid_copy(&nd_label->type_guid, &nd_set->type_guid);
1084 if (namespace_label_has(ndd, abstraction_guid))

--- 272 unchanged lines hidden ---