diff options
Diffstat (limited to 'fs/nfs/inode.c')
-rw-r--r-- | fs/nfs/inode.c | 58 |
1 files changed, 48 insertions, 10 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 50a56edca0b5..099b3518feea 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -393,8 +393,8 @@ int | |||
393 | nfs_setattr(struct dentry *dentry, struct iattr *attr) | 393 | nfs_setattr(struct dentry *dentry, struct iattr *attr) |
394 | { | 394 | { |
395 | struct inode *inode = dentry->d_inode; | 395 | struct inode *inode = dentry->d_inode; |
396 | struct nfs_fattr fattr; | 396 | struct nfs_fattr *fattr; |
397 | int error; | 397 | int error = -ENOMEM; |
398 | 398 | ||
399 | nfs_inc_stats(inode, NFSIOS_VFSSETATTR); | 399 | nfs_inc_stats(inode, NFSIOS_VFSSETATTR); |
400 | 400 | ||
@@ -417,14 +417,20 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
417 | filemap_write_and_wait(inode->i_mapping); | 417 | filemap_write_and_wait(inode->i_mapping); |
418 | nfs_wb_all(inode); | 418 | nfs_wb_all(inode); |
419 | } | 419 | } |
420 | |||
421 | fattr = nfs_alloc_fattr(); | ||
422 | if (fattr == NULL) | ||
423 | goto out; | ||
420 | /* | 424 | /* |
421 | * Return any delegations if we're going to change ACLs | 425 | * Return any delegations if we're going to change ACLs |
422 | */ | 426 | */ |
423 | if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0) | 427 | if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0) |
424 | nfs_inode_return_delegation(inode); | 428 | nfs_inode_return_delegation(inode); |
425 | error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr); | 429 | error = NFS_PROTO(inode)->setattr(dentry, fattr, attr); |
426 | if (error == 0) | 430 | if (error == 0) |
427 | nfs_refresh_inode(inode, &fattr); | 431 | nfs_refresh_inode(inode, fattr); |
432 | nfs_free_fattr(fattr); | ||
433 | out: | ||
428 | return error; | 434 | return error; |
429 | } | 435 | } |
430 | 436 | ||
@@ -682,7 +688,7 @@ int | |||
682 | __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | 688 | __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) |
683 | { | 689 | { |
684 | int status = -ESTALE; | 690 | int status = -ESTALE; |
685 | struct nfs_fattr fattr; | 691 | struct nfs_fattr *fattr = NULL; |
686 | struct nfs_inode *nfsi = NFS_I(inode); | 692 | struct nfs_inode *nfsi = NFS_I(inode); |
687 | 693 | ||
688 | dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n", | 694 | dfprintk(PAGECACHE, "NFS: revalidating (%s/%Ld)\n", |
@@ -693,8 +699,13 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
693 | if (NFS_STALE(inode)) | 699 | if (NFS_STALE(inode)) |
694 | goto out; | 700 | goto out; |
695 | 701 | ||
702 | status = -ENOMEM; | ||
703 | fattr = nfs_alloc_fattr(); | ||
704 | if (fattr == NULL) | ||
705 | goto out; | ||
706 | |||
696 | nfs_inc_stats(inode, NFSIOS_INODEREVALIDATE); | 707 | nfs_inc_stats(inode, NFSIOS_INODEREVALIDATE); |
697 | status = NFS_PROTO(inode)->getattr(server, NFS_FH(inode), &fattr); | 708 | status = NFS_PROTO(inode)->getattr(server, NFS_FH(inode), fattr); |
698 | if (status != 0) { | 709 | if (status != 0) { |
699 | dfprintk(PAGECACHE, "nfs_revalidate_inode: (%s/%Ld) getattr failed, error=%d\n", | 710 | dfprintk(PAGECACHE, "nfs_revalidate_inode: (%s/%Ld) getattr failed, error=%d\n", |
700 | inode->i_sb->s_id, | 711 | inode->i_sb->s_id, |
@@ -707,7 +718,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
707 | goto out; | 718 | goto out; |
708 | } | 719 | } |
709 | 720 | ||
710 | status = nfs_refresh_inode(inode, &fattr); | 721 | status = nfs_refresh_inode(inode, fattr); |
711 | if (status) { | 722 | if (status) { |
712 | dfprintk(PAGECACHE, "nfs_revalidate_inode: (%s/%Ld) refresh failed, error=%d\n", | 723 | dfprintk(PAGECACHE, "nfs_revalidate_inode: (%s/%Ld) refresh failed, error=%d\n", |
713 | inode->i_sb->s_id, | 724 | inode->i_sb->s_id, |
@@ -723,6 +734,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
723 | (long long)NFS_FILEID(inode)); | 734 | (long long)NFS_FILEID(inode)); |
724 | 735 | ||
725 | out: | 736 | out: |
737 | nfs_free_fattr(fattr); | ||
726 | return status; | 738 | return status; |
727 | } | 739 | } |
728 | 740 | ||
@@ -730,9 +742,14 @@ int nfs_attribute_timeout(struct inode *inode) | |||
730 | { | 742 | { |
731 | struct nfs_inode *nfsi = NFS_I(inode); | 743 | struct nfs_inode *nfsi = NFS_I(inode); |
732 | 744 | ||
745 | return !time_in_range_open(jiffies, nfsi->read_cache_jiffies, nfsi->read_cache_jiffies + nfsi->attrtimeo); | ||
746 | } | ||
747 | |||
748 | static int nfs_attribute_cache_expired(struct inode *inode) | ||
749 | { | ||
733 | if (nfs_have_delegated_attributes(inode)) | 750 | if (nfs_have_delegated_attributes(inode)) |
734 | return 0; | 751 | return 0; |
735 | return !time_in_range_open(jiffies, nfsi->read_cache_jiffies, nfsi->read_cache_jiffies + nfsi->attrtimeo); | 752 | return nfs_attribute_timeout(inode); |
736 | } | 753 | } |
737 | 754 | ||
738 | /** | 755 | /** |
@@ -745,7 +762,7 @@ int nfs_attribute_timeout(struct inode *inode) | |||
745 | int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | 762 | int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) |
746 | { | 763 | { |
747 | if (!(NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATTR) | 764 | if (!(NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATTR) |
748 | && !nfs_attribute_timeout(inode)) | 765 | && !nfs_attribute_cache_expired(inode)) |
749 | return NFS_STALE(inode) ? -ESTALE : 0; | 766 | return NFS_STALE(inode) ? -ESTALE : 0; |
750 | return __nfs_revalidate_inode(server, inode); | 767 | return __nfs_revalidate_inode(server, inode); |
751 | } | 768 | } |
@@ -782,7 +799,8 @@ int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping) | |||
782 | int ret = 0; | 799 | int ret = 0; |
783 | 800 | ||
784 | if ((nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE) | 801 | if ((nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE) |
785 | || nfs_attribute_timeout(inode) || NFS_STALE(inode)) { | 802 | || nfs_attribute_cache_expired(inode) |
803 | || NFS_STALE(inode)) { | ||
786 | ret = __nfs_revalidate_inode(NFS_SERVER(inode), inode); | 804 | ret = __nfs_revalidate_inode(NFS_SERVER(inode), inode); |
787 | if (ret < 0) | 805 | if (ret < 0) |
788 | goto out; | 806 | goto out; |
@@ -916,6 +934,26 @@ void nfs_fattr_init(struct nfs_fattr *fattr) | |||
916 | fattr->gencount = nfs_inc_attr_generation_counter(); | 934 | fattr->gencount = nfs_inc_attr_generation_counter(); |
917 | } | 935 | } |
918 | 936 | ||
937 | struct nfs_fattr *nfs_alloc_fattr(void) | ||
938 | { | ||
939 | struct nfs_fattr *fattr; | ||
940 | |||
941 | fattr = kmalloc(sizeof(*fattr), GFP_NOFS); | ||
942 | if (fattr != NULL) | ||
943 | nfs_fattr_init(fattr); | ||
944 | return fattr; | ||
945 | } | ||
946 | |||
947 | struct nfs_fh *nfs_alloc_fhandle(void) | ||
948 | { | ||
949 | struct nfs_fh *fh; | ||
950 | |||
951 | fh = kmalloc(sizeof(struct nfs_fh), GFP_NOFS); | ||
952 | if (fh != NULL) | ||
953 | fh->size = 0; | ||
954 | return fh; | ||
955 | } | ||
956 | |||
919 | /** | 957 | /** |
920 | * nfs_inode_attrs_need_update - check if the inode attributes need updating | 958 | * nfs_inode_attrs_need_update - check if the inode attributes need updating |
921 | * @inode - pointer to inode | 959 | * @inode - pointer to inode |