| 1 | /* |
| 2 | * Copyright (C) 2025, Northwestern University and Argonne National Laboratory |
| 3 | * See COPYRIGHT notice in top-level directory. |
| 4 | */ |
| 5 | |
| 6 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:410:9`! |
| 7 | # include <config.h>cxx . . $ `<file>/src/include/config.h`/ |
| 8 | #endif |
| 9 | |
| 10 | #include <pncio.h>cxx . . $ `<file>/src/drivers/pncio/pncio.h`/ |
| 11 | |
| 12 | |
| 13 | #define BUFFERED_WRITEcxx . . $ `src/drivers/pncio/pncio_lustre_wrstr.c:13:9`! { \ |
| 14 | if (req_off >= writebuf_off + writebuf_len) { \ |
| 15 | if (writebuf_len) { \ |
| 16 | w_len = PNCIO_WriteContig(fd, writebuf, writebuf_len, \ |
| 17 | writebuf_off); \ |
| 18 | if (!fd->atomicity && fd->hints->romio_ds_write == PNCIO_HINT_DISABLEcxx . . $ `src/drivers/pncio/pncio.h:106:9`!) \ |
| 19 | PNCIO_UNLOCKcxx . . $ `src/drivers/pncio/pncio.h:39:9`!(fd, writebuf_off, SEEK_SETcxx . . $ `<external>/14710646456994434043/fcntl.h:137:10`!, writebuf_len); \ |
| 20 | if (w_len < 0) { \ |
| 21 | NCI_Freecxx . . $ `src/drivers/include/common.h:80:9`!(writebuf); \ |
| 22 | return w_len; \ |
| 23 | } \ |
| 24 | total_w_len += w_len; \ |
| 25 | writebuf_off = req_off; \ |
| 26 | } \ |
| 27 | writebuf_off = req_off; \ |
| 28 | /* stripe_size alignment */ \ |
| 29 | writebuf_len = MINcxx . . $ `src/drivers/include/common.h:25:9`!(end_offset - writebuf_off + 1, \ |
| 30 | (writebuf_off / stripe_size + 1) * stripe_size \ |
| 31 | - writebuf_off); \ |
| 32 | if (!fd->atomicity && fd->hints->romio_ds_write == PNCIO_HINT_DISABLEcxx . . $ `src/drivers/pncio/pncio.h:106:9`!) \ |
| 33 | PNCIO_WRITE_LOCKcxx . . $ `src/drivers/pncio/pncio.h:41:9`!(fd, writebuf_off, SEEK_SETcxx . . $ `<external>/14710646456994434043/fcntl.h:137:10`!, writebuf_len); \ |
| 34 | r_len = PNCIO_ReadContig(fd, writebuf, writebuf_len, writebuf_off); \ |
| 35 | if (r_len < 0) { \ |
| 36 | NCI_Freecxx . . $ `src/drivers/include/common.h:80:9`!(writebuf); \ |
| 37 | return r_len; \ |
| 38 | } \ |
| 39 | } \ |
| 40 | write_sz = (MINcxx . . $ `src/drivers/include/common.h:25:9`!(req_len, writebuf_off + writebuf_len - req_off)); \ |
| 41 | memcpy(writebuf + req_off - writebuf_off, (char *)buf + userbuf_off, \ |
| 42 | write_sz); \ |
| 43 | while (write_sz != req_len) { \ |
| 44 | w_len = PNCIO_WriteContig(fd, writebuf, writebuf_len, writebuf_off); \ |
| 45 | if (!fd->atomicity && fd->hints->romio_ds_write == PNCIO_HINT_DISABLEcxx . . $ `src/drivers/pncio/pncio.h:106:9`!) \ |
| 46 | PNCIO_UNLOCKcxx . . $ `src/drivers/pncio/pncio.h:39:9`!(fd, writebuf_off, SEEK_SETcxx . . $ `<external>/14710646456994434043/fcntl.h:137:10`!, writebuf_len); \ |
| 47 | if (w_len < 0) { \ |
| 48 | NCI_Freecxx . . $ `src/drivers/include/common.h:80:9`!(writebuf); \ |
| 49 | return w_len; \ |
| 50 | } \ |
| 51 | total_w_len += w_len; \ |
| 52 | req_len -= write_sz; \ |
| 53 | userbuf_off += write_sz; \ |
| 54 | writebuf_off += writebuf_len; \ |
| 55 | /* stripe_size alignment */ \ |
| 56 | writebuf_len = MINcxx . . $ `src/drivers/include/common.h:25:9`!(end_offset - writebuf_off + 1, \ |
| 57 | (writebuf_off / stripe_size + 1) * stripe_size \ |
| 58 | - writebuf_off); \ |
| 59 | if (!fd->atomicity && fd->hints->romio_ds_write == PNCIO_HINT_DISABLEcxx . . $ `src/drivers/pncio/pncio.h:106:9`!) \ |
| 60 | PNCIO_WRITE_LOCKcxx . . $ `src/drivers/pncio/pncio.h:41:9`!(fd, writebuf_off, SEEK_SETcxx . . $ `<external>/14710646456994434043/fcntl.h:137:10`!, writebuf_len); \ |
| 61 | r_len = PNCIO_ReadContig(fd, writebuf, writebuf_len, writebuf_off); \ |
| 62 | if (r_len < 0) { \ |
| 63 | NCI_Freecxx . . $ `src/drivers/include/common.h:80:9`!(writebuf); \ |
| 64 | return r_len; \ |
| 65 | } \ |
| 66 | write_sz = MINcxx . . $ `src/drivers/include/common.h:25:9`!(req_len, writebuf_len); \ |
| 67 | memcpy(writebuf, (char *)buf + userbuf_off, write_sz); \ |
| 68 | } \ |
| 69 | } |
| 70 | |
| 71 | /* this macro is used when filetype is contig and buftype is not contig. |
| 72 | * it does not do a read-modify-write and does not lock |
| 73 | */ |
| 74 | #define BUFFERED_WRITE_WITHOUT_READcxx . . $ `src/drivers/pncio/pncio_lustre_wrstr.c:74:9`! { \ |
| 75 | if (req_off >= writebuf_off + writebuf_len) { \ |
| 76 | w_len = PNCIO_WriteContig(fd, writebuf, writebuf_len, writebuf_off); \ |
| 77 | if (w_len < 0) { \ |
| 78 | NCI_Freecxx . . $ `src/drivers/include/common.h:80:9`!(writebuf); \ |
| 79 | return w_len; \ |
| 80 | } \ |
| 81 | total_w_len += w_len; \ |
| 82 | writebuf_off = req_off; \ |
| 83 | /* stripe_size alignment */ \ |
| 84 | writebuf_len = MINcxx . . $ `src/drivers/include/common.h:25:9`!(end_offset - writebuf_off + 1, \ |
| 85 | (writebuf_off / stripe_size + 1) * stripe_size \ |
| 86 | - writebuf_off); \ |
| 87 | } \ |
| 88 | write_sz = MINcxx . . $ `src/drivers/include/common.h:25:9`!(req_len, writebuf_off + writebuf_len - req_off); \ |
| 89 | memcpy(writebuf + req_off - writebuf_off, \ |
| 90 | (char *)buf + userbuf_off, write_sz); \ |
| 91 | while (write_sz != req_len) { \ |
| 92 | w_len = PNCIO_WriteContig(fd, writebuf, writebuf_len, writebuf_off); \ |
| 93 | if (w_len < 0) { \ |
| 94 | NCI_Freecxx . . $ `src/drivers/include/common.h:80:9`!(writebuf); \ |
| 95 | return w_len; \ |
| 96 | } \ |
| 97 | total_w_len += w_len; \ |
| 98 | req_len -= write_sz; \ |
| 99 | userbuf_off += write_sz; \ |
| 100 | writebuf_off += writebuf_len; \ |
| 101 | /* stripe_size alignment */ \ |
| 102 | writebuf_len = MINcxx . . $ `src/drivers/include/common.h:25:9`!(end_offset - writebuf_off + 1, \ |
| 103 | (writebuf_off / stripe_size + 1) * stripe_size \ |
| 104 | - writebuf_off); \ |
| 105 | write_sz = MINcxx . . $ `src/drivers/include/common.h:25:9`!(req_len, writebuf_len); \ |
| 106 | memcpy(writebuf, (char *)buf + userbuf_off, write_sz); \ |
| 107 | } \ |
| 108 | } |
| 109 | |
| 110 | MPI_Offsetcxx . . $ MPI_Offset# PNCIO_LUSTRE_WriteStridedcxx . . $ PNCIO_LUSTRE_WriteStrided(f507f2b8c20624fe).(PNCIO_Filecxx . . $ PNCIO_File# *fd, |
| 111 | const void *buf, |
| 112 | PNCIO_Viewcxx . . $ PNCIO_View# buf_view, |
| 113 | MPI_Offsetcxx . . $ MPI_Offset# offset) |
| 114 | { |
| 115 | char *writebuf; |
| 116 | int i, j, k, st_index=0, stripe_size; |
| 117 | /* offset is in units of etype relative to the filetype. */ |
| 118 | MPI_Offsetcxx . . $ MPI_Offset# i_offset, sum, num, size, abs_off_in_filetype=0, off, disp; |
| 119 | MPI_Offsetcxx . . $ MPI_Offset# userbuf_off, req_off, end_offset=0, writebuf_off, start_off; |
| 120 | MPI_Offsetcxx . . $ MPI_Offset# new_bwr_size, new_fwr_size, st_fwr_size, fwr_size=0, bwr_size; |
| 121 | MPI_Offsetcxx . . $ MPI_Offset# req_len, r_len, w_len, total_w_len=0; |
| 122 | MPI_Countcxx . . $ MPI_Count# bufsize, writebuf_len, write_sz; |
| 123 | |
| 124 | /* The case of both buftype and filetype being contiguous has gone to |
| 125 | * PNCIO_WriteContig(). |
| 126 | */ |
| 127 | |
| 128 | // printf("%s at %d:\n",__func__,__LINE__); |
| 129 | |
| 130 | if (fd->hintscxx . . $ $anonymous_type_c9d83daee76f2_2#hints.->romio_ds_writecxx . . $ $anonymous_type_c9d83daee76f2_0#romio_ds_write. == PNCIO_HINT_DISABLEcxx . . $ `src/drivers/pncio/pncio.h:106:9`!) { |
| 131 | /* if user has disabled data sieving on writes, use naive |
| 132 | * approach instead. |
| 133 | */ |
| 134 | return PNCIO_GEN_WriteStrided_naivecxx . . $ PNCIO_GEN_WriteStrided_naive(f507f2b8c20624fe).(fd, buf, buf_view, offset); |
| 135 | } |
| 136 | |
| 137 | |
| 138 | /* PnetCDF always sets these 3 conditions */ |
| 139 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(fd->filetype == MPI_BYTEcxx . . $ `<external>/6934199238193867845/mpi.h:1233:9`!); |
| 140 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(fd->flat_file.size == buf_view.size); |
| 141 | if (fd->flat_filecxx . . $ $anonymous_type_c9d83daee76f2_2#flat_file..countcxx . . $ $anonymous_type_c9d83daee76f2_1#count. > 0) assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(offset == 0); /* not whole file visible */ |
| 142 | |
| 143 | bufsize = buf_view.sizecxx . . $ $anonymous_type_c9d83daee76f2_1#size.; |
| 144 | |
| 145 | /* get striping info */ |
| 146 | stripe_size = fd->hintscxx . . $ $anonymous_type_c9d83daee76f2_2#hints.->striping_unitcxx . . $ $anonymous_type_c9d83daee76f2_0#striping_unit.; |
| 147 | |
| 148 | if (!buf_view.is_contigcxx . . $ $anonymous_type_c9d83daee76f2_1#is_contig. && fd->flat_filecxx . . $ $anonymous_type_c9d83daee76f2_2#flat_file..is_contigcxx . . $ $anonymous_type_c9d83daee76f2_1#is_contig.) { |
| 149 | /* noncontiguous in write buffer, contiguous in file. */ |
| 150 | |
| 151 | off = fd->dispcxx . . $ $anonymous_type_c9d83daee76f2_2#disp. + offset; |
| 152 | if (fd->flat_filecxx . . $ $anonymous_type_c9d83daee76f2_2#flat_file..countcxx . . $ $anonymous_type_c9d83daee76f2_1#count. > 0) off += fd->flat_filecxx . . $ $anonymous_type_c9d83daee76f2_2#flat_file..offcxx . . $ $anonymous_type_c9d83daee76f2_1#off.[0]; |
| 153 | |
| 154 | start_off = off; |
| 155 | end_offset = start_off + bufsize - 1; |
| 156 | |
| 157 | /* write stripe size buffer each time */ |
| 158 | writebuf = (char *) NCI_Malloccxx . . $ `src/drivers/include/common.h:76:9`!(MINcxx . . $ `src/drivers/include/common.h:25:9`!(bufsize, stripe_size)); |
| 159 | writebuf_off = 0; |
| 160 | writebuf_len = 0; |
| 161 | |
| 162 | /* if atomicity is true or data sieving is not disable, lock the region |
| 163 | * to be accessed |
| 164 | */ |
| 165 | if (fd->atomicitycxx . . $ $anonymous_type_c9d83daee76f2_2#atomicity. || fd->hintscxx . . $ $anonymous_type_c9d83daee76f2_2#hints.->romio_ds_writecxx . . $ $anonymous_type_c9d83daee76f2_0#romio_ds_write. != PNCIO_HINT_DISABLEcxx . . $ `src/drivers/pncio/pncio.h:106:9`!) |
| 166 | PNCIO_WRITE_LOCKcxx . . $ `src/drivers/pncio/pncio.h:41:9`!(fd, start_off, SEEK_SETcxx . . $ `<external>/14710646456994434043/fcntl.h:137:10`!, bufsize); |
| 167 | |
| 168 | for (i = 0; i < buf_view.countcxx . . $ $anonymous_type_c9d83daee76f2_1#count.; i++) { |
| 169 | userbuf_off = buf_view.offcxx . . $ $anonymous_type_c9d83daee76f2_1#off.[i]; |
| 170 | req_off = off; |
| 171 | req_len = buf_view.lencxx . . $ $anonymous_type_c9d83daee76f2_1#len.[i]; |
| 172 | BUFFERED_WRITE_WITHOUT_READcxx . . $ `src/drivers/pncio/pncio_lustre_wrstr.c:74:9`!; |
| 173 | off += buf_view.lencxx . . $ $anonymous_type_c9d83daee76f2_1#len.[i]; |
| 174 | } |
| 175 | |
| 176 | /* write the buffer out the last round */ |
| 177 | w_len = PNCIO_WriteContigcxx . . $ PNCIO_WriteContig(c9116b011f5a1a2b).(fd, writebuf, writebuf_len, writebuf_off); |
| 178 | |
| 179 | if (fd->atomicitycxx . . $ $anonymous_type_c9d83daee76f2_2#atomicity. || fd->hintscxx . . $ $anonymous_type_c9d83daee76f2_2#hints.->romio_ds_writecxx . . $ $anonymous_type_c9d83daee76f2_0#romio_ds_write. != PNCIO_HINT_DISABLEcxx . . $ `src/drivers/pncio/pncio.h:106:9`!) |
| 180 | PNCIO_UNLOCKcxx . . $ `src/drivers/pncio/pncio.h:39:9`!(fd, start_off, SEEK_SETcxx . . $ `<external>/14710646456994434043/fcntl.h:137:10`!, bufsize); |
| 181 | |
| 182 | NCI_Freecxx . . $ `src/drivers/include/common.h:80:9`!(writebuf); |
| 183 | |
| 184 | if (w_len < 0) return w_len; |
| 185 | total_w_len += w_len; |
| 186 | |
| 187 | } else { /* contiguous buffer and non-contiguous in file */ |
| 188 | disp = fd->dispcxx . . $ $anonymous_type_c9d83daee76f2_2#disp.; |
| 189 | /* for non-contiguous in file, PnetCDF always uses disp == 0 */ |
| 190 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(disp == 0); |
| 191 | |
| 192 | /* find the starting index in fd->flat_file offset-length pairs */ |
| 193 | sum = 0; |
| 194 | for (i = 0; i < fd->flat_filecxx . . $ $anonymous_type_c9d83daee76f2_2#flat_file..countcxx . . $ $anonymous_type_c9d83daee76f2_1#count.; i++) { |
| 195 | sum += fd->flat_filecxx . . $ $anonymous_type_c9d83daee76f2_2#flat_file..lencxx . . $ $anonymous_type_c9d83daee76f2_1#len.[i]; |
| 196 | if (sum > offset) { |
| 197 | st_index = i; |
| 198 | fwr_size = sum - offset; |
| 199 | abs_off_in_filetype = fd->flat_filecxx . . $ $anonymous_type_c9d83daee76f2_2#flat_file..offcxx . . $ $anonymous_type_c9d83daee76f2_1#off.[i] + |
| 200 | offset - (sum - fd->flat_filecxx . . $ $anonymous_type_c9d83daee76f2_2#flat_file..lencxx . . $ $anonymous_type_c9d83daee76f2_1#len.[i]); |
| 201 | break; |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | /* abs. offset in bytes in the file */ |
| 206 | offset = disp + abs_off_in_filetype; |
| 207 | |
| 208 | start_off = offset; |
| 209 | |
| 210 | /* Write request is within single flat_file contig block. This could |
| 211 | * happen, for example, with subarray types that are actually fairly |
| 212 | * contiguous. |
| 213 | */ |
| 214 | if (buf_view.is_contigcxx . . $ $anonymous_type_c9d83daee76f2_1#is_contig. && bufsize <= fwr_size) { |
| 215 | req_off = start_off; |
| 216 | req_len = bufsize; |
| 217 | end_offset = start_off + bufsize - 1; |
| 218 | writebuf = (char *) NCI_Malloccxx . . $ `src/drivers/include/common.h:76:9`!(MINcxx . . $ `src/drivers/include/common.h:25:9`!(bufsize, stripe_size)); |
| 219 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(writebuf, -1, (size_tcxx . . $ size_t#)MINcxx . . $ `src/drivers/include/common.h:25:9`!(bufsize, stripe_size)); |
| 220 | writebuf_off = 0; |
| 221 | writebuf_len = 0; |
| 222 | userbuf_off = 0; |
| 223 | BUFFERED_WRITE_WITHOUT_READcxx . . $ `src/drivers/pncio/pncio_lustre_wrstr.c:74:9`!; |
| 224 | |
| 225 | /* write the buffer out the last round */ |
| 226 | if (fd->hintscxx . . $ $anonymous_type_c9d83daee76f2_2#hints.->romio_ds_writecxx . . $ $anonymous_type_c9d83daee76f2_0#romio_ds_write. != PNCIO_HINT_DISABLEcxx . . $ `src/drivers/pncio/pncio.h:106:9`!) |
| 227 | PNCIO_WRITE_LOCKcxx . . $ `src/drivers/pncio/pncio.h:41:9`!(fd, writebuf_off, SEEK_SETcxx . . $ `<external>/14710646456994434043/fcntl.h:137:10`!, writebuf_len); |
| 228 | |
| 229 | w_len = PNCIO_WriteContigcxx . . $ PNCIO_WriteContig(c9116b011f5a1a2b).(fd, writebuf, writebuf_len, writebuf_off); |
| 230 | if (w_len > 0) total_w_len += w_len; |
| 231 | |
| 232 | if (fd->hintscxx . . $ $anonymous_type_c9d83daee76f2_2#hints.->romio_ds_writecxx . . $ $anonymous_type_c9d83daee76f2_0#romio_ds_write. != PNCIO_HINT_DISABLEcxx . . $ `src/drivers/pncio/pncio.h:106:9`!) |
| 233 | PNCIO_UNLOCKcxx . . $ `src/drivers/pncio/pncio.h:39:9`!(fd, writebuf_off, SEEK_SETcxx . . $ `<external>/14710646456994434043/fcntl.h:137:10`!, writebuf_len); |
| 234 | |
| 235 | NCI_Freecxx . . $ `src/drivers/include/common.h:80:9`!(writebuf); |
| 236 | |
| 237 | return total_w_len; |
| 238 | } |
| 239 | |
| 240 | /* Calculate end_offset, the last byte-offset that will be accessed. |
| 241 | * e.g., if start_offset=0 and 100 bytes to be write, end_offset=99 */ |
| 242 | |
| 243 | st_fwr_size = fwr_size; |
| 244 | j = st_index; |
| 245 | i_offset = fwr_size = MINcxx . . $ `src/drivers/include/common.h:25:9`!(st_fwr_size, bufsize); |
| 246 | end_offset = offset + fwr_size - 1; |
| 247 | while (i_offset < bufsize) { |
| 248 | j++; |
| 249 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(j < fd->flat_file.count); |
| 250 | off = disp + fd->flat_filecxx . . $ $anonymous_type_c9d83daee76f2_2#flat_file..offcxx . . $ $anonymous_type_c9d83daee76f2_1#off.[j]; |
| 251 | fwr_size = MINcxx . . $ `src/drivers/include/common.h:25:9`!(fd->flat_file.len[j], bufsize - i_offset); |
| 252 | i_offset += fwr_size; |
| 253 | end_offset = off + fwr_size - 1; |
| 254 | } |
| 255 | |
| 256 | /* if atomicity is true or data sieving is not disable, lock the region |
| 257 | * to be accessed */ |
| 258 | if (fd->atomicitycxx . . $ $anonymous_type_c9d83daee76f2_2#atomicity. || fd->hintscxx . . $ $anonymous_type_c9d83daee76f2_2#hints.->romio_ds_writecxx . . $ $anonymous_type_c9d83daee76f2_0#romio_ds_write. != PNCIO_HINT_DISABLEcxx . . $ `src/drivers/pncio/pncio.h:106:9`!) |
| 259 | PNCIO_WRITE_LOCKcxx . . $ `src/drivers/pncio/pncio.h:41:9`!(fd, start_off, SEEK_SETcxx . . $ `<external>/14710646456994434043/fcntl.h:137:10`!, end_offset-start_off+1); |
| 260 | |
| 261 | writebuf_off = 0; |
| 262 | writebuf_len = 0; |
| 263 | writebuf = (char *) NCI_Malloccxx . . $ `src/drivers/include/common.h:76:9`!(stripe_size); |
| 264 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(writebuf, -1, stripe_size); |
| 265 | |
| 266 | if (buf_view.is_contigcxx . . $ $anonymous_type_c9d83daee76f2_1#is_contig. && !fd->flat_filecxx . . $ $anonymous_type_c9d83daee76f2_2#flat_file..is_contigcxx . . $ $anonymous_type_c9d83daee76f2_1#is_contig.) { |
| 267 | /* contiguous in memory, noncontiguous in file should be the most |
| 268 | * common case. |
| 269 | */ |
| 270 | i_offset = 0; |
| 271 | j = st_index; |
| 272 | off = offset; |
| 273 | fwr_size = MINcxx . . $ `src/drivers/include/common.h:25:9`!(st_fwr_size, bufsize); |
| 274 | while (i_offset < bufsize) { |
| 275 | if (fwr_size) { |
| 276 | req_off = off; |
| 277 | req_len = fwr_size; |
| 278 | userbuf_off = i_offset; |
| 279 | BUFFERED_WRITEcxx . . $ `src/drivers/pncio/pncio_lustre_wrstr.c:13:9`!; |
| 280 | } |
| 281 | i_offset += fwr_size; |
| 282 | if (i_offset >= bufsize) break; |
| 283 | |
| 284 | if (off + fwr_size < disp + fd->flat_filecxx . . $ $anonymous_type_c9d83daee76f2_2#flat_file..offcxx . . $ $anonymous_type_c9d83daee76f2_1#off.[j] + |
| 285 | fd->flat_filecxx . . $ $anonymous_type_c9d83daee76f2_2#flat_file..lencxx . . $ $anonymous_type_c9d83daee76f2_1#len.[j]) |
| 286 | off += fwr_size; |
| 287 | /* no more I/O needed. off is incremented by fwr_size. */ |
| 288 | else { |
| 289 | j++; |
| 290 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(j < fd->flat_file.count); |
| 291 | off = disp + fd->flat_filecxx . . $ $anonymous_type_c9d83daee76f2_2#flat_file..offcxx . . $ $anonymous_type_c9d83daee76f2_1#off.[j]; |
| 292 | fwr_size = MINcxx . . $ `src/drivers/include/common.h:25:9`!(fd->flat_file.len[j], |
| 293 | bufsize - i_offset); |
| 294 | } |
| 295 | } |
| 296 | } else { |
| 297 | /* noncontiguous in memory as well as in file */ |
| 298 | k = num = 0; |
| 299 | i_offset = buf_view.offcxx . . $ $anonymous_type_c9d83daee76f2_1#off.[0]; |
| 300 | j = st_index; |
| 301 | off = offset; |
| 302 | fwr_size = st_fwr_size; |
| 303 | bwr_size = buf_view.lencxx . . $ $anonymous_type_c9d83daee76f2_1#len.[0]; |
| 304 | |
| 305 | while (num < bufsize) { |
| 306 | size = MINcxx . . $ `src/drivers/include/common.h:25:9`!(fwr_size, bwr_size); |
| 307 | if (size) { |
| 308 | req_off = off; |
| 309 | req_len = size; |
| 310 | userbuf_off = i_offset; |
| 311 | BUFFERED_WRITEcxx . . $ `src/drivers/pncio/pncio_lustre_wrstr.c:13:9`!; |
| 312 | } |
| 313 | num += size; |
| 314 | if (num >= bufsize) break; |
| 315 | |
| 316 | new_fwr_size = fwr_size; |
| 317 | new_bwr_size = bwr_size; |
| 318 | |
| 319 | if (size == fwr_size) { |
| 320 | /* reached end of contiguous block in file */ |
| 321 | j++; |
| 322 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(j < fd->flat_file.count); |
| 323 | off = disp + fd->flat_filecxx . . $ $anonymous_type_c9d83daee76f2_2#flat_file..offcxx . . $ $anonymous_type_c9d83daee76f2_1#off.[j]; |
| 324 | |
| 325 | new_fwr_size = fd->flat_filecxx . . $ $anonymous_type_c9d83daee76f2_2#flat_file..lencxx . . $ $anonymous_type_c9d83daee76f2_1#len.[j]; |
| 326 | if (size != bwr_size) { |
| 327 | i_offset += size; |
| 328 | new_bwr_size -= size; |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | if (size == bwr_size) { |
| 333 | /* reached end of contiguous block in memory */ |
| 334 | k++; |
| 335 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(k < buf_view.count); |
| 336 | i_offset = buf_view.offcxx . . $ $anonymous_type_c9d83daee76f2_1#off.[k]; |
| 337 | new_bwr_size = buf_view.lencxx . . $ $anonymous_type_c9d83daee76f2_1#len.[k]; |
| 338 | if (size != fwr_size) { |
| 339 | off += size; |
| 340 | new_fwr_size -= size; |
| 341 | } |
| 342 | } |
| 343 | fwr_size = new_fwr_size; |
| 344 | bwr_size = new_bwr_size; |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | /* write the buffer out the last round */ |
| 349 | if (writebuf_len) { |
| 350 | w_len = PNCIO_WriteContigcxx . . $ PNCIO_WriteContig(c9116b011f5a1a2b).(fd, writebuf, writebuf_len, writebuf_off); |
| 351 | if (!fd->atomicitycxx . . $ $anonymous_type_c9d83daee76f2_2#atomicity. && fd->hintscxx . . $ $anonymous_type_c9d83daee76f2_2#hints.->romio_ds_writecxx . . $ $anonymous_type_c9d83daee76f2_0#romio_ds_write. == PNCIO_HINT_DISABLEcxx . . $ `src/drivers/pncio/pncio.h:106:9`!) |
| 352 | PNCIO_UNLOCKcxx . . $ `src/drivers/pncio/pncio.h:39:9`!(fd, writebuf_off, SEEK_SETcxx . . $ `<external>/14710646456994434043/fcntl.h:137:10`!, writebuf_len); |
| 353 | if (w_len < 0) return w_len; |
| 354 | total_w_len += w_len; |
| 355 | } |
| 356 | if (fd->atomicitycxx . . $ $anonymous_type_c9d83daee76f2_2#atomicity. || fd->hintscxx . . $ $anonymous_type_c9d83daee76f2_2#hints.->romio_ds_writecxx . . $ $anonymous_type_c9d83daee76f2_0#romio_ds_write. != PNCIO_HINT_DISABLEcxx . . $ `src/drivers/pncio/pncio.h:106:9`!) |
| 357 | PNCIO_UNLOCKcxx . . $ `src/drivers/pncio/pncio.h:39:9`!(fd, start_off, SEEK_SETcxx . . $ `<external>/14710646456994434043/fcntl.h:137:10`!, end_offset - start_off + 1); |
| 358 | |
| 359 | NCI_Freecxx . . $ `src/drivers/include/common.h:80:9`!(writebuf); |
| 360 | } |
| 361 | |
| 362 | return buf_view.sizecxx . . $ $anonymous_type_c9d83daee76f2_1#size.; |
| 363 | } |