Hi Konstantin, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on linus/master] [also build test WARNING on v5.9-rc6 next-20200925] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Konstantin-Komarov/NTFS-read-write-driver-GPL-implementation-by-Paragon-Software/20200925-235918 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 171d4ff79f965c1f164705ef0aaea102a6ad238b config: sh-allmodconfig (attached as .config) compiler: sh4-linux-gcc (GCC) 9.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/9b42f6a3e875b4a31a2487a7e6fcdeb464978834 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Konstantin-Komarov/NTFS-read-write-driver-GPL-implementation-by-Paragon-Software/20200925-235918 git checkout 9b42f6a3e875b4a31a2487a7e6fcdeb464978834 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sh If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All warnings (new ones prefixed by >>): fs/ntfs3/file.c: In function 'ntfs_filemap_close': >> fs/ntfs3/file.c:395:8: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] 395 | to = (loff_t)vma->vm_private_data; | ^ fs/ntfs3/file.c: In function 'ntfs_file_mmap': >> fs/ntfs3/file.c:530:26: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 530 | vma->vm_private_data = (void *)to; | ^ fs/ntfs3/file.c: In function 'ntfs_file_release': >> fs/ntfs3/file.c:1136:23: warning: variable 'sbi' set but not used [-Wunused-but-set-variable] 1136 | struct ntfs_sb_info *sbi; | ^~~ vim +395 fs/ntfs3/file.c 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 384 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 385 /* 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 386 * vm_operations_struct::close 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 387 */ 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 388 static void ntfs_filemap_close(struct vm_area_struct *vma) 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 389 { 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 390 struct inode *inode = file_inode(vma->vm_file); 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 391 struct ntfs_inode *ni = ntfs_i(inode); 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 392 loff_t to; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 393 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 394 if (sizeof(void *) >= sizeof(loff_t)) 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 @395 to = (loff_t)vma->vm_private_data; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 396 else 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 397 to = ((struct vma_cookie *)vma->vm_private_data)->to; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 398 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 399 // Update valid size 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 400 ni->i_valid = max_t(loff_t, ni->i_valid, 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 401 min_t(loff_t, i_size_read(inode), to)); 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 402 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 403 if (sizeof(void *) < sizeof(loff_t)) { 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 404 ntfs_free(vma->vm_private_data); 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 405 vma->vm_private_data = NULL; // is it necessary? 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 406 } 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 407 } 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 408 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 409 /* 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 410 * vm_operations_struct::fault 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 411 */ 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 412 static vm_fault_t ntfs_filemap_fault(struct vm_fault *vmf) 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 413 { 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 414 struct vm_area_struct *vma = vmf->vma; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 415 vm_fault_t ret; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 416 loff_t to, *vmc_to; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 417 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 418 ret = filemap_fault(vmf); 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 419 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 420 if (!(ret & VM_FAULT_LOCKED)) 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 421 return ret; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 422 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 423 /* Update maximum mapped range */ 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 424 to = (loff_t)(vmf->pgoff + 1) << PAGE_SHIFT; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 425 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 426 if (sizeof(void *) >= sizeof(loff_t)) 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 427 vmc_to = (loff_t *)&vma->vm_private_data; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 428 else 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 429 vmc_to = &((struct vma_cookie *)vma->vm_private_data)->to; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 430 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 431 if (*vmc_to < to) 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 432 *vmc_to = to; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 433 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 434 return ret; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 435 } 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 436 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 437 static const struct vm_operations_struct vma_cookie = { 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 438 .close = ntfs_filemap_close, 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 439 .fault = ntfs_filemap_fault, 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 440 .map_pages = filemap_map_pages, 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 441 .page_mkwrite = filemap_page_mkwrite, 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 442 }; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 443 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 444 /* 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 445 * file_operations::mmap 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 446 */ 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 447 static int ntfs_file_mmap(struct file *file, struct vm_area_struct *vma) 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 448 { 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 449 struct address_space *mapping = file->f_mapping; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 450 struct inode *inode = mapping->host; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 451 struct ntfs_inode *ni = ntfs_i(inode); 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 452 u64 to, from = ((u64)vma->vm_pgoff << PAGE_SHIFT); 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 453 bool rw = vma->vm_flags & VM_WRITE; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 454 int err; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 455 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 456 if (is_encrypted(ni)) { 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 457 err = -EOPNOTSUPP; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 458 goto out; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 459 } 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 460 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 461 if (!rw) { 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 462 err = generic_file_mmap(file, vma); 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 463 goto out; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 464 } 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 465 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 466 if (is_compressed(ni)) { 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 467 err = -EOPNOTSUPP; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 468 goto out; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 469 } 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 470 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 471 // map for write 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 472 inode_lock(inode); 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 473 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 474 to = from + vma->vm_end - vma->vm_start; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 475 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 476 if (to > inode->i_size) 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 477 to = inode->i_size; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 478 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 479 if (is_sparsed(ni)) { 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 480 /* allocate clusters for rw map */ 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 481 struct ntfs_sb_info *sbi = inode->i_sb->s_fs_info; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 482 CLST vcn, lcn, len; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 483 CLST end = bytes_to_cluster(sbi, to); 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 484 bool new; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 485 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 486 for (vcn = from >> sbi->cluster_bits; vcn < end; vcn += len) { 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 487 err = attr_data_get_block(ni, vcn, 1, &lcn, &len, &new); 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 488 if (err) { 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 489 inode_unlock(inode); 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 490 goto out; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 491 } 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 492 if (!new) 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 493 continue; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 494 ntfs_sparse_cluster(inode, NULL, 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 495 (u64)vcn << sbi->cluster_bits, 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 496 sbi->cluster_size); 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 497 } 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 498 } 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 499 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 500 err = ni->i_valid < to ? 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 501 ntfs_extend_initialized_size(file, ni, ni->i_valid, to) : 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 502 0; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 503 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 504 inode_unlock(inode); 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 505 if (err) 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 506 goto out; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 507 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 508 if (vma->vm_private_data) { 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 509 ntfs_inode_warn( 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 510 inode, 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 511 "mmap: failed to keep private vma_data, possible garbidge data"); 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 512 err = generic_file_mmap(file, vma); 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 513 goto out; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 514 } 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 515 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 516 if (!mapping->a_ops->readpage) { 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 517 err = -ENOEXEC; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 518 goto out; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 519 } 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 520 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 521 /* 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 522 * Allocate and init small struct to keep track the mapping operations 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 523 * It is useful when mmap(size) + truncate(size/2) + unmap(). see 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 524 * xfstests/generic/039 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 525 * 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 526 * TODO: if sizeof(void*) == 8 bytes we can store the only field 'to' 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 527 * of vma_cookie in vma->vm_private_data 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 528 */ 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 529 if (sizeof(void *) >= sizeof(loff_t)) 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 @530 vma->vm_private_data = (void *)to; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 531 else { 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 532 struct vma_cookie *vmc = 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 533 ntfs_alloc(sizeof(struct vma_cookie), 0); 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 534 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 535 if (unlikely(!vmc)) { 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 536 err = -ENOMEM; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 537 goto out; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 538 } 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 539 vmc->to = to; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 540 vma->vm_private_data = vmc; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 541 } 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 542 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 543 file_accessed(file); 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 544 vma->vm_ops = &vma_cookie; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 545 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 546 out: 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 547 return err; 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 548 } 1dcce9cfa1ccb04 Konstantin Komarov 2020-09-25 549 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org