|
20 | 20 | #include "internal.h" |
21 | 21 |
|
22 | 22 | static unsigned __read_mostly afs_cell_gc_delay = 10; |
| 23 | +static unsigned __read_mostly afs_cell_min_ttl = 10 * 60; |
| 24 | +static unsigned __read_mostly afs_cell_max_ttl = 24 * 60 * 60; |
23 | 25 |
|
24 | 26 | static void afs_manage_cell(struct work_struct *); |
25 | 27 |
|
@@ -171,6 +173,8 @@ static struct afs_cell *afs_alloc_cell(struct afs_net *net, |
171 | 173 |
|
172 | 174 | rcu_assign_pointer(cell->vl_servers, vllist); |
173 | 175 | cell->dns_expiry = TIME64_MAX; |
| 176 | + } else { |
| 177 | + cell->dns_expiry = ktime_get_real_seconds(); |
174 | 178 | } |
175 | 179 |
|
176 | 180 | _leave(" = %p", cell); |
@@ -358,25 +362,39 @@ int afs_cell_init(struct afs_net *net, const char *rootcell) |
358 | 362 | static void afs_update_cell(struct afs_cell *cell) |
359 | 363 | { |
360 | 364 | struct afs_vlserver_list *vllist, *old; |
361 | | - time64_t now, expiry; |
| 365 | + unsigned int min_ttl = READ_ONCE(afs_cell_min_ttl); |
| 366 | + unsigned int max_ttl = READ_ONCE(afs_cell_max_ttl); |
| 367 | + time64_t now, expiry = 0; |
362 | 368 |
|
363 | 369 | _enter("%s", cell->name); |
364 | 370 |
|
365 | 371 | vllist = afs_dns_query(cell, &expiry); |
| 372 | + |
| 373 | + now = ktime_get_real_seconds(); |
| 374 | + if (min_ttl > max_ttl) |
| 375 | + max_ttl = min_ttl; |
| 376 | + if (expiry < now + min_ttl) |
| 377 | + expiry = now + min_ttl; |
| 378 | + else if (expiry > now + max_ttl) |
| 379 | + expiry = now + max_ttl; |
| 380 | + |
366 | 381 | if (IS_ERR(vllist)) { |
367 | 382 | switch (PTR_ERR(vllist)) { |
368 | 383 | case -ENODATA: |
369 | | - /* The DNS said that the cell does not exist */ |
| 384 | + case -EDESTADDRREQ: |
| 385 | + /* The DNS said that the cell does not exist or there |
| 386 | + * weren't any addresses to be had. |
| 387 | + */ |
370 | 388 | set_bit(AFS_CELL_FL_NOT_FOUND, &cell->flags); |
371 | 389 | clear_bit(AFS_CELL_FL_DNS_FAIL, &cell->flags); |
372 | | - cell->dns_expiry = ktime_get_real_seconds() + 61; |
| 390 | + cell->dns_expiry = expiry; |
373 | 391 | break; |
374 | 392 |
|
375 | 393 | case -EAGAIN: |
376 | 394 | case -ECONNREFUSED: |
377 | 395 | default: |
378 | 396 | set_bit(AFS_CELL_FL_DNS_FAIL, &cell->flags); |
379 | | - cell->dns_expiry = ktime_get_real_seconds() + 10; |
| 397 | + cell->dns_expiry = now + 10; |
380 | 398 | break; |
381 | 399 | } |
382 | 400 |
|
|
0 commit comments