1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* AFS server record management
3 *
4 * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
6 */
7
8 #include <linux/sched.h>
9 #include <linux/slab.h>
10 #include "afs_fs.h"
11 #include "internal.h"
12 #include "protocol_yfs.h"
13
14 static unsigned afs_server_gc_delay = 10; /* Server record timeout in seconds */
15 static atomic_t afs_server_debug_id;
16
17 static struct afs_server *afs_maybe_use_server(struct afs_server *,
18 enum afs_server_trace);
19 static void __afs_put_server(struct afs_net *, struct afs_server *);
20
21 /*
22 * Find a server by one of its addresses.
23 */
afs_find_server(struct afs_net * net,const struct sockaddr_rxrpc * srx)24 struct afs_server *afs_find_server(struct afs_net *net,
25 const struct sockaddr_rxrpc *srx)
26 {
27 const struct afs_addr_list *alist;
28 struct afs_server *server = NULL;
29 unsigned int i;
30 int seq = 1, diff;
31
32 rcu_read_lock();
33
34 do {
35 if (server)
36 afs_unuse_server_notime(net, server, afs_server_trace_put_find_rsq);
37 server = NULL;
38 seq++; /* 2 on the 1st/lockless path, otherwise odd */
39 read_seqbegin_or_lock(&net->fs_addr_lock, &seq);
40
41 if (srx->transport.family == AF_INET6) {
42 const struct sockaddr_in6 *a = &srx->transport.sin6, *b;
43 hlist_for_each_entry_rcu(server, &net->fs_addresses6, addr6_link) {
44 alist = rcu_dereference(server->addresses);
45 for (i = alist->nr_ipv4; i < alist->nr_addrs; i++) {
46 b = &alist->addrs[i].transport.sin6;
47 diff = ((u16 __force)a->sin6_port -
48 (u16 __force)b->sin6_port);
49 if (diff == 0)
50 diff = memcmp(&a->sin6_addr,
51 &b->sin6_addr,
52 sizeof(struct in6_addr));
53 if (diff == 0)
54 goto found;
55 }
56 }
57 } else {
58 const struct sockaddr_in *a = &srx->transport.sin, *b;
59 hlist_for_each_entry_rcu(server, &net->fs_addresses4, addr4_link) {
60 alist = rcu_dereference(server->addresses);
61 for (i = 0; i < alist->nr_ipv4; i++) {
62 b = &alist->addrs[i].transport.sin;
63 diff = ((u16 __force)a->sin_port -
64 (u16 __force)b->sin_port);
65 if (diff == 0)
66 diff = ((u32 __force)a->sin_addr.s_addr -
67 (u32 __force)b->sin_addr.s_addr);
68 if (diff == 0)
69 goto found;
70 }
71 }
72 }
73
74 server = NULL;
75 continue;
76 found:
77 server = afs_maybe_use_server(server, afs_server_trace_get_by_addr);
78
79 } while (need_seqretry(&net->fs_addr_lock, seq));
80
81 done_seqretry(&net->fs_addr_lock, seq);
82
83 rcu_read_unlock();
84 return server;
85 }
86
87 /*
88 * Look up a server by its UUID and mark it active.
89 */
afs_find_server_by_uuid(struct afs_net * net,const uuid_t * uuid)90 struct afs_server *afs_find_server_by_uuid(struct afs_net *net, const uuid_t *uuid)
91 {
92 struct afs_server *server = NULL;
93 struct rb_node *p;
94 int diff, seq = 1;
95
96 _enter("%pU", uuid);
97
98 do {
99 /* Unfortunately, rbtree walking doesn't give reliable results
100 * under just the RCU read lock, so we have to check for
101 * changes.
102 */
103 if (server)
104 afs_unuse_server(net, server, afs_server_trace_put_uuid_rsq);
105 server = NULL;
106 seq++; /* 2 on the 1st/lockless path, otherwise odd */
107 read_seqbegin_or_lock(&net->fs_lock, &seq);
108
109 p = net->fs_servers.rb_node;
110 while (p) {
111 server = rb_entry(p, struct afs_server, uuid_rb);
112
113 diff = memcmp(uuid, &server->uuid, sizeof(*uuid));
114 if (diff < 0) {
115 p = p->rb_left;
116 } else if (diff > 0) {
117 p = p->rb_right;
118 } else {
119 afs_use_server(server, afs_server_trace_get_by_uuid);
120 break;
121 }
122
123 server = NULL;
124 }
125 } while (need_seqretry(&net->fs_lock, seq));
126
127 done_seqretry(&net->fs_lock, seq);
128
129 _leave(" = %p", server);
130 return server;
131 }
132
133 /*
134 * Install a server record in the namespace tree. If there's a clash, we stick
135 * it into a list anchored on whichever afs_server struct is actually in the
136 * tree.
137 */
afs_install_server(struct afs_cell * cell,struct afs_server * candidate)138 static struct afs_server *afs_install_server(struct afs_cell *cell,
139 struct afs_server *candidate)
140 {
141 const struct afs_addr_list *alist;
142 struct afs_server *server, *next;
143 struct afs_net *net = cell->net;
144 struct rb_node **pp, *p;
145 int diff;
146
147 _enter("%p", candidate);
148
149 write_seqlock(&net->fs_lock);
150
151 /* Firstly install the server in the UUID lookup tree */
152 pp = &net->fs_servers.rb_node;
153 p = NULL;
154 while (*pp) {
155 p = *pp;
156 _debug("- consider %p", p);
157 server = rb_entry(p, struct afs_server, uuid_rb);
158 diff = memcmp(&candidate->uuid, &server->uuid, sizeof(uuid_t));
159 if (diff < 0) {
160 pp = &(*pp)->rb_left;
161 } else if (diff > 0) {
162 pp = &(*pp)->rb_right;
163 } else {
164 if (server->cell == cell)
165 goto exists;
166
167 /* We have the same UUID representing servers in
168 * different cells. Append the new server to the list.
169 */
170 for (;;) {
171 next = rcu_dereference_protected(
172 server->uuid_next,
173 lockdep_is_held(&net->fs_lock.lock));
174 if (!next)
175 break;
176 server = next;
177 }
178 rcu_assign_pointer(server->uuid_next, candidate);
179 candidate->uuid_prev = server;
180 server = candidate;
181 goto added_dup;
182 }
183 }
184
185 server = candidate;
186 rb_link_node(&server->uuid_rb, p, pp);
187 rb_insert_color(&server->uuid_rb, &net->fs_servers);
188 hlist_add_head_rcu(&server->proc_link, &net->fs_proc);
189
190 added_dup:
191 write_seqlock(&net->fs_addr_lock);
192 alist = rcu_dereference_protected(server->addresses,
193 lockdep_is_held(&net->fs_addr_lock.lock));
194
195 /* Secondly, if the server has any IPv4 and/or IPv6 addresses, install
196 * it in the IPv4 and/or IPv6 reverse-map lists.
197 *
198 * TODO: For speed we want to use something other than a flat list
199 * here; even sorting the list in terms of lowest address would help a
200 * bit, but anything we might want to do gets messy and memory
201 * intensive.
202 */
203 if (alist->nr_ipv4 > 0)
204 hlist_add_head_rcu(&server->addr4_link, &net->fs_addresses4);
205 if (alist->nr_addrs > alist->nr_ipv4)
206 hlist_add_head_rcu(&server->addr6_link, &net->fs_addresses6);
207
208 write_sequnlock(&net->fs_addr_lock);
209
210 exists:
211 afs_get_server(server, afs_server_trace_get_install);
212 write_sequnlock(&net->fs_lock);
213 return server;
214 }
215
216 /*
217 * Allocate a new server record and mark it active.
218 */
afs_alloc_server(struct afs_cell * cell,const uuid_t * uuid,struct afs_addr_list * alist)219 static struct afs_server *afs_alloc_server(struct afs_cell *cell,
220 const uuid_t *uuid,
221 struct afs_addr_list *alist)
222 {
223 struct afs_server *server;
224 struct afs_net *net = cell->net;
225
226 _enter("");
227
228 server = kzalloc(sizeof(struct afs_server), GFP_KERNEL);
229 if (!server)
230 goto enomem;
231
232 refcount_set(&server->ref, 1);
233 atomic_set(&server->active, 1);
234 server->debug_id = atomic_inc_return(&afs_server_debug_id);
235 RCU_INIT_POINTER(server->addresses, alist);
236 server->addr_version = alist->version;
237 server->uuid = *uuid;
238 rwlock_init(&server->fs_lock);
239 INIT_WORK(&server->initcb_work, afs_server_init_callback_work);
240 init_waitqueue_head(&server->probe_wq);
241 INIT_LIST_HEAD(&server->probe_link);
242 spin_lock_init(&server->probe_lock);
243 server->cell = cell;
244 server->rtt = UINT_MAX;
245
246 afs_inc_servers_outstanding(net);
247 trace_afs_server(server, 1, 1, afs_server_trace_alloc);
248 _leave(" = %p", server);
249 return server;
250
251 enomem:
252 _leave(" = NULL [nomem]");
253 return NULL;
254 }
255
256 /*
257 * Look up an address record for a server
258 */
afs_vl_lookup_addrs(struct afs_cell * cell,struct key * key,const uuid_t * uuid)259 static struct afs_addr_list *afs_vl_lookup_addrs(struct afs_cell *cell,
260 struct key *key, const uuid_t *uuid)
261 {
262 struct afs_vl_cursor vc;
263 struct afs_addr_list *alist = NULL;
264 int ret;
265
266 ret = -ERESTARTSYS;
267 if (afs_begin_vlserver_operation(&vc, cell, key)) {
268 while (afs_select_vlserver(&vc)) {
269 if (test_bit(AFS_VLSERVER_FL_IS_YFS, &vc.server->flags))
270 alist = afs_yfsvl_get_endpoints(&vc, uuid);
271 else
272 alist = afs_vl_get_addrs_u(&vc, uuid);
273 }
274
275 ret = afs_end_vlserver_operation(&vc);
276 }
277
278 return ret < 0 ? ERR_PTR(ret) : alist;
279 }
280
281 /*
282 * Get or create a fileserver record.
283 */
afs_lookup_server(struct afs_cell * cell,struct key * key,const uuid_t * uuid,u32 addr_version)284 struct afs_server *afs_lookup_server(struct afs_cell *cell, struct key *key,
285 const uuid_t *uuid, u32 addr_version)
286 {
287 struct afs_addr_list *alist;
288 struct afs_server *server, *candidate;
289
290 _enter("%p,%pU", cell->net, uuid);
291
292 server = afs_find_server_by_uuid(cell->net, uuid);
293 if (server) {
294 if (server->addr_version != addr_version)
295 set_bit(AFS_SERVER_FL_NEEDS_UPDATE, &server->flags);
296 return server;
297 }
298
299 alist = afs_vl_lookup_addrs(cell, key, uuid);
300 if (IS_ERR(alist))
301 return ERR_CAST(alist);
302
303 candidate = afs_alloc_server(cell, uuid, alist);
304 if (!candidate) {
305 afs_put_addrlist(alist);
306 return ERR_PTR(-ENOMEM);
307 }
308
309 server = afs_install_server(cell, candidate);
310 if (server != candidate) {
311 afs_put_addrlist(alist);
312 kfree(candidate);
313 } else {
314 /* Immediately dispatch an asynchronous probe to each interface
315 * on the fileserver. This will make sure the repeat-probing
316 * service is started.
317 */
318 afs_fs_probe_fileserver(cell->net, server, key, true);
319 }
320
321 return server;
322 }
323
324 /*
325 * Set the server timer to fire after a given delay, assuming it's not already
326 * set for an earlier time.
327 */
afs_set_server_timer(struct afs_net * net,time64_t delay)328 static void afs_set_server_timer(struct afs_net *net, time64_t delay)
329 {
330 if (net->live) {
331 afs_inc_servers_outstanding(net);
332 if (timer_reduce(&net->fs_timer, jiffies + delay * HZ))
333 afs_dec_servers_outstanding(net);
334 }
335 }
336
337 /*
338 * Server management timer. We have an increment on fs_outstanding that we
339 * need to pass along to the work item.
340 */
afs_servers_timer(struct timer_list * timer)341 void afs_servers_timer(struct timer_list *timer)
342 {
343 struct afs_net *net = container_of(timer, struct afs_net, fs_timer);
344
345 _enter("");
346 if (!queue_work(afs_wq, &net->fs_manager))
347 afs_dec_servers_outstanding(net);
348 }
349
350 /*
351 * Get a reference on a server object.
352 */
afs_get_server(struct afs_server * server,enum afs_server_trace reason)353 struct afs_server *afs_get_server(struct afs_server *server,
354 enum afs_server_trace reason)
355 {
356 int r;
357
358 __refcount_inc(&server->ref, &r);
359 trace_afs_server(server, r + 1, atomic_read(&server->active), reason);
360 return server;
361 }
362
363 /*
364 * Try to get a reference on a server object.
365 */
afs_maybe_use_server(struct afs_server * server,enum afs_server_trace reason)366 static struct afs_server *afs_maybe_use_server(struct afs_server *server,
367 enum afs_server_trace reason)
368 {
369 unsigned int a;
370 int r;
371
372 if (!__refcount_inc_not_zero(&server->ref, &r))
373 return NULL;
374
375 a = atomic_inc_return(&server->active);
376 trace_afs_server(server, r + 1, a, reason);
377 return server;
378 }
379
380 /*
381 * Get an active count on a server object.
382 */
afs_use_server(struct afs_server * server,enum afs_server_trace reason)383 struct afs_server *afs_use_server(struct afs_server *server, enum afs_server_trace reason)
384 {
385 unsigned int a;
386 int r;
387
388 __refcount_inc(&server->ref, &r);
389 a = atomic_inc_return(&server->active);
390
391 trace_afs_server(server, r + 1, a, reason);
392 return server;
393 }
394
395 /*
396 * Release a reference on a server record.
397 */
afs_put_server(struct afs_net * net,struct afs_server * server,enum afs_server_trace reason)398 void afs_put_server(struct afs_net *net, struct afs_server *server,
399 enum afs_server_trace reason)
400 {
401 bool zero;
402 int r;
403
404 if (!server)
405 return;
406
407 zero = __refcount_dec_and_test(&server->ref, &r);
408 trace_afs_server(server, r - 1, atomic_read(&server->active), reason);
409 if (unlikely(zero))
410 __afs_put_server(net, server);
411 }
412
413 /*
414 * Drop an active count on a server object without updating the last-unused
415 * time.
416 */
afs_unuse_server_notime(struct afs_net * net,struct afs_server * server,enum afs_server_trace reason)417 void afs_unuse_server_notime(struct afs_net *net, struct afs_server *server,
418 enum afs_server_trace reason)
419 {
420 if (server) {
421 unsigned int active = atomic_dec_return(&server->active);
422
423 if (active == 0)
424 afs_set_server_timer(net, afs_server_gc_delay);
425 afs_put_server(net, server, reason);
426 }
427 }
428
429 /*
430 * Drop an active count on a server object.
431 */
afs_unuse_server(struct afs_net * net,struct afs_server * server,enum afs_server_trace reason)432 void afs_unuse_server(struct afs_net *net, struct afs_server *server,
433 enum afs_server_trace reason)
434 {
435 if (server) {
436 server->unuse_time = ktime_get_real_seconds();
437 afs_unuse_server_notime(net, server, reason);
438 }
439 }
440
afs_server_rcu(struct rcu_head * rcu)441 static void afs_server_rcu(struct rcu_head *rcu)
442 {
443 struct afs_server *server = container_of(rcu, struct afs_server, rcu);
444
445 trace_afs_server(server, refcount_read(&server->ref),
446 atomic_read(&server->active), afs_server_trace_free);
447 afs_put_addrlist(rcu_access_pointer(server->addresses));
448 kfree(server);
449 }
450
__afs_put_server(struct afs_net * net,struct afs_server * server)451 static void __afs_put_server(struct afs_net *net, struct afs_server *server)
452 {
453 call_rcu(&server->rcu, afs_server_rcu);
454 afs_dec_servers_outstanding(net);
455 }
456
afs_give_up_callbacks(struct afs_net * net,struct afs_server * server)457 static void afs_give_up_callbacks(struct afs_net *net, struct afs_server *server)
458 {
459 struct afs_addr_list *alist = rcu_access_pointer(server->addresses);
460 struct afs_addr_cursor ac = {
461 .alist = alist,
462 .index = alist->preferred,
463 .error = 0,
464 };
465
466 afs_fs_give_up_all_callbacks(net, server, &ac, NULL);
467 }
468
469 /*
470 * destroy a dead server
471 */
afs_destroy_server(struct afs_net * net,struct afs_server * server)472 static void afs_destroy_server(struct afs_net *net, struct afs_server *server)
473 {
474 if (test_bit(AFS_SERVER_FL_MAY_HAVE_CB, &server->flags))
475 afs_give_up_callbacks(net, server);
476
477 flush_work(&server->initcb_work);
478 afs_put_server(net, server, afs_server_trace_destroy);
479 }
480
481 /*
482 * Garbage collect any expired servers.
483 */
afs_gc_servers(struct afs_net * net,struct afs_server * gc_list)484 static void afs_gc_servers(struct afs_net *net, struct afs_server *gc_list)
485 {
486 struct afs_server *server, *next, *prev;
487 int active;
488
489 while ((server = gc_list)) {
490 gc_list = server->gc_next;
491
492 write_seqlock(&net->fs_lock);
493
494 active = atomic_read(&server->active);
495 if (active == 0) {
496 trace_afs_server(server, refcount_read(&server->ref),
497 active, afs_server_trace_gc);
498 next = rcu_dereference_protected(
499 server->uuid_next, lockdep_is_held(&net->fs_lock.lock));
500 prev = server->uuid_prev;
501 if (!prev) {
502 /* The one at the front is in the tree */
503 if (!next) {
504 rb_erase(&server->uuid_rb, &net->fs_servers);
505 } else {
506 rb_replace_node_rcu(&server->uuid_rb,
507 &next->uuid_rb,
508 &net->fs_servers);
509 next->uuid_prev = NULL;
510 }
511 } else {
512 /* This server is not at the front */
513 rcu_assign_pointer(prev->uuid_next, next);
514 if (next)
515 next->uuid_prev = prev;
516 }
517
518 list_del(&server->probe_link);
519 hlist_del_rcu(&server->proc_link);
520 if (!hlist_unhashed(&server->addr4_link))
521 hlist_del_rcu(&server->addr4_link);
522 if (!hlist_unhashed(&server->addr6_link))
523 hlist_del_rcu(&server->addr6_link);
524 }
525 write_sequnlock(&net->fs_lock);
526
527 if (active == 0)
528 afs_destroy_server(net, server);
529 }
530 }
531
532 /*
533 * Manage the records of servers known to be within a network namespace. This
534 * includes garbage collecting unused servers.
535 *
536 * Note also that we were given an increment on net->servers_outstanding by
537 * whoever queued us that we need to deal with before returning.
538 */
afs_manage_servers(struct work_struct * work)539 void afs_manage_servers(struct work_struct *work)
540 {
541 struct afs_net *net = container_of(work, struct afs_net, fs_manager);
542 struct afs_server *gc_list = NULL;
543 struct rb_node *cursor;
544 time64_t now = ktime_get_real_seconds(), next_manage = TIME64_MAX;
545 bool purging = !net->live;
546
547 _enter("");
548
549 /* Trawl the server list looking for servers that have expired from
550 * lack of use.
551 */
552 read_seqlock_excl(&net->fs_lock);
553
554 for (cursor = rb_first(&net->fs_servers); cursor; cursor = rb_next(cursor)) {
555 struct afs_server *server =
556 rb_entry(cursor, struct afs_server, uuid_rb);
557 int active = atomic_read(&server->active);
558
559 _debug("manage %pU %u", &server->uuid, active);
560
561 if (purging) {
562 trace_afs_server(server, refcount_read(&server->ref),
563 active, afs_server_trace_purging);
564 if (active != 0)
565 pr_notice("Can't purge s=%08x\n", server->debug_id);
566 }
567
568 if (active == 0) {
569 time64_t expire_at = server->unuse_time;
570
571 if (!test_bit(AFS_SERVER_FL_VL_FAIL, &server->flags) &&
572 !test_bit(AFS_SERVER_FL_NOT_FOUND, &server->flags))
573 expire_at += afs_server_gc_delay;
574 if (purging || expire_at <= now) {
575 server->gc_next = gc_list;
576 gc_list = server;
577 } else if (expire_at < next_manage) {
578 next_manage = expire_at;
579 }
580 }
581 }
582
583 read_sequnlock_excl(&net->fs_lock);
584
585 /* Update the timer on the way out. We have to pass an increment on
586 * servers_outstanding in the namespace that we are in to the timer or
587 * the work scheduler.
588 */
589 if (!purging && next_manage < TIME64_MAX) {
590 now = ktime_get_real_seconds();
591
592 if (next_manage - now <= 0) {
593 if (queue_work(afs_wq, &net->fs_manager))
594 afs_inc_servers_outstanding(net);
595 } else {
596 afs_set_server_timer(net, next_manage - now);
597 }
598 }
599
600 afs_gc_servers(net, gc_list);
601
602 afs_dec_servers_outstanding(net);
603 _leave(" [%d]", atomic_read(&net->servers_outstanding));
604 }
605
afs_queue_server_manager(struct afs_net * net)606 static void afs_queue_server_manager(struct afs_net *net)
607 {
608 afs_inc_servers_outstanding(net);
609 if (!queue_work(afs_wq, &net->fs_manager))
610 afs_dec_servers_outstanding(net);
611 }
612
613 /*
614 * Purge list of servers.
615 */
afs_purge_servers(struct afs_net * net)616 void afs_purge_servers(struct afs_net *net)
617 {
618 _enter("");
619
620 if (del_timer_sync(&net->fs_timer))
621 afs_dec_servers_outstanding(net);
622
623 afs_queue_server_manager(net);
624
625 _debug("wait");
626 atomic_dec(&net->servers_outstanding);
627 wait_var_event(&net->servers_outstanding,
628 !atomic_read(&net->servers_outstanding));
629 _leave("");
630 }
631
632 /*
633 * Get an update for a server's address list.
634 */
afs_update_server_record(struct afs_operation * op,struct afs_server * server)635 static noinline bool afs_update_server_record(struct afs_operation *op,
636 struct afs_server *server)
637 {
638 struct afs_addr_list *alist, *discard;
639
640 _enter("");
641
642 trace_afs_server(server, refcount_read(&server->ref),
643 atomic_read(&server->active),
644 afs_server_trace_update);
645
646 alist = afs_vl_lookup_addrs(op->volume->cell, op->key, &server->uuid);
647 if (IS_ERR(alist)) {
648 if ((PTR_ERR(alist) == -ERESTARTSYS ||
649 PTR_ERR(alist) == -EINTR) &&
650 (op->flags & AFS_OPERATION_UNINTR) &&
651 server->addresses) {
652 _leave(" = t [intr]");
653 return true;
654 }
655 op->error = PTR_ERR(alist);
656 _leave(" = f [%d]", op->error);
657 return false;
658 }
659
660 discard = alist;
661 if (server->addr_version != alist->version) {
662 write_lock(&server->fs_lock);
663 discard = rcu_dereference_protected(server->addresses,
664 lockdep_is_held(&server->fs_lock));
665 rcu_assign_pointer(server->addresses, alist);
666 server->addr_version = alist->version;
667 write_unlock(&server->fs_lock);
668 }
669
670 afs_put_addrlist(discard);
671 _leave(" = t");
672 return true;
673 }
674
675 /*
676 * See if a server's address list needs updating.
677 */
afs_check_server_record(struct afs_operation * op,struct afs_server * server)678 bool afs_check_server_record(struct afs_operation *op, struct afs_server *server)
679 {
680 bool success;
681 int ret, retries = 0;
682
683 _enter("");
684
685 ASSERT(server);
686
687 retry:
688 if (test_bit(AFS_SERVER_FL_UPDATING, &server->flags))
689 goto wait;
690 if (test_bit(AFS_SERVER_FL_NEEDS_UPDATE, &server->flags))
691 goto update;
692 _leave(" = t [good]");
693 return true;
694
695 update:
696 if (!test_and_set_bit_lock(AFS_SERVER_FL_UPDATING, &server->flags)) {
697 clear_bit(AFS_SERVER_FL_NEEDS_UPDATE, &server->flags);
698 success = afs_update_server_record(op, server);
699 clear_bit_unlock(AFS_SERVER_FL_UPDATING, &server->flags);
700 wake_up_bit(&server->flags, AFS_SERVER_FL_UPDATING);
701 _leave(" = %d", success);
702 return success;
703 }
704
705 wait:
706 ret = wait_on_bit(&server->flags, AFS_SERVER_FL_UPDATING,
707 (op->flags & AFS_OPERATION_UNINTR) ?
708 TASK_UNINTERRUPTIBLE : TASK_INTERRUPTIBLE);
709 if (ret == -ERESTARTSYS) {
710 op->error = ret;
711 _leave(" = f [intr]");
712 return false;
713 }
714
715 retries++;
716 if (retries == 4) {
717 _leave(" = f [stale]");
718 ret = -ESTALE;
719 return false;
720 }
721 goto retry;
722 }
723