aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2019-05-09 09:31:11 -0400
committerDavid Howells <dhowells@redhat.com>2019-05-16 17:23:21 -0400
commitc925bd0ac4741badb567f594c41c8cba5e9e9732 (patch)
tree553b6c1ba69724e66becc4c37ed6f89ef23d2fc7
parent7c712458669f203fb2c59af8aafea4c4767b4bc9 (diff)
afs: Split afs_validate() so first part can be used under LOOKUP_RCU
Split afs_validate() so that the part that decides if the vnode is still valid can be used under LOOKUP_RCU conditions from afs_d_revalidate(). Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r--fs/afs/inode.c37
-rw-r--r--fs/afs/internal.h1
2 files changed, 25 insertions, 13 deletions
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 8d3d060a33fc..5c95da7d5f3d 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -561,23 +561,12 @@ void afs_zap_data(struct afs_vnode *vnode)
561} 561}
562 562
563/* 563/*
564 * validate a vnode/inode 564 * Check the validity of a vnode/inode.
565 * - there are several things we need to check
566 * - parent dir data changes (rm, rmdir, rename, mkdir, create, link,
567 * symlink)
568 * - parent dir metadata changed (security changes)
569 * - dentry data changed (write, truncate)
570 * - dentry metadata changed (security changes)
571 */ 565 */
572int afs_validate(struct afs_vnode *vnode, struct key *key) 566bool afs_check_validity(struct afs_vnode *vnode)
573{ 567{
574 time64_t now = ktime_get_real_seconds(); 568 time64_t now = ktime_get_real_seconds();
575 bool valid; 569 bool valid;
576 int ret;
577
578 _enter("{v={%llx:%llu} fl=%lx},%x",
579 vnode->fid.vid, vnode->fid.vnode, vnode->flags,
580 key_serial(key));
581 570
582 /* Quickly check the callback state. Ideally, we'd use read_seqbegin 571 /* Quickly check the callback state. Ideally, we'd use read_seqbegin
583 * here, but we have no way to pass the net namespace to the RCU 572 * here, but we have no way to pass the net namespace to the RCU
@@ -606,6 +595,28 @@ int afs_validate(struct afs_vnode *vnode, struct key *key)
606 } 595 }
607 596
608 read_sequnlock_excl(&vnode->cb_lock); 597 read_sequnlock_excl(&vnode->cb_lock);
598 return valid;
599}
600
601/*
602 * validate a vnode/inode
603 * - there are several things we need to check
604 * - parent dir data changes (rm, rmdir, rename, mkdir, create, link,
605 * symlink)
606 * - parent dir metadata changed (security changes)
607 * - dentry data changed (write, truncate)
608 * - dentry metadata changed (security changes)
609 */
610int afs_validate(struct afs_vnode *vnode, struct key *key)
611{
612 bool valid;
613 int ret;
614
615 _enter("{v={%llx:%llu} fl=%lx},%x",
616 vnode->fid.vid, vnode->fid.vnode, vnode->flags,
617 key_serial(key));
618
619 valid = afs_check_validity(vnode);
609 620
610 if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) 621 if (test_bit(AFS_VNODE_DELETED, &vnode->flags))
611 clear_nlink(&vnode->vfs_inode); 622 clear_nlink(&vnode->vfs_inode);
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index ca7edfe97410..54688f6ca9e5 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -1022,6 +1022,7 @@ extern struct inode *afs_iget(struct super_block *, struct key *,
1022 struct afs_cb_interest *, 1022 struct afs_cb_interest *,
1023 struct afs_vnode *); 1023 struct afs_vnode *);
1024extern void afs_zap_data(struct afs_vnode *); 1024extern void afs_zap_data(struct afs_vnode *);
1025extern bool afs_check_validity(struct afs_vnode *);
1025extern int afs_validate(struct afs_vnode *, struct key *); 1026extern int afs_validate(struct afs_vnode *, struct key *);
1026extern int afs_getattr(const struct path *, struct kstat *, u32, unsigned int); 1027extern int afs_getattr(const struct path *, struct kstat *, u32, unsigned int);
1027extern int afs_setattr(struct dentry *, struct iattr *); 1028extern int afs_setattr(struct dentry *, struct iattr *);