Merge tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 6 Feb 2022 18:34:45 +0000 (10:34 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 6 Feb 2022 18:34:45 +0000 (10:34 -0800)
Pull ext4 fixes from Ted Ts'o:
 "Various bug fixes for ext4 fast commit and inline data handling.

  Also fix regression introduced as part of moving to the new mount API"

* tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
  fs/ext4: fix comments mentioning i_mutex
  ext4: fix incorrect type issue during replay_del_range
  jbd2: fix kernel-doc descriptions for jbd2_journal_shrink_{scan,count}()
  ext4: fix potential NULL pointer dereference in ext4_fill_super()
  jbd2: refactor wait logic for transaction updates into a common function
  jbd2: cleanup unused functions declarations from jbd2.h
  ext4: fix error handling in ext4_fc_record_modified_inode()
  ext4: remove redundant max inline_size check in ext4_da_write_inline_data_begin()
  ext4: fix error handling in ext4_restore_inline_data()
  ext4: fast commit may miss file actions
  ext4: fast commit may not fallback for ineligible commit
  ext4: modify the logic of ext4_mb_new_blocks_simple
  ext4: prevent used blocks from being allocated during fast commit replay

1  2 
fs/ext4/ext4.h
fs/ext4/extents.c
fs/ext4/inline.c
fs/ext4/inode.c
fs/ext4/mballoc.c
fs/ext4/namei.c
fs/ext4/super.c
fs/jbd2/journal.c

diff --combined fs/ext4/ext4.h
index 242e74cfb06064c93b9f3b5c490bade784045007,09d8f60ebf0f78478fc4762e818153c62d6e68f0..bcd3b9bf8069b26d93836a1ed64fd4716f7a1674
@@@ -1028,7 -1028,7 +1028,7 @@@ struct ext4_inode_info 
  
        /*
         * Extended attributes can be read independently of the main file
-        * data. Taking i_mutex even when reading would cause contention
+        * data. Taking i_rwsem even when reading would cause contention
         * between readers of EAs and writers of regular file data, so
         * instead we synchronize on xattr_sem when reading or changing
         * EAs.
@@@ -1699,7 -1699,6 +1699,7 @@@ struct ext4_sb_info 
         */
        struct percpu_rw_semaphore s_writepages_rwsem;
        struct dax_device *s_daxdev;
 +      u64 s_dax_part_off;
  #ifdef CONFIG_EXT4_DEBUG
        unsigned long s_simulate_fail;
  #endif
        spinlock_t s_fc_lock;
        struct buffer_head *s_fc_bh;
        struct ext4_fc_stats s_fc_stats;
+       tid_t s_fc_ineligible_tid;
  #ifdef CONFIG_EXT4_DEBUG
        int s_fc_debug_max_replay;
  #endif
@@@ -1795,10 -1795,7 +1796,7 @@@ static inline int ext4_valid_inum(struc
  enum {
        EXT4_MF_MNTDIR_SAMPLED,
        EXT4_MF_FS_ABORTED,     /* Fatal error detected */
-       EXT4_MF_FC_INELIGIBLE,  /* Fast commit ineligible */
-       EXT4_MF_FC_COMMITTING   /* File system underoing a fast
-                                * commit.
-                                */
+       EXT4_MF_FC_INELIGIBLE   /* Fast commit ineligible */
  };
  
  static inline void ext4_set_mount_flag(struct super_block *sb, int bit)
@@@ -2485,7 -2482,7 +2483,7 @@@ struct ext4_filename 
  #ifdef CONFIG_FS_ENCRYPTION
        struct fscrypt_str crypto_buf;
  #endif
 -#ifdef CONFIG_UNICODE
 +#if IS_ENABLED(CONFIG_UNICODE)
        struct fscrypt_str cf_name;
  #endif
  };
@@@ -2721,7 -2718,7 +2719,7 @@@ extern unsigned ext4_free_clusters_afte
                                              struct ext4_group_desc *gdp);
  ext4_fsblk_t ext4_inode_to_goal_block(struct inode *);
  
 -#ifdef CONFIG_UNICODE
 +#if IS_ENABLED(CONFIG_UNICODE)
  extern int ext4_fname_setup_ci_filename(struct inode *dir,
                                         const struct qstr *iname,
                                         struct ext4_filename *fname);
@@@ -2754,7 -2751,7 +2752,7 @@@ static inline int ext4_fname_setup_file
  
        ext4_fname_from_fscrypt_name(fname, &name);
  
 -#ifdef CONFIG_UNICODE
 +#if IS_ENABLED(CONFIG_UNICODE)
        err = ext4_fname_setup_ci_filename(dir, iname, fname);
  #endif
        return err;
@@@ -2773,7 -2770,7 +2771,7 @@@ static inline int ext4_fname_prepare_lo
  
        ext4_fname_from_fscrypt_name(fname, &name);
  
 -#ifdef CONFIG_UNICODE
 +#if IS_ENABLED(CONFIG_UNICODE)
        err = ext4_fname_setup_ci_filename(dir, &dentry->d_name, fname);
  #endif
        return err;
