Lines Matching +full:cfg +full:- +full:space
1 // SPDX-License-Identifier: GPL-2.0-or-later
27 * marshal_virt_to_resize() - translate uvirtual to resize structure
34 resize->hdr = virt->hdr; in marshal_virt_to_resize()
35 resize->context_id = virt->context_id; in marshal_virt_to_resize()
36 resize->rsrc_handle = virt->rsrc_handle; in marshal_virt_to_resize()
37 resize->req_size = virt->lun_size; in marshal_virt_to_resize()
38 resize->last_lba = virt->last_lba; in marshal_virt_to_resize()
42 * marshal_clone_to_rele() - translate clone to release structure
49 release->hdr = clone->hdr; in marshal_clone_to_rele()
50 release->context_id = clone->context_id_dst; in marshal_clone_to_rele()
54 * ba_init() - initializes a block allocator
57 * Return: 0 on success, -errno on failure
67 "ba_lun->lsize=%lx ba_lun->au_size=%lX\n", in ba_init()
68 __func__, ba_lun->lun_id, ba_lun->lsize, ba_lun->au_size); in ba_init()
71 lun_size_au = ba_lun->lsize / ba_lun->au_size; in ba_init()
74 return -EINVAL; in ba_init()
81 __func__, ba_lun->lun_id); in ba_init()
82 return -ENOMEM; in ba_init()
85 bali->total_aus = lun_size_au; in ba_init()
86 bali->lun_bmap_size = lun_size_au / BITS_PER_LONG; in ba_init()
89 bali->lun_bmap_size++; in ba_init()
91 /* Allocate bitmap space */ in ba_init()
92 bali->lun_alloc_map = kzalloc((bali->lun_bmap_size * sizeof(u64)), in ba_init()
94 if (unlikely(!bali->lun_alloc_map)) { in ba_init()
96 "lun_id=%016llx\n", __func__, ba_lun->lun_id); in ba_init()
98 return -ENOMEM; in ba_init()
102 bali->free_aun_cnt = lun_size_au; in ba_init()
104 for (i = 0; i < bali->lun_bmap_size; i++) in ba_init()
105 bali->lun_alloc_map[i] = 0xFFFFFFFFFFFFFFFFULL; in ba_init()
108 last_word_underflow = (bali->lun_bmap_size * BITS_PER_LONG); in ba_init()
109 last_word_underflow -= bali->free_aun_cnt; in ba_init()
111 lam = &bali->lun_alloc_map[bali->lun_bmap_size - 1]; in ba_init()
112 for (i = (HIBIT - last_word_underflow + 1); in ba_init()
119 bali->free_high_idx = bali->lun_bmap_size; in ba_init()
122 bali->aun_clone_map = kzalloc((bali->total_aus * sizeof(u8)), in ba_init()
124 if (unlikely(!bali->aun_clone_map)) { in ba_init()
126 __func__, ba_lun->lun_id); in ba_init()
127 kfree(bali->lun_alloc_map); in ba_init()
129 return -ENOMEM; in ba_init()
133 ba_lun->ba_lun_handle = bali; in ba_init()
137 __func__, ba_lun->lun_id, bali->lun_bmap_size, in ba_init()
138 bali->free_aun_cnt); in ba_init()
143 * find_free_range() - locates a free bit within the block allocator
149 * Return: The bit position within the passed back word, -1 on failure
156 u64 bit_pos = -1; in find_free_range()
160 if (bali->lun_alloc_map[i] != 0) { in find_free_range()
161 lam = (ulong *)&bali->lun_alloc_map[i]; in find_free_range()
167 __func__, bit_pos, bali->lun_alloc_map[i], i); in find_free_range()
170 bali->free_aun_cnt--; in find_free_range()
179 * ba_alloc() - allocates a block from the block allocator
182 * Return: The allocated block, -1 on failure
186 u64 bit_pos = -1; in ba_alloc()
190 bali = ba_lun->ba_lun_handle; in ba_alloc()
194 __func__, ba_lun->lun_id, bali->free_aun_cnt); in ba_alloc()
196 if (bali->free_aun_cnt == 0) { in ba_alloc()
197 pr_debug("%s: No space left on LUN: lun_id=%016llx\n", in ba_alloc()
198 __func__, ba_lun->lun_id); in ba_alloc()
199 return -1ULL; in ba_alloc()
202 /* Search to find a free entry, curr->high then low->curr */ in ba_alloc()
203 bit_pos = find_free_range(bali->free_curr_idx, in ba_alloc()
204 bali->free_high_idx, bali, &bit_word); in ba_alloc()
205 if (bit_pos == -1) { in ba_alloc()
206 bit_pos = find_free_range(bali->free_low_idx, in ba_alloc()
207 bali->free_curr_idx, in ba_alloc()
209 if (bit_pos == -1) { in ba_alloc()
211 " lun_id=%016llx\n", __func__, ba_lun->lun_id); in ba_alloc()
212 return -1ULL; in ba_alloc()
218 bali->free_curr_idx = bit_word + 1; in ba_alloc()
220 bali->free_curr_idx = bit_word; in ba_alloc()
224 ((bit_word * BITS_PER_LONG) + bit_pos), ba_lun->lun_id, in ba_alloc()
225 bali->free_aun_cnt); in ba_alloc()
231 * validate_alloc() - validates the specified block has been allocated
235 * Return: 0 on success, -1 on failure
244 if (test_bit(bit_pos, (ulong *)&bali->lun_alloc_map[idx])) in validate_alloc()
245 return -1; in validate_alloc()
251 * ba_free() - frees a block from the block allocator
255 * Return: 0 on success, -1 on failure
262 bali = ba_lun->ba_lun_handle; in ba_free()
266 __func__, to_free, ba_lun->lun_id); in ba_free()
267 return -1; in ba_free()
271 "free_aun_cnt=%llx\n", __func__, to_free, ba_lun->lun_id, in ba_free()
272 bali->free_aun_cnt); in ba_free()
274 if (bali->aun_clone_map[to_free] > 0) { in ba_free()
276 __func__, to_free, ba_lun->lun_id, in ba_free()
277 bali->aun_clone_map[to_free]); in ba_free()
278 bali->aun_clone_map[to_free]--; in ba_free()
285 set_bit(bit_pos, (ulong *)&bali->lun_alloc_map[idx]); in ba_free()
286 bali->free_aun_cnt++; in ba_free()
288 if (idx < bali->free_low_idx) in ba_free()
289 bali->free_low_idx = idx; in ba_free()
290 else if (idx > bali->free_high_idx) in ba_free()
291 bali->free_high_idx = idx; in ba_free()
295 ba_lun->lun_id, bali->free_aun_cnt); in ba_free()
301 * ba_clone() - Clone a chunk of the block allocation table
305 * Return: 0 on success, -1 on failure
309 struct ba_lun_info *bali = ba_lun->ba_lun_handle; in ba_clone()
313 __func__, to_clone, ba_lun->lun_id); in ba_clone()
314 return -1; in ba_clone()
318 __func__, to_clone, ba_lun->lun_id); in ba_clone()
320 if (bali->aun_clone_map[to_clone] == MAX_AUN_CLONE_CNT) { in ba_clone()
322 __func__, to_clone, ba_lun->lun_id); in ba_clone()
323 return -1; in ba_clone()
326 bali->aun_clone_map[to_clone]++; in ba_clone()
332 * ba_space() - returns the amount of free space left in the block allocator
335 * Return: Amount of free space in block allocator
339 struct ba_lun_info *bali = ba_lun->ba_lun_handle; in ba_space()
341 return bali->free_aun_cnt; in ba_space()
345 * cxlflash_ba_terminate() - frees resources associated with the block allocator
352 struct ba_lun_info *bali = ba_lun->ba_lun_handle; in cxlflash_ba_terminate()
355 kfree(bali->aun_clone_map); in cxlflash_ba_terminate()
356 kfree(bali->lun_alloc_map); in cxlflash_ba_terminate()
358 ba_lun->ba_lun_handle = NULL; in cxlflash_ba_terminate()
363 * init_vlun() - initializes a LUN for virtual use
366 * Return: 0 on success, -errno on failure
371 struct glun_info *gli = lli->parent; in init_vlun()
372 struct blka *blka = &gli->blka; in init_vlun()
375 mutex_init(&blka->mutex); in init_vlun()
378 blka->ba_lun.lun_id = lli->lun_index; in init_vlun()
379 blka->ba_lun.lsize = gli->max_lba + 1; in init_vlun()
380 blka->ba_lun.lba_size = gli->blk_len; in init_vlun()
382 blka->ba_lun.au_size = MC_CHUNK_SIZE; in init_vlun()
383 blka->nchunk = blka->ba_lun.lsize / MC_CHUNK_SIZE; in init_vlun()
385 rc = ba_init(&blka->ba_lun); in init_vlun()
394 * write_same16() - sends a SCSI WRITE_SAME16 (0) command to specified LUN
417 * Return: 0 on success, -errno on failure
429 struct cxlflash_cfg *cfg = shost_priv(sdev->host); in write_same16() local
430 struct device *dev = &cfg->dev->dev; in write_same16()
431 const u32 s = ilog2(sdev->sector_size) - 9; in write_same16()
432 const u32 to = sdev->request_queue->rq_timeout; in write_same16()
434 sdev->request_queue->limits.max_write_zeroes_sectors >> s; in write_same16()
439 rc = -ENOMEM; in write_same16()
446 scsi_cmd[1] = cfg->ws_unmap ? 0x8 : 0; in write_same16()
452 up_read(&cfg->ioctl_rwsem); in write_same16()
456 down_read(&cfg->ioctl_rwsem); in write_same16()
457 rc = check_state(cfg); in write_same16()
461 rc = -ENODEV; in write_same16()
469 rc = -EIO; in write_same16()
472 left -= ws_limit; in write_same16()
484 * grow_lxt() - expands the translation table associated with the specified RHTE
493 * truncate the requested size down if there is not sufficient space in
495 * amount of space. The user is made aware of this by returning the size
498 * Return: 0 on success, -errno on failure
507 struct cxlflash_cfg *cfg = shost_priv(sdev->host); in grow_lxt() local
508 struct device *dev = &cfg->dev->dev; in grow_lxt()
510 struct llun_info *lli = sdev->hostdata; in grow_lxt()
511 struct glun_info *gli = lli->parent; in grow_lxt()
512 struct blka *blka = &gli->blka; in grow_lxt()
516 u64 delta = *new_size - rhte->lxt_cnt; in grow_lxt()
521 * Check what is available in the block allocator before re-allocating in grow_lxt()
525 mutex_lock(&blka->mutex); in grow_lxt()
526 av_size = ba_space(&blka->ba_lun); in grow_lxt()
530 mutex_unlock(&blka->mutex); in grow_lxt()
531 rc = -ENOSPC; in grow_lxt()
538 lxt_old = rhte->lxt_start; in grow_lxt()
539 ngrps_old = LXT_NUM_GROUPS(rhte->lxt_cnt); in grow_lxt()
540 ngrps = LXT_NUM_GROUPS(rhte->lxt_cnt + delta); in grow_lxt()
547 mutex_unlock(&blka->mutex); in grow_lxt()
548 rc = -ENOMEM; in grow_lxt()
553 memcpy(lxt, lxt_old, (sizeof(*lxt) * rhte->lxt_cnt)); in grow_lxt()
558 my_new_size = rhte->lxt_cnt + delta; in grow_lxt()
561 for (i = rhte->lxt_cnt; i < my_new_size; i++) { in grow_lxt()
563 * Due to the earlier check of available space, ba_alloc in grow_lxt()
565 * leave a rlba_base of -1u which will likely be a in grow_lxt()
568 aun = ba_alloc(&blka->ba_lun); in grow_lxt()
569 if ((aun == -1ULL) || (aun >= blka->nchunk)) in grow_lxt()
571 "max=%llu\n", __func__, aun, blka->nchunk - 1); in grow_lxt()
575 (lli->lun_index << LXT_LUNIDX_SHIFT) | in grow_lxt()
577 lli->port_sel)); in grow_lxt()
580 mutex_unlock(&blka->mutex); in grow_lxt()
588 rhte->lxt_start = lxt; in grow_lxt()
591 rhte->lxt_cnt = my_new_size; in grow_lxt()
596 rc = -EAGAIN; in grow_lxt()
608 * shrink_lxt() - reduces translation table associated with the specified RHTE
616 * Return: 0 on success, -errno on failure
625 struct cxlflash_cfg *cfg = shost_priv(sdev->host); in shrink_lxt() local
626 struct device *dev = &cfg->dev->dev; in shrink_lxt()
628 struct llun_info *lli = sdev->hostdata; in shrink_lxt()
629 struct glun_info *gli = lli->parent; in shrink_lxt()
630 struct blka *blka = &gli->blka; in shrink_lxt()
631 ctx_hndl_t ctxid = DECODE_CTXID(ctxi->ctxid); in shrink_lxt()
632 bool needs_ws = ctxi->rht_needs_ws[rhndl]; in shrink_lxt()
633 bool needs_sync = !ctxi->err_recovery_active; in shrink_lxt()
636 u64 delta = rhte->lxt_cnt - *new_size; in shrink_lxt()
640 lxt_old = rhte->lxt_start; in shrink_lxt()
641 ngrps_old = LXT_NUM_GROUPS(rhte->lxt_cnt); in shrink_lxt()
642 ngrps = LXT_NUM_GROUPS(rhte->lxt_cnt - delta); in shrink_lxt()
650 rc = -ENOMEM; in shrink_lxt()
656 (sizeof(*lxt) * (rhte->lxt_cnt - delta))); in shrink_lxt()
663 my_new_size = rhte->lxt_cnt - delta; in shrink_lxt()
669 rhte->lxt_cnt = my_new_size; in shrink_lxt()
672 rhte->lxt_start = lxt; in shrink_lxt()
678 rc = -EAGAIN; in shrink_lxt()
686 ctxi->unavail = true; in shrink_lxt()
687 mutex_unlock(&ctxi->mutex); in shrink_lxt()
691 mutex_lock(&blka->mutex); in shrink_lxt()
692 for (i = delta - 1; i >= 0; i--) { in shrink_lxt()
696 ba_free(&blka->ba_lun, aun); in shrink_lxt()
698 mutex_unlock(&blka->mutex); in shrink_lxt()
702 mutex_lock(&ctxi->mutex); in shrink_lxt()
703 ctxi->unavail = false; in shrink_lxt()
716 * _cxlflash_vlun_resize() - changes the size of a virtual LUN
723 * LUN is zero, the last LBA is reflected as -1. See comment in the
727 * Return: 0 on success, -errno on failure
733 struct cxlflash_cfg *cfg = shost_priv(sdev->host); in _cxlflash_vlun_resize() local
734 struct device *dev = &cfg->dev->dev; in _cxlflash_vlun_resize()
735 struct llun_info *lli = sdev->hostdata; in _cxlflash_vlun_resize()
736 struct glun_info *gli = lli->parent; in _cxlflash_vlun_resize()
737 struct afu *afu = cfg->afu; in _cxlflash_vlun_resize()
740 res_hndl_t rhndl = resize->rsrc_handle; in _cxlflash_vlun_resize()
743 u64 ctxid = DECODE_CTXID(resize->context_id), in _cxlflash_vlun_resize()
744 rctxid = resize->context_id; in _cxlflash_vlun_resize()
754 nsectors = (resize->req_size * CXLFLASH_BLOCK_SIZE) / gli->blk_len; in _cxlflash_vlun_resize()
758 __func__, ctxid, resize->rsrc_handle, resize->req_size, in _cxlflash_vlun_resize()
761 if (unlikely(gli->mode != MODE_VIRTUAL)) { in _cxlflash_vlun_resize()
763 __func__, gli->mode); in _cxlflash_vlun_resize()
764 rc = -EINVAL; in _cxlflash_vlun_resize()
770 ctxi = get_context(cfg, rctxid, lli, CTX_CTRL_ERR_FALLBACK); in _cxlflash_vlun_resize()
774 rc = -EINVAL; in _cxlflash_vlun_resize()
785 rc = -EINVAL; in _cxlflash_vlun_resize()
789 if (new_size > rhte->lxt_cnt) in _cxlflash_vlun_resize()
791 else if (new_size < rhte->lxt_cnt) in _cxlflash_vlun_resize()
795 * Rare case where there is already sufficient space, just in _cxlflash_vlun_resize()
804 rc = -EAGAIN; in _cxlflash_vlun_resize()
809 resize->hdr.return_flags = 0; in _cxlflash_vlun_resize()
810 resize->last_lba = (new_size * MC_CHUNK_SIZE * gli->blk_len); in _cxlflash_vlun_resize()
811 resize->last_lba /= CXLFLASH_BLOCK_SIZE; in _cxlflash_vlun_resize()
812 resize->last_lba--; in _cxlflash_vlun_resize()
818 __func__, resize->last_lba, rc); in _cxlflash_vlun_resize()
829 * cxlflash_restore_luntable() - Restore LUN table to prior state
830 * @cfg: Internal structure associated with the host.
832 void cxlflash_restore_luntable(struct cxlflash_cfg *cfg) in cxlflash_restore_luntable() argument
837 struct device *dev = &cfg->dev->dev; in cxlflash_restore_luntable()
842 list_for_each_entry_safe(lli, temp, &cfg->lluns, list) { in cxlflash_restore_luntable()
843 if (!lli->in_table) in cxlflash_restore_luntable()
846 lind = lli->lun_index; in cxlflash_restore_luntable()
849 for (k = 0; k < cfg->num_fc_ports; k++) in cxlflash_restore_luntable()
850 if (lli->port_sel & (1 << k)) { in cxlflash_restore_luntable()
851 fc_port_luns = get_fc_port_luns(cfg, k); in cxlflash_restore_luntable()
852 writeq_be(lli->lun_id[k], &fc_port_luns[lind]); in cxlflash_restore_luntable()
853 dev_dbg(dev, "\t%d=%llx\n", k, lli->lun_id[k]); in cxlflash_restore_luntable()
861 * get_num_ports() - compute number of ports from port selection mask
875 * init_luntable() - write an entry in the LUN table
876 * @cfg: Internal structure associated with the host.
880 * - at the top for LUNs visible on multiple ports.
881 * - at the bottom for LUNs visible only on one port.
883 * Return: 0 on success, -errno on failure
885 static int init_luntable(struct cxlflash_cfg *cfg, struct llun_info *lli) in init_luntable() argument
892 struct device *dev = &cfg->dev->dev; in init_luntable()
897 if (lli->in_table) in init_luntable()
900 nports = get_num_ports(lli->port_sel); in init_luntable()
901 if (nports == 0 || nports > cfg->num_fc_ports) { in init_luntable()
903 rc = -EIO; in init_luntable()
912 for (k = 0; k < cfg->num_fc_ports; k++) { in init_luntable()
913 if (!(lli->port_sel & (1 << k))) in init_luntable()
916 if (cfg->promote_lun_index == cfg->last_lun_index[k]) { in init_luntable()
917 rc = -ENOSPC; in init_luntable()
922 lind = lli->lun_index = cfg->promote_lun_index; in init_luntable()
925 for (k = 0; k < cfg->num_fc_ports; k++) { in init_luntable()
926 if (!(lli->port_sel & (1 << k))) in init_luntable()
929 fc_port_luns = get_fc_port_luns(cfg, k); in init_luntable()
930 writeq_be(lli->lun_id[k], &fc_port_luns[lind]); in init_luntable()
931 dev_dbg(dev, "\t%d=%llx\n", k, lli->lun_id[k]); in init_luntable()
934 cfg->promote_lun_index++; in init_luntable()
940 chan = PORTMASK2CHAN(lli->port_sel); in init_luntable()
941 if (cfg->promote_lun_index == cfg->last_lun_index[chan]) { in init_luntable()
942 rc = -ENOSPC; in init_luntable()
946 lind = lli->lun_index = cfg->last_lun_index[chan]; in init_luntable()
947 fc_port_luns = get_fc_port_luns(cfg, chan); in init_luntable()
948 writeq_be(lli->lun_id[chan], &fc_port_luns[lind]); in init_luntable()
949 cfg->last_lun_index[chan]--; in init_luntable()
951 __func__, lind, chan, lli->lun_id[chan]); in init_luntable()
954 lli->in_table = true; in init_luntable()
962 * cxlflash_disk_virtual_open() - open a virtual disk of specified size
969 * is zero, the last LBA is reflected as -1.
971 * Return: 0 on success, -errno on failure
975 struct cxlflash_cfg *cfg = shost_priv(sdev->host); in cxlflash_disk_virtual_open() local
976 struct device *dev = &cfg->dev->dev; in cxlflash_disk_virtual_open()
977 struct llun_info *lli = sdev->hostdata; in cxlflash_disk_virtual_open()
978 struct glun_info *gli = lli->parent; in cxlflash_disk_virtual_open()
983 u64 ctxid = DECODE_CTXID(virt->context_id), in cxlflash_disk_virtual_open()
984 rctxid = virt->context_id; in cxlflash_disk_virtual_open()
985 u64 lun_size = virt->lun_size; in cxlflash_disk_virtual_open()
987 u64 rsrc_handle = -1; in cxlflash_disk_virtual_open()
997 mutex_lock(&gli->mutex); in cxlflash_disk_virtual_open()
998 if (gli->mode == MODE_NONE) { in cxlflash_disk_virtual_open()
1003 rc = -ENOMEM; in cxlflash_disk_virtual_open()
1013 mutex_unlock(&gli->mutex); in cxlflash_disk_virtual_open()
1015 rc = init_luntable(cfg, lli); in cxlflash_disk_virtual_open()
1021 ctxi = get_context(cfg, rctxid, lli, 0); in cxlflash_disk_virtual_open()
1024 rc = -EINVAL; in cxlflash_disk_virtual_open()
1032 rc = -EMFILE; /* too many opens */ in cxlflash_disk_virtual_open()
1036 rsrc_handle = (rhte - ctxi->rht_start); in cxlflash_disk_virtual_open()
1039 rhte->nmask = MC_RHT_NMASK; in cxlflash_disk_virtual_open()
1040 rhte->fp = SISL_RHT_FP(0U, ctxi->rht_perms); in cxlflash_disk_virtual_open()
1052 if (virt->hdr.flags & DK_CXLFLASH_UVIRTUAL_NEED_WRITE_SAME) in cxlflash_disk_virtual_open()
1053 ctxi->rht_needs_ws[rsrc_handle] = true; in cxlflash_disk_virtual_open()
1055 virt->hdr.return_flags = 0; in cxlflash_disk_virtual_open()
1056 virt->last_lba = last_lba; in cxlflash_disk_virtual_open()
1057 virt->rsrc_handle = rsrc_handle; in cxlflash_disk_virtual_open()
1059 if (get_num_ports(lli->port_sel) > 1) in cxlflash_disk_virtual_open()
1060 virt->hdr.return_flags |= DK_CXLFLASH_ALL_PORTS_ACTIVE; in cxlflash_disk_virtual_open()
1075 cxlflash_ba_terminate(&gli->blka.ba_lun); in cxlflash_disk_virtual_open()
1076 mutex_unlock(&gli->mutex); in cxlflash_disk_virtual_open()
1081 * clone_lxt() - copies translation tables from source to destination RHTE
1089 * Return: 0 on success, -errno on failure
1098 struct cxlflash_cfg *cfg = afu->parent; in clone_lxt() local
1099 struct device *dev = &cfg->dev->dev; in clone_lxt()
1108 ngrps = LXT_NUM_GROUPS(rhte_src->lxt_cnt); in clone_lxt()
1115 rc = -ENOMEM; in clone_lxt()
1120 memcpy(lxt, rhte_src->lxt_start, in clone_lxt()
1121 (sizeof(*lxt) * rhte_src->lxt_cnt)); in clone_lxt()
1128 mutex_lock(&blka->mutex); in clone_lxt()
1130 for (i = 0; i < rhte_src->lxt_cnt; i++) { in clone_lxt()
1132 if (ba_clone(&blka->ba_lun, aun) == -1ULL) { in clone_lxt()
1133 rc = -EIO; in clone_lxt()
1145 rhte->lxt_start = lxt; in clone_lxt()
1148 rhte->lxt_cnt = rhte_src->lxt_cnt; in clone_lxt()
1153 rc = -EAGAIN; in clone_lxt()
1159 mutex_unlock(&blka->mutex); in clone_lxt()
1164 rhte->lxt_cnt = 0; in clone_lxt()
1166 rhte->lxt_start = NULL; in clone_lxt()
1172 ba_free(&blka->ba_lun, aun); in clone_lxt()
1179 * cxlflash_disk_clone() - clone a context by making snapshot of another
1184 * in-use virtual resource in the source context. Note that the destination
1188 * Return: 0 on success, -errno on failure
1193 struct cxlflash_cfg *cfg = shost_priv(sdev->host); in cxlflash_disk_clone() local
1194 struct device *dev = &cfg->dev->dev; in cxlflash_disk_clone()
1195 struct llun_info *lli = sdev->hostdata; in cxlflash_disk_clone()
1196 struct glun_info *gli = lli->parent; in cxlflash_disk_clone()
1197 struct blka *blka = &gli->blka; in cxlflash_disk_clone()
1198 struct afu *afu = cfg->afu; in cxlflash_disk_clone()
1205 u64 ctxid_src = DECODE_CTXID(clone->context_id_src), in cxlflash_disk_clone()
1206 ctxid_dst = DECODE_CTXID(clone->context_id_dst), in cxlflash_disk_clone()
1207 rctxid_src = clone->context_id_src, in cxlflash_disk_clone()
1208 rctxid_dst = clone->context_id_dst; in cxlflash_disk_clone()
1219 rc = -EINVAL; in cxlflash_disk_clone()
1223 if (unlikely(gli->mode != MODE_VIRTUAL)) { in cxlflash_disk_clone()
1224 rc = -EINVAL; in cxlflash_disk_clone()
1226 __func__, gli->mode); in cxlflash_disk_clone()
1230 ctxi_src = get_context(cfg, rctxid_src, lli, CTX_CTRL_CLONE); in cxlflash_disk_clone()
1231 ctxi_dst = get_context(cfg, rctxid_dst, lli, 0); in cxlflash_disk_clone()
1235 rc = -EINVAL; in cxlflash_disk_clone()
1241 if (ctxi_dst->rht_start[i].nmask != 0) { in cxlflash_disk_clone()
1242 rc = -EINVAL; in cxlflash_disk_clone()
1247 list_for_each_entry(lun_access_src, &ctxi_src->luns, list) { in cxlflash_disk_clone()
1249 list_for_each_entry(lun_access_dst, &ctxi_dst->luns, list) in cxlflash_disk_clone()
1250 if (lun_access_dst->sdev == lun_access_src->sdev) { in cxlflash_disk_clone()
1261 rc = -ENOMEM; in cxlflash_disk_clone()
1266 list_add(&lun_access_dst->list, &sidecar); in cxlflash_disk_clone()
1270 if (unlikely(!ctxi_src->rht_out)) { in cxlflash_disk_clone()
1276 perms = ctxi_dst->rht_perms; in cxlflash_disk_clone()
1279 * Copy over checked-out RHT (and their associated LXT) entries by in cxlflash_disk_clone()
1290 if (ctxi_src->rht_out == ctxi_dst->rht_out) in cxlflash_disk_clone()
1292 if (ctxi_src->rht_start[i].nmask == 0) in cxlflash_disk_clone()
1296 ctxi_dst->rht_out++; in cxlflash_disk_clone()
1297 ctxi_dst->rht_start[i].nmask = ctxi_src->rht_start[i].nmask; in cxlflash_disk_clone()
1298 ctxi_dst->rht_start[i].fp = in cxlflash_disk_clone()
1299 SISL_RHT_FP_CLONE(ctxi_src->rht_start[i].fp, perms); in cxlflash_disk_clone()
1300 ctxi_dst->rht_lun[i] = ctxi_src->rht_lun[i]; in cxlflash_disk_clone()
1303 &ctxi_dst->rht_start[i], in cxlflash_disk_clone()
1304 &ctxi_src->rht_start[i]); in cxlflash_disk_clone()
1314 rhte_checkin(ctxi_dst, &ctxi_dst->rht_start[i]); in cxlflash_disk_clone()
1318 cxlflash_lun_attach(gli, gli->mode, false); in cxlflash_disk_clone()
1322 list_splice(&sidecar, &ctxi_dst->luns); in cxlflash_disk_clone()