Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'vfs-6.9-rc6.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs

Pull vfs fixes from Christian Brauner:
"This contains a few small fixes for this merge window and the attempt
to handle the ntfs removal regression that was reported a little while
ago:

- After the removal of the legacy ntfs driver we received reports
about regressions for some people that do mount "ntfs" explicitly
and expect the driver to be available. Since ntfs3 is a drop-in for
legacy ntfs we alias legacy ntfs to ntfs3 just like ext3 is aliased
to ext4.

We also enforce legacy ntfs is always mounted read-only and give it
custom file operations to ensure that ioctl()'s can't be abused to
perform write operations.

- Fix an unbalanced module_get() in bdev_open().

- Two smaller fixes for the netfs work done earlier in this cycle.

- Fix the errno returned from the new FS_IOC_GETUUID and
FS_IOC_GETFSSYSFSPATH ioctls. Both commands just pull information
out of the superblock so there's no need to call into the actual
ioctl handlers.

So instead of returning ENOIOCTLCMD to indicate to fallback we just
return ENOTTY directly avoiding that indirection"

* tag 'vfs-6.9-rc6.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs:
netfs: Fix the pre-flush when appending to a file in writethrough mode
netfs: Fix writethrough-mode error handling
ntfs3: add legacy ntfs file operations
ntfs3: enforce read-only when used as legacy ntfs driver
ntfs3: serve as alias for the legacy ntfs driver
block: fix module reference leakage from bdev_open_by_dev error path
fs: Return ENOTTY directly if FS_IOC_GETUUID or FS_IOC_GETFSSYSFSPATH fail

