1. 06 3月, 2020 10 次提交
  2. 09 2月, 2020 3 次提交
    • H
      fs: Add VirtualBox guest shared folder (vboxsf) support · 0fd16957
      Hans de Goede 提交于
      VirtualBox hosts can share folders with guests, this commit adds a
      VFS driver implementing the Linux-guest side of this, allowing folders
      exported by the host to be mounted under Linux.
      
      This driver depends on the guest <-> host IPC functions exported by
      the vboxguest driver.
      Acked-by: NChristoph Hellwig <hch@infradead.org>
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      0fd16957
    • L
      pipe: use exclusive waits when reading or writing · 0ddad21d
      Linus Torvalds 提交于
      This makes the pipe code use separate wait-queues and exclusive waiting
      for readers and writers, avoiding a nasty thundering herd problem when
      there are lots of readers waiting for data on a pipe (or, less commonly,
      lots of writers waiting for a pipe to have space).
      
      While this isn't a common occurrence in the traditional "use a pipe as a
      data transport" case, where you typically only have a single reader and
      a single writer process, there is one common special case: using a pipe
      as a source of "locking tokens" rather than for data communication.
      
      In particular, the GNU make jobserver code ends up using a pipe as a way
      to limit parallelism, where each job consumes a token by reading a byte
      from the jobserver pipe, and releases the token by writing a byte back
      to the pipe.
      
      This pattern is fairly traditional on Unix, and works very well, but
      will waste a lot of time waking up a lot of processes when only a single
      reader needs to be woken up when a writer releases a new token.
      
      A simplified test-case of just this pipe interaction is to create 64
      processes, and then pass a single token around between them (this
      test-case also intentionally passes another token that gets ignored to
      test the "wake up next" logic too, in case anybody wonders about it):
      
          #include <unistd.h>
      
          int main(int argc, char **argv)
          {
              int fd[2], counters[2];
      
              pipe(fd);
              counters[0] = 0;
              counters[1] = -1;
              write(fd[1], counters, sizeof(counters));
      
              /* 64 processes */
              fork(); fork(); fork(); fork(); fork(); fork();
      
              do {
                      int i;
                      read(fd[0], &i, sizeof(i));
                      if (i < 0)
                              continue;
                      counters[0] = i+1;
                      write(fd[1], counters, (1+(i & 1)) *sizeof(int));
              } while (counters[0] < 1000000);
              return 0;
          }
      
      and in a perfect world, passing that token around should only cause one
      context switch per transfer, when the writer of a token causes a
      directed wakeup of just a single reader.
      
      But with the "writer wakes all readers" model we traditionally had, on
      my test box the above case causes more than an order of magnitude more
      scheduling: instead of the expected ~1M context switches, "perf stat"
      shows
      
              231,852.37 msec task-clock                #   15.857 CPUs utilized
              11,250,961      context-switches          #    0.049 M/sec
                 616,304      cpu-migrations            #    0.003 M/sec
                   1,648      page-faults               #    0.007 K/sec
       1,097,903,998,514      cycles                    #    4.735 GHz
         120,781,778,352      instructions              #    0.11  insn per cycle
          27,997,056,043      branches                  #  120.754 M/sec
             283,581,233      branch-misses             #    1.01% of all branches
      
            14.621273891 seconds time elapsed
      
             0.018243000 seconds user
             3.611468000 seconds sys
      
      before this commit.
      
      After this commit, I get
      
                5,229.55 msec task-clock                #    3.072 CPUs utilized
               1,212,233      context-switches          #    0.232 M/sec
                 103,951      cpu-migrations            #    0.020 M/sec
                   1,328      page-faults               #    0.254 K/sec
          21,307,456,166      cycles                    #    4.074 GHz
          12,947,819,999      instructions              #    0.61  insn per cycle
           2,881,985,678      branches                  #  551.096 M/sec
              64,267,015      branch-misses             #    2.23% of all branches
      
             1.702148350 seconds time elapsed
      
             0.004868000 seconds user
             0.110786000 seconds sys
      
      instead. Much better.
      
      [ Note! This kernel improvement seems to be very good at triggering a
        race condition in the make jobserver (in GNU make 4.2.1) for me. It's
        a long known bug that was fixed back in June 2017 by GNU make commit
        b552b0525198 ("[SV 51159] Use a non-blocking read with pselect to
        avoid hangs.").
      
        But there wasn't a new release of GNU make until 4.3 on Jan 19 2020,
        so a number of distributions may still have the buggy version. Some
        have backported the fix to their 4.2.1 release, though, and even
        without the fix it's quite timing-dependent whether the bug actually
        is hit. ]
      
      Josh Triplett says:
       "I've been hammering on your pipe fix patch (switching to exclusive
        wait queues) for a month or so, on several different systems, and I've
        run into no issues with it. The patch *substantially* improves
        parallel build times on large (~100 CPU) systems, both with parallel
        make and with other things that use make's pipe-based jobserver.
      
        All current distributions (including stable and long-term stable
        distributions) have versions of GNU make that no longer have the
        jobserver bug"
      Tested-by: NJosh Triplett <josh@joshtriplett.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      0ddad21d
    • A
      compat_ioctl: fix FIONREAD on devices · 0a061743
      Arnd Bergmann 提交于
      My final cleanup patch for sys_compat_ioctl() introduced a regression on
      the FIONREAD ioctl command, which is used for both regular and special
      files, but only works on regular files after my patch, as I had missed
      the warning that Al Viro put into a comment right above it.
      
      Change it back so it can work on any file again by moving the implementation
      to do_vfs_ioctl() instead.
      
      Fixes: 77b90401 ("compat_ioctl: simplify the implementation")
      Reported-and-tested-by: NChristian Zigotzky <chzigotzky@xenosoft.de>
      Reported-and-tested-by: Nyouling257 <youling257@gmail.com>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      0a061743
  3. 08 2月, 2020 17 次提交
  4. 07 2月, 2020 10 次提交
    • D
      fs: New zonefs file system · 8dcc1a9d
      Damien Le Moal 提交于
      zonefs is a very simple file system exposing each zone of a zoned block
      device as a file. Unlike a regular file system with zoned block device
      support (e.g. f2fs), zonefs does not hide the sequential write
      constraint of zoned block devices to the user. Files representing
      sequential write zones of the device must be written sequentially
      starting from the end of the file (append only writes).
      
      As such, zonefs is in essence closer to a raw block device access
      interface than to a full featured POSIX file system. The goal of zonefs
      is to simplify the implementation of zoned block device support in
      applications by replacing raw block device file accesses with a richer
      file API, avoiding relying on direct block device file ioctls which may
      be more obscure to developers. One example of this approach is the
      implementation of LSM (log-structured merge) tree structures (such as
      used in RocksDB and LevelDB) on zoned block devices by allowing SSTables
      to be stored in a zone file similarly to a regular file system rather
      than as a range of sectors of a zoned device. The introduction of the
      higher level construct "one file is one zone" can help reducing the
      amount of changes needed in the application as well as introducing
      support for different application programming languages.
      
      Zonefs on-disk metadata is reduced to an immutable super block to
      persistently store a magic number and optional feature flags and
      values. On mount, zonefs uses blkdev_report_zones() to obtain the device
      zone configuration and populates the mount point with a static file tree
      solely based on this information. E.g. file sizes come from the device
      zone type and write pointer offset managed by the device itself.
      
      The zone files created on mount have the following characteristics.
      1) Files representing zones of the same type are grouped together
         under a common sub-directory:
           * For conventional zones, the sub-directory "cnv" is used.
           * For sequential write zones, the sub-directory "seq" is used.
        These two directories are the only directories that exist in zonefs.
        Users cannot create other directories and cannot rename nor delete
        the "cnv" and "seq" sub-directories.
      2) The name of zone files is the number of the file within the zone
         type sub-directory, in order of increasing zone start sector.
      3) The size of conventional zone files is fixed to the device zone size.
         Conventional zone files cannot be truncated.
      4) The size of sequential zone files represent the file's zone write
         pointer position relative to the zone start sector. Truncating these
         files is allowed only down to 0, in which case, the zone is reset to
         rewind the zone write pointer position to the start of the zone, or
         up to the zone size, in which case the file's zone is transitioned
         to the FULL state (finish zone operation).
      5) All read and write operations to files are not allowed beyond the
         file zone size. Any access exceeding the zone size is failed with
         the -EFBIG error.
      6) Creating, deleting, renaming or modifying any attribute of files and
         sub-directories is not allowed.
      7) There are no restrictions on the type of read and write operations
         that can be issued to conventional zone files. Buffered, direct and
         mmap read & write operations are accepted. For sequential zone files,
         there are no restrictions on read operations, but all write
         operations must be direct IO append writes. mmap write of sequential
         files is not allowed.
      
      Several optional features of zonefs can be enabled at format time.
      * Conventional zone aggregation: ranges of contiguous conventional
        zones can be aggregated into a single larger file instead of the
        default one file per zone.
      * File ownership: The owner UID and GID of zone files is by default 0
        (root) but can be changed to any valid UID/GID.
      * File access permissions: the default 640 access permissions can be
        changed.
      
      The mkzonefs tool is used to format zoned block devices for use with
      zonefs. This tool is available on Github at:
      
      git@github.com:damien-lemoal/zonefs-tools.git.
      
      zonefs-tools also includes a test suite which can be run against any
      zoned block device, including null_blk block device created with zoned
      mode.
      
      Example: the following formats a 15TB host-managed SMR HDD with 256 MB
      zones with the conventional zones aggregation feature enabled.
      
      $ sudo mkzonefs -o aggr_cnv /dev/sdX
      $ sudo mount -t zonefs /dev/sdX /mnt
      $ ls -l /mnt/
      total 0
      dr-xr-xr-x 2 root root     1 Nov 25 13:23 cnv
      dr-xr-xr-x 2 root root 55356 Nov 25 13:23 seq
      
      The size of the zone files sub-directories indicate the number of files
      existing for each type of zones. In this example, there is only one
      conventional zone file (all conventional zones are aggregated under a
      single file).
      
      $ ls -l /mnt/cnv
      total 137101312
      -rw-r----- 1 root root 140391743488 Nov 25 13:23 0
      
      This aggregated conventional zone file can be used as a regular file.
      
      $ sudo mkfs.ext4 /mnt/cnv/0
      $ sudo mount -o loop /mnt/cnv/0 /data
      
      The "seq" sub-directory grouping files for sequential write zones has
      in this example 55356 zones.
      
      $ ls -lv /mnt/seq
      total 14511243264
      -rw-r----- 1 root root 0 Nov 25 13:23 0
      -rw-r----- 1 root root 0 Nov 25 13:23 1
      -rw-r----- 1 root root 0 Nov 25 13:23 2
      ...
      -rw-r----- 1 root root 0 Nov 25 13:23 55354
      -rw-r----- 1 root root 0 Nov 25 13:23 55355
      
      For sequential write zone files, the file size changes as data is
      appended at the end of the file, similarly to any regular file system.
      
      $ dd if=/dev/zero of=/mnt/seq/0 bs=4K count=1 conv=notrunc oflag=direct
      1+0 records in
      1+0 records out
      4096 bytes (4.1 kB, 4.0 KiB) copied, 0.000452219 s, 9.1 MB/s
      
      $ ls -l /mnt/seq/0
      -rw-r----- 1 root root 4096 Nov 25 13:23 /mnt/seq/0
      
      The written file can be truncated to the zone size, preventing any
      further write operation.
      
      $ truncate -s 268435456 /mnt/seq/0
      $ ls -l /mnt/seq/0
      -rw-r----- 1 root root 268435456 Nov 25 13:49 /mnt/seq/0
      
      Truncation to 0 size allows freeing the file zone storage space and
      restart append-writes to the file.
      
      $ truncate -s 0 /mnt/seq/0
      $ ls -l /mnt/seq/0
      -rw-r----- 1 root root 0 Nov 25 13:49 /mnt/seq/0
      
      Since files are statically mapped to zones on the disk, the number of
      blocks of a file as reported by stat() and fstat() indicates the size
      of the file zone.
      
      $ stat /mnt/seq/0
        File: /mnt/seq/0
        Size: 0       Blocks: 524288     IO Block: 4096   regular empty file
      Device: 870h/2160d      Inode: 50431       Links: 1
      Access: (0640/-rw-r-----)  Uid: (    0/    root)   Gid: (    0/  root)
      Access: 2019-11-25 13:23:57.048971997 +0900
      Modify: 2019-11-25 13:52:25.553805765 +0900
      Change: 2019-11-25 13:52:25.553805765 +0900
       Birth: -
      
      The number of blocks of the file ("Blocks") in units of 512B blocks
      gives the maximum file size of 524288 * 512 B = 256 MB, corresponding
      to the device zone size in this example. Of note is that the "IO block"
      field always indicates the minimum IO size for writes and corresponds
      to the device physical sector size.
      
      This code contains contributions from:
      * Johannes Thumshirn <jthumshirn@suse.de>,
      * Darrick J. Wong <darrick.wong@oracle.com>,
      * Christoph Hellwig <hch@lst.de>,
      * Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> and
      * Ting Yao <tingyao@hust.edu.cn>.
      Signed-off-by: NDamien Le Moal <damien.lemoal@wdc.com>
      Reviewed-by: NDave Chinner <dchinner@redhat.com>
      8dcc1a9d
    • A
      fold struct fs_parameter_enum into struct constant_table · 5eede625
      Al Viro 提交于
      no real difference now
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      5eede625
    • A
      fs_parse: get rid of ->enums · 2710c957
      Al Viro 提交于
      Don't do a single array; attach them to fsparam_enum() entry
      instead.  And don't bother trying to embed the names into those -
      it actually loses memory, with no real speedup worth mentioning.
      
      Simplifies validation as well.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      2710c957
    • A
      Pass consistent param->type to fs_parse() · 0f89589a
      Al Viro 提交于
      As it is, vfs_parse_fs_string() makes "foo" and "foo=" indistinguishable;
      both get fs_value_is_string for ->type and NULL for ->string.  To make
      it even more unpleasant, that combination is impossible to produce with
      fsconfig().
      
      Much saner rules would be
              "foo"           => fs_value_is_flag, NULL
      	"foo="          => fs_value_is_string, ""
      	"foo=bar"       => fs_value_is_string, "bar"
      All cases are distinguishable, all results are expressable by fsconfig(),
      ->has_value checks are much simpler that way (to the point of the field
      being useless) and quite a few regressions go away (gfs2 has no business
      accepting -o nodebug=, for example).
      
      Partially based upon patches from Miklos.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      0f89589a
    • S
      smb3: Add defines for new information level, FileIdInformation · 51d92d69
      Steve French 提交于
      See MS-FSCC 2.4.43.  Valid to be quried from most
      Windows servers (among others).
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Reviewed-by: NAurelien Aptel <aaptel@suse.com>
      51d92d69
    • S
      smb3: print warning once if posix context returned on open · ab3459d8
      Steve French 提交于
      SMB3.1.1 POSIX Context processing is not complete yet - so print warning
      (once) if server returns it on open.
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Reviewed-by: NAurelien Aptel <aaptel@suse.com>
      ab3459d8
    • S
      smb3: add one more dynamic tracepoint missing from strict fsync path · 2391ca41
      Steve French 提交于
      We didn't have a dynamic trace point for catching errors in
      file_write_and_wait_range error cases in cifs_strict_fsync.
      
      Since not all apps check for write behind errors, it can be
      important for debugging to be able to trace these error
      paths.
      Suggested-and-reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      2391ca41
    • A
      cifs: fix mode bits from dir listing when mounted with modefromsid · e3e056c3
      Aurelien Aptel 提交于
      When mounting with -o modefromsid, the mode bits are stored in an
      ACE. Directory enumeration (e.g. ls -l /mnt) triggers an SMB Query Dir
      which does not include ACEs in its response. The mode bits in this
      case are silently set to a default value of 755 instead.
      
      This patch marks the dentry created during the directory enumeration
      as needing re-evaluation (i.e. additional Query Info with ACEs) so
      that the mode bits can be properly extracted.
      
      Quick repro:
      
      $ mount.cifs //win19.test/data /mnt -o ...,modefromsid
      $ touch /mnt/foo && chmod 751 /mnt/foo
      $ stat /mnt/foo
        # reports 751 (OK)
      $ sleep 2
        # dentry older than 1s by default get invalidated
      $ ls -l /mnt
        # since dentry invalid, ls does a Query Dir
        # and reports foo as 755 (WRONG)
      Signed-off-by: NAurelien Aptel <aaptel@suse.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      CC: Stable <stable@vger.kernel.org>
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      e3e056c3
    • A
      cifs: fix channel signing · cc95b677
      Aurelien Aptel 提交于
      The server var was accidentally used as an iterator over the global
      list of connections, thus overwritten the passed argument. This
      resulted in the wrong signing key being returned for extra channels.
      
      Fix this by using a separate var to iterate.
      Signed-off-by: NAurelien Aptel <aaptel@suse.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Reviewed-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      cc95b677
    • A
      gfs2: fix O_SYNC write handling · 6e5e41e2
      Andreas Gruenbacher 提交于
      In gfs2_file_write_iter, for direct writes, the error checking in the buffered
      write fallback case is incomplete.  This can cause inode write errors to go
      undetected.  Fix and clean up gfs2_file_write_iter along the way.
      
      Based on a proposed fix by Christoph Hellwig <hch@lst.de>.
      
      Fixes: 967bcc91 ("gfs2: iomap direct I/O support")
      Cc: stable@vger.kernel.org # v4.19+
      Signed-off-by: NAndreas Gruenbacher <agruenba@redhat.com>
      6e5e41e2