04 Jun, 2020

40 commits

  • No need to pull the fiemap definitions into almost every file in the
    kernel build.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Ritesh Harjani
    Reviewed-by: Darrick J. Wong
    Link: https://lore.kernel.org/r/20200523073016.2944131-5-hch@lst.de
    Signed-off-by: Theodore Ts'o

    Christoph Hellwig
     
  • There is no caller left outside of ioctl.c.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Ritesh Harjani
    Reviewed-by: Jan Kara
    Reviewed-by: Darrick J. Wong
    Link: https://lore.kernel.org/r/20200523073016.2944131-4-hch@lst.de
    Signed-off-by: Theodore Ts'o

    Christoph Hellwig
     
  • iomap_fiemap already calls fiemap_check_flags first thing, so this
    additional check is redundant.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Ritesh Harjani
    Reviewed-by: Jan Kara
    Link: https://lore.kernel.org/r/20200523073016.2944131-3-hch@lst.de
    Signed-off-by: Theodore Ts'o

    Christoph Hellwig
     
  • The fiemap and EXT4_IOC_GET_ES_CACHE cases share almost no code, so split
    them into entirely separate functions.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Ritesh Harjani
    Reviewed-by: Jan Kara
    Link: https://lore.kernel.org/r/20200523073016.2944131-2-hch@lst.de
    Signed-off-by: Theodore Ts'o

    Christoph Hellwig
     
  • Add an extra validation of the len parameter, as for ext4 some files
    might have smaller file size limits than others. This also means the
    redundant size check in ext4_ioctl_get_es_cache can go away, as all
    size checking is done in the shared fiemap handler.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Ritesh Harjani
    Reviewed-by: Jan Kara
    Link: https://lore.kernel.org/r/20200505154324.3226743-3-hch@lst.de
    Signed-off-by: Theodore Ts'o

    Christoph Hellwig
     
  • ext4 supports max number of logical blocks in a file to be 0xffffffff.
    (This is since ext4_extent's ee_block is __le32).
    This means that EXT4_MAX_LOGICAL_BLOCK should be 0xfffffffe (starting
    from 0 logical offset). This patch fixes this.

    The issue was seen when ext4 moved to iomap_fiemap API and when
    overlayfs was mounted on top of ext4. Since overlayfs was missing
    filemap_check_ranges(), so it could pass a arbitrary huge length which
    lead to overflow of map.m_len logic.

    This patch fixes that.

    Fixes: d3b6f23f7167 ("ext4: move ext4_fiemap to use iomap framework")
    Reported-by: syzbot+77fa5bdb65cc39711820@syzkaller.appspotmail.com
    Signed-off-by: Ritesh Harjani
    Reviewed-by: Jan Kara
    Signed-off-by: Christoph Hellwig
    Link: https://lore.kernel.org/r/20200505154324.3226743-2-hch@lst.de
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • Signed-off-by: Jonathan Grant
    Reviewed-by: Andreas Dilger
    Link: https://lore.kernel.org/r/ad3290d5-86af-99c1-f9d5-cd1bab710429@jguk.org
    Signed-off-by: Theodore Ts'o

    Jonathan Grant
     
  • When reserved transaction handle is unused, we subtract its reserved
    credits in __jbd2_journal_unreserve_handle() called from
    jbd2_journal_stop(). However this function forgets to remove reserved
    credits from transaction->t_outstanding_credits and thus the transaction
    space that was reserved remains effectively leaked. The leaked
    transaction space can be quite significant in some cases and leads to
    unnecessarily small transactions and thus reducing throughput of the
    journalling machinery. E.g. fsmark workload creating lots of 4k files
    was observed to have about 20% lower throughput due to this when ext4 is
    mounted with dioread_nolock mount option.

    Subtract reserved credits from t_outstanding_credits as well.

    CC: stable@vger.kernel.org
    Fixes: 8f7d89f36829 ("jbd2: transaction reservation support")
    Reviewed-by: Andreas Dilger
    Signed-off-by: Jan Kara
    Link: https://lore.kernel.org/r/20200520133119.1383-3-jack@suse.cz
    Signed-off-by: Theodore Ts'o

    Jan Kara
     
  • Remove ext4_journal_free_reserved() function. It is never used.

    Signed-off-by: Jan Kara
    Reviewed-by: Andreas Dilger
    Link: https://lore.kernel.org/r/20200520133119.1383-2-jack@suse.cz
    Signed-off-by: Theodore Ts'o

    Jan Kara
     
  • Currently while doing block allocation grp->bb_free may be getting
    modified if discard is happening in parallel.
    For e.g. consider a case where there are lot of threads who have
    preallocated lot of blocks and there is a thread which is trying
    to discard all of this group's PA. Now it could happen that
    we see all of those group's bb_free is zero and fail the allocation
    while there is sufficient space if we free up all the PA.

    So this patch adds another flag "EXT4_MB_STRICT_CHECK" which will be set
    if we are unable to allocate any blocks in the first try (since we may
    not have considered blocks about to be discarded from PA lists).
    So during retry attempt to allocate blocks we will use ext4_lock_group()
    for checking if the group is good or not.

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/9cb740a117c958c36596f167b12af1beae9a68b7.1589955723.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • ext4_mb_good_group() definition was changed some time back
    and now it even initializes the buddy cache (via ext4_mb_init_group()),
    if in case the EXT4_MB_GRP_NEED_INIT() is true for a group.
    Note that ext4_mb_init_group() could sleep and so should not be called
    under a spinlock held.
    This is fine as of now because ext4_mb_good_group() is called before
    loading the buddy bitmap without ext4_lock_group() held
    and again called after loading the bitmap, only this time with
    ext4_lock_group() held.
    But still this whole thing is confusing.

    So this patch refactors out ext4_mb_good_group_nolock() which should be
    called when without holding ext4_lock_group().
    Also in further patches we hold the spinlock (ext4_lock_group()) while
    doing any calculations which involves grp->bb_free or grp->bb_fragments.

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/d9f7d031a5fbe1c943fae6bf1ff5cdf0604ae722.1589955723.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • There could be a race in function ext4_mb_discard_group_preallocations()
    where the 1st thread may iterate through group's bb_prealloc_list and
    remove all the PAs and add to function's local list head.
    Now if the 2nd thread comes in to discard the group preallocations,
    it will see that the group->bb_prealloc_list is empty and will return 0.

    Consider for a case where we have less number of groups
    (for e.g. just group 0),
    this may even return an -ENOSPC error from ext4_mb_new_blocks()
    (where we call for ext4_mb_discard_group_preallocations()).
    But that is wrong, since 2nd thread should have waited for 1st thread
    to release all the PAs and should have retried for allocation.
    Since 1st thread was anyway going to discard the PAs.

    The algorithm using this percpu seq counter goes below:
    1. We sample the percpu discard_pa_seq counter before trying for block
    allocation in ext4_mb_new_blocks().
    2. We increment this percpu discard_pa_seq counter when we either allocate
    or free these blocks i.e. while marking those blocks as used/free in
    mb_mark_used()/mb_free_blocks().
    3. We also increment this percpu seq counter when we successfully identify
    that the bb_prealloc_list is not empty and hence proceed for discarding
    of those PAs inside ext4_mb_discard_group_preallocations().

    Now to make sure that the regular fast path of block allocation is not
    affected, as a small optimization we only sample the percpu seq counter
    on that cpu. Only when the block allocation fails and when freed blocks
    found were 0, that is when we sample percpu seq counter for all cpus using
    below function ext4_get_discard_pa_seq_sum(). This happens after making
    sure that all the PAs on grp->bb_prealloc_list got freed or if it's empty.

    It can be well argued that why don't just check for grp->bb_free to
    see if there are any free blocks to be allocated. So here are the two
    concerns which were discussed:-

    1. If for some reason the blocks available in the group are not
    appropriate for allocation logic (say for e.g.
    EXT4_MB_HINT_GOAL_ONLY, although this is not yet implemented), then
    the retry logic may result into infinte looping since grp->bb_free is
    non-zero.

    2. Also before preallocation was clubbed with block allocation with the
    same ext4_lock_group() held, there were lot of races where grp->bb_free
    could not be reliably relied upon.
    Due to above, this patch considers discard_pa_seq logic to determine if
    we should retry for block allocation. Say if there are are n threads
    trying for block allocation and none of those could allocate or discard
    any of the blocks, then all of those n threads will fail the block
    allocation and return -ENOSPC error. (Since the seq counter for all of
    those will match as no block allocation/discard was done during that
    duration).

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/7f254686903b87c419d798742fd9a1be34f0657b.1589955723.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • Implement ext4_mb_discard_preallocations_should_retry()
    which we will need in later patches to add more logic
    like check for sequence number match to see if we should
    retry for block allocation or not.

    There should be no functionality change in this patch.

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/1cfae0098d2aa9afbeb59331401258182868c8f2.1589955723.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • ext4_mb_discard_preallocations() only checks for grp->bb_prealloc_list
    of every group to discard the group's PA to free up the space if
    allocation request fails. Consider below race:-

    Process A Process B

    1. allocate blocks
    1. Fails block allocation from
    ext4_mb_regular_allocator()
    ext4_lock_group()
    allocated blocks
    more than ac_o_ex.fe_len
    ext4_unlock_group()
    2. Scans the
    grp->bb_prealloc_list (under
    ext4_lock_group()) and
    find nothing and thus return
    -ENOSPC.

    2. Add the additional blocks to PA list

    ext4_lock_group()
    add blocks to grp->bb_prealloc_list
    ext4_unlock_group()

    Above race could be avoided if we add those additional blocks to
    grp->bb_prealloc_list at the same time with block allocation when
    ext4_lock_group() was still held.
    With this discard-PA will know if there are actually any blocks which
    could be freed from the PA

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/a2217dd782585b42328981832e6d396abaaccb80.1589955723.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • No one currently needs EXT4_INODE_CASEFOLD, but add it to keep the
    EXT4_INODE_* definitions in sync with the EXT4_*_FL definitions.

    Also make it clearer that the casefold flag is only for directories.

    Signed-off-by: Eric Biggers
    Link: https://lore.kernel.org/r/20200510215252.87833-1-ebiggers@kernel.org
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • The path performing block allocations in ext4_ext_map_blocks() contains
    code trimming the length of a new extent that is repeated later
    in the function. This code is both redundant and unnecessary as the
    exact length of the new extent has already been calculated. Rewrite the
    instantiation of the map struct in this case to use the available
    values, avoiding the overhead of unnecessary conversions and improving
    clarity. Add another map struct instantiation tailored specifically to
    the separate case for an existing written extent. Remove an old comment
    that no longer appears applicable to the current code.

    Signed-off-by: Eric Whitney
    Link: https://lore.kernel.org/r/20200510155805.18808-1-enwlinux@gmail.com
    Signed-off-by: Theodore Ts'o
    Reviewed-by: Ritesh Harjani

    Eric Whitney
     
  • ext_debug() msgs could be helpful, provided those could be enabled
    without recompiling kernel and also if we could selectively enable
    only required prints for case by case debugging.

    So make ext_debug() implementation use pr_debug().
    Also change ext_debug() to be defined with CONFIG_EXT4_DEBUG.
    So EXT_DEBUG macro now mostly remain for below 3 functions.
    ext4_ext_show_path/leaf/move() (whose print msgs use ext_debug()
    which again could be dynamically enabled using pr_debug())

    This also changes the ext_debug() to take inode as a parameter
    to add inode no. in all of it's msgs.
    Prints additional info like process name / pid, superblock id etc.
    This also removes any explicit function names passed in ext_debug().
    Since ext_debug() on it's own prints file, func and line no.

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/d31dc189b0aeda9384fe7665e36da7cd8c61571f.1589086800.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • mb_debug() msg had only 1 control level for all type of msgs.
    And if we enable mballoc_debug then all of those msgs would be enabled.
    Instead of adding multiple debug levels for mb_debug() msgs, use
    pr_debug() with which we could have finer control to print msgs at all
    of different levels (i.e. at file, func, line no.).

    Also add process name/pid, superblk id, and other info in mb_debug()
    msg. This also kills the mballoc_debug module parameter, since it is
    not needed any more.

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/f0c660cbde9e2edbe95c67942ca9ad80dd2231eb.1589086800.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • Replace EXT_DEBUG with __maybe_unused from inside
    ext4_ext_handle_unwritten_extents() function.

    There should be no functionality change in this patch.

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/ae335b94506cd9db9d2648c1f4dd25a80f9f3ce2.1589086800.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • ext4_map_blocks() has ext_debug msg early at the start of function.
    We also get ext_debug msg if we could allocate a block from
    ext4_ext_map_blocks(). But there is no ext_debug() msg in case of
    block allocation failure. So add one along with error code.

    Also add more info in ext_debug() msg like how many blocks were allocated
    v/s how many were requested in ext4_ext_map_blocks().

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/1610ec2aa932396be00f9d552fe29da473ead176.1589086800.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • Simply use BIT() macro for all BH_** state bits instead of open
    coding it.

    There should be no functionality change in this patch.

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/57667689f51a3f9dba2fcef7d3425187fa3ba69f.1589086800.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • Use task_pid_nr() function instead of current->pid.
    There should be no functionality change in this patch.

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/4b58403e15e9c8deb34a1b93deb3fc9cd153ab84.1589086800.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • Make sure to check for e4b->bd_info->bb_bitmap == NULL, in
    mb_cmp_bitmaps() and return if NULL, to avoid possible NULL ptr
    dereference. Similar to how we do this in other ifdef DOUBLE_CHECK
    functions.

    Also remove the BUG_ON() logic if kmalloc() or ext4_read_block_bitmap()
    fails. We should simply mark grp->bb_bitmap as NULL if above happens.
    In fact ext4_read_block_bitmap() may even return an error in case of resize
    ioctl. Hence remove this BUG_ON logic (fstests ext4/032 may trigger
    this).

    Link: https://lore.kernel.org/r/9a54f8a696ff17c057cd571be3d15ac3ec1407f1.1589086800.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • This patch implemets mb_group_bb_bitmap_alloc() and
    mb_group_bb_bitmap_free() function to remove #ifdef DOUBLE_CHECK macro
    and it's related code from inside
    ext4_mb_add_groupinfo()/ext4_mb_release().

    There should be no functionality change in this patch.

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/8c2095d74b779f0254a19b24982490dc6f07c4f9.1589086800.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • Change return type of function ext4_mb_use_preallocated() to bool to
    better reflect what this function can return.

    There should be no functionality change in this patch.

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/7880cb6ef911465beafefcd7e9c3ea214688744b.1589086800.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • This patch simplifies error handling logic in ext4_init_mballoc(),
    by adding all the cleanups at one place at the end of that function.

    There should be no functionality change in this patch.

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/8621a7bc68f7107a9ac4292afeb784515333bd25.1589086800.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • Fix few other format specifiers in mb_debug() msgs.
    As such no other functionality change in this patch.

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/574fa7f833abf2dbf3b53a2fea3195e71f6cdbd8.1589086800.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • pa->pa_len is an integer. Fix all of the format specifier used in
    mb_debug() for pa_len to %d instead of %u.

    As such no functionality change in this patch.

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/af4987f643c586f62bcc9961e43f0a67151d5551.1589086800.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • This patch adds some more debugging mb_debug() msgs to help improve
    mballoc code debugging.
    Other than adding more mb_debug() msgs at few more places,
    there should be no other functionality change in this patch.

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/5fc8e7788b924e211fcfa4a4c1d2f8503511661a.1589086800.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • This factors out ext4_mb_show_pa() function to show all the group's
    preallocation info. This could be useful info to be added in later
    patches.

    There should be no functionality change in this patch.

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/8f07d890b0038dcc935e9c10e6043ec9f3792721.1589086800.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • Improve the debugging msg by also printing even if bb_free is 0.

    Signed-off-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/c894f1d1d30f86ae38f4e3a861949665b6dc61cd.1589086800.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o

    Ritesh Harjani
     
  • We can't fail in the truncate path without requiring an fsck.
    Add work around for this by using a combination of retry loops
    and the __GFP_NOFAIL flag.

    From: Theodore Ts'o
    Signed-off-by: Theodore Ts'o
    Signed-off-by: Anna Pendleton
    Reviewed-by: Harshad Shirwadkar
    Link: https://lore.kernel.org/r/20200507175028.15061-1-pendleton@google.com
    Signed-off-by: Theodore Ts'o

    Theodore Ts'o
     
  • 'igrab(d_inode(dentry->d_parent))' without holding dentry->d_lock is
    broken because without d_lock, d_parent can be concurrently changed due
    to a rename(). Then if the old directory is immediately deleted, old
    d_parent->inode can be NULL. That causes a NULL dereference in igrab().

    To fix this, use dget_parent() to safely grab a reference to the parent
    dentry, which pins the inode. This also eliminates the need to use
    d_find_any_alias() other than for the initial inode, as we no longer
    throw away the dentry at each step.

    This is an extremely hard race to hit, but it is possible. Adding a
    udelay() in between the reads of ->d_parent and its ->d_inode makes it
    reproducible on a no-journal filesystem using the following program:

    #include
    #include

    int main()
    {
    if (fork()) {
    for (;;) {
    mkdir("dir1", 0700);
    int fd = open("dir1/file", O_RDWR|O_CREAT|O_SYNC);
    write(fd, "X", 1);
    close(fd);
    }
    } else {
    mkdir("dir2", 0700);
    for (;;) {
    rename("dir1/file", "dir2/file");
    rmdir("dir1");
    }
    }
    }

    Fixes: d59729f4e794 ("ext4: fix races in ext4_sync_parent()")
    Cc: stable@vger.kernel.org
    Signed-off-by: Eric Biggers
    Link: https://lore.kernel.org/r/20200506183140.541194-1-ebiggers@kernel.org
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • s/extnets/extents/

    Signed-off-by: Christophe JAILLET
    Link: https://lore.kernel.org/r/20200503200647.154701-1-christophe.jaillet@wanadoo.fr
    Signed-off-by: Theodore Ts'o

    Christophe JAILLET
     
  • If ext4_ext_convert_to_initialized() fails when called within
    ext4_ext_handle_unwritten_extents(), immediately error out through the
    exit point at function end. Fix the error handling in the event
    ext4_ext_convert_to_initialized() returns 0, which it shouldn't do when
    converting an existing extent. The current code returns the passed in
    value of allocated (which is likely non-zero) while failing to set
    m_flags, m_pblk, and m_len.

    Signed-off-by: Eric Whitney
    Link: https://lore.kernel.org/r/20200430185320.23001-5-enwlinux@gmail.com
    Signed-off-by: Theodore Ts'o

    Eric Whitney
     
  • If the call to ext4_split_convert_extents() fails in the
    EXT4_GET_BLOCKS_PRE_IO case within ext4_ext_handle_unwritten_extents(),
    error out through the exit point at function end rather than jumping
    through an intermediate point. Fix the error handling in the event
    ext4_split_convert_extents() returns 0, which it shouldn't do when
    splitting an existing extent. The current code returns the passed in
    value of allocated (which is likely non-zero) while failing to set
    m_flags, m_pblk, and m_len.

    Signed-off-by: Eric Whitney
    Link: https://lore.kernel.org/r/20200430185320.23001-4-enwlinux@gmail.com
    Signed-off-by: Theodore Ts'o

    Eric Whitney
     
  • Remove the redundant code assigning values to ext4_map_blocks components
    in ext4_ext_handle_unwritten_extents() for the EXT4_GET_BLOCKS_CONVERT
    case, using the code at the function exit instead. Clean up and reorder
    that code to eliminate more redundancy and improve readability.

    Signed-off-by: Eric Whitney
    Link: https://lore.kernel.org/r/20200430185320.23001-3-enwlinux@gmail.com
    Signed-off-by: Theodore Ts'o

    Eric Whitney
     
  • There's no call to ext4_map_blocks() in the current ext4 code with a
    flags argument that combines EXT4_GET_BLOCKS_CONVERT and
    EXT4_GET_BLOCKS_ZERO. Remove the code that corresponds to this case
    from ext4_ext_handle_unwritten_extents().

    Signed-off-by: Eric Whitney
    Reviewed-by: Ritesh Harjani
    Link: https://lore.kernel.org/r/20200430185320.23001-2-enwlinux@gmail.com
    Signed-off-by: Theodore Ts'o

    Eric Whitney
     
  • Don't ignore return values from ext4_ext_dirty, since the errors
    indicate valid failures below Ext4. In all of the other instances of
    ext4_ext_dirty calls, the error return value is handled in some
    way. This patch makes those remaining couple of places to handle
    ext4_ext_dirty errors as well. In case of ext4_split_extent_at(), the
    ignorance of return value is intentional. The reason is that we are
    already in error path and there isn't much we can do if ext4_ext_dirty
    returns error. This patch adds a comment for that case explaining why
    we ignore the return value.

    In the longer run, we probably should
    make sure that errors from other mark_dirty routines are handled as
    well.

    Ran gce-xfstests smoke tests and verified that there were no
    regressions.

    Signed-off-by: Harshad Shirwadkar
    Reviewed-by: Jan Kara
    Link: https://lore.kernel.org/r/20200427013438.219117-2-harshadshirwadkar@gmail.com
    Signed-off-by: Theodore Ts'o

    Harshad Shirwadkar
     
  • ext4_mark_inode_dirty() can fail for real reasons. Ignoring its return
    value may lead ext4 to ignore real failures that would result in
    corruption / crashes. Harden ext4_mark_inode_dirty error paths to fail
    as soon as possible and return errors to the caller whenever
    appropriate.

    One of the possible scnearios when this bug could affected is that
    while creating a new inode, its directory entry gets added
    successfully but while writing the inode itself mark_inode_dirty
    returns error which is ignored. This would result in inconsistency
    that the directory entry points to a non-existent inode.

    Ran gce-xfstests smoke tests and verified that there were no
    regressions.

    Signed-off-by: Harshad Shirwadkar
    Link: https://lore.kernel.org/r/20200427013438.219117-1-harshadshirwadkar@gmail.com
    Signed-off-by: Theodore Ts'o

    Harshad Shirwadkar