25 Sep, 2019

1 commit

  • If userspace reads the buffer via blockdev while mounting,
    sb_getblk()+modify can race with buffer read via blockdev.

    For example,

    FS userspace
    bh = sb_getblk()
    modify bh->b_data
    read
    ll_rw_block(bh)
    fill bh->b_data by on-disk data
    /* lost modified data by FS */
    set_buffer_uptodate(bh)
    set_buffer_uptodate(bh)

    Userspace should not use the blockdev while mounting though, the udev
    seems to be already doing this. Although I think the udev should try to
    avoid this, workaround the race by small overhead.

    Link: http://lkml.kernel.org/r/87pnk7l3sw.fsf_-_@mail.parknet.co.jp
    Signed-off-by: OGAWA Hirofumi
    Reported-by: Jan Stancek
    Tested-by: Jan Stancek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    OGAWA Hirofumi
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    released under gpl v2

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 15 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Steve Winslow
    Reviewed-by: Allison Randal
    Reviewed-by: Alexios Zavras
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190528171438.895196075@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

05 Jan, 2019

1 commit

  • This patch introduces 3 new inline functions - is_fat12, is_fat16 and
    is_fat32, and replaces every occurrence in the code in which the FS
    variant (whether this is FAT12, FAT16 or FAT32) was previously checked
    using msdos_sb_info->fat_bits.

    Link: http://lkml.kernel.org/r/1544990640-11604-4-git-send-email-carmeli.tamir@gmail.com
    Signed-off-by: Carmeli Tamir
    Acked-by: OGAWA Hirofumi
    Reviewed-by: Sergey Senozhatsky
    Cc: Johannes Thumshirn
    Cc: Bart Van Assche
    Cc: Martin K. Petersen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Carmeli Tamir
     

13 Oct, 2018

1 commit


23 Aug, 2018

2 commits

  • On corrupted FATfs may have invalid ->i_start. To handle it, this checks
    ->i_start before using, and return proper error code.

    Link: http://lkml.kernel.org/r/87o9f8y1t5.fsf_-_@mail.parknet.co.jp
    Signed-off-by: OGAWA Hirofumi
    Reported-by: Anatoly Trosinenko
    Tested-by: Anatoly Trosinenko
    Cc: Alan Cox
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    OGAWA Hirofumi
     
  • Add FITRIM ioctl for FAT file system

    [witallwang@gmail.com: use u64s]
    Link: http://lkml.kernel.org/r/87h8l37hub.fsf@mail.parknet.co.jp
    [hirofumi@mail.parknet.co.jp: bug fixes, coding style fixes, add signal check]
    Link: http://lkml.kernel.org/r/87fu10anhj.fsf@mail.parknet.co.jp
    Signed-off-by: Wentao Wang
    Signed-off-by: OGAWA Hirofumi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Wentao Wang
     

28 Nov, 2017

1 commit

  • This is a pure automated search-and-replace of the internal kernel
    superblock flags.

    The s_flags are now called SB_*, with the names and the values for the
    moment mirroring the MS_* flags that they're equivalent to.

    Note how the MS_xyz flags are the ones passed to the mount system call,
    while the SB_xyz flags are what we then use in sb->s_flags.

    The script to do this was:

    # places to look in; re security/*: it generally should *not* be
    # touched (that stuff parses mount(2) arguments directly), but
    # there are two places where we really deal with superblock flags.
    FILES="drivers/mtd drivers/staging/lustre fs ipc mm \
    include/linux/fs.h include/uapi/linux/bfs_fs.h \
    security/apparmor/apparmorfs.c security/apparmor/include/lib.h"
    # the list of MS_... constants
    SYMS="RDONLY NOSUID NODEV NOEXEC SYNCHRONOUS REMOUNT MANDLOCK \
    DIRSYNC NOATIME NODIRATIME BIND MOVE REC VERBOSE SILENT \
    POSIXACL UNBINDABLE PRIVATE SLAVE SHARED RELATIME KERNMOUNT \
    I_VERSION STRICTATIME LAZYTIME SUBMOUNT NOREMOTELOCK NOSEC BORN \
    ACTIVE NOUSER"

    SED_PROG=
    for i in $SYMS; do SED_PROG="$SED_PROG -e s/MS_$i/SB_$i/g"; done

    # we want files that contain at least one of MS_...,
    # with fs/namespace.c and fs/pnode.c excluded.
    L=$(for i in $SYMS; do git grep -w -l MS_$i $FILES; done| sort|uniq|grep -v '^fs/namespace.c'|grep -v '^fs/pnode.c')

    for f in $L; do sed -i $f $SED_PROG; done

    Requested-by: Al Viro
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

17 Jul, 2017

