ondemand.c (d3179bae72b1b5e555ba839d6d9f40a350a4d78a) | ondemand.c (de045a82e1a4e04be62718d3c2981a55150765a0) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2#include <linux/fdtable.h> 3#include <linux/anon_inodes.h> 4#include <linux/uio.h> 5#include "internal.h" 6 7struct ondemand_anon_file { 8 struct file *file; --- 491 unchanged lines hidden (view full) --- 500 ret = -EIO; 501 goto out; 502 } 503 504 /* coupled with the barrier in cachefiles_flush_reqs() */ 505 smp_mb(); 506 507 if (opcode == CACHEFILES_OP_CLOSE && | 1// SPDX-License-Identifier: GPL-2.0-or-later 2#include <linux/fdtable.h> 3#include <linux/anon_inodes.h> 4#include <linux/uio.h> 5#include "internal.h" 6 7struct ondemand_anon_file { 8 struct file *file; --- 491 unchanged lines hidden (view full) --- 500 ret = -EIO; 501 goto out; 502 } 503 504 /* coupled with the barrier in cachefiles_flush_reqs() */ 505 smp_mb(); 506 507 if (opcode == CACHEFILES_OP_CLOSE && |
508 !cachefiles_ondemand_object_is_open(object)) { | 508 !cachefiles_ondemand_object_is_open(object)) { |
509 WARN_ON_ONCE(object->ondemand->ondemand_id == 0); 510 xas_unlock(&xas); 511 ret = -EIO; 512 goto out; 513 } 514 | 509 WARN_ON_ONCE(object->ondemand->ondemand_id == 0); 510 xas_unlock(&xas); 511 ret = -EIO; 512 goto out; 513 } 514 |
515 xas.xa_index = 0; | 515 /* 516 * Cyclically find a free xas to avoid msg_id reuse that would 517 * cause the daemon to successfully copen a stale msg_id. 518 */ 519 xas.xa_index = cache->msg_id_next; |
516 xas_find_marked(&xas, UINT_MAX, XA_FREE_MARK); | 520 xas_find_marked(&xas, UINT_MAX, XA_FREE_MARK); |
521 if (xas.xa_node == XAS_RESTART) { 522 xas.xa_index = 0; 523 xas_find_marked(&xas, cache->msg_id_next - 1, XA_FREE_MARK); 524 } |
|
517 if (xas.xa_node == XAS_RESTART) 518 xas_set_err(&xas, -EBUSY); | 525 if (xas.xa_node == XAS_RESTART) 526 xas_set_err(&xas, -EBUSY); |
527 |
|
519 xas_store(&xas, req); | 528 xas_store(&xas, req); |
520 xas_clear_mark(&xas, XA_FREE_MARK); 521 xas_set_mark(&xas, CACHEFILES_REQ_NEW); | 529 if (xas_valid(&xas)) { 530 cache->msg_id_next = xas.xa_index + 1; 531 xas_clear_mark(&xas, XA_FREE_MARK); 532 xas_set_mark(&xas, CACHEFILES_REQ_NEW); 533 } |
522 xas_unlock(&xas); 523 } while (xas_nomem(&xas, GFP_KERNEL)); 524 525 ret = xas_error(&xas); 526 if (ret) 527 goto out; 528 529 wake_up_all(&cache->daemon_pollwq); --- 171 unchanged lines hidden --- | 534 xas_unlock(&xas); 535 } while (xas_nomem(&xas, GFP_KERNEL)); 536 537 ret = xas_error(&xas); 538 if (ret) 539 goto out; 540 541 wake_up_all(&cache->daemon_pollwq); --- 171 unchanged lines hidden --- |