1. 10 Aug, 2023 1 commit
    • Damien Le Moal's avatar
      zonefs: fix synchronous direct writes to sequential files · fe9da61f
      Damien Le Moal authored
      Commit 16d7fd3c ("zonefs: use iomap for synchronous direct writes")
      changes zonefs code from a self-built zone append BIO to using iomap for
      synchronous direct writes. This change relies on iomap submit BIO
      callback to change the write BIO built by iomap to a zone append BIO.
      However, this change overlooked the fact that a write BIO may be very
      large as it is split when issued. The change from a regular write to a
      zone append operation for the built BIO can result in a block layer
      warning as zone append BIO are not allowed to be split.
      
      WARNING: CPU: 18 PID: 202210 at block/bio.c:1644 bio_split+0x288/0x350
      Call Trace:
      ? __warn+0xc9/0x2b0
      ? bio_split+0x288/0x350
      ? report_bug+0x2e6/0x390
      ? handle_bug+0x41/0x80
      ? exc_invalid_op+0x13/0x40
      ? asm_exc_invalid_op+0x16/0x20
      ? bio_split+0x288/0x350
      bio_split_rw+0x4bc/0x810
      ? __pfx_bio_split_rw+0x10/0x10
      ? lockdep_unlock+0xf2/0x250
      __bio_split_to_limits+0x1d8/0x900
      blk_mq_submit_bio+0x1cf/0x18a0
      ? __pfx_iov_iter_extract_pages+0x10/0x10
      ? __pfx_blk_mq_submit_bio+0x10/0x10
      ? find_held_lock+0x2d/0x110
      ? lock_release+0x362/0x620
      ? mark_held_locks+0x9e/0xe0
      __submit_bio+0x1ea/0x290
      ? __pfx___submit_bio+0x10/0x10
      ? seqcount_lockdep_reader_access.constprop.0+0x82/0x90
      submit_bio_noacct_nocheck+0x675/0xa20
      ? __pfx_bio_iov_iter_get_pages+0x10/0x10
      ? __pfx_submit_bio_noacct_nocheck+0x10/0x10
      iomap_dio_bio_iter+0x624/0x1280
      __iomap_dio_rw+0xa22/0x18a0
      ? lock_is_held_type+0xe3/0x140
      ? __pfx___iomap_dio_rw+0x10/0x10
      ? lock_release+0x362/0x620
      ? zonefs_file_write_iter+0x74c/0xc80 [zonefs]
      ? down_write+0x13d/0x1e0
      iomap_dio_rw+0xe/0x40
      zonefs_file_write_iter+0x5ea/0xc80 [zonefs]
      do_iter_readv_writev+0x18b/0x2c0
      ? __pfx_do_iter_readv_writev+0x10/0x10
      ? inode_security+0x54/0xf0
      do_iter_write+0x13b/0x7c0
      ? lock_is_held_type+0xe3/0x140
      vfs_writev+0x185/0x550
      ? __pfx_vfs_writev+0x10/0x10
      ? __handle_mm_fault+0x9bd/0x1c90
      ? find_held_lock+0x2d/0x110
      ? lock_release+0x362/0x620
      ? find_held_lock+0x2d/0x110
      ? lock_release+0x362/0x620
      ? __up_read+0x1ea/0x720
      ? do_pwritev+0x136/0x1f0
      do_pwritev+0x136/0x1f0
      ? __pfx_do_pwritev+0x10/0x10
      ? syscall_enter_from_user_mode+0x22/0x90
      ? lockdep_hardirqs_on+0x7d/0x100
      do_syscall_64+0x58/0x80
      
      This error depends on the hardware used, specifically on the max zone
      append bytes and max_[hw_]sectors limits. Tests using AMD Epyc machines
      that have low limits did not reveal this issue while runs on Intel Xeon
      machines with larger limits trigger it.
      
      Manually splitting the zone append BIO using bio_split_rw() can solve
      this issue but also requires issuing the fragment BIOs synchronously
      with submit_bio_wait(), to avoid potential reordering of the zone append
      BIO fragments, which would lead to data corruption. That is, this
      solution is not better than using regular write BIOs which are subject
      to serialization using zone write locking at the IO scheduler level.
      
      Given this, fix the issue by removing zone append support and using
      regular write BIOs for synchronous direct writes. This allows preseving
      the use of iomap and having identical synchronous and asynchronous
      sequential file write path. Zone append support will be reintroduced
      later through io_uring commands to ensure that the needed special
      handling is done correctly.
      Reported-by: default avatarShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
      Fixes: 16d7fd3c ("zonefs: use iomap for synchronous direct writes")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDamien Le Moal <dlemoal@kernel.org>
      Tested-by: default avatarShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      fe9da61f
  2. 06 Aug, 2023 8 commits
    • Linus Torvalds's avatar
      Linux 6.5-rc5 · 52a93d39
      Linus Torvalds authored
      52a93d39
    • Linus Torvalds's avatar
      Merge tag 'v6.5-rc5.vfs.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs · 0108963f
      Linus Torvalds authored
      Pull vfs fixes from Christian Brauner:
      
       - Fix a wrong check for O_TMPFILE during RESOLVE_CACHED lookup
      
       - Clean up directory iterators and clarify file_needs_f_pos_lock()
      
      * tag 'v6.5-rc5.vfs.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs:
        fs: rely on ->iterate_shared to determine f_pos locking
        vfs: get rid of old '->iterate' directory operation
        proc: fix missing conversion to 'iterate_shared'
        open: make RESOLVE_CACHED correctly test for O_TMPFILE
      0108963f
    • Christian Brauner's avatar
      fs: rely on ->iterate_shared to determine f_pos locking · 7d84d1b9
      Christian Brauner authored
      Now that we removed ->iterate we don't need to check for either
      ->iterate or ->iterate_shared in file_needs_f_pos_lock(). Simply check
      for ->iterate_shared instead. This will tell us whether we need to
      unconditionally take the lock. Not just does it allow us to avoid
      checking f_inode's mode it also actually clearly shows that we're
      locking because of readdir.
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      7d84d1b9
    • Linus Torvalds's avatar
      vfs: get rid of old '->iterate' directory operation · 3e327154
      Linus Torvalds authored
      All users now just use '->iterate_shared()', which only takes the
      directory inode lock for reading.
      
      Filesystems that never got convered to shared mode now instead use a
      wrapper that drops the lock, re-takes it in write mode, calls the old
      function, and then downgrades the lock back to read mode.
      
      This way the VFS layer and other callers no longer need to care about
      filesystems that never got converted to the modern era.
      
      The filesystems that use the new wrapper are ceph, coda, exfat, jfs,
      ntfs, ocfs2, overlayfs, and vboxsf.
      
      Honestly, several of them look like they really could just iterate their
      directories in shared mode and skip the wrapper entirely, but the point
      of this change is to not change semantics or fix filesystems that
      haven't been fixed in the last 7+ years, but to finally get rid of the
      dual iterators.
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      3e327154
    • Linus Torvalds's avatar
      proc: fix missing conversion to 'iterate_shared' · 0a2c2baa
      Linus Torvalds authored
      I'm looking at the directory handling due to the discussion about f_pos
      locking (see commit 79796425: "file: reinstate f_pos locking
      optimization for regular files"), and wanting to clean that up.
      
      And one source of ugliness is how we were supposed to move filesystems
      over to the '->iterate_shared()' function that only takes the inode lock
      for reading many many years ago, but several filesystems still use the
      bad old '->iterate()' that takes the inode lock for exclusive access.
      
      See commit 61922694 ("introduce a parallel variant of ->iterate()")
      that also added some documentation stating
      
            Old method is only used if the new one is absent; eventually it will
            be removed.  Switch while you still can; the old one won't stay.
      
      and that was back in April 2016.  Here we are, many years later, and the
      old version is still clearly sadly alive and well.
      
      Now, some of those old style iterators are probably just because the
      filesystem may end up having per-inode mutable data that it uses for
      iterating a directory, but at least one case is just a mistake.
      
      Al switched over most filesystems to use '->iterate_shared()' back when
      it was introduced.  In particular, the /proc filesystem was converted as
      one of the first ones in commit f50752ea ("switch all procfs
      directories ->iterate_shared()").
      
      But then later one new user of '->iterate()' was then re-introduced by
      commit 6d9c939d ("procfs: add smack subdir to attrs").
      
      And that's clearly not what we wanted, since that new case just uses the
      same 'proc_pident_readdir()' and 'proc_pident_lookup()' helper functions
      that other /proc pident directories use, and they are most definitely
      safe to use with the inode lock held shared.
      
      So just fix it.
      
      This still leaves a fair number of oddball filesystems using the
      old-style directory iterator (ceph, coda, exfat, jfs, ntfs, ocfs2,
      overlayfs, and vboxsf), but at least we don't have any remaining in the
      core filesystems.
      
      I'm going to add a wrapper function that just drops the read-lock and
      takes it as a write lock, so that we can clean up the core vfs layer and
      make all the ugly 'this filesystem needs exclusive inode locking' be
      just filesystem-internal warts.
      
      I just didn't want to make that conversion when we still had a core user
      left.
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      0a2c2baa
    • Aleksa Sarai's avatar
      open: make RESOLVE_CACHED correctly test for O_TMPFILE · a0fc452a
      Aleksa Sarai authored
      O_TMPFILE is actually __O_TMPFILE|O_DIRECTORY. This means that the old
      fast-path check for RESOLVE_CACHED would reject all users passing
      O_DIRECTORY with -EAGAIN, when in fact the intended test was to check
      for __O_TMPFILE.
      
      Cc: stable@vger.kernel.org # v5.12+
      Fixes: 99668f61 ("fs: expose LOOKUP_CACHED through openat2() RESOLVE_CACHED")
      Signed-off-by: default avatarAleksa Sarai <cyphar@cyphar.com>
      Message-Id: <20230806-resolve_cached-o_tmpfile-v1-1-7ba16308465e@cyphar.com>
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      a0fc452a
    • Linus Torvalds's avatar
      Merge tag 'rust-fixes-6.5-rc5' of https://github.com/Rust-for-Linux/linux · f0ab9f34
      Linus Torvalds authored
      Pull rust fixes from Miguel Ojeda:
      
       - Allocator: prevent mis-aligned allocation
      
       - Types: delete 'ForeignOwnable::borrow_mut'. A sound replacement is
         planned for the merge window
      
       - Build: fix bindgen error with UBSAN_BOUNDS_STRICT
      
      * tag 'rust-fixes-6.5-rc5' of https://github.com/Rust-for-Linux/linux:
        rust: fix bindgen build error with UBSAN_BOUNDS_STRICT
        rust: delete `ForeignOwnable::borrow_mut`
        rust: allocator: Prevent mis-aligned allocation
      f0ab9f34
    • Linus Torvalds's avatar
      Merge tag 'ata-6.5-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata · fb0d9199
      Linus Torvalds authored
      Pull ata fix from Damien Le Moal:
      
       - Prevent the scsi disk driver from issuing a START STOP UNIT command
         for ATA devices during system resume as this causes various issues
         reported by multiple users.
      
      * tag 'ata-6.5-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata:
        ata,scsi: do not issue START STOP UNIT on resume
      fb0d9199
  3. 05 Aug, 2023 5 commits
  4. 04 Aug, 2023 13 commits
  5. 03 Aug, 2023 13 commits