Merge tag 'afs-fixes-20171124' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs

Pull AFS fixes from David Howells:

- Make AFS file locking work again.

- Don't write to a page that's being written out, but wait for it to
complete.

- Do d_drop() and d_add() in the right places.

- Put keys on error paths.

- Remove some redundant code.

* tag 'afs-fixes-20171124' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs:
afs: remove redundant assignment of dvnode to itself
afs: cell: Remove unnecessary code in afs_lookup_cell
afs: Fix signal handling in some file ops
afs: Fix some dentry handling in dir ops and missing key_puts
afs: Make afs_write_begin() avoid writing to a page that's being stored
afs: Fix file locking

+418 -292
+1 -6
fs/afs/cell.c
··· 207 rcu_read_lock(); 208 cell = afs_lookup_cell_rcu(net, name, namesz); 209 rcu_read_unlock(); 210 - if (!IS_ERR(cell)) { 211 - if (excl) { 212 - afs_put_cell(net, cell); 213 - return ERR_PTR(-EEXIST); 214 - } 215 goto wait_for_cell; 216 - } 217 } 218 219 /* Assume we're probably going to create a cell and preallocate and
··· 207 rcu_read_lock(); 208 cell = afs_lookup_cell_rcu(net, name, namesz); 209 rcu_read_unlock(); 210 + if (!IS_ERR(cell)) 211 goto wait_for_cell; 212 } 213 214 /* Assume we're probably going to create a cell and preallocate and
+14 -11
fs/afs/dir.c
··· 765 if (fc->ac.error < 0) 766 return; 767 768 inode = afs_iget(fc->vnode->vfs_inode.i_sb, fc->key, 769 newfid, newstatus, newcb, fc->cbi); 770 if (IS_ERR(inode)) { ··· 777 return; 778 } 779 780 - d_instantiate(new_dentry, inode); 781 - if (d_unhashed(new_dentry)) 782 - d_rehash(new_dentry); 783 } 784 785 /* ··· 818 ret = afs_end_vnode_operation(&fc); 819 if (ret < 0) 820 goto error_key; 821 } 822 823 key_put(key); ··· 974 struct afs_fs_cursor fc; 975 struct afs_file_status newstatus; 976 struct afs_callback newcb; 977 - struct afs_vnode *dvnode = dvnode = AFS_FS_I(dir); 978 struct afs_fid newfid; 979 struct key *key; 980 int ret; ··· 1008 ret = afs_end_vnode_operation(&fc); 1009 if (ret < 0) 1010 goto error_key; 1011 } 1012 1013 key_put(key); ··· 1057 if (afs_begin_vnode_operation(&fc, dvnode, key)) { 1058 if (mutex_lock_interruptible_nested(&vnode->io_lock, 1) < 0) { 1059 afs_end_vnode_operation(&fc); 1060 - return -ERESTARTSYS; 1061 } 1062 1063 while (afs_select_fileserver(&fc)) { ··· 1075 ret = afs_end_vnode_operation(&fc); 1076 if (ret < 0) 1077 goto error_key; 1078 } 1079 1080 key_put(key); ··· 1136 ret = afs_end_vnode_operation(&fc); 1137 if (ret < 0) 1138 goto error_key; 1139 } 1140 1141 key_put(key); ··· 1188 if (orig_dvnode != new_dvnode) { 1189 if (mutex_lock_interruptible_nested(&new_dvnode->io_lock, 1) < 0) { 1190 afs_end_vnode_operation(&fc); 1191 - return -ERESTARTSYS; 1192 } 1193 } 1194 while (afs_select_fileserver(&fc)) { ··· 1207 goto error_key; 1208 } 1209 1210 - key_put(key); 1211 - _leave(" = 0"); 1212 - return 0; 1213 - 1214 error_key: 1215 key_put(key); 1216 error: 1217 - d_drop(new_dentry); 1218 _leave(" = %d", ret); 1219 return ret; 1220 }
··· 765 if (fc->ac.error < 0) 766 return; 767 768 + d_drop(new_dentry); 769 + 770 inode = afs_iget(fc->vnode->vfs_inode.i_sb, fc->key, 771 newfid, newstatus, newcb, fc->cbi); 772 if (IS_ERR(inode)) { ··· 775 return; 776 } 777 778 + d_add(new_dentry, inode); 779 } 780 781 /* ··· 818 ret = afs_end_vnode_operation(&fc); 819 if (ret < 0) 820 goto error_key; 821 + } else { 822 + goto error_key; 823 } 824 825 key_put(key); ··· 972 struct afs_fs_cursor fc; 973 struct afs_file_status newstatus; 974 struct afs_callback newcb; 975 + struct afs_vnode *dvnode = AFS_FS_I(dir); 976 struct afs_fid newfid; 977 struct key *key; 978 int ret; ··· 1006 ret = afs_end_vnode_operation(&fc); 1007 if (ret < 0) 1008 goto error_key; 1009 + } else { 1010 + goto error_key; 1011 } 1012 1013 key_put(key); ··· 1053 if (afs_begin_vnode_operation(&fc, dvnode, key)) { 1054 if (mutex_lock_interruptible_nested(&vnode->io_lock, 1) < 0) { 1055 afs_end_vnode_operation(&fc); 1056 + goto error_key; 1057 } 1058 1059 while (afs_select_fileserver(&fc)) { ··· 1071 ret = afs_end_vnode_operation(&fc); 1072 if (ret < 0) 1073 goto error_key; 1074 + } else { 1075 + goto error_key; 1076 } 1077 1078 key_put(key); ··· 1130 ret = afs_end_vnode_operation(&fc); 1131 if (ret < 0) 1132 goto error_key; 1133 + } else { 1134 + goto error_key; 1135 } 1136 1137 key_put(key); ··· 1180 if (orig_dvnode != new_dvnode) { 1181 if (mutex_lock_interruptible_nested(&new_dvnode->io_lock, 1) < 0) { 1182 afs_end_vnode_operation(&fc); 1183 + goto error_key; 1184 } 1185 } 1186 while (afs_select_fileserver(&fc)) { ··· 1199 goto error_key; 1200 } 1201 1202 error_key: 1203 key_put(key); 1204 error: 1205 _leave(" = %d", ret); 1206 return ret; 1207 }
+322 -250
fs/afs/flock.c
··· 170 { 171 struct afs_vnode *vnode = 172 container_of(work, struct afs_vnode, lock_work.work); 173 - struct file_lock *fl; 174 afs_lock_type_t type; 175 struct key *key; 176 int ret; ··· 179 180 spin_lock(&vnode->lock); 181 182 - if (test_bit(AFS_VNODE_UNLOCKING, &vnode->flags)) { 183 _debug("unlock"); 184 spin_unlock(&vnode->lock); 185 186 /* attempt to release the server lock; if it fails, we just 187 - * wait 5 minutes and it'll time out anyway */ 188 - ret = afs_release_lock(vnode, vnode->unlock_key); 189 if (ret < 0) 190 printk(KERN_WARNING "AFS:" 191 " Failed to release lock on {%x:%x} error %d\n", 192 vnode->fid.vid, vnode->fid.vnode, ret); 193 194 spin_lock(&vnode->lock); 195 - key_put(vnode->unlock_key); 196 - vnode->unlock_key = NULL; 197 - clear_bit(AFS_VNODE_UNLOCKING, &vnode->flags); 198 - } 199 200 - /* if we've got a lock, then it must be time to extend that lock as AFS 201 - * locks time out after 5 minutes */ 202 - if (!list_empty(&vnode->granted_locks)) { 203 _debug("extend"); 204 205 - if (test_and_set_bit(AFS_VNODE_LOCKING, &vnode->flags)) 206 - BUG(); 207 - fl = list_entry(vnode->granted_locks.next, 208 - struct file_lock, fl_u.afs.link); 209 - key = key_get(afs_file_key(fl->fl_file)); 210 spin_unlock(&vnode->lock); 211 212 - ret = afs_extend_lock(vnode, key); 213 - clear_bit(AFS_VNODE_LOCKING, &vnode->flags); 214 key_put(key); 215 - switch (ret) { 216 - case 0: 217 afs_schedule_lock_extension(vnode); 218 - break; 219 - default: 220 - /* ummm... we failed to extend the lock - retry 221 - * extension shortly */ 222 - printk(KERN_WARNING "AFS:" 223 - " Failed to extend lock on {%x:%x} error %d\n", 224 - vnode->fid.vid, vnode->fid.vnode, ret); 225 queue_delayed_work(afs_lock_manager, &vnode->lock_work, 226 HZ * 10); 227 - break; 228 - } 229 - _leave(" [extend]"); 230 return; 231 - } 232 233 - /* if we don't have a granted lock, then we must've been called back by 234 - * the server, and so if might be possible to get a lock we're 235 - * currently waiting for */ 236 - if (!list_empty(&vnode->pending_locks)) { 237 _debug("get"); 238 239 - if (test_and_set_bit(AFS_VNODE_LOCKING, &vnode->flags)) 240 - BUG(); 241 - fl = list_entry(vnode->pending_locks.next, 242 - struct file_lock, fl_u.afs.link); 243 - key = key_get(afs_file_key(fl->fl_file)); 244 - type = (fl->fl_type == F_RDLCK) ? 245 - AFS_LOCK_READ : AFS_LOCK_WRITE; 246 spin_unlock(&vnode->lock); 247 248 - ret = afs_set_lock(vnode, key, type); 249 - clear_bit(AFS_VNODE_LOCKING, &vnode->flags); 250 switch (ret) { 251 case -EWOULDBLOCK: 252 _debug("blocked"); 253 break; 254 case 0: 255 _debug("acquired"); 256 - if (type == AFS_LOCK_READ) 257 - set_bit(AFS_VNODE_READLOCKED, &vnode->flags); 258 - else 259 - set_bit(AFS_VNODE_WRITELOCKED, &vnode->flags); 260 - ret = AFS_LOCK_GRANTED; 261 default: 262 - spin_lock(&vnode->lock); 263 - /* the pending lock may have been withdrawn due to a 264 - * signal */ 265 - if (list_entry(vnode->pending_locks.next, 266 - struct file_lock, fl_u.afs.link) == fl) { 267 - fl->fl_u.afs.state = ret; 268 - if (ret == AFS_LOCK_GRANTED) 269 - afs_grant_locks(vnode, fl); 270 - else 271 - list_del_init(&fl->fl_u.afs.link); 272 - wake_up(&fl->fl_wait); 273 - spin_unlock(&vnode->lock); 274 - } else { 275 _debug("withdrawn"); 276 - clear_bit(AFS_VNODE_READLOCKED, &vnode->flags); 277 - clear_bit(AFS_VNODE_WRITELOCKED, &vnode->flags); 278 - spin_unlock(&vnode->lock); 279 - afs_release_lock(vnode, key); 280 - if (!list_empty(&vnode->pending_locks)) 281 - afs_lock_may_be_available(vnode); 282 } 283 - break; 284 } 285 - key_put(key); 286 - _leave(" [pend]"); 287 return; 288 } 289 - 290 - /* looks like the lock request was withdrawn on a signal */ 291 - spin_unlock(&vnode->lock); 292 - _leave(" [no locks]"); 293 } 294 295 /* ··· 317 * AF_RXRPC 318 * - the caller must hold the vnode lock 319 */ 320 - static void afs_defer_unlock(struct afs_vnode *vnode, struct key *key) 321 { 322 - cancel_delayed_work(&vnode->lock_work); 323 - if (!test_and_clear_bit(AFS_VNODE_READLOCKED, &vnode->flags) && 324 - !test_and_clear_bit(AFS_VNODE_WRITELOCKED, &vnode->flags)) 325 - BUG(); 326 - if (test_and_set_bit(AFS_VNODE_UNLOCKING, &vnode->flags)) 327 - BUG(); 328 - vnode->unlock_key = key_get(key); 329 afs_lock_may_be_available(vnode); 330 } 331 ··· 424 */ 425 static int afs_do_setlk(struct file *file, struct file_lock *fl) 426 { 427 - struct inode *inode = file_inode(file); 428 struct afs_vnode *vnode = AFS_FS_I(inode); 429 afs_lock_type_t type; 430 struct key *key = afs_file_key(file); ··· 442 443 type = (fl->fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE; 444 445 - spin_lock(&inode->i_lock); 446 - 447 - /* make sure we've got a callback on this file and that our view of the 448 - * data version is up to date */ 449 - ret = afs_validate(vnode, key); 450 if (ret < 0) 451 - goto error; 452 - 453 - if (vnode->status.lock_count != 0 && !(fl->fl_flags & FL_SLEEP)) { 454 - ret = -EAGAIN; 455 - goto error; 456 - } 457 458 spin_lock(&vnode->lock); 459 460 - /* if we've already got a readlock on the server then we can instantly 461 * grant another readlock, irrespective of whether there are any 462 - * pending writelocks */ 463 if (type == AFS_LOCK_READ && 464 - vnode->flags & (1 << AFS_VNODE_READLOCKED)) { 465 _debug("instant readlock"); 466 - ASSERTCMP(vnode->flags & 467 - ((1 << AFS_VNODE_LOCKING) | 468 - (1 << AFS_VNODE_WRITELOCKED)), ==, 0); 469 ASSERT(!list_empty(&vnode->granted_locks)); 470 - goto sharing_existing_lock; 471 } 472 473 - /* if there's no-one else with a lock on this vnode, then we need to 474 - * ask the server for a lock */ 475 - if (list_empty(&vnode->pending_locks) && 476 - list_empty(&vnode->granted_locks)) { 477 - _debug("not locked"); 478 - ASSERTCMP(vnode->flags & 479 - ((1 << AFS_VNODE_LOCKING) | 480 - (1 << AFS_VNODE_READLOCKED) | 481 - (1 << AFS_VNODE_WRITELOCKED)), ==, 0); 482 - list_add_tail(&fl->fl_u.afs.link, &vnode->pending_locks); 483 - set_bit(AFS_VNODE_LOCKING, &vnode->flags); 484 - spin_unlock(&vnode->lock); 485 - 486 - ret = afs_set_lock(vnode, key, type); 487 - clear_bit(AFS_VNODE_LOCKING, &vnode->flags); 488 - switch (ret) { 489 - case 0: 490 - _debug("acquired"); 491 - goto acquired_server_lock; 492 - case -EWOULDBLOCK: 493 - _debug("would block"); 494 - spin_lock(&vnode->lock); 495 - ASSERT(list_empty(&vnode->granted_locks)); 496 - ASSERTCMP(vnode->pending_locks.next, ==, 497 - &fl->fl_u.afs.link); 498 - goto wait; 499 - default: 500 - spin_lock(&vnode->lock); 501 - list_del_init(&fl->fl_u.afs.link); 502 - spin_unlock(&vnode->lock); 503 - goto error; 504 - } 505 - } 506 - 507 - /* otherwise, we need to wait for a local lock to become available */ 508 - _debug("wait local"); 509 list_add_tail(&fl->fl_u.afs.link, &vnode->pending_locks); 510 - wait: 511 - if (!(fl->fl_flags & FL_SLEEP)) { 512 - _debug("noblock"); 513 - ret = -EAGAIN; 514 - goto abort_attempt; 515 - } 516 spin_unlock(&vnode->lock); 517 518 - /* now we need to sleep and wait for the lock manager thread to get the 519 - * lock from the server */ 520 - _debug("sleep"); 521 - ret = wait_event_interruptible(fl->fl_wait, 522 - fl->fl_u.afs.state <= AFS_LOCK_GRANTED); 523 - if (fl->fl_u.afs.state <= AFS_LOCK_GRANTED) { 524 - ret = fl->fl_u.afs.state; 525 - if (ret < 0) 526 - goto error; 527 - spin_lock(&vnode->lock); 528 - goto given_lock; 529 - } 530 - 531 - /* we were interrupted, but someone may still be in the throes of 532 - * giving us the lock */ 533 - _debug("intr"); 534 - ASSERTCMP(ret, ==, -ERESTARTSYS); 535 536 spin_lock(&vnode->lock); 537 - if (fl->fl_u.afs.state <= AFS_LOCK_GRANTED) { 538 - ret = fl->fl_u.afs.state; 539 - if (ret < 0) { 540 - spin_unlock(&vnode->lock); 541 - goto error; 542 - } 543 - goto given_lock; 544 } 545 546 abort_attempt: 547 /* we aren't going to get the lock, either because we're unwilling to 548 * wait, or because some signal happened */ 549 _debug("abort"); 550 - if (list_empty(&vnode->granted_locks) && 551 - vnode->pending_locks.next == &fl->fl_u.afs.link) { 552 - if (vnode->pending_locks.prev != &fl->fl_u.afs.link) { 553 - /* kick the next pending lock into having a go */ 554 - list_del_init(&fl->fl_u.afs.link); 555 - afs_lock_may_be_available(vnode); 556 - } 557 - } else { 558 - list_del_init(&fl->fl_u.afs.link); 559 - } 560 spin_unlock(&vnode->lock); 561 - goto error; 562 - 563 - acquired_server_lock: 564 - /* we've acquired a server lock, but it needs to be renewed after 5 565 - * mins */ 566 - spin_lock(&vnode->lock); 567 - afs_schedule_lock_extension(vnode); 568 - if (type == AFS_LOCK_READ) 569 - set_bit(AFS_VNODE_READLOCKED, &vnode->flags); 570 - else 571 - set_bit(AFS_VNODE_WRITELOCKED, &vnode->flags); 572 - sharing_existing_lock: 573 - /* the lock has been granted as far as we're concerned... */ 574 - fl->fl_u.afs.state = AFS_LOCK_GRANTED; 575 - list_move_tail(&fl->fl_u.afs.link, &vnode->granted_locks); 576 - given_lock: 577 - /* ... but we do still need to get the VFS's blessing */ 578 - ASSERT(!(vnode->flags & (1 << AFS_VNODE_LOCKING))); 579 - ASSERT((vnode->flags & ((1 << AFS_VNODE_READLOCKED) | 580 - (1 << AFS_VNODE_WRITELOCKED))) != 0); 581 - ret = posix_lock_file(file, fl, NULL); 582 - if (ret < 0) 583 - goto vfs_rejected_lock; 584 - spin_unlock(&vnode->lock); 585 - 586 - /* again, make sure we've got a callback on this file and, again, make 587 - * sure that our view of the data version is up to date (we ignore 588 - * errors incurred here and deal with the consequences elsewhere) */ 589 - afs_validate(vnode, key); 590 - 591 - error: 592 - spin_unlock(&inode->i_lock); 593 _leave(" = %d", ret); 594 return ret; 595 596 vfs_rejected_lock: 597 - /* the VFS rejected the lock we just obtained, so we have to discard 598 - * what we just got */ 599 _debug("vfs refused %d", ret); 600 list_del_init(&fl->fl_u.afs.link); 601 if (list_empty(&vnode->granted_locks)) 602 - afs_defer_unlock(vnode, key); 603 - goto abort_attempt; 604 } 605 606 /* ··· 579 */ 580 static int afs_do_unlk(struct file *file, struct file_lock *fl) 581 { 582 - struct afs_vnode *vnode = AFS_FS_I(file->f_mapping->host); 583 - struct key *key = afs_file_key(file); 584 int ret; 585 586 _enter("{%x:%u},%u", vnode->fid.vid, vnode->fid.vnode, fl->fl_type); 587 588 /* only whole-file unlocks are supported */ 589 if (fl->fl_start != 0 || fl->fl_end != OFFSET_MAX) 590 return -EINVAL; 591 592 - fl->fl_ops = &afs_lock_ops; 593 - INIT_LIST_HEAD(&fl->fl_u.afs.link); 594 - fl->fl_u.afs.state = AFS_LOCK_PENDING; 595 - 596 - spin_lock(&vnode->lock); 597 ret = posix_lock_file(file, fl, NULL); 598 - if (ret < 0) { 599 - spin_unlock(&vnode->lock); 600 - _leave(" = %d [vfs]", ret); 601 - return ret; 602 - } 603 - 604 - /* discard the server lock only if all granted locks are gone */ 605 - if (list_empty(&vnode->granted_locks)) 606 - afs_defer_unlock(vnode, key); 607 - spin_unlock(&vnode->lock); 608 - _leave(" = 0"); 609 - return 0; 610 } 611 612 /* ··· 601 */ 602 static int afs_do_getlk(struct file *file, struct file_lock *fl) 603 { 604 - struct afs_vnode *vnode = AFS_FS_I(file->f_mapping->host); 605 struct key *key = afs_file_key(file); 606 int ret, lock_count; 607 ··· 609 610 fl->fl_type = F_UNLCK; 611 612 - inode_lock(&vnode->vfs_inode); 613 - 614 /* check local lock records first */ 615 - ret = 0; 616 posix_test_lock(file, fl); 617 if (fl->fl_type == F_UNLCK) { 618 /* no local locks; consult the server */ 619 ret = afs_fetch_status(vnode, key); 620 if (ret < 0) 621 goto error; 622 - lock_count = vnode->status.lock_count; 623 - if (lock_count) { 624 - if (lock_count > 0) 625 - fl->fl_type = F_RDLCK; 626 - else 627 - fl->fl_type = F_WRLCK; 628 - fl->fl_start = 0; 629 - fl->fl_end = OFFSET_MAX; 630 - } 631 } 632 633 error: 634 - inode_unlock(&vnode->vfs_inode); 635 _leave(" = %d [%hd]", ret, fl->fl_type); 636 return ret; 637 } ··· 637 */ 638 int afs_lock(struct file *file, int cmd, struct file_lock *fl) 639 { 640 - struct afs_vnode *vnode = AFS_FS_I(file_inode(file)); 641 642 _enter("{%x:%u},%d,{t=%x,fl=%x,r=%Ld:%Ld}", 643 vnode->fid.vid, vnode->fid.vnode, cmd, ··· 660 */ 661 int afs_flock(struct file *file, int cmd, struct file_lock *fl) 662 { 663 - struct afs_vnode *vnode = AFS_FS_I(file_inode(file)); 664 665 _enter("{%x:%u},%d,{t=%x,fl=%x}", 666 vnode->fid.vid, vnode->fid.vnode, cmd, ··· 690 */ 691 static void afs_fl_copy_lock(struct file_lock *new, struct file_lock *fl) 692 { 693 _enter(""); 694 695 list_add(&new->fl_u.afs.link, &fl->fl_u.afs.link); 696 } 697 698 /* ··· 705 */ 706 static void afs_fl_release_private(struct file_lock *fl) 707 { 708 _enter(""); 709 710 - list_del_init(&fl->fl_u.afs.link); 711 }
··· 170 { 171 struct afs_vnode *vnode = 172 container_of(work, struct afs_vnode, lock_work.work); 173 + struct file_lock *fl, *next; 174 afs_lock_type_t type; 175 struct key *key; 176 int ret; ··· 179 180 spin_lock(&vnode->lock); 181 182 + again: 183 + _debug("wstate %u for %p", vnode->lock_state, vnode); 184 + switch (vnode->lock_state) { 185 + case AFS_VNODE_LOCK_NEED_UNLOCK: 186 _debug("unlock"); 187 + vnode->lock_state = AFS_VNODE_LOCK_UNLOCKING; 188 spin_unlock(&vnode->lock); 189 190 /* attempt to release the server lock; if it fails, we just 191 + * wait 5 minutes and it'll expire anyway */ 192 + ret = afs_release_lock(vnode, vnode->lock_key); 193 if (ret < 0) 194 printk(KERN_WARNING "AFS:" 195 " Failed to release lock on {%x:%x} error %d\n", 196 vnode->fid.vid, vnode->fid.vnode, ret); 197 198 spin_lock(&vnode->lock); 199 + key_put(vnode->lock_key); 200 + vnode->lock_key = NULL; 201 + vnode->lock_state = AFS_VNODE_LOCK_NONE; 202 203 + if (list_empty(&vnode->pending_locks)) { 204 + spin_unlock(&vnode->lock); 205 + return; 206 + } 207 + 208 + /* The new front of the queue now owns the state variables. */ 209 + next = list_entry(vnode->pending_locks.next, 210 + struct file_lock, fl_u.afs.link); 211 + vnode->lock_key = afs_file_key(next->fl_file); 212 + vnode->lock_type = (next->fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE; 213 + vnode->lock_state = AFS_VNODE_LOCK_WAITING_FOR_CB; 214 + goto again; 215 + 216 + /* If we've already got a lock, then it must be time to extend that 217 + * lock as AFS locks time out after 5 minutes. 218 + */ 219 + case AFS_VNODE_LOCK_GRANTED: 220 _debug("extend"); 221 222 + ASSERT(!list_empty(&vnode->granted_locks)); 223 + 224 + key = key_get(vnode->lock_key); 225 + vnode->lock_state = AFS_VNODE_LOCK_EXTENDING; 226 spin_unlock(&vnode->lock); 227 228 + ret = afs_extend_lock(vnode, key); /* RPC */ 229 key_put(key); 230 + 231 + if (ret < 0) 232 + pr_warning("AFS: Failed to extend lock on {%x:%x} error %d\n", 233 + vnode->fid.vid, vnode->fid.vnode, ret); 234 + 235 + spin_lock(&vnode->lock); 236 + 237 + if (vnode->lock_state != AFS_VNODE_LOCK_EXTENDING) 238 + goto again; 239 + vnode->lock_state = AFS_VNODE_LOCK_GRANTED; 240 + 241 + if (ret == 0) 242 afs_schedule_lock_extension(vnode); 243 + else 244 queue_delayed_work(afs_lock_manager, &vnode->lock_work, 245 HZ * 10); 246 + spin_unlock(&vnode->lock); 247 + _leave(" [ext]"); 248 return; 249 250 + /* If we don't have a granted lock, then we must've been called 251 + * back by the server, and so if might be possible to get a 252 + * lock we're currently waiting for. 253 + */ 254 + case AFS_VNODE_LOCK_WAITING_FOR_CB: 255 _debug("get"); 256 257 + key = key_get(vnode->lock_key); 258 + type = vnode->lock_type; 259 + vnode->lock_state = AFS_VNODE_LOCK_SETTING; 260 spin_unlock(&vnode->lock); 261 262 + ret = afs_set_lock(vnode, key, type); /* RPC */ 263 + key_put(key); 264 + 265 + spin_lock(&vnode->lock); 266 switch (ret) { 267 case -EWOULDBLOCK: 268 _debug("blocked"); 269 break; 270 case 0: 271 _debug("acquired"); 272 + vnode->lock_state = AFS_VNODE_LOCK_GRANTED; 273 + /* Fall through */ 274 default: 275 + /* Pass the lock or the error onto the first locker in 276 + * the list - if they're looking for this type of lock. 277 + * If they're not, we assume that whoever asked for it 278 + * took a signal. 279 + */ 280 + if (list_empty(&vnode->pending_locks)) { 281 _debug("withdrawn"); 282 + vnode->lock_state = AFS_VNODE_LOCK_NEED_UNLOCK; 283 + goto again; 284 } 285 + 286 + fl = list_entry(vnode->pending_locks.next, 287 + struct file_lock, fl_u.afs.link); 288 + type = (fl->fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE; 289 + if (vnode->lock_type != type) { 290 + _debug("changed"); 291 + vnode->lock_state = AFS_VNODE_LOCK_NEED_UNLOCK; 292 + goto again; 293 + } 294 + 295 + fl->fl_u.afs.state = ret; 296 + if (ret == 0) 297 + afs_grant_locks(vnode, fl); 298 + else 299 + list_del_init(&fl->fl_u.afs.link); 300 + wake_up(&fl->fl_wait); 301 + spin_unlock(&vnode->lock); 302 + _leave(" [granted]"); 303 + return; 304 } 305 + 306 + default: 307 + /* Looks like a lock request was withdrawn. */ 308 + spin_unlock(&vnode->lock); 309 + _leave(" [no]"); 310 return; 311 } 312 } 313 314 /* ··· 298 * AF_RXRPC 299 * - the caller must hold the vnode lock 300 */ 301 + static void afs_defer_unlock(struct afs_vnode *vnode) 302 { 303 + _enter(""); 304 + 305 + if (vnode->lock_state == AFS_VNODE_LOCK_GRANTED || 306 + vnode->lock_state == AFS_VNODE_LOCK_EXTENDING) { 307 + cancel_delayed_work(&vnode->lock_work); 308 + 309 + vnode->lock_state = AFS_VNODE_LOCK_NEED_UNLOCK; 310 + afs_lock_may_be_available(vnode); 311 + } 312 + } 313 + 314 + /* 315 + * Check that our view of the file metadata is up to date and check to see 316 + * whether we think that we have a locking permit. 317 + */ 318 + static int afs_do_setlk_check(struct afs_vnode *vnode, struct key *key, 319 + afs_lock_type_t type, bool can_sleep) 320 + { 321 + afs_access_t access; 322 + int ret; 323 + 324 + /* Make sure we've got a callback on this file and that our view of the 325 + * data version is up to date. 326 + */ 327 + ret = afs_validate(vnode, key); 328 + if (ret < 0) 329 + return ret; 330 + 331 + /* Check the permission set to see if we're actually going to be 332 + * allowed to get a lock on this file. 333 + */ 334 + ret = afs_check_permit(vnode, key, &access); 335 + if (ret < 0) 336 + return ret; 337 + 338 + /* At a rough estimation, you need LOCK, WRITE or INSERT perm to 339 + * read-lock a file and WRITE or INSERT perm to write-lock a file. 340 + * 341 + * We can't rely on the server to do this for us since if we want to 342 + * share a read lock that we already have, we won't go the server. 343 + */ 344 + if (type == AFS_LOCK_READ) { 345 + if (!(access & (AFS_ACE_INSERT | AFS_ACE_WRITE | AFS_ACE_LOCK))) 346 + return -EACCES; 347 + if (vnode->status.lock_count == -1 && !can_sleep) 348 + return -EAGAIN; /* Write locked */ 349 + } else { 350 + if (!(access & (AFS_ACE_INSERT | AFS_ACE_WRITE))) 351 + return -EACCES; 352 + if (vnode->status.lock_count != 0 && !can_sleep) 353 + return -EAGAIN; /* Locked */ 354 + } 355 + 356 + return 0; 357 + } 358 + 359 + /* 360 + * Remove the front runner from the pending queue. 361 + * - The caller must hold vnode->lock. 362 + */ 363 + static void afs_dequeue_lock(struct afs_vnode *vnode, struct file_lock *fl) 364 + { 365 + struct file_lock *next; 366 + 367 + _enter(""); 368 + 369 + /* ->lock_type, ->lock_key and ->lock_state only belong to this 370 + * file_lock if we're at the front of the pending queue or if we have 371 + * the lock granted or if the lock_state is NEED_UNLOCK or UNLOCKING. 372 + */ 373 + if (vnode->granted_locks.next == &fl->fl_u.afs.link && 374 + vnode->granted_locks.prev == &fl->fl_u.afs.link) { 375 + list_del_init(&fl->fl_u.afs.link); 376 + afs_defer_unlock(vnode); 377 + return; 378 + } 379 + 380 + if (!list_empty(&vnode->granted_locks) || 381 + vnode->pending_locks.next != &fl->fl_u.afs.link) { 382 + list_del_init(&fl->fl_u.afs.link); 383 + return; 384 + } 385 + 386 + list_del_init(&fl->fl_u.afs.link); 387 + key_put(vnode->lock_key); 388 + vnode->lock_key = NULL; 389 + vnode->lock_state = AFS_VNODE_LOCK_NONE; 390 + 391 + if (list_empty(&vnode->pending_locks)) 392 + return; 393 + 394 + /* The new front of the queue now owns the state variables. */ 395 + next = list_entry(vnode->pending_locks.next, 396 + struct file_lock, fl_u.afs.link); 397 + vnode->lock_key = afs_file_key(next->fl_file); 398 + vnode->lock_type = (next->fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE; 399 + vnode->lock_state = AFS_VNODE_LOCK_WAITING_FOR_CB; 400 afs_lock_may_be_available(vnode); 401 } 402 ··· 315 */ 316 static int afs_do_setlk(struct file *file, struct file_lock *fl) 317 { 318 + struct inode *inode = locks_inode(file); 319 struct afs_vnode *vnode = AFS_FS_I(inode); 320 afs_lock_type_t type; 321 struct key *key = afs_file_key(file); ··· 333 334 type = (fl->fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE; 335 336 + ret = afs_do_setlk_check(vnode, key, type, fl->fl_flags & FL_SLEEP); 337 if (ret < 0) 338 + return ret; 339 340 spin_lock(&vnode->lock); 341 342 + /* If we've already got a readlock on the server then we instantly 343 * grant another readlock, irrespective of whether there are any 344 + * pending writelocks. 345 + */ 346 if (type == AFS_LOCK_READ && 347 + vnode->lock_state == AFS_VNODE_LOCK_GRANTED && 348 + vnode->lock_type == AFS_LOCK_READ) { 349 _debug("instant readlock"); 350 ASSERT(!list_empty(&vnode->granted_locks)); 351 + goto share_existing_lock; 352 } 353 354 list_add_tail(&fl->fl_u.afs.link, &vnode->pending_locks); 355 + 356 + if (vnode->lock_state != AFS_VNODE_LOCK_NONE) 357 + goto need_to_wait; 358 + 359 + /* We don't have a lock on this vnode and we aren't currently waiting 360 + * for one either, so ask the server for a lock. 361 + * 362 + * Note that we need to be careful if we get interrupted by a signal 363 + * after dispatching the request as we may still get the lock, even 364 + * though we don't wait for the reply (it's not too bad a problem - the 365 + * lock will expire in 10 mins anyway). 366 + */ 367 + _debug("not locked"); 368 + vnode->lock_key = key_get(key); 369 + vnode->lock_type = type; 370 + vnode->lock_state = AFS_VNODE_LOCK_SETTING; 371 spin_unlock(&vnode->lock); 372 373 + ret = afs_set_lock(vnode, key, type); /* RPC */ 374 375 spin_lock(&vnode->lock); 376 + switch (ret) { 377 + default: 378 + goto abort_attempt; 379 + 380 + case -EWOULDBLOCK: 381 + /* The server doesn't have a lock-waiting queue, so the client 382 + * will have to retry. The server will break the outstanding 383 + * callbacks on a file when a lock is released. 384 + */ 385 + _debug("would block"); 386 + ASSERT(list_empty(&vnode->granted_locks)); 387 + ASSERTCMP(vnode->pending_locks.next, ==, &fl->fl_u.afs.link); 388 + vnode->lock_state = AFS_VNODE_LOCK_WAITING_FOR_CB; 389 + goto need_to_wait; 390 + 391 + case 0: 392 + _debug("acquired"); 393 + break; 394 } 395 + 396 + /* we've acquired a server lock, but it needs to be renewed after 5 397 + * mins */ 398 + vnode->lock_state = AFS_VNODE_LOCK_GRANTED; 399 + afs_schedule_lock_extension(vnode); 400 + 401 + share_existing_lock: 402 + /* the lock has been granted as far as we're concerned... */ 403 + fl->fl_u.afs.state = AFS_LOCK_GRANTED; 404 + list_move_tail(&fl->fl_u.afs.link, &vnode->granted_locks); 405 + 406 + given_lock: 407 + /* ... but we do still need to get the VFS's blessing */ 408 + spin_unlock(&vnode->lock); 409 + 410 + ret = posix_lock_file(file, fl, NULL); 411 + if (ret < 0) 412 + goto vfs_rejected_lock; 413 + 414 + /* Again, make sure we've got a callback on this file and, again, make 415 + * sure that our view of the data version is up to date (we ignore 416 + * errors incurred here and deal with the consequences elsewhere). 417 + */ 418 + afs_validate(vnode, key); 419 + _leave(" = 0"); 420 + return 0; 421 + 422 + need_to_wait: 423 + /* We're going to have to wait. Either this client doesn't have a lock 424 + * on the server yet and we need to wait for a callback to occur, or 425 + * the client does have a lock on the server, but it belongs to some 426 + * other process(es) and is incompatible with the lock we want. 427 + */ 428 + ret = -EAGAIN; 429 + if (fl->fl_flags & FL_SLEEP) { 430 + spin_unlock(&vnode->lock); 431 + 432 + _debug("sleep"); 433 + ret = wait_event_interruptible(fl->fl_wait, 434 + fl->fl_u.afs.state != AFS_LOCK_PENDING); 435 + 436 + spin_lock(&vnode->lock); 437 + } 438 + 439 + if (fl->fl_u.afs.state == AFS_LOCK_GRANTED) 440 + goto given_lock; 441 + if (fl->fl_u.afs.state < 0) 442 + ret = fl->fl_u.afs.state; 443 444 abort_attempt: 445 /* we aren't going to get the lock, either because we're unwilling to 446 * wait, or because some signal happened */ 447 _debug("abort"); 448 + afs_dequeue_lock(vnode, fl); 449 + 450 + error_unlock: 451 spin_unlock(&vnode->lock); 452 _leave(" = %d", ret); 453 return ret; 454 455 vfs_rejected_lock: 456 + /* The VFS rejected the lock we just obtained, so we have to discard 457 + * what we just got. We defer this to the lock manager work item to 458 + * deal with. 459 + */ 460 _debug("vfs refused %d", ret); 461 + spin_lock(&vnode->lock); 462 list_del_init(&fl->fl_u.afs.link); 463 if (list_empty(&vnode->granted_locks)) 464 + afs_defer_unlock(vnode); 465 + goto error_unlock; 466 } 467 468 /* ··· 499 */ 500 static int afs_do_unlk(struct file *file, struct file_lock *fl) 501 { 502 + struct afs_vnode *vnode = AFS_FS_I(locks_inode(file)); 503 int ret; 504 505 _enter("{%x:%u},%u", vnode->fid.vid, vnode->fid.vnode, fl->fl_type); 506 + 507 + /* Flush all pending writes before doing anything with locks. */ 508 + vfs_fsync(file, 0); 509 510 /* only whole-file unlocks are supported */ 511 if (fl->fl_start != 0 || fl->fl_end != OFFSET_MAX) 512 return -EINVAL; 513 514 ret = posix_lock_file(file, fl, NULL); 515 + _leave(" = %d [%u]", ret, vnode->lock_state); 516 + return ret; 517 } 518 519 /* ··· 534 */ 535 static int afs_do_getlk(struct file *file, struct file_lock *fl) 536 { 537 + struct afs_vnode *vnode = AFS_FS_I(locks_inode(file)); 538 struct key *key = afs_file_key(file); 539 int ret, lock_count; 540 ··· 542 543 fl->fl_type = F_UNLCK; 544 545 /* check local lock records first */ 546 posix_test_lock(file, fl); 547 if (fl->fl_type == F_UNLCK) { 548 /* no local locks; consult the server */ 549 ret = afs_fetch_status(vnode, key); 550 if (ret < 0) 551 goto error; 552 + 553 + lock_count = READ_ONCE(vnode->status.lock_count); 554 + if (lock_count > 0) 555 + fl->fl_type = F_RDLCK; 556 + else 557 + fl->fl_type = F_WRLCK; 558 + fl->fl_start = 0; 559 + fl->fl_end = OFFSET_MAX; 560 } 561 562 + ret = 0; 563 error: 564 _leave(" = %d [%hd]", ret, fl->fl_type); 565 return ret; 566 } ··· 574 */ 575 int afs_lock(struct file *file, int cmd, struct file_lock *fl) 576 { 577 + struct afs_vnode *vnode = AFS_FS_I(locks_inode(file)); 578 579 _enter("{%x:%u},%d,{t=%x,fl=%x,r=%Ld:%Ld}", 580 vnode->fid.vid, vnode->fid.vnode, cmd, ··· 597 */ 598 int afs_flock(struct file *file, int cmd, struct file_lock *fl) 599 { 600 + struct afs_vnode *vnode = AFS_FS_I(locks_inode(file)); 601 602 _enter("{%x:%u},%d,{t=%x,fl=%x}", 603 vnode->fid.vid, vnode->fid.vnode, cmd, ··· 627 */ 628 static void afs_fl_copy_lock(struct file_lock *new, struct file_lock *fl) 629 { 630 + struct afs_vnode *vnode = AFS_FS_I(locks_inode(fl->fl_file)); 631 + 632 _enter(""); 633 634 + spin_lock(&vnode->lock); 635 list_add(&new->fl_u.afs.link, &fl->fl_u.afs.link); 636 + spin_unlock(&vnode->lock); 637 } 638 639 /* ··· 638 */ 639 static void afs_fl_release_private(struct file_lock *fl) 640 { 641 + struct afs_vnode *vnode = AFS_FS_I(locks_inode(fl->fl_file)); 642 + 643 _enter(""); 644 645 + spin_lock(&vnode->lock); 646 + afs_dequeue_lock(vnode, fl); 647 + _debug("state %u for %p", vnode->lock_state, vnode); 648 + spin_unlock(&vnode->lock); 649 }
+16 -7
fs/afs/internal.h
··· 430 u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */ 431 }; 432 433 /* 434 * AFS inode private data 435 */ ··· 464 #define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */ 465 #define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */ 466 #define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */ 467 - #define AFS_VNODE_LOCKING 6 /* set if waiting for lock on vnode */ 468 - #define AFS_VNODE_READLOCKED 7 /* set if vnode is read-locked on the server */ 469 - #define AFS_VNODE_WRITELOCKED 8 /* set if vnode is write-locked on the server */ 470 - #define AFS_VNODE_UNLOCKING 9 /* set if vnode is being unlocked on the server */ 471 - #define AFS_VNODE_AUTOCELL 10 /* set if Vnode is an auto mount point */ 472 - #define AFS_VNODE_PSEUDODIR 11 /* set if Vnode is a pseudo directory */ 473 474 struct list_head wb_keys; /* List of keys available for writeback */ 475 struct list_head pending_locks; /* locks waiting to be granted */ 476 struct list_head granted_locks; /* locks granted on this file */ 477 struct delayed_work lock_work; /* work to be done in locking */ 478 - struct key *unlock_key; /* key to be used in unlocking */ 479 480 /* outstanding callback notification on this file */ 481 struct afs_cb_interest *cb_interest; /* Server on which this resides */ ··· 851 extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int); 852 extern void afs_zap_permits(struct rcu_head *); 853 extern struct key *afs_request_key(struct afs_cell *); 854 extern int afs_permission(struct inode *, int); 855 extern void __exit afs_clean_up_permit_cache(void); 856
··· 430 u8 name[AFS_MAXVOLNAME + 1]; /* NUL-padded volume name */ 431 }; 432 433 + enum afs_lock_state { 434 + AFS_VNODE_LOCK_NONE, /* The vnode has no lock on the server */ 435 + AFS_VNODE_LOCK_WAITING_FOR_CB, /* We're waiting for the server to break the callback */ 436 + AFS_VNODE_LOCK_SETTING, /* We're asking the server for a lock */ 437 + AFS_VNODE_LOCK_GRANTED, /* We have a lock on the server */ 438 + AFS_VNODE_LOCK_EXTENDING, /* We're extending a lock on the server */ 439 + AFS_VNODE_LOCK_NEED_UNLOCK, /* We need to unlock on the server */ 440 + AFS_VNODE_LOCK_UNLOCKING, /* We're telling the server to unlock */ 441 + }; 442 + 443 /* 444 * AFS inode private data 445 */ ··· 454 #define AFS_VNODE_ZAP_DATA 3 /* set if vnode's data should be invalidated */ 455 #define AFS_VNODE_DELETED 4 /* set if vnode deleted on server */ 456 #define AFS_VNODE_MOUNTPOINT 5 /* set if vnode is a mountpoint symlink */ 457 + #define AFS_VNODE_AUTOCELL 6 /* set if Vnode is an auto mount point */ 458 + #define AFS_VNODE_PSEUDODIR 7 /* set if Vnode is a pseudo directory */ 459 460 struct list_head wb_keys; /* List of keys available for writeback */ 461 struct list_head pending_locks; /* locks waiting to be granted */ 462 struct list_head granted_locks; /* locks granted on this file */ 463 struct delayed_work lock_work; /* work to be done in locking */ 464 + struct key *lock_key; /* Key to be used in lock ops */ 465 + enum afs_lock_state lock_state : 8; 466 + afs_lock_type_t lock_type : 8; 467 468 /* outstanding callback notification on this file */ 469 struct afs_cb_interest *cb_interest; /* Server on which this resides */ ··· 843 extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int); 844 extern void afs_zap_permits(struct rcu_head *); 845 extern struct key *afs_request_key(struct afs_cell *); 846 + extern int afs_check_permit(struct afs_vnode *, struct key *, afs_access_t *); 847 extern int afs_permission(struct inode *, int); 848 extern void __exit afs_clean_up_permit_cache(void); 849
+57 -15
fs/afs/rotate.c
··· 46 return false; 47 } 48 49 - if (test_bit(AFS_VNODE_READLOCKED, &vnode->flags) || 50 - test_bit(AFS_VNODE_WRITELOCKED, &vnode->flags)) 51 fc->flags |= AFS_FS_CURSOR_CUR_ONLY; 52 return true; 53 } ··· 116 case VSALVAGING: m = "being salvaged"; break; 117 default: m = "busy"; break; 118 } 119 - 120 pr_notice("kAFS: Volume %u '%s' is %s\n", volume->vid, volume->name, m); 121 } 122 ··· 437 438 _enter(""); 439 440 - if (!cbi) { 441 - fc->ac.error = -ESTALE; 442 fc->flags |= AFS_FS_CURSOR_STOP; 443 return false; 444 } 445 446 - read_lock(&cbi->server->fs_lock); 447 - alist = afs_get_addrlist(cbi->server->addresses); 448 - read_unlock(&cbi->server->fs_lock); 449 - if (!alist) { 450 - fc->ac.error = -ESTALE; 451 - fc->flags |= AFS_FS_CURSOR_STOP; 452 - return false; 453 } 454 455 - fc->ac.alist = alist; 456 - fc->ac.error = 0; 457 - return true; 458 } 459 460 /*
··· 46 return false; 47 } 48 49 + if (vnode->lock_state != AFS_VNODE_LOCK_NONE) 50 fc->flags |= AFS_FS_CURSOR_CUR_ONLY; 51 return true; 52 } ··· 117 case VSALVAGING: m = "being salvaged"; break; 118 default: m = "busy"; break; 119 } 120 + 121 pr_notice("kAFS: Volume %u '%s' is %s\n", volume->vid, volume->name, m); 122 } 123 ··· 438 439 _enter(""); 440 441 + switch (fc->ac.error) { 442 + case SHRT_MAX: 443 + if (!cbi) { 444 + fc->ac.error = -ESTALE; 445 + fc->flags |= AFS_FS_CURSOR_STOP; 446 + return false; 447 + } 448 + 449 + fc->cbi = afs_get_cb_interest(vnode->cb_interest); 450 + 451 + read_lock(&cbi->server->fs_lock); 452 + alist = rcu_dereference_protected(cbi->server->addresses, 453 + lockdep_is_held(&cbi->server->fs_lock)); 454 + afs_get_addrlist(alist); 455 + read_unlock(&cbi->server->fs_lock); 456 + if (!alist) { 457 + fc->ac.error = -ESTALE; 458 + fc->flags |= AFS_FS_CURSOR_STOP; 459 + return false; 460 + } 461 + 462 + fc->ac.alist = alist; 463 + fc->ac.addr = NULL; 464 + fc->ac.start = READ_ONCE(alist->index); 465 + fc->ac.index = fc->ac.start; 466 + fc->ac.error = 0; 467 + fc->ac.begun = false; 468 + goto iterate_address; 469 + 470 + case 0: 471 + default: 472 + /* Success or local failure. Stop. */ 473 fc->flags |= AFS_FS_CURSOR_STOP; 474 + _leave(" = f [okay/local %d]", fc->ac.error); 475 return false; 476 + 477 + case -ECONNABORTED: 478 + fc->flags |= AFS_FS_CURSOR_STOP; 479 + _leave(" = f [abort]"); 480 + return false; 481 + 482 + case -ENETUNREACH: 483 + case -EHOSTUNREACH: 484 + case -ECONNREFUSED: 485 + case -ETIMEDOUT: 486 + case -ETIME: 487 + _debug("no conn"); 488 + goto iterate_address; 489 } 490 491 + iterate_address: 492 + /* Iterate over the current server's address list to try and find an 493 + * address on which it will respond to us. 494 + */ 495 + if (afs_iterate_addresses(&fc->ac)) { 496 + _leave(" = t"); 497 + return true; 498 } 499 500 + afs_end_cursor(&fc->ac); 501 + return false; 502 } 503 504 /*
+2 -2
fs/afs/security.c
··· 284 * permitted to be accessed with this authorisation, and if so, what access it 285 * is granted 286 */ 287 - static int afs_check_permit(struct afs_vnode *vnode, struct key *key, 288 - afs_access_t *_access) 289 { 290 struct afs_permits *permits; 291 bool valid = false;
··· 284 * permitted to be accessed with this authorisation, and if so, what access it 285 * is granted 286 */ 287 + int afs_check_permit(struct afs_vnode *vnode, struct key *key, 288 + afs_access_t *_access) 289 { 290 struct afs_permits *permits; 291 bool valid = false;
+1 -1
fs/afs/server_list.c
··· 17 { 18 int i; 19 20 - if (refcount_dec_and_test(&slist->usage)) { 21 for (i = 0; i < slist->nr_servers; i++) { 22 afs_put_cb_interest(net, slist->servers[i].cb_interest); 23 afs_put_server(net, slist->servers[i].server);
··· 17 { 18 int i; 19 20 + if (slist && refcount_dec_and_test(&slist->usage)) { 21 for (i = 0; i < slist->nr_servers; i++) { 22 afs_put_cb_interest(net, slist->servers[i].cb_interest); 23 afs_put_server(net, slist->servers[i].server);
+5
fs/afs/write.c
··· 119 } 120 121 if (f != t) { 122 if (to < f || from > t) 123 goto flush_conflicting_write; 124 if (from < f)
··· 119 } 120 121 if (f != t) { 122 + if (PageWriteback(page)) { 123 + trace_afs_page_dirty(vnode, tracepoint_string("alrdy"), 124 + page->index, priv); 125 + goto flush_conflicting_write; 126 + } 127 if (to < f || from > t) 128 goto flush_conflicting_write; 129 if (from < f)