1 commit

  • Firstly by applying the following with coccinelle's spatch:

    @@ expression SB; @@
    -SB->s_flags & MS_RDONLY
    +sb_rdonly(SB)

    to effect the conversion to sb_rdonly(sb), then by applying:

    @@ expression A, SB; @@
    (
    -(!sb_rdonly(SB)) && A
    +!sb_rdonly(SB) && A
    |
    -A != (sb_rdonly(SB))
    +A != sb_rdonly(SB)
    |
    -A == (sb_rdonly(SB))
    +A == sb_rdonly(SB)
    |
    -!(sb_rdonly(SB))
    +!sb_rdonly(SB)
    |
    -A && (sb_rdonly(SB))
    +A && sb_rdonly(SB)
    |
    -A || (sb_rdonly(SB))
    +A || sb_rdonly(SB)
    |
    -(sb_rdonly(SB)) != A
    +sb_rdonly(SB) != A
    |
    -(sb_rdonly(SB)) == A
    +sb_rdonly(SB) == A
    |
    -(sb_rdonly(SB)) && A
    +sb_rdonly(SB) && A
    |
    -(sb_rdonly(SB)) || A
    +sb_rdonly(SB) || A
    )

    @@ expression A, B, SB; @@
    (
    -(sb_rdonly(SB)) ? 1 : 0
    +sb_rdonly(SB)
    |
    -(sb_rdonly(SB)) ? A : B
    +sb_rdonly(SB) ? A : B
    )

    to remove left over excess bracketage and finally by applying:

    @@ expression A, SB; @@
    (
    -(A & MS_RDONLY) != sb_rdonly(SB)
    +(bool)(A & MS_RDONLY) != sb_rdonly(SB)
    |
    -(A & MS_RDONLY) == sb_rdonly(SB)
    +(bool)(A & MS_RDONLY) == sb_rdonly(SB)
    )

    to make comparisons against the result of sb_rdonly() (which is a bool)
    work correctly.

    Signed-off-by: David Howells

    David Howells
     

21 Jan, 2016

1 commit


17 Apr, 2015

1 commit

  • 'fat.h' includes which includes which
    includes all the header files required for all *.c files fat filesystem.

    [akpm@linux-foundation.org: fs/fat/iode.c needs seq_file.h]
    [sfr@canb.auug.org.au: put one actually necessary include file back]
    Signed-off-by: Alexander Kuleshov
    Acked-by: OGAWA Hirofumi
    Signed-off-by: Stephen Rothwell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexander Kuleshov
     

06 Oct, 2012

2 commits


01 Jun, 2012

3 commits

  • Currently FAT file-system maps the VFS "superblock" abstraction to the
    FSINFO block. The FSINFO block contains non-essential data about the
    amount of free clusters and the next free cluster. FAT file-system can
    always find out this information by scanning the FAT table, but having it
    in the FSINFO block may speed things up sometimes. So FAT file-system
    relies on the VFS superblock write-out services to make sure the FSINFO
    block is written out to the media from time to time.

    The whole "superblock write-out" VFS infrastructure is served by the
    'sync_supers()' kernel thread, which wakes up every 5 (by default) seconds
    and writes out all dirty superblock using the '->write_super()' call-back.
    But the problem with this thread is that it wastes power by waking up the
    system every 5 seconds no matter what. So we want to kill it completely
    and thus, we need to make file-systems to stop using the '->write_super'
    VFS service, and then remove it together with the kernel thread.

    This patch switches the FAT FSINFO block management from
    '->write_super()'/'->s_dirt' to 'fsinfo_inode'/'->write_inode'. Now,
    instead of setting the 's_dirt' flag, we just mark the special
    'fsinfo_inode' inode as dirty and let VFS invoke the '->write_inode'
    call-back when needed, where we write-out the FSINFO block.

    This patch also makes sure we do not mark the 'fsinfo_inode' inode as
    dirty if we are not FAT32 (FAT16 and FAT12 do not have the FSINFO block)
    or if we are in R/O mode.

    As a bonus, we can also remove the '->sync_fs()' and '->write_super()' FAT
    call-back function because they become unneeded.

    Signed-off-by: Artem Bityutskiy
    Cc: OGAWA Hirofumi
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Artem Bityutskiy
     
  • Preparation for further changes. It touches few functions in fatent.c and
    prevents them from marking the superblock as dirty unnecessarily often.
    Namely, instead of marking it as dirty in the internal tight loops - do it
    only once at the end of the functions. And instead of marking it as dirty
    while holding the FAT table lock, do it outside the lock.

    The reason for this patch is that marking the superblock as dirty will
    soon become a little bit heavier operation, so it is cleaner to do this
    only when it is necessary.

    Signed-off-by: Artem Bityutskiy
    Cc: OGAWA Hirofumi
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Artem Bityutskiy
     
  • A preparation patch which introduces a 'mark_fsinfo_dirty()' helper
    function which just sets the 's_dirt' flag to 1 so far. I'll add more
    code to this helper later, so I do not mark it as 'inline'.

    Signed-off-by: Artem Bityutskiy
    Cc: OGAWA Hirofumi
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Artem Bityutskiy
     