@@@ -2790,7 -2787,7 +2788,7 @@@ static inline void ext4_fname_free_file
        fname->usr_fname = NULL;
        fname->disk_name.name = NULL;
  
 -#ifdef CONFIG_UNICODE
 +#if IS_ENABLED(CONFIG_UNICODE)
        kfree(fname->cf_name.name);
        fname->cf_name.name = NULL;
  #endif
@@@ -2806,7 -2803,7 +2804,7 @@@ static inline int ext4_fname_setup_file
        fname->disk_name.name = (unsigned char *) iname->name;
        fname->disk_name.len = iname->len;
  
 -#ifdef CONFIG_UNICODE
 +#if IS_ENABLED(CONFIG_UNICODE)
        err = ext4_fname_setup_ci_filename(dir, iname, fname);
  #endif
  
@@@ -2822,7 -2819,7 +2820,7 @@@ static inline int ext4_fname_prepare_lo
  
  static inline void ext4_fname_free_filename(struct ext4_filename *fname)
  {
 -#ifdef CONFIG_UNICODE
 +#if IS_ENABLED(CONFIG_UNICODE)
        kfree(fname->cf_name.name);
        fname->cf_name.name = NULL;
  #endif
@@@ -2926,7 -2923,7 +2924,7 @@@ void __ext4_fc_track_create(handle_t *h
                            struct dentry *dentry);
  void ext4_fc_track_create(handle_t *handle, struct dentry *dentry);
  void ext4_fc_track_inode(handle_t *handle, struct inode *inode);
- void ext4_fc_mark_ineligible(struct super_block *sb, int reason);
+ void ext4_fc_mark_ineligible(struct super_block *sb, int reason, handle_t *handle);
  void ext4_fc_start_update(struct inode *inode);
  void ext4_fc_stop_update(struct inode *inode);
  void ext4_fc_del(struct inode *inode);
@@@ -2935,6 -2932,9 +2933,9 @@@ void ext4_fc_replay_cleanup(struct supe
  int ext4_fc_commit(journal_t *journal, tid_t commit_tid);
  int __init ext4_fc_init_dentry_cache(void);
  void ext4_fc_destroy_dentry_cache(void);
+ int ext4_fc_record_regions(struct super_block *sb, int ino,
+                          ext4_lblk_t lblk, ext4_fsblk_t pblk,
+                          int len, int replay);
  
  /* mballoc.c */
  extern const struct seq_operations ext4_mb_seq_groups_ops;
@@@ -3407,7 -3407,7 +3408,7 @@@ do {                                                            
  #define EXT4_FREECLUSTERS_WATERMARK 0
  #endif
  
- /* Update i_disksize. Requires i_mutex to avoid races with truncate */
+ /* Update i_disksize. Requires i_rwsem to avoid races with truncate */
  static inline void ext4_update_i_disksize(struct inode *inode, loff_t newsize)
  {
        WARN_ON_ONCE(S_ISREG(inode->i_mode) &&
        up_write(&EXT4_I(inode)->i_data_sem);
  }
  
- /* Update i_size, i_disksize. Requires i_mutex to avoid races with truncate */
+ /* Update i_size, i_disksize. Requires i_rwsem to avoid races with truncate */
  static inline int ext4_update_inode_size(struct inode *inode, loff_t newsize)
  {
        int changed = 0;
diff --combined fs/ext4/extents.c
index 74c91da585d7f9f7e1e775c78f269dabf71f5997,190c284e0a8124bfbbe4adc93f520aa433cd6e62..c0f3f83e0c1b1f6a5ec5f45f2d0885810f30d1dc
@@@ -27,8 -27,8 +27,8 @@@
  #include <linux/slab.h>
  #include <linux/uaccess.h>
  #include <linux/fiemap.h>
 -#include <linux/backing-dev.h>
  #include <linux/iomap.h>
 +#include <linux/sched/mm.h>
  #include "ext4_jbd2.h"
  #include "ext4_extents.h"
  #include "xattr.h"
@@@ -97,7 -97,7 +97,7 @@@ static int ext4_ext_trunc_restart_fn(st
         * Drop i_data_sem to avoid deadlock with ext4_map_blocks.  At this
         * moment, get_block can be called only for blocks inside i_size since
         * page cache has been already dropped and writes are blocked by
-        * i_mutex. So we can safely drop the i_data_sem here.
+        * i_rwsem. So we can safely drop the i_data_sem here.
         */
        BUG_ON(EXT4_JOURNAL(inode) == NULL);
        ext4_discard_preallocations(inode, 0);
@@@ -4404,7 -4404,8 +4404,7 @@@ retry
        err = ext4_es_remove_extent(inode, last_block,
                                    EXT_MAX_BLOCKS - last_block);
        if (err == -ENOMEM) {
 -              cond_resched();
 -              congestion_wait(BLK_RW_ASYNC, HZ/50);
 +              memalloc_retry_wait(GFP_ATOMIC);
                goto retry;
        }
        if (err)
  retry_remove_space:
        err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCKS - 1);
        if (err == -ENOMEM) {
 -              cond_resched();
 -              congestion_wait(BLK_RW_ASYNC, HZ/50);
 +              memalloc_retry_wait(GFP_ATOMIC);
                goto retry_remove_space;
        }
        return err;
@@@ -4572,7 -4574,7 +4572,7 @@@ static long ext4_zero_range(struct fil
  
        flags = EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT;
  
-       /* Wait all existing dio workers, newcomers will block on i_mutex */
+       /* Wait all existing dio workers, newcomers will block on i_rwsem */
        inode_dio_wait(inode);
  
        /* Preallocate the range including the unaligned edges */
@@@ -4738,7 -4740,7 +4738,7 @@@ long ext4_fallocate(struct file *file, 
                        goto out;
        }
  
-       /* Wait all existing dio workers, newcomers will block on i_mutex */
+       /* Wait all existing dio workers, newcomers will block on i_rwsem */
        inode_dio_wait(inode);
  
        ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size, flags);
@@@ -5334,7 -5336,7 +5334,7 @@@ static int ext4_collapse_range(struct i
                ret = PTR_ERR(handle);
                goto out_mmap;
        }
-       ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE);
+       ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE, handle);
  
        down_write(&EXT4_I(inode)->i_data_sem);
        ext4_discard_preallocations(inode, 0);
@@@ -5474,7 -5476,7 +5474,7 @@@ static int ext4_insert_range(struct ino
                ret = PTR_ERR(handle);
                goto out_mmap;
        }
-       ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE);
+       ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_FALLOC_RANGE, handle);
  
        /* Expand file to avoid data loss if there is error while shifting */
        inode->i_size += len;
@@@ -5571,7 -5573,7 +5571,7 @@@ out_mutex
   * stuff such as page-cache locking consistency, bh mapping consistency or
   * extent's data copying must be performed by caller.
   * Locking:
-  *            i_mutex is held for both inodes
+  *            i_rwsem is held for both inodes
   *            i_data_sem is locked for write for both inodes
   * Assumptions:
   *            All pages from requested range are locked for both inodes
@@@ -6091,11 -6093,15 +6091,15 @@@ int ext4_ext_clear_bb(struct inode *ino
  
                                        ext4_mb_mark_bb(inode->i_sb,
                                                        path[j].p_block, 1, 0);
+                                       ext4_fc_record_regions(inode->i_sb, inode->i_ino,
+                                                       0, path[j].p_block, 1, 1);
                                }
                                ext4_ext_drop_refs(path);
                                kfree(path);
                        }
                        ext4_mb_mark_bb(inode->i_sb, map.m_pblk, map.m_len, 0);
