tree: https://github.com/ceph/ceph-client.git testing head: 4c0447ba18613d13c10820958dd6b7a6cb2883ed commit: 4c0447ba18613d13c10820958dd6b7a6cb2883ed [4/4] ceph: refactor ceph_sync_read() config: i386-randconfig-x077-201838 (attached as .config) compiler: gcc-7 (Debian 7.3.0-1) 7.3.0 reproduce: git checkout 4c0447ba18613d13c10820958dd6b7a6cb2883ed # save the attached .config to linux build tree make ARCH=i386 All warnings (new ones prefixed by >>): In file included from include/linux/list.h:9:0, from include/linux/module.h:9, from fs//ceph/file.c:4: fs//ceph/file.c: In function 'ceph_sync_read': include/linux/kernel.h:845:29: warning: comparison of distinct pointer types lacks a cast (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) ^ include/linux/kernel.h:859:4: note: in expansion of macro '__typecheck' (__typecheck(x, y) && __no_side_effects(x, y)) ^~~~~~~~~~~ include/linux/kernel.h:869:24: note: in expansion of macro '__safe_cmp' __builtin_choose_expr(__safe_cmp(x, y), \ ^~~~~~~~~~ include/linux/kernel.h:878:19: note: in expansion of macro '__careful_cmp' #define min(x, y) __careful_cmp(x, y, <) ^~~~~~~~~~~~~ >> fs//ceph/file.c:674:11: note: in expansion of macro 'min' len = min(left, PAGE_SIZE - page_off); ^~~ vim +/min +674 fs//ceph/file.c 558 559 /* 560 * Completely synchronous read and write methods. Direct from __user 561 * buffer to osd, or directly to user pages (if O_DIRECT). 562 * 563 * If the read spans object boundary, just do multiple reads. 564 */ 565 static ssize_t ceph_sync_read(struct kiocb *iocb, struct iov_iter *to, 566 int *retry_op) 567 { 568 struct file *file = iocb->ki_filp; 569 struct inode *inode = file_inode(file); 570 struct ceph_inode_info *ci = ceph_inode(inode); 571 struct ceph_fs_client *fsc = ceph_inode_to_client(inode); 572 struct ceph_osd_client *osdc = &fsc->client->osdc; 573 ssize_t ret; 574 u64 off = iocb->ki_pos; 575 u64 len = iov_iter_count(to); 576 577 dout("sync_read on file %p %llu~%u %s\n", file, off, (unsigned)len, 578 (file->f_flags & O_DIRECT) ? "O_DIRECT" : ""); 579 580 if (!len) 581 return 0; 582 /* 583 * flush any page cache pages in this range. this 584 * will make concurrent normal and sync io slow, 585 * but it will at least behave sensibly when they are 586 * in sequence. 587 */ 588 ret = filemap_write_and_wait_range(inode->i_mapping, off, off + len); 589 if (ret < 0) 590 return ret; 591 592 ret = 0; 593 while ((len = iov_iter_count(to)) > 0) { 594 struct ceph_osd_request *req; 595 struct page **pages; 596 int num_pages; 597 size_t page_off; 598 u64 i_size; 599 bool more; 600 601 req = ceph_osdc_new_request(osdc, &ci->i_layout, 602 ci->i_vino, off, &len, 0, 1, 603 CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ, 604 NULL, ci->i_truncate_seq, 605 ci->i_truncate_size, false); 606 if (IS_ERR(req)) { 607 ret = PTR_ERR(req); 608 break; 609 } 610 611 more = len < iov_iter_count(to); 612 613 if (unlikely(to->type & ITER_PIPE)) { 614 ret = iov_iter_get_pages_alloc(to, &pages, len, 615 &page_off); 616 if (ret <= 0) { 617 ceph_osdc_put_request(req); 618 ret = -ENOMEM; 619 break; 620 } 621 num_pages = DIV_ROUND_UP(ret + page_off, PAGE_SIZE); 622 if (ret < len) { 623 len = ret; 624 osd_req_op_extent_update(req, 0, len); 625 more = false; 626 } 627 } else { 628 num_pages = calc_pages_for(off, len); 629 page_off = off & ~PAGE_MASK; 630 pages = ceph_alloc_page_vector(num_pages, GFP_KERNEL); 631 if (IS_ERR(pages)) { 632 ceph_osdc_put_request(req); 633 ret = PTR_ERR(pages); 634 break; 635 } 636 } 637 638 osd_req_op_extent_osd_data_pages(req, 0, pages, len, page_off, 639 false, false); 640 ret = ceph_osdc_start_request(osdc, req, false); 641 if (!ret) 642 ret = ceph_osdc_wait_request(osdc, req); 643 ceph_osdc_put_request(req); 644 645 i_size = i_size_read(inode); 646 dout("sync_read %llu~%llu got %zd i_size %llu%s\n", 647 off, len, ret, i_size, (more ? " MORE" : "")); 648 649 if (ret == -ENOENT) 650 ret = 0; 651 if (ret >= 0 && ret < len && (off + ret < i_size)) { 652 int zlen = min(len - ret, i_size - off - ret); 653 int zoff = page_off + ret; 654 dout("sync_read zero gap %llu~%llu\n", 655 off + ret, off + ret + zlen); 656 ceph_zero_page_vector_range(zoff, zlen, pages); 657 ret += zlen; 658 } 659 660 if (unlikely(to->type & ITER_PIPE)) { 661 if (ret > 0) { 662 iov_iter_advance(to, ret); 663 off += ret; 664 } else { 665 iov_iter_advance(to, 0); 666 } 667 ceph_put_page_vector(pages, num_pages, false); 668 } else { 669 int idx = 0; 670 size_t left = ret > 0 ? ret : 0; 671 while (left > 0) { 672 size_t len, copied; 673 page_off = off & ~PAGE_MASK; > 674 len = min(left, PAGE_SIZE - page_off); 675 copied = copy_page_to_iter(pages[idx++], 676 page_off, len, to); 677 off += copied; 678 left -= copied; 679 if (copied < len) { 680 ret = -EFAULT; 681 break; 682 } 683 } 684 ceph_release_page_vector(pages, num_pages); 685 } 686 687 if (ret <= 0 || off >= i_size || !more) 688 break; 689 } 690 691 if (off > iocb->ki_pos) { 692 if (ret >= 0 && 693 iov_iter_count(to) > 0 && off >= i_size_read(inode)) 694 *retry_op = CHECK_EOF; 695 ret = off - iocb->ki_pos; 696 iocb->ki_pos = off; 697 } 698 699 dout("sync_read result %zd retry_op %d\n", ret, *retry_op); 700 return ret; 701 } 702 --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
Attachment:
.config.gz
Description: application/gzip