write_issue.c (ee4cdf7ba857a894ad1650d6ab77669cbbfa329e) write_issue.c (c4f1450ecccc5311db87f806998eda1c824c4e35)
1// SPDX-License-Identifier: GPL-2.0-only
2/* Network filesystem high-level (buffered) writeback.
3 *
4 * Copyright (C) 2024 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
6 *
7 *
8 * To support network filesystems with local caching, we manage a situation

--- 269 unchanged lines hidden (view full) ---

278 if (!stream->construct)
279 netfs_prepare_write(wreq, stream, start);
280 subreq = stream->construct;
281
282 part = umin(stream->sreq_max_len - subreq->len, len);
283 _debug("part %zx/%zx %zx/%zx", subreq->len, stream->sreq_max_len, part, len);
284 subreq->len += part;
285 subreq->nr_segs++;
1// SPDX-License-Identifier: GPL-2.0-only
2/* Network filesystem high-level (buffered) writeback.
3 *
4 * Copyright (C) 2024 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
6 *
7 *
8 * To support network filesystems with local caching, we manage a situation

--- 269 unchanged lines hidden (view full) ---

278 if (!stream->construct)
279 netfs_prepare_write(wreq, stream, start);
280 subreq = stream->construct;
281
282 part = umin(stream->sreq_max_len - subreq->len, len);
283 _debug("part %zx/%zx %zx/%zx", subreq->len, stream->sreq_max_len, part, len);
284 subreq->len += part;
285 subreq->nr_segs++;
286 stream->submit_extendable_to -= part;
286
287 if (subreq->len >= stream->sreq_max_len ||
288 subreq->nr_segs >= stream->sreq_max_segs ||
289 to_eof) {
290 netfs_issue_write(wreq, stream);
291 subreq = NULL;
292 }
293

--- 125 unchanged lines hidden (view full) ---

419 * not starting at the front of the page. We don't do write-streaming
420 * with the cache as the cache requires DIO alignment.
421 *
422 * Also skip uploading for data that's been read and just needs copying
423 * to the cache.
424 */
425 for (int s = 0; s < NR_IO_STREAMS; s++) {
426 stream = &wreq->io_streams[s];
287
288 if (subreq->len >= stream->sreq_max_len ||
289 subreq->nr_segs >= stream->sreq_max_segs ||
290 to_eof) {
291 netfs_issue_write(wreq, stream);
292 subreq = NULL;
293 }
294

--- 125 unchanged lines hidden (view full) ---

420 * not starting at the front of the page. We don't do write-streaming
421 * with the cache as the cache requires DIO alignment.
422 *
423 * Also skip uploading for data that's been read and just needs copying
424 * to the cache.
425 */
426 for (int s = 0; s < NR_IO_STREAMS; s++) {
427 stream = &wreq->io_streams[s];
427 stream->submit_max_len = fsize;
428 stream->submit_off = foff;
429 stream->submit_len = flen;
430 if ((stream->source == NETFS_WRITE_TO_CACHE && streamw) ||
431 (stream->source == NETFS_UPLOAD_TO_SERVER &&
432 fgroup == NETFS_FOLIO_COPY_TO_CACHE)) {
433 stream->submit_off = UINT_MAX;
434 stream->submit_len = 0;
428 stream->submit_off = foff;
429 stream->submit_len = flen;
430 if ((stream->source == NETFS_WRITE_TO_CACHE && streamw) ||
431 (stream->source == NETFS_UPLOAD_TO_SERVER &&
432 fgroup == NETFS_FOLIO_COPY_TO_CACHE)) {
433 stream->submit_off = UINT_MAX;
434 stream->submit_len = 0;
435 stream->submit_max_len = 0;
436 }
437 }
438
439 /* Attach the folio to one or more subrequests. For a big folio, we
440 * could end up with thousands of subrequests if the wsize is small -
441 * but we might need to wait during the creation of subrequests for
442 * network resources (eg. SMB credits).
443 */

--- 13 unchanged lines hidden (view full) ---

457 }
458
459 if (choose_s < 0)
460 break;
461 stream = &wreq->io_streams[choose_s];
462 wreq->io_iter.iov_offset = stream->submit_off;
463
464 atomic64_set(&wreq->issued_to, fpos + stream->submit_off);
435 }
436 }
437
438 /* Attach the folio to one or more subrequests. For a big folio, we
439 * could end up with thousands of subrequests if the wsize is small -
440 * but we might need to wait during the creation of subrequests for
441 * network resources (eg. SMB credits).
442 */

--- 13 unchanged lines hidden (view full) ---

456 }
457
458 if (choose_s < 0)
459 break;
460 stream = &wreq->io_streams[choose_s];
461 wreq->io_iter.iov_offset = stream->submit_off;
462
463 atomic64_set(&wreq->issued_to, fpos + stream->submit_off);
464 stream->submit_extendable_to = fsize - stream->submit_off;
465 part = netfs_advance_write(wreq, stream, fpos + stream->submit_off,
466 stream->submit_len, to_eof);
467 stream->submit_off += part;
465 part = netfs_advance_write(wreq, stream, fpos + stream->submit_off,
466 stream->submit_len, to_eof);
467 stream->submit_off += part;
468 stream->submit_max_len -= part;
469 if (part > stream->submit_len)
470 stream->submit_len = 0;
471 else
472 stream->submit_len -= part;
473 if (part > 0)
474 debug = true;
475 }
476

--- 216 unchanged lines hidden ---
468 if (part > stream->submit_len)
469 stream->submit_len = 0;
470 else
471 stream->submit_len -= part;
472 if (part > 0)
473 debug = true;
474 }
475

--- 216 unchanged lines hidden ---