+                       ext4_fc_record_regions(inode->i_sb, inode->i_ino,
+                                       map.m_lblk, map.m_pblk, map.m_len, 1);
                }
                cur = cur + map.m_len;
        }
diff --combined fs/ext4/inline.c
index 635bcf68a67eca5a29f95e3d9ff6e8cc125e63a2,cbdd84e49f2c68f8eca2a74d0971e70f0e953c6e..e429418036050edb6a4e0c5d0deeeec5e313b1fb
@@@ -7,7 -7,7 +7,7 @@@
  #include <linux/iomap.h>
  #include <linux/fiemap.h>
  #include <linux/iversion.h>
 -#include <linux/backing-dev.h>
 +#include <linux/sched/mm.h>
  
  #include "ext4_jbd2.h"
  #include "ext4.h"
@@@ -911,7 -911,7 +911,7 @@@ int ext4_da_write_inline_data_begin(str
                                    struct page **pagep,
                                    void **fsdata)
  {
-       int ret, inline_size;
+       int ret;
        handle_t *handle;
        struct page *page;
        struct ext4_iloc iloc;
@@@ -928,14 -928,9 +928,9 @@@ retry_journal
                goto out;
        }
  
-       inline_size = ext4_get_max_inline_size(inode);
-       ret = -ENOSPC;
-       if (inline_size >= pos + len) {
-               ret = ext4_prepare_inline_data(handle, inode, pos + len);
-               if (ret && ret != -ENOSPC)
-                       goto out_journal;
-       }
+       ret = ext4_prepare_inline_data(handle, inode, pos + len);
+       if (ret && ret != -ENOSPC)
+               goto out_journal;
  
        /*
         * We cannot recurse into the filesystem as the transaction
@@@ -1133,7 -1128,15 +1128,15 @@@ static void ext4_restore_inline_data(ha
                                     struct ext4_iloc *iloc,
                                     void *buf, int inline_size)
  {
-       ext4_create_inline_data(handle, inode, inline_size);
+       int ret;
+       ret = ext4_create_inline_data(handle, inode, inline_size);
+       if (ret) {
+               ext4_msg(inode->i_sb, KERN_EMERG,
+                       "error restoring inline_data for inode -- potential data loss! (inode %lu, error %d)",
+                       inode->i_ino, ret);
+               return;
+       }
        ext4_write_inline_data(inode, iloc, buf, 0, inline_size);
        ext4_set_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);
  }
@@@ -1929,7 -1932,8 +1932,7 @@@ int ext4_inline_data_truncate(struct in
  retry:
                        err = ext4_es_remove_extent(inode, 0, EXT_MAX_BLOCKS);
                        if (err == -ENOMEM) {
 -                              cond_resched();
 -                              congestion_wait(BLK_RW_ASYNC, HZ/50);
 +                              memalloc_retry_wait(GFP_ATOMIC);
                                goto retry;
                        }
                        if (err)
diff --combined fs/ext4/inode.c
index 5f79d265d06a023d7204ea773e59ffc852f2c40a,d2a29fc93742e9e99285707855e9339faa31242c..01c9e4f743ba9a6ed0b03c283574fd1ffb3632e2
@@@ -41,7 -41,6 +41,7 @@@
  #include <linux/bitops.h>
  #include <linux/iomap.h>
  #include <linux/iversion.h>
 +#include <linux/dax.h>
  
  #include "ext4_jbd2.h"
  #include "xattr.h"
@@@ -338,7 -337,7 +338,7 @@@ stop_handle
        return;
  no_delete:
        if (!list_empty(&EXT4_I(inode)->i_fc_list))
-               ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_NOMEM);
+               ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_NOMEM, NULL);
        ext4_clear_inode(inode);        /* We must guarantee clearing of inode... */
  }
  
