summaryrefslogtreecommitdiffstats
path: root/fs/notify
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2019-01-10 12:04:39 -0500
committerJan Kara <jack@suse.cz>2019-02-07 10:38:35 -0500
commit73072283a249c798838e09813760db8bcdd9cd3a (patch)
treefed1224b11dece26dc6a183da16e2ddb119d2526 /fs/notify
parentec86ff5689ff9605e2d57e016098764ad9a2fee5 (diff)
fanotify: use vfs_get_fsid() helper instead of vfs_statfs()
This is a cleanup that doesn't change any logic. Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/notify')
-rw-r--r--fs/notify/fanotify/fanotify_user.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 603419ce096f..396de6edad2b 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -863,35 +863,31 @@ out_destroy_group:
863} 863}
864 864
865/* Check if filesystem can encode a unique fid */ 865/* Check if filesystem can encode a unique fid */
866static int fanotify_test_fid(struct path *path, struct kstatfs *stat) 866static int fanotify_test_fid(struct path *path, __kernel_fsid_t *fsid)
867{ 867{
868 struct kstatfs root_stat; 868 __kernel_fsid_t root_fsid;
869 struct path root = {
870 .mnt = path->mnt,
871 .dentry = path->dentry->d_sb->s_root,
872 };
873 int err; 869 int err;
874 870
875 /* 871 /*
876 * Make sure path is not in filesystem with zero fsid (e.g. tmpfs). 872 * Make sure path is not in filesystem with zero fsid (e.g. tmpfs).
877 */ 873 */
878 err = vfs_statfs(path, stat); 874 err = vfs_get_fsid(path->dentry, fsid);
879 if (err) 875 if (err)
880 return err; 876 return err;
881 877
882 if (!stat->f_fsid.val[0] && !stat->f_fsid.val[1]) 878 if (!fsid->val[0] && !fsid->val[1])
883 return -ENODEV; 879 return -ENODEV;
884 880
885 /* 881 /*
886 * Make sure path is not inside a filesystem subvolume (e.g. btrfs) 882 * Make sure path is not inside a filesystem subvolume (e.g. btrfs)
887 * which uses a different fsid than sb root. 883 * which uses a different fsid than sb root.
888 */ 884 */
889 err = vfs_statfs(&root, &root_stat); 885 err = vfs_get_fsid(path->dentry->d_sb->s_root, &root_fsid);
890 if (err) 886 if (err)
891 return err; 887 return err;
892 888
893 if (root_stat.f_fsid.val[0] != stat->f_fsid.val[0] || 889 if (root_fsid.val[0] != fsid->val[0] ||
894 root_stat.f_fsid.val[1] != stat->f_fsid.val[1]) 890 root_fsid.val[1] != fsid->val[1])
895 return -EXDEV; 891 return -EXDEV;
896 892
897 /* 893 /*
@@ -916,8 +912,7 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
916 struct fsnotify_group *group; 912 struct fsnotify_group *group;
917 struct fd f; 913 struct fd f;
918 struct path path; 914 struct path path;
919 struct kstatfs stat; 915 __kernel_fsid_t __fsid, *fsid = NULL;
920 __kernel_fsid_t *fsid = NULL;
921 u32 valid_mask = FANOTIFY_EVENTS | FANOTIFY_EVENT_FLAGS; 916 u32 valid_mask = FANOTIFY_EVENTS | FANOTIFY_EVENT_FLAGS;
922 unsigned int mark_type = flags & FANOTIFY_MARK_TYPE_BITS; 917 unsigned int mark_type = flags & FANOTIFY_MARK_TYPE_BITS;
923 int ret; 918 int ret;
@@ -996,11 +991,11 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
996 goto fput_and_out; 991 goto fput_and_out;
997 992
998 if (FAN_GROUP_FLAG(group, FAN_REPORT_FID)) { 993 if (FAN_GROUP_FLAG(group, FAN_REPORT_FID)) {
999 ret = fanotify_test_fid(&path, &stat); 994 ret = fanotify_test_fid(&path, &__fsid);
1000 if (ret) 995 if (ret)
1001 goto path_put_and_out; 996 goto path_put_and_out;
1002 997
1003 fsid = &stat.f_fsid; 998 fsid = &__fsid;
1004 } 999 }
1005 1000
1006 /* inode held in place by reference to path; group by fget on fd */ 1001 /* inode held in place by reference to path; group by fget on fd */