Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 5 Aug 2022 03:13:46 +0000 (20:13 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 5 Aug 2022 03:13:46 +0000 (20:13 -0700)
Pull ext4 updates from Ted Ts'o:
 "Add new ioctls to set and get the file system UUID in the ext4
  superblock and improved the performance of the online resizing of file
  systems with bigalloc enabled.

  Fixed a lot of bugs, in particular for the inline data feature,
  potential races when creating and deleting inodes with shared extended
  attribute blocks, and the handling of directory blocks which are
  corrupted"

* tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: (37 commits)
  ext4: add ioctls to get/set the ext4 superblock uuid
  ext4: avoid resizing to a partial cluster size
  ext4: reduce computation of overhead during resize
  jbd2: fix assertion 'jh->b_frozen_data == NULL' failure when journal aborted
  ext4: block range must be validated before use in ext4_mb_clear_bb()
  mbcache: automatically delete entries from cache on freeing
  mbcache: Remove mb_cache_entry_delete()
  ext2: avoid deleting xattr block that is being reused
  ext2: unindent codeblock in ext2_xattr_set()
  ext2: factor our freeing of xattr block reference
  ext4: fix race when reusing xattr blocks
  ext4: unindent codeblock in ext4_xattr_block_set()
  ext4: remove EA inode entry from mbcache on inode eviction
  mbcache: add functions to delete entry if unused
  mbcache: don't reclaim used entries
  ext4: make sure ext4_append() always allocates new block
  ext4: check if directory block is within i_size
  ext4: reflect mb_optimize_scan value in options file
  ext4: avoid remove directory when directory is corrupted
  ext4: aligned '*' in comments
  ...

1  2 
fs/ext4/ext4.h
fs/ext4/fast_commit.c
fs/ext4/inode.c
fs/ext4/super.c
fs/jbd2/commit.c
fs/jbd2/journal.c
fs/jbd2/recovery.c
include/linux/jbd2.h

diff --combined fs/ext4/ext4.h
@@@ -724,6 -724,8 +724,8 @@@ enum 
  #define EXT4_IOC_GETSTATE             _IOW('f', 41, __u32)
  #define EXT4_IOC_GET_ES_CACHE         _IOWR('f', 42, struct fiemap)
  #define EXT4_IOC_CHECKPOINT           _IOW('f', 43, __u32)
+ #define EXT4_IOC_GETFSUUID            _IOR('f', 44, struct fsuuid)
+ #define EXT4_IOC_SETFSUUID            _IOW('f', 44, struct fsuuid)
  
  #define EXT4_IOC_SHUTDOWN _IOR ('X', 125, __u32)
  
                                                EXT4_IOC_CHECKPOINT_FLAG_ZEROOUT | \
                                                EXT4_IOC_CHECKPOINT_FLAG_DRY_RUN)
  
+ /*
+  * Structure for EXT4_IOC_GETFSUUID/EXT4_IOC_SETFSUUID
+  */
+ struct fsuuid {
+       __u32       fsu_len;
+       __u32       fsu_flags;
+       __u8        fsu_uuid[];
+ };
  #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
  /*
   * ioctl commands in 32 bit emulation
@@@ -3016,7 -3027,7 +3027,7 @@@ int ext4_fileattr_set(struct user_names
                      struct dentry *dentry, struct fileattr *fa);
  int ext4_fileattr_get(struct dentry *dentry, struct fileattr *fa);
  extern void ext4_reset_inode_seed(struct inode *inode);
- int ext4_update_overhead(struct super_block *sb);
+ int ext4_update_overhead(struct super_block *sb, bool force);
  
  /* migrate.c */
  extern int ext4_ext_migrate(struct inode *);
