tree:
https://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux.git ceph-fscrypt
head: 6b3ebb239173120d2d62579b9d2a27a24c444a45
commit: 3b7f98c91a9e727c828e4e80b9543672e4439166 [38/39] ceph: add a helper for adjusting
offset and length
config: ia64-randconfig-s032-20210209 (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce:
wget
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O
~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-215-g0fb77bb6-dirty
#
https://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux.git/commit/...
git remote add jlayton
https://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux.git
git fetch --no-tags jlayton ceph-fscrypt
git checkout 3b7f98c91a9e727c828e4e80b9543672e4439166
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=ia64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All errors (new ones prefixed by >>):
In file included from arch/ia64/include/asm/pgtable.h:154,
from include/linux/pgtable.h:6,
from arch/ia64/include/asm/uaccess.h:40,
from include/linux/uaccess.h:11,
from include/linux/sched/task.h:11,
from include/linux/sched/signal.h:9,
from include/linux/rcuwait.h:6,
from include/linux/percpu-rwsem.h:7,
from include/linux/fs.h:33,
from include/linux/namei.h:5,
from fs/ceph/file.c:10:
arch/ia64/include/asm/mmu_context.h: In function 'reload_context':
arch/ia64/include/asm/mmu_context.h:127:41: warning: variable 'old_rr4' set but
not used [-Wunused-but-set-variable]
127 | unsigned long rr0, rr1, rr2, rr3, rr4, old_rr4;
| ^~~~~~~
In file included from <command-line>:
fs/ceph/file.c: At top level:
include/linux/compiler_types.h:298:2: error: expected identifier or '(' before
'do'
298 | do { \
| ^~
include/linux/compiler_types.h:308:2: note: in expansion of macro
'__compiletime_assert'
308 | __compiletime_assert(condition, msg, prefix, suffix)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:320:2: note: in expansion of macro
'_compiletime_assert'
320 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro
'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:50:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
| ^~~~~~~~~~~~~~~~
fs/ceph/file.c:27:1: note: in expansion of macro 'BUILD_BUG_ON'
27 | BUILD_BUG_ON(CEPH_FSCRYPT_BLOCK_SHIFT > PAGE_SHIFT);
| ^~~~~~~~~~~~
include/linux/compiler_types.h:302:4: error: expected identifier or '(' before
'while'
302 | } while (0)
| ^~~~~
include/linux/compiler_types.h:308:2: note: in expansion of macro
'__compiletime_assert'
308 | __compiletime_assert(condition, msg, prefix, suffix)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:320:2: note: in expansion of macro
'_compiletime_assert'
320 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro
'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:50:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
| ^~~~~~~~~~~~~~~~
fs/ceph/file.c:27:1: note: in expansion of macro 'BUILD_BUG_ON'
27 | BUILD_BUG_ON(CEPH_FSCRYPT_BLOCK_SHIFT > PAGE_SHIFT);
| ^~~~~~~~~~~~
fs/ceph/file.c: In function 'ceph_sync_read':
> fs/ceph/file.c:927:37: error: invalid type argument of unary
'*' (have 'u64' {aka 'long long unsigned int'})
927 |
fscrypt_adjust_off_and_len(inode, *read_off, *read_len);
| ^~~~~~~~~
fs/ceph/file.c:927:48: error: invalid type argument of unary '*' (have
'u64' {aka 'long long unsigned int'})
927 | fscrypt_adjust_off_and_len(inode, *read_off, *read_len);
| ^~~~~~~~~
vim +927 fs/ceph/file.c
874
875 /*
876 * Completely synchronous read and write methods. Direct from __user
877 * buffer to osd, or directly to user pages (if O_DIRECT).
878 *
879 * If the read spans object boundary, just do multiple reads. (That's not
880 * atomic, but good enough for now.)
881 *
882 * If we get a short result from the OSD, check against i_size; we need to
883 * only return a short read to the caller if we hit EOF.
884 */
885 static ssize_t ceph_sync_read(struct kiocb *iocb, struct iov_iter *to,
886 int *retry_op)
887 {
888 struct file *file = iocb->ki_filp;
889 struct inode *inode = file_inode(file);
890 struct ceph_inode_info *ci = ceph_inode(inode);
891 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
892 struct ceph_osd_client *osdc = &fsc->client->osdc;
893 ssize_t ret;
894 u64 off = iocb->ki_pos;
895 u64 len = iov_iter_count(to);
896
897 dout("sync_read on file %p %llu~%u %s\n", file, off, (unsigned)len,
898 (file->f_flags & O_DIRECT) ? "O_DIRECT" : "");
899
900 if (!len)
901 return 0;
902
903 /*
904 * flush any page cache pages in this range. this
905 * will make concurrent normal and sync io slow,
906 * but it will at least behave sensibly when they are
907 * in sequence.
908 */
909 ret = filemap_write_and_wait_range(inode->i_mapping,
910 off, off + len - 1);
911 if (ret < 0)
912 return ret;
913
914 ret = 0;
915 while ((len = iov_iter_count(to)) > 0) {
916 struct ceph_osd_request *req;
917 struct page **pages;
918 int num_pages;
919 size_t page_off;
920 u64 i_size;
921 bool more;
922 int idx;
923 size_t left;
924 u64 read_off = off;
925 u64 read_len = len;
926
927 fscrypt_adjust_off_and_len(inode, *read_off, *read_len);
928
929 /* determine new offset/length if encrypted */
930 req = ceph_osdc_new_request(osdc, &ci->i_layout,
931 ci->i_vino, read_off, &read_len, 0, 1,
932 CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ,
933 NULL, ci->i_truncate_seq,
934 ci->i_truncate_size, false);
935 if (IS_ERR(req)) {
936 ret = PTR_ERR(req);
937 break;
938 }
939
940 more = read_len < iov_iter_count(to);
941
942 num_pages = calc_pages_for(read_off, read_len);
943 page_off = read_off & ~PAGE_MASK;
944 pages = ceph_alloc_page_vector(num_pages, GFP_KERNEL);
945 if (IS_ERR(pages)) {
946 ceph_osdc_put_request(req);
947 ret = PTR_ERR(pages);
948 break;
949 }
950
951 osd_req_op_extent_osd_data_pages(req, 0, pages, read_len, page_off,
952 false, false);
953 ret = ceph_osdc_start_request(osdc, req, false);
954 if (!ret)
955 ret = ceph_osdc_wait_request(osdc, req);
956
957 ceph_update_read_latency(&fsc->mdsc->metric,
958 req->r_start_latency,
959 req->r_end_latency,
960 ret);
961
962 ceph_osdc_put_request(req);
963
964
965 if (IS_ENCRYPTED(inode)) {
966 int i;
967 int baseblk = read_off >> CEPH_FSCRYPT_BLOCK_SHIFT;
968 int num_blocks = ceph_fscrypt_blocks(read_off, read_len);
969
970 for (i = 0; i < num_blocks; ++i) {
971 int blkoff = i << CEPH_FSCRYPT_BLOCK_SHIFT;
972 int pgidx = blkoff >> PAGE_SHIFT;
973 unsigned int pgoffs = blkoff & ~PAGE_MASK;
974
975 ret = fscrypt_decrypt_block_inplace(inode, pages[pgidx],
976 CEPH_FSCRYPT_BLOCK_SIZE, pgoffs,
977 baseblk + i);
978 if (ret < 0) {
979 ceph_release_page_vector(pages, num_pages);
980 goto out;
981 }
982 }
983 }
984
985 i_size = i_size_read(inode);
986 dout("sync_read %llu~%llu got %zd i_size %llu%s\n",
987 off, len, ret, i_size, (more ? " MORE" : ""));
988
989 if (ret == -ENOENT)
990 ret = 0;
991
992 page_off = off & ~PAGE_MASK;
993 if (ret >= 0 && ret < len && (off + ret < i_size)) {
994 int zlen = min(len - ret, i_size - off - ret);
995 int zoff = page_off + ret;
996 dout("sync_read zero gap %llu~%llu\n",
997 off + ret, off + ret + zlen);
998 ceph_zero_page_vector_range(zoff, zlen, pages);
999 ret += zlen;
1000 }
1001
1002 idx = 0;
1003 left = ret > 0 ? ret : 0;
1004 while (left > 0) {
1005 size_t len, copied;
1006 page_off = off & ~PAGE_MASK;
1007 len = min_t(size_t, left, PAGE_SIZE - page_off);
1008 SetPageUptodate(pages[idx]);
1009 copied = copy_page_to_iter(pages[idx++],
1010 page_off, len, to);
1011 off += copied;
1012 left -= copied;
1013 if (copied < len) {
1014 ret = -EFAULT;
1015 ceph_release_page_vector(pages, num_pages);
1016 break;
1017 }
1018 }
1019 ceph_release_page_vector(pages, num_pages);
1020
1021 if (ret < 0) {
1022 if (ret == -EBLOCKLISTED)
1023 fsc->blocklisted = true;
1024 break;
1025 }
1026
1027 if (off >= i_size || !more)
1028 break;
1029 }
1030
1031 if (off > iocb->ki_pos) {
1032 if (ret >= 0 &&
1033 iov_iter_count(to) > 0 && off >= i_size_read(inode))
1034 *retry_op = CHECK_EOF;
1035 ret = off - iocb->ki_pos;
1036 iocb->ki_pos = off;
1037 }
1038 out:
1039 dout("sync_read result %zd retry_op %d\n", ret, *retry_op);
1040 return ret;
1041 }
1042
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org