]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 4 Apr 2014 22:39:39 +0000 (15:39 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 4 Apr 2014 22:39:39 +0000 (15:39 -0700)
Pull ext4 updates from Ted Ts'o:
 "Major changes for 3.14 include support for the newly added ZERO_RANGE
  and COLLAPSE_RANGE fallocate operations, and scalability improvements
  in the jbd2 layer and in xattr handling when the extended attributes
  spill over into an external block.

  Other than that, the usual clean ups and minor bug fixes"

* tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: (42 commits)
  ext4: fix premature freeing of partial clusters split across leaf blocks
  ext4: remove unneeded test of ret variable
  ext4: fix comment typo
  ext4: make ext4_block_zero_page_range static
  ext4: atomically set inode->i_flags in ext4_set_inode_flags()
  ext4: optimize Hurd tests when reading/writing inodes
  ext4: kill i_version support for Hurd-castrated file systems
  ext4: each filesystem creates and uses its own mb_cache
  fs/mbcache.c: doucple the locking of local from global data
  fs/mbcache.c: change block and index hash chain to hlist_bl_node
  ext4: Introduce FALLOC_FL_ZERO_RANGE flag for fallocate
  ext4: refactor ext4_fallocate code
  ext4: Update inode i_size after the preallocation
  ext4: fix partial cluster handling for bigalloc file systems
  ext4: delete path dealloc code in ext4_ext_handle_uninitialized_extents
  ext4: only call sync_filesystm() when remounting read-only
  fs: push sync_filesystem() down to the file system's remount_fs()
  jbd2: improve error messages for inconsistent journal heads
  jbd2: minimize region locked by j_list_lock in jbd2_journal_forget()
  jbd2: minimize region locked by j_list_lock in journal_get_create_access()
  ...

22 files changed:
1  2 
fs/befs/linuxvfs.c
fs/btrfs/super.c
fs/cifs/cifsfs.c
fs/coda/inode.c
fs/cramfs/inode.c
fs/debugfs/inode.c
fs/efs/super.c
fs/ext4/inode.c
fs/fat/inode.c
fs/fuse/inode.c
fs/gfs2/super.c
fs/hfsplus/super.c
fs/inode.c
fs/minix/inode.c
fs/ncpfs/inode.c
fs/ocfs2/super.c
fs/proc/root.c
fs/reiserfs/super.c
fs/sysv/inode.c
fs/ubifs/super.c
fs/xfs/xfs_super.c
include/linux/fs.h

diff --combined fs/befs/linuxvfs.c
index 5188f1222987412c87f8b8ec974b79c05441be87,56d70c8a89b0869e08d3e4ff7f3c38d5c6b3d7af..d626756ff7219415d027380590371b70384445c9
@@@ -5,8 -5,6 +5,8 @@@
   *
   */
  
 +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 +
  #include <linux/module.h>
  #include <linux/slab.h>
  #include <linux/fs.h>
@@@ -41,6 -39,7 +41,6 @@@ static struct dentry *befs_lookup(struc
  static struct inode *befs_iget(struct super_block *, unsigned long);
  static struct inode *befs_alloc_inode(struct super_block *sb);
  static void befs_destroy_inode(struct inode *inode);
 -static int befs_init_inodecache(void);
  static void befs_destroy_inodecache(void);
  static void *befs_follow_link(struct dentry *, struct nameidata *);
  static void *befs_fast_follow_link(struct dentry *, struct nameidata *);
@@@ -132,28 -131,26 +132,28 @@@ befs_get_block(struct inode *inode, sec
        ulong disk_off;
  
        befs_debug(sb, "---> befs_get_block() for inode %lu, block %ld",
 -                 inode->i_ino, block);
 +                 (unsigned long)inode->i_ino, (long)block);
  
        if (block < 0) {
                befs_error(sb, "befs_get_block() was asked for a block "
                           "number less than zero: block %ld in inode %lu",
 -                         block, inode->i_ino);
 +                         (long)block, (unsigned long)inode->i_ino);
                return -EIO;
        }
  
        if (create) {
                befs_error(sb, "befs_get_block() was asked to write to "
 -                         "block %ld in inode %lu", block, inode->i_ino);
 +                         "block %ld in inode %lu", (long)block,
 +                         (unsigned long)inode->i_ino);
                return -EPERM;
        }
  
        res = befs_fblock2brun(sb, ds, block, &run);
        if (res != BEFS_OK) {
                befs_error(sb,
 -                         "<--- befs_get_block() for inode %lu, block "
 -                         "%ld ERROR", inode->i_ino, block);
 +                         "<--- %s for inode %lu, block %ld ERROR",
 +                         __func__, (unsigned long)inode->i_ino,
 +                         (long)block);
                return -EFBIG;
        }
  
  
        map_bh(bh_result, inode->i_sb, disk_off);
  
 -      befs_debug(sb, "<--- befs_get_block() for inode %lu, block %ld, "
 -                 "disk address %lu", inode->i_ino, block, disk_off);
 +      befs_debug(sb, "<--- %s for inode %lu, block %ld, disk address %lu",
 +                __func__, (unsigned long)inode->i_ino, (long)block,
 +                (unsigned long)disk_off);
  
        return 0;
  }
@@@ -180,15 -176,15 +180,15 @@@ befs_lookup(struct inode *dir, struct d
        char *utfname;
        const char *name = dentry->d_name.name;
  
 -      befs_debug(sb, "---> befs_lookup() "
 -                 "name %s inode %ld", dentry->d_name.name, dir->i_ino);
 +      befs_debug(sb, "---> %s name %s inode %ld", __func__,
 +                 dentry->d_name.name, dir->i_ino);
  
        /* Convert to UTF-8 */
        if (BEFS_SB(sb)->nls) {
                ret =
                    befs_nls2utf(sb, name, strlen(name), &utfname, &utfnamelen);
                if (ret < 0) {
 -                      befs_debug(sb, "<--- befs_lookup() ERROR");
 +                      befs_debug(sb, "<--- %s ERROR", __func__);
                        return ERR_PTR(ret);
                }
                ret = befs_btree_find(sb, ds, utfname, &offset);
        }
  
        if (ret == BEFS_BT_NOT_FOUND) {
 -              befs_debug(sb, "<--- befs_lookup() %s not found",
 +              befs_debug(sb, "<--- %s %s not found", __func__,
                           dentry->d_name.name);
                return ERR_PTR(-ENOENT);
  
        } else if (ret != BEFS_OK || offset == 0) {
 -              befs_warning(sb, "<--- befs_lookup() Error");
 +              befs_warning(sb, "<--- %s Error", __func__);
                return ERR_PTR(-ENODATA);
        }
  
  
        d_add(dentry, inode);
  
 -      befs_debug(sb, "<--- befs_lookup()");
 +      befs_debug(sb, "<--- %s", __func__);
  
        return NULL;
  }
@@@ -232,25 -228,26 +232,25 @@@ befs_readdir(struct file *file, struct 
        char keybuf[BEFS_NAME_LEN + 1];
        const char *dirname = file->f_path.dentry->d_name.name;
  
 -      befs_debug(sb, "---> befs_readdir() "
 -                 "name %s, inode %ld, ctx->pos %Ld",
 -                 dirname, inode->i_ino, ctx->pos);
 +      befs_debug(sb, "---> %s name %s, inode %ld, ctx->pos %lld",
 +                __func__, dirname, inode->i_ino, ctx->pos);
  
  more:
        result = befs_btree_read(sb, ds, ctx->pos, BEFS_NAME_LEN + 1,
                                 keybuf, &keysize, &value);
  
        if (result == BEFS_ERR) {
 -              befs_debug(sb, "<--- befs_readdir() ERROR");
 +              befs_debug(sb, "<--- %s ERROR", __func__);
                befs_error(sb, "IO error reading %s (inode %lu)",
                           dirname, inode->i_ino);
                return -EIO;
  
        } else if (result == BEFS_BT_END) {
 -              befs_debug(sb, "<--- befs_readdir() END");
 +              befs_debug(sb, "<--- %s END", __func__);
                return 0;
  
        } else if (result == BEFS_BT_EMPTY) {
 -              befs_debug(sb, "<--- befs_readdir() Empty directory");
 +              befs_debug(sb, "<--- %s Empty directory", __func__);
                return 0;
        }
  
                result =
                    befs_utf2nls(sb, keybuf, keysize, &nlsname, &nlsnamelen);
                if (result < 0) {
 -                      befs_debug(sb, "<--- befs_readdir() ERROR");
 +                      befs_debug(sb, "<--- %s ERROR", __func__);
                        return result;
                }
                if (!dir_emit(ctx, nlsname, nlsnamelen,
        ctx->pos++;
        goto more;
  
 -      befs_debug(sb, "<--- befs_readdir() pos %Ld", ctx->pos);
 +      befs_debug(sb, "<--- %s pos %lld", __func__, ctx->pos);
  
        return 0;
  }
@@@ -324,7 -321,7 +324,7 @@@ static struct inode *befs_iget(struct s
        struct inode *inode;
        long ret = -EIO;
  
 -      befs_debug(sb, "---> befs_read_inode() " "inode = %lu", ino);
 +      befs_debug(sb, "---> %s inode = %lu", __func__, ino);
  
        inode = iget_locked(sb, ino);
        if (!inode)
        }
  
        brelse(bh);
 -      befs_debug(sb, "<--- befs_read_inode()");
 +      befs_debug(sb, "<--- %s", __func__);
        unlock_new_inode(inode);
        return inode;
  
  
        unacquire_none:
        iget_failed(inode);
 -      befs_debug(sb, "<--- befs_read_inode() - Bad inode");
 +      befs_debug(sb, "<--- %s - Bad inode", __func__);
        return ERR_PTR(ret);
  }
  
   *
   * Taken from NFS implementation by Al Viro.
   */
 -static int
 +static int __init
  befs_init_inodecache(void)
  {
        befs_inode_cachep = kmem_cache_create("befs_inode_cache",
                                                SLAB_MEM_SPREAD),
                                              init_once);
        if (befs_inode_cachep == NULL) {
 -              printk(KERN_ERR "befs_init_inodecache: "
 -                     "Couldn't initialize inode slabcache\n");
 +              pr_err("%s: Couldn't initialize inode slabcache\n", __func__);
                return -ENOMEM;
        }
 -
        return 0;
  }
  
@@@ -545,16 -544,16 +545,16 @@@ befs_utf2nls(struct super_block *sb, co
         */
        int maxlen = in_len + 1;
  
 -      befs_debug(sb, "---> utf2nls()");
 +      befs_debug(sb, "---> %s", __func__);
  
        if (!nls) {
 -              befs_error(sb, "befs_utf2nls called with no NLS table loaded");
 +              befs_error(sb, "%s called with no NLS table loaded", __func__);
                return -EINVAL;
        }
  
        *out = result = kmalloc(maxlen, GFP_NOFS);
        if (!*out) {
 -              befs_error(sb, "befs_utf2nls() cannot allocate memory");
 +              befs_error(sb, "%s cannot allocate memory", __func__);
                *out_len = 0;
                return -ENOMEM;
        }
        result[o] = '\0';
        *out_len = o;
  
 -      befs_debug(sb, "<--- utf2nls()");
 +      befs_debug(sb, "<--- %s", __func__);
  
        return o;
  
        conv_err:
        befs_error(sb, "Name using character set %s contains a character that "
                   "cannot be converted to unicode.", nls->charset);
 -      befs_debug(sb, "<--- utf2nls()");
 +      befs_debug(sb, "<--- %s", __func__);
        kfree(result);
        return -EILSEQ;
  }
@@@ -624,17 -623,16 +624,17 @@@ befs_nls2utf(struct super_block *sb, co
         * in special cases */
        int maxlen = (3 * in_len) + 1;
  
 -      befs_debug(sb, "---> nls2utf()\n");
 +      befs_debug(sb, "---> %s\n", __func__);
  
        if (!nls) {
 -              befs_error(sb, "befs_nls2utf called with no NLS table loaded.");
 +              befs_error(sb, "%s called with no NLS table loaded.",
 +                         __func__);
                return -EINVAL;
        }
  
        *out = result = kmalloc(maxlen, GFP_NOFS);
        if (!*out) {
 -              befs_error(sb, "befs_nls2utf() cannot allocate memory");
 +              befs_error(sb, "%s cannot allocate memory", __func__);
                *out_len = 0;
                return -ENOMEM;
        }
        result[o] = '\0';
        *out_len = o;
  
 -      befs_debug(sb, "<--- nls2utf()");
 +      befs_debug(sb, "<--- %s", __func__);
  
        return i;
  
        conv_err:
        befs_error(sb, "Name using charecter set %s contains a charecter that "
                   "cannot be converted to unicode.", nls->charset);
 -      befs_debug(sb, "<--- nls2utf()");
 +      befs_debug(sb, "<--- %s", __func__);
        kfree(result);
        return -EILSEQ;
  }
@@@ -717,8 -715,8 +717,8 @@@ parse_options(char *options, befs_mount
                        if (option >= 0)
                                uid = make_kuid(current_user_ns(), option);
                        if (!uid_valid(uid)) {
 -                              printk(KERN_ERR "BeFS: Invalid uid %d, "
 -                                              "using default\n", option);
 +                              pr_err("Invalid uid %d, "
 +                                     "using default\n", option);
                                break;
                        }
                        opts->uid = uid;
                        if (option >= 0)
                                gid = make_kgid(current_user_ns(), option);
                        if (!gid_valid(gid)) {
 -                              printk(KERN_ERR "BeFS: Invalid gid %d, "
 -                                              "using default\n", option);
 +                              pr_err("Invalid gid %d, "
 +                                     "using default\n", option);
                                break;
                        }
                        opts->gid = gid;
                        kfree(opts->iocharset);
                        opts->iocharset = match_strdup(&args[0]);
                        if (!opts->iocharset) {
 -                              printk(KERN_ERR "BeFS: allocation failure for "
 -                                              "iocharset string\n");
 +                              pr_err("allocation failure for "
 +                                     "iocharset string\n");
                                return 0;
                        }
                        break;
                        opts->debug = 1;
                        break;
                default:
 -                      printk(KERN_ERR "BeFS: Unrecognized mount option \"%s\" "
 -                                      "or missing value\n", p);
 +                      pr_err("Unrecognized mount option \"%s\" "
 +                             "or missing value\n", p);
                        return 0;
                }
        }