+121 -21
+1 -1
block/bdev.c
··· 882 882 goto abort_claiming; 883 883 ret = -EBUSY; 884 884 if (!bdev_may_open(bdev, mode)) 885 - goto abort_claiming; 885 + goto put_module; 886 886 if (bdev_is_partition(bdev)) 887 887 ret = blkdev_get_part(bdev, mode); 888 888 else
+2 -2
fs/ioctl.c
··· 769 769 struct fsuuid2 u = { .len = sb->s_uuid_len, }; 770 770 771 771 if (!sb->s_uuid_len) 772 - return -ENOIOCTLCMD; 772 + return -ENOTTY; 773 773 774 774 memcpy(&u.uuid[0], &sb->s_uuid, sb->s_uuid_len); 775 775 ··· 781 781 struct super_block *sb = file_inode(file)->i_sb; 782 782 783 783 if (!strlen(sb->s_sysfs_name)) 784 - return -ENOIOCTLCMD; 784 + return -ENOTTY; 785 785 786 786 struct fs_sysfs_path u = {}; 787 787
+12 -11
fs/netfs/buffered_write.c
··· 164 164 enum netfs_how_to_modify howto; 165 165 enum netfs_folio_trace trace; 166 166 unsigned int bdp_flags = (iocb->ki_flags & IOCB_SYNC) ? 0: BDP_ASYNC; 167 - ssize_t written = 0, ret; 167 + ssize_t written = 0, ret, ret2; 168 168 loff_t i_size, pos = iocb->ki_pos, from, to; 169 169 size_t max_chunk = PAGE_SIZE << MAX_PAGECACHE_ORDER; 170 170 bool maybe_trouble = false; ··· 172 172 if (unlikely(test_bit(NETFS_ICTX_WRITETHROUGH, &ctx->flags) || 173 173 iocb->ki_flags & (IOCB_DSYNC | IOCB_SYNC)) 174 174 ) { 175 - if (pos < i_size_read(inode)) { 176 - ret = filemap_write_and_wait_range(mapping, pos, pos + iter->count); 177 - if (ret < 0) { 178 - goto out; 179 - } 180 - } 181 - 182 175 wbc_attach_fdatawrite_inode(&wbc, mapping->host); 176 + 177 + ret = filemap_write_and_wait_range(mapping, pos, pos + iter->count); 178 + if (ret < 0) { 179 + wbc_detach_inode(&wbc); 180 + goto out; 181 + } 183 182 184 183 wreq = netfs_begin_writethrough(iocb, iter->count); 185 184 if (IS_ERR(wreq)) { ··· 394 395 395 396 out: 396 397 if (unlikely(wreq)) { 397 - ret = netfs_end_writethrough(wreq, iocb); 398 + ret2 = netfs_end_writethrough(wreq, iocb); 398 399 wbc_detach_inode(&wbc); 399 - if (ret == -EIOCBQUEUED) 400 - return ret; 400 + if (ret2 == -EIOCBQUEUED) 401 + return ret2; 402 + if (ret == 0) 403 + ret = ret2; 401 404 } 402 405 403 406 iocb->ki_pos += written;
+9
fs/ntfs3/Kconfig
··· 46 46 NOTE: this is linux only feature. Windows will ignore these ACLs. 47 47 48 48 If you don't know what Access Control Lists are, say N. 49 + 50 + config NTFS_FS 51 + tristate "NTFS file system support" 52 + select NTFS3_FS 53 + select BUFFER_HEAD 54 + select NLS 55 + help 56 + This config option is here only for backward compatibility. NTFS 57 + filesystem is now handled by the NTFS3 driver.
+7
fs/ntfs3/dir.c
··· 616 616 .compat_ioctl = ntfs_compat_ioctl, 617 617 #endif 618 618 }; 619 + 620 + const struct file_operations ntfs_legacy_dir_operations = { 621 + .llseek = generic_file_llseek, 622 + .read = generic_read_dir, 623 + .iterate_shared = ntfs_readdir, 624 + .open = ntfs_file_open, 625 + }; 619 626 // clang-format on
+8
fs/ntfs3/file.c
··· 1236 1236 .fallocate = ntfs_fallocate, 1237 1237 .release = ntfs_file_release, 1238 1238 }; 1239 + 1240 + const struct file_operations ntfs_legacy_file_operations = { 1241 + .llseek = generic_file_llseek, 1242 + .read_iter = ntfs_file_read_iter, 1243 + .splice_read = ntfs_file_splice_read, 1244 + .open = ntfs_file_open, 1245 + .release = ntfs_file_release, 1246 + }; 1239 1247 // clang-format on
+16 -4
fs/ntfs3/inode.c
··· 440 440 * Usually a hard links to directories are disabled. 441 441 */ 442 442 inode->i_op = &ntfs_dir_inode_operations; 443 - inode->i_fop = &ntfs_dir_operations; 443 + if (is_legacy_ntfs(inode->i_sb)) 444 + inode->i_fop = &ntfs_legacy_dir_operations; 445 + else 446 + inode->i_fop = &ntfs_dir_operations; 444 447 ni->i_valid = 0; 445 448 } else if (S_ISLNK(mode)) { 446 449 ni->std_fa &= ~FILE_ATTRIBUTE_DIRECTORY; ··· 453 450 } else if (S_ISREG(mode)) { 454 451 ni->std_fa &= ~FILE_ATTRIBUTE_DIRECTORY; 455 452 inode->i_op = &ntfs_file_inode_operations; 456 - inode->i_fop = &ntfs_file_operations; 453 + if (is_legacy_ntfs(inode->i_sb)) 454 + inode->i_fop = &ntfs_legacy_file_operations; 455 + else 456 + inode->i_fop = &ntfs_file_operations; 457 457 inode->i_mapping->a_ops = is_compressed(ni) ? &ntfs_aops_cmpr : 458 458 &ntfs_aops; 459 459 if (ino != MFT_REC_MFT) ··· 1620 1614 1621 1615 if (S_ISDIR(mode)) { 1622 1616 inode->i_op = &ntfs_dir_inode_operations; 1623 - inode->i_fop = &ntfs_dir_operations; 1617 + if (is_legacy_ntfs(inode->i_sb)) 1618 + inode->i_fop = &ntfs_legacy_dir_operations; 1619 + else 1620 + inode->i_fop = &ntfs_dir_operations; 1624 1621 } else if (S_ISLNK(mode)) { 1625 1622 inode->i_op = &ntfs_link_inode_operations; 1626 1623 inode->i_fop = NULL; ··· 1632 1623 inode_nohighmem(inode); 1633 1624 } else if (S_ISREG(mode)) { 1634 1625 inode->i_op = &ntfs_file_inode_operations; 1635 - inode->i_fop = &ntfs_file_operations; 1626 + if (is_legacy_ntfs(inode->i_sb)) 1627 + inode->i_fop = &ntfs_legacy_file_operations; 1628 + else 1629 + inode->i_fop = &ntfs_file_operations; 1636 1630 inode->i_mapping->a_ops = is_compressed(ni) ? &ntfs_aops_cmpr : 1637 1631 &ntfs_aops; 1638 1632 init_rwsem(&ni->file.run_lock);
+4
fs/ntfs3/ntfs_fs.h
··· 493 493 struct ntfs_fnd *fnd); 494 494 bool dir_is_empty(struct inode *dir); 495 495 extern const struct file_operations ntfs_dir_operations; 496 + extern const struct file_operations ntfs_legacy_dir_operations; 496 497 497 498 /* Globals from file.c */ 498 499 int ntfs_getattr(struct mnt_idmap *idmap, const struct path *path, ··· 508 507 extern const struct inode_operations ntfs_special_inode_operations; 509 508 extern const struct inode_operations ntfs_file_inode_operations; 510 509 extern const struct file_operations ntfs_file_operations; 510 + extern const struct file_operations ntfs_legacy_file_operations; 511 511 512 512 /* Globals from frecord.c */ 513 513 void ni_remove_mi(struct ntfs_inode *ni, struct mft_inode *mi); ··· 1155 1153 { 1156 1154 *var = cpu_to_le64(le64_to_cpu(*var) - val); 1157 1155 } 1156 + 1157 + bool is_legacy_ntfs(struct super_block *sb); 1158 1158 1159 1159 #endif /* _LINUX_NTFS3_NTFS_FS_H */
+62 -3
fs/ntfs3/super.c
··· 408 408 struct ntfs_mount_options *new_opts = fc->fs_private; 409 409 int ro_rw; 410 410 411 + /* If ntfs3 is used as legacy ntfs enforce read-only mode. */ 412 + if (is_legacy_ntfs(sb)) { 413 + fc->sb_flags |= SB_RDONLY; 414 + goto out; 415 + } 416 + 411 417 ro_rw = sb_rdonly(sb) && !(fc->sb_flags & SB_RDONLY); 412 418 if (ro_rw && (sbi->flags & NTFS_FLAGS_NEED_REPLAY)) { 413 419 errorf(fc, ··· 433 427 fc, 434 428 "ntfs3: Cannot use different iocharset when remounting!"); 435 429 436 - sync_filesystem(sb); 437 - 438 430 if (ro_rw && (sbi->volume.flags & VOLUME_FLAG_DIRTY) && 439 431 !new_opts->force) { 440 432 errorf(fc, ··· 440 436 return -EINVAL; 441 437 } 442 438 439 + out: 440 + sync_filesystem(sb); 443 441 swap(sbi->options, fc->fs_private); 444 442 445 443 return 0; ··· 1619 1613 } 1620 1614 #endif 1621 1615 1616 + if (is_legacy_ntfs(sb)) 1617 + sb->s_flags |= SB_RDONLY; 1622 1618 return 0; 1623 1619 1624 1620 put_inode_out: ··· 1738 1730 * This will called when mount/remount. We will first initialize 1739 1731 * options so that if remount we can use just that. 1740 1732 */ 1741 - static int ntfs_init_fs_context(struct fs_context *fc) 1733 + static int __ntfs_init_fs_context(struct fs_context *fc) 1742 1734 { 1743 1735 struct ntfs_mount_options *opts; 1744 1736 struct ntfs_sb_info *sbi; ··· 1786 1778 return -ENOMEM; 1787 1779 } 1788 1780 1781 + static int ntfs_init_fs_context(struct fs_context *fc) 1782 + { 1783 + return __ntfs_init_fs_context(fc); 1784 + } 1785 + 1789 1786 static void ntfs3_kill_sb(struct super_block *sb) 1790 1787 { 1791 1788 struct ntfs_sb_info *sbi = sb->s_fs_info; ··· 1811 1798 .kill_sb = ntfs3_kill_sb, 1812 1799 .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, 1813 1800 }; 1801 + 1802 + #if IS_ENABLED(CONFIG_NTFS_FS) 1803 + static int ntfs_legacy_init_fs_context(struct fs_context *fc) 1804 + { 1805 + int ret; 1806 + 1807 + ret = __ntfs_init_fs_context(fc); 1808 + /* If ntfs3 is used as legacy ntfs enforce read-only mode. */ 1809 + fc->sb_flags |= SB_RDONLY; 1810 + return ret; 1811 + } 1812 + 1813 + static struct file_system_type ntfs_legacy_fs_type = { 1814 + .owner = THIS_MODULE, 1815 + .name = "ntfs", 1816 + .init_fs_context = ntfs_legacy_init_fs_context, 1817 + .parameters = ntfs_fs_parameters, 1818 + .kill_sb = ntfs3_kill_sb, 1819 + .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, 1820 + }; 1821 + MODULE_ALIAS_FS("ntfs"); 1822 + 1823 + static inline void register_as_ntfs_legacy(void) 1824 + { 1825 + int err = register_filesystem(&ntfs_legacy_fs_type); 1826 + if (err) 1827 + pr_warn("ntfs3: Failed to register legacy ntfs filesystem driver: %d\n", err); 1828 + } 1829 + 1830 + static inline void unregister_as_ntfs_legacy(void) 1831 + { 1832 + unregister_filesystem(&ntfs_legacy_fs_type); 1833 + } 1834 + bool is_legacy_ntfs(struct super_block *sb) 1835 + { 1836 + return sb->s_type == &ntfs_legacy_fs_type; 1837 + } 1838 + #else 1839 + static inline void register_as_ntfs_legacy(void) {} 1840 + static inline void unregister_as_ntfs_legacy(void) {} 1841 + bool is_legacy_ntfs(struct super_block *sb) { return false; } 1842 + #endif 1843 + 1844 + 1814 1845 // clang-format on 1815 1846 1816 1847 static int __init init_ntfs_fs(void) ··· 1889 1832 goto out1; 1890 1833 } 1891 1834 1835 + register_as_ntfs_legacy(); 1892 1836 err = register_filesystem(&ntfs_fs_type); 1893 1837 if (err) 1894 1838 goto out; ··· 1907 1849 rcu_barrier(); 1908 1850 kmem_cache_destroy(ntfs_inode_cachep); 1909 1851 unregister_filesystem(&ntfs_fs_type); 1852 + unregister_as_ntfs_legacy(); 1910 1853 ntfs3_exit_bitmap(); 1911 1854 1912 1855 #ifdef CONFIG_PROC_FS