linux/drivers/nvdimm/namespace_devs.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
 */
#include <linux/kstrtox.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/sort.h>
#include <linux/slab.h>
#include <linux/list.h>
#include <linux/nd.h>
#include "nd-core.h"
#include "pmem.h"
#include "pfn.h"
#include "nd.h"

static void namespace_io_release(struct device *dev)
{}

static void namespace_pmem_release(struct device *dev)
{}

static bool is_namespace_pmem(const struct device *dev);
static bool is_namespace_io(const struct device *dev);

static int is_uuid_busy(struct device *dev, void *data)
{}

static int is_namespace_uuid_busy(struct device *dev, void *data)
{}

/**
 * nd_is_uuid_unique - verify that no other namespace has @uuid
 * @dev: any device on a nvdimm_bus
 * @uuid: uuid to check
 *
 * Returns: %true if the uuid is unique, %false if not
 */
bool nd_is_uuid_unique(struct device *dev, uuid_t *uuid)
{}

bool pmem_should_map_pages(struct device *dev)
{}
EXPORT_SYMBOL();

unsigned int pmem_sector_size(struct nd_namespace_common *ndns)
{}
EXPORT_SYMBOL();

const char *nvdimm_namespace_disk_name(struct nd_namespace_common *ndns,
		char *name)
{}
EXPORT_SYMBOL();

const uuid_t *nd_dev_to_uuid(struct device *dev)
{}
EXPORT_SYMBOL();

static ssize_t nstype_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(nstype);

static ssize_t __alt_name_store(struct device *dev, const char *buf,
		const size_t len)
{}

static int nd_namespace_label_update(struct nd_region *nd_region,
		struct device *dev)
{}

static ssize_t alt_name_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t len)
{}

static ssize_t alt_name_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RW(alt_name);

static int scan_free(struct nd_region *nd_region,
		struct nd_mapping *nd_mapping, struct nd_label_id *label_id,
		resource_size_t n)
{}

/**
 * shrink_dpa_allocation - for each dimm in region free n bytes for label_id
 * @nd_region: the set of dimms to reclaim @n bytes from
 * @label_id: unique identifier for the namespace consuming this dpa range
 * @n: number of bytes per-dimm to release
 *
 * Assumes resources are ordered.  Starting from the end try to
 * adjust_resource() the allocation to @n, but if @n is larger than the
 * allocation delete it and find the 'new' last allocation in the label
 * set.
 *
 * Returns: %0 on success on -errno on error
 */
static int shrink_dpa_allocation(struct nd_region *nd_region,
		struct nd_label_id *label_id, resource_size_t n)
{}

static resource_size_t init_dpa_allocation(struct nd_label_id *label_id,
		struct nd_region *nd_region, struct nd_mapping *nd_mapping,
		resource_size_t n)
{}


/**
 * space_valid() - validate free dpa space against constraints
 * @nd_region: hosting region of the free space
 * @ndd: dimm device data for debug
 * @label_id: namespace id to allocate space
 * @prev: potential allocation that precedes free space
 * @next: allocation that follows the given free space range
 * @exist: first allocation with same id in the mapping
 * @n: range that must satisfied for pmem allocations
 * @valid: free space range to validate
 *
 * BLK-space is valid as long as it does not precede a PMEM
 * allocation in a given region. PMEM-space must be contiguous
 * and adjacent to an existing allocation (if one
 * exists).  If reserving PMEM any space is valid.
 */
static void space_valid(struct nd_region *nd_region, struct nvdimm_drvdata *ndd,
		struct nd_label_id *label_id, struct resource *prev,
		struct resource *next, struct resource *exist,
		resource_size_t n, struct resource *valid)
{}

enum alloc_loc {};

static resource_size_t scan_allocate(struct nd_region *nd_region,
		struct nd_mapping *nd_mapping, struct nd_label_id *label_id,
		resource_size_t n)
{}

static int merge_dpa(struct nd_region *nd_region,
		struct nd_mapping *nd_mapping, struct nd_label_id *label_id)
{}

int __reserve_free_pmem(struct device *dev, void *data)
{}

void release_free_pmem(struct nvdimm_bus *nvdimm_bus,
		struct nd_mapping *nd_mapping)
{}

/**
 * grow_dpa_allocation - for each dimm allocate n bytes for @label_id
 * @nd_region: the set of dimms to allocate @n more bytes from
 * @label_id: unique identifier for the namespace consuming this dpa range
 * @n: number of bytes per-dimm to add to the existing allocation
 *
 * Assumes resources are ordered.  For BLK regions, first consume
 * BLK-only available DPA free space, then consume PMEM-aliased DPA
 * space starting at the highest DPA.  For PMEM regions start
 * allocations from the start of an interleave set and end at the first
 * BLK allocation or the end of the interleave set, whichever comes
 * first.
 *
 * Returns: %0 on success on -errno on error
 */
static int grow_dpa_allocation(struct nd_region *nd_region,
		struct nd_label_id *label_id, resource_size_t n)
{}