@@@ -3058,14 -3069,14 +3069,14 @@@ extern unsigned int ext4_list_backups(s
  
  /* super.c */
  extern struct buffer_head *ext4_sb_bread(struct super_block *sb,
 -                                       sector_t block, int op_flags);
 +                                       sector_t block, blk_opf_t op_flags);
  extern struct buffer_head *ext4_sb_bread_unmovable(struct super_block *sb,
                                                   sector_t block);
 -extern void ext4_read_bh_nowait(struct buffer_head *bh, int op_flags,
 +extern void ext4_read_bh_nowait(struct buffer_head *bh, blk_opf_t op_flags,
                                bh_end_io_t *end_io);
 -extern int ext4_read_bh(struct buffer_head *bh, int op_flags,
 +extern int ext4_read_bh(struct buffer_head *bh, blk_opf_t op_flags,
                        bh_end_io_t *end_io);
 -extern int ext4_read_bh_lock(struct buffer_head *bh, int op_flags, bool wait);
 +extern int ext4_read_bh_lock(struct buffer_head *bh, blk_opf_t op_flags, bool wait);
  extern void ext4_sb_breadahead_unmovable(struct super_block *sb, sector_t block);
  extern int ext4_seq_options_show(struct seq_file *seq, void *offset);
  extern int ext4_calculate_overhead(struct super_block *sb);
@@@ -3583,6 -3594,7 +3594,7 @@@ extern struct buffer_head *ext4_get_fir
  extern int ext4_inline_data_fiemap(struct inode *inode,
                                   struct fiemap_extent_info *fieinfo,
                                   int *has_inline, __u64 start, __u64 len);
+ extern void *ext4_read_inline_link(struct inode *inode);
  
  struct iomap;
  extern int ext4_inline_data_iomap(struct inode *inode, struct iomap *iomap);
@@@ -3799,7 -3811,7 +3811,7 @@@ static inline void set_bitmap_uptodate(
  extern wait_queue_head_t ext4__ioend_wq[EXT4_WQ_HASH_SZ];
  
  extern int ext4_resize_begin(struct super_block *sb);
- extern void ext4_resize_end(struct super_block *sb);
+ extern int ext4_resize_end(struct super_block *sb, bool update_backups);
  
  static inline void ext4_set_io_unwritten_flag(struct inode *inode,
                                              struct ext4_io_end *io_end)
diff --combined fs/ext4/fast_commit.c
@@@ -658,7 -658,7 +658,7 @@@ void ext4_fc_track_range(handle_t *hand
  
  static void ext4_fc_submit_bh(struct super_block *sb, bool is_tail)
  {
 -      int write_flags = REQ_SYNC;
 +      blk_opf_t write_flags = REQ_SYNC;
        struct buffer_head *bh = EXT4_SB(sb)->s_fc_bh;
  
        /* Add REQ_FUA | REQ_PREFLUSH only its tail */
        set_buffer_dirty(bh);
        set_buffer_uptodate(bh);
        bh->b_end_io = ext4_end_buffer_io_sync;
 -      submit_bh(REQ_OP_WRITE, write_flags, bh);
 +      submit_bh(REQ_OP_WRITE | write_flags, bh);
        EXT4_SB(sb)->s_fc_bh = NULL;
  }
  
@@@ -917,8 -917,8 +917,8 @@@ static int ext4_fc_write_inode_data(str
        mutex_unlock(&ei->i_fc_lock);
  
        cur_lblk_off = old_blk_size;
-       jbd_debug(1, "%s: will try writing %d to %d for inode %ld\n",
-                 __func__, cur_lblk_off, new_blk_size, inode->i_ino);
+       ext4_debug("will try writing %d to %d for inode %ld\n",
+                  cur_lblk_off, new_blk_size, inode->i_ino);
  
        while (cur_lblk_off <= new_blk_size) {
                map.m_lblk = cur_lblk_off;
@@@ -1168,7 -1168,7 +1168,7 @@@ static void ext4_fc_update_stats(struc
  {
        struct ext4_fc_stats *stats = &EXT4_SB(sb)->s_fc_stats;
  
-       jbd_debug(1, "Fast commit ended with status = %d for tid %u",
+       ext4_debug("Fast commit ended with status = %d for tid %u",
                        status, commit_tid);
        if (status == EXT4_FC_STATUS_OK) {
                stats->fc_num_commits++;
@@@ -1375,14 -1375,14 +1375,14 @@@ static int ext4_fc_replay_unlink(struc
        inode = ext4_iget(sb, darg.ino, EXT4_IGET_NORMAL);
  
        if (IS_ERR(inode)) {
-               jbd_debug(1, "Inode %d not found", darg.ino);
+               ext4_debug("Inode %d not found", darg.ino);
                return 0;
        }
  
        old_parent = ext4_iget(sb, darg.parent_ino,
                                EXT4_IGET_NORMAL);
        if (IS_ERR(old_parent)) {
-               jbd_debug(1, "Dir with inode  %d not found", darg.parent_ino);
+               ext4_debug("Dir with inode %d not found", darg.parent_ino);
                iput(inode);
                return 0;
        }
@@@ -1407,21 -1407,21 +1407,21 @@@ static int ext4_fc_replay_link_internal
  
        dir = ext4_iget(sb, darg->parent_ino, EXT4_IGET_NORMAL);
        if (IS_ERR(dir)) {
-               jbd_debug(1, "Dir with inode %d not found.", darg->parent_ino);
+               ext4_debug("Dir with inode %d not found.", darg->parent_ino);
                dir = NULL;
                goto out;
        }
  
        dentry_dir = d_obtain_alias(dir);
        if (IS_ERR(dentry_dir)) {
-               jbd_debug(1, "Failed to obtain dentry");
+               ext4_debug("Failed to obtain dentry");
                dentry_dir = NULL;
                goto out;
        }
  
        dentry_inode = d_alloc(dentry_dir, &qstr_dname);
        if (!dentry_inode) {
-               jbd_debug(1, "Inode dentry not created.");
+               ext4_debug("Inode dentry not created.");
                ret = -ENOMEM;
                goto out;
        }
         * could complete.
         */
        if (ret && ret != -EEXIST) {
-               jbd_debug(1, "Failed to link\n");
+               ext4_debug("Failed to link\n");
                goto out;
        }
  
@@@ -1468,7 -1468,7 +1468,7 @@@ static int ext4_fc_replay_link(struct s
  
        inode = ext4_iget(sb, darg.ino, EXT4_IGET_NORMAL);
        if (IS_ERR(inode)) {
-               jbd_debug(1, "Inode not found.");
+               ext4_debug("Inode not found.");
                return 0;
        }
  
@@@ -1576,7 -1576,7 +1576,7 @@@ static int ext4_fc_replay_inode(struct 
        /* Given that we just wrote the inode on disk, this SHOULD succeed. */
        inode = ext4_iget(sb, ino, EXT4_IGET_NORMAL);
        if (IS_ERR(inode)) {
-               jbd_debug(1, "Inode not found.");
+               ext4_debug("Inode not found.");
                return -EFSCORRUPTED;
        }
  
@@@ -1630,7 -1630,7 +1630,7 @@@ static int ext4_fc_replay_create(struc
  
        inode = ext4_iget(sb, darg.ino, EXT4_IGET_NORMAL);
        if (IS_ERR(inode)) {
-               jbd_debug(1, "inode %d not found.", darg.ino);
+               ext4_debug("inode %d not found.", darg.ino);
                inode = NULL;
                ret = -EINVAL;
                goto out;
                 */
                dir = ext4_iget(sb, darg.parent_ino, EXT4_IGET_NORMAL);
                if (IS_ERR(dir)) {
-                       jbd_debug(1, "Dir %d not found.", darg.ino);
+                       ext4_debug("Dir %d not found.", darg.ino);
                        goto out;
                }
                ret = ext4_init_new_dir(NULL, dir, inode);
@@@ -1727,7 -1727,7 +1727,7 @@@ static int ext4_fc_replay_add_range(str
  
        inode = ext4_iget(sb, le32_to_cpu(fc_add_ex.fc_ino), EXT4_IGET_NORMAL);
        if (IS_ERR(inode)) {
-               jbd_debug(1, "Inode not found.");
+               ext4_debug("Inode not found.");
                return 0;
        }
  
  
        cur = start;
        remaining = len;
-       jbd_debug(1, "ADD_RANGE, lblk %d, pblk %lld, len %d, unwritten %d, inode %ld\n",
+       ext4_debug("ADD_RANGE, lblk %d, pblk %lld, len %d, unwritten %d, inode %ld\n",
                  start, start_pblk, len, ext4_ext_is_unwritten(ex),
                  inode->i_ino);
  
                }
  
                /* Range is mapped and needs a state change */
-               jbd_debug(1, "Converting from %ld to %d %lld",
+               ext4_debug("Converting from %ld to %d %lld",
                                map.m_flags & EXT4_MAP_UNWRITTEN,
                        ext4_ext_is_unwritten(ex), map.m_pblk);
                ret = ext4_ext_replay_update_ex(inode, cur, map.m_len,
@@@ -1845,7 -1845,7 +1845,7 @@@ ext4_fc_replay_del_range(struct super_b
  
        inode = ext4_iget(sb, le32_to_cpu(lrange.fc_ino), EXT4_IGET_NORMAL);
        if (IS_ERR(inode)) {
-               jbd_debug(1, "Inode %d not found", le32_to_cpu(lrange.fc_ino));
+               ext4_debug("Inode %d not found", le32_to_cpu(lrange.fc_ino));
                return 0;
        }
  
        if (ret)
                goto out;
  
-       jbd_debug(1, "DEL_RANGE, inode %ld, lblk %d, len %d\n",
+       ext4_debug("DEL_RANGE, inode %ld, lblk %d, len %d\n",
                        inode->i_ino, le32_to_cpu(lrange.fc_lblk),
                        le32_to_cpu(lrange.fc_len));
        while (remaining > 0) {
@@@ -1902,7 -1902,7 +1902,7 @@@ static void ext4_fc_set_bitmaps_and_cou
                inode = ext4_iget(sb, state->fc_modified_inodes[i],
                        EXT4_IGET_NORMAL);
                if (IS_ERR(inode)) {
-                       jbd_debug(1, "Inode %d not found.",
+                       ext4_debug("Inode %d not found.",
                                state->fc_modified_inodes[i]);
                        continue;
                }
@@@ -2031,7 -2031,7 +2031,7 @@@ static int ext4_fc_replay_scan(journal_
        for (cur = start; cur < end; cur = cur + sizeof(tl) + le16_to_cpu(tl.fc_len)) {
                memcpy(&tl, cur, sizeof(tl));
                val = cur + sizeof(tl);
-               jbd_debug(3, "Scan phase, tag:%s, blk %lld\n",
+               ext4_debug("Scan phase, tag:%s, blk %lld\n",
                          tag2str(le16_to_cpu(tl.fc_tag)), bh->b_blocknr);
                switch (le16_to_cpu(tl.fc_tag)) {
                case EXT4_FC_TAG_ADD_RANGE:
@@@ -2126,7 -2126,7 +2126,7 @@@ static int ext4_fc_replay(journal_t *jo
                sbi->s_mount_state |= EXT4_FC_REPLAY;
        }
        if (!sbi->s_fc_replay_state.fc_replay_num_tags) {
-               jbd_debug(1, "Replay stops\n");
+               ext4_debug("Replay stops\n");
                ext4_fc_set_bitmaps_and_counters(sb);
                return 0;
        }
                        ext4_fc_set_bitmaps_and_counters(sb);
                        break;
                }
-               jbd_debug(3, "Replay phase, tag:%s\n",
+               ext4_debug("Replay phase, tag:%s\n",
                                tag2str(le16_to_cpu(tl.fc_tag)));
                state->fc_replay_num_tags--;
                switch (le16_to_cpu(tl.fc_tag)) {
diff --combined fs/ext4/inode.c
@@@ -177,6 -177,8 +177,8 @@@ void ext4_evict_inode(struct inode *ino
  
        trace_ext4_evict_inode(inode);
  
+       if (EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL)
+               ext4_evict_ea_inode(inode);
        if (inode->i_nlink) {
                /*
                 * When journalling data dirty buffers are tracked only in the
@@@ -1554,9 -1556,9 +1556,9 @@@ struct mpage_da_data 
  static void mpage_release_unused_pages(struct mpage_da_data *mpd,
                                       bool invalidate)
  {
 -      int nr_pages, i;
 +      unsigned nr, i;
        pgoff_t index, end;
 -      struct pagevec pvec;
 +      struct folio_batch fbatch;
        struct inode *inode = mpd->inode;
        struct address_space *mapping = inode->i_mapping;
  
                ext4_lblk_t start, last;
                start = index << (PAGE_SHIFT - inode->i_blkbits);
                last = end << (PAGE_SHIFT - inode->i_blkbits);
+               /*
+                * avoid racing with extent status tree scans made by
+                * ext4_insert_delayed_block()
+                */
+               down_write(&EXT4_I(inode)->i_data_sem);
                ext4_es_remove_extent(inode, start, last - start + 1);
+               up_write(&EXT4_I(inode)->i_data_sem);
        }
  
 -      pagevec_init(&pvec);
 +      folio_batch_init(&fbatch);
        while (index <= end) {
 -              nr_pages = pagevec_lookup_range(&pvec, mapping, &index, end);
 -              if (nr_pages == 0)
 +              nr = filemap_get_folios(mapping, &index, end, &fbatch);
 +              if (nr == 0)
                        break;
 -              for (i = 0; i < nr_pages; i++) {
 -                      struct page *page = pvec.pages[i];
 -                      struct folio *folio = page_folio(page);
 +              for (i = 0; i < nr; i++) {
 +                      struct folio *folio = fbatch.folios[i];
  
 +                      if (folio->index < mpd->first_page)
 +                              continue;
 +                      if (folio->index + folio_nr_pages(folio) - 1 > end)
 +                              continue;
                        BUG_ON(!folio_test_locked(folio));
                        BUG_ON(folio_test_writeback(folio));
                        if (invalidate) {
                        }
                        folio_unlock(folio);
                }
 -              pagevec_release(&pvec);
 +              folio_batch_release(&fbatch);
        }
  }
  
@@@ -2314,8 -2320,8 +2323,8 @@@ out
   */
  static int mpage_map_and_submit_buffers(struct mpage_da_data *mpd)
  {
 -      struct pagevec pvec;
 -      int nr_pages, i;
 +      struct folio_batch fbatch;
 +      unsigned nr, i;
        struct inode *inode = mpd->inode;
        int bpp_bits = PAGE_SHIFT - inode->i_blkbits;
        pgoff_t start, end;
        lblk = start << bpp_bits;
        pblock = mpd->map.m_pblk;
  
 -      pagevec_init(&pvec);
 +      folio_batch_init(&fbatch);
        while (start <= end) {
 -              nr_pages = pagevec_lookup_range(&pvec, inode->i_mapping,
 -                                              &start, end);
 -              if (nr_pages == 0)
 +              nr = filemap_get_folios(inode->i_mapping, &start, end, &fbatch);
 +              if (nr == 0)
                        break;
 -              for (i = 0; i < nr_pages; i++) {
 -                      struct page *page = pvec.pages[i];
 +              for (i = 0; i < nr; i++) {
 +                      struct page *page = &fbatch.folios[i]->page;
  
                        err = mpage_process_page(mpd, page, &lblk, &pblock,
                                                 &map_bh);
                        if (err < 0)
                                goto out;
                }
 -              pagevec_release(&pvec);
 +              folio_batch_release(&fbatch);
        }
        /* Extent fully mapped and matches with page boundary. We are done. */
        mpd->map.m_len = 0;
        mpd->map.m_flags = 0;
        return 0;
  out:
 -      pagevec_release(&pvec);
 +      folio_batch_release(&fbatch);
        return err;
  }
  
@@@ -3142,13 -3149,15 +3151,15 @@@ static sector_t ext4_bmap(struct addres
  {
        struct inode *inode = mapping->host;
        journal_t *journal;
+       sector_t ret = 0;
        int err;
  
+       inode_lock_shared(inode);
        /*
         * We can get here for an inline file via the FIBMAP ioctl
         */
        if (ext4_has_inline_data(inode))
-               return 0;
+               goto out;
  
        if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) &&
                        test_opt(inode->i_sb, DELALLOC)) {
                jbd2_journal_unlock_updates(journal);
  
                if (err)
-                       return 0;
+                       goto out;
        }
  
-       return iomap_bmap(mapping, block, &ext4_iomap_ops);
+       ret = iomap_bmap(mapping, block, &ext4_iomap_ops);
+ out:
+       inode_unlock_shared(inode);
+       return ret;
  }
  
  static int ext4_read_folio(struct file *file, struct folio *folio)
@@@ -3633,7 -3646,7 +3648,7 @@@ static const struct address_space_opera
        .invalidate_folio       = ext4_invalidate_folio,
        .release_folio          = ext4_release_folio,
        .direct_IO              = noop_direct_IO,
 -      .migratepage            = buffer_migrate_page,
 +      .migrate_folio          = buffer_migrate_folio,
        .is_partially_uptodate  = block_is_partially_uptodate,
        .error_remove_page      = generic_error_remove_page,
        .swap_activate          = ext4_iomap_swap_activate,
@@@ -3668,7 -3681,7 +3683,7 @@@ static const struct address_space_opera
        .invalidate_folio       = ext4_invalidate_folio,
        .release_folio          = ext4_release_folio,
        .direct_IO              = noop_direct_IO,
 -      .migratepage            = buffer_migrate_page,
 +      .migrate_folio          = buffer_migrate_folio,
        .is_partially_uptodate  = block_is_partially_uptodate,
        .error_remove_page      = generic_error_remove_page,
        .swap_activate          = ext4_iomap_swap_activate,
@@@ -4687,8 -4700,7 +4702,7 @@@ static inline int ext4_iget_extra_inode
        __le32 *magic = (void *)raw_inode +
                        EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize;
  
-       if (EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize + sizeof(__le32) <=
-           EXT4_INODE_SIZE(inode->i_sb) &&
+       if (EXT4_INODE_HAS_XATTR_SPACE(inode)  &&
            *magic == cpu_to_le32(EXT4_XATTR_MAGIC)) {
                ext4_set_inode_state(inode, EXT4_STATE_XATTR);
                return ext4_find_inline_data_nolock(inode);
@@@ -5215,7 -5227,7 +5229,7 @@@ int ext4_write_inode(struct inode *inod
  
        if (EXT4_SB(inode->i_sb)->s_journal) {
                if (ext4_journal_current_handle()) {
-                       jbd_debug(1, "called recursively, non-PF_MEMALLOC!\n");
+                       ext4_debug("called recursively, non-PF_MEMALLOC!\n");
                        dump_stack();
                        return -EIO;
                }
@@@ -5352,14 -5364,14 +5366,14 @@@ int ext4_setattr(struct user_namespace 
        if (error)
                return error;
  
 -      if (is_quota_modification(inode, attr)) {
 +      if (is_quota_modification(mnt_userns, inode, attr)) {
                error = dquot_initialize(inode);
                if (error)
                        return error;
        }
  
 -      if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, inode->i_uid)) ||
 -          (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid))) {
 +      if (i_uid_needs_update(mnt_userns, attr, inode) ||
 +          i_gid_needs_update(mnt_userns, attr, inode)) {
                handle_t *handle;
  
                /* (user+group)*(old+new) structure, inode write (sb,
                 * counts xattr inode references.
                 */
                down_read(&EXT4_I(inode)->xattr_sem);
 -              error = dquot_transfer(inode, attr);
 +              error = dquot_transfer(mnt_userns, inode, attr);
                up_read(&EXT4_I(inode)->xattr_sem);
  
                if (error) {
                }
                /* Update corresponding info in inode so that everything is in
                 * one transaction */
 -              if (attr->ia_valid & ATTR_UID)
 -                      inode->i_uid = attr->ia_uid;
 -              if (attr->ia_valid & ATTR_GID)
 -                      inode->i_gid = attr->ia_gid;
 +              i_uid_update(mnt_userns, attr, inode);
 +              i_gid_update(mnt_userns, attr, inode);
                error = ext4_mark_inode_dirty(handle, inode);
                ext4_journal_stop(handle);
                if (unlikely(error)) {
diff --combined fs/ext4/super.c
@@@ -159,7 -159,7 +159,7 @@@ MODULE_ALIAS("ext3")
  #define IS_EXT3_SB(sb) ((sb)->s_bdev->bd_holder == &ext3_fs_type)
  
  
 -static inline void __ext4_read_bh(struct buffer_head *bh, int op_flags,
 +static inline void __ext4_read_bh(struct buffer_head *bh, blk_opf_t op_flags,
                                  bh_end_io_t *end_io)
  {
        /*
  
        bh->b_end_io = end_io ? end_io : end_buffer_read_sync;
        get_bh(bh);
 -      submit_bh(REQ_OP_READ, op_flags, bh);
 +      submit_bh(REQ_OP_READ | op_flags, bh);
  }
  
 -void ext4_read_bh_nowait(struct buffer_head *bh, int op_flags,
 +void ext4_read_bh_nowait(struct buffer_head *bh, blk_opf_t op_flags,
                         bh_end_io_t *end_io)
  {
        BUG_ON(!buffer_locked(bh));
        __ext4_read_bh(bh, op_flags, end_io);
  }
  
 -int ext4_read_bh(struct buffer_head *bh, int op_flags, bh_end_io_t *end_io)
 +int ext4_read_bh(struct buffer_head *bh, blk_opf_t op_flags, bh_end_io_t *end_io)
  {
        BUG_ON(!buffer_locked(bh));
  
        return -EIO;
  }
  
 -int ext4_read_bh_lock(struct buffer_head *bh, int op_flags, bool wait)
 +int ext4_read_bh_lock(struct buffer_head *bh, blk_opf_t op_flags, bool wait)
  {
        if (trylock_buffer(bh)) {
                if (wait)
   * return.
   */
  static struct buffer_head *__ext4_sb_bread_gfp(struct super_block *sb,
 -                                             sector_t block, int op_flags,
 -                                             gfp_t gfp)
 +                                             sector_t block,
 +                                             blk_opf_t op_flags, gfp_t gfp)
  {
        struct buffer_head *bh;
        int ret;
  }
  
  struct buffer_head *ext4_sb_bread(struct super_block *sb, sector_t block,
 -                                 int op_flags)
 +                                 blk_opf_t op_flags)
  {
        return __ext4_sb_bread_gfp(sb, block, op_flags, __GFP_MOVABLE);
  }
@@@ -3011,6 -3011,15 +3011,15 @@@ static int _ext4_show_options(struct se
        } else if (test_opt2(sb, DAX_INODE)) {
                SEQ_OPTS_PUTS("dax=inode");
        }
+       if (sbi->s_groups_count >= MB_DEFAULT_LINEAR_SCAN_THRESHOLD &&
+                       !test_opt2(sb, MB_OPTIMIZE_SCAN)) {
+               SEQ_OPTS_PUTS("mb_optimize_scan=0");
+       } else if (sbi->s_groups_count < MB_DEFAULT_LINEAR_SCAN_THRESHOLD &&
+                       test_opt2(sb, MB_OPTIMIZE_SCAN)) {
+               SEQ_OPTS_PUTS("mb_optimize_scan=1");
+       }
        ext4_show_quota_options(seq, sb);
        return 0;
  }
@@@ -5523,7 -5532,7 +5532,7 @@@ static int ext4_fill_super(struct super
                         "Quota mode: %s.", descr, ext4_quota_mode(sb));
  
        /* Update the s_overhead_clusters if necessary */
-       ext4_update_overhead(sb);
+       ext4_update_overhead(sb, false);
        return 0;
  
  free_sbi:
@@@ -5585,7 -5594,7 +5594,7 @@@ static struct inode *ext4_get_journal_i
                return NULL;
        }
  
-       jbd_debug(2, "Journal inode found at %p: %lld bytes\n",
+       ext4_debug("Journal inode found at %p: %lld bytes\n",
                  journal_inode, journal_inode->i_size);
        if (!S_ISREG(journal_inode->i_mode)) {
                ext4_msg(sb, KERN_ERR, "invalid journal inode");
@@@ -5939,8 -5948,8 +5948,8 @@@ static int ext4_commit_super(struct sup
        /* Clear potential dirty bit if it was journalled update */
        clear_buffer_dirty(sbh);
        sbh->b_end_io = end_buffer_write_sync;
 -      submit_bh(REQ_OP_WRITE,
 -                REQ_SYNC | (test_opt(sb, BARRIER) ? REQ_FUA : 0), sbh);
 +      submit_bh(REQ_OP_WRITE | REQ_SYNC |
 +                (test_opt(sb, BARRIER) ? REQ_FUA : 0), sbh);
        wait_on_buffer(sbh);
        if (buffer_write_io_error(sbh)) {
                ext4_msg(sb, KERN_ERR, "I/O error while writing "
diff --combined fs/jbd2/commit.c
@@@ -155,10 -155,10 +155,10 @@@ static int journal_submit_commit_record
  
        if (journal->j_flags & JBD2_BARRIER &&
            !jbd2_has_feature_async_commit(journal))
 -              ret = submit_bh(REQ_OP_WRITE,
 -                      REQ_SYNC | REQ_PREFLUSH | REQ_FUA, bh);
 +              ret = submit_bh(REQ_OP_WRITE | REQ_SYNC | REQ_PREFLUSH |
 +                              REQ_FUA, bh);
        else
 -              ret = submit_bh(REQ_OP_WRITE, REQ_SYNC, bh);
 +              ret = submit_bh(REQ_OP_WRITE | REQ_SYNC, bh);
  
        *cbh = bh;
        return ret;
@@@ -421,7 -421,7 +421,7 @@@ void jbd2_journal_commit_transaction(jo
  
        /* Do we need to erase the effects of a prior jbd2_journal_flush? */
        if (journal->j_flags & JBD2_FLUSHED) {
-               jbd_debug(3, "super block updated\n");
+               jbd2_debug(3, "super block updated\n");
                mutex_lock_io(&journal->j_checkpoint_mutex);
                /*
                 * We hold j_checkpoint_mutex so tail cannot change under us.
                                                REQ_SYNC);
                mutex_unlock(&journal->j_checkpoint_mutex);
        } else {
-               jbd_debug(3, "superblock not updated\n");
+               jbd2_debug(3, "superblock not updated\n");
        }
  
        J_ASSERT(journal->j_running_transaction != NULL);
        commit_transaction = journal->j_running_transaction;
  
        trace_jbd2_start_commit(journal, commit_transaction);
-       jbd_debug(1, "JBD2: starting commit of transaction %d\n",
+       jbd2_debug(1, "JBD2: starting commit of transaction %d\n",
                        commit_transaction->t_tid);
  
        write_lock(&journal->j_state_lock);
        __jbd2_journal_clean_checkpoint_list(journal, false);
        spin_unlock(&journal->j_list_lock);
  
-       jbd_debug(3, "JBD2: commit phase 1\n");
+       jbd2_debug(3, "JBD2: commit phase 1\n");
  
        /*
         * Clear revoked flag to reflect there is no revoked buffers
         */
        jbd2_journal_switch_revoke_table(journal);
  
+       write_lock(&journal->j_state_lock);
        /*
         * Reserved credits cannot be claimed anymore, free them
         */
        atomic_sub(atomic_read(&journal->j_reserved_credits),
                   &commit_transaction->t_outstanding_credits);
  
-       write_lock(&journal->j_state_lock);
        trace_jbd2_commit_flushing(journal, commit_transaction);
        stats.run.rs_flushing = jiffies;
        stats.run.rs_locked = jbd2_time_diff(stats.run.rs_locked,
        wake_up(&journal->j_wait_transaction_locked);
        write_unlock(&journal->j_state_lock);
  
-       jbd_debug(3, "JBD2: commit phase 2a\n");
+       jbd2_debug(3, "JBD2: commit phase 2a\n");
  
        /*
         * Now start flushing things to disk, in the order they appear
        blk_start_plug(&plug);
        jbd2_journal_write_revoke_records(commit_transaction, &log_bufs);
  
-       jbd_debug(3, "JBD2: commit phase 2b\n");
+       jbd2_debug(3, "JBD2: commit phase 2b\n");
  
        /*
         * Way to go: we have now written out all of the data for a
                if (!descriptor) {
                        J_ASSERT (bufs == 0);
  
-                       jbd_debug(4, "JBD2: get descriptor\n");
+                       jbd2_debug(4, "JBD2: get descriptor\n");
  
                        descriptor = jbd2_journal_get_descriptor_buffer(
                                                        commit_transaction,
                                continue;
                        }
  
-                       jbd_debug(4, "JBD2: got buffer %llu (%p)\n",
+                       jbd2_debug(4, "JBD2: got buffer %llu (%p)\n",
                                (unsigned long long)descriptor->b_blocknr,
                                descriptor->b_data);
                        tagp = &descriptor->b_data[sizeof(journal_header_t)];
                    commit_transaction->t_buffers == NULL ||
                    space_left < tag_bytes + 16 + csum_size) {
  
-                       jbd_debug(4, "JBD2: Submit %d IOs\n", bufs);
+                       jbd2_debug(4, "JBD2: Submit %d IOs\n", bufs);
  
                        /* Write an end-of-descriptor marker before
                             submitting the IOs.  "tag" still points to
@@@ -763,7 -763,7 +763,7 @@@ start_journal_io
                                clear_buffer_dirty(bh);
                                set_buffer_uptodate(bh);
                                bh->b_end_io = journal_end_buffer_io_sync;
 -                              submit_bh(REQ_OP_WRITE, REQ_SYNC, bh);
 +                              submit_bh(REQ_OP_WRITE | REQ_SYNC, bh);
                        }
                        cond_resched();
  
           so we incur less scheduling load.
        */
  
-       jbd_debug(3, "JBD2: commit phase 3\n");
+       jbd2_debug(3, "JBD2: commit phase 3\n");
  
        while (!list_empty(&io_bufs)) {
                struct buffer_head *bh = list_entry(io_bufs.prev,
  
        J_ASSERT (commit_transaction->t_shadow_list == NULL);
  
-       jbd_debug(3, "JBD2: commit phase 4\n");
+       jbd2_debug(3, "JBD2: commit phase 4\n");
  
        /* Here we wait for the revoke record and descriptor record buffers */
        while (!list_empty(&log_bufs)) {
        if (err)
                jbd2_journal_abort(journal, err);
  
-       jbd_debug(3, "JBD2: commit phase 5\n");
+       jbd2_debug(3, "JBD2: commit phase 5\n");
        write_lock(&journal->j_state_lock);
        J_ASSERT(commit_transaction->t_state == T_COMMIT_DFLUSH);
        commit_transaction->t_state = T_COMMIT_JFLUSH;
             transaction can be removed from any checkpoint list it was on
             before. */
  
-       jbd_debug(3, "JBD2: commit phase 6\n");
+       jbd2_debug(3, "JBD2: commit phase 6\n");
  
        J_ASSERT(list_empty(&commit_transaction->t_inode_list));
        J_ASSERT(commit_transaction->t_buffers == NULL);
@@@ -1122,7 -1122,7 +1122,7 @@@ restart_loop
  
        /* Done with this transaction! */
  
-       jbd_debug(3, "JBD2: commit phase 7\n");
+       jbd2_debug(3, "JBD2: commit phase 7\n");
  
        J_ASSERT(commit_transaction->t_state == T_COMMIT_JFLUSH);
  
                journal->j_fc_cleanup_callback(journal, 1, commit_transaction->t_tid);
  
        trace_jbd2_end_commit(journal, commit_transaction);
-       jbd_debug(1, "JBD2: commit %d complete, head %d\n",
+       jbd2_debug(1, "JBD2: commit %d complete, head %d\n",
                  journal->j_commit_sequence, journal->j_tail_sequence);
  
        write_lock(&journal->j_state_lock);
diff --combined fs/jbd2/journal.c
@@@ -49,8 -49,7 +49,7 @@@
  #include <asm/page.h>
  
  #ifdef CONFIG_JBD2_DEBUG
- ushort jbd2_journal_enable_debug __read_mostly;
- EXPORT_SYMBOL(jbd2_journal_enable_debug);
+ static ushort jbd2_journal_enable_debug __read_mostly;
  
  module_param_named(jbd2_debug, jbd2_journal_enable_debug, ushort, 0644);
  MODULE_PARM_DESC(jbd2_debug, "Debugging level for jbd2");
@@@ -81,7 -80,6 +80,6 @@@ EXPORT_SYMBOL(jbd2_journal_errno)
  EXPORT_SYMBOL(jbd2_journal_ack_err);
  EXPORT_SYMBOL(jbd2_journal_clear_err);
  EXPORT_SYMBOL(jbd2_log_wait_commit);
- EXPORT_SYMBOL(jbd2_log_start_commit);
  EXPORT_SYMBOL(jbd2_journal_start_commit);
  EXPORT_SYMBOL(jbd2_journal_force_commit_nested);
  EXPORT_SYMBOL(jbd2_journal_wipe);
@@@ -115,7 -113,6 +113,6 @@@ void __jbd2_debug(int level, const cha
        printk(KERN_DEBUG "%s: (%s, %u): %pV", file, func, line, &vaf);
        va_end(args);
  }
- EXPORT_SYMBOL(__jbd2_debug);
  #endif
  
  /* Checksumming functions */
@@@ -203,11 -200,11 +200,11 @@@ loop
        if (journal->j_flags & JBD2_UNMOUNT)
                goto end_loop;
  
-       jbd_debug(1, "commit_sequence=%u, commit_request=%u\n",
+       jbd2_debug(1, "commit_sequence=%u, commit_request=%u\n",
                journal->j_commit_sequence, journal->j_commit_request);
  
        if (journal->j_commit_sequence != journal->j_commit_request) {
-               jbd_debug(1, "OK, requests differ\n");
+               jbd2_debug(1, "OK, requests differ\n");
                write_unlock(&journal->j_state_lock);
                del_timer_sync(&journal->j_commit_timer);
                jbd2_journal_commit_transaction(journal);
                 * good idea, because that depends on threads that may
                 * be already stopped.
                 */
-               jbd_debug(1, "Now suspending kjournald2\n");
+               jbd2_debug(1, "Now suspending kjournald2\n");
                write_unlock(&journal->j_state_lock);
                try_to_freeze();
                write_lock(&journal->j_state_lock);
                finish_wait(&journal->j_wait_commit, &wait);
        }
  
-       jbd_debug(1, "kjournald2 wakes\n");
+       jbd2_debug(1, "kjournald2 wakes\n");
  
        /*
         * Were we woken up by a commit wakeup event?
        transaction = journal->j_running_transaction;
        if (transaction && time_after_eq(jiffies, transaction->t_expires)) {
                journal->j_commit_request = transaction->t_tid;
-               jbd_debug(1, "woke because of timeout\n");
+               jbd2_debug(1, "woke because of timeout\n");
        }
        goto loop;
  
@@@ -268,7 -265,7 +265,7 @@@ end_loop
        del_timer_sync(&journal->j_commit_timer);
        journal->j_task = NULL;
        wake_up(&journal->j_wait_done_commit);
-       jbd_debug(1, "Journal thread exiting.\n");
+       jbd2_debug(1, "Journal thread exiting.\n");
        write_unlock(&journal->j_state_lock);
        return 0;
  }
@@@ -481,7 -478,7 +478,7 @@@ repeat
   * Called with j_state_lock locked for writing.
   * Returns true if a transaction commit was started.
   */
- int __jbd2_log_start_commit(journal_t *journal, tid_t target)
static int __jbd2_log_start_commit(journal_t *journal, tid_t target)
  {
        /* Return if the txn has already requested to be committed */
        if (journal->j_commit_request == target)
                 */
  
                journal->j_commit_request = target;
-               jbd_debug(1, "JBD2: requesting commit %u/%u\n",
+               jbd2_debug(1, "JBD2: requesting commit %u/%u\n",
                          journal->j_commit_request,
                          journal->j_commit_sequence);
                journal->j_running_transaction->t_requested = jiffies;
@@@ -705,7 -702,7 +702,7 @@@ int jbd2_log_wait_commit(journal_t *jou
        }
  #endif
        while (tid_gt(tid, journal->j_commit_sequence)) {
-               jbd_debug(1, "JBD2: want %u, j_commit_sequence=%u\n",
+               jbd2_debug(1, "JBD2: want %u, j_commit_sequence=%u\n",
                                  tid, journal->j_commit_sequence);
                read_unlock(&journal->j_state_lock);
                wake_up(&journal->j_wait_commit);
@@@ -1117,7 -1114,7 +1114,7 @@@ int __jbd2_update_log_tail(journal_t *j
                freed += journal->j_last - journal->j_first;
  
        trace_jbd2_update_log_tail(journal, tid, block, freed);
-       jbd_debug(1,
+       jbd2_debug(1,
                  "Cleaning journal tail from %u to %u (offset %lu), "
                  "freeing %lu\n",
                  journal->j_tail_sequence, tid, block, freed);
@@@ -1465,8 -1462,7 +1462,8 @@@ journal_t *jbd2_journal_init_dev(struc
        if (!journal)
                return NULL;
  
 -      bdevname(journal->j_dev, journal->j_devname);
 +      snprintf(journal->j_devname, sizeof(journal->j_devname),
 +               "%pg", journal->j_dev);
        strreplace(journal->j_devname, '/', '!');
        jbd2_stats_proc_init(journal);
  
@@@ -1497,7 -1493,7 +1494,7 @@@ journal_t *jbd2_journal_init_inode(stru
                return NULL;
        }
  
-       jbd_debug(1, "JBD2: inode %s/%ld, size %lld, bits %d, blksize %ld\n",
+       jbd2_debug(1, "JBD2: inode %s/%ld, size %lld, bits %d, blksize %ld\n",
                  inode->i_sb->s_id, inode->i_ino, (long long) inode->i_size,
                  inode->i_sb->s_blocksize_bits, inode->i_sb->s_blocksize);
  
                return NULL;
  
        journal->j_inode = inode;
 -      bdevname(journal->j_dev, journal->j_devname);
 +      snprintf(journal->j_devname, sizeof(journal->j_devname),
 +               "%pg", journal->j_dev);
        p = strreplace(journal->j_devname, '/', '!');
        sprintf(p, "-%lu", journal->j_inode->i_ino);
        jbd2_stats_proc_init(journal);
@@@ -1577,7 -1572,7 +1574,7 @@@ static int journal_reset(journal_t *jou
         * attempting a write to a potential-readonly device.
         */
        if (sb->s_start == 0) {
-               jbd_debug(1, "JBD2: Skipping superblock update on recovered sb "
+               jbd2_debug(1, "JBD2: Skipping superblock update on recovered sb "
                        "(start %ld, seq %u, errno %d)\n",
                        journal->j_tail, journal->j_tail_sequence,
                        journal->j_errno);
   * This function expects that the caller will have locked the journal
   * buffer head, and will return with it unlocked
   */
 -static int jbd2_write_superblock(journal_t *journal, int write_flags)
 +static int jbd2_write_superblock(journal_t *journal, blk_opf_t write_flags)
  {
        struct buffer_head *bh = journal->j_sb_buffer;
        journal_superblock_t *sb = journal->j_superblock;
                sb->s_checksum = jbd2_superblock_csum(journal, sb);
        get_bh(bh);
        bh->b_end_io = end_buffer_write_sync;
 -      ret = submit_bh(REQ_OP_WRITE, write_flags, bh);
 +      ret = submit_bh(REQ_OP_WRITE | write_flags, bh);
        wait_on_buffer(bh);
        if (buffer_write_io_error(bh)) {
                clear_buffer_write_io_error(bh);
   * @journal: The journal to update.
   * @tail_tid: TID of the new transaction at the tail of the log
   * @tail_block: The first block of the transaction at the tail of the log
 - * @write_op: With which operation should we write the journal sb
 + * @write_flags: Flags for the journal sb write operation
   *
   * Update a journal's superblock information about log tail and write it to
   * disk, waiting for the IO to complete.
   */
  int jbd2_journal_update_sb_log_tail(journal_t *journal, tid_t tail_tid,
 -                                   unsigned long tail_block, int write_op)
 +                                  unsigned long tail_block,
 +                                  blk_opf_t write_flags)
  {
        journal_superblock_t *sb = journal->j_superblock;
        int ret;
        }
  
        BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
-       jbd_debug(1, "JBD2: updating superblock (start %lu, seq %u)\n",
+       jbd2_debug(1, "JBD2: updating superblock (start %lu, seq %u)\n",
                  tail_block, tail_tid);
  
        lock_buffer(journal->j_sb_buffer);
        sb->s_sequence = cpu_to_be32(tail_tid);
        sb->s_start    = cpu_to_be32(tail_block);
  
 -      ret = jbd2_write_superblock(journal, write_op);
 +      ret = jbd2_write_superblock(journal, write_flags);
        if (ret)
                goto out;
  
  /**
   * jbd2_mark_journal_empty() - Mark on disk journal as empty.
   * @journal: The journal to update.
 - * @write_op: With which operation should we write the journal sb
 + * @write_flags: Flags for the journal sb write operation
   *
   * Update a journal's dynamic superblock fields to show that journal is empty.
   * Write updated superblock to disk waiting for IO to complete.
   */
 -static void jbd2_mark_journal_empty(journal_t *journal, int write_op)
 +static void jbd2_mark_journal_empty(journal_t *journal, blk_opf_t write_flags)
  {
        journal_superblock_t *sb = journal->j_superblock;
        bool had_fast_commit = false;
                return;
        }
  
-       jbd_debug(1, "JBD2: Marking journal as empty (seq %u)\n",
+       jbd2_debug(1, "JBD2: Marking journal as empty (seq %u)\n",
                  journal->j_tail_sequence);
  
        sb->s_sequence = cpu_to_be32(journal->j_tail_sequence);
                had_fast_commit = true;
        }
  
 -      jbd2_write_superblock(journal, write_op);
 +      jbd2_write_superblock(journal, write_flags);
  
        if (had_fast_commit)
                jbd2_set_feature_fast_commit(journal);
@@@ -1865,7 -1859,7 +1862,7 @@@ void jbd2_journal_update_sb_errno(journ
        errcode = journal->j_errno;
        if (errcode == -ESHUTDOWN)
                errcode = 0;
-       jbd_debug(1, "JBD2: updating superblock error (errno %d)\n", errcode);
+       jbd2_debug(1, "JBD2: updating superblock error (errno %d)\n", errcode);
        sb->s_errno    = cpu_to_be32(errcode);
  
        jbd2_write_superblock(journal, REQ_SYNC | REQ_FUA);
@@@ -1901,7 -1895,7 +1898,7 @@@ static int journal_get_superblock(journ
  
        J_ASSERT(bh != NULL);
        if (!buffer_uptodate(bh)) {
 -              ll_rw_block(REQ_OP_READ, 0, 1, &bh);
 +              ll_rw_block(REQ_OP_READ, 1, &bh);
                wait_on_buffer(bh);
                if (!buffer_uptodate(bh)) {
                        printk(KERN_ERR
@@@ -2337,7 -2331,7 +2334,7 @@@ int jbd2_journal_set_features(journal_
            compat & JBD2_FEATURE_COMPAT_CHECKSUM)
                compat &= ~JBD2_FEATURE_COMPAT_CHECKSUM;
  
-       jbd_debug(1, "Setting new features 0x%lx/0x%lx/0x%lx\n",
+       jbd2_debug(1, "Setting new features 0x%lx/0x%lx/0x%lx\n",
                  compat, ro, incompat);
  
        sb = journal->j_superblock;
@@@ -2406,7 -2400,7 +2403,7 @@@ void jbd2_journal_clear_features(journa
  {
        journal_superblock_t *sb;
  
-       jbd_debug(1, "Clear features 0x%lx/0x%lx/0x%lx\n",
+       jbd2_debug(1, "Clear features 0x%lx/0x%lx/0x%lx\n",
                  compat, ro, incompat);
  
        sb = journal->j_superblock;
@@@ -2863,7 -2857,7 +2860,7 @@@ static struct journal_head *journal_all
  #endif
        ret = kmem_cache_zalloc(jbd2_journal_head_cache, GFP_NOFS);
        if (!ret) {
-               jbd_debug(1, "out of memory for journal_head\n");
+               jbd2_debug(1, "out of memory for journal_head\n");
                pr_notice_ratelimited("ENOMEM in %s, retrying.\n", __func__);
                ret = kmem_cache_zalloc(jbd2_journal_head_cache,
                                GFP_NOFS | __GFP_NOFAIL);
diff --combined fs/jbd2/recovery.c
@@@ -100,7 -100,7 +100,7 @@@ static int do_readahead(journal_t *jour
                if (!buffer_uptodate(bh) && !buffer_locked(bh)) {
                        bufs[nbufs++] = bh;
                        if (nbufs == MAXBUF) {
 -                              ll_rw_block(REQ_OP_READ, 0, nbufs, bufs);
 +                              ll_rw_block(REQ_OP_READ, nbufs, bufs);
                                journal_brelse_array(bufs, nbufs);
                                nbufs = 0;
                        }
        }
  
        if (nbufs)
 -              ll_rw_block(REQ_OP_READ, 0, nbufs, bufs);
 +              ll_rw_block(REQ_OP_READ, nbufs, bufs);
        err = 0;
  
  failed:
@@@ -245,11 -245,11 +245,11 @@@ static int fc_do_one_pass(journal_t *jo
                return 0;
  
        while (next_fc_block <= journal->j_fc_last) {
-               jbd_debug(3, "Fast commit replay: next block %ld\n",
+               jbd2_debug(3, "Fast commit replay: next block %ld\n",
                          next_fc_block);
                err = jread(&bh, journal, next_fc_block);
                if (err) {
-                       jbd_debug(3, "Fast commit replay: read error\n");
+                       jbd2_debug(3, "Fast commit replay: read error\n");
                        break;
                }
  
        }
  
        if (err)
-               jbd_debug(3, "Fast commit replay failed, err = %d\n", err);
+               jbd2_debug(3, "Fast commit replay failed, err = %d\n", err);
  
        return err;
  }
@@@ -297,7 -297,7 +297,7 @@@ int jbd2_journal_recover(journal_t *jou
         */
  
        if (!sb->s_start) {
-               jbd_debug(1, "No recovery required, last transaction %d\n",
+               jbd2_debug(1, "No recovery required, last transaction %d\n",
                          be32_to_cpu(sb->s_sequence));
                journal->j_transaction_sequence = be32_to_cpu(sb->s_sequence) + 1;
                return 0;
        if (!err)
                err = do_one_pass(journal, &info, PASS_REPLAY);
  
-       jbd_debug(1, "JBD2: recovery, exit status %d, "
+       jbd2_debug(1, "JBD2: recovery, exit status %d, "
                  "recovered transactions %u to %u\n",
                  err, info.start_transaction, info.end_transaction);
-       jbd_debug(1, "JBD2: Replayed %d and revoked %d/%d blocks\n",
+       jbd2_debug(1, "JBD2: Replayed %d and revoked %d/%d blocks\n",
                  info.nr_replays, info.nr_revoke_hits, info.nr_revokes);
  
        /* Restart the log at the next transaction ID, thus invalidating
@@@ -362,7 -362,7 +362,7 @@@ int jbd2_journal_skip_recovery(journal_
  #ifdef CONFIG_JBD2_DEBUG
                int dropped = info.end_transaction - 
                        be32_to_cpu(journal->j_superblock->s_sequence);
-               jbd_debug(1,
+               jbd2_debug(1,
                          "JBD2: ignoring %d transaction%s from the journal.\n",
                          dropped, (dropped == 1) ? "" : "s");
  #endif
@@@ -484,7 -484,7 +484,7 @@@ static int do_one_pass(journal_t *journ
        if (pass == PASS_SCAN)
                info->start_transaction = first_commit_ID;
  
-       jbd_debug(1, "Starting recovery pass %d\n", pass);
+       jbd2_debug(1, "Starting recovery pass %d\n", pass);
  
        /*
         * Now we walk through the log, transaction by transaction,
                        if (tid_geq(next_commit_ID, info->end_transaction))
                                break;
  
-               jbd_debug(2, "Scanning for sequence ID %u at %lu/%lu\n",
+               jbd2_debug(2, "Scanning for sequence ID %u at %lu/%lu\n",
                          next_commit_ID, next_log_block,
                          jbd2_has_feature_fast_commit(journal) ?
                          journal->j_fc_last : journal->j_last);
                 * either the next descriptor block or the final commit
                 * record. */
  
-               jbd_debug(3, "JBD2: checking block %ld\n", next_log_block);
+               jbd2_debug(3, "JBD2: checking block %ld\n", next_log_block);
                err = jread(&bh, journal, next_log_block);
                if (err)
                        goto failed;
  
                blocktype = be32_to_cpu(tmp->h_blocktype);
                sequence = be32_to_cpu(tmp->h_sequence);
-               jbd_debug(3, "Found magic %d, sequence %d\n",
+               jbd2_debug(3, "Found magic %d, sequence %d\n",
                          blocktype, sequence);
  
                if (sequence != next_commit_ID) {
                                        goto failed;
                                }
                                need_check_commit_time = true;
-                               jbd_debug(1,
+                               jbd2_debug(1,
                                        "invalid descriptor block found in %lu\n",
                                        next_log_block);
                        }
                                 * It likely does not belong to same journal,
                                 * just end this recovery with success.
                                 */
-                               jbd_debug(1, "JBD2: Invalid checksum ignored in transaction %u, likely stale data\n",
+                               jbd2_debug(1, "JBD2: Invalid checksum ignored in transaction %u, likely stale data\n",
                                          next_commit_ID);
                                brelse(bh);
                                goto done;
                        if (pass == PASS_SCAN &&
                            !jbd2_descriptor_block_csum_verify(journal,
                                                               bh->b_data)) {
-                               jbd_debug(1, "JBD2: invalid revoke block found in %lu\n",
+                               jbd2_debug(1, "JBD2: invalid revoke block found in %lu\n",
                                          next_log_block);
                                need_check_commit_time = true;
                        }
                        continue;
  
                default:
-                       jbd_debug(3, "Unrecognised magic %d, end of scan.\n",
+                       jbd2_debug(3, "Unrecognised magic %d, end of scan.\n",
                                  blocktype);
                        brelse(bh);
                        goto done;
diff --combined include/linux/jbd2.h
   * CONFIG_JBD2_DEBUG is on.
   */
  #define JBD2_EXPENSIVE_CHECKING
- extern ushort jbd2_journal_enable_debug;
  void __jbd2_debug(int level, const char *file, const char *func,
                  unsigned int line, const char *fmt, ...);
  
- #define jbd_debug(n, fmt, a...) \
+ #define jbd2_debug(n, fmt, a...) \
        __jbd2_debug((n), __FILE__, __func__, __LINE__, (fmt), ##a)
  #else
- #define jbd_debug(n, fmt, a...)  no_printk(fmt, ##a)
+ #define jbd2_debug(n, fmt, a...)  no_printk(fmt, ##a)
  #endif
  
  extern void *jbd2_alloc(size_t size, gfp_t flags);
@@@ -1557,7 -1556,7 +1556,7 @@@ extern int         jbd2_journal_wipe       (
  extern int       jbd2_journal_skip_recovery   (journal_t *);
  extern void      jbd2_journal_update_sb_errno(journal_t *);
  extern int       jbd2_journal_update_sb_log_tail      (journal_t *, tid_t,
 -                              unsigned long, int);
 +                              unsigned long, blk_opf_t);
  extern void      jbd2_journal_abort      (journal_t *, int);
  extern int       jbd2_journal_errno      (journal_t *);
  extern void      jbd2_journal_ack_err    (journal_t *);
@@@ -1647,7 -1646,6 +1646,6 @@@ extern void     jbd2_clear_buffer_revoked_f
   */
  
  int jbd2_log_start_commit(journal_t *journal, tid_t tid);
- int __jbd2_log_start_commit(journal_t *journal, tid_t tid);
  int jbd2_journal_start_commit(journal_t *journal, tid_t *tid);
  int jbd2_log_wait_commit(journal_t *journal, tid_t tid);
  int jbd2_transaction_committed(journal_t *journal, tid_t tid);