Lines Matching refs:nd_btt
19 struct nd_btt *nd_btt = to_nd_btt(dev); in nd_btt_release() local
22 nd_detach_ndns(&nd_btt->dev, &nd_btt->ndns); in nd_btt_release()
23 ida_simple_remove(&nd_region->btt_ida, nd_btt->id); in nd_btt_release()
24 kfree(nd_btt->uuid); in nd_btt_release()
25 kfree(nd_btt); in nd_btt_release()
28 struct nd_btt *to_nd_btt(struct device *dev) in to_nd_btt()
30 struct nd_btt *nd_btt = container_of(dev, struct nd_btt, dev); in to_nd_btt() local
33 return nd_btt; in to_nd_btt()
43 struct nd_btt *nd_btt = to_nd_btt(dev); in sector_size_show() local
45 return nd_size_select_show(nd_btt->lbasize, btt_lbasize_supported, buf); in sector_size_show()
51 struct nd_btt *nd_btt = to_nd_btt(dev); in sector_size_store() local
56 rc = nd_size_select_store(dev, buf, &nd_btt->lbasize, in sector_size_store()
70 struct nd_btt *nd_btt = to_nd_btt(dev); in uuid_show() local
72 if (nd_btt->uuid) in uuid_show()
73 return sprintf(buf, "%pUb\n", nd_btt->uuid); in uuid_show()
80 struct nd_btt *nd_btt = to_nd_btt(dev); in uuid_store() local
84 rc = nd_uuid_store(dev, &nd_btt->uuid, buf, len); in uuid_store()
96 struct nd_btt *nd_btt = to_nd_btt(dev); in namespace_show() local
100 rc = sprintf(buf, "%s\n", nd_btt->ndns in namespace_show()
101 ? dev_name(&nd_btt->ndns->dev) : ""); in namespace_show()
109 struct nd_btt *nd_btt = to_nd_btt(dev); in namespace_store() local
114 rc = nd_namespace_store(dev, &nd_btt->ndns, buf, len); in namespace_store()
127 struct nd_btt *nd_btt = to_nd_btt(dev); in size_show() local
132 rc = sprintf(buf, "%llu\n", nd_btt->size); in size_show()
186 struct nd_btt *nd_btt; in __nd_btt_create() local
189 nd_btt = kzalloc(sizeof(*nd_btt), GFP_KERNEL); in __nd_btt_create()
190 if (!nd_btt) in __nd_btt_create()
193 nd_btt->id = ida_simple_get(&nd_region->btt_ida, 0, 0, GFP_KERNEL); in __nd_btt_create()
194 if (nd_btt->id < 0) in __nd_btt_create()
197 nd_btt->lbasize = lbasize; in __nd_btt_create()
203 nd_btt->uuid = uuid; in __nd_btt_create()
204 dev = &nd_btt->dev; in __nd_btt_create()
205 dev_set_name(dev, "btt%d.%d", nd_region->id, nd_btt->id); in __nd_btt_create()
208 device_initialize(&nd_btt->dev); in __nd_btt_create()
209 if (ndns && !__nd_attach_ndns(&nd_btt->dev, ndns, &nd_btt->ndns)) { in __nd_btt_create()
218 ida_simple_remove(&nd_region->btt_ida, nd_btt->id); in __nd_btt_create()
221 kfree(nd_btt); in __nd_btt_create()
245 bool nd_btt_arena_is_valid(struct nd_btt *nd_btt, struct btt_sb *super) in nd_btt_arena_is_valid() argument
247 const u8 *parent_uuid = nd_dev_to_uuid(&nd_btt->ndns->dev); in nd_btt_arena_is_valid()
265 dev_info(&nd_btt->dev, "Found arena with an error flag\n"); in nd_btt_arena_is_valid()
271 int nd_btt_version(struct nd_btt *nd_btt, struct nd_namespace_common *ndns, in nd_btt_version() argument
276 nd_btt->initial_offset = 0; in nd_btt_version()
277 nd_btt->version_major = 2; in nd_btt_version()
278 nd_btt->version_minor = 0; in nd_btt_version()
281 if (!nd_btt_arena_is_valid(nd_btt, btt_sb)) in nd_btt_version()
291 nd_btt->initial_offset = SZ_4K; in nd_btt_version()
292 nd_btt->version_major = 1; in nd_btt_version()
293 nd_btt->version_minor = 1; in nd_btt_version()
296 if (!nd_btt_arena_is_valid(nd_btt, btt_sb)) in nd_btt_version()
306 static int __nd_btt_probe(struct nd_btt *nd_btt, in __nd_btt_probe() argument
311 if (!btt_sb || !ndns || !nd_btt) in __nd_btt_probe()
317 rc = nd_btt_version(nd_btt, ndns, btt_sb); in __nd_btt_probe()
321 nd_btt->lbasize = le32_to_cpu(btt_sb->external_lbasize); in __nd_btt_probe()
322 nd_btt->uuid = kmemdup(btt_sb->uuid, 16, GFP_KERNEL); in __nd_btt_probe()
323 if (!nd_btt->uuid) in __nd_btt_probe()
326 __nd_device_register(&nd_btt->dev); in __nd_btt_probe()
359 struct nd_btt *nd_btt = to_nd_btt(btt_dev); in nd_btt_probe() local
361 nd_detach_ndns(btt_dev, &nd_btt->ndns); in nd_btt_probe()