12 Apr, 2011

1 commit


17 Sep, 2010

1 commit

  • All the blkdev_issue_* helpers can only sanely be used for synchronous
    caller. To issue cache flushes or barriers asynchronously the caller needs
    to set up a bio by itself with a completion callback to move the asynchronous
    state machine ahead. So drop the BLKDEV_IFL_WAIT flag that is always
    specified when calling blkdev_issue_* and also remove the now unused flags
    argument to blkdev_issue_flush and blkdev_issue_zeroout. For
    blkdev_issue_discard we need to keep it for the secure discard flag, which
    gains a more descriptive name and loses the bitops vs flag confusion.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

10 Sep, 2010

2 commits


21 Nov, 2009

1 commit

  • Currently shipping discard capable SSDs and arrays have rather sub-optimal
    implementations of the command and can the use of it can cause massive
    slowdowns. Make issueing these commands option as it's already in btrfs
    and gfs2.

    Signed-off-by: Christoph Hellwig
    [hirofumi@mail.parknet.co.jp: tweaks, and add "discard" to fat_show_options]
    Signed-off-by: OGAWA Hirofumi

    Christoph Hellwig
     

17 Jun, 2009

1 commit


12 Jun, 2009

1 commit

  • * mark directory data blocks as assoc. metadata
    * add new inode to deal with FAT, mark FAT blocks as assoc. metadata of that
    * now ->fsync() is trivial both for files and directories

    Signed-off-by: Al Viro

    Al Viro
     

04 Jun, 2009

1 commit

  • On severe errors FAT remounts itself in read-only mode. Allow to
    specify FAT fs desired behavior through 'errors' mount option:
    panic, continue or remount read-only.

    `mount -t [fat|vfat] -o errors=[panic,remount-ro,continue] \
    `

    This is analog to ext2 fs 'errors' mount option.

    Signed-off-by: Denis Karpov
    Signed-off-by: OGAWA Hirofumi

    Denis Karpov
     

07 Nov, 2008

3 commits


09 Oct, 2008

1 commit


30 Apr, 2008

1 commit


28 Apr, 2008

2 commits

  • This removes unneeded fat_clusters_flush().

    Signed-off-by: OGAWA Hirofumi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    OGAWA Hirofumi
     
  • Currently, free_clusters is not updated until it is trusted, because
    Windows doesn't update it correctly.

    But if user is using FAT driver of Linux, it updates free_clusters
    correctly. Instead, this updates it even if it's untrusted, so if
    free_clustes is correct, now keep correct value.

    Signed-off-by: OGAWA Hirofumi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    OGAWA Hirofumi
     

09 Jan, 2008

1 commit

  • On large partition, scanning the free clusters is very slow if users
    doesn't use "usefree" option.

    For optimizing it, this patch uses sb_breadahead() to read of FAT
    sectors. On some user's 15GB partition, this patch improved it very
    much (1min => 600ms).

    The following is the result of 2GB partition on my machine.

    without patch:
    root@devron (/)# time df -h > /dev/null

    real 0m1.202s
    user 0m0.000s
    sys 0m0.440s

    with patch:
    root@devron (/)# time df -h > /dev/null

    real 0m0.378s
    user 0m0.012s
    sys 0m0.168s

    Signed-off-by: OGAWA Hirofumi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    OGAWA Hirofumi
     

17 Jul, 2007

1 commit

  • FAT12 entry is 12bits, so it needs 2 phase to update the value. And
    writer and reader access it without any lock, so reader can get the
    half updated value.

    This fixes the long standing race condition by adding a global
    spinlock to only FAT12 for avoiding any impact against FAT16/32.

    Signed-off-by: OGAWA Hirofumi
    Signed-off-by: Linus Torvalds

    OGAWA Hirofumi
     

23 Mar, 2006

1 commit


09 Jan, 2006

2 commits


17 Apr, 2005

1 commit

  • Initial git repository build. I'm not bothering with the full history,
    even though we have it. We can create a separate "historical" git
    archive of that later if we want to, and in the meantime it's about
    3.2GB when imported into git - space that would just make the early
    git days unnecessarily complicated, when we don't have a lot of good
    infrastructure for it.

    Let it rip!

    Linus Torvalds