@@@ -1224,7 -1223,7 +1224,7 @@@ retry_journal
                /*
                 * __block_write_begin may have instantiated a few blocks
                 * outside i_size.  Trim these off again. Don't need
-                * i_size_read because we hold i_mutex.
+                * i_size_read because we hold i_rwsem.
                 *
                 * Add inode to orphan list in case we crash before
                 * truncate finishes
@@@ -3254,7 -3253,7 +3254,7 @@@ static bool ext4_inode_datasync_dirty(s
  
  static void ext4_set_iomap(struct inode *inode, struct iomap *iomap,
                           struct ext4_map_blocks *map, loff_t offset,
 -                         loff_t length)
 +                         loff_t length, unsigned int flags)
  {
        u8 blkbits = inode->i_blkbits;
  
        if (map->m_flags & EXT4_MAP_NEW)
                iomap->flags |= IOMAP_F_NEW;
  
 -      iomap->bdev = inode->i_sb->s_bdev;
 -      iomap->dax_dev = EXT4_SB(inode->i_sb)->s_daxdev;
 +      if (flags & IOMAP_DAX)
 +              iomap->dax_dev = EXT4_SB(inode->i_sb)->s_daxdev;
 +      else
 +              iomap->bdev = inode->i_sb->s_bdev;
        iomap->offset = (u64) map->m_lblk << blkbits;
        iomap->length = (u64) map->m_len << blkbits;
  
        if (map->m_flags & EXT4_MAP_UNWRITTEN) {
                iomap->type = IOMAP_UNWRITTEN;
                iomap->addr = (u64) map->m_pblk << blkbits;
 +              if (flags & IOMAP_DAX)
 +                      iomap->addr += EXT4_SB(inode->i_sb)->s_dax_part_off;
        } else if (map->m_flags & EXT4_MAP_MAPPED) {
                iomap->type = IOMAP_MAPPED;
                iomap->addr = (u64) map->m_pblk << blkbits;
 +              if (flags & IOMAP_DAX)
 +                      iomap->addr += EXT4_SB(inode->i_sb)->s_dax_part_off;
        } else {
                iomap->type = IOMAP_HOLE;
                iomap->addr = IOMAP_NULL_ADDR;
@@@ -3337,8 -3330,8 +3337,8 @@@ retry
         * DAX and direct I/O are the only two operations that are currently
         * supported with IOMAP_WRITE.
         */
 -      WARN_ON(!IS_DAX(inode) && !(flags & IOMAP_DIRECT));
 -      if (IS_DAX(inode))
 +      WARN_ON(!(flags & (IOMAP_DAX | IOMAP_DIRECT)));
 +      if (flags & IOMAP_DAX)
                m_flags = EXT4_GET_BLOCKS_CREATE_ZERO;
        /*
         * We use i_size instead of i_disksize here because delalloc writeback
@@@ -3409,7 -3402,7 +3409,7 @@@ static int ext4_iomap_begin(struct inod
        if (ret < 0)
                return ret;
  out:
 -      ext4_set_iomap(inode, iomap, &map, offset, length);
 +      ext4_set_iomap(inode, iomap, &map, offset, length, flags);
  
        return 0;
  }
@@@ -3529,7 -3522,7 +3529,7 @@@ static int ext4_iomap_begin_report(stru
                delalloc = ext4_iomap_is_delalloc(inode, &map);
  
  set_iomap:
 -      ext4_set_iomap(inode, iomap, &map, offset, length);
 +      ext4_set_iomap(inode, iomap, &map, offset, length, flags);
        if (delalloc && iomap->type == IOMAP_HOLE)
                iomap->type = IOMAP_DELALLOC;
  
@@@ -3769,8 -3762,8 +3769,8 @@@ static int ext4_block_zero_page_range(h
                length = max;
  
        if (IS_DAX(inode)) {
 -              return iomap_zero_range(inode, from, length, NULL,
 -                                      &ext4_iomap_ops);
 +              return dax_zero_range(inode, from, length, NULL,
 +                                    &ext4_iomap_ops);
        }
        return __ext4_block_zero_page_range(handle, mapping, from, length);
  }
@@@ -3979,7 -3972,7 +3979,7 @@@ int ext4_punch_hole(struct inode *inode
  
        }
  
-       /* Wait all existing dio workers, newcomers will block on i_mutex */
+       /* Wait all existing dio workers, newcomers will block on i_rwsem */
        inode_dio_wait(inode);
  
        /*
@@@ -4129,7 -4122,7 +4129,7 @@@ int ext4_truncate(struct inode *inode
        /*
         * There is a possibility that we're either freeing the inode
         * or it's a completely new inode. In those cases we might not
-        * have i_mutex locked because it's not necessary.
+        * have i_rwsem locked because it's not necessary.
         */
        if (!(inode->i_state & (I_NEW|I_FREEING)))
                WARN_ON(!inode_is_locked(inode));
