CC: [email protected] CC: [email protected] TO: Vivek Goyal <[email protected]> CC: Miklos Szeredi <[email protected]> CC: Liu Bo <[email protected]>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 9ccce092fc64d19504fa54de4fd659e279cc92e7 commit: 9a752d18c85ae5da28e4a07d52adfd95eacb2495 virtiofs: add logic to free up a memory range date: 8 months ago :::::: branch date: 18 hours ago :::::: commit date: 8 months ago config: i386-randconfig-m031-20210503 (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> New smatch warnings: fs/fuse/dax.c:875 dmap_writeback_invalidate() warn: should 'dmap->itn.start << 21' be a 64 bit type? fs/fuse/dax.c:969 inode_inline_reclaim_one_dmap() warn: should 'start_idx << 21' be a 64 bit type? fs/fuse/dax.c:1121 lookup_and_reclaim_dmap() warn: should 'start_idx << 21' be a 64 bit type? Old smatch warnings: fs/fuse/dax.c:189 fuse_setup_one_mapping() warn: should 'start_idx << 21' be a 64 bit type? fs/fuse/dax.c:283 dmap_removemapping_list() error: uninitialized symbol 'ret'. vim +875 fs/fuse/dax.c 2a9a609a0c4a3b Stefan Hajnoczi 2020-08-19 870 9a752d18c85ae5 Vivek Goyal 2020-08-19 871 static int dmap_writeback_invalidate(struct inode *inode, 9a752d18c85ae5 Vivek Goyal 2020-08-19 872 struct fuse_dax_mapping *dmap) 9a752d18c85ae5 Vivek Goyal 2020-08-19 873 { 9a752d18c85ae5 Vivek Goyal 2020-08-19 874 int ret; 9a752d18c85ae5 Vivek Goyal 2020-08-19 @875 loff_t start_pos = dmap->itn.start << FUSE_DAX_SHIFT; 9a752d18c85ae5 Vivek Goyal 2020-08-19 876 loff_t end_pos = (start_pos + FUSE_DAX_SZ - 1); 9a752d18c85ae5 Vivek Goyal 2020-08-19 877 9a752d18c85ae5 Vivek Goyal 2020-08-19 878 ret = filemap_fdatawrite_range(inode->i_mapping, start_pos, end_pos); 9a752d18c85ae5 Vivek Goyal 2020-08-19 879 if (ret) { 9a752d18c85ae5 Vivek Goyal 2020-08-19 880 pr_debug("fuse: filemap_fdatawrite_range() failed. err=%d start_pos=0x%llx, end_pos=0x%llx\n", 9a752d18c85ae5 Vivek Goyal 2020-08-19 881 ret, start_pos, end_pos); 9a752d18c85ae5 Vivek Goyal 2020-08-19 882 return ret; 9a752d18c85ae5 Vivek Goyal 2020-08-19 883 } 9a752d18c85ae5 Vivek Goyal 2020-08-19 884 9a752d18c85ae5 Vivek Goyal 2020-08-19 885 ret = invalidate_inode_pages2_range(inode->i_mapping, 9a752d18c85ae5 Vivek Goyal 2020-08-19 886 start_pos >> PAGE_SHIFT, 9a752d18c85ae5 Vivek Goyal 2020-08-19 887 end_pos >> PAGE_SHIFT); 9a752d18c85ae5 Vivek Goyal 2020-08-19 888 if (ret) 9a752d18c85ae5 Vivek Goyal 2020-08-19 889 pr_debug("fuse: invalidate_inode_pages2_range() failed err=%d\n", 9a752d18c85ae5 Vivek Goyal 2020-08-19 890 ret); 9a752d18c85ae5 Vivek Goyal 2020-08-19 891 9a752d18c85ae5 Vivek Goyal 2020-08-19 892 return ret; 9a752d18c85ae5 Vivek Goyal 2020-08-19 893 } 9a752d18c85ae5 Vivek Goyal 2020-08-19 894 9a752d18c85ae5 Vivek Goyal 2020-08-19 895 static int reclaim_one_dmap_locked(struct inode *inode, 9a752d18c85ae5 Vivek Goyal 2020-08-19 896 struct fuse_dax_mapping *dmap) 9a752d18c85ae5 Vivek Goyal 2020-08-19 897 { 9a752d18c85ae5 Vivek Goyal 2020-08-19 898 int ret; 9a752d18c85ae5 Vivek Goyal 2020-08-19 899 struct fuse_inode *fi = get_fuse_inode(inode); 9a752d18c85ae5 Vivek Goyal 2020-08-19 900 9a752d18c85ae5 Vivek Goyal 2020-08-19 901 /* 9a752d18c85ae5 Vivek Goyal 2020-08-19 902 * igrab() was done to make sure inode won't go under us, and this 9a752d18c85ae5 Vivek Goyal 2020-08-19 903 * further avoids the race with evict(). 9a752d18c85ae5 Vivek Goyal 2020-08-19 904 */ 9a752d18c85ae5 Vivek Goyal 2020-08-19 905 ret = dmap_writeback_invalidate(inode, dmap); 9a752d18c85ae5 Vivek Goyal 2020-08-19 906 if (ret) 9a752d18c85ae5 Vivek Goyal 2020-08-19 907 return ret; 9a752d18c85ae5 Vivek Goyal 2020-08-19 908 9a752d18c85ae5 Vivek Goyal 2020-08-19 909 /* Remove dax mapping from inode interval tree now */ 9a752d18c85ae5 Vivek Goyal 2020-08-19 910 interval_tree_remove(&dmap->itn, &fi->dax->tree); 9a752d18c85ae5 Vivek Goyal 2020-08-19 911 fi->dax->nr--; 9a752d18c85ae5 Vivek Goyal 2020-08-19 912 9a752d18c85ae5 Vivek Goyal 2020-08-19 913 /* It is possible that umount/shutdown has killed the fuse connection 9a752d18c85ae5 Vivek Goyal 2020-08-19 914 * and worker thread is trying to reclaim memory in parallel. Don't 9a752d18c85ae5 Vivek Goyal 2020-08-19 915 * warn in that case. 9a752d18c85ae5 Vivek Goyal 2020-08-19 916 */ 9a752d18c85ae5 Vivek Goyal 2020-08-19 917 ret = dmap_removemapping_one(inode, dmap); 9a752d18c85ae5 Vivek Goyal 2020-08-19 918 if (ret && ret != -ENOTCONN) { 9a752d18c85ae5 Vivek Goyal 2020-08-19 919 pr_warn("Failed to remove mapping. offset=0x%llx len=0x%llx ret=%d\n", 9a752d18c85ae5 Vivek Goyal 2020-08-19 920 dmap->window_offset, dmap->length, ret); 9a752d18c85ae5 Vivek Goyal 2020-08-19 921 } 9a752d18c85ae5 Vivek Goyal 2020-08-19 922 return 0; 9a752d18c85ae5 Vivek Goyal 2020-08-19 923 } 9a752d18c85ae5 Vivek Goyal 2020-08-19 924 9a752d18c85ae5 Vivek Goyal 2020-08-19 925 /* Find first mapped dmap for an inode and return file offset. Caller needs 9a752d18c85ae5 Vivek Goyal 2020-08-19 926 * to hold fi->dax->sem lock either shared or exclusive. 9a752d18c85ae5 Vivek Goyal 2020-08-19 927 */ 9a752d18c85ae5 Vivek Goyal 2020-08-19 928 static struct fuse_dax_mapping *inode_lookup_first_dmap(struct inode *inode) 9a752d18c85ae5 Vivek Goyal 2020-08-19 929 { 9a752d18c85ae5 Vivek Goyal 2020-08-19 930 struct fuse_inode *fi = get_fuse_inode(inode); 9a752d18c85ae5 Vivek Goyal 2020-08-19 931 struct fuse_dax_mapping *dmap; 9a752d18c85ae5 Vivek Goyal 2020-08-19 932 struct interval_tree_node *node; 9a752d18c85ae5 Vivek Goyal 2020-08-19 933 9a752d18c85ae5 Vivek Goyal 2020-08-19 934 for (node = interval_tree_iter_first(&fi->dax->tree, 0, -1); node; 9a752d18c85ae5 Vivek Goyal 2020-08-19 935 node = interval_tree_iter_next(node, 0, -1)) { 9a752d18c85ae5 Vivek Goyal 2020-08-19 936 dmap = node_to_dmap(node); 9a752d18c85ae5 Vivek Goyal 2020-08-19 937 /* still in use. */ 9a752d18c85ae5 Vivek Goyal 2020-08-19 938 if (refcount_read(&dmap->refcnt) > 1) 9a752d18c85ae5 Vivek Goyal 2020-08-19 939 continue; 9a752d18c85ae5 Vivek Goyal 2020-08-19 940 9a752d18c85ae5 Vivek Goyal 2020-08-19 941 return dmap; 9a752d18c85ae5 Vivek Goyal 2020-08-19 942 } 9a752d18c85ae5 Vivek Goyal 2020-08-19 943 9a752d18c85ae5 Vivek Goyal 2020-08-19 944 return NULL; 9a752d18c85ae5 Vivek Goyal 2020-08-19 945 } 9a752d18c85ae5 Vivek Goyal 2020-08-19 946 9a752d18c85ae5 Vivek Goyal 2020-08-19 947 /* 9a752d18c85ae5 Vivek Goyal 2020-08-19 948 * Find first mapping in the tree and free it and return it. Do not add 9a752d18c85ae5 Vivek Goyal 2020-08-19 949 * it back to free pool. 9a752d18c85ae5 Vivek Goyal 2020-08-19 950 */ 9a752d18c85ae5 Vivek Goyal 2020-08-19 951 static struct fuse_dax_mapping * 9a752d18c85ae5 Vivek Goyal 2020-08-19 952 inode_inline_reclaim_one_dmap(struct fuse_conn_dax *fcd, struct inode *inode, 9a752d18c85ae5 Vivek Goyal 2020-08-19 953 bool *retry) 9a752d18c85ae5 Vivek Goyal 2020-08-19 954 { 9a752d18c85ae5 Vivek Goyal 2020-08-19 955 struct fuse_inode *fi = get_fuse_inode(inode); 9a752d18c85ae5 Vivek Goyal 2020-08-19 956 struct fuse_dax_mapping *dmap; 9a752d18c85ae5 Vivek Goyal 2020-08-19 957 u64 dmap_start, dmap_end; 9a752d18c85ae5 Vivek Goyal 2020-08-19 958 unsigned long start_idx; 9a752d18c85ae5 Vivek Goyal 2020-08-19 959 int ret; 9a752d18c85ae5 Vivek Goyal 2020-08-19 960 struct interval_tree_node *node; 9a752d18c85ae5 Vivek Goyal 2020-08-19 961 9a752d18c85ae5 Vivek Goyal 2020-08-19 962 down_write(&fi->i_mmap_sem); 9a752d18c85ae5 Vivek Goyal 2020-08-19 963 9a752d18c85ae5 Vivek Goyal 2020-08-19 964 /* Lookup a dmap and corresponding file offset to reclaim. */ 9a752d18c85ae5 Vivek Goyal 2020-08-19 965 down_read(&fi->dax->sem); 9a752d18c85ae5 Vivek Goyal 2020-08-19 966 dmap = inode_lookup_first_dmap(inode); 9a752d18c85ae5 Vivek Goyal 2020-08-19 967 if (dmap) { 9a752d18c85ae5 Vivek Goyal 2020-08-19 968 start_idx = dmap->itn.start; 9a752d18c85ae5 Vivek Goyal 2020-08-19 @969 dmap_start = start_idx << FUSE_DAX_SHIFT; 9a752d18c85ae5 Vivek Goyal 2020-08-19 970 dmap_end = dmap_start + FUSE_DAX_SZ - 1; 9a752d18c85ae5 Vivek Goyal 2020-08-19 971 } 9a752d18c85ae5 Vivek Goyal 2020-08-19 972 up_read(&fi->dax->sem); 9a752d18c85ae5 Vivek Goyal 2020-08-19 973 9a752d18c85ae5 Vivek Goyal 2020-08-19 974 if (!dmap) 9a752d18c85ae5 Vivek Goyal 2020-08-19 975 goto out_mmap_sem; 9a752d18c85ae5 Vivek Goyal 2020-08-19 976 /* 9a752d18c85ae5 Vivek Goyal 2020-08-19 977 * Make sure there are no references to inode pages using 9a752d18c85ae5 Vivek Goyal 2020-08-19 978 * get_user_pages() 9a752d18c85ae5 Vivek Goyal 2020-08-19 979 */ 9a752d18c85ae5 Vivek Goyal 2020-08-19 980 ret = fuse_dax_break_layouts(inode, dmap_start, dmap_end); 9a752d18c85ae5 Vivek Goyal 2020-08-19 981 if (ret) { 9a752d18c85ae5 Vivek Goyal 2020-08-19 982 pr_debug("fuse: fuse_dax_break_layouts() failed. err=%d\n", 9a752d18c85ae5 Vivek Goyal 2020-08-19 983 ret); 9a752d18c85ae5 Vivek Goyal 2020-08-19 984 dmap = ERR_PTR(ret); 9a752d18c85ae5 Vivek Goyal 2020-08-19 985 goto out_mmap_sem; 9a752d18c85ae5 Vivek Goyal 2020-08-19 986 } 9a752d18c85ae5 Vivek Goyal 2020-08-19 987 9a752d18c85ae5 Vivek Goyal 2020-08-19 988 down_write(&fi->dax->sem); 9a752d18c85ae5 Vivek Goyal 2020-08-19 989 node = interval_tree_iter_first(&fi->dax->tree, start_idx, start_idx); 9a752d18c85ae5 Vivek Goyal 2020-08-19 990 /* Range already got reclaimed by somebody else */ 9a752d18c85ae5 Vivek Goyal 2020-08-19 991 if (!node) { 9a752d18c85ae5 Vivek Goyal 2020-08-19 992 if (retry) 9a752d18c85ae5 Vivek Goyal 2020-08-19 993 *retry = true; 9a752d18c85ae5 Vivek Goyal 2020-08-19 994 goto out_write_dmap_sem; 9a752d18c85ae5 Vivek Goyal 2020-08-19 995 } 9a752d18c85ae5 Vivek Goyal 2020-08-19 996 9a752d18c85ae5 Vivek Goyal 2020-08-19 997 dmap = node_to_dmap(node); 9a752d18c85ae5 Vivek Goyal 2020-08-19 998 /* still in use. */ 9a752d18c85ae5 Vivek Goyal 2020-08-19 999 if (refcount_read(&dmap->refcnt) > 1) { 9a752d18c85ae5 Vivek Goyal 2020-08-19 1000 dmap = NULL; 9a752d18c85ae5 Vivek Goyal 2020-08-19 1001 if (retry) 9a752d18c85ae5 Vivek Goyal 2020-08-19 1002 *retry = true; 9a752d18c85ae5 Vivek Goyal 2020-08-19 1003 goto out_write_dmap_sem; 9a752d18c85ae5 Vivek Goyal 2020-08-19 1004 } 9a752d18c85ae5 Vivek Goyal 2020-08-19 1005 9a752d18c85ae5 Vivek Goyal 2020-08-19 1006 ret = reclaim_one_dmap_locked(inode, dmap); 9a752d18c85ae5 Vivek Goyal 2020-08-19 1007 if (ret < 0) { 9a752d18c85ae5 Vivek Goyal 2020-08-19 1008 dmap = ERR_PTR(ret); 9a752d18c85ae5 Vivek Goyal 2020-08-19 1009 goto out_write_dmap_sem; 9a752d18c85ae5 Vivek Goyal 2020-08-19 1010 } 9a752d18c85ae5 Vivek Goyal 2020-08-19 1011 9a752d18c85ae5 Vivek Goyal 2020-08-19 1012 /* Clean up dmap. Do not add back to free list */ 9a752d18c85ae5 Vivek Goyal 2020-08-19 1013 dmap_remove_busy_list(fcd, dmap); 9a752d18c85ae5 Vivek Goyal 2020-08-19 1014 dmap->inode = NULL; 9a752d18c85ae5 Vivek Goyal 2020-08-19 1015 dmap->itn.start = dmap->itn.last = 0; 9a752d18c85ae5 Vivek Goyal 2020-08-19 1016 9a752d18c85ae5 Vivek Goyal 2020-08-19 1017 pr_debug("fuse: %s: inline reclaimed memory range. inode=%p, window_offset=0x%llx, length=0x%llx\n", 9a752d18c85ae5 Vivek Goyal 2020-08-19 1018 __func__, inode, dmap->window_offset, dmap->length); 9a752d18c85ae5 Vivek Goyal 2020-08-19 1019 9a752d18c85ae5 Vivek Goyal 2020-08-19 1020 out_write_dmap_sem: 9a752d18c85ae5 Vivek Goyal 2020-08-19 1021 up_write(&fi->dax->sem); 9a752d18c85ae5 Vivek Goyal 2020-08-19 1022 out_mmap_sem: 9a752d18c85ae5 Vivek Goyal 2020-08-19 1023 up_write(&fi->i_mmap_sem); 9a752d18c85ae5 Vivek Goyal 2020-08-19 1024 return dmap; 9a752d18c85ae5 Vivek Goyal 2020-08-19 1025 } 9a752d18c85ae5 Vivek Goyal 2020-08-19 1026 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/[email protected]
.config.gz
Description: application/gzip
_______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