static void nd_namespace_pmem_set_resource(struct nd_region *nd_region,
		struct nd_namespace_pmem *nspm, resource_size_t size)
{}

static bool uuid_not_set(const uuid_t *uuid, struct device *dev,
			 const char *where)
{}

static ssize_t __size_store(struct device *dev, unsigned long long val)
{}

static ssize_t size_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t len)
{}

resource_size_t __nvdimm_namespace_capacity(struct nd_namespace_common *ndns)
{}

resource_size_t nvdimm_namespace_capacity(struct nd_namespace_common *ndns)
{}
EXPORT_SYMBOL();

bool nvdimm_namespace_locked(struct nd_namespace_common *ndns)
{}
EXPORT_SYMBOL();

static ssize_t size_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR(size, 0444, size_show, size_store);

static uuid_t *namespace_to_uuid(struct device *dev)
{}

static ssize_t uuid_show(struct device *dev, struct device_attribute *attr,
			 char *buf)
{}

/**
 * namespace_update_uuid - check for a unique uuid and whether we're "renaming"
 * @nd_region: parent region so we can updates all dimms in the set
 * @dev: namespace type for generating label_id
 * @new_uuid: incoming uuid
 * @old_uuid: reference to the uuid storage location in the namespace object
 *
 * Returns: %0 on success on -errno on error
 */
static int namespace_update_uuid(struct nd_region *nd_region,
				 struct device *dev, uuid_t *new_uuid,
				 uuid_t **old_uuid)
{}

static ssize_t uuid_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t len)
{}
static DEVICE_ATTR_RW(uuid);

static ssize_t resource_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_ADMIN_RO(resource);

static const unsigned long pmem_lbasize_supported[] =;

static ssize_t sector_size_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

static ssize_t sector_size_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t len)
{}
static DEVICE_ATTR_RW(sector_size);

static ssize_t dpa_extents_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(dpa_extents);

static int btt_claim_class(struct device *dev)
{}

static ssize_t holder_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(holder);

static int __holder_class_store(struct device *dev, const char *buf)
{}

static ssize_t holder_class_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t len)
{}

static ssize_t holder_class_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RW(holder_class);

static ssize_t mode_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(mode);

static ssize_t force_raw_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t len)
{}

static ssize_t force_raw_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RW(force_raw);

static struct attribute *nd_namespace_attributes[] =;

static umode_t namespace_visible(struct kobject *kobj,
		struct attribute *a, int n)
{}

static struct attribute_group nd_namespace_attribute_group =;

static const struct attribute_group *nd_namespace_attribute_groups[] =;

static const struct device_type namespace_io_device_type =;

static const struct device_type namespace_pmem_device_type =;

static bool is_namespace_pmem(const struct device *dev)
{}

static bool is_namespace_io(const struct device *dev)
{}

struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev)
{}
EXPORT_SYMBOL();

int devm_namespace_enable(struct device *dev, struct nd_namespace_common *ndns,
		resource_size_t size)
{}
EXPORT_SYMBOL_GPL();

void devm_namespace_disable(struct device *dev, struct nd_namespace_common *ndns)
{}
EXPORT_SYMBOL_GPL();

static struct device **create_namespace_io(struct nd_region *nd_region)
{}

static bool has_uuid_at_pos(struct nd_region *nd_region, const uuid_t *uuid,
			    u64 cookie, u16 pos)
{}

static int select_pmem_id(struct nd_region *nd_region, const uuid_t *pmem_id)
{}

/**
 * create_namespace_pmem - validate interleave set labelling, retrieve label0
 * @nd_region: region with mappings to validate
 * @nd_mapping: container of dpa-resource-root + labels
 * @nd_label: target pmem namespace label to evaluate
 *
 * Returns: the created &struct device on success or ERR_PTR(-errno) on error
 */
static struct device *create_namespace_pmem(struct nd_region *nd_region,
					    struct nd_mapping *nd_mapping,
					    struct nd_namespace_label *nd_label)
{}

static struct device *nd_namespace_pmem_create(struct nd_region *nd_region)
{}

static struct lock_class_key nvdimm_namespace_key;

void nd_region_create_ns_seed(struct nd_region *nd_region)
{}

void nd_region_create_dax_seed(struct nd_region *nd_region)
{}

void nd_region_create_pfn_seed(struct nd_region *nd_region)
{}

void nd_region_create_btt_seed(struct nd_region *nd_region)
{}

static int add_namespace_resource(struct nd_region *nd_region,
		struct nd_namespace_label *nd_label, struct device **devs,
		int count)
{}

static int cmp_dpa(const void *a, const void *b)
{}

static struct device **scan_labels(struct nd_region *nd_region)
{}

static struct device **create_namespaces(struct nd_region *nd_region)
{}

static void deactivate_labels(void *region)
{}

static int init_active_labels(struct nd_region *nd_region)
{}

int nd_region_register_namespaces(struct nd_region *nd_region, int *err)
{}