History

afs: Use ITER_XARRAY for writing

Use a single ITER_XARRAY iterator to describe the portion of a file to be transmitted to the server rather than generating a series of small ITER_BVEC iterators on the fly. This will make it easier to implement AIO in afs. In theory we could maybe use one giant ITER_BVEC, but that means potentially allocating a huge array of bio_vec structs (max 256 per page) when in fact the pagecache already has a structure listing all the relevant pages (radix_tree/xarray) that can be walked over.

David Howells committed 6 years ago

Commit bd80d8a1 parent c4508466 files · +126 −218Browse files

Unified · Split

6 files
  1. fs/afs/fsclient.c +20 −30
  2. fs/afs/internal.h +8 −7
  3. fs/afs/rxrpc.c +15 −88
  4. fs/afs/write.c +57 −43
  5. fs/afs/yfsclient.c +7 −18
  6. include/trace/events/afs.h +19 −32
fs/afs/fsclient.c+20−30
@@ -1055,8 +1055,7 @@ static const struct afs_call_type afs_RXFSStoreData64 = { · 1054 unmodified lines
1055/*1055/*
1056 * store a set of pages to a very large file1056 * store a set of pages to a very large file
1057 */1057 */
1058static void afs_fs_store_data64(struct afs_operation *op,1058static void afs_fs_store_data64(struct afs_operation *op)
1059 loff_t pos, loff_t size, loff_t i_size)
1060{1059{
1061 struct afs_vnode_param *vp = &op->file[0];1060 struct afs_vnode_param *vp = &op->file[0];
1062 struct afs_call *call;1061 struct afs_call *call;
@@ -1071,7 +1070,7 @@ static void afs_fs_store_data64(struct afs_operation *op, · 8 unmodified lines
1071 if (!call)1070 if (!call)
1072 return afs_op_nomem(op);1071 return afs_op_nomem(op);
1073 1072
1074 call->send_pages = true;1073 call->write_iter = op->store.write_iter;
1075 1074
1076 /* marshall the parameters */1075 /* marshall the parameters */
1077 bp = call->request;1076 bp = call->request;
@@ -1087,47 +1086,38 @@ static void afs_fs_store_data64(struct afs_operation *op, · 9 unmodified lines
1087 *bp++ = 0; /* unix mode */1086 *bp++ = 0; /* unix mode */
1088 *bp++ = 0; /* segment size */1087 *bp++ = 0; /* segment size */
1089 1088
1090 *bp++ = htonl(upper_32_bits(pos));1089 *bp++ = htonl(upper_32_bits(op->store.pos));
1091 *bp++ = htonl(lower_32_bits(pos));1090 *bp++ = htonl(lower_32_bits(op->store.pos));
1092 *bp++ = htonl(upper_32_bits(size));1091 *bp++ = htonl(upper_32_bits(op->store.size));
1093 *bp++ = htonl(lower_32_bits(size));1092 *bp++ = htonl(lower_32_bits(op->store.size));
1094 *bp++ = htonl(upper_32_bits(i_size));1093 *bp++ = htonl(upper_32_bits(op->store.i_size));
1095 *bp++ = htonl(lower_32_bits(i_size));1094 *bp++ = htonl(lower_32_bits(op->store.i_size));
1096 1095
1097 trace_afs_make_fs_call(call, &vp->fid);1096 trace_afs_make_fs_call(call, &vp->fid);
1098 afs_make_op_call(op, call, GFP_NOFS);1097 afs_make_op_call(op, call, GFP_NOFS);
1099}1098}
1100 1099
1101/*1100/*
1102 * store a set of pages1101 * Write data to a file on the server.
1103 */1102 */
1104void afs_fs_store_data(struct afs_operation *op)1103void afs_fs_store_data(struct afs_operation *op)
1105{1104{
1106 struct afs_vnode_param *vp = &op->file[0];1105 struct afs_vnode_param *vp = &op->file[0];
1107 struct afs_call *call;1106 struct afs_call *call;
1108 loff_t size, pos, i_size;
1109 __be32 *bp;1107 __be32 *bp;
1110 1108
1111 _enter(",%x,{%llx:%llu},,",1109 _enter(",%x,{%llx:%llu},,",
1112 key_serial(op->key), vp->fid.vid, vp->fid.vnode);1110 key_serial(op->key), vp->fid.vid, vp->fid.vnode);
1113 1111
1114 size = (loff_t)op->store.last_to - (loff_t)op->store.first_offset;
1115 if (op->store.first != op->store.last)
1116 size += (loff_t)(op->store.last - op->store.first) << PAGE_SHIFT;
1117 pos = (loff_t)op->store.first << PAGE_SHIFT;
1118 pos += op->store.first_offset;
1119
1120 i_size = i_size_read(&vp->vnode->vfs_inode);
1121 if (pos + size > i_size)
1122 i_size = size + pos;
1123
1124 _debug("size %llx, at %llx, i_size %llx",1112 _debug("size %llx, at %llx, i_size %llx",
1125 (unsigned long long) size, (unsigned long long) pos,1113 (unsigned long long)op->store.size,
1126 (unsigned long long) i_size);1114 (unsigned long long)op->store.pos,
1115 (unsigned long long)op->store.i_size);
1127 1116
1128 if (upper_32_bits(pos) || upper_32_bits(i_size) || upper_32_bits(size) ||1117 if (upper_32_bits(op->store.pos) ||
1129 upper_32_bits(pos + size))1118 upper_32_bits(op->store.size) ||
1130 return afs_fs_store_data64(op, pos, size, i_size);1119 upper_32_bits(op->store.i_size))
1120 return afs_fs_store_data64(op);
1131 1121
1132 call = afs_alloc_flat_call(op->net, &afs_RXFSStoreData,1122 call = afs_alloc_flat_call(op->net, &afs_RXFSStoreData,
1133 (4 + 6 + 3) * 4,1123 (4 + 6 + 3) * 4,
@@ -1135,7 +1125,7 @@ void afs_fs_store_data(struct afs_operation *op) · 1 unmodified line
1135 if (!call)1125 if (!call)
1136 return afs_op_nomem(op);1126 return afs_op_nomem(op);
1137 1127
1138 call->send_pages = true;1128 call->write_iter = op->store.write_iter;
1139 1129
1140 /* marshall the parameters */1130 /* marshall the parameters */
1141 bp = call->request;1131 bp = call->request;
@@ -1151,9 +1141,9 @@ void afs_fs_store_data(struct afs_operation *op) · 9 unmodified lines
1151 *bp++ = 0; /* unix mode */1141 *bp++ = 0; /* unix mode */
1152 *bp++ = 0; /* segment size */1142 *bp++ = 0; /* segment size */
1153 1143
1154 *bp++ = htonl(lower_32_bits(pos));1144 *bp++ = htonl(lower_32_bits(op->store.pos));
1155 *bp++ = htonl(lower_32_bits(size));1145 *bp++ = htonl(lower_32_bits(op->store.size));
1156 *bp++ = htonl(lower_32_bits(i_size));1146 *bp++ = htonl(lower_32_bits(op->store.i_size));
1157 1147
1158 trace_afs_make_fs_call(call, &vp->fid);1148 trace_afs_make_fs_call(call, &vp->fid);
1159 afs_make_op_call(op, call, GFP_NOFS);1149 afs_make_op_call(op, call, GFP_NOFS);
fs/afs/internal.h+8−7
@@ -107,6 +107,7 @@ struct afs_call { · 106 unmodified lines
107 void *request; /* request data (first part) */107 void *request; /* request data (first part) */
108 size_t iov_len; /* Size of *iter to be used */108 size_t iov_len; /* Size of *iter to be used */
109 struct iov_iter def_iter; /* Default buffer/data iterator */109 struct iov_iter def_iter; /* Default buffer/data iterator */
110 struct iov_iter *write_iter; /* Iterator defining write to be made */
110 struct iov_iter *iter; /* Iterator currently in use */111 struct iov_iter *iter; /* Iterator currently in use */
111 union { /* Convenience for ->def_iter */112 union { /* Convenience for ->def_iter */
112 struct kvec kvec[1];113 struct kvec kvec[1];
@@ -133,7 +134,6 @@ struct afs_call { · 20 unmodified lines
133 unsigned char unmarshall; /* unmarshalling phase */134 unsigned char unmarshall; /* unmarshalling phase */
134 unsigned char addr_ix; /* Address in ->alist */135 unsigned char addr_ix; /* Address in ->alist */
135 bool drop_ref; /* T if need to drop ref for incoming call */136 bool drop_ref; /* T if need to drop ref for incoming call */
136 bool send_pages; /* T if data from mapping should be sent */
137 bool need_attention; /* T if RxRPC poked us */137 bool need_attention; /* T if RxRPC poked us */
138 bool async; /* T if asynchronous */138 bool async; /* T if asynchronous */
139 bool upgrade; /* T to request service upgrade */139 bool upgrade; /* T to request service upgrade */
@@ -811,12 +811,13 @@ struct afs_operation { · 671 unmodified lines
811 afs_lock_type_t type;811 afs_lock_type_t type;
812 } lock;812 } lock;
813 struct {813 struct {
814 struct address_space *mapping; /* Pages being written from */814 struct iov_iter *write_iter;
815 pgoff_t first; /* first page in mapping to deal with */815 loff_t pos;
816 pgoff_t last; /* last page in mapping to deal with */816 loff_t size;
817 unsigned first_offset; /* offset into mapping[first] */817 loff_t i_size;
818 unsigned last_to; /* amount of mapping[last] */818 pgoff_t first; /* first page in mapping to deal with */
819 bool laundering; /* Laundering page, PG_writeback not set */819 pgoff_t last; /* last page in mapping to deal with */
820 bool laundering; /* Laundering page, PG_writeback not set */
820 } store;821 } store;
821 struct {822 struct {
822 struct iattr *attr;823 struct iattr *attr;
fs/afs/rxrpc.c+15−88
@@ -271,40 +271,6 @@ void afs_flat_call_destructor(struct afs_call *call) · 270 unmodified lines
271 call->buffer = NULL;271 call->buffer = NULL;
272}272}
273 273
274#define AFS_BVEC_MAX 8
275
276/*
277 * Load the given bvec with the next few pages.
278 */
279static void afs_load_bvec(struct afs_call *call, struct msghdr *msg,
280 struct bio_vec *bv, pgoff_t first, pgoff_t last,
281 unsigned offset)
282{
283 struct afs_operation *op = call->op;
284 struct page *pages[AFS_BVEC_MAX];
285 unsigned int nr, n, i, to, bytes = 0;
286
287 nr = min_t(pgoff_t, last - first + 1, AFS_BVEC_MAX);
288 n = find_get_pages_contig(op->store.mapping, first, nr, pages);
289 ASSERTCMP(n, ==, nr);
290
291 msg->msg_flags |= MSG_MORE;
292 for (i = 0; i < nr; i++) {
293 to = PAGE_SIZE;
294 if (first + i >= last) {
295 to = op->store.last_to;
296 msg->msg_flags &= ~MSG_MORE;
297 }
298 bv[i].bv_page = pages[i];
299 bv[i].bv_len = to - offset;
300 bv[i].bv_offset = offset;
301 bytes += to - offset;
302 offset = 0;
303 }
304
305 iov_iter_bvec(&msg->msg_iter, WRITE, bv, nr, bytes);
306}
307
308/*274/*
309 * Advance the AFS call state when the RxRPC call ends the transmit phase.275 * Advance the AFS call state when the RxRPC call ends the transmit phase.
310 */276 */
@@ -317,42 +283,6 @@ static void afs_notify_end_request_tx(struct sock *sock, · 6 unmodified lines
317 afs_set_call_state(call, AFS_CALL_CL_REQUESTING, AFS_CALL_CL_AWAIT_REPLY);283 afs_set_call_state(call, AFS_CALL_CL_REQUESTING, AFS_CALL_CL_AWAIT_REPLY);
318}284}
319 285
320/*
321 * attach the data from a bunch of pages on an inode to a call
322 */
323static int afs_send_pages(struct afs_call *call, struct msghdr *msg)
324{
325 struct afs_operation *op = call->op;
326 struct bio_vec bv[AFS_BVEC_MAX];
327 unsigned int bytes, nr, loop, offset;
328 pgoff_t first = op->store.first, last = op->store.last;
329 int ret;
330
331 offset = op->store.first_offset;
332 op->store.first_offset = 0;
333
334 do {
335 afs_load_bvec(call, msg, bv, first, last, offset);
336 trace_afs_send_pages(call, msg, first, last, offset);
337
338 offset = 0;
339 bytes = msg->msg_iter.count;
340 nr = msg->msg_iter.nr_segs;
341
342 ret = rxrpc_kernel_send_data(op->net->socket, call->rxcall, msg,
343 bytes, afs_notify_end_request_tx);
344 for (loop = 0; loop < nr; loop++)
345 put_page(bv[loop].bv_page);
346 if (ret < 0)
347 break;
348
349 first += nr;
350 } while (first <= last);
351
352 trace_afs_sent_pages(call, op->store.first, last, first, ret);
353 return ret;
354}
355
356/*286/*
357 * Initiate a call and synchronously queue up the parameters for dispatch. Any287 * Initiate a call and synchronously queue up the parameters for dispatch. Any
358 * error is stored into the call struct, which the caller must check for.288 * error is stored into the call struct, which the caller must check for.
@@ -384,21 +314,8 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp) · 25 unmodified lines
384 * after the initial fixed part.314 * after the initial fixed part.
385 */315 */
386 tx_total_len = call->request_size;316 tx_total_len = call->request_size;
387 if (call->send_pages) {317 if (call->write_iter)
388 struct afs_operation *op = call->op;318 tx_total_len += iov_iter_count(call->write_iter);
389
390 if (op->store.last == op->store.first) {
391 tx_total_len += op->store.last_to - op->store.first_offset;
392 } else {
393 /* It looks mathematically like you should be able to
394 * combine the following lines with the ones above, but
395 * unsigned arithmetic is fun when it wraps...
396 */
397 tx_total_len += PAGE_SIZE - op->store.first_offset;
398 tx_total_len += op->store.last_to;
399 tx_total_len += (op->store.last - op->store.first - 1) * PAGE_SIZE;
400 }
401 }
402 319
403 /* If the call is going to be asynchronous, we need an extra ref for320 /* If the call is going to be asynchronous, we need an extra ref for
404 * the call to hold itself so the caller need not hang on to its ref.321 * the call to hold itself so the caller need not hang on to its ref.
@@ -440,7 +357,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp) · 35 unmodified lines
440 iov_iter_kvec(&msg.msg_iter, WRITE, iov, 1, call->request_size);357 iov_iter_kvec(&msg.msg_iter, WRITE, iov, 1, call->request_size);
441 msg.msg_control = NULL;358 msg.msg_control = NULL;
442 msg.msg_controllen = 0;359 msg.msg_controllen = 0;
443 msg.msg_flags = MSG_WAITALL | (call->send_pages ? MSG_MORE : 0);360 msg.msg_flags = MSG_WAITALL | (call->write_iter ? MSG_MORE : 0);
444 361
445 ret = rxrpc_kernel_send_data(call->net->socket, rxcall,362 ret = rxrpc_kernel_send_data(call->net->socket, rxcall,
446 &msg, call->request_size,363 &msg, call->request_size,
@@ -448,8 +365,18 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp) · 1 unmodified line
448 if (ret < 0)365 if (ret < 0)
449 goto error_do_abort;366 goto error_do_abort;
450 367
451 if (call->send_pages) {368 if (call->write_iter) {
452 ret = afs_send_pages(call, &msg);369 msg.msg_iter = *call->write_iter;
370 msg.msg_flags &= ~MSG_MORE;
371 trace_afs_send_data(call, &msg);
372
373 ret = rxrpc_kernel_send_data(call->net->socket,
374 call->rxcall, &msg,
375 iov_iter_count(&msg.msg_iter),
376 afs_notify_end_request_tx);
377 *call->write_iter = msg.msg_iter;
378
379 trace_afs_sent_data(call, &msg, ret);
453 if (ret < 0)380 if (ret < 0)
454 goto error_do_abort;381 goto error_do_abort;
455 }382 }
fs/afs/write.c+57−43
@@ -325,36 +325,27 @@ static void afs_redirty_pages(struct writeback_control *wbc, · 324 unmodified lines
325/*325/*
326 * completion of write to server326 * completion of write to server
327 */327 */
328static void afs_pages_written_back(struct afs_vnode *vnode,328static void afs_pages_written_back(struct afs_vnode *vnode, pgoff_t start, pgoff_t last)
329 pgoff_t first, pgoff_t last)
330{329{
331 struct pagevec pv;330 struct address_space *mapping = vnode->vfs_inode.i_mapping;
332 unsigned count, loop;331 struct page *page;
332
333 XA_STATE(xas, &mapping->i_pages, start);
333 334
334 _enter("{%llx:%llu},{%lx-%lx}",335 _enter("{%llx:%llu},{%lx-%lx}",
335 vnode->fid.vid, vnode->fid.vnode, first, last);336 vnode->fid.vid, vnode->fid.vnode, start, last);
336 337
337 pagevec_init(&pv);338 rcu_read_lock();
338 339
339 do {340 xas_for_each(&xas, page, last) {
340 _debug("done %lx-%lx", first, last);341 ASSERT(PageWriteback(page));
341 342
342 count = last - first + 1;343 detach_page_private(page);
343 if (count > PAGEVEC_SIZE)344 trace_afs_page_dirty(vnode, tracepoint_string("clear"), page);
344 count = PAGEVEC_SIZE;345 page_endio(page, true, 0);
345 pv.nr = find_get_pages_contig(vnode->vfs_inode.i_mapping,346 }
346 first, count, pv.pages);
347 ASSERTCMP(pv.nr, ==, count);
348 347
349 for (loop = 0; loop < count; loop++) {348 rcu_read_unlock();
350 detach_page_private(pv.pages[loop]);
351 trace_afs_page_dirty(vnode, tracepoint_string("clear"),
352 pv.pages[loop]);
353 end_page_writeback(pv.pages[loop]);
354 }
355 first += count;
356 __pagevec_release(&pv);
357 } while (first <= last);
358 349
359 afs_prune_wb_keys(vnode);350 afs_prune_wb_keys(vnode);
360 _leave("");351 _leave("");
@@ -411,9 +402,7 @@ static void afs_store_data_success(struct afs_operation *op) · 50 unmodified lines
411 if (!op->store.laundering)402 if (!op->store.laundering)
412 afs_pages_written_back(vnode, op->store.first, op->store.last);403 afs_pages_written_back(vnode, op->store.first, op->store.last);
413 afs_stat_v(vnode, n_stores);404 afs_stat_v(vnode, n_stores);
414 atomic_long_add((op->store.last * PAGE_SIZE + op->store.last_to) -405 atomic_long_add(op->store.size, &afs_v2net(vnode)->n_store_bytes);
415 (op->store.first * PAGE_SIZE + op->store.first_offset),
416 &afs_v2net(vnode)->n_store_bytes);
417 }406 }
418}407}
419 408
@@ -426,21 +415,21 @@ static const struct afs_operation_ops afs_store_data_operation = { · 6 unmodified lines
426/*415/*
427 * write to a file416 * write to a file
428 */417 */
429static int afs_store_data(struct address_space *mapping,418static int afs_store_data(struct afs_vnode *vnode, struct iov_iter *iter,
430 pgoff_t first, pgoff_t last,419 loff_t pos, pgoff_t first, pgoff_t last,
431 unsigned offset, unsigned to, bool laundering)420 bool laundering)
432{421{
433 struct afs_vnode *vnode = AFS_FS_I(mapping->host);
434 struct afs_operation *op;422 struct afs_operation *op;
435 struct afs_wb_key *wbk = NULL;423 struct afs_wb_key *wbk = NULL;
436 int ret;424 loff_t size = iov_iter_count(iter), i_size;
425 int ret = -ENOKEY;
437 426
438 _enter("%s{%llx:%llu.%u},%lx,%lx,%x,%x",427 _enter("%s{%llx:%llu.%u},%llx,%llx",
439 vnode->volume->name,428 vnode->volume->name,
440 vnode->fid.vid,429 vnode->fid.vid,
441 vnode->fid.vnode,430 vnode->fid.vnode,
442 vnode->fid.unique,431 vnode->fid.unique,
443 first, last, offset, to);432 size, pos);
444 433
445 ret = afs_get_writeback_key(vnode, &wbk);434 ret = afs_get_writeback_key(vnode, &wbk);
446 if (ret) {435 if (ret) {
@@ -454,13 +443,16 @@ static int afs_store_data(struct address_space *mapping, · 7 unmodified lines
454 return -ENOMEM;443 return -ENOMEM;
455 }444 }
456 445
446 i_size = i_size_read(&vnode->vfs_inode);
447
457 afs_op_set_vnode(op, 0, vnode);448 afs_op_set_vnode(op, 0, vnode);
458 op->file[0].dv_delta = 1;449 op->file[0].dv_delta = 1;
459 op->store.mapping = mapping;450 op->store.write_iter = iter;
451 op->store.pos = pos;
460 op->store.first = first;452 op->store.first = first;
461 op->store.last = last;453 op->store.last = last;
462 op->store.first_offset = offset;454 op->store.size = size;
463 op->store.last_to = to;455 op->store.i_size = max(pos + size, i_size);
464 op->store.laundering = laundering;456 op->store.laundering = laundering;
465 op->mtime = vnode->vfs_inode.i_mtime;457 op->mtime = vnode->vfs_inode.i_mtime;
466 op->flags |= AFS_OPERATION_UNINTR;458 op->flags |= AFS_OPERATION_UNINTR;
@@ -503,11 +495,12 @@ static int afs_write_back_from_locked_page(struct address_space *mapping, · 36 unmodified lines
503 pgoff_t final_page)495 pgoff_t final_page)
504{496{
505 struct afs_vnode *vnode = AFS_FS_I(mapping->host);497 struct afs_vnode *vnode = AFS_FS_I(mapping->host);
498 struct iov_iter iter;
506 struct page *pages[8], *page;499 struct page *pages[8], *page;
507 unsigned long count, priv;500 unsigned long count, priv;
508 unsigned n, offset, to, f, t;501 unsigned n, offset, to, f, t;
509 pgoff_t start, first, last;502 pgoff_t start, first, last;
510 loff_t i_size, end;503 loff_t i_size, pos, end;
511 int loop, ret;504 int loop, ret;
512 505
513 _enter(",%lx", primary_page->index);506 _enter(",%lx", primary_page->index);
@@ -604,15 +597,28 @@ no_more: · 90 unmodified lines
604 597
605 first = primary_page->index;598 first = primary_page->index;
606 last = first + count - 1;599 last = first + count - 1;
600 _debug("write back %lx[%u..] to %lx[..%u]", first, offset, last, to);
607 601
608 end = (loff_t)last * PAGE_SIZE + to;602 pos = first;
609 i_size = i_size_read(&vnode->vfs_inode);603 pos <<= PAGE_SHIFT;
604 pos += offset;
605 end = last;
606 end <<= PAGE_SHIFT;
607 end += to;
610 608
611 _debug("write back %lx[%u..] to %lx[..%u]", first, offset, last, to);609 /* Trim the actual write down to the EOF */
610 i_size = i_size_read(&vnode->vfs_inode);
612 if (end > i_size)611 if (end > i_size)
613 to = i_size & ~PAGE_MASK;612 end = i_size;
613
614 if (pos < i_size) {
615 iov_iter_xarray(&iter, WRITE, &mapping->i_pages, pos, end - pos);
616 ret = afs_store_data(vnode, &iter, pos, first, last, false);
617 } else {
618 /* The dirty region was entirely beyond the EOF. */
619 ret = 0;
620 }
614 621
615 ret = afs_store_data(mapping, first, last, offset, to, false);
616 switch (ret) {622 switch (ret) {
617 case 0:623 case 0:
618 ret = count;624 ret = count;
@@ -912,6 +918,8 @@ int afs_launder_page(struct page *page) · 293 unmodified lines
912{918{
913 struct address_space *mapping = page->mapping;919 struct address_space *mapping = page->mapping;
914 struct afs_vnode *vnode = AFS_FS_I(mapping->host);920 struct afs_vnode *vnode = AFS_FS_I(mapping->host);
921 struct iov_iter iter;
922 struct bio_vec bv[1];
915 unsigned long priv;923 unsigned long priv;
916 unsigned int f, t;924 unsigned int f, t;
917 int ret = 0;925 int ret = 0;
@@ -927,8 +935,14 @@ int afs_launder_page(struct page *page) · 9 unmodified lines
927 t = afs_page_dirty_to(page, priv);935 t = afs_page_dirty_to(page, priv);
928 }936 }
929 937
938 bv[0].bv_page = page;
939 bv[0].bv_offset = f;
940 bv[0].bv_len = t - f;
941 iov_iter_bvec(&iter, WRITE, bv, 1, bv[0].bv_len);
942
930 trace_afs_page_dirty(vnode, tracepoint_string("launder"), page);943 trace_afs_page_dirty(vnode, tracepoint_string("launder"), page);
931 ret = afs_store_data(mapping, page->index, page->index, t, f, true);944 ret = afs_store_data(vnode, &iter, (loff_t)page->index << PAGE_SHIFT,
945 page->index, page->index, true);
932 }946 }
933 947
934 detach_page_private(page);948 detach_page_private(page);
fs/afs/yfsclient.c+7−18
@@ -1078,25 +1078,15 @@ void yfs_fs_store_data(struct afs_operation *op) · 1077 unmodified lines
1078{1078{
1079 struct afs_vnode_param *vp = &op->file[0];1079 struct afs_vnode_param *vp = &op->file[0];
1080 struct afs_call *call;1080 struct afs_call *call;
1081 loff_t size, pos, i_size;
1082 __be32 *bp;1081 __be32 *bp;
1083 1082
1084 _enter(",%x,{%llx:%llu},,",1083 _enter(",%x,{%llx:%llu},,",
1085 key_serial(op->key), vp->fid.vid, vp->fid.vnode);1084 key_serial(op->key), vp->fid.vid, vp->fid.vnode);
1086 1085
1087 size = (loff_t)op->store.last_to - (loff_t)op->store.first_offset;
1088 if (op->store.first != op->store.last)
1089 size += (loff_t)(op->store.last - op->store.first) << PAGE_SHIFT;
1090 pos = (loff_t)op->store.first << PAGE_SHIFT;
1091 pos += op->store.first_offset;
1092
1093 i_size = i_size_read(&vp->vnode->vfs_inode);
1094 if (pos + size > i_size)
1095 i_size = size + pos;
1096
1097 _debug("size %llx, at %llx, i_size %llx",1086 _debug("size %llx, at %llx, i_size %llx",
1098 (unsigned long long)size, (unsigned long long)pos,1087 (unsigned long long)op->store.size,
1099 (unsigned long long)i_size);1088 (unsigned long long)op->store.pos,
1089 (unsigned long long)op->store.i_size);
1100 1090
1101 call = afs_alloc_flat_call(op->net, &yfs_RXYFSStoreData64,1091 call = afs_alloc_flat_call(op->net, &yfs_RXYFSStoreData64,
1102 sizeof(__be32) +1092 sizeof(__be32) +
@@ -1109,8 +1099,7 @@ void yfs_fs_store_data(struct afs_operation *op) · 6 unmodified lines
1109 if (!call)1099 if (!call)
1110 return afs_op_nomem(op);1100 return afs_op_nomem(op);
1111 1101
1112 call->key = op->key;1102 call->write_iter = op->store.write_iter;
1113 call->send_pages = true;
1114 1103
1115 /* marshall the parameters */1104 /* marshall the parameters */
1116 bp = call->request;1105 bp = call->request;
@@ -1118,9 +1107,9 @@ void yfs_fs_store_data(struct afs_operation *op) · 1 unmodified line
1118 bp = xdr_encode_u32(bp, 0); /* RPC flags */1107 bp = xdr_encode_u32(bp, 0); /* RPC flags */
1119 bp = xdr_encode_YFSFid(bp, &vp->fid);1108 bp = xdr_encode_YFSFid(bp, &vp->fid);
1120 bp = xdr_encode_YFSStoreStatus_mtime(bp, &op->mtime);1109 bp = xdr_encode_YFSStoreStatus_mtime(bp, &op->mtime);
1121 bp = xdr_encode_u64(bp, pos);1110 bp = xdr_encode_u64(bp, op->store.pos);
1122 bp = xdr_encode_u64(bp, size);1111 bp = xdr_encode_u64(bp, op->store.size);
1123 bp = xdr_encode_u64(bp, i_size);1112 bp = xdr_encode_u64(bp, op->store.i_size);
1124 yfs_check_req(call, bp);1113 yfs_check_req(call, bp);
1125 1114
1126 trace_afs_make_fs_call(call, &vp->fid);1115 trace_afs_make_fs_call(call, &vp->fid);
include/trace/events/afs.h+19−32
@@ -886,65 +886,52 @@ TRACE_EVENT(afs_call_done, · 885 unmodified lines
886 __entry->rx_call)886 __entry->rx_call)
887 );887 );
888 888
889TRACE_EVENT(afs_send_pages,889TRACE_EVENT(afs_send_data,
890 TP_PROTO(struct afs_call *call, struct msghdr *msg,890 TP_PROTO(struct afs_call *call, struct msghdr *msg),
891 pgoff_t first, pgoff_t last, unsigned int offset),
892 891
893 TP_ARGS(call, msg, first, last, offset),892 TP_ARGS(call, msg),
894 893
895 TP_STRUCT__entry(894 TP_STRUCT__entry(
896 __field(unsigned int, call )895 __field(unsigned int, call )
897 __field(pgoff_t, first )
898 __field(pgoff_t, last )
899 __field(unsigned int, nr )
900 __field(unsigned int, bytes )
901 __field(unsigned int, offset )
902 __field(unsigned int, flags )896 __field(unsigned int, flags )
897 __field(loff_t, offset )
898 __field(loff_t, count )
903 ),899 ),
904 900
905 TP_fast_assign(901 TP_fast_assign(
906 __entry->call = call->debug_id;902 __entry->call = call->debug_id;
907 __entry->first = first;
908 __entry->last = last;
909 __entry->nr = msg->msg_iter.nr_segs;
910 __entry->bytes = msg->msg_iter.count;
911 __entry->offset = offset;
912 __entry->flags = msg->msg_flags;903 __entry->flags = msg->msg_flags;
904 __entry->offset = msg->msg_iter.xarray_start + msg->msg_iter.iov_offset;
905 __entry->count = iov_iter_count(&msg->msg_iter);
913 ),906 ),
914 907
915 TP_printk(" c=%08x %lx-%lx-%lx b=%x o=%x f=%x",908 TP_printk(" c=%08x o=%llx n=%llx f=%x",
916 __entry->call,909 __entry->call, __entry->offset, __entry->count,
917 __entry->first, __entry->first + __entry->nr - 1, __entry->last,
918 __entry->bytes, __entry->offset,
919 __entry->flags)910 __entry->flags)
920 );911 );
921 912
922TRACE_EVENT(afs_sent_pages,913TRACE_EVENT(afs_sent_data,
923 TP_PROTO(struct afs_call *call, pgoff_t first, pgoff_t last,914 TP_PROTO(struct afs_call *call, struct msghdr *msg, int ret),
924 pgoff_t cursor, int ret),
925 915
926 TP_ARGS(call, first, last, cursor, ret),916 TP_ARGS(call, msg, ret),
927 917
928 TP_STRUCT__entry(918 TP_STRUCT__entry(
929 __field(unsigned int, call )919 __field(unsigned int, call )
930 __field(pgoff_t, first )
931 __field(pgoff_t, last )
932 __field(pgoff_t, cursor )
933 __field(int, ret )920 __field(int, ret )
921 __field(loff_t, offset )
922 __field(loff_t, count )
934 ),923 ),
935 924
936 TP_fast_assign(925 TP_fast_assign(
937 __entry->call = call->debug_id;926 __entry->call = call->debug_id;
938 __entry->first = first;
939 __entry->last = last;
940 __entry->cursor = cursor;
941 __entry->ret = ret;927 __entry->ret = ret;
928 __entry->offset = msg->msg_iter.xarray_start + msg->msg_iter.iov_offset;
929 __entry->count = iov_iter_count(&msg->msg_iter);
942 ),930 ),
943 931
944 TP_printk(" c=%08x %lx-%lx c=%lx r=%d",932 TP_printk(" c=%08x o=%llx n=%llx r=%x",
945 __entry->call,933 __entry->call, __entry->offset, __entry->count,
946 __entry->first, __entry->last,934 __entry->ret)
947 __entry->cursor, __entry->ret)
948 );935 );
949 936
950TRACE_EVENT(afs_dir_check_failed,937TRACE_EVENT(afs_dir_check_failed,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t