@@@ -5271,7 -5264,7 +5271,7 @@@ static void ext4_wait_for_tail_page_com
   * transaction are already on disk (truncate waits for pages under
   * writeback).
   *
-  * Called with inode->i_mutex down.
+  * Called with inode->i_rwsem down.
   */
  int ext4_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
                 struct iattr *attr)
@@@ -5983,7 -5976,7 +5983,7 @@@ int ext4_change_inode_journal_flag(stru
                return PTR_ERR(handle);
  
        ext4_fc_mark_ineligible(inode->i_sb,
-               EXT4_FC_REASON_JOURNAL_FLAG_CHANGE);
+               EXT4_FC_REASON_JOURNAL_FLAG_CHANGE, handle);
        err = ext4_mark_inode_dirty(handle, inode);
        ext4_handle_sync(handle);
        ext4_journal_stop(handle);
diff --combined fs/ext4/mballoc.c
index 9f86dd947032706b61db6f0b2a0f5cc699bf13a5,c781974df9d0fb569239f4143446488f023db810..67ac95c4cd9b8308e9ab60d2fbaea55514d9c0ca
@@@ -2834,7 -2834,7 +2834,7 @@@ out
  
  static void *ext4_mb_seq_groups_start(struct seq_file *seq, loff_t *pos)
  {
 -      struct super_block *sb = PDE_DATA(file_inode(seq->file));
 +      struct super_block *sb = pde_data(file_inode(seq->file));
        ext4_group_t group;
  
        if (*pos < 0 || *pos >= ext4_get_groups_count(sb))
  
  static void *ext4_mb_seq_groups_next(struct seq_file *seq, void *v, loff_t *pos)
  {
 -      struct super_block *sb = PDE_DATA(file_inode(seq->file));
 +      struct super_block *sb = pde_data(file_inode(seq->file));
        ext4_group_t group;
  
        ++*pos;
  
  static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
  {
 -      struct super_block *sb = PDE_DATA(file_inode(seq->file));
 +      struct super_block *sb = pde_data(file_inode(seq->file));
        ext4_group_t group = (ext4_group_t) ((unsigned long) v);
        int i;
        int err, buddy_loaded = 0;
@@@ -2985,7 -2985,7 +2985,7 @@@ int ext4_seq_mb_stats_show(struct seq_f
  static void *ext4_mb_seq_structs_summary_start(struct seq_file *seq, loff_t *pos)
  __acquires(&EXT4_SB(sb)->s_mb_rb_lock)
  {
 -      struct super_block *sb = PDE_DATA(file_inode(seq->file));
 +      struct super_block *sb = pde_data(file_inode(seq->file));
        unsigned long position;
  
        read_lock(&EXT4_SB(sb)->s_mb_rb_lock);
  
  static void *ext4_mb_seq_structs_summary_next(struct seq_file *seq, void *v, loff_t *pos)
  {
 -      struct super_block *sb = PDE_DATA(file_inode(seq->file));
 +      struct super_block *sb = pde_data(file_inode(seq->file));
        unsigned long position;
  
        ++*pos;
  
  static int ext4_mb_seq_structs_summary_show(struct seq_file *seq, void *v)
  {
 -      struct super_block *sb = PDE_DATA(file_inode(seq->file));
 +      struct super_block *sb = pde_data(file_inode(seq->file));
        struct ext4_sb_info *sbi = EXT4_SB(sb);
        unsigned long position = ((unsigned long) v);
        struct ext4_group_info *grp;
  static void ext4_mb_seq_structs_summary_stop(struct seq_file *seq, void *v)
  __releases(&EXT4_SB(sb)->s_mb_rb_lock)
  {
 -      struct super_block *sb = PDE_DATA(file_inode(seq->file));
 +      struct super_block *sb = pde_data(file_inode(seq->file));
  
        read_unlock(&EXT4_SB(sb)->s_mb_rb_lock);
  }
@@@ -5753,7 -5753,8 +5753,8 @@@ static ext4_fsblk_t ext4_mb_new_blocks_
        struct super_block *sb = ar->inode->i_sb;
        ext4_group_t group;
        ext4_grpblk_t blkoff;
-       int i = sb->s_blocksize;
+       ext4_grpblk_t max = EXT4_CLUSTERS_PER_GROUP(sb);
+       ext4_grpblk_t i = 0;
        ext4_fsblk_t goal, block;
        struct ext4_super_block *es = EXT4_SB(sb)->s_es;
  
                ext4_get_group_no_and_offset(sb,
                        max(ext4_group_first_block_no(sb, group), goal),
                        NULL, &blkoff);
-               i = mb_find_next_zero_bit(bitmap_bh->b_data, sb->s_blocksize,
+               while (1) {
+                       i = mb_find_next_zero_bit(bitmap_bh->b_data, max,
                                                blkoff);
+                       if (i >= max)
+                               break;
+                       if (ext4_fc_replay_check_excluded(sb,
+                               ext4_group_first_block_no(sb, group) + i)) {
+                               blkoff = i + 1;
+                       } else
+                               break;
+               }
                brelse(bitmap_bh);
-               if (i >= sb->s_blocksize)
-                       continue;
-               if (ext4_fc_replay_check_excluded(sb,
-                       ext4_group_first_block_no(sb, group) + i))
-                       continue;
-               break;
+               if (i < max)
+                       break;
        }
  
-       if (group >= ext4_get_groups_count(sb) && i >= sb->s_blocksize)
+       if (group >= ext4_get_groups_count(sb) || i >= max) {
+               *errp = -ENOSPC;
                return 0;
+       }
  
        block = ext4_group_first_block_no(sb, group) + i;
        ext4_mb_mark_bb(sb, block, 1, 1);
diff --combined fs/ext4/namei.c
index 269d2d051edeb00f3785cef3d4a87257dd01fd2f,47b9f87dbc6f792cc38f2b9bd9b762aa8cb30aca..8cf0a924a49bfc1f4cf79276307141941e31b388
@@@ -1317,7 -1317,7 +1317,7 @@@ static void dx_insert_block(struct dx_f
        dx_set_count(entries, count + 1);
  }
  
 -#ifdef CONFIG_UNICODE
 +#if IS_ENABLED(CONFIG_UNICODE)
  /*
   * Test whether a case-insensitive directory entry matches the filename
   * being searched for.  If quick is set, assume the name being looked up
@@@ -1428,7 -1428,7 +1428,7 @@@ static bool ext4_match(struct inode *pa
        f.crypto_buf = fname->crypto_buf;
  #endif
  
 -#ifdef CONFIG_UNICODE
 +#if IS_ENABLED(CONFIG_UNICODE)
        if (parent->i_sb->s_encoding && IS_CASEFOLDED(parent) &&
            (!IS_ENCRYPTED(parent) || fscrypt_has_encryption_key(parent))) {
                if (fname->cf_name.name) {
@@@ -1800,7 -1800,7 +1800,7 @@@ static struct dentry *ext4_lookup(struc
                }
        }
  
 -#ifdef CONFIG_UNICODE
 +#if IS_ENABLED(CONFIG_UNICODE)
        if (!inode && IS_CASEFOLDED(dir)) {
                /* Eventually we want to call d_add_ci(dentry, NULL)
                 * for negative dentries in the encoding case as
@@@ -2308,7 -2308,7 +2308,7 @@@ static int ext4_add_entry(handle_t *han
        if (fscrypt_is_nokey_name(dentry))
                return -ENOKEY;
  
 -#ifdef CONFIG_UNICODE
 +#if IS_ENABLED(CONFIG_UNICODE)
        if (sb_has_strict_encoding(sb) && IS_CASEFOLDED(dir) &&
            sb->s_encoding && utf8_validate(sb->s_encoding, &dentry->d_name))
                return -EINVAL;
@@@ -3126,7 -3126,7 +3126,7 @@@ static int ext4_rmdir(struct inode *dir
        ext4_fc_track_unlink(handle, dentry);
        retval = ext4_mark_inode_dirty(handle, dir);
  
 -#ifdef CONFIG_UNICODE
 +#if IS_ENABLED(CONFIG_UNICODE)
        /* VFS negative dentries are incompatible with Encoding and
         * Case-insensitiveness. Eventually we'll want avoid
         * invalidating the dentries here, alongside with returning the
@@@ -3231,7 -3231,7 +3231,7 @@@ static int ext4_unlink(struct inode *di
        retval = __ext4_unlink(handle, dir, &dentry->d_name, d_inode(dentry));
        if (!retval)
                ext4_fc_track_unlink(handle, dentry);
 -#ifdef CONFIG_UNICODE
 +#if IS_ENABLED(CONFIG_UNICODE)
        /* VFS negative dentries are incompatible with Encoding and
         * Case-insensitiveness. Eventually we'll want avoid
         * invalidating the dentries here, alongside with returning the
@@@ -3889,7 -3889,7 +3889,7 @@@ static int ext4_rename(struct user_name
                 * dirents in directories.
                 */
                ext4_fc_mark_ineligible(old.inode->i_sb,
-                       EXT4_FC_REASON_RENAME_DIR);
+                       EXT4_FC_REASON_RENAME_DIR, handle);
        } else {
                if (new.inode)
                        ext4_fc_track_unlink(handle, new.dentry);
@@@ -4049,7 -4049,7 +4049,7 @@@ static int ext4_cross_rename(struct ino
        if (unlikely(retval))
                goto end_rename;
        ext4_fc_mark_ineligible(new.inode->i_sb,
-                               EXT4_FC_REASON_CROSS_RENAME);
+                               EXT4_FC_REASON_CROSS_RENAME, handle);
        if (old.dir_bh) {
                retval = ext4_rename_dir_finish(handle, &old, new.dir->i_ino);
                if (retval)
diff --combined fs/ext4/super.c
index ce60b5026bdef453d53c6b9de432fa75e3d03862,d1c4b04e72ab04d9dd05bf767419d2f7fb027b4e..c5021ca0a28ad52d99d1f3ee19c490e390c2fe35
@@@ -39,6 -39,7 +39,6 @@@
  #include <linux/log2.h>
  #include <linux/crc16.h>
  #include <linux/dax.h>
 -#include <linux/cleancache.h>
  #include <linux/uaccess.h>
  #include <linux/iversion.h>
  #include <linux/unicode.h>
@@@ -1301,7 -1302,7 +1301,7 @@@ static void ext4_put_super(struct super
        kfree(sbi->s_blockgroup_lock);
        fs_put_dax(sbi->s_daxdev);
        fscrypt_free_dummy_policy(&sbi->s_dummy_enc_policy);
 -#ifdef CONFIG_UNICODE
 +#if IS_ENABLED(CONFIG_UNICODE)
        utf8_unload(sb->s_encoding);
  #endif
        kfree(sbi);
@@@ -1961,26 -1962,33 +1961,26 @@@ static const struct mount_opts 
        {Opt_err, 0, 0}
  };
  
 -#ifdef CONFIG_UNICODE
 +#if IS_ENABLED(CONFIG_UNICODE)
  static const struct ext4_sb_encodings {
        __u16 magic;
        char *name;
 -      char *version;
 +      unsigned int version;
  } ext4_sb_encoding_map[] = {
 -      {EXT4_ENC_UTF8_12_1, "utf8", "12.1.0"},
 +      {EXT4_ENC_UTF8_12_1, "utf8", UNICODE_AGE(12, 1, 0)},
  };
  
 -static int ext4_sb_read_encoding(const struct ext4_super_block *es,
 -                               const struct ext4_sb_encodings **encoding,
 -                               __u16 *flags)
 +static const struct ext4_sb_encodings *
 +ext4_sb_read_encoding(const struct ext4_super_block *es)
  {
        __u16 magic = le16_to_cpu(es->s_encoding);
        int i;
  
        for (i = 0; i < ARRAY_SIZE(ext4_sb_encoding_map); i++)
                if (magic == ext4_sb_encoding_map[i].magic)
 -                      break;
 -
 -      if (i >= ARRAY_SIZE(ext4_sb_encoding_map))
 -              return -EINVAL;
 +                      return &ext4_sb_encoding_map[i];
  
 -      *encoding = &ext4_sb_encoding_map[i];
 -      *flags = le16_to_cpu(es->s_encoding_flags);
 -
 -      return 0;
 +      return NULL;
  }
  #endif
  
@@@ -3148,6 -3156,8 +3148,6 @@@ done
                        EXT4_BLOCKS_PER_GROUP(sb),
                        EXT4_INODES_PER_GROUP(sb),
                        sbi->s_mount_opt, sbi->s_mount_opt2);
 -
 -      cleancache_init_fs(sb);
        return err;
  }
  
@@@ -3606,7 -3616,7 +3606,7 @@@ int ext4_feature_set_ok(struct super_bl
                return 0;
        }
  
 -#ifndef CONFIG_UNICODE
 +#if !IS_ENABLED(CONFIG_UNICODE)
        if (ext4_has_feature_casefold(sb)) {
                ext4_msg(sb, KERN_ERR,
                         "Filesystem with casefold feature cannot be "
@@@ -4328,7 -4338,7 +4328,7 @@@ static struct ext4_sb_info *ext4_alloc_
        if (!sbi)
                return NULL;
  
 -      sbi->s_daxdev = fs_dax_get_by_bdev(sb->s_bdev);
 +      sbi->s_daxdev = fs_dax_get_by_bdev(sb->s_bdev, &sbi->s_dax_part_off);
  
        sbi->s_blockgroup_lock =
                kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL);
@@@ -4610,14 -4620,14 +4610,14 @@@ static int __ext4_fill_super(struct fs_
        if (err < 0)
                goto failed_mount;
  
 -#ifdef CONFIG_UNICODE
 +#if IS_ENABLED(CONFIG_UNICODE)
        if (ext4_has_feature_casefold(sb) && !sb->s_encoding) {
                const struct ext4_sb_encodings *encoding_info;
                struct unicode_map *encoding;
 -              __u16 encoding_flags;
 +              __u16 encoding_flags = le16_to_cpu(es->s_encoding_flags);
  
 -              if (ext4_sb_read_encoding(es, &encoding_info,
 -                                        &encoding_flags)) {
 +              encoding_info = ext4_sb_read_encoding(es);
 +              if (!encoding_info) {
                        ext4_msg(sb, KERN_ERR,
                                 "Encoding requested by superblock is unknown");
                        goto failed_mount;
                encoding = utf8_load(encoding_info->version);
                if (IS_ERR(encoding)) {
                        ext4_msg(sb, KERN_ERR,
 -                               "can't mount with superblock charset: %s-%s "
 +                               "can't mount with superblock charset: %s-%u.%u.%u "
                                 "not supported by the kernel. flags: 0x%x.",
 -                               encoding_info->name, encoding_info->version,
 +                               encoding_info->name,
 +                               unicode_major(encoding_info->version),
 +                               unicode_minor(encoding_info->version),
 +                               unicode_rev(encoding_info->version),
                                 encoding_flags);
                        goto failed_mount;
                }
                ext4_msg(sb, KERN_INFO,"Using encoding defined by superblock: "
 -                       "%s-%s with flags 0x%hx", encoding_info->name,
 -                       encoding_info->version?:"\b", encoding_flags);
 +                       "%s-%u.%u.%u with flags 0x%hx", encoding_info->name,
 +                       unicode_major(encoding_info->version),
 +                       unicode_minor(encoding_info->version),
 +                       unicode_rev(encoding_info->version),
 +                       encoding_flags);
  
                sb->s_encoding = encoding;
                sb->s_encoding_flags = encoding_flags;
                goto failed_mount;
        }
  
 -      if (dax_supported(sbi->s_daxdev, sb->s_bdev, blocksize, 0,
 -                      bdev_nr_sectors(sb->s_bdev)))
 -              set_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags);
 +      if (sbi->s_daxdev) {
 +              if (blocksize == PAGE_SIZE)
 +                      set_bit(EXT4_FLAGS_BDEV_IS_DAX, &sbi->s_ext4_flags);
 +              else
 +                      ext4_msg(sb, KERN_ERR, "unsupported blocksize for DAX\n");
 +      }
  
        if (sbi->s_mount_opt & EXT4_MOUNT_DAX_ALWAYS) {
                if (ext4_has_feature_inline_data(sb)) {
        INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_STAGING]);
        sbi->s_fc_bytes = 0;
        ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE);
-       ext4_clear_mount_flag(sb, EXT4_MF_FC_COMMITTING);
+       sbi->s_fc_ineligible_tid = 0;
        spin_lock_init(&sbi->s_fc_lock);
        memset(&sbi->s_fc_stats, 0, sizeof(sbi->s_fc_stats));
        sbi->s_fc_replay_state.fc_regions = NULL;
@@@ -5514,7 -5515,7 +5514,7 @@@ failed_mount
        if (sbi->s_chksum_driver)
                crypto_free_shash(sbi->s_chksum_driver);
  
 -#ifdef CONFIG_UNICODE
 +#if IS_ENABLED(CONFIG_UNICODE)
        utf8_unload(sb->s_encoding);
  #endif
  
@@@ -5540,7 -5541,7 +5540,7 @@@ static int ext4_fill_super(struct super
  
        sbi = ext4_alloc_sbi(sb);
        if (!sbi)
-               ret = -ENOMEM;
+               return -ENOMEM;
  
        fc->s_fs_info = sbi;
  
diff --combined fs/jbd2/journal.c
index bf108d4493d211eed291c4c13dd3055c1d425db7,a654d22aa2f11de5a432b8cf2defdeab53ee059b..c2cf74b01ddb07b5fe9d9d6d919f69704ffbef41
@@@ -771,7 -771,7 +771,7 @@@ static int __jbd2_fc_end_commit(journal
  {
        jbd2_journal_unlock_updates(journal);
        if (journal->j_fc_cleanup_callback)
-               journal->j_fc_cleanup_callback(journal, 0);
+               journal->j_fc_cleanup_callback(journal, 0, tid);
        write_lock(&journal->j_state_lock);
        journal->j_flags &= ~JBD2_FAST_COMMIT_ONGOING;
        if (fallback)
@@@ -1212,7 -1212,7 +1212,7 @@@ static const struct seq_operations jbd2
  
  static int jbd2_seq_info_open(struct inode *inode, struct file *file)
  {
 -      journal_t *journal = PDE_DATA(inode);
 +      journal_t *journal = pde_data(inode);
        struct jbd2_stats_proc_session *s;
        int rc, size;
  
@@@ -1287,6 -1287,8 +1287,8 @@@ static int jbd2_min_tag_size(void
  
  /**
   * jbd2_journal_shrink_scan()
+  * @shrink: shrinker to work on
+  * @sc: reclaim request to process
   *
   * Scan the checkpointed buffer on the checkpoint list and release the
   * journal_head.
@@@ -1312,6 -1314,8 +1314,8 @@@ static unsigned long jbd2_journal_shrin
  
  /**
   * jbd2_journal_shrink_count()
+  * @shrink: shrinker to work on
+  * @sc: reclaim request to process
   *
   * Count the number of checkpoint buffers on the checkpoint list.
   */
@@@ -2972,7 -2976,6 +2976,7 @@@ struct journal_head *jbd2_journal_grab_
        jbd_unlock_bh_journal_head(bh);
        return jh;
  }
 +EXPORT_SYMBOL(jbd2_journal_grab_journal_head);
  
  static void __journal_remove_journal_head(struct buffer_head *bh)
  {
@@@ -3025,7 -3028,6 +3029,7 @@@ void jbd2_journal_put_journal_head(stru
                jbd_unlock_bh_journal_head(bh);
        }
  }
 +EXPORT_SYMBOL(jbd2_journal_put_journal_head);
  
  /*
   * Initialize jbd inode head