Changeset 978130a in mainline for uspace/srv/bd/hr/raid0.c
- Timestamp:
- 2024-10-28T16:03:24Z (7 months ago)
- Children:
- 4dd650a
- Parents:
- 76cd345
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/hr/raid0.c
r76cd345 r978130a 74 74 }; 75 75 76 static void raid0_geometry(uint64_t x, hr_volume_t *vol, size_t *extent,77 uint64_t *phys_block)78 {79 uint64_t N = vol->dev_no; /* extents */80 uint64_t L = vol->strip_size / vol->bsize; /* size of strip in blocks */81 82 uint64_t i = (x / L) % N; /* extent */83 uint64_t j = (x / L) / N; /* stripe */84 uint64_t k = x % L; /* strip offset */85 86 *extent = i;87 *phys_block = j * L + k;88 }89 90 76 static errno_t hr_raid0_bd_open(bd_srvs_t *bds, bd_srv_t *bd) 91 77 { … … 106 92 errno_t rc; 107 93 uint64_t phys_block; 108 size_t extent,left;94 size_t left; 109 95 110 96 if (type == HR_BD_READ || type == HR_BD_WRITE) … … 116 102 return rc; 117 103 104 uint64_t strip_size = vol->strip_size / vol->bsize; /* in blocks */ 105 uint64_t stripe = ba / strip_size; /* stripe number */ 106 uint64_t extent = stripe % vol->dev_no; 107 uint64_t ext_stripe = stripe / vol->dev_no; /* stripe level */ 108 uint64_t strip_off = ba % strip_size; /* strip offset */ 109 118 110 fibril_mutex_lock(&vol->lock); 119 111 120 112 left = cnt; 121 113 while (left != 0) { 122 raid0_geometry(ba, vol, &extent, &phys_block); 114 phys_block = ext_stripe * strip_size + strip_off; 115 cnt = min(left, strip_size - strip_off); 123 116 hr_add_ba_offset(vol, &phys_block); 124 117 switch (type) { 125 118 case HR_BD_SYNC: 126 119 rc = block_sync_cache(vol->extents[extent].svc_id, 127 phys_block, 1);120 phys_block, cnt); 128 121 break; 129 122 case HR_BD_READ: 130 123 rc = block_read_direct(vol->extents[extent].svc_id, 131 phys_block, 1, data_read); 132 data_read = data_read + vol->bsize; 124 phys_block, cnt, data_read); 125 data_read = (void *) ((uintptr_t) data_read + 126 (vol->bsize * cnt)); 133 127 break; 134 128 case HR_BD_WRITE: 135 129 rc = block_write_direct(vol->extents[extent].svc_id, 136 phys_block, 1, data_write); 137 data_write = data_write + vol->bsize; 130 phys_block, cnt, data_write); 131 data_write = (void *) ((uintptr_t) data_write + 132 (vol->bsize * cnt)); 138 133 break; 139 134 default: 140 135 rc = EINVAL; 141 136 } 142 143 137 if (rc != EOK) 144 138 goto error; 145 139 146 left--; 147 ba++; 140 left -= cnt; 141 strip_off = 0; 142 extent++; 143 if (extent >= vol->dev_no) { 144 ext_stripe++; 145 extent = 0; 146 } 148 147 } 149 148
Note:
See TracChangeset
for help on using the changeset viewer.