diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-16 17:49:49 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-16 17:49:49 -0400 |
| commit | 8df1b049bc86495a40e421abc8b9cf1dda32f0d9 (patch) | |
| tree | ed0d7f582b401852a9ea98f572076131950a15c4 /fs/nfs/inode.c | |
| parent | a3cf859321486f69506326146ab3e2fd15c05c3f (diff) | |
| parent | cadc723cc19ce6b881d973d3c04e25ebb83058e6 (diff) | |
Merge git://git.linux-nfs.org/projects/trondmy/nfs-2.6
* git://git.linux-nfs.org/projects/trondmy/nfs-2.6: (82 commits)
NFSv4: Remove BKL from the nfsv4 state recovery
SUNRPC: Remove the BKL from the callback functions
NFS: Remove BKL from the readdir code
NFS: Remove BKL from the symlink code
NFS: Remove BKL from the sillydelete operations
NFS: Remove the BKL from the rename, rmdir and unlink operations
NFS: Remove BKL from NFS lookup code
NFS: Remove the BKL from nfs_link()
NFS: Remove the BKL from the inode creation operations
NFS: Remove BKL usage from open()
NFS: Remove BKL usage from the write path
NFS: Remove the BKL from the permission checking code
NFS: Remove attribute update related BKL references
NFS: Remove BKL requirement from attribute updates
NFS: Protect inode->i_nlink updates using inode->i_lock
nfs: set correct fl_len in nlmclnt_test()
SUNRPC: Support registering IPv6 interfaces with local rpcbind daemon
SUNRPC: Refactor rpcb_register to make rpcbindv4 support easier
SUNRPC: None of rpcb_create's callers wants a privileged source port
SUNRPC: Introduce a specific rpcb_create for contacting localhost
...
Diffstat (limited to 'fs/nfs/inode.c')
| -rw-r--r-- | fs/nfs/inode.c | 79 |
1 files changed, 64 insertions, 15 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 596c5d8e86f4..df23f987da6b 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
| @@ -57,8 +57,6 @@ static int enable_ino64 = NFS_64_BIT_INODE_NUMBERS_ENABLED; | |||
| 57 | static void nfs_invalidate_inode(struct inode *); | 57 | static void nfs_invalidate_inode(struct inode *); |
| 58 | static int nfs_update_inode(struct inode *, struct nfs_fattr *); | 58 | static int nfs_update_inode(struct inode *, struct nfs_fattr *); |
| 59 | 59 | ||
| 60 | static void nfs_zap_acl_cache(struct inode *); | ||
| 61 | |||
| 62 | static struct kmem_cache * nfs_inode_cachep; | 60 | static struct kmem_cache * nfs_inode_cachep; |
| 63 | 61 | ||
| 64 | static inline unsigned long | 62 | static inline unsigned long |
| @@ -167,7 +165,7 @@ void nfs_zap_mapping(struct inode *inode, struct address_space *mapping) | |||
| 167 | } | 165 | } |
| 168 | } | 166 | } |
| 169 | 167 | ||
| 170 | static void nfs_zap_acl_cache(struct inode *inode) | 168 | void nfs_zap_acl_cache(struct inode *inode) |
| 171 | { | 169 | { |
| 172 | void (*clear_acl_cache)(struct inode *); | 170 | void (*clear_acl_cache)(struct inode *); |
| 173 | 171 | ||
| @@ -347,7 +345,7 @@ out_no_inode: | |||
| 347 | goto out; | 345 | goto out; |
| 348 | } | 346 | } |
| 349 | 347 | ||
| 350 | #define NFS_VALID_ATTRS (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_ATIME|ATTR_ATIME_SET|ATTR_MTIME|ATTR_MTIME_SET) | 348 | #define NFS_VALID_ATTRS (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_ATIME|ATTR_ATIME_SET|ATTR_MTIME|ATTR_MTIME_SET|ATTR_FILE) |
| 351 | 349 | ||
| 352 | int | 350 | int |
| 353 | nfs_setattr(struct dentry *dentry, struct iattr *attr) | 351 | nfs_setattr(struct dentry *dentry, struct iattr *attr) |
| @@ -369,10 +367,9 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
| 369 | 367 | ||
| 370 | /* Optimization: if the end result is no change, don't RPC */ | 368 | /* Optimization: if the end result is no change, don't RPC */ |
| 371 | attr->ia_valid &= NFS_VALID_ATTRS; | 369 | attr->ia_valid &= NFS_VALID_ATTRS; |
| 372 | if (attr->ia_valid == 0) | 370 | if ((attr->ia_valid & ~ATTR_FILE) == 0) |
| 373 | return 0; | 371 | return 0; |
| 374 | 372 | ||
| 375 | lock_kernel(); | ||
| 376 | /* Write all dirty data */ | 373 | /* Write all dirty data */ |
| 377 | if (S_ISREG(inode->i_mode)) { | 374 | if (S_ISREG(inode->i_mode)) { |
| 378 | filemap_write_and_wait(inode->i_mapping); | 375 | filemap_write_and_wait(inode->i_mapping); |
| @@ -386,11 +383,66 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
| 386 | error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr); | 383 | error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr); |
| 387 | if (error == 0) | 384 | if (error == 0) |
| 388 | nfs_refresh_inode(inode, &fattr); | 385 | nfs_refresh_inode(inode, &fattr); |
| 389 | unlock_kernel(); | ||
| 390 | return error; | 386 | return error; |
| 391 | } | 387 | } |
| 392 | 388 | ||
| 393 | /** | 389 | /** |
| 390 | * nfs_vmtruncate - unmap mappings "freed" by truncate() syscall | ||
| 391 | * @inode: inode of the file used | ||
| 392 | * @offset: file offset to start truncating | ||
| 393 | * | ||
| 394 | * This is a copy of the common vmtruncate, but with the locking | ||
| 395 | * corrected to take into account the fact that NFS requires | ||
| 396 | * inode->i_size to be updated under the inode->i_lock. | ||
| 397 | */ | ||
| 398 | static int nfs_vmtruncate(struct inode * inode, loff_t offset) | ||
| 399 | { | ||
| 400 | if (i_size_read(inode) < offset) { | ||
| 401 | unsigned long limit; | ||
| 402 | |||
| 403 | limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur; | ||
| 404 | if (limit != RLIM_INFINITY && offset > limit) | ||
| 405 | goto out_sig; | ||
| 406 | if (offset > inode->i_sb->s_maxbytes) | ||
| 407 | goto out_big; | ||
| 408 | spin_lock(&inode->i_lock); | ||
| 409 | i_size_write(inode, offset); | ||
| 410 | spin_unlock(&inode->i_lock); | ||
| 411 | } else { | ||
| 412 | struct address_space *mapping = inode->i_mapping; | ||
| 413 | |||
| 414 | /* | ||
| 415 | * truncation of in-use swapfiles is disallowed - it would | ||
| 416 | * cause subsequent swapout to scribble on the now-freed | ||
| 417 | * blocks. | ||
| 418 | */ | ||
| 419 | if (IS_SWAPFILE(inode)) | ||
| 420 | return -ETXTBSY; | ||
| 421 | spin_lock(&inode->i_lock); | ||
| 422 | i_size_write(inode, offset); | ||
| 423 | spin_unlock(&inode->i_lock); | ||
| 424 | |||
| 425 | /* | ||
| 426 | * unmap_mapping_range is called twice, first simply for | ||
| 427 | * efficiency so that truncate_inode_pages does fewer | ||
| 428 | * single-page unmaps. However after this first call, and | ||
| 429 | * before truncate_inode_pages finishes, it is possible for | ||
| 430 | * private pages to be COWed, which remain after | ||
| 431 | * truncate_inode_pages finishes, hence the second | ||
| 432 | * unmap_mapping_range call must be made for correctness. | ||
| 433 | */ | ||
| 434 | unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1); | ||
| 435 | truncate_inode_pages(mapping, offset); | ||
| 436 | unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1); | ||
| 437 | } | ||
| 438 | return 0; | ||
| 439 | out_sig: | ||
| 440 | send_sig(SIGXFSZ, current, 0); | ||
| 441 | out_big: | ||
| 442 | return -EFBIG; | ||
| 443 | } | ||
| 444 | |||
| 445 | /** | ||
| 394 | * nfs_setattr_update_inode - Update inode metadata after a setattr call. | 446 | * nfs_setattr_update_inode - Update inode metadata after a setattr call. |
| 395 | * @inode: pointer to struct inode | 447 | * @inode: pointer to struct inode |
| 396 | * @attr: pointer to struct iattr | 448 | * @attr: pointer to struct iattr |
| @@ -416,8 +468,7 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr) | |||
| 416 | } | 468 | } |
| 417 | if ((attr->ia_valid & ATTR_SIZE) != 0) { | 469 | if ((attr->ia_valid & ATTR_SIZE) != 0) { |
| 418 | nfs_inc_stats(inode, NFSIOS_SETATTRTRUNC); | 470 | nfs_inc_stats(inode, NFSIOS_SETATTRTRUNC); |
| 419 | inode->i_size = attr->ia_size; | 471 | nfs_vmtruncate(inode, attr->ia_size); |
| 420 | vmtruncate(inode, attr->ia_size); | ||
| 421 | } | 472 | } |
| 422 | } | 473 | } |
| 423 | 474 | ||
| @@ -647,7 +698,6 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
| 647 | inode->i_sb->s_id, (long long)NFS_FILEID(inode)); | 698 | inode->i_sb->s_id, (long long)NFS_FILEID(inode)); |
| 648 | 699 | ||
| 649 | nfs_inc_stats(inode, NFSIOS_INODEREVALIDATE); | 700 | nfs_inc_stats(inode, NFSIOS_INODEREVALIDATE); |
| 650 | lock_kernel(); | ||
| 651 | if (is_bad_inode(inode)) | 701 | if (is_bad_inode(inode)) |
| 652 | goto out_nowait; | 702 | goto out_nowait; |
| 653 | if (NFS_STALE(inode)) | 703 | if (NFS_STALE(inode)) |
| @@ -696,7 +746,6 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
| 696 | nfs_wake_up_inode(inode); | 746 | nfs_wake_up_inode(inode); |
| 697 | 747 | ||
| 698 | out_nowait: | 748 | out_nowait: |
| 699 | unlock_kernel(); | ||
| 700 | return status; | 749 | return status; |
| 701 | } | 750 | } |
| 702 | 751 | ||
| @@ -831,9 +880,9 @@ static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
| 831 | if (S_ISDIR(inode->i_mode)) | 880 | if (S_ISDIR(inode->i_mode)) |
| 832 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; | 881 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; |
| 833 | } | 882 | } |
| 834 | if (inode->i_size == nfs_size_to_loff_t(fattr->pre_size) && | 883 | if (i_size_read(inode) == nfs_size_to_loff_t(fattr->pre_size) && |
| 835 | nfsi->npages == 0) | 884 | nfsi->npages == 0) |
| 836 | inode->i_size = nfs_size_to_loff_t(fattr->size); | 885 | i_size_write(inode, nfs_size_to_loff_t(fattr->size)); |
| 837 | } | 886 | } |
| 838 | } | 887 | } |
| 839 | 888 | ||
| @@ -974,7 +1023,7 @@ int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fa | |||
| 974 | (fattr->valid & NFS_ATTR_WCC) == 0) { | 1023 | (fattr->valid & NFS_ATTR_WCC) == 0) { |
| 975 | memcpy(&fattr->pre_ctime, &inode->i_ctime, sizeof(fattr->pre_ctime)); | 1024 | memcpy(&fattr->pre_ctime, &inode->i_ctime, sizeof(fattr->pre_ctime)); |
| 976 | memcpy(&fattr->pre_mtime, &inode->i_mtime, sizeof(fattr->pre_mtime)); | 1025 | memcpy(&fattr->pre_mtime, &inode->i_mtime, sizeof(fattr->pre_mtime)); |
| 977 | fattr->pre_size = inode->i_size; | 1026 | fattr->pre_size = i_size_read(inode); |
| 978 | fattr->valid |= NFS_ATTR_WCC; | 1027 | fattr->valid |= NFS_ATTR_WCC; |
| 979 | } | 1028 | } |
| 980 | return nfs_post_op_update_inode(inode, fattr); | 1029 | return nfs_post_op_update_inode(inode, fattr); |
| @@ -1059,7 +1108,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
| 1059 | /* Do we perhaps have any outstanding writes, or has | 1108 | /* Do we perhaps have any outstanding writes, or has |
| 1060 | * the file grown beyond our last write? */ | 1109 | * the file grown beyond our last write? */ |
| 1061 | if (nfsi->npages == 0 || new_isize > cur_isize) { | 1110 | if (nfsi->npages == 0 || new_isize > cur_isize) { |
| 1062 | inode->i_size = new_isize; | 1111 | i_size_write(inode, new_isize); |
| 1063 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA; | 1112 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA; |
| 1064 | } | 1113 | } |
| 1065 | dprintk("NFS: isize change on server for file %s/%ld\n", | 1114 | dprintk("NFS: isize change on server for file %s/%ld\n", |
