Lines Matching refs:inode
65 static int nfs_update_inode(struct inode *, struct nfs_fattr *);
107 int nfs_drop_inode(struct inode *inode) in nfs_drop_inode() argument
109 return NFS_STALE(inode) || generic_drop_inode(inode); in nfs_drop_inode()
113 void nfs_clear_inode(struct inode *inode) in nfs_clear_inode() argument
118 WARN_ON_ONCE(nfs_have_writebacks(inode)); in nfs_clear_inode()
119 WARN_ON_ONCE(!list_empty(&NFS_I(inode)->open_files)); in nfs_clear_inode()
120 nfs_zap_acl_cache(inode); in nfs_clear_inode()
121 nfs_access_zap_cache(inode); in nfs_clear_inode()
122 nfs_fscache_clear_inode(inode); in nfs_clear_inode()
126 void nfs_evict_inode(struct inode *inode) in nfs_evict_inode() argument
128 truncate_inode_pages_final(&inode->i_data); in nfs_evict_inode()
129 clear_inode(inode); in nfs_evict_inode()
130 nfs_clear_inode(inode); in nfs_evict_inode()
133 int nfs_sync_inode(struct inode *inode) in nfs_sync_inode() argument
135 inode_dio_wait(inode); in nfs_sync_inode()
136 return nfs_wb_all(inode); in nfs_sync_inode()
155 static int nfs_attribute_timeout(struct inode *inode) in nfs_attribute_timeout() argument
157 struct nfs_inode *nfsi = NFS_I(inode); in nfs_attribute_timeout()
162 static bool nfs_check_cache_flags_invalid(struct inode *inode, in nfs_check_cache_flags_invalid() argument
165 unsigned long cache_validity = READ_ONCE(NFS_I(inode)->cache_validity); in nfs_check_cache_flags_invalid()
170 bool nfs_check_cache_invalid(struct inode *inode, unsigned long flags) in nfs_check_cache_invalid() argument
172 if (nfs_check_cache_flags_invalid(inode, flags)) in nfs_check_cache_invalid()
174 return nfs_attribute_cache_expired(inode); in nfs_check_cache_invalid()
190 void nfs_set_cache_invalid(struct inode *inode, unsigned long flags) in nfs_set_cache_invalid() argument
192 struct nfs_inode *nfsi = NFS_I(inode); in nfs_set_cache_invalid()
193 bool have_delegation = NFS_PROTO(inode)->have_delegation(inode, FMODE_READ); in nfs_set_cache_invalid()
206 nfs_fscache_invalidate(inode, 0); in nfs_set_cache_invalid()
211 if (inode->i_mapping->nrpages == 0) in nfs_set_cache_invalid()
216 trace_nfs_set_cache_invalid(inode, 0); in nfs_set_cache_invalid()
223 static void nfs_zap_caches_locked(struct inode *inode) in nfs_zap_caches_locked() argument
225 struct nfs_inode *nfsi = NFS_I(inode); in nfs_zap_caches_locked()
226 int mode = inode->i_mode; in nfs_zap_caches_locked()
228 nfs_inc_stats(inode, NFSIOS_ATTRINVALIDATE); in nfs_zap_caches_locked()
230 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode); in nfs_zap_caches_locked()
234 nfs_set_cache_invalid(inode, NFS_INO_INVALID_ATTR | in nfs_zap_caches_locked()
240 nfs_set_cache_invalid(inode, NFS_INO_INVALID_ATTR | in nfs_zap_caches_locked()
247 void nfs_zap_caches(struct inode *inode) in nfs_zap_caches() argument
249 spin_lock(&inode->i_lock); in nfs_zap_caches()
250 nfs_zap_caches_locked(inode); in nfs_zap_caches()
251 spin_unlock(&inode->i_lock); in nfs_zap_caches()
254 void nfs_zap_mapping(struct inode *inode, struct address_space *mapping) in nfs_zap_mapping() argument
257 spin_lock(&inode->i_lock); in nfs_zap_mapping()
258 nfs_set_cache_invalid(inode, NFS_INO_INVALID_DATA); in nfs_zap_mapping()
259 spin_unlock(&inode->i_lock); in nfs_zap_mapping()
263 void nfs_zap_acl_cache(struct inode *inode) in nfs_zap_acl_cache() argument
265 void (*clear_acl_cache)(struct inode *); in nfs_zap_acl_cache()
267 clear_acl_cache = NFS_PROTO(inode)->clear_acl_cache; in nfs_zap_acl_cache()
269 clear_acl_cache(inode); in nfs_zap_acl_cache()
270 spin_lock(&inode->i_lock); in nfs_zap_acl_cache()
271 NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_ACL; in nfs_zap_acl_cache()
272 spin_unlock(&inode->i_lock); in nfs_zap_acl_cache()
276 void nfs_invalidate_atime(struct inode *inode) in nfs_invalidate_atime() argument
278 spin_lock(&inode->i_lock); in nfs_invalidate_atime()
279 nfs_set_cache_invalid(inode, NFS_INO_INVALID_ATIME); in nfs_invalidate_atime()
280 spin_unlock(&inode->i_lock); in nfs_invalidate_atime()
288 static void nfs_set_inode_stale_locked(struct inode *inode) in nfs_set_inode_stale_locked() argument
290 set_bit(NFS_INO_STALE, &NFS_I(inode)->flags); in nfs_set_inode_stale_locked()
291 nfs_zap_caches_locked(inode); in nfs_set_inode_stale_locked()
292 trace_nfs_set_inode_stale(inode); in nfs_set_inode_stale_locked()
295 void nfs_set_inode_stale(struct inode *inode) in nfs_set_inode_stale() argument
297 spin_lock(&inode->i_lock); in nfs_set_inode_stale()
298 nfs_set_inode_stale_locked(inode); in nfs_set_inode_stale()
299 spin_unlock(&inode->i_lock); in nfs_set_inode_stale()
314 nfs_find_actor(struct inode *inode, void *opaque) in nfs_find_actor() argument
320 if (NFS_FILEID(inode) != fattr->fileid) in nfs_find_actor()
322 if (inode_wrong_type(inode, fattr->mode)) in nfs_find_actor()
324 if (nfs_compare_fh(NFS_FH(inode), fh)) in nfs_find_actor()
326 if (is_bad_inode(inode) || NFS_STALE(inode)) in nfs_find_actor()
332 nfs_init_locked(struct inode *inode, void *opaque) in nfs_init_locked() argument
337 set_nfs_fileid(inode, fattr->fileid); in nfs_init_locked()
338 inode->i_mode = fattr->mode; in nfs_init_locked()
339 nfs_copy_fh(NFS_FH(inode), desc->fh); in nfs_init_locked()
344 static void nfs_clear_label_invalid(struct inode *inode) in nfs_clear_label_invalid() argument
346 spin_lock(&inode->i_lock); in nfs_clear_label_invalid()
347 NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_LABEL; in nfs_clear_label_invalid()
348 spin_unlock(&inode->i_lock); in nfs_clear_label_invalid()
351 void nfs_setsecurity(struct inode *inode, struct nfs_fattr *fattr) in nfs_setsecurity() argument
358 if ((fattr->valid & NFS_ATTR_FATTR_V4_SECURITY_LABEL) && inode->i_security) { in nfs_setsecurity()
359 error = security_inode_notifysecctx(inode, fattr->label->label, in nfs_setsecurity()
367 nfs_clear_label_invalid(inode); in nfs_setsecurity()
393 void nfs_setsecurity(struct inode *inode, struct nfs_fattr *fattr) in nfs_setsecurity() argument
400 struct inode *
407 struct inode *inode; in nfs_ilookup() local
415 inode = ilookup5(sb, hash, nfs_find_actor, &desc); in nfs_ilookup()
417 dprintk("%s: returning %p\n", __func__, inode); in nfs_ilookup()
418 return inode; in nfs_ilookup()
442 struct inode *
449 struct inode *inode = ERR_PTR(-ENOENT); in nfs_fhget() local
464 inode = iget5_locked(sb, hash, nfs_find_actor, nfs_init_locked, &desc); in nfs_fhget()
465 if (inode == NULL) { in nfs_fhget()
466 inode = ERR_PTR(-ENOMEM); in nfs_fhget()
470 if (inode->i_state & I_NEW) { in nfs_fhget()
471 struct nfs_inode *nfsi = NFS_I(inode); in nfs_fhget()
476 inode->i_ino = hash; in nfs_fhget()
479 inode->i_flags |= S_NOATIME|S_NOCMTIME; in nfs_fhget()
480 inode->i_mode = fattr->mode; in nfs_fhget()
484 nfs_set_cache_invalid(inode, NFS_INO_INVALID_MODE); in nfs_fhget()
488 inode->i_op = NFS_SB(sb)->nfs_client->rpc_ops->file_inode_ops; in nfs_fhget()
489 if (S_ISREG(inode->i_mode)) { in nfs_fhget()
490 inode->i_fop = NFS_SB(sb)->nfs_client->rpc_ops->file_ops; in nfs_fhget()
491 inode->i_data.a_ops = &nfs_file_aops; in nfs_fhget()
493 } else if (S_ISDIR(inode->i_mode)) { in nfs_fhget()
494 inode->i_op = NFS_SB(sb)->nfs_client->rpc_ops->dir_inode_ops; in nfs_fhget()
495 inode->i_fop = &nfs_dir_operations; in nfs_fhget()
496 inode->i_data.a_ops = &nfs_dir_aops; in nfs_fhget()
502 inode->i_op = &nfs_referral_inode_operations; in nfs_fhget()
504 inode->i_op = &nfs_mountpoint_inode_operations; in nfs_fhget()
505 inode->i_fop = NULL; in nfs_fhget()
506 inode->i_flags |= S_AUTOMOUNT; in nfs_fhget()
508 } else if (S_ISLNK(inode->i_mode)) { in nfs_fhget()
509 inode->i_op = &nfs_symlink_inode_operations; in nfs_fhget()
510 inode_nohighmem(inode); in nfs_fhget()
512 init_special_inode(inode, inode->i_mode, fattr->rdev); in nfs_fhget()
514 memset(&inode->i_atime, 0, sizeof(inode->i_atime)); in nfs_fhget()
515 memset(&inode->i_mtime, 0, sizeof(inode->i_mtime)); in nfs_fhget()
516 memset(&inode->i_ctime, 0, sizeof(inode->i_ctime)); in nfs_fhget()
517 inode_set_iversion_raw(inode, 0); in nfs_fhget()
518 inode->i_size = 0; in nfs_fhget()
519 clear_nlink(inode); in nfs_fhget()
520 inode->i_uid = make_kuid(&init_user_ns, -2); in nfs_fhget()
521 inode->i_gid = make_kgid(&init_user_ns, -2); in nfs_fhget()
522 inode->i_blocks = 0; in nfs_fhget()
529 inode->i_atime = fattr->atime; in nfs_fhget()
531 nfs_set_cache_invalid(inode, NFS_INO_INVALID_ATIME); in nfs_fhget()
533 inode->i_mtime = fattr->mtime; in nfs_fhget()
535 nfs_set_cache_invalid(inode, NFS_INO_INVALID_MTIME); in nfs_fhget()
537 inode->i_ctime = fattr->ctime; in nfs_fhget()
539 nfs_set_cache_invalid(inode, NFS_INO_INVALID_CTIME); in nfs_fhget()
541 inode_set_iversion_raw(inode, fattr->change_attr); in nfs_fhget()
543 nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE); in nfs_fhget()
545 inode->i_size = nfs_size_to_loff_t(fattr->size); in nfs_fhget()
547 nfs_set_cache_invalid(inode, NFS_INO_INVALID_SIZE); in nfs_fhget()
549 set_nlink(inode, fattr->nlink); in nfs_fhget()
551 nfs_set_cache_invalid(inode, NFS_INO_INVALID_NLINK); in nfs_fhget()
553 inode->i_uid = fattr->uid; in nfs_fhget()
555 nfs_set_cache_invalid(inode, NFS_INO_INVALID_OTHER); in nfs_fhget()
557 inode->i_gid = fattr->gid; in nfs_fhget()
559 nfs_set_cache_invalid(inode, NFS_INO_INVALID_OTHER); in nfs_fhget()
561 inode->i_blocks = fattr->du.nfs2.blocks; in nfs_fhget()
564 nfs_set_cache_invalid(inode, NFS_INO_INVALID_BLOCKS); in nfs_fhget()
569 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used); in nfs_fhget()
572 nfs_set_cache_invalid(inode, NFS_INO_INVALID_BLOCKS); in nfs_fhget()
574 nfs_setsecurity(inode, fattr); in nfs_fhget()
576 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode); in nfs_fhget()
580 nfs_fscache_init_inode(inode); in nfs_fhget()
582 unlock_new_inode(inode); in nfs_fhget()
584 int err = nfs_refresh_inode(inode, fattr); in nfs_fhget()
586 iput(inode); in nfs_fhget()
587 inode = ERR_PTR(err); in nfs_fhget()
592 inode->i_sb->s_id, in nfs_fhget()
593 (unsigned long long)NFS_FILEID(inode), in nfs_fhget()
595 atomic_read(&inode->i_count)); in nfs_fhget()
598 return inode; in nfs_fhget()
601 dprintk("nfs_fhget: iget failed with error %ld\n", PTR_ERR(inode)); in nfs_fhget()
612 struct inode *inode = d_inode(dentry); in nfs_setattr() local
616 nfs_inc_stats(inode, NFSIOS_VFSSETATTR); in nfs_setattr()
623 BUG_ON(!S_ISREG(inode->i_mode)); in nfs_setattr()
625 error = inode_newsize_ok(inode, attr->ia_size); in nfs_setattr()
629 if (attr->ia_size == i_size_read(inode)) in nfs_setattr()
637 trace_nfs_setattr_enter(inode); in nfs_setattr()
640 if (S_ISREG(inode->i_mode)) in nfs_setattr()
641 nfs_sync_inode(inode); in nfs_setattr()
643 fattr = nfs_alloc_fattr_with_label(NFS_SERVER(inode)); in nfs_setattr()
649 error = NFS_PROTO(inode)->setattr(dentry, fattr, attr); in nfs_setattr()
651 error = nfs_refresh_inode(inode, fattr); in nfs_setattr()
654 trace_nfs_setattr_exit(inode, error); in nfs_setattr()
669 static int nfs_vmtruncate(struct inode * inode, loff_t offset) in nfs_vmtruncate() argument
673 err = inode_newsize_ok(inode, offset); in nfs_vmtruncate()
677 trace_nfs_size_truncate(inode, offset); in nfs_vmtruncate()
678 i_size_write(inode, offset); in nfs_vmtruncate()
681 NFS_I(inode)->cache_validity &= ~(NFS_INO_INVALID_DATA | in nfs_vmtruncate()
683 NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_SIZE; in nfs_vmtruncate()
685 spin_unlock(&inode->i_lock); in nfs_vmtruncate()
686 truncate_pagecache(inode, offset); in nfs_vmtruncate()
687 spin_lock(&inode->i_lock); in nfs_vmtruncate()
701 void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr, in nfs_setattr_update_inode() argument
707 spin_lock(&inode->i_lock); in nfs_setattr_update_inode()
708 NFS_I(inode)->attr_gencount = fattr->gencount; in nfs_setattr_update_inode()
710 nfs_set_cache_invalid(inode, NFS_INO_INVALID_MTIME | in nfs_setattr_update_inode()
712 nfs_inc_stats(inode, NFSIOS_SETATTRTRUNC); in nfs_setattr_update_inode()
713 nfs_vmtruncate(inode, attr->ia_size); in nfs_setattr_update_inode()
716 NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_CTIME; in nfs_setattr_update_inode()
718 inode->i_mode & S_ISUID) in nfs_setattr_update_inode()
719 inode->i_mode &= ~S_ISUID; in nfs_setattr_update_inode()
721 (inode->i_mode & (S_ISGID | S_IXGRP)) == in nfs_setattr_update_inode()
723 inode->i_mode &= ~S_ISGID; in nfs_setattr_update_inode()
726 mode |= inode->i_mode & ~S_IALLUGO; in nfs_setattr_update_inode()
727 inode->i_mode = mode; in nfs_setattr_update_inode()
730 inode->i_uid = attr->ia_uid; in nfs_setattr_update_inode()
732 inode->i_gid = attr->ia_gid; in nfs_setattr_update_inode()
734 inode->i_ctime = fattr->ctime; in nfs_setattr_update_inode()
736 nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE in nfs_setattr_update_inode()
738 nfs_set_cache_invalid(inode, NFS_INO_INVALID_ACCESS in nfs_setattr_update_inode()
742 NFS_I(inode)->cache_validity &= ~(NFS_INO_INVALID_ATIME in nfs_setattr_update_inode()
745 inode->i_atime = fattr->atime; in nfs_setattr_update_inode()
747 inode->i_atime = attr->ia_atime; in nfs_setattr_update_inode()
749 nfs_set_cache_invalid(inode, NFS_INO_INVALID_ATIME); in nfs_setattr_update_inode()
752 inode->i_ctime = fattr->ctime; in nfs_setattr_update_inode()
754 nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE in nfs_setattr_update_inode()
758 NFS_I(inode)->cache_validity &= ~(NFS_INO_INVALID_MTIME in nfs_setattr_update_inode()
761 inode->i_mtime = fattr->mtime; in nfs_setattr_update_inode()
763 inode->i_mtime = attr->ia_mtime; in nfs_setattr_update_inode()
765 nfs_set_cache_invalid(inode, NFS_INO_INVALID_MTIME); in nfs_setattr_update_inode()
768 inode->i_ctime = fattr->ctime; in nfs_setattr_update_inode()
770 nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE in nfs_setattr_update_inode()
774 nfs_update_inode(inode, fattr); in nfs_setattr_update_inode()
775 spin_unlock(&inode->i_lock); in nfs_setattr_update_inode()
783 static bool nfs_getattr_readdirplus_enable(const struct inode *inode) in nfs_getattr_readdirplus_enable() argument
785 return nfs_server_capable(inode, NFS_CAP_READDIRPLUS) && in nfs_getattr_readdirplus_enable()
786 !nfs_have_writebacks(inode) && NFS_MAXATTRTIMEO(inode) > 5 * HZ; in nfs_getattr_readdirplus_enable()
807 static u32 nfs_get_valid_attrmask(struct inode *inode) in nfs_get_valid_attrmask() argument
809 unsigned long cache_validity = READ_ONCE(NFS_I(inode)->cache_validity); in nfs_get_valid_attrmask()
836 struct inode *inode = d_inode(path->dentry); in nfs_getattr() local
837 struct nfs_server *server = NFS_SERVER(inode); in nfs_getattr()
842 bool readdirplus_enabled = nfs_getattr_readdirplus_enable(inode); in nfs_getattr()
844 trace_nfs_getattr_enter(inode); in nfs_getattr()
859 S_ISREG(inode->i_mode)) in nfs_getattr()
860 filemap_write_and_wait(inode->i_mapping); in nfs_getattr()
872 ((path->mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode))) in nfs_getattr()
883 do_update |= force_sync || nfs_attribute_cache_expired(inode); in nfs_getattr()
884 cache_validity = READ_ONCE(NFS_I(inode)->cache_validity); in nfs_getattr()
906 err = __nfs_revalidate_inode(server, inode); in nfs_getattr()
913 stat->result_mask = nfs_get_valid_attrmask(inode) | request_mask; in nfs_getattr()
915 generic_fillattr(&nop_mnt_idmap, inode, stat); in nfs_getattr()
916 stat->ino = nfs_compat_user_ino64(NFS_FILEID(inode)); in nfs_getattr()
917 stat->change_cookie = inode_peek_iversion_raw(inode); in nfs_getattr()
921 if (S_ISDIR(inode->i_mode)) in nfs_getattr()
922 stat->blksize = NFS_SERVER(inode)->dtsize; in nfs_getattr()
924 trace_nfs_getattr_exit(inode, err); in nfs_getattr()
953 struct inode *inode = d_inode(ctx->dentry); in nfs_get_lock_context() local
963 spin_lock(&inode->i_lock); in nfs_get_lock_context()
975 spin_unlock(&inode->i_lock); in nfs_get_lock_context()
985 struct inode *inode = d_inode(ctx->dentry); in nfs_put_lock_context() local
987 if (!refcount_dec_and_lock(&l_ctx->count, &inode->i_lock)) in nfs_put_lock_context()
990 spin_unlock(&inode->i_lock); in nfs_put_lock_context()
1008 struct inode *inode; in nfs_close_context() local
1014 inode = d_inode(ctx->dentry); in nfs_close_context()
1015 if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ)) in nfs_close_context()
1017 nfsi = NFS_I(inode); in nfs_close_context()
1018 if (inode->i_mapping->nrpages == 0) in nfs_close_context()
1024 if (NFS_SERVER(inode)->flags & NFS_MOUNT_NOCTO) in nfs_close_context()
1026 nfs_revalidate_inode(inode, in nfs_close_context()
1070 struct inode *inode = d_inode(ctx->dentry); in __put_nfs_open_context() local
1076 spin_lock(&inode->i_lock); in __put_nfs_open_context()
1078 spin_unlock(&inode->i_lock); in __put_nfs_open_context()
1080 if (inode != NULL) in __put_nfs_open_context()
1081 NFS_PROTO(inode)->close_context(ctx, is_sync); in __put_nfs_open_context()
1107 struct inode *inode = d_inode(ctx->dentry); in nfs_inode_attach_open_context() local
1108 struct nfs_inode *nfsi = NFS_I(inode); in nfs_inode_attach_open_context()
1110 spin_lock(&inode->i_lock); in nfs_inode_attach_open_context()
1113 nfs_set_cache_invalid(inode, NFS_INO_INVALID_DATA | in nfs_inode_attach_open_context()
1116 spin_unlock(&inode->i_lock); in nfs_inode_attach_open_context()
1132 struct nfs_open_context *nfs_find_open_context(struct inode *inode, const struct cred *cred, fmode_… in nfs_find_open_context() argument
1134 struct nfs_inode *nfsi = NFS_I(inode); in nfs_find_open_context()
1158 struct inode *inode = d_inode(ctx->dentry); in nfs_file_clear_open_context() local
1166 invalidate_inode_pages2(inode->i_mapping); in nfs_file_clear_open_context()
1175 int nfs_open(struct inode *inode, struct file *filp) in nfs_open() argument
1185 nfs_fscache_open_file(inode, filp); in nfs_open()
1194 __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) in __nfs_revalidate_inode() argument
1198 struct nfs_inode *nfsi = NFS_I(inode); in __nfs_revalidate_inode()
1201 inode->i_sb->s_id, (unsigned long long)NFS_FILEID(inode)); in __nfs_revalidate_inode()
1203 trace_nfs_revalidate_inode_enter(inode); in __nfs_revalidate_inode()
1205 if (is_bad_inode(inode)) in __nfs_revalidate_inode()
1207 if (NFS_STALE(inode)) in __nfs_revalidate_inode()
1211 if (S_ISREG(inode->i_mode)) { in __nfs_revalidate_inode()
1212 status = pnfs_sync_inode(inode, false); in __nfs_revalidate_inode()
1218 fattr = nfs_alloc_fattr_with_label(NFS_SERVER(inode)); in __nfs_revalidate_inode()
1222 nfs_inc_stats(inode, NFSIOS_INODEREVALIDATE); in __nfs_revalidate_inode()
1224 status = NFS_PROTO(inode)->getattr(server, NFS_FH(inode), fattr, inode); in __nfs_revalidate_inode()
1227 inode->i_sb->s_id, in __nfs_revalidate_inode()
1228 (unsigned long long)NFS_FILEID(inode), status); in __nfs_revalidate_inode()
1236 if (!S_ISDIR(inode->i_mode)) in __nfs_revalidate_inode()
1237 nfs_set_inode_stale(inode); in __nfs_revalidate_inode()
1239 nfs_zap_caches(inode); in __nfs_revalidate_inode()
1244 status = nfs_refresh_inode(inode, fattr); in __nfs_revalidate_inode()
1247 inode->i_sb->s_id, in __nfs_revalidate_inode()
1248 (unsigned long long)NFS_FILEID(inode), status); in __nfs_revalidate_inode()
1253 nfs_zap_acl_cache(inode); in __nfs_revalidate_inode()
1255 nfs_setsecurity(inode, fattr); in __nfs_revalidate_inode()
1258 inode->i_sb->s_id, in __nfs_revalidate_inode()
1259 (unsigned long long)NFS_FILEID(inode)); in __nfs_revalidate_inode()
1263 trace_nfs_revalidate_inode_exit(inode, status); in __nfs_revalidate_inode()
1267 int nfs_attribute_cache_expired(struct inode *inode) in nfs_attribute_cache_expired() argument
1269 if (nfs_have_delegated_attributes(inode)) in nfs_attribute_cache_expired()
1271 return nfs_attribute_timeout(inode); in nfs_attribute_cache_expired()
1281 int nfs_revalidate_inode(struct inode *inode, unsigned long flags) in nfs_revalidate_inode() argument
1283 if (!nfs_check_cache_invalid(inode, flags)) in nfs_revalidate_inode()
1284 return NFS_STALE(inode) ? -ESTALE : 0; in nfs_revalidate_inode()
1285 return __nfs_revalidate_inode(NFS_SERVER(inode), inode); in nfs_revalidate_inode()
1289 static int nfs_invalidate_mapping(struct inode *inode, struct address_space *mapping) in nfs_invalidate_mapping() argument
1293 nfs_fscache_invalidate(inode, 0); in nfs_invalidate_mapping()
1295 if (S_ISREG(inode->i_mode)) { in nfs_invalidate_mapping()
1304 nfs_inc_stats(inode, NFSIOS_DATAINVALIDATE); in nfs_invalidate_mapping()
1307 inode->i_sb->s_id, in nfs_invalidate_mapping()
1308 (unsigned long long)NFS_FILEID(inode)); in nfs_invalidate_mapping()
1320 struct inode *inode = mapping->host; in nfs_clear_invalid_mapping() local
1321 struct nfs_inode *nfsi = NFS_I(inode); in nfs_clear_invalid_mapping()
1343 spin_lock(&inode->i_lock); in nfs_clear_invalid_mapping()
1345 spin_unlock(&inode->i_lock); in nfs_clear_invalid_mapping()
1350 spin_unlock(&inode->i_lock); in nfs_clear_invalid_mapping()
1358 spin_unlock(&inode->i_lock); in nfs_clear_invalid_mapping()
1359 trace_nfs_invalidate_mapping_enter(inode); in nfs_clear_invalid_mapping()
1360 ret = nfs_invalidate_mapping(inode, mapping); in nfs_clear_invalid_mapping()
1361 trace_nfs_invalidate_mapping_exit(inode, ret); in nfs_clear_invalid_mapping()
1370 bool nfs_mapping_need_revalidate_inode(struct inode *inode) in nfs_mapping_need_revalidate_inode() argument
1372 return nfs_check_cache_invalid(inode, NFS_INO_INVALID_CHANGE) || in nfs_mapping_need_revalidate_inode()
1373 NFS_STALE(inode); in nfs_mapping_need_revalidate_inode()
1376 int nfs_revalidate_mapping_rcu(struct inode *inode) in nfs_revalidate_mapping_rcu() argument
1378 struct nfs_inode *nfsi = NFS_I(inode); in nfs_revalidate_mapping_rcu()
1382 if (IS_SWAPFILE(inode)) in nfs_revalidate_mapping_rcu()
1384 if (nfs_mapping_need_revalidate_inode(inode)) { in nfs_revalidate_mapping_rcu()
1388 spin_lock(&inode->i_lock); in nfs_revalidate_mapping_rcu()
1392 spin_unlock(&inode->i_lock); in nfs_revalidate_mapping_rcu()
1402 int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping) in nfs_revalidate_mapping() argument
1405 if (IS_SWAPFILE(inode)) in nfs_revalidate_mapping()
1408 if (nfs_mapping_need_revalidate_inode(inode)) { in nfs_revalidate_mapping()
1409 int ret = __nfs_revalidate_inode(NFS_SERVER(inode), inode); in nfs_revalidate_mapping()
1419 struct inode *inode = &nfsi->vfs_inode; in nfs_file_has_writers() local
1421 if (!S_ISREG(inode->i_mode)) in nfs_file_has_writers()
1425 return inode_is_open_for_write(inode); in nfs_file_has_writers()
1433 static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr) in nfs_wcc_update_inode() argument
1439 && inode_eq_iversion_raw(inode, fattr->pre_change_attr)) { in nfs_wcc_update_inode()
1440 inode_set_iversion_raw(inode, fattr->change_attr); in nfs_wcc_update_inode()
1441 if (S_ISDIR(inode->i_mode)) in nfs_wcc_update_inode()
1442 nfs_set_cache_invalid(inode, NFS_INO_INVALID_DATA); in nfs_wcc_update_inode()
1443 else if (nfs_server_capable(inode, NFS_CAP_XATTR)) in nfs_wcc_update_inode()
1444 nfs_set_cache_invalid(inode, NFS_INO_INVALID_XATTR); in nfs_wcc_update_inode()
1447 ts = inode->i_ctime; in nfs_wcc_update_inode()
1451 inode->i_ctime = fattr->ctime; in nfs_wcc_update_inode()
1454 ts = inode->i_mtime; in nfs_wcc_update_inode()
1458 inode->i_mtime = fattr->mtime; in nfs_wcc_update_inode()
1462 && i_size_read(inode) == nfs_size_to_loff_t(fattr->pre_size) in nfs_wcc_update_inode()
1463 && !nfs_have_writebacks(inode)) { in nfs_wcc_update_inode()
1464 trace_nfs_size_wcc(inode, fattr->size); in nfs_wcc_update_inode()
1465 i_size_write(inode, nfs_size_to_loff_t(fattr->size)); in nfs_wcc_update_inode()
1478 static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fattr) in nfs_check_inode_attributes() argument
1480 struct nfs_inode *nfsi = NFS_I(inode); in nfs_check_inode_attributes()
1485 if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ)) in nfs_check_inode_attributes()
1500 if ((fattr->valid & NFS_ATTR_FATTR_TYPE) && inode_wrong_type(inode, fattr->mode)) in nfs_check_inode_attributes()
1506 …if ((fattr->valid & NFS_ATTR_FATTR_CHANGE) != 0 && !inode_eq_iversion_raw(inode, fattr->change_att… in nfs_check_inode_attributes()
1509 ts = inode->i_mtime; in nfs_check_inode_attributes()
1513 ts = inode->i_ctime; in nfs_check_inode_attributes()
1518 cur_size = i_size_read(inode); in nfs_check_inode_attributes()
1526 …if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUG… in nfs_check_inode_attributes()
1528 if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && !uid_eq(inode->i_uid, fattr->uid)) in nfs_check_inode_attributes()
1530 if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && !gid_eq(inode->i_gid, fattr->gid)) in nfs_check_inode_attributes()
1534 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink) in nfs_check_inode_attributes()
1537 ts = inode->i_atime; in nfs_check_inode_attributes()
1542 nfs_set_cache_invalid(inode, invalid); in nfs_check_inode_attributes()
1705 const struct inode *inode) in nfs_inode_attrs_cmp_generic() argument
1707 unsigned long attr_gencount = NFS_I(inode)->attr_gencount; in nfs_inode_attrs_cmp_generic()
1730 const struct inode *inode) in nfs_inode_attrs_cmp_monotonic() argument
1732 s64 diff = fattr->change_attr - inode_peek_iversion_raw(inode); in nfs_inode_attrs_cmp_monotonic()
1754 const struct inode *inode) in nfs_inode_attrs_cmp_strict_monotonic() argument
1756 return nfs_inode_attrs_cmp_monotonic(fattr, inode) > 0 ? 1 : -1; in nfs_inode_attrs_cmp_strict_monotonic()
1770 const struct inode *inode) in nfs_inode_attrs_cmp() argument
1772 if (nfs_inode_attrs_cmp_generic(fattr, inode) > 0) in nfs_inode_attrs_cmp()
1774 switch (NFS_SERVER(inode)->change_attr_type) { in nfs_inode_attrs_cmp()
1780 return nfs_inode_attrs_cmp_monotonic(fattr, inode); in nfs_inode_attrs_cmp()
1784 return nfs_inode_attrs_cmp_strict_monotonic(fattr, inode); in nfs_inode_attrs_cmp()
1800 const struct inode *inode) in nfs_inode_finish_partial_attr_update() argument
1807 unsigned long cache_validity = NFS_I(inode)->cache_validity; in nfs_inode_finish_partial_attr_update()
1808 enum nfs4_change_attr_type ctype = NFS_SERVER(inode)->change_attr_type; in nfs_inode_finish_partial_attr_update()
1814 nfs_inode_attrs_cmp_monotonic(fattr, inode) == 0) in nfs_inode_finish_partial_attr_update()
1819 static int nfs_refresh_inode_locked(struct inode *inode, in nfs_refresh_inode_locked() argument
1822 int attr_cmp = nfs_inode_attrs_cmp(fattr, inode); in nfs_refresh_inode_locked()
1825 trace_nfs_refresh_inode_enter(inode); in nfs_refresh_inode_locked()
1827 if (attr_cmp > 0 || nfs_inode_finish_partial_attr_update(fattr, inode)) in nfs_refresh_inode_locked()
1828 ret = nfs_update_inode(inode, fattr); in nfs_refresh_inode_locked()
1830 ret = nfs_check_inode_attributes(inode, fattr); in nfs_refresh_inode_locked()
1832 trace_nfs_refresh_inode_exit(inode, ret); in nfs_refresh_inode_locked()
1846 int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) in nfs_refresh_inode() argument
1852 spin_lock(&inode->i_lock); in nfs_refresh_inode()
1853 status = nfs_refresh_inode_locked(inode, fattr); in nfs_refresh_inode()
1854 spin_unlock(&inode->i_lock); in nfs_refresh_inode()
1860 static int nfs_post_op_update_inode_locked(struct inode *inode, in nfs_post_op_update_inode_locked() argument
1863 if (S_ISDIR(inode->i_mode)) in nfs_post_op_update_inode_locked()
1865 nfs_set_cache_invalid(inode, invalid); in nfs_post_op_update_inode_locked()
1868 return nfs_refresh_inode_locked(inode, fattr); in nfs_post_op_update_inode_locked()
1885 int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr) in nfs_post_op_update_inode() argument
1889 spin_lock(&inode->i_lock); in nfs_post_op_update_inode()
1891 status = nfs_post_op_update_inode_locked(inode, fattr, in nfs_post_op_update_inode()
1895 spin_unlock(&inode->i_lock); in nfs_post_op_update_inode()
1912 int nfs_post_op_update_inode_force_wcc_locked(struct inode *inode, struct nfs_fattr *fattr) in nfs_post_op_update_inode_force_wcc_locked() argument
1914 int attr_cmp = nfs_inode_attrs_cmp(fattr, inode); in nfs_post_op_update_inode_force_wcc_locked()
1929 fattr->pre_change_attr = inode_peek_iversion_raw(inode); in nfs_post_op_update_inode_force_wcc_locked()
1934 fattr->pre_ctime = inode->i_ctime; in nfs_post_op_update_inode_force_wcc_locked()
1939 fattr->pre_mtime = inode->i_mtime; in nfs_post_op_update_inode_force_wcc_locked()
1944 fattr->pre_size = i_size_read(inode); in nfs_post_op_update_inode_force_wcc_locked()
1948 status = nfs_post_op_update_inode_locked(inode, fattr, in nfs_post_op_update_inode_force_wcc_locked()
1967 int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr) in nfs_post_op_update_inode_force_wcc() argument
1971 spin_lock(&inode->i_lock); in nfs_post_op_update_inode_force_wcc()
1973 status = nfs_post_op_update_inode_force_wcc_locked(inode, fattr); in nfs_post_op_update_inode_force_wcc()
1974 spin_unlock(&inode->i_lock); in nfs_post_op_update_inode_force_wcc()
1992 static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) in nfs_update_inode() argument
1994 struct nfs_server *server = NFS_SERVER(inode); in nfs_update_inode()
1995 struct nfs_inode *nfsi = NFS_I(inode); in nfs_update_inode()
2007 __func__, inode->i_sb->s_id, inode->i_ino, in nfs_update_inode()
2008 nfs_display_fhandle_hash(NFS_FH(inode)), in nfs_update_inode()
2009 atomic_read(&inode->i_count), fattr->valid); in nfs_update_inode()
2023 NFS_SERVER(inode)->nfs_client->cl_hostname, in nfs_update_inode()
2024 inode->i_sb->s_id, (long long)nfsi->fileid, in nfs_update_inode()
2032 if ((fattr->valid & NFS_ATTR_FATTR_TYPE) && inode_wrong_type(inode, fattr->mode)) { in nfs_update_inode()
2037 __func__, inode->i_ino, inode->i_mode, fattr->mode); in nfs_update_inode()
2042 if (S_ISDIR(inode->i_mode) && (fattr->valid & NFS_ATTR_FATTR_FSID) && in nfs_update_inode()
2044 !IS_AUTOMOUNT(inode)) in nfs_update_inode()
2048 have_delegation = nfs_have_delegated_attributes(inode); in nfs_update_inode()
2062 nfs_wcc_update_inode(inode, fattr); in nfs_update_inode()
2064 if (pnfs_layoutcommit_outstanding(inode)) { in nfs_update_inode()
2075 if (!inode_eq_iversion_raw(inode, fattr->change_attr)) { in nfs_update_inode()
2090 if (S_ISDIR(inode->i_mode)) in nfs_update_inode()
2091 nfs_force_lookup_revalidate(inode); in nfs_update_inode()
2094 inode->i_sb->s_id, in nfs_update_inode()
2095 inode->i_ino); in nfs_update_inode()
2098 inode_set_iversion_raw(inode, fattr->change_attr); in nfs_update_inode()
2109 inode->i_mtime = fattr->mtime; in nfs_update_inode()
2115 inode->i_ctime = fattr->ctime; in nfs_update_inode()
2123 cur_isize = i_size_read(inode); in nfs_update_inode()
2127 if (!nfs_have_writebacks(inode) || new_isize > cur_isize) { in nfs_update_inode()
2128 trace_nfs_size_update(inode, new_isize); in nfs_update_inode()
2129 i_size_write(inode, new_isize); in nfs_update_inode()
2145 inode->i_atime = fattr->atime; in nfs_update_inode()
2151 if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO)) { in nfs_update_inode()
2152 umode_t newmode = inode->i_mode & S_IFMT; in nfs_update_inode()
2154 inode->i_mode = newmode; in nfs_update_inode()
2163 if (!uid_eq(inode->i_uid, fattr->uid)) { in nfs_update_inode()
2166 inode->i_uid = fattr->uid; in nfs_update_inode()
2173 if (!gid_eq(inode->i_gid, fattr->gid)) { in nfs_update_inode()
2176 inode->i_gid = fattr->gid; in nfs_update_inode()
2183 if (inode->i_nlink != fattr->nlink) in nfs_update_inode()
2184 set_nlink(inode, fattr->nlink); in nfs_update_inode()
2193 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used); in nfs_update_inode()
2199 inode->i_blocks = fattr->du.nfs2.blocks; in nfs_update_inode()
2206 nfs_inc_stats(inode, NFSIOS_ATTRINVALIDATE); in nfs_update_inode()
2207 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode); in nfs_update_inode()
2216 if (nfsi->attrtimeo > NFS_MAXATTRTIMEO(inode)) in nfs_update_inode()
2217 nfsi->attrtimeo = NFS_MAXATTRTIMEO(inode); in nfs_update_inode()
2227 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) in nfs_update_inode()
2228 || S_ISLNK(inode->i_mode))) in nfs_update_inode()
2230 nfs_set_cache_invalid(inode, invalid); in nfs_update_inode()
2239 nfs_set_inode_stale_locked(inode); in nfs_update_inode()
2243 struct inode *nfs_alloc_inode(struct super_block *sb) in nfs_alloc_inode()
2261 void nfs_free_inode(struct inode *inode) in nfs_free_inode() argument
2263 kmem_cache_free(nfs_inode_cachep, NFS_I(inode)); in nfs_free_inode()