@@@ -793,20 -791,22 +793,20 @@@ befs_fill_super(struct super_block *sb
  
        save_mount_options(sb, data);
  
 -      sb->s_fs_info = kmalloc(sizeof (*befs_sb), GFP_KERNEL);
 +      sb->s_fs_info = kzalloc(sizeof(*befs_sb), GFP_KERNEL);
        if (sb->s_fs_info == NULL) {
 -              printk(KERN_ERR
 -                     "BeFS(%s): Unable to allocate memory for private "
 +              pr_err("(%s): Unable to allocate memory for private "
                       "portion of superblock. Bailing.\n", sb->s_id);
                goto unacquire_none;
        }
        befs_sb = BEFS_SB(sb);
 -      memset(befs_sb, 0, sizeof(befs_sb_info));
  
        if (!parse_options((char *) data, &befs_sb->mount_opts)) {
                befs_error(sb, "cannot parse mount options");
                goto unacquire_priv_sbp;
        }
  
 -      befs_debug(sb, "---> befs_fill_super()");
 +      befs_debug(sb, "---> %s", __func__);
  
  #ifndef CONFIG_BEFS_RW
        if (!(sb->s_flags & MS_RDONLY)) {
                goto unacquire_priv_sbp;
  
        if( befs_sb->num_blocks > ~((sector_t)0) ) {
 -              befs_error(sb, "blocks count: %Lu "
 +              befs_error(sb, "blocks count: %llu "
                        "is larger than the host can use",
                        befs_sb->num_blocks);
                goto unacquire_priv_sbp;
  static int
  befs_remount(struct super_block *sb, int *flags, char *data)
  {
+       sync_filesystem(sb);
        if (!(*flags & MS_RDONLY))
                return -EINVAL;
        return 0;
@@@ -924,7 -925,7 +925,7 @@@ befs_statfs(struct dentry *dentry, stru
        struct super_block *sb = dentry->d_sb;
        u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
  
 -      befs_debug(sb, "---> befs_statfs()");
 +      befs_debug(sb, "---> %s", __func__);
  
        buf->f_type = BEFS_SUPER_MAGIC;
        buf->f_bsize = sb->s_blocksize;
        buf->f_fsid.val[1] = (u32)(id >> 32);
        buf->f_namelen = BEFS_NAME_LEN;
  
 -      befs_debug(sb, "<--- befs_statfs()");
 +      befs_debug(sb, "<--- %s", __func__);
  
        return 0;
  }
@@@ -963,7 -964,7 +964,7 @@@ init_befs_fs(void
  {
        int err;
  
 -      printk(KERN_INFO "BeFS version: %s\n", BEFS_VERSION);
 +      pr_info("version: %s\n", BEFS_VERSION);
  
        err = befs_init_inodecache();
        if (err)
diff --combined fs/btrfs/super.c
index d4878ddba87acdd4ceb927ce71d8c015b5085fc8,00cd0c57b0b3dd39b59cea127e849eec36e34890..9dbf4239515308a480b3cdb2cfc48b4b38812811
@@@ -566,7 -566,7 +566,7 @@@ int btrfs_parse_options(struct btrfs_ro
                                kfree(num);
  
                                if (info->max_inline) {
 -                                      info->max_inline = max_t(u64,
 +                                      info->max_inline = min_t(u64,
                                                info->max_inline,
                                                root->sectorsize);
                                }
@@@ -855,7 -855,6 +855,7 @@@ static struct dentry *get_default_root(
        struct btrfs_path *path;
        struct btrfs_key location;
        struct inode *inode;
 +      struct dentry *dentry;
        u64 dir_id;
        int new = 0;
  
@@@ -926,13 -925,7 +926,13 @@@ setup_root
                return dget(sb->s_root);
        }
  
 -      return d_obtain_alias(inode);
 +      dentry = d_obtain_alias(inode);
 +      if (!IS_ERR(dentry)) {
 +              spin_lock(&dentry->d_lock);
 +              dentry->d_flags &= ~DCACHE_DISCONNECTED;
 +              spin_unlock(&dentry->d_lock);
 +      }
 +      return dentry;
  }
  
  static int btrfs_fill_super(struct super_block *sb,
@@@ -1305,6 -1298,13 +1305,6 @@@ error_fs_info
        return ERR_PTR(error);
  }
  
 -static void btrfs_set_max_workers(struct btrfs_workers *workers, int new_limit)
 -{
 -      spin_lock_irq(&workers->lock);
 -      workers->max_workers = new_limit;
 -      spin_unlock_irq(&workers->lock);
 -}
 -
  static void btrfs_resize_thread_pool(struct btrfs_fs_info *fs_info,
                                     int new_pool_size, int old_pool_size)
  {
        btrfs_info(fs_info, "resize thread pool %d -> %d",
               old_pool_size, new_pool_size);
  
 -      btrfs_set_max_workers(&fs_info->generic_worker, new_pool_size);
 -      btrfs_set_max_workers(&fs_info->workers, new_pool_size);
 -      btrfs_set_max_workers(&fs_info->delalloc_workers, new_pool_size);
 -      btrfs_set_max_workers(&fs_info->submit_workers, new_pool_size);
 -      btrfs_set_max_workers(&fs_info->caching_workers, new_pool_size);
 -      btrfs_set_max_workers(&fs_info->fixup_workers, new_pool_size);
 -      btrfs_set_max_workers(&fs_info->endio_workers, new_pool_size);
 -      btrfs_set_max_workers(&fs_info->endio_meta_workers, new_pool_size);
 -      btrfs_set_max_workers(&fs_info->endio_meta_write_workers, new_pool_size);
 -      btrfs_set_max_workers(&fs_info->endio_write_workers, new_pool_size);
 -      btrfs_set_max_workers(&fs_info->endio_freespace_worker, new_pool_size);
 -      btrfs_set_max_workers(&fs_info->delayed_workers, new_pool_size);
 -      btrfs_set_max_workers(&fs_info->readahead_workers, new_pool_size);
 -      btrfs_set_max_workers(&fs_info->scrub_wr_completion_workers,
 -                            new_pool_size);
 +      btrfs_workqueue_set_max(fs_info->workers, new_pool_size);
 +      btrfs_workqueue_set_max(fs_info->delalloc_workers, new_pool_size);
 +      btrfs_workqueue_set_max(fs_info->submit_workers, new_pool_size);
 +      btrfs_workqueue_set_max(fs_info->caching_workers, new_pool_size);
 +      btrfs_workqueue_set_max(fs_info->endio_workers, new_pool_size);
 +      btrfs_workqueue_set_max(fs_info->endio_meta_workers, new_pool_size);
 +      btrfs_workqueue_set_max(fs_info->endio_meta_write_workers,
 +                              new_pool_size);
 +      btrfs_workqueue_set_max(fs_info->endio_write_workers, new_pool_size);
 +      btrfs_workqueue_set_max(fs_info->endio_freespace_worker, new_pool_size);
 +      btrfs_workqueue_set_max(fs_info->delayed_workers, new_pool_size);
 +      btrfs_workqueue_set_max(fs_info->readahead_workers, new_pool_size);
 +      btrfs_workqueue_set_max(fs_info->scrub_wr_completion_workers,
 +                              new_pool_size);
  }
  
  static inline void btrfs_remount_prepare(struct btrfs_fs_info *fs_info)
@@@ -1380,6 -1381,7 +1380,7 @@@ static int btrfs_remount(struct super_b
        unsigned int old_metadata_ratio = fs_info->metadata_ratio;
        int ret;
  
+       sync_filesystem(sb);
        btrfs_remount_prepare(fs_info);
  
        ret = btrfs_parse_options(root, data);
                sb->s_flags &= ~MS_RDONLY;
        }
  out:
 +      wake_up_process(fs_info->transaction_kthread);
        btrfs_remount_cleanup(fs_info, old_opts);
        return 0;
  
diff --combined fs/cifs/cifsfs.c
index ab8ad2546c3e69d40f005f193c064a9062a2977a,4942c94bf7ee621eae5a6c91fd9f8d43ea158427..2c70cbe35d39c3b7df79dd0b7e2b3fde6401f8fe
@@@ -286,7 -286,7 +286,7 @@@ cifs_destroy_inode(struct inode *inode
  static void
  cifs_evict_inode(struct inode *inode)
  {
 -      truncate_inode_pages(&inode->i_data, 0);
 +      truncate_inode_pages_final(&inode->i_data);
        clear_inode(inode);
        cifs_fscache_release_inode_cookie(inode);
  }
@@@ -541,6 -541,7 +541,7 @@@ static int cifs_show_stats(struct seq_f
  
  static int cifs_remount(struct super_block *sb, int *flags, char *data)
  {
+       sync_filesystem(sb);
        *flags |= MS_NODIRATIME;
        return 0;
  }
@@@ -1005,7 -1006,7 +1006,7 @@@ cifs_init_once(void *inode
        init_rwsem(&cifsi->lock_sem);
  }
  
 -static int
 +static int __init
  cifs_init_inodecache(void)
  {
        cifs_inode_cachep = kmem_cache_create("cifs_inode_cache",
diff --combined fs/coda/inode.c
index 626abc02b694e074cd9dc631cc619b7d8c9e44ed,3f48000ef1a5da3242a65971f1a73e7d1d5d20ae..d9c7751f10acef9bc7195c342552c4d58e0f9a71
@@@ -73,7 -73,7 +73,7 @@@ static void init_once(void *foo
        inode_init_once(&ei->vfs_inode);
  }
  
 -int coda_init_inodecache(void)
 +int __init coda_init_inodecache(void)
  {
        coda_inode_cachep = kmem_cache_create("coda_inode_cache",
                                sizeof(struct coda_inode_info),
@@@ -96,6 -96,7 +96,7 @@@ void coda_destroy_inodecache(void
  
  static int coda_remount(struct super_block *sb, int *flags, char *data)
  {
+       sync_filesystem(sb);
        *flags |= MS_NOATIME;
        return 0;
  }
@@@ -250,7 -251,7 +251,7 @@@ static void coda_put_super(struct super
  
  static void coda_evict_inode(struct inode *inode)
  {
 -      truncate_inode_pages(&inode->i_data, 0);
 +      truncate_inode_pages_final(&inode->i_data);
        clear_inode(inode);
        coda_cache_clear_inode(inode);
  }
diff --combined fs/cramfs/inode.c
index a1f801c14fbc206bacf02a12040c4b3c1515937c,a2759112563c95916fbfed4b60eaa9f2d6535601..ddcfe590b8a857a13faf7c5eefc4a9d7d8bcbdb9
@@@ -195,7 -195,8 +195,7 @@@ static void *cramfs_read(struct super_b
                struct page *page = NULL;
  
                if (blocknr + i < devsize) {
 -                      page = read_mapping_page_async(mapping, blocknr + i,
 -                                                                      NULL);
 +                      page = read_mapping_page(mapping, blocknr + i, NULL);
                        /* synchronous error? */
                        if (IS_ERR(page))
                                page = NULL;
@@@ -243,6 -244,7 +243,7 @@@ static void cramfs_kill_sb(struct super
  
  static int cramfs_remount(struct super_block *sb, int *flags, char *data)
  {
+       sync_filesystem(sb);
        *flags |= MS_RDONLY;
        return 0;
  }
diff --combined fs/debugfs/inode.c
index ca4a08f383743868db0a4949c608b1b3cc4e1be1,02928a9d00a87c7a359faae79a36b2d332da5cd7..8c41b52da35872461cffbbebcd0299b2cc9d4d45
@@@ -218,6 -218,7 +218,7 @@@ static int debugfs_remount(struct super
        int err;
        struct debugfs_fs_info *fsi = sb->s_fs_info;
  
+       sync_filesystem(sb);
        err = debugfs_parse_options(data, &fsi->mount_opts);
        if (err)
                goto fail;
@@@ -358,7 -359,7 +359,7 @@@ exit
   * @name: a pointer to a string containing the name of the file to create.
   * @mode: the permission that the file should have.
   * @parent: a pointer to the parent dentry for this file.  This should be a
 - *          directory dentry if set.  If this paramater is NULL, then the
 + *          directory dentry if set.  If this parameter is NULL, then the
   *          file will be created in the root of the debugfs filesystem.
   * @data: a pointer to something that the caller will want to get to later
   *        on.  The inode.i_private pointer will point to this value on
@@@ -400,7 -401,7 +401,7 @@@ EXPORT_SYMBOL_GPL(debugfs_create_file)
   * @name: a pointer to a string containing the name of the directory to
   *        create.
   * @parent: a pointer to the parent dentry for this file.  This should be a
 - *          directory dentry if set.  If this paramater is NULL, then the
 + *          directory dentry if set.  If this parameter is NULL, then the
   *          directory will be created in the root of the debugfs filesystem.
   *
   * This function creates a directory in debugfs with the given name.
@@@ -425,7 -426,7 +426,7 @@@ EXPORT_SYMBOL_GPL(debugfs_create_dir)
   * @name: a pointer to a string containing the name of the symbolic link to
   *        create.
   * @parent: a pointer to the parent dentry for this symbolic link.  This
 - *          should be a directory dentry if set.  If this paramater is NULL,
 + *          should be a directory dentry if set.  If this parameter is NULL,
   *          then the symbolic link will be created in the root of the debugfs
   *          filesystem.
   * @target: a pointer to a string containing the path to the target of the
diff --combined fs/efs/super.c
index f8def1acf08cf3e2e313319f810854131830d62b,103bbd820b87c38f9923382231299e0e51360336..3befcc9f5d63c55c9872989300ff7f744553be1f
@@@ -91,7 -91,7 +91,7 @@@ static void init_once(void *foo
        inode_init_once(&ei->vfs_inode);
  }
  
 -static int init_inodecache(void)
 +static int __init init_inodecache(void)
  {
        efs_inode_cachep = kmem_cache_create("efs_inode_cache",
                                sizeof(struct efs_inode_info),
@@@ -114,6 -114,7 +114,7 @@@ static void destroy_inodecache(void
  
  static int efs_remount(struct super_block *sb, int *flags, char *data)
  {
+       sync_filesystem(sb);
        *flags |= MS_RDONLY;
        return 0;
  }
diff --combined fs/ext4/inode.c
index 175c3f933816b72ecb02ebd1fa479cf5278fa142,0171c19a5467e12f38af38368be7e450dd4c04d4..5b0d2c7d54080dea4080909fe8ec6a74ecf19b56
@@@ -38,7 -38,6 +38,7 @@@
  #include <linux/slab.h>
  #include <linux/ratelimit.h>
  #include <linux/aio.h>
 +#include <linux/bitops.h>
  
  #include "ext4_jbd2.h"
  #include "xattr.h"
@@@ -215,7 -214,7 +215,7 @@@ void ext4_evict_inode(struct inode *ino
                        jbd2_complete_transaction(journal, commit_tid);
                        filemap_write_and_wait(&inode->i_data);
                }
 -              truncate_inode_pages(&inode->i_data, 0);
 +              truncate_inode_pages_final(&inode->i_data);
  
                WARN_ON(atomic_read(&EXT4_I(inode)->i_ioend_count));
                goto no_delete;
  
        if (ext4_should_order_data(inode))
                ext4_begin_ordered_truncate(inode, 0);
 -      truncate_inode_pages(&inode->i_data, 0);
 +      truncate_inode_pages_final(&inode->i_data);
  
        WARN_ON(atomic_read(&EXT4_I(inode)->i_ioend_count));
        if (is_bad_inode(inode))
@@@ -504,6 -503,7 +504,7 @@@ int ext4_map_blocks(handle_t *handle, s
  {
        struct extent_status es;
        int retval;
+       int ret = 0;
  #ifdef ES_AGGRESSIVE_TEST
        struct ext4_map_blocks orig_map;
  
                  "logical block %lu\n", inode->i_ino, flags, map->m_len,
                  (unsigned long) map->m_lblk);
  
+       /*
+        * ext4_map_blocks returns an int, and m_len is an unsigned int
+        */
+       if (unlikely(map->m_len > INT_MAX))
+               map->m_len = INT_MAX;
        /* Lookup extent status tree firstly */
        if (ext4_es_lookup_extent(inode, map->m_lblk, &es)) {
                ext4_es_lru_add(inode);
                                             EXT4_GET_BLOCKS_KEEP_SIZE);
        }
        if (retval > 0) {
-               int ret;
                unsigned int status;
  
                if (unlikely(retval != map->m_len)) {
  
  found:
        if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) {
-               int ret = check_block_validity(inode, map);
+               ret = check_block_validity(inode, map);
                if (ret != 0)
                        return ret;
        }
         * with buffer head unmapped.
         */
        if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED)
-               return retval;
+               /*
+                * If we need to convert extent to unwritten
+                * we continue and do the actual work in
+                * ext4_ext_map_blocks()
+                */
+               if (!(flags & EXT4_GET_BLOCKS_CONVERT_UNWRITTEN))
+                       return retval;
  
        /*
         * Here we clear m_flags because after allocating an new extent,
                ext4_clear_inode_state(inode, EXT4_STATE_DELALLOC_RESERVED);
  
        if (retval > 0) {
-               int ret;
                unsigned int status;
  
                if (unlikely(retval != map->m_len)) {
  has_zeroout:
        up_write((&EXT4_I(inode)->i_data_sem));
        if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) {
-               int ret = check_block_validity(inode, map);
+               ret = check_block_validity(inode, map);
                if (ret != 0)
                        return ret;
        }
@@@ -3312,26 -3322,6 +3323,6 @@@ void ext4_set_aops(struct inode *inode
                inode->i_mapping->a_ops = &ext4_aops;
  }
  
- /*
-  * ext4_block_truncate_page() zeroes out a mapping from file offset `from'
-  * up to the end of the block which corresponds to `from'.
-  * This required during truncate. We need to physically zero the tail end
-  * of that block so it doesn't yield old data if the file is later grown.
-  */
- int ext4_block_truncate_page(handle_t *handle,
-               struct address_space *mapping, loff_t from)
- {
-       unsigned offset = from & (PAGE_CACHE_SIZE-1);
-       unsigned length;
-       unsigned blocksize;
-       struct inode *inode = mapping->host;
-       blocksize = inode->i_sb->s_blocksize;
-       length = blocksize - (offset & (blocksize - 1));
-       return ext4_block_zero_page_range(handle, mapping, from, length);
- }
  /*
   * ext4_block_zero_page_range() zeros out a mapping of length 'length'
   * starting from file offset 'from'.  The range to be zero'd must
   * the end of the block it will be shortened to end of the block
   * that cooresponds to 'from'
   */
- int ext4_block_zero_page_range(handle_t *handle,
static int ext4_block_zero_page_range(handle_t *handle,
                struct address_space *mapping, loff_t from, loff_t length)
  {
        ext4_fsblk_t index = from >> PAGE_CACHE_SHIFT;
@@@ -3429,6 -3419,26 +3420,26 @@@ unlock
        return err;
  }
  
+ /*
+  * ext4_block_truncate_page() zeroes out a mapping from file offset `from'
+  * up to the end of the block which corresponds to `from'.
+  * This required during truncate. We need to physically zero the tail end
+  * of that block so it doesn't yield old data if the file is later grown.
+  */
+ int ext4_block_truncate_page(handle_t *handle,
+               struct address_space *mapping, loff_t from)
+ {
+       unsigned offset = from & (PAGE_CACHE_SIZE-1);
+       unsigned length;
+       unsigned blocksize;
+       struct inode *inode = mapping->host;
+       blocksize = inode->i_sb->s_blocksize;
+       length = blocksize - (offset & (blocksize - 1));
+       return ext4_block_zero_page_range(handle, mapping, from, length);
+ }
  int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode,
                             loff_t lstart, loff_t length)
  {
@@@ -3502,7 -3512,7 +3513,7 @@@ int ext4_punch_hole(struct inode *inode
        if (!S_ISREG(inode->i_mode))
                return -EOPNOTSUPP;
  
-       trace_ext4_punch_hole(inode, offset, length);
+       trace_ext4_punch_hole(inode, offset, length, 0);
  
        /*
         * Write out all dirty pages to avoid race conditions
        up_write(&EXT4_I(inode)->i_data_sem);
        if (IS_SYNC(inode))
                ext4_handle_sync(handle);
+       /* Now release the pages again to reduce race window */
+       if (last_block_offset > first_block_offset)
+               truncate_pagecache_range(inode, first_block_offset,
+                                        last_block_offset);
        inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
        ext4_mark_inode_dirty(handle, inode);
  out_stop:
@@@ -3682,7 -3698,7 +3699,7 @@@ void ext4_truncate(struct inode *inode
  
        /*
         * There is a possibility that we're either freeing the inode
-        * or it completely new indode. In those cases we might not
+        * or it's a completely new inode. In those cases we might not
         * have i_mutex locked because it's not necessary.
         */
        if (!(inode->i_state & (I_NEW|I_FREEING)))
@@@ -3934,8 -3950,8 +3951,8 @@@ void ext4_set_inode_flags(struct inode 
                new_fl |= S_NOATIME;
        if (flags & EXT4_DIRSYNC_FL)
                new_fl |= S_DIRSYNC;
-       set_mask_bits(&inode->i_flags,
-                     S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC, new_fl);
+       inode_set_flags(inode, new_fl,
+                       S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
  }
  
  /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
@@@ -4154,11 -4170,13 +4171,13 @@@ struct inode *ext4_iget(struct super_bl
        EXT4_INODE_GET_XTIME(i_atime, inode, raw_inode);
        EXT4_EINODE_GET_XTIME(i_crtime, ei, raw_inode);
  
-       inode->i_version = le32_to_cpu(raw_inode->i_disk_version);
-       if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
-               if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
-                       inode->i_version |=
-                       (__u64)(le32_to_cpu(raw_inode->i_version_hi)) << 32;
+       if (likely(!test_opt2(inode->i_sb, HURD_COMPAT))) {
+               inode->i_version = le32_to_cpu(raw_inode->i_disk_version);
+               if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
+                       if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
+                               inode->i_version |=
+                   (__u64)(le32_to_cpu(raw_inode->i_version_hi)) << 32;
+               }
        }
  
        ret = 0;
@@@ -4328,8 -4346,7 +4347,7 @@@ static int ext4_do_update_inode(handle_
                goto out_brelse;
        raw_inode->i_dtime = cpu_to_le32(ei->i_dtime);
        raw_inode->i_flags = cpu_to_le32(ei->i_flags & 0xFFFFFFFF);
-       if (EXT4_SB(inode->i_sb)->s_es->s_creator_os !=
-           cpu_to_le32(EXT4_OS_HURD))
+       if (likely(!test_opt2(inode->i_sb, HURD_COMPAT)))
                raw_inode->i_file_acl_high =
                        cpu_to_le16(ei->i_file_acl >> 32);
        raw_inode->i_file_acl_lo = cpu_to_le32(ei->i_file_acl);
                        raw_inode->i_block[block] = ei->i_data[block];
        }
  
-       raw_inode->i_disk_version = cpu_to_le32(inode->i_version);
-       if (ei->i_extra_isize) {
-               if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
-                       raw_inode->i_version_hi =
-                       cpu_to_le32(inode->i_version >> 32);
-               raw_inode->i_extra_isize = cpu_to_le16(ei->i_extra_isize);
+       if (likely(!test_opt2(inode->i_sb, HURD_COMPAT))) {
+               raw_inode->i_disk_version = cpu_to_le32(inode->i_version);
+               if (ei->i_extra_isize) {
+                       if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
+                               raw_inode->i_version_hi =
+                                       cpu_to_le32(inode->i_version >> 32);
+                       raw_inode->i_extra_isize =
+                               cpu_to_le16(ei->i_extra_isize);
+               }
        }
  
        ext4_inode_csum_set(inode, raw_inode, ei);
@@@ -4446,7 -4466,12 +4467,12 @@@ int ext4_write_inode(struct inode *inod
                        return -EIO;
                }
  
-               if (wbc->sync_mode != WB_SYNC_ALL)
+               /*
+                * No need to force transaction in WB_SYNC_NONE mode. Also
+                * ext4_sync_fs() will force the commit after everything is
+                * written.
+                */
+               if (wbc->sync_mode != WB_SYNC_ALL || wbc->for_sync)
                        return 0;
  
                err = ext4_force_commit(inode->i_sb);
                err = __ext4_get_inode_loc(inode, &iloc, 0);
                if (err)
                        return err;
-               if (wbc->sync_mode == WB_SYNC_ALL)
+               /*
+                * sync(2) will flush the whole buffer cache. No need to do
+                * it here separately for each inode.
+                */
+               if (wbc->sync_mode == WB_SYNC_ALL && !wbc->for_sync)
                        sync_dirty_buffer(iloc.bh);
                if (buffer_req(iloc.bh) && !buffer_uptodate(iloc.bh)) {
                        EXT4_ERROR_INODE_BLOCK(inode, iloc.bh->b_blocknr,
diff --combined fs/fat/inode.c
index c68d9f27135e4b72a41ba63bc9d3e758fbd81c98,343e477c6dcb1fe2e83324ffd1f7a86ce5a3d743..b3361fe2bcb590183150fac820d6ffbc1f46e9f9
@@@ -490,7 -490,7 +490,7 @@@ EXPORT_SYMBOL_GPL(fat_build_inode)
  
  static void fat_evict_inode(struct inode *inode)
  {
 -      truncate_inode_pages(&inode->i_data, 0);
 +      truncate_inode_pages_final(&inode->i_data);
        if (!inode->i_nlink) {
                inode->i_size = 0;
                fat_truncate_blocks(inode, 0);
@@@ -635,6 -635,8 +635,8 @@@ static int fat_remount(struct super_blo
        struct msdos_sb_info *sbi = MSDOS_SB(sb);
        *flags |= MS_NODIRATIME | (sbi->options.isvfat ? 0 : MS_NOATIME);
  
+       sync_filesystem(sb);
        /* make sure we update state on remount. */
        new_rdonly = *flags & MS_RDONLY;
        if (new_rdonly != (sb->s_flags & MS_RDONLY)) {
diff --combined fs/fuse/inode.c
index b4bff1b15028ff3fb99e33521517acb38f355177,ecdb255d086da871b5c092398f74644d04dfe2a0..8d611696fcad303dfe4137a2ff9bc9e1d2a5b97d
@@@ -123,7 -123,7 +123,7 @@@ static void fuse_destroy_inode(struct i
  
  static void fuse_evict_inode(struct inode *inode)
  {
 -      truncate_inode_pages(&inode->i_data, 0);
 +      truncate_inode_pages_final(&inode->i_data);
        clear_inode(inode);
        if (inode->i_sb->s_flags & MS_ACTIVE) {
                struct fuse_conn *fc = get_fuse_conn(inode);
  
  static int fuse_remount_fs(struct super_block *sb, int *flags, char *data)
  {
+       sync_filesystem(sb);
        if (*flags & MS_MANDLOCK)
                return -EINVAL;
  
@@@ -170,11 -171,8 +171,11 @@@ void fuse_change_attributes_common(stru
        inode->i_blocks  = attr->blocks;
        inode->i_atime.tv_sec   = attr->atime;
        inode->i_atime.tv_nsec  = attr->atimensec;
 -      inode->i_mtime.tv_sec   = attr->mtime;
 -      inode->i_mtime.tv_nsec  = attr->mtimensec;
 +      /* mtime from server may be stale due to local buffered write */
 +      if (!fc->writeback_cache || !S_ISREG(inode->i_mode)) {
 +              inode->i_mtime.tv_sec   = attr->mtime;
 +              inode->i_mtime.tv_nsec  = attr->mtimensec;
 +      }
        inode->i_ctime.tv_sec   = attr->ctime;
        inode->i_ctime.tv_nsec  = attr->ctimensec;
  
@@@ -200,7 -198,6 +201,7 @@@ void fuse_change_attributes(struct inod
  {
        struct fuse_conn *fc = get_fuse_conn(inode);
        struct fuse_inode *fi = get_fuse_inode(inode);
 +      bool is_wb = fc->writeback_cache;
        loff_t oldsize;
        struct timespec old_mtime;
  
        fuse_change_attributes_common(inode, attr, attr_valid);
  
        oldsize = inode->i_size;
 -      i_size_write(inode, attr->size);
 +      /*
 +       * In case of writeback_cache enabled, the cached writes beyond EOF
 +       * extend local i_size without keeping userspace server in sync. So,
 +       * attr->size coming from server can be stale. We cannot trust it.
 +       */
 +      if (!is_wb || !S_ISREG(inode->i_mode))
 +              i_size_write(inode, attr->size);
        spin_unlock(&fc->lock);
  
 -      if (S_ISREG(inode->i_mode)) {
 +      if (!is_wb && S_ISREG(inode->i_mode)) {
                bool inval = false;
  
                if (oldsize != attr->size) {
@@@ -253,8 -244,6 +254,8 @@@ static void fuse_init_inode(struct inod
  {
        inode->i_mode = attr->mode & S_IFMT;
        inode->i_size = attr->size;
 +      inode->i_mtime.tv_sec  = attr->mtime;
 +      inode->i_mtime.tv_nsec = attr->mtimensec;
        if (S_ISREG(inode->i_mode)) {
                fuse_init_common(inode);
                fuse_init_file_inode(inode);
@@@ -301,9 -290,7 +302,9 @@@ struct inode *fuse_iget(struct super_bl
                return NULL;
  
        if ((inode->i_state & I_NEW)) {
 -              inode->i_flags |= S_NOATIME|S_NOCMTIME;
 +              inode->i_flags |= S_NOATIME;
 +              if (!fc->writeback_cache || !S_ISREG(inode->i_mode))
 +                      inode->i_flags |= S_NOCMTIME;
                inode->i_generation = generation;
                inode->i_data.backing_dev_info = &fc->bdi;
                fuse_init_inode(inode, attr);
@@@ -887,8 -874,6 +888,8 @@@ static void process_init_reply(struct f
                        }
                        if (arg->flags & FUSE_ASYNC_DIO)
                                fc->async_dio = 1;
 +                      if (arg->flags & FUSE_WRITEBACK_CACHE)
 +                              fc->writeback_cache = 1;
                } else {
                        ra_pages = fc->max_read / PAGE_CACHE_SIZE;
                        fc->no_lock = 1;
@@@ -916,8 -901,7 +917,8 @@@ static void fuse_send_init(struct fuse_
                FUSE_EXPORT_SUPPORT | FUSE_BIG_WRITES | FUSE_DONT_MASK |
                FUSE_SPLICE_WRITE | FUSE_SPLICE_MOVE | FUSE_SPLICE_READ |
                FUSE_FLOCK_LOCKS | FUSE_IOCTL_DIR | FUSE_AUTO_INVAL_DATA |
 -              FUSE_DO_READDIRPLUS | FUSE_READDIRPLUS_AUTO | FUSE_ASYNC_DIO;
 +              FUSE_DO_READDIRPLUS | FUSE_READDIRPLUS_AUTO | FUSE_ASYNC_DIO |
 +              FUSE_WRITEBACK_CACHE;
        req->in.h.opcode = FUSE_INIT;
        req->in.numargs = 1;
        req->in.args[0].size = sizeof(*arg);
diff --combined fs/gfs2/super.c
index 033ee975a895d835fee0243d3d09ae3a418bf7d5,4c6dd50831baf51df3731b1bd388337620bb45d9..de8afad89e5103fe495a1e416bd0714e6e3762b4
@@@ -7,8 -7,6 +7,8 @@@
   * of the GNU General Public License version 2.
   */
  
 +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 +
  #include <linux/bio.h>
  #include <linux/sched.h>
  #include <linux/slab.h>
@@@ -177,7 -175,8 +177,7 @@@ int gfs2_mount_args(struct gfs2_args *a
                        break;
                case Opt_debug:
                        if (args->ar_errors == GFS2_ERRORS_PANIC) {
 -                              printk(KERN_WARNING "GFS2: -o debug and -o errors=panic "
 -                                     "are mutually exclusive.\n");
 +                              pr_warn("-o debug and -o errors=panic are mutually exclusive\n");
                                return -EINVAL;
                        }
                        args->ar_debug = 1;
                case Opt_commit:
                        rv = match_int(&tmp[0], &args->ar_commit);
                        if (rv || args->ar_commit <= 0) {
 -                              printk(KERN_WARNING "GFS2: commit mount option requires a positive numeric argument\n");
 +                              pr_warn("commit mount option requires a positive numeric argument\n");
                                return rv ? rv : -EINVAL;
                        }
                        break;
                case Opt_statfs_quantum:
                        rv = match_int(&tmp[0], &args->ar_statfs_quantum);
                        if (rv || args->ar_statfs_quantum < 0) {
 -                              printk(KERN_WARNING "GFS2: statfs_quantum mount option requires a non-negative numeric argument\n");
 +                              pr_warn("statfs_quantum mount option requires a non-negative numeric argument\n");
                                return rv ? rv : -EINVAL;
                        }
                        break;
                case Opt_quota_quantum:
                        rv = match_int(&tmp[0], &args->ar_quota_quantum);
                        if (rv || args->ar_quota_quantum <= 0) {
 -                              printk(KERN_WARNING "GFS2: quota_quantum mount option requires a positive numeric argument\n");
 +                              pr_warn("quota_quantum mount option requires a positive numeric argument\n");
                                return rv ? rv : -EINVAL;
                        }
                        break;
                        rv = match_int(&tmp[0], &args->ar_statfs_percent);
                        if (rv || args->ar_statfs_percent < 0 ||
                            args->ar_statfs_percent > 100) {
 -                              printk(KERN_WARNING "statfs_percent mount option requires a numeric argument between 0 and 100\n");
 +                              pr_warn("statfs_percent mount option requires a numeric argument between 0 and 100\n");
                                return rv ? rv : -EINVAL;
                        }
                        break;
                        break;
                case Opt_err_panic:
                        if (args->ar_debug) {
 -                              printk(KERN_WARNING "GFS2: -o debug and -o errors=panic "
 -                                      "are mutually exclusive.\n");
 +                              pr_warn("-o debug and -o errors=panic are mutually exclusive\n");
                                return -EINVAL;
                        }
                        args->ar_errors = GFS2_ERRORS_PANIC;
                        break;
                case Opt_error:
                default:
 -                      printk(KERN_WARNING "GFS2: invalid mount option: %s\n", o);
 +                      pr_warn("invalid mount option: %s\n", o);
                        return -EINVAL;
                }
        }
  
  void gfs2_jindex_free(struct gfs2_sbd *sdp)
  {
 -      struct list_head list, *head;
 +      struct list_head list;
        struct gfs2_jdesc *jd;
 -      struct gfs2_journal_extent *jext;
  
        spin_lock(&sdp->sd_jindex_spin);
        list_add(&list, &sdp->sd_jindex_list);
  
        while (!list_empty(&list)) {
                jd = list_entry(list.next, struct gfs2_jdesc, jd_list);
 -              head = &jd->extent_list;
 -              while (!list_empty(head)) {
 -                      jext = list_entry(head->next,
 -                                        struct gfs2_journal_extent,
 -                                        extent_list);
 -                      list_del(&jext->extent_list);
 -                      kfree(jext);
 -              }
 +              gfs2_free_journal_extents(jd);
                list_del(&jd->jd_list);
                iput(jd->jd_inode);
                kfree(jd);
@@@ -1167,6 -1175,8 +1167,8 @@@ static int gfs2_remount_fs(struct super
        struct gfs2_tune *gt = &sdp->sd_tune;
        int error;
  
+       sync_filesystem(sb);
        spin_lock(&gt->gt_spin);
        args.ar_commit = gt->gt_logd_secs;
        args.ar_quota_quantum = gt->gt_quota_quantum;
@@@ -1248,7 -1258,7 +1250,7 @@@ static int gfs2_drop_inode(struct inod
  {
        struct gfs2_inode *ip = GFS2_I(inode);
  
 -      if (inode->i_nlink) {
 +      if (!test_bit(GIF_FREE_VFS_INODE, &ip->i_flags) && inode->i_nlink) {
                struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
                if (gl && test_bit(GLF_DEMOTE, &gl->gl_flags))
                        clear_nlink(inode);
@@@ -1463,11 -1473,6 +1465,11 @@@ static void gfs2_evict_inode(struct ino
        struct gfs2_holder gh;
        int error;
  
 +      if (test_bit(GIF_FREE_VFS_INODE, &ip->i_flags)) {
 +              clear_inode(inode);
 +              return;
 +      }
 +
        if (inode->i_nlink || (sb->s_flags & MS_RDONLY))
                goto out;
  
@@@ -1555,7 -1560,7 +1557,7 @@@ out_unlock
                fs_warn(sdp, "gfs2_evict_inode: %d\n", error);
  out:
        /* Case 3 starts here */
 -      truncate_inode_pages(&inode->i_data, 0);
 +      truncate_inode_pages_final(&inode->i_data);
        gfs2_rs_delete(ip, NULL);
        gfs2_ordered_del_inode(ip);
        clear_inode(inode);
diff --combined fs/hfsplus/super.c
index a6abf87d79d0b4b6fb75e2cdfe15613e9def2c93,8eb787b52c058a607c10dca255232901d7a1a4de..a513d2d36be956c0a82314d786941ceb0b9f8990
@@@ -161,7 -161,7 +161,7 @@@ static int hfsplus_write_inode(struct i
  static void hfsplus_evict_inode(struct inode *inode)
  {
        hfs_dbg(INODE, "hfsplus_evict_inode: %lu\n", inode->i_ino);
 -      truncate_inode_pages(&inode->i_data, 0);
 +      truncate_inode_pages_final(&inode->i_data);
        clear_inode(inode);
        if (HFSPLUS_IS_RSRC(inode)) {
                HFSPLUS_I(HFSPLUS_I(inode)->rsrc_inode)->rsrc_inode = NULL;
@@@ -323,6 -323,7 +323,7 @@@ static int hfsplus_statfs(struct dentr
  
  static int hfsplus_remount(struct super_block *sb, int *flags, char *data)
  {
+       sync_filesystem(sb);
        if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
                return 0;
        if (!(*flags & MS_RDONLY)) {
diff --combined fs/inode.c
index fb59ba7967f1da210a22bcd2e2babe5ee2483f69,26f95ceb62502b0d923d2e95e9f14f4c8aa45f60..f96d2a6f88cca3a2e7c6e40bd122a7edeb43fc35
@@@ -503,7 -503,6 +503,7 @@@ void clear_inode(struct inode *inode
         */
        spin_lock_irq(&inode->i_data.tree_lock);
        BUG_ON(inode->i_data.nrpages);
 +      BUG_ON(inode->i_data.nrshadows);
        spin_unlock_irq(&inode->i_data.tree_lock);
        BUG_ON(!list_empty(&inode->i_data.private_list));
        BUG_ON(!(inode->i_state & I_FREEING));
@@@ -549,7 -548,8 +549,7 @@@ static void evict(struct inode *inode
        if (op->evict_inode) {
                op->evict_inode(inode);
        } else {
 -              if (inode->i_data.nrpages)
 -                      truncate_inode_pages(&inode->i_data, 0);
 +              truncate_inode_pages_final(&inode->i_data);
                clear_inode(inode);
        }
        if (S_ISBLK(inode->i_mode) && inode->i_bdev)
@@@ -944,22 -944,24 +944,22 @@@ EXPORT_SYMBOL(unlock_new_inode)
  
  /**
   * lock_two_nondirectories - take two i_mutexes on non-directory objects
 + *
 + * Lock any non-NULL argument that is not a directory.
 + * Zero, one or two objects may be locked by this function.
 + *
   * @inode1: first inode to lock
   * @inode2: second inode to lock
   */
  void lock_two_nondirectories(struct inode *inode1, struct inode *inode2)
  {
 -      WARN_ON_ONCE(S_ISDIR(inode1->i_mode));
 -      if (inode1 == inode2 || !inode2) {
 -              mutex_lock(&inode1->i_mutex);
 -              return;
 -      }
 -      WARN_ON_ONCE(S_ISDIR(inode2->i_mode));
 -      if (inode1 < inode2) {
 +      if (inode1 > inode2)
 +              swap(inode1, inode2);
 +
 +      if (inode1 && !S_ISDIR(inode1->i_mode))
                mutex_lock(&inode1->i_mutex);
 +      if (inode2 && !S_ISDIR(inode2->i_mode) && inode2 != inode1)
                mutex_lock_nested(&inode2->i_mutex, I_MUTEX_NONDIR2);
 -      } else {
 -              mutex_lock(&inode2->i_mutex);
 -              mutex_lock_nested(&inode1->i_mutex, I_MUTEX_NONDIR2);
 -      }
  }
  EXPORT_SYMBOL(lock_two_nondirectories);
  
   */
  void unlock_two_nondirectories(struct inode *inode1, struct inode *inode2)
  {
 -      mutex_unlock(&inode1->i_mutex);
 -      if (inode2 && inode2 != inode1)
 +      if (inode1 && !S_ISDIR(inode1->i_mode))
 +              mutex_unlock(&inode1->i_mutex);
 +      if (inode2 && !S_ISDIR(inode2->i_mode) && inode2 != inode1)
                mutex_unlock(&inode2->i_mutex);
  }
  EXPORT_SYMBOL(unlock_two_nondirectories);
@@@ -1898,3 -1899,34 +1898,34 @@@ void inode_dio_done(struct inode *inode
                wake_up_bit(&inode->i_state, __I_DIO_WAKEUP);
  }
  EXPORT_SYMBOL(inode_dio_done);
+ /*
+  * inode_set_flags - atomically set some inode flags
+  *
+  * Note: the caller should be holding i_mutex, or else be sure that
+  * they have exclusive access to the inode structure (i.e., while the
+  * inode is being instantiated).  The reason for the cmpxchg() loop
+  * --- which wouldn't be necessary if all code paths which modify
+  * i_flags actually followed this rule, is that there is at least one
+  * code path which doesn't today --- for example,
+  * __generic_file_aio_write() calls file_remove_suid() without holding
+  * i_mutex --- so we use cmpxchg() out of an abundance of caution.
+  *
+  * In the long run, i_mutex is overkill, and we should probably look
+  * at using the i_lock spinlock to protect i_flags, and then make sure
+  * it is so documented in include/linux/fs.h and that all code follows
+  * the locking convention!!
+  */
+ void inode_set_flags(struct inode *inode, unsigned int flags,
+                    unsigned int mask)
+ {
+       unsigned int old_flags, new_flags;
+       WARN_ON_ONCE(flags & ~mask);
+       do {
+               old_flags = ACCESS_ONCE(inode->i_flags);
+               new_flags = (old_flags & ~mask) | flags;
+       } while (unlikely(cmpxchg(&inode->i_flags, old_flags,
+                                 new_flags) != old_flags));
+ }
+ EXPORT_SYMBOL(inode_set_flags);
diff --combined fs/minix/inode.c
index 0ad2ec9601de1b2bfee9b1d4c202df6627f7f751,dcdc2989370df416a04ae7f6e20a1ba644a5470f..f007a3355570b38de89b57343407ccafad6cbe21
@@@ -26,7 -26,7 +26,7 @@@ static int minix_remount (struct super_
  
  static void minix_evict_inode(struct inode *inode)
  {
 -      truncate_inode_pages(&inode->i_data, 0);
 +      truncate_inode_pages_final(&inode->i_data);
        if (!inode->i_nlink) {
                inode->i_size = 0;
                minix_truncate(inode);
@@@ -86,7 -86,7 +86,7 @@@ static void init_once(void *foo
        inode_init_once(&ei->vfs_inode);
  }
  
 -static int init_inodecache(void)
 +static int __init init_inodecache(void)
  {
        minix_inode_cachep = kmem_cache_create("minix_inode_cache",
                                             sizeof(struct minix_inode_info),
@@@ -123,6 -123,7 +123,7 @@@ static int minix_remount (struct super_
        struct minix_sb_info * sbi = minix_sb(sb);
        struct minix_super_block * ms;
  
+       sync_filesystem(sb);
        ms = sbi->s_ms;
        if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
                return 0;
diff --combined fs/ncpfs/inode.c
index ee59d35ff069821bcc00160a0f104fada6865861,5f86e8080178893f7fe8ff2e1f2cfd7d2d51c406..647d86d2db395028a47eed98be3f5264b715e8cb
@@@ -99,6 -99,7 +99,7 @@@ static void destroy_inodecache(void
  
  static int ncp_remount(struct super_block *sb, int *flags, char* data)
  {
+       sync_filesystem(sb);
        *flags |= MS_NODIRATIME;
        return 0;
  }
@@@ -296,7 -297,7 +297,7 @@@ ncp_iget(struct super_block *sb, struc
  static void
  ncp_evict_inode(struct inode *inode)
  {
 -      truncate_inode_pages(&inode->i_data, 0);
 +      truncate_inode_pages_final(&inode->i_data);
        clear_inode(inode);
  
        if (S_ISDIR(inode->i_mode)) {
diff --combined fs/ocfs2/super.c
index 1aecd626e645a7cf6be82f8dbf062dd1232be072,5f9bf8f9dfa79e1cc2b60b890694d1c10e1bbe8b..a7cdd56f4c79baa4139807c3082d8e81507fbcdc
@@@ -561,9 -561,6 +561,9 @@@ static struct inode *ocfs2_alloc_inode(
        if (!oi)
                return NULL;
  
 +      oi->i_sync_tid = 0;
 +      oi->i_datasync_tid = 0;
 +
        jbd2_journal_init_jbd_inode(&oi->ip_jinode, &oi->vfs_inode);
        return &oi->vfs_inode;
  }
@@@ -634,6 -631,8 +634,8 @@@ static int ocfs2_remount(struct super_b
        struct ocfs2_super *osb = OCFS2_SB(sb);
        u32 tmp;
  
+       sync_filesystem(sb);
        if (!ocfs2_parse_options(sb, data, &parsed_options, 1) ||
            !ocfs2_check_set_options(sb, &parsed_options)) {
                ret = -EINVAL;
@@@ -1241,11 -1240,30 +1243,11 @@@ static struct dentry *ocfs2_mount(struc
        return mount_bdev(fs_type, flags, dev_name, data, ocfs2_fill_super);
  }
  
 -static void ocfs2_kill_sb(struct super_block *sb)
 -{
 -      struct ocfs2_super *osb = OCFS2_SB(sb);
 -
 -      /* Failed mount? */
 -      if (!osb || atomic_read(&osb->vol_state) == VOLUME_DISABLED)
 -              goto out;
 -
 -      /* Prevent further queueing of inode drop events */
 -      spin_lock(&dentry_list_lock);
 -      ocfs2_set_osb_flag(osb, OCFS2_OSB_DROP_DENTRY_LOCK_IMMED);
 -      spin_unlock(&dentry_list_lock);
 -      /* Wait for work to finish and/or remove it */
 -      cancel_work_sync(&osb->dentry_lock_work);
 -out:
 -      kill_block_super(sb);
 -}
 -
  static struct file_system_type ocfs2_fs_type = {
        .owner          = THIS_MODULE,
        .name           = "ocfs2",
        .mount          = ocfs2_mount,
 -      .kill_sb        = ocfs2_kill_sb,
 -
 +      .kill_sb        = kill_block_super,
        .fs_flags       = FS_REQUIRES_DEV|FS_RENAME_DOES_D_MOVE,
        .next           = NULL
  };
@@@ -1596,9 -1614,14 +1598,9 @@@ static int ocfs2_show_options(struct se
        return 0;
  }
  
 -wait_queue_head_t ocfs2__ioend_wq[OCFS2_IOEND_WQ_HASH_SZ];
 -
  static int __init ocfs2_init(void)
  {
 -      int status, i;
 -
 -      for (i = 0; i < OCFS2_IOEND_WQ_HASH_SZ; i++)
 -              init_waitqueue_head(&ocfs2__ioend_wq[i]);
 +      int status;
  
        status = init_ocfs2_uptodate_cache();
        if (status < 0)
@@@ -1740,7 -1763,7 +1742,7 @@@ static void ocfs2_inode_init_once(void 
        ocfs2_extent_map_init(&oi->vfs_inode);
        INIT_LIST_HEAD(&oi->ip_io_markers);
        oi->ip_dir_start_lookup = 0;
 -      atomic_set(&oi->ip_unaligned_aio, 0);
 +      mutex_init(&oi->ip_unaligned_aio);
        init_rwsem(&oi->ip_alloc_sem);
        init_rwsem(&oi->ip_xattr_sem);
        mutex_init(&oi->ip_io_mutex);
@@@ -1911,16 -1934,17 +1913,16 @@@ static void ocfs2_dismount_volume(struc
  
        debugfs_remove(osb->osb_ctxt);
  
 -      /*
 -       * Flush inode dropping work queue so that deletes are
 -       * performed while the filesystem is still working
 -       */
 -      ocfs2_drop_all_dl_inodes(osb);
 -
        /* Orphan scan should be stopped as early as possible */
        ocfs2_orphan_scan_stop(osb);
  
        ocfs2_disable_quotas(osb);
  
 +      /* All dquots should be freed by now */
 +      WARN_ON(!llist_empty(&osb->dquot_drop_list));
 +      /* Wait for worker to be done with the work structure in osb */
 +      cancel_work_sync(&osb->dquot_drop_work);
 +
        ocfs2_shutdown_local_alloc(osb);
  
        /* This will disable recovery and flush any recovery work. */
@@@ -2055,6 -2079,7 +2057,6 @@@ static int ocfs2_initialize_super(struc
        struct ocfs2_dinode *di = (struct ocfs2_dinode *)bh->b_data;
        struct inode *inode = NULL;
        struct ocfs2_journal *journal;
 -      __le32 uuid_net_key;
        struct ocfs2_super *osb;
        u64 total_blocks;
  
        spin_lock_init(&osb->osb_xattr_lock);
        ocfs2_init_steal_slots(osb);
  
 +      mutex_init(&osb->system_file_mutex);
 +
        atomic_set(&osb->alloc_stats.moves, 0);
        atomic_set(&osb->alloc_stats.local_data, 0);
        atomic_set(&osb->alloc_stats.bitmap_data, 0);
        INIT_WORK(&journal->j_recovery_work, ocfs2_complete_recovery);
        journal->j_state = OCFS2_JOURNAL_FREE;
  
 -      INIT_WORK(&osb->dentry_lock_work, ocfs2_drop_dl_inodes);
 -      osb->dentry_lock_list = NULL;
 +      INIT_WORK(&osb->dquot_drop_work, ocfs2_drop_dquot_refs);
 +      init_llist_head(&osb->dquot_drop_list);
  
        /* get some pseudo constants for clustersize bits */
        osb->s_clustersize_bits =
                goto bail;
        }
  
 -      memcpy(&uuid_net_key, di->id2.i_super.s_uuid, sizeof(uuid_net_key));
 -
        strncpy(osb->vol_label, di->id2.i_super.s_label, 63);
        osb->vol_label[63] = '\0';
        osb->root_blkno = le64_to_cpu(di->id2.i_super.s_root_blkno);
diff --combined fs/proc/root.c
index 7bbeb5257af166bb5a39f5cb02f5be481c779240,ac823a85cf6e5675b6ff3318784c6c8f9ea176ef..5dbadecb234da01be9cc7eb5705e71363da7dfea
@@@ -92,6 -92,8 +92,8 @@@ static int proc_parse_options(char *opt
  int proc_remount(struct super_block *sb, int *flags, char *data)
  {
        struct pid_namespace *pid = sb->s_fs_info;
+       sync_filesystem(sb);
        return !proc_parse_options(data, pid);
  }
  
@@@ -183,6 -185,9 +185,6 @@@ void __init proc_root_init(void
        proc_mkdir("openprom", NULL);
  #endif
        proc_tty_init();
 -#ifdef CONFIG_PROC_DEVICETREE
 -      proc_device_tree_init();
 -#endif
        proc_mkdir("bus", NULL);
        proc_sys_init();
  }
diff --combined fs/reiserfs/super.c
index ed54a04c33bd27dd33c5ea35f70a76cd22293be4,abf2b76c0d198768a0c0aef2e1eeb7241ab1beaa..9fb20426005e4ff3a0af37f675bdc4d5a29ffb84
@@@ -62,6 -62,7 +62,6 @@@ static int is_any_reiserfs_magic_string
  
  static int reiserfs_remount(struct super_block *s, int *flags, char *data);
  static int reiserfs_statfs(struct dentry *dentry, struct kstatfs *buf);
 -void show_alloc_options(struct seq_file *seq, struct super_block *s);
  
  static int reiserfs_sync_fs(struct super_block *s, int wait)
  {
@@@ -596,7 -597,7 +596,7 @@@ static void init_once(void *foo
        inode_init_once(&ei->vfs_inode);
  }
  
 -static int init_inodecache(void)
 +static int __init init_inodecache(void)
  {
        reiserfs_inode_cachep = kmem_cache_create("reiser_inode_cache",
                                                  sizeof(struct
@@@ -1318,6 -1319,7 +1318,7 @@@ static int reiserfs_remount(struct supe
        int i;
  #endif
  
+       sync_filesystem(s);
        reiserfs_write_lock(s);
  
  #ifdef CONFIG_QUOTA
diff --combined fs/sysv/inode.c
index 5625ca920f5eae1236a85b01557a577b96c3a146,4742e58f3fc520328a965b7a512fbcb3d0ec02a9..88956309cc86ab6d6d614315651ced6778647347
@@@ -60,6 -60,7 +60,7 @@@ static int sysv_remount(struct super_bl
  {
        struct sysv_sb_info *sbi = SYSV_SB(sb);
  
+       sync_filesystem(sb);
        if (sbi->s_forced_ro)
                *flags |= MS_RDONLY;
        return 0;
@@@ -295,7 -296,7 +296,7 @@@ int sysv_sync_inode(struct inode *inode
  
  static void sysv_evict_inode(struct inode *inode)
  {
 -      truncate_inode_pages(&inode->i_data, 0);
 +      truncate_inode_pages_final(&inode->i_data);
        if (!inode->i_nlink) {
                inode->i_size = 0;
                sysv_truncate(inode);
diff --combined fs/ubifs/super.c
index 48f943f7f5d5592737fdad71744834ce7b802af2,e1598abd74752c25fd12257eef3a1ba576893dda..a1266089eca1fc0054065dfc723e697daf5691e6
@@@ -351,7 -351,7 +351,7 @@@ static void ubifs_evict_inode(struct in
        dbg_gen("inode %lu, mode %#x", inode->i_ino, (int)inode->i_mode);
        ubifs_assert(!atomic_read(&inode->i_count));
  
 -      truncate_inode_pages(&inode->i_data, 0);
 +      truncate_inode_pages_final(&inode->i_data);
  
        if (inode->i_nlink)
                goto done;
@@@ -1827,6 -1827,7 +1827,7 @@@ static int ubifs_remount_fs(struct supe
        int err;
        struct ubifs_info *c = sb->s_fs_info;
  
+       sync_filesystem(sb);
        dbg_gen("old flags %#lx, new flags %#x", sb->s_flags, *flags);
  
        err = ubifs_parse_options(c, data, 1);
diff --combined fs/xfs/xfs_super.c
index 0ef5992189913a93f82ed7e83ef2aefffac64287,aaa3eca3f234ce72f6fadc74d3835a26c67c4314..2053767763773b60d7b7f8aca31f3b31a9219785
@@@ -913,7 -913,7 +913,7 @@@ xfs_flush_inodes
        struct super_block      *sb = mp->m_super;
  
        if (down_read_trylock(&sb->s_umount)) {
 -              sync_inodes_sb(sb, jiffies);
 +              sync_inodes_sb(sb);
                up_read(&sb->s_umount);
        }
  }
@@@ -996,7 -996,7 +996,7 @@@ xfs_fs_evict_inode
  
        trace_xfs_evict_inode(ip);
  
 -      truncate_inode_pages(&inode->i_data, 0);
 +      truncate_inode_pages_final(&inode->i_data);
        clear_inode(inode);
        XFS_STATS_INC(vn_rele);
        XFS_STATS_INC(vn_remove);
@@@ -1197,6 -1197,7 +1197,7 @@@ xfs_fs_remount
        char                    *p;
        int                     error;
  
+       sync_filesystem(sb);
        while ((p = strsep(&options, ",")) != NULL) {
                int token;
  
diff --combined include/linux/fs.h
index a877ed3f389f8a0f8b350019ee15c3ce1e7316dd,5d1f6fa8daedb9683f841634537f4dfc1ae1fc25..ea80f1cdff064b7c3bf330d186b9954a06985f9b
@@@ -123,9 -123,6 +123,9 @@@ typedef void (dio_iodone_t)(struct kioc
  /* File is opened with O_PATH; almost nothing can be done with it */
  #define FMODE_PATH            ((__force fmode_t)0x4000)
  
 +/* File needs atomic accesses to f_pos */
 +#define FMODE_ATOMIC_POS      ((__force fmode_t)0x8000)
 +
  /* File was opened by fanotify and shouldn't generate fanotify events */
  #define FMODE_NONOTIFY                ((__force fmode_t)0x1000000)
  
@@@ -419,7 -416,6 +419,7 @@@ struct address_space 
        struct mutex            i_mmap_mutex;   /* protect tree, count, list */
        /* Protected by tree_lock together with the radix tree */
        unsigned long           nrpages;        /* number of total pages */
 +      unsigned long           nrshadows;      /* number of shadow entries */
        pgoff_t                 writeback_index;/* writeback starts here */
        const struct address_space_operations *a_ops;   /* methods */
        unsigned long           flags;          /* error bits/gfp mask */
@@@ -590,9 -586,6 +590,9 @@@ struct inode 
        atomic_t                i_count;
        atomic_t                i_dio_count;
        atomic_t                i_writecount;
 +#ifdef CONFIG_IMA
 +      atomic_t                i_readcount; /* struct files open RO */
 +#endif
        const struct file_operations    *i_fop; /* former ->i_op->default_file_ops */
        struct file_lock        *i_flock;
        struct address_space    i_data;
        struct hlist_head       i_fsnotify_marks;
  #endif
  
 -#ifdef CONFIG_IMA
 -      atomic_t                i_readcount; /* struct files open RO */
 -#endif
        void                    *i_private; /* fs or device private pointer */
  };
  
@@@ -784,14 -780,13 +784,14 @@@ struct file 
        const struct file_operations    *f_op;
  
        /*
 -       * Protects f_ep_links, f_flags, f_pos vs i_size in lseek SEEK_CUR.
 +       * Protects f_ep_links, f_flags.
         * Must not be taken from IRQ context.
         */
        spinlock_t              f_lock;
        atomic_long_t           f_count;
        unsigned int            f_flags;
        fmode_t                 f_mode;
 +      struct mutex            f_pos_lock;
        loff_t                  f_pos;
        struct fown_struct      f_owner;
        const struct cred       *f_cred;
  #ifdef CONFIG_DEBUG_WRITECOUNT
        unsigned long f_mnt_write_state;
  #endif
 -};
 +} __attribute__((aligned(4)));        /* lest something weird decides that 2 is OK */
  
  struct file_handle {
        __u32 handle_bytes;
@@@ -893,7 -888,6 +893,7 @@@ static inline int file_check_writeable(
  #define FL_SLEEP      128     /* A blocking lock */
  #define FL_DOWNGRADE_PENDING  256 /* Lease is being downgraded */
  #define FL_UNLOCK_PENDING     512 /* Lease is being broken */
 +#define FL_FILE_PVT   1024    /* lock is private to the file */
  
  /*
   * Special return value from posix_lock_file() and vfs_lock_file() for
@@@ -998,12 -992,12 +998,12 @@@ struct file_lock 
  extern void send_sigio(struct fown_struct *fown, int fd, int band);
  
  #ifdef CONFIG_FILE_LOCKING
 -extern int fcntl_getlk(struct file *, struct flock __user *);
 +extern int fcntl_getlk(struct file *, unsigned int, struct flock __user *);
  extern int fcntl_setlk(unsigned int, struct file *, unsigned int,
                        struct flock __user *);
  
  #if BITS_PER_LONG == 32
 -extern int fcntl_getlk64(struct file *, struct flock64 __user *);
 +extern int fcntl_getlk64(struct file *, unsigned int, struct flock64 __user *);
  extern int fcntl_setlk64(unsigned int, struct file *, unsigned int,
                        struct flock64 __user *);
  #endif
@@@ -1018,7 -1012,7 +1018,7 @@@ extern struct file_lock * locks_alloc_l
  extern void locks_copy_lock(struct file_lock *, struct file_lock *);
  extern void __locks_copy_lock(struct file_lock *, const struct file_lock *);
  extern void locks_remove_posix(struct file *, fl_owner_t);
 -extern void locks_remove_flock(struct file *);
 +extern void locks_remove_file(struct file *);
  extern void locks_release_private(struct file_lock *);
  extern void posix_test_lock(struct file *, struct file_lock *);
  extern int posix_lock_file(struct file *, struct file_lock *, struct file_lock *);
@@@ -1036,8 -1030,7 +1036,8 @@@ extern int lease_modify(struct file_loc
  extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
  extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
  #else /* !CONFIG_FILE_LOCKING */
 -static inline int fcntl_getlk(struct file *file, struct flock __user *user)
 +static inline int fcntl_getlk(struct file *file, unsigned int cmd,
 +                            struct flock __user *user)
  {
        return -EINVAL;
  }
@@@ -1049,8 -1042,7 +1049,8 @@@ static inline int fcntl_setlk(unsigned 
  }
  
  #if BITS_PER_LONG == 32
 -static inline int fcntl_getlk64(struct file *file, struct flock64 __user *user)
 +static inline int fcntl_getlk64(struct file *file, unsigned int cmd,
 +                              struct flock64 __user *user)
  {
        return -EINVAL;
  }
@@@ -1091,7 -1083,7 +1091,7 @@@ static inline void locks_remove_posix(s
        return;
  }
  
 -static inline void locks_remove_flock(struct file *filp)
 +static inline void locks_remove_file(struct file *filp)
  {
        return;
  }
@@@ -1464,7 -1456,7 +1464,7 @@@ extern int vfs_symlink(struct inode *, 
  extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct inode **);
  extern int vfs_rmdir(struct inode *, struct dentry *);
  extern int vfs_unlink(struct inode *, struct dentry *, struct inode **);
 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *, struct inode **);
 +extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *, struct inode **, unsigned int);
  
  /*
   * VFS dentry helper functions.
@@@ -1575,8 -1567,6 +1575,8 @@@ struct inode_operations 
        int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t);
        int (*rename) (struct inode *, struct dentry *,
                        struct inode *, struct dentry *);
 +      int (*rename2) (struct inode *, struct dentry *,
 +                      struct inode *, struct dentry *, unsigned int);
        int (*setattr) (struct dentry *, struct iattr *);
        int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
        int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
@@@ -1919,11 -1909,6 +1919,11 @@@ extern int current_umask(void)
  extern void ihold(struct inode * inode);
  extern void iput(struct inode *);
  
 +static inline struct inode *file_inode(struct file *f)
 +{
 +      return f->f_inode;
 +}
 +
  /* /sys/fs */
  extern struct kobject *fs_kobj;
  
  #define FLOCK_VERIFY_WRITE 2
  
  #ifdef CONFIG_FILE_LOCKING
 -extern int locks_mandatory_locked(struct inode *);
 +extern int locks_mandatory_locked(struct file *);
  extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
  
  /*
@@@ -1956,10 -1941,10 +1956,10 @@@ static inline int mandatory_lock(struc
        return IS_MANDLOCK(ino) && __mandatory_lock(ino);
  }
  
 -static inline int locks_verify_locked(struct inode *inode)
 +static inline int locks_verify_locked(struct file *file)
  {
 -      if (mandatory_lock(inode))
 -              return locks_mandatory_locked(inode);
 +      if (mandatory_lock(file_inode(file)))
 +              return locks_mandatory_locked(file);
        return 0;
  }
  
@@@ -1979,12 -1964,6 +1979,12 @@@ static inline int locks_verify_truncate
  
  static inline int break_lease(struct inode *inode, unsigned int mode)
  {
 +      /*
 +       * Since this check is lockless, we must ensure that any refcounts
 +       * taken are done before checking inode->i_flock. Otherwise, we could
 +       * end up racing with tasks trying to set a new lease on this file.
 +       */
 +      smp_mb();
        if (inode->i_flock)
                return __break_lease(inode, mode, FL_LEASE);
        return 0;
@@@ -2020,7 -1999,7 +2020,7 @@@ static inline int break_deleg_wait(stru
  }
  
  #else /* !CONFIG_FILE_LOCKING */
 -static inline int locks_mandatory_locked(struct inode *inode)
 +static inline int locks_mandatory_locked(struct file *file)
  {
        return 0;
  }
@@@ -2042,7 -2021,7 +2042,7 @@@ static inline int mandatory_lock(struc
        return 0;
  }
  
 -static inline int locks_verify_locked(struct inode *inode)
 +static inline int locks_verify_locked(struct file *file)
  {
        return 0;
  }
@@@ -2314,6 -2293,11 +2314,6 @@@ extern int generic_permission(struct in
  static inline bool execute_ok(struct inode *inode)
  {
        return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode);
 -}
 -
 -static inline struct inode *file_inode(struct file *f)
 -{
 -      return f->f_inode;
  }
  
  static inline void file_start_write(struct file *file)
@@@ -2572,6 -2556,9 +2572,9 @@@ static inline ssize_t blockdev_direct_I
  void inode_dio_wait(struct inode *inode);
  void inode_dio_done(struct inode *inode);
  
+ extern void inode_set_flags(struct inode *inode, unsigned int flags,
+                           unsigned int mask);
  extern const struct file_operations generic_ro_fops;
  
  #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))