inode.c (f81483aaeb59da530b286fe5d081e1705eb5c886) | inode.c (523d27cda149cfc8c99159c0f68f690e4d3b9d14) |
---|---|
1/* 2 * Copyright (c) 2002 Red Hat, Inc. All rights reserved. 3 * 4 * This software may be freely redistributed under the terms of the 5 * GNU General Public License. 6 * 7 * You should have received a copy of the GNU General Public License 8 * along with this program; if not, write to the Free Software --- 399 unchanged lines hidden (view full) --- 408 409/* 410 * Get a cache cookie for an inode. 411 */ 412static void afs_get_inode_cache(struct afs_vnode *vnode) 413{ 414#ifdef CONFIG_AFS_FSCACHE 415 struct { | 1/* 2 * Copyright (c) 2002 Red Hat, Inc. All rights reserved. 3 * 4 * This software may be freely redistributed under the terms of the 5 * GNU General Public License. 6 * 7 * You should have received a copy of the GNU General Public License 8 * along with this program; if not, write to the Free Software --- 399 unchanged lines hidden (view full) --- 408 409/* 410 * Get a cache cookie for an inode. 411 */ 412static void afs_get_inode_cache(struct afs_vnode *vnode) 413{ 414#ifdef CONFIG_AFS_FSCACHE 415 struct { |
416 u32 vnode_id; 417 u32 unique; 418 u32 vnode_id_ext[2]; /* Allow for a 96-bit key */ | 416 __be32 vnode_id; 417 __be32 unique; 418 __be32 vnode_id_ext[2]; /* Allow for a 96-bit key */ |
419 } __packed key; 420 struct afs_vnode_cache_aux aux; 421 422 if (vnode->status.type != AFS_FTYPE_FILE) { 423 vnode->cache = NULL; 424 return; 425 } 426 | 419 } __packed key; 420 struct afs_vnode_cache_aux aux; 421 422 if (vnode->status.type != AFS_FTYPE_FILE) { 423 vnode->cache = NULL; 424 return; 425 } 426 |
427 key.vnode_id = vnode->fid.vnode; 428 key.unique = vnode->fid.unique; 429 key.vnode_id_ext[0] = vnode->fid.vnode >> 32; 430 key.vnode_id_ext[1] = vnode->fid.vnode_hi; 431 aux.data_version = vnode->status.data_version; | 427 key.vnode_id = htonl(vnode->fid.vnode); 428 key.unique = htonl(vnode->fid.unique); 429 key.vnode_id_ext[0] = htonl(vnode->fid.vnode >> 32); 430 key.vnode_id_ext[1] = htonl(vnode->fid.vnode_hi); 431 afs_set_cache_aux(vnode, &aux); |
432 | 432 |
433 vnode->cache = fscache_acquire_cookie(vnode->volume->cache, 434 &afs_vnode_cache_index_def, 435 &key, sizeof(key), 436 &aux, sizeof(aux), 437 vnode, vnode->status.size, true); | 433 vnode->cache = fscache_acquire_cookie( 434 vnode->volume->cache, 435 vnode->status.type == AFS_FTYPE_FILE ? 0 : FSCACHE_ADV_SINGLE_CHUNK, 436 &key, sizeof(key), 437 &aux, sizeof(aux), 438 vnode->status.size); |
438#endif 439} 440 441/* 442 * inode retrieval 443 */ 444struct inode *afs_iget(struct afs_operation *op, struct afs_vnode_param *vp) 445{ --- 112 unchanged lines hidden (view full) --- 558/* 559 * mark the data attached to an inode as obsolete due to a write on the server 560 * - might also want to ditch all the outstanding writes and dirty pages 561 */ 562static void afs_zap_data(struct afs_vnode *vnode) 563{ 564 _enter("{%llx:%llu}", vnode->fid.vid, vnode->fid.vnode); 565 | 439#endif 440} 441 442/* 443 * inode retrieval 444 */ 445struct inode *afs_iget(struct afs_operation *op, struct afs_vnode_param *vp) 446{ --- 112 unchanged lines hidden (view full) --- 559/* 560 * mark the data attached to an inode as obsolete due to a write on the server 561 * - might also want to ditch all the outstanding writes and dirty pages 562 */ 563static void afs_zap_data(struct afs_vnode *vnode) 564{ 565 _enter("{%llx:%llu}", vnode->fid.vid, vnode->fid.vnode); 566 |
566#ifdef CONFIG_AFS_FSCACHE 567 fscache_invalidate(vnode->cache); 568#endif | 567 afs_invalidate_cache(vnode, 0); |
569 570 /* nuke all the non-dirty pages that aren't locked, mapped or being 571 * written back in a regular file and completely discard the pages in a 572 * directory or symlink */ 573 if (S_ISREG(vnode->vfs_inode.i_mode)) 574 invalidate_remote_inode(&vnode->vfs_inode); 575 else 576 invalidate_inode_pages2(vnode->vfs_inode.i_mapping); --- 204 unchanged lines hidden (view full) --- 781 while (!list_empty(&vnode->wb_keys)) { 782 struct afs_wb_key *wbk = list_entry(vnode->wb_keys.next, 783 struct afs_wb_key, vnode_link); 784 list_del(&wbk->vnode_link); 785 afs_put_wb_key(wbk); 786 } 787 788#ifdef CONFIG_AFS_FSCACHE | 568 569 /* nuke all the non-dirty pages that aren't locked, mapped or being 570 * written back in a regular file and completely discard the pages in a 571 * directory or symlink */ 572 if (S_ISREG(vnode->vfs_inode.i_mode)) 573 invalidate_remote_inode(&vnode->vfs_inode); 574 else 575 invalidate_inode_pages2(vnode->vfs_inode.i_mapping); --- 204 unchanged lines hidden (view full) --- 780 while (!list_empty(&vnode->wb_keys)) { 781 struct afs_wb_key *wbk = list_entry(vnode->wb_keys.next, 782 struct afs_wb_key, vnode_link); 783 list_del(&wbk->vnode_link); 784 afs_put_wb_key(wbk); 785 } 786 787#ifdef CONFIG_AFS_FSCACHE |
789 { 790 struct afs_vnode_cache_aux aux; 791 792 aux.data_version = vnode->status.data_version; 793 fscache_relinquish_cookie(vnode->cache, &aux, 794 test_bit(AFS_VNODE_DELETED, &vnode->flags)); 795 vnode->cache = NULL; 796 } | 788 fscache_relinquish_cookie(vnode->cache, 789 test_bit(AFS_VNODE_DELETED, &vnode->flags)); 790 vnode->cache = NULL; |
797#endif 798 799 afs_prune_wb_keys(vnode); 800 afs_put_permits(rcu_access_pointer(vnode->permit_cache)); 801 key_put(vnode->silly_key); 802 vnode->silly_key = NULL; 803 key_put(vnode->lock_key); 804 vnode->lock_key = NULL; --- 23 unchanged lines hidden (view full) --- 828 struct inode *inode = &vp->vnode->vfs_inode; 829 830 if (op->setattr.attr->ia_valid & ATTR_SIZE) { 831 loff_t size = op->setattr.attr->ia_size; 832 loff_t i_size = op->setattr.old_i_size; 833 834 if (size < i_size) 835 truncate_pagecache(inode, size); | 791#endif 792 793 afs_prune_wb_keys(vnode); 794 afs_put_permits(rcu_access_pointer(vnode->permit_cache)); 795 key_put(vnode->silly_key); 796 vnode->silly_key = NULL; 797 key_put(vnode->lock_key); 798 vnode->lock_key = NULL; --- 23 unchanged lines hidden (view full) --- 822 struct inode *inode = &vp->vnode->vfs_inode; 823 824 if (op->setattr.attr->ia_valid & ATTR_SIZE) { 825 loff_t size = op->setattr.attr->ia_size; 826 loff_t i_size = op->setattr.old_i_size; 827 828 if (size < i_size) 829 truncate_pagecache(inode, size); |
830 if (size != i_size) 831 fscache_resize_cookie(afs_vnode_cache(vp->vnode), 832 vp->scb.status.size); |
|
836 } 837} 838 839static const struct afs_operation_ops afs_setattr_operation = { 840 .issue_afs_rpc = afs_fs_setattr, 841 .issue_yfs_rpc = yfs_fs_setattr, 842 .success = afs_setattr_success, 843 .edit_dir = afs_setattr_edit_file, --- 27 unchanged lines hidden (view full) --- 871 ret = inode_newsize_ok(&vnode->vfs_inode, attr->ia_size); 872 if (ret) 873 return ret; 874 875 if (attr->ia_size == i_size_read(&vnode->vfs_inode)) 876 attr->ia_valid &= ~ATTR_SIZE; 877 } 878 | 833 } 834} 835 836static const struct afs_operation_ops afs_setattr_operation = { 837 .issue_afs_rpc = afs_fs_setattr, 838 .issue_yfs_rpc = yfs_fs_setattr, 839 .success = afs_setattr_success, 840 .edit_dir = afs_setattr_edit_file, --- 27 unchanged lines hidden (view full) --- 868 ret = inode_newsize_ok(&vnode->vfs_inode, attr->ia_size); 869 if (ret) 870 return ret; 871 872 if (attr->ia_size == i_size_read(&vnode->vfs_inode)) 873 attr->ia_valid &= ~ATTR_SIZE; 874 } 875 |
876 fscache_use_cookie(afs_vnode_cache(vnode), true); 877 |
|
879 /* flush any dirty data outstanding on a regular file */ 880 if (S_ISREG(vnode->vfs_inode.i_mode)) 881 filemap_write_and_wait(vnode->vfs_inode.i_mapping); 882 883 /* Prevent any new writebacks from starting whilst we do this. */ 884 down_write(&vnode->validate_lock); 885 886 op = afs_alloc_operation(((attr->ia_valid & ATTR_FILE) ? --- 15 unchanged lines hidden (view full) --- 902 op->file[0].update_ctime = 1; 903 op->file[0].modification = true; 904 905 op->ops = &afs_setattr_operation; 906 ret = afs_do_sync_operation(op); 907 908out_unlock: 909 up_write(&vnode->validate_lock); | 878 /* flush any dirty data outstanding on a regular file */ 879 if (S_ISREG(vnode->vfs_inode.i_mode)) 880 filemap_write_and_wait(vnode->vfs_inode.i_mapping); 881 882 /* Prevent any new writebacks from starting whilst we do this. */ 883 down_write(&vnode->validate_lock); 884 885 op = afs_alloc_operation(((attr->ia_valid & ATTR_FILE) ? --- 15 unchanged lines hidden (view full) --- 901 op->file[0].update_ctime = 1; 902 op->file[0].modification = true; 903 904 op->ops = &afs_setattr_operation; 905 ret = afs_do_sync_operation(op); 906 907out_unlock: 908 up_write(&vnode->validate_lock); |
909 fscache_unuse_cookie(afs_vnode_cache(vnode), NULL, NULL); |
|
910 _leave(" = %d", ret); 911 return ret; 912} | 910 _leave(" = %d", ret); 911 return ret; 912} |