[Xenial][PATCH 0/9] Fix for CVE-2015-1350

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

[Xenial][PATCH 0/9] Fix for CVE-2015-1350

Khalid Elmously
The VFS subsystem in the Linux kernel 3.x provides an incomplete set of
requirements for setattr operations that underspecifies removing extended
privilege attributes, which allows local users to cause a denial of service
(capability stripping) via a failed invocation of a system call, as
demonstrated by using chown to remove a capability from the ping or
Wireshark dumpcap program.



Al Viro (1):
  ->getxattr(): pass dentry and inode as separate arguments

Andreas Gruenbacher (1):
  ceph: Get rid of d_find_alias in ceph_set_acl

Jan Kara (5):
  xfs: Propagate dentry down to inode_change_ok()
  ceph: Propagate dentry down to inode_change_ok()
  fuse: Propagate dentry down to inode_change_ok()
  fs: Give dentry to inode_change_ok() instead of inode
  fs: Avoid premature clearing of capabilities

Khalid Elmously (2):
  wrappers for ->i_mutex access
  xattr_handler: pass dentry and inode as separate arguments of ->get()

 Documentation/filesystems/porting                  | 10 ++-
 arch/powerpc/platforms/cell/spufs/file.c           |  4 +-
 arch/powerpc/platforms/cell/spufs/inode.c          | 12 +--
 arch/s390/hypfs/inode.c                            |  8 +-
 arch/x86/kernel/cpuid.c                            |  4 +-
 arch/x86/kernel/msr.c                              |  4 +-
 drivers/base/devtmpfs.c                            | 12 +--
 drivers/block/aoe/aoecmd.c                         |  4 +-
 drivers/block/drbd/drbd_debugfs.c                  |  4 +-
 drivers/char/mem.c                                 |  4 +-
 drivers/char/ps3flash.c                            |  4 +-
 drivers/infiniband/hw/qib/qib_fs.c                 | 12 +--
 drivers/mtd/ubi/cdev.c                             |  4 +-
 drivers/oprofile/oprofilefs.c                      | 16 ++--
 drivers/staging/lustre/lustre/llite/dir.c          |  4 +-
 drivers/staging/lustre/lustre/llite/file.c         | 16 ++--
 .../staging/lustre/lustre/llite/llite_internal.h   |  4 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c    |  6 +-
 drivers/staging/lustre/lustre/llite/llite_nfs.c    |  4 +-
 drivers/staging/lustre/lustre/llite/lloop.c        |  4 +-
 drivers/staging/lustre/lustre/llite/rw.c           |  4 +-
 drivers/staging/lustre/lustre/llite/rw26.c         |  4 +-
 drivers/staging/lustre/lustre/llite/vvp_io.c       |  4 +-
 drivers/staging/lustre/lustre/llite/vvp_page.c     | 10 +--
 drivers/staging/lustre/lustre/llite/xattr.c        |  6 +-
 drivers/staging/rdma/ipath/ipath_fs.c              |  8 +-
 drivers/usb/core/devices.c                         |  4 +-
 drivers/usb/core/devio.c                           |  4 +-
 drivers/usb/gadget/function/f_printer.c            |  4 +-
 drivers/usb/gadget/legacy/inode.c                  |  4 +-
 drivers/usb/gadget/udc/atmel_usba_udc.c            | 12 +--
 drivers/video/fbdev/core/fb_defio.c                |  4 +-
 fs/9p/acl.c                                        |  6 +-
 fs/9p/vfs_file.c                                   |  8 +-
 fs/9p/vfs_inode.c                                  |  2 +-
 fs/9p/vfs_inode_dotl.c                             |  2 +-
 fs/9p/xattr.c                                      |  4 +-
 fs/adfs/inode.c                                    |  2 +-
 fs/affs/file.c                                     |  8 +-
 fs/affs/inode.c                                    |  2 +-
 fs/afs/flock.c                                     |  4 +-
 fs/afs/write.c                                     |  4 +-
 fs/attr.c                                          | 37 ++++++---
 fs/aufs/cpup.c                                     | 22 +++---
 fs/aufs/dentry.c                                   |  8 +-
 fs/aufs/dir.c                                      |  4 +-
 fs/aufs/export.c                                   |  4 +-
 fs/aufs/f_op.c                                     | 16 ++--
 fs/aufs/hnotify.c                                  |  8 +-
 fs/aufs/i_op.c                                     | 18 ++---
 fs/aufs/i_op_add.c                                 |  4 +-
 fs/aufs/inode.h                                    |  6 +-
 fs/aufs/mvdown.c                                   |  8 +-
 fs/aufs/plink.c                                    |  4 +-
 fs/aufs/posix_acl.c                                |  4 +-
 fs/aufs/rdu.c                                      |  4 +-
 fs/aufs/super.c                                    |  8 +-
 fs/aufs/wbr_policy.c                               | 10 +--
 fs/aufs/whout.c                                    |  8 +-
 fs/aufs/xattr.c                                    | 14 ++--
 fs/aufs/xino.c                                     |  8 +-
 fs/bad_inode.c                                     |  4 +-
 fs/binfmt_misc.c                                   | 12 +--
 fs/block_dev.c                                     |  8 +-
 fs/btrfs/file.c                                    | 42 +++++-----
 fs/btrfs/inode.c                                   |  6 +-
 fs/btrfs/ioctl.c                                   | 38 ++++-----
 fs/btrfs/relocation.c                              |  4 +-
 fs/btrfs/scrub.c                                   |  4 +-
 fs/btrfs/xattr.c                                   |  8 +-
 fs/btrfs/xattr.h                                   |  4 +-
 fs/cachefiles/interface.c                          |  4 +-
 fs/cachefiles/namei.c                              | 40 +++++-----
 fs/ceph/acl.c                                      | 19 ++---
 fs/ceph/cache.c                                    |  4 +-
 fs/ceph/caps.c                                     |  4 +-
 fs/ceph/dir.c                                      |  4 +-
 fs/ceph/export.c                                   |  4 +-
 fs/ceph/file.c                                     | 18 ++---
 fs/ceph/inode.c                                    | 25 +++---
 fs/ceph/super.h                                    |  7 +-
 fs/ceph/xattr.c                                    | 36 ++++-----
 fs/cifs/cifsfs.c                                   |  4 +-
 fs/cifs/cifsfs.h                                   |  2 +-
 fs/cifs/file.c                                     | 12 +--
 fs/cifs/inode.c                                    |  4 +-
 fs/cifs/xattr.c                                    |  6 +-
 fs/coda/dir.c                                      |  4 +-
 fs/coda/file.c                                     |  8 +-
 fs/configfs/dir.c                                  | 54 ++++++-------
 fs/configfs/file.c                                 |  4 +-
 fs/configfs/inode.c                                |  4 +-
 fs/dax.c                                           |  6 +-
 fs/dcache.c                                        |  4 +-
 fs/debugfs/inode.c                                 | 22 +++---
 fs/devpts/inode.c                                  | 12 +--
 fs/direct-io.c                                     |  8 +-
 fs/ecryptfs/crypto.c                               |  5 +-
 fs/ecryptfs/ecryptfs_kernel.h                      |  4 +-
 fs/ecryptfs/inode.c                                | 53 +++++++------
 fs/ecryptfs/mmap.c                                 |  7 +-
 fs/efivarfs/file.c                                 |  8 +-
 fs/efivarfs/super.c                                |  4 +-
 fs/exec.c                                          |  4 +-
 fs/exofs/file.c                                    |  4 +-
 fs/exofs/inode.c                                   |  2 +-
 fs/exportfs/expfs.c                                | 12 +--
 fs/ext2/inode.c                                    |  2 +-
 fs/ext2/ioctl.c                                    | 12 +--
 fs/ext2/xattr_security.c                           |  6 +-
 fs/ext2/xattr_trusted.c                            |  6 +-
 fs/ext2/xattr_user.c                               |  8 +-
 fs/ext4/ext4.h                                     |  2 +-
 fs/ext4/extents.c                                  | 20 ++---
 fs/ext4/file.c                                     | 22 +++---
 fs/ext4/inode.c                                    | 14 ++--
 fs/ext4/ioctl.c                                    | 16 ++--
 fs/ext4/namei.c                                    |  4 +-
 fs/ext4/super.c                                    |  4 +-
 fs/ext4/xattr_security.c                           |  6 +-
 fs/ext4/xattr_trusted.c                            |  6 +-
 fs/ext4/xattr_user.c                               |  8 +-
 fs/f2fs/data.c                                     |  4 +-
 fs/f2fs/file.c                                     | 22 +++---
 fs/f2fs/xattr.c                                    | 14 ++--
 fs/fat/dir.c                                       |  4 +-
 fs/fat/file.c                                      | 10 +--
 fs/fuse/dir.c                                      | 22 +++---
 fs/fuse/file.c                                     | 34 ++++----
 fs/fuse/fuse_i.h                                   |  2 +-
 fs/gfs2/file.c                                     |  4 +-
 fs/gfs2/inode.c                                    | 15 ++--
 fs/gfs2/quota.c                                    |  8 +-
 fs/gfs2/xattr.c                                    |  6 +-
 fs/hfs/attr.c                                      |  5 +-
 fs/hfs/dir.c                                       |  4 +-
 fs/hfs/hfs_fs.h                                    |  4 +-
 fs/hfs/inode.c                                     | 10 +--
 fs/hfsplus/dir.c                                   |  4 +-
 fs/hfsplus/inode.c                                 | 10 +--
 fs/hfsplus/ioctl.c                                 |  4 +-
 fs/hfsplus/xattr.c                                 | 10 +--
 fs/hfsplus/xattr.h                                 |  2 +-
 fs/hfsplus/xattr_security.c                        |  6 +-
 fs/hfsplus/xattr_trusted.c                         |  6 +-
 fs/hfsplus/xattr_user.c                            |  6 +-
 fs/hostfs/hostfs_kern.c                            |  6 +-
 fs/hpfs/dir.c                                      |  6 +-
 fs/hpfs/inode.c                                    |  2 +-
 fs/hugetlbfs/inode.c                               | 14 ++--
 fs/inode.c                                         |  8 +-
 fs/ioctl.c                                         |  4 +-
 fs/jffs2/file.c                                    |  4 +-
 fs/jffs2/fs.c                                      |  2 +-
 fs/jffs2/security.c                                |  6 +-
 fs/jffs2/xattr_trusted.c                           |  6 +-
 fs/jffs2/xattr_user.c                              |  6 +-
 fs/jfs/file.c                                      |  8 +-
 fs/jfs/ioctl.c                                     |  6 +-
 fs/jfs/jfs_xattr.h                                 |  2 +-
 fs/jfs/super.c                                     |  6 +-
 fs/jfs/xattr.c                                     |  8 +-
 fs/kernfs/dir.c                                    |  4 +-
 fs/kernfs/inode.c                                  |  8 +-
 fs/kernfs/kernfs-internal.h                        |  4 +-
 fs/kernfs/mount.c                                  |  4 +-
 fs/libfs.c                                         | 16 ++--
 fs/locks.c                                         |  6 +-
 fs/logfs/file.c                                    | 10 +--
 fs/minix/file.c                                    |  2 +-
 fs/namei.c                                         | 70 ++++++++--------
 fs/namespace.c                                     | 10 +--
 fs/ncpfs/dir.c                                     |  8 +-
 fs/ncpfs/file.c                                    |  4 +-
 fs/ncpfs/inode.c                                   |  2 +-
 fs/nfs/dir.c                                       |  8 +-
 fs/nfs/direct.c                                    | 12 +--
 fs/nfs/file.c                                      |  4 +-
 fs/nfs/inode.c                                     |  8 +-
 fs/nfs/nfs42proc.c                                 |  8 +-
 fs/nfs/nfs4file.c                                  | 24 +++---
 fs/nfs/nfs4proc.c                                  | 12 +--
 fs/nfsd/nfs4proc.c                                 |  4 +-
 fs/nfsd/nfs4recover.c                              | 12 +--
 fs/nfsd/nfsfh.h                                    |  4 +-
 fs/nfsd/nfsproc.c                                  |  8 +-
 fs/nfsd/vfs.c                                      |  6 +-
 fs/nilfs2/inode.c                                  |  6 +-
 fs/nilfs2/ioctl.c                                  |  4 +-
 fs/ntfs/dir.c                                      |  4 +-
 fs/ntfs/file.c                                     |  8 +-
 fs/ntfs/inode.c                                    |  2 +-
 fs/ntfs/quota.c                                    |  6 +-
 fs/ntfs/super.c                                    | 12 +--
 fs/ocfs2/alloc.c                                   | 32 ++++----
 fs/ocfs2/aops.c                                    |  4 +-
 fs/ocfs2/dir.c                                     |  4 +-
 fs/ocfs2/dlmfs/dlmfs.c                             |  2 +-
 fs/ocfs2/file.c                                    | 14 ++--
 fs/ocfs2/inode.c                                   | 12 +--
 fs/ocfs2/ioctl.c                                   | 12 +--
 fs/ocfs2/journal.c                                 |  8 +-
 fs/ocfs2/localalloc.c                              | 16 ++--
 fs/ocfs2/move_extents.c                            | 16 ++--
 fs/ocfs2/namei.c                                   | 28 +++----
 fs/ocfs2/quota_global.c                            |  4 +-
 fs/ocfs2/refcounttree.c                            | 12 +--
 fs/ocfs2/resize.c                                  |  8 +-
 fs/ocfs2/suballoc.c                                | 12 +--
 fs/ocfs2/xattr.c                                   | 34 ++++----
 fs/omfs/file.c                                     |  2 +-
 fs/open.c                                          | 12 +--
 fs/overlayfs/copy_up.c                             |  4 +-
 fs/overlayfs/dir.c                                 | 16 ++--
 fs/overlayfs/inode.c                               | 10 +--
 fs/overlayfs/overlayfs.h                           | 12 +--
 fs/overlayfs/readdir.c                             | 20 ++---
 fs/overlayfs/super.c                               | 21 ++---
 fs/posix_acl.c                                     | 12 +--
 fs/proc/base.c                                     |  2 +-
 fs/proc/generic.c                                  |  2 +-
 fs/proc/kcore.c                                    |  4 +-
 fs/proc/proc_sysctl.c                              |  2 +-
 fs/proc/self.c                                     |  4 +-
 fs/proc/thread_self.c                              |  4 +-
 fs/pstore/inode.c                                  |  6 +-
 fs/quota/dquot.c                                   | 20 ++---
 fs/ramfs/file-nommu.c                              |  2 +-
 fs/read_write.c                                    |  4 +-
 fs/readdir.c                                       |  2 +-
 fs/reiserfs/dir.c                                  |  4 +-
 fs/reiserfs/file.c                                 |  4 +-
 fs/reiserfs/inode.c                                |  2 +-
 fs/reiserfs/ioctl.c                                |  2 +-
 fs/reiserfs/xattr.c                                | 64 +++++++--------
 fs/reiserfs/xattr_security.c                       |  9 +--
 fs/reiserfs/xattr_trusted.c                        |  9 +--
 fs/reiserfs/xattr_user.c                           |  9 +--
 fs/squashfs/xattr.c                                |  6 +-
 fs/sysv/file.c                                     |  2 +-
 fs/tracefs/inode.c                                 | 34 ++++----
 fs/ubifs/dir.c                                     | 18 ++---
 fs/ubifs/file.c                                    |  6 +-
 fs/ubifs/ubifs.h                                   |  4 +-
 fs/ubifs/xattr.c                                   | 10 +--
 fs/udf/file.c                                      | 12 +--
 fs/udf/inode.c                                     |  2 +-
 fs/ufs/inode.c                                     |  2 +-
 fs/utimes.c                                        |  6 +-
 fs/xattr.c                                         | 19 ++---
 fs/xfs/xfs_file.c                                  |  8 +-
 fs/xfs/xfs_inode.c                                 |  2 +-
 fs/xfs/xfs_ioctl.c                                 |  2 +-
 fs/xfs/xfs_iops.c                                  | 92 ++++++++++++++--------
 fs/xfs/xfs_iops.h                                  |  3 +-
 fs/xfs/xfs_pnfs.c                                  |  4 +-
 fs/xfs/xfs_xattr.c                                 |  6 +-
 include/linux/fs.h                                 |  5 +-
 include/linux/xattr.h                              |  5 +-
 ipc/mqueue.c                                       |  8 +-
 kernel/audit_fsnotify.c                            |  2 +-
 kernel/audit_watch.c                               |  2 +-
 kernel/events/core.c                               |  4 +-
 kernel/relay.c                                     |  4 +-
 kernel/sched/core.c                                |  4 +-
 mm/filemap.c                                       |  4 +-
 mm/shmem.c                                         | 16 ++--
 mm/swapfile.c                                      | 12 +--
 net/socket.c                                       |  2 +-
 net/sunrpc/cache.c                                 | 10 +--
 net/sunrpc/rpc_pipe.c                              | 60 +++++++-------
 security/commoncap.c                               |  6 +-
 security/inode.c                                   | 10 +--
 security/integrity/evm/evm_main.c                  |  2 +-
 security/integrity/ima/ima_main.c                  |  8 +-
 security/selinux/hooks.c                           |  9 ++-
 security/selinux/selinuxfs.c                       |  4 +-
 security/smack/smack_lsm.c                         |  4 +-
 spl/include/linux/file_compat.h                    |  4 +-
 zfs/config/kernel-xattr-handler.m4                 |  2 +-
 zfs/include/linux/xattr_compat.h                   |  4 +-
 zfs/module/zfs/zpl_inode.c                         |  2 +-
 282 files changed, 1352 insertions(+), 1304 deletions(-)

--
2.14.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[Xenial][PATCH 1/9] xfs: Propagate dentry down to inode_change_ok()

Khalid Elmously
BugLink: https://bugs.launchpad.net/bugs/1415636

commit 69bca80744eef58fa155e8042996b968fec17b2 upstream.

To avoid clearing of capabilities or security related extended
attributes too early, inode_change_ok() will need to take dentry instead
of inode. Propagate dentry down to functions calling inode_change_ok().
This is rather straightforward except for xfs_set_mode() function which
does not have dentry easily available. Luckily that function does not
call inode_change_ok() anyway so we just have to do a little dance with
function prototypes.

Acked-by: Dave Chinner <[hidden email]>
Reviewed-by: Christoph Hellwig <[hidden email]>
Signed-off-by: Jan Kara <[hidden email]>
Signed-off-by: Khalid Elmously <[hidden email]>
---
 fs/xfs/xfs_file.c  |  2 +-
 fs/xfs/xfs_inode.c |  2 +-
 fs/xfs/xfs_ioctl.c |  2 +-
 fs/xfs/xfs_iops.c  | 94 ++++++++++++++++++++++++++++++++++++------------------
 fs/xfs/xfs_iops.h  |  3 +-
 5 files changed, 68 insertions(+), 35 deletions(-)

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 3dd47307363f..b40f34e8c9bf 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -1022,7 +1022,7 @@ xfs_file_fallocate(
 
  iattr.ia_valid = ATTR_SIZE;
  iattr.ia_size = new_size;
- error = xfs_setattr_size(ip, &iattr);
+ error = xfs_vn_setattr_size(file_dentry(file), &iattr);
  if (error)
  goto out_unlock;
  }
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index f0ce28cd311d..918692b1e9f2 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1738,7 +1738,7 @@ xfs_inactive_truncate(
  /*
  * Log the inode size first to prevent stale data exposure in the event
  * of a system crash before the truncate completes. See the related
- * comment in xfs_setattr_size() for details.
+ * comment in xfs_vn_setattr_size() for details.
  */
  ip->i_d.di_size = 0;
  xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index e4a4f82ea13f..2e16bed464bf 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -737,7 +737,7 @@ xfs_ioc_space(
  iattr.ia_valid = ATTR_SIZE;
  iattr.ia_size = bf->l_start;
 
- error = xfs_setattr_size(ip, &iattr);
+ error = xfs_vn_setattr_size(file_dentry(filp), &iattr);
  break;
  default:
  ASSERT(0);
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 245268a0cdf0..01511afe266a 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -534,6 +534,30 @@ xfs_setattr_time(
  }
 }
 
+static int
+xfs_vn_change_ok(
+ struct dentry *dentry,
+ struct iattr *iattr)
+{
+ struct inode *inode = d_inode(dentry);
+ struct xfs_inode *ip = XFS_I(inode);
+ struct xfs_mount *mp = ip->i_mount;
+
+ if (mp->m_flags & XFS_MOUNT_RDONLY)
+ return -EROFS;
+
+ if (XFS_FORCED_SHUTDOWN(mp))
+ return -EIO;
+
+ return inode_change_ok(inode, iattr);
+}
+
+/*
+ * Set non-size attributes of an inode.
+ *
+ * Caution: The caller of this function is responsible for calling
+ * inode_change_ok() or otherwise verifying the change is fine.
+ */
 int
 xfs_setattr_nonsize(
  struct xfs_inode *ip,
@@ -550,21 +574,6 @@ xfs_setattr_nonsize(
  struct xfs_dquot *udqp = NULL, *gdqp = NULL;
  struct xfs_dquot *olddquot1 = NULL, *olddquot2 = NULL;
 
- trace_xfs_setattr(ip);
-
- /* If acls are being inherited, we already have this checked */
- if (!(flags & XFS_ATTR_NOACL)) {
- if (mp->m_flags & XFS_MOUNT_RDONLY)
- return -EROFS;
-
- if (XFS_FORCED_SHUTDOWN(mp))
- return -EIO;
-
- error = inode_change_ok(inode, iattr);
- if (error)
- return error;
- }
-
  ASSERT((mask & ATTR_SIZE) == 0);
 
  /*
@@ -738,8 +747,27 @@ out_trans_cancel:
  return error;
 }
 
+int
+xfs_vn_setattr_nonsize(
+ struct dentry *dentry,
+ struct iattr *iattr)
+{
+ struct xfs_inode *ip = XFS_I(d_inode(dentry));
+ int error;
+
+ trace_xfs_setattr(ip);
+
+ error = xfs_vn_change_ok(dentry, iattr);
+ if (error)
+ return error;
+ return xfs_setattr_nonsize(ip, iattr, 0);
+}
+
 /*
  * Truncate file.  Must have write permission and not be a directory.
+ *
+ * Caution: The caller of this function is responsible for calling
+ * inode_change_ok() or otherwise verifying the change is fine.
  */
 int
 xfs_setattr_size(
@@ -754,18 +782,6 @@ xfs_setattr_size(
  uint lock_flags = 0;
  bool did_zeroing = false;
 
- trace_xfs_setattr(ip);
-
- if (mp->m_flags & XFS_MOUNT_RDONLY)
- return -EROFS;
-
- if (XFS_FORCED_SHUTDOWN(mp))
- return -EIO;
-
- error = inode_change_ok(inode, iattr);
- if (error)
- return error;
-
  ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL));
  ASSERT(xfs_isilocked(ip, XFS_MMAPLOCK_EXCL));
  ASSERT(S_ISREG(ip->i_d.di_mode));
@@ -938,16 +954,32 @@ out_trans_cancel:
  goto out_unlock;
 }
 
+int
+xfs_vn_setattr_size(
+ struct dentry *dentry,
+ struct iattr *iattr)
+{
+ struct xfs_inode *ip = XFS_I(d_inode(dentry));
+ int error;
+
+ trace_xfs_setattr(ip);
+
+ error = xfs_vn_change_ok(dentry, iattr);
+ if (error)
+ return error;
+ return xfs_setattr_size(ip, iattr);
+}
+
 STATIC int
 xfs_vn_setattr(
  struct dentry *dentry,
  struct iattr *iattr)
 {
- struct xfs_inode *ip = XFS_I(d_inode(dentry));
  int error;
 
  if (iattr->ia_valid & ATTR_SIZE) {
- uint iolock = XFS_IOLOCK_EXCL;
+ struct xfs_inode *ip = XFS_I(d_inode(dentry));
+ uint iolock = XFS_IOLOCK_EXCL;
 
  xfs_ilock(ip, iolock);
  error = xfs_break_layouts(d_inode(dentry), &iolock, true);
@@ -955,11 +987,11 @@ xfs_vn_setattr(
  xfs_ilock(ip, XFS_MMAPLOCK_EXCL);
  iolock |= XFS_MMAPLOCK_EXCL;
 
- error = xfs_setattr_size(ip, iattr);
+ error = xfs_vn_setattr_size(dentry, iattr);
  }
  xfs_iunlock(ip, iolock);
  } else {
- error = xfs_setattr_nonsize(ip, iattr, 0);
+ error = xfs_vn_setattr_nonsize(dentry, iattr);
  }
 
  return error;
diff --git a/fs/xfs/xfs_iops.h b/fs/xfs/xfs_iops.h
index a0f84abb0d09..0259a383721a 100644
--- a/fs/xfs/xfs_iops.h
+++ b/fs/xfs/xfs_iops.h
@@ -33,6 +33,7 @@ extern ssize_t xfs_vn_listxattr(struct dentry *, char *data, size_t size);
 extern void xfs_setattr_time(struct xfs_inode *ip, struct iattr *iattr);
 extern int xfs_setattr_nonsize(struct xfs_inode *ip, struct iattr *vap,
        int flags);
-extern int xfs_setattr_size(struct xfs_inode *ip, struct iattr *vap);
+extern int xfs_vn_setattr_nonsize(struct dentry *dentry, struct iattr *vap);
+extern int xfs_vn_setattr_size(struct dentry *dentry, struct iattr *vap);
 
 #endif /* __XFS_IOPS_H__ */
--
2.14.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[Xenial][PATCH 2/9] wrappers for ->i_mutex access

Khalid Elmously
In reply to this post by Khalid Elmously
BugLink: http://bugs.launchpad.net/bugs/1415636

commit 5955102c9984fa081b2d570cfac75c97eecf8f3b upstream.

5955102c9984fa081b2d570cfac75c97eecf8f3b was only partially implemented before this - this is the rest of the change

Signed-off-by: Khalid Elmously <[hidden email]>
---
 arch/powerpc/platforms/cell/spufs/file.c        |  4 +-
 arch/powerpc/platforms/cell/spufs/inode.c       | 12 ++---
 arch/s390/hypfs/inode.c                         |  8 +--
 arch/x86/kernel/cpuid.c                         |  4 +-
 arch/x86/kernel/msr.c                           |  4 +-
 drivers/base/devtmpfs.c                         | 12 ++---
 drivers/block/aoe/aoecmd.c                      |  4 +-
 drivers/block/drbd/drbd_debugfs.c               |  4 +-
 drivers/char/mem.c                              |  4 +-
 drivers/char/ps3flash.c                         |  4 +-
 drivers/infiniband/hw/qib/qib_fs.c              | 12 ++---
 drivers/mtd/ubi/cdev.c                          |  4 +-
 drivers/oprofile/oprofilefs.c                   | 16 +++---
 drivers/staging/lustre/lustre/llite/dir.c       |  4 +-
 drivers/staging/lustre/lustre/llite/file.c      | 16 +++---
 drivers/staging/lustre/lustre/llite/llite_lib.c |  4 +-
 drivers/staging/lustre/lustre/llite/llite_nfs.c |  4 +-
 drivers/staging/lustre/lustre/llite/lloop.c     |  4 +-
 drivers/staging/lustre/lustre/llite/rw.c        |  4 +-
 drivers/staging/lustre/lustre/llite/rw26.c      |  4 +-
 drivers/staging/lustre/lustre/llite/vvp_io.c    |  4 +-
 drivers/staging/lustre/lustre/llite/vvp_page.c  | 10 ++--
 drivers/staging/rdma/ipath/ipath_fs.c           |  8 +--
 drivers/usb/core/devices.c                      |  4 +-
 drivers/usb/core/devio.c                        |  4 +-
 drivers/usb/gadget/function/f_printer.c         |  4 +-
 drivers/usb/gadget/legacy/inode.c               |  4 +-
 drivers/usb/gadget/udc/atmel_usba_udc.c         | 12 ++---
 drivers/video/fbdev/core/fb_defio.c             |  4 +-
 fs/9p/vfs_file.c                                |  8 +--
 fs/affs/file.c                                  |  8 +--
 fs/afs/flock.c                                  |  4 +-
 fs/afs/write.c                                  |  4 +-
 fs/attr.c                                       |  2 +-
 fs/aufs/cpup.c                                  | 22 ++++----
 fs/aufs/dentry.c                                |  8 +--
 fs/aufs/dir.c                                   |  4 +-
 fs/aufs/export.c                                |  4 +-
 fs/aufs/f_op.c                                  | 16 +++---
 fs/aufs/hnotify.c                               |  8 +--
 fs/aufs/i_op.c                                  | 18 +++----
 fs/aufs/i_op_add.c                              |  4 +-
 fs/aufs/inode.h                                 |  6 +--
 fs/aufs/mvdown.c                                |  8 +--
 fs/aufs/plink.c                                 |  4 +-
 fs/aufs/posix_acl.c                             |  4 +-
 fs/aufs/rdu.c                                   |  4 +-
 fs/aufs/super.c                                 |  8 +--
 fs/aufs/wbr_policy.c                            | 10 ++--
 fs/aufs/whout.c                                 |  8 +--
 fs/aufs/xattr.c                                 | 14 ++---
 fs/aufs/xino.c                                  |  8 +--
 fs/binfmt_misc.c                                | 12 ++---
 fs/block_dev.c                                  |  8 +--
 fs/btrfs/file.c                                 | 42 +++++++--------
 fs/btrfs/inode.c                                |  4 +-
 fs/btrfs/ioctl.c                                | 38 +++++++-------
 fs/btrfs/relocation.c                           |  4 +-
 fs/btrfs/scrub.c                                |  4 +-
 fs/btrfs/xattr.c                                |  2 +-
 fs/cachefiles/interface.c                       |  4 +-
 fs/cachefiles/namei.c                           | 40 +++++++-------
 fs/ceph/cache.c                                 |  4 +-
 fs/ceph/caps.c                                  |  4 +-
 fs/ceph/dir.c                                   |  4 +-
 fs/ceph/export.c                                |  4 +-
 fs/ceph/file.c                                  | 18 +++----
 fs/cifs/cifsfs.c                                |  4 +-
 fs/cifs/file.c                                  | 12 ++---
 fs/coda/dir.c                                   |  4 +-
 fs/coda/file.c                                  |  8 +--
 fs/configfs/dir.c                               | 54 +++++++++----------
 fs/configfs/file.c                              |  4 +-
 fs/configfs/inode.c                             |  4 +-
 fs/dax.c                                        |  6 +--
 fs/dcache.c                                     |  4 +-
 fs/debugfs/inode.c                              | 22 ++++----
 fs/devpts/inode.c                               | 12 ++---
 fs/direct-io.c                                  |  8 +--
 fs/ecryptfs/inode.c                             | 32 +++++------
 fs/ecryptfs/mmap.c                              |  4 +-
 fs/efivarfs/file.c                              |  8 +--
 fs/efivarfs/super.c                             |  4 +-
 fs/exec.c                                       |  4 +-
 fs/exofs/file.c                                 |  4 +-
 fs/exportfs/expfs.c                             | 12 ++---
 fs/ext2/ioctl.c                                 | 12 ++---
 fs/ext4/ext4.h                                  |  2 +-
 fs/ext4/extents.c                               | 20 +++----
 fs/ext4/file.c                                  | 22 ++++----
 fs/ext4/inode.c                                 | 12 ++---
 fs/ext4/ioctl.c                                 | 16 +++---
 fs/ext4/namei.c                                 |  4 +-
 fs/ext4/super.c                                 |  4 +-
 fs/f2fs/data.c                                  |  4 +-
 fs/f2fs/file.c                                  | 20 +++----
 fs/fat/dir.c                                    |  4 +-
 fs/fat/file.c                                   |  8 +--
 fs/fuse/dir.c                                   | 10 ++--
 fs/fuse/file.c                                  | 32 +++++------
 fs/gfs2/file.c                                  |  4 +-
 fs/gfs2/inode.c                                 |  4 +-
 fs/gfs2/quota.c                                 |  8 +--
 fs/hfs/dir.c                                    |  4 +-
 fs/hfs/inode.c                                  |  8 +--
 fs/hfsplus/dir.c                                |  4 +-
 fs/hfsplus/inode.c                              |  8 +--
 fs/hfsplus/ioctl.c                              |  4 +-
 fs/hostfs/hostfs_kern.c                         |  4 +-
 fs/hpfs/dir.c                                   |  6 +--
 fs/hugetlbfs/inode.c                            | 12 ++---
 fs/inode.c                                      |  8 +--
 fs/ioctl.c                                      |  4 +-
 fs/jffs2/file.c                                 |  4 +-
 fs/jfs/file.c                                   |  6 +--
 fs/jfs/ioctl.c                                  |  6 +--
 fs/jfs/super.c                                  |  6 +--
 fs/kernfs/dir.c                                 |  4 +-
 fs/kernfs/mount.c                               |  4 +-
 fs/libfs.c                                      | 10 ++--
 fs/locks.c                                      |  6 +--
 fs/logfs/file.c                                 |  8 +--
 fs/namei.c                                      | 70 ++++++++++++-------------
 fs/namespace.c                                  | 10 ++--
 fs/ncpfs/dir.c                                  |  8 +--
 fs/ncpfs/file.c                                 |  4 +-
 fs/nfs/dir.c                                    |  8 +--
 fs/nfs/direct.c                                 | 12 ++---
 fs/nfs/file.c                                   |  4 +-
 fs/nfs/inode.c                                  |  8 +--
 fs/nfs/nfs42proc.c                              |  8 +--
 fs/nfs/nfs4file.c                               | 24 ++++-----
 fs/nfsd/nfs4proc.c                              |  4 +-
 fs/nfsd/nfs4recover.c                           | 12 ++---
 fs/nfsd/nfsfh.h                                 |  4 +-
 fs/nfsd/vfs.c                                   |  6 +--
 fs/nilfs2/inode.c                               |  4 +-
 fs/nilfs2/ioctl.c                               |  4 +-
 fs/ntfs/dir.c                                   |  4 +-
 fs/ntfs/file.c                                  |  8 +--
 fs/ntfs/quota.c                                 |  6 +--
 fs/ntfs/super.c                                 | 12 ++---
 fs/ocfs2/alloc.c                                | 32 +++++------
 fs/ocfs2/aops.c                                 |  4 +-
 fs/ocfs2/dir.c                                  |  4 +-
 fs/ocfs2/file.c                                 | 12 ++---
 fs/ocfs2/inode.c                                | 12 ++---
 fs/ocfs2/ioctl.c                                | 12 ++---
 fs/ocfs2/journal.c                              |  8 +--
 fs/ocfs2/localalloc.c                           | 16 +++---
 fs/ocfs2/move_extents.c                         | 16 +++---
 fs/ocfs2/namei.c                                | 28 +++++-----
 fs/ocfs2/quota_global.c                         |  4 +-
 fs/ocfs2/refcounttree.c                         | 12 ++---
 fs/ocfs2/resize.c                               |  8 +--
 fs/ocfs2/suballoc.c                             | 12 ++---
 fs/ocfs2/xattr.c                                | 14 ++---
 fs/open.c                                       | 12 ++---
 fs/overlayfs/copy_up.c                          |  4 +-
 fs/overlayfs/dir.c                              | 16 +++---
 fs/overlayfs/inode.c                            |  4 +-
 fs/overlayfs/overlayfs.h                        |  8 +--
 fs/overlayfs/readdir.c                          | 20 +++----
 fs/overlayfs/super.c                            | 14 ++---
 fs/proc/kcore.c                                 |  4 +-
 fs/proc/self.c                                  |  4 +-
 fs/proc/thread_self.c                           |  4 +-
 fs/pstore/inode.c                               |  6 +--
 fs/quota/dquot.c                                | 20 +++----
 fs/read_write.c                                 |  4 +-
 fs/readdir.c                                    |  2 +-
 fs/reiserfs/dir.c                               |  4 +-
 fs/reiserfs/file.c                              |  4 +-
 fs/reiserfs/ioctl.c                             |  2 +-
 fs/reiserfs/xattr.c                             | 64 +++++++++++-----------
 fs/tracefs/inode.c                              | 34 ++++++------
 fs/ubifs/dir.c                                  | 18 +++----
 fs/ubifs/file.c                                 |  4 +-
 fs/ubifs/xattr.c                                |  4 +-
 fs/udf/file.c                                   | 10 ++--
 fs/udf/inode.c                                  |  2 +-
 fs/utimes.c                                     |  4 +-
 fs/xattr.c                                      |  8 +--
 fs/xfs/xfs_file.c                               |  6 +--
 fs/xfs/xfs_pnfs.c                               |  4 +-
 ipc/mqueue.c                                    |  8 +--
 kernel/audit_fsnotify.c                         |  2 +-
 kernel/audit_watch.c                            |  2 +-
 kernel/events/core.c                            |  4 +-
 kernel/relay.c                                  |  4 +-
 kernel/sched/core.c                             |  4 +-
 mm/filemap.c                                    |  4 +-
 mm/shmem.c                                      | 12 ++---
 mm/swapfile.c                                   | 12 ++---
 net/sunrpc/cache.c                              | 10 ++--
 net/sunrpc/rpc_pipe.c                           | 60 ++++++++++-----------
 security/inode.c                                | 10 ++--
 security/integrity/ima/ima_main.c               |  8 +--
 security/selinux/selinuxfs.c                    |  4 +-
 spl/include/linux/file_compat.h                 |  4 +-
 200 files changed, 963 insertions(+), 963 deletions(-)

diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index 5038fd578e65..2936a0044c04 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -1799,9 +1799,9 @@ static int spufs_mfc_fsync(struct file *file, loff_t start, loff_t end, int data
  struct inode *inode = file_inode(file);
  int err = filemap_write_and_wait_range(inode->i_mapping, start, end);
  if (!err) {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  err = spufs_mfc_flush(file, NULL);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
  return err;
 }
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index 11634fa7ab3c..5b38a75cba83 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -163,7 +163,7 @@ static void spufs_prune_dir(struct dentry *dir)
 {
  struct dentry *dentry, *tmp;
 
- mutex_lock(&d_inode(dir)->i_mutex);
+ inode_lock(d_inode(dir));
  list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_child) {
  spin_lock(&dentry->d_lock);
  if (simple_positive(dentry)) {
@@ -180,7 +180,7 @@ static void spufs_prune_dir(struct dentry *dir)
  }
  }
  shrink_dcache_parent(dir);
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
 }
 
 /* Caller must hold parent->i_mutex */
@@ -225,9 +225,9 @@ static int spufs_dir_close(struct inode *inode, struct file *file)
  parent = d_inode(dir->d_parent);
  ctx = SPUFS_I(d_inode(dir))->i_ctx;
 
- mutex_lock_nested(&parent->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(parent, I_MUTEX_PARENT);
  ret = spufs_rmdir(parent, dir);
- mutex_unlock(&parent->i_mutex);
+ inode_unlock(parent);
  WARN_ON(ret);
 
  return dcache_dir_close(inode, file);
@@ -270,7 +270,7 @@ spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags,
  inode->i_op = &simple_dir_inode_operations;
  inode->i_fop = &simple_dir_operations;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  dget(dentry);
  inc_nlink(dir);
@@ -291,7 +291,7 @@ spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags,
  if (ret)
  spufs_rmdir(dir, dentry);
 
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return ret;
 }
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index b2e5902bd8f4..0f3da2cb2bd6 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -67,7 +67,7 @@ static void hypfs_remove(struct dentry *dentry)
  struct dentry *parent;
 
  parent = dentry->d_parent;
- mutex_lock(&d_inode(parent)->i_mutex);
+ inode_lock(d_inode(parent));
  if (simple_positive(dentry)) {
  if (d_is_dir(dentry))
  simple_rmdir(d_inode(parent), dentry);
@@ -76,7 +76,7 @@ static void hypfs_remove(struct dentry *dentry)
  }
  d_delete(dentry);
  dput(dentry);
- mutex_unlock(&d_inode(parent)->i_mutex);
+ inode_unlock(d_inode(parent));
 }
 
 static void hypfs_delete_tree(struct dentry *root)
@@ -331,7 +331,7 @@ static struct dentry *hypfs_create_file(struct dentry *parent, const char *name,
  struct dentry *dentry;
  struct inode *inode;
 
- mutex_lock(&d_inode(parent)->i_mutex);
+ inode_lock(d_inode(parent));
  dentry = lookup_one_len(name, parent, strlen(name));
  if (IS_ERR(dentry)) {
  dentry = ERR_PTR(-ENOMEM);
@@ -359,7 +359,7 @@ static struct dentry *hypfs_create_file(struct dentry *parent, const char *name,
  d_instantiate(dentry, inode);
  dget(dentry);
 fail:
- mutex_unlock(&d_inode(parent)->i_mutex);
+ inode_unlock(d_inode(parent));
  return dentry;
 }
 
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
index bd3507da39f0..a6962661c821 100644
--- a/arch/x86/kernel/cpuid.c
+++ b/arch/x86/kernel/cpuid.c
@@ -63,7 +63,7 @@ static loff_t cpuid_seek(struct file *file, loff_t offset, int orig)
  loff_t ret;
  struct inode *inode = file->f_mapping->host;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  switch (orig) {
  case 0:
  file->f_pos = offset;
@@ -76,7 +76,7 @@ static loff_t cpuid_seek(struct file *file, loff_t offset, int orig)
  default:
  ret = -EINVAL;
  }
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
 
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
index 1bf1d446f4ca..954da8262497 100644
--- a/arch/x86/kernel/msr.c
+++ b/arch/x86/kernel/msr.c
@@ -50,7 +50,7 @@ static loff_t msr_seek(struct file *file, loff_t offset, int orig)
  loff_t ret;
  struct inode *inode = file_inode(file);
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  switch (orig) {
  case SEEK_SET:
  file->f_pos = offset;
@@ -63,7 +63,7 @@ static loff_t msr_seek(struct file *file, loff_t offset, int orig)
  default:
  ret = -EINVAL;
  }
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
 
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
index 68f03141e432..44a74cf1372c 100644
--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -215,9 +215,9 @@ static int handle_create(const char *nodename, umode_t mode, kuid_t uid,
  newattrs.ia_uid = uid;
  newattrs.ia_gid = gid;
  newattrs.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID;
- mutex_lock(&d_inode(dentry)->i_mutex);
+ inode_lock(d_inode(dentry));
  notify_change(dentry, &newattrs, NULL);
- mutex_unlock(&d_inode(dentry)->i_mutex);
+ inode_unlock(d_inode(dentry));
 
  /* mark as kernel-created inode */
  d_inode(dentry)->i_private = &thread;
@@ -244,7 +244,7 @@ static int dev_rmdir(const char *name)
  err = -ENOENT;
  }
  dput(dentry);
- mutex_unlock(&d_inode(parent.dentry)->i_mutex);
+ inode_unlock(d_inode(parent.dentry));
  path_put(&parent);
  return err;
 }
@@ -321,9 +321,9 @@ static int handle_remove(const char *nodename, struct device *dev)
  newattrs.ia_mode = stat.mode & ~0777;
  newattrs.ia_valid =
  ATTR_UID|ATTR_GID|ATTR_MODE;
- mutex_lock(&d_inode(dentry)->i_mutex);
+ inode_lock(d_inode(dentry));
  notify_change(dentry, &newattrs, NULL);
- mutex_unlock(&d_inode(dentry)->i_mutex);
+ inode_unlock(d_inode(dentry));
  err = vfs_unlink(d_inode(parent.dentry), dentry, NULL);
  if (!err || err == -ENOENT)
  deleted = 1;
@@ -332,7 +332,7 @@ static int handle_remove(const char *nodename, struct device *dev)
  err = -ENOENT;
  }
  dput(dentry);
- mutex_unlock(&d_inode(parent.dentry)->i_mutex);
+ inode_unlock(d_inode(parent.dentry));
 
  path_put(&parent);
  if (deleted && strchr(nodename, '/'))
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index ad80c85e0857..d048d2009e89 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -964,9 +964,9 @@ aoecmd_sleepwork(struct work_struct *work)
  ssize = get_capacity(d->gd);
  bd = bdget_disk(d->gd, 0);
  if (bd) {
- mutex_lock(&bd->bd_inode->i_mutex);
+ inode_lock(bd->bd_inode);
  i_size_write(bd->bd_inode, (loff_t)ssize<<9);
- mutex_unlock(&bd->bd_inode->i_mutex);
+ inode_unlock(bd->bd_inode);
  bdput(bd);
  }
  spin_lock_irq(&d->lock);
diff --git a/drivers/block/drbd/drbd_debugfs.c b/drivers/block/drbd/drbd_debugfs.c
index 6b88a35fb048..98dd4994db6f 100644
--- a/drivers/block/drbd/drbd_debugfs.c
+++ b/drivers/block/drbd/drbd_debugfs.c
@@ -434,12 +434,12 @@ static int drbd_single_open(struct file *file, int (*show)(struct seq_file *, vo
  if (!parent || d_really_is_negative(parent))
  goto out;
  /* serialize with d_delete() */
- mutex_lock(&d_inode(parent)->i_mutex);
+ inode_lock(d_inode(parent));
  /* Make sure the object is still alive */
  if (simple_positive(file->f_path.dentry)
  && kref_get_unless_zero(kref))
  ret = 0;
- mutex_unlock(&d_inode(parent)->i_mutex);
+ inode_unlock(d_inode(parent));
  if (!ret) {
  ret = single_open(file, show, data);
  if (ret)
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 8b50745bc022..1bdb9107c323 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -726,7 +726,7 @@ static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
 {
  loff_t ret;
 
- mutex_lock(&file_inode(file)->i_mutex);
+ inode_lock(file_inode(file));
  switch (orig) {
  case SEEK_CUR:
  offset += file->f_pos;
@@ -743,7 +743,7 @@ static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
  default:
  ret = -EINVAL;
  }
- mutex_unlock(&file_inode(file)->i_mutex);
+ inode_unlock(file_inode(file));
  return ret;
 }
 
diff --git a/drivers/char/ps3flash.c b/drivers/char/ps3flash.c
index 0b311fa277ef..b526dc15c271 100644
--- a/drivers/char/ps3flash.c
+++ b/drivers/char/ps3flash.c
@@ -290,9 +290,9 @@ static int ps3flash_fsync(struct file *file, loff_t start, loff_t end, int datas
 {
  struct inode *inode = file_inode(file);
  int err;
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  err = ps3flash_writeback(ps3flash_dev);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return err;
 }
 
diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib/qib_fs.c
index 13ef22bd9459..fcdf37913a26 100644
--- a/drivers/infiniband/hw/qib/qib_fs.c
+++ b/drivers/infiniband/hw/qib/qib_fs.c
@@ -89,14 +89,14 @@ static int create_file(const char *name, umode_t mode,
 {
  int error;
 
- mutex_lock(&d_inode(parent)->i_mutex);
+ inode_lock(d_inode(parent));
  *dentry = lookup_one_len(name, parent, strlen(name));
  if (!IS_ERR(*dentry))
  error = qibfs_mknod(d_inode(parent), *dentry,
     mode, fops, data);
  else
  error = PTR_ERR(*dentry);
- mutex_unlock(&d_inode(parent)->i_mutex);
+ inode_unlock(d_inode(parent));
 
  return error;
 }
@@ -481,7 +481,7 @@ static int remove_device_files(struct super_block *sb,
  int ret, i;
 
  root = dget(sb->s_root);
- mutex_lock(&d_inode(root)->i_mutex);
+ inode_lock(d_inode(root));
  snprintf(unit, sizeof(unit), "%u", dd->unit);
  dir = lookup_one_len(unit, root, strlen(unit));
 
@@ -491,7 +491,7 @@ static int remove_device_files(struct super_block *sb,
  goto bail;
  }
 
- mutex_lock(&d_inode(dir)->i_mutex);
+ inode_lock(d_inode(dir));
  remove_file(dir, "counters");
  remove_file(dir, "counter_names");
  remove_file(dir, "portcounter_names");
@@ -506,13 +506,13 @@ static int remove_device_files(struct super_block *sb,
  }
  }
  remove_file(dir, "flash");
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
  ret = simple_rmdir(d_inode(root), dir);
  d_delete(dir);
  dput(dir);
 
 bail:
- mutex_unlock(&d_inode(root)->i_mutex);
+ inode_unlock(d_inode(root));
  dput(root);
  return ret;
 }
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 54e056d3be02..ee2b74d1d1b5 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -174,9 +174,9 @@ static int vol_cdev_fsync(struct file *file, loff_t start, loff_t end,
  struct ubi_device *ubi = desc->vol->ubi;
  struct inode *inode = file_inode(file);
  int err;
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  err = ubi_sync(ubi->ubi_num);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return err;
 }
 
diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
index dd92c5edf219..b48ac6300c79 100644
--- a/drivers/oprofile/oprofilefs.c
+++ b/drivers/oprofile/oprofilefs.c
@@ -138,22 +138,22 @@ static int __oprofilefs_create_file(struct dentry *root, char const *name,
  struct dentry *dentry;
  struct inode *inode;
 
- mutex_lock(&d_inode(root)->i_mutex);
+ inode_lock(d_inode(root));
  dentry = d_alloc_name(root, name);
  if (!dentry) {
- mutex_unlock(&d_inode(root)->i_mutex);
+ inode_unlock(d_inode(root));
  return -ENOMEM;
  }
  inode = oprofilefs_get_inode(root->d_sb, S_IFREG | perm);
  if (!inode) {
  dput(dentry);
- mutex_unlock(&d_inode(root)->i_mutex);
+ inode_unlock(d_inode(root));
  return -ENOMEM;
  }
  inode->i_fop = fops;
  inode->i_private = priv;
  d_add(dentry, inode);
- mutex_unlock(&d_inode(root)->i_mutex);
+ inode_unlock(d_inode(root));
  return 0;
 }
 
@@ -215,22 +215,22 @@ struct dentry *oprofilefs_mkdir(struct dentry *parent, char const *name)
  struct dentry *dentry;
  struct inode *inode;
 
- mutex_lock(&d_inode(parent)->i_mutex);
+ inode_lock(d_inode(parent));
  dentry = d_alloc_name(parent, name);
  if (!dentry) {
- mutex_unlock(&d_inode(parent)->i_mutex);
+ inode_unlock(d_inode(parent));
  return NULL;
  }
  inode = oprofilefs_get_inode(parent->d_sb, S_IFDIR | 0755);
  if (!inode) {
  dput(dentry);
- mutex_unlock(&d_inode(parent)->i_mutex);
+ inode_unlock(d_inode(parent));
  return NULL;
  }
  inode->i_op = &simple_dir_inode_operations;
  inode->i_fop = &simple_dir_operations;
  d_add(dentry, inode);
- mutex_unlock(&d_inode(parent)->i_mutex);
+ inode_unlock(d_inode(parent));
  return dentry;
 }
 
diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c
index 5c9502b5b358..03756fc8ba96 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -1863,7 +1863,7 @@ static loff_t ll_dir_seek(struct file *file, loff_t offset, int origin)
  int api32 = ll_need_32bit_api(sbi);
  loff_t ret = -EINVAL;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  switch (origin) {
  case SEEK_SET:
  break;
@@ -1901,7 +1901,7 @@ static loff_t ll_dir_seek(struct file *file, loff_t offset, int origin)
  goto out;
 
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
 
diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
index 02f27593013e..241275553c19 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -2082,17 +2082,17 @@ putgl:
  /* update time if requested */
  rc = 0;
  if (llss->ia2.ia_valid != 0) {
- mutex_lock(&llss->inode1->i_mutex);
+ inode_lock(llss->inode1);
  rc = ll_setattr(file1->f_path.dentry, &llss->ia2);
- mutex_unlock(&llss->inode1->i_mutex);
+ inode_unlock(llss->inode1);
  }
 
  if (llss->ia1.ia_valid != 0) {
  int rc1;
 
- mutex_lock(&llss->inode2->i_mutex);
+ inode_lock(llss->inode2);
  rc1 = ll_setattr(file2->f_path.dentry, &llss->ia1);
- mutex_unlock(&llss->inode2->i_mutex);
+ inode_unlock(llss->inode2);
  if (rc == 0)
  rc = rc1;
  }
@@ -2179,13 +2179,13 @@ static int ll_hsm_import(struct inode *inode, struct file *file,
  ATTR_MTIME | ATTR_MTIME_SET |
  ATTR_ATIME | ATTR_ATIME_SET;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  rc = ll_setattr_raw(file->f_path.dentry, attr, true);
  if (rc == -ENODATA)
  rc = 0;
 
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  kfree(attr);
 free_hss:
@@ -2609,7 +2609,7 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync)
  ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_FSYNC, 1);
 
  rc = filemap_write_and_wait_range(inode->i_mapping, start, end);
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  /* catch async errors that were recorded back when async writeback
  * failed for pages in this mapping. */
@@ -2641,7 +2641,7 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync)
  fd->fd_write_failed = false;
  }
 
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return rc;
 }
 
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 4a8c759fef42..fc008e6dae74 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -1277,7 +1277,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
  return -ENOMEM;
 
  if (!S_ISDIR(inode->i_mode))
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  memcpy(&op_data->op_attr, attr, sizeof(*attr));
 
@@ -1358,7 +1358,7 @@ out:
  ll_finish_md_op_data(op_data);
 
  if (!S_ISDIR(inode->i_mode)) {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  if ((attr->ia_valid & ATTR_SIZE) && !hsm_import)
  inode_dio_wait(inode);
  }
diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c
index e578a1130ad1..18aab25f9cd9 100644
--- a/drivers/staging/lustre/lustre/llite/llite_nfs.c
+++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c
@@ -245,9 +245,9 @@ static int ll_get_name(struct dentry *dentry, char *name,
  goto out;
  }
 
- mutex_lock(&dir->i_mutex);
+ inode_lock(dir);
  rc = ll_dir_read(dir, &lgd.ctx);
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
  if (!rc && !lgd.lgd_found)
  rc = -ENOENT;
 out:
diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c
index fed50d538a41..b75552132941 100644
--- a/drivers/staging/lustre/lustre/llite/lloop.c
+++ b/drivers/staging/lustre/lustre/llite/lloop.c
@@ -257,9 +257,9 @@ static int do_bio_lustrebacked(struct lloop_device *lo, struct bio *head)
  *    be asked to write less pages once, this purely depends on
  *    implementation. Anyway, we should be careful to avoid deadlocking.
  */
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  bytes = ll_direct_rw_pages(env, io, rw, inode, pvec);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  cl_io_fini(env, io);
  return (bytes == pvec->ldp_size) ? 0 : (int)bytes;
 }
diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c
index f79193fa2fb7..3bc17a29d501 100644
--- a/drivers/staging/lustre/lustre/llite/rw.c
+++ b/drivers/staging/lustre/lustre/llite/rw.c
@@ -115,8 +115,8 @@ static struct ll_cl_context *ll_cl_init(struct file *file,
  struct inode *inode = vmpage->mapping->host;
  loff_t pos;
 
- if (mutex_trylock(&inode->i_mutex)) {
- mutex_unlock(&(inode)->i_mutex);
+ if (inode_trylock(inode)) {
+ inode_unlock((inode));
 
  /* this is too bad. Someone is trying to write the
  * page w/o holding inode mutex. This means we can
diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c
index adeefb31cbad..fd487527c28d 100644
--- a/drivers/staging/lustre/lustre/llite/rw26.c
+++ b/drivers/staging/lustre/lustre/llite/rw26.c
@@ -404,7 +404,7 @@ static ssize_t ll_direct_IO_26(struct kiocb *iocb, struct iov_iter *iter,
  * 1. Need inode mutex to operate transient pages.
  */
  if (iov_iter_rw(iter) == READ)
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  LASSERT(obj->cob_transient_pages == 0);
  while (iov_iter_count(iter)) {
@@ -455,7 +455,7 @@ static ssize_t ll_direct_IO_26(struct kiocb *iocb, struct iov_iter *iter,
 out:
  LASSERT(obj->cob_transient_pages == 0);
  if (iov_iter_rw(iter) == READ)
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  if (tot_bytes > 0) {
  if (iov_iter_rw(iter) == WRITE) {
diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c
index 37773c181729..6e4da04dcf0c 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_io.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_io.c
@@ -439,7 +439,7 @@ static int vvp_io_setattr_start(const struct lu_env *env,
  struct inode *inode = ccc_object_inode(io->ci_obj);
  int result = 0;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  if (cl_io_is_trunc(io))
  result = vvp_io_setattr_trunc(env, ios, inode,
  io->u.ci_setattr.sa_attr.lvb_size);
@@ -459,7 +459,7 @@ static void vvp_io_setattr_end(const struct lu_env *env,
  * because osc has already notified to destroy osc_extents. */
  vvp_do_vmtruncate(inode, io->u.ci_setattr.sa_attr.lvb_size);
 
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 }
 
 static void vvp_io_setattr_fini(const struct lu_env *env,
diff --git a/drivers/staging/lustre/lustre/llite/vvp_page.c b/drivers/staging/lustre/lustre/llite/vvp_page.c
index 92f60c350f35..b6546e324cdb 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_page.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_page.c
@@ -428,7 +428,7 @@ static void vvp_transient_page_verify(const struct cl_page *page)
 {
  struct inode *inode = ccc_object_inode(page->cp_obj);
 
- LASSERT(!mutex_trylock(&inode->i_mutex));
+ LASSERT(!inode_trylock(inode));
 }
 
 static int vvp_transient_page_own(const struct lu_env *env,
@@ -480,9 +480,9 @@ static int vvp_transient_page_is_vmlocked(const struct lu_env *env,
  struct inode    *inode = ccc_object_inode(slice->cpl_obj);
  int locked;
 
- locked = !mutex_trylock(&inode->i_mutex);
+ locked = !inode_trylock(inode);
  if (!locked)
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return locked ? -EBUSY : -ENODATA;
 }
 
@@ -502,7 +502,7 @@ static void vvp_transient_page_fini(const struct lu_env *env,
  struct ccc_object *clobj = cl2ccc(clp->cp_obj);
 
  vvp_page_fini_common(cp);
- LASSERT(!mutex_trylock(&clobj->cob_inode->i_mutex));
+ LASSERT(!inode_trylock(clobj->cob_inode));
  clobj->cob_transient_pages--;
 }
 
@@ -548,7 +548,7 @@ int vvp_page_init(const struct lu_env *env, struct cl_object *obj,
  } else {
  struct ccc_object *clobj = cl2ccc(obj);
 
- LASSERT(!mutex_trylock(&clobj->cob_inode->i_mutex));
+ LASSERT(!inode_trylock(clobj->cob_inode));
  cl_page_slice_add(page, &cpg->cpg_cl, obj,
  &vvp_transient_page_ops);
  clobj->cob_transient_pages++;
diff --git a/drivers/staging/rdma/ipath/ipath_fs.c b/drivers/staging/rdma/ipath/ipath_fs.c
index 796af6867007..476fcdf05acb 100644
--- a/drivers/staging/rdma/ipath/ipath_fs.c
+++ b/drivers/staging/rdma/ipath/ipath_fs.c
@@ -82,14 +82,14 @@ static int create_file(const char *name, umode_t mode,
 {
  int error;
 
- mutex_lock(&d_inode(parent)->i_mutex);
+ inode_lock(d_inode(parent));
  *dentry = lookup_one_len(name, parent, strlen(name));
  if (!IS_ERR(*dentry))
  error = ipathfs_mknod(d_inode(parent), *dentry,
       mode, fops, data);
  else
  error = PTR_ERR(*dentry);
- mutex_unlock(&d_inode(parent)->i_mutex);
+ inode_unlock(d_inode(parent));
 
  return error;
 }
@@ -295,7 +295,7 @@ static int remove_device_files(struct super_block *sb,
  int ret;
 
  root = dget(sb->s_root);
- mutex_lock(&d_inode(root)->i_mutex);
+ inode_lock(d_inode(root));
  snprintf(unit, sizeof unit, "%02d", dd->ipath_unit);
  dir = lookup_one_len(unit, root, strlen(unit));
 
@@ -311,7 +311,7 @@ static int remove_device_files(struct super_block *sb,
  ret = simple_rmdir(d_inode(root), dir);
 
 bail:
- mutex_unlock(&d_inode(root)->i_mutex);
+ inode_unlock(d_inode(root));
  dput(root);
  return ret;
 }
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index 332ed277a06c..f357c31d05ce 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -667,7 +667,7 @@ static loff_t usb_device_lseek(struct file *file, loff_t offset, int orig)
 {
  loff_t ret;
 
- mutex_lock(&file_inode(file)->i_mutex);
+ inode_lock(file_inode(file));
 
  switch (orig) {
  case 0:
@@ -683,7 +683,7 @@ static loff_t usb_device_lseek(struct file *file, loff_t offset, int orig)
  ret = -EINVAL;
  }
 
- mutex_unlock(&file_inode(file)->i_mutex);
+ inode_unlock(file_inode(file));
  return ret;
 }
 
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 873ba02d59e6..88504b28090f 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -161,7 +161,7 @@ static loff_t usbdev_lseek(struct file *file, loff_t offset, int orig)
 {
  loff_t ret;
 
- mutex_lock(&file_inode(file)->i_mutex);
+ inode_lock(file_inode(file));
 
  switch (orig) {
  case 0:
@@ -177,7 +177,7 @@ static loff_t usbdev_lseek(struct file *file, loff_t offset, int orig)
  ret = -EINVAL;
  }
 
- mutex_unlock(&file_inode(file)->i_mutex);
+ inode_unlock(file_inode(file));
  return ret;
 }
 
diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
index 0fbfb2b2aa08..26ccad5d8680 100644
--- a/drivers/usb/gadget/function/f_printer.c
+++ b/drivers/usb/gadget/function/f_printer.c
@@ -673,7 +673,7 @@ printer_fsync(struct file *fd, loff_t start, loff_t end, int datasync)
  unsigned long flags;
  int tx_list_empty;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  spin_lock_irqsave(&dev->lock, flags);
  tx_list_empty = (likely(list_empty(&dev->tx_reqs)));
  spin_unlock_irqrestore(&dev->lock, flags);
@@ -683,7 +683,7 @@ printer_fsync(struct file *fd, loff_t start, loff_t end, int datasync)
  wait_event_interruptible(dev->tx_flush_wait,
  (likely(list_empty(&dev->tx_reqs_active))));
  }
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return 0;
 }
diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index b6df47aa25af..f52768d9121a 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -1559,10 +1559,10 @@ static void destroy_ep_files (struct dev_data *dev)
  put_ep (ep);
 
  /* break link to dcache */
- mutex_lock (&parent->i_mutex);
+ inode_lock (&parent);
  d_delete (dentry);
  dput (dentry);
- mutex_unlock (&parent->i_mutex);
+ inode_unlock (&parent);
 
  spin_lock_irq (&dev->lock);
  }
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 585cb8734f50..4fb1efed46a4 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -93,7 +93,7 @@ static ssize_t queue_dbg_read(struct file *file, char __user *buf,
  if (!access_ok(VERIFY_WRITE, buf, nbytes))
  return -EFAULT;
 
- mutex_lock(&file_inode(file)->i_mutex);
+ inode_lock(file_inode(file));
  list_for_each_entry_safe(req, tmp_req, queue, queue) {
  len = snprintf(tmpbuf, sizeof(tmpbuf),
  "%8p %08x %c%c%c %5d %c%c%c\n",
@@ -120,7 +120,7 @@ static ssize_t queue_dbg_read(struct file *file, char __user *buf,
  nbytes -= len;
  buf += len;
  }
- mutex_unlock(&file_inode(file)->i_mutex);
+ inode_unlock(file_inode(file));
 
  return actual;
 }
@@ -145,7 +145,7 @@ static int regs_dbg_open(struct inode *inode, struct file *file)
  u32 *data;
  int ret = -ENOMEM;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  udc = inode->i_private;
  data = kmalloc(inode->i_size, GFP_KERNEL);
  if (!data)
@@ -160,7 +160,7 @@ static int regs_dbg_open(struct inode *inode, struct file *file)
  ret = 0;
 
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return ret;
 }
@@ -171,11 +171,11 @@ static ssize_t regs_dbg_read(struct file *file, char __user *buf,
  struct inode *inode = file_inode(file);
  int ret;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  ret = simple_read_from_buffer(buf, nbytes, ppos,
  file->private_data,
  file_inode(file)->i_size);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return ret;
 }
diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c
index 3fc63c208d08..57721c73177f 100644
--- a/drivers/video/fbdev/core/fb_defio.c
+++ b/drivers/video/fbdev/core/fb_defio.c
@@ -78,13 +78,13 @@ int fb_deferred_io_fsync(struct file *file, loff_t start, loff_t end, int datasy
  if (!info->fbdefio)
  return 0;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  /* Kill off the delayed work */
  cancel_delayed_work_sync(&info->deferred_work);
 
  /* Run it immediately */
  schedule_delayed_work(&info->deferred_work, 0);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return 0;
 }
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index 12ceaf52dae6..6d84616edce7 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -449,14 +449,14 @@ static int v9fs_file_fsync(struct file *filp, loff_t start, loff_t end,
  if (retval)
  return retval;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  p9_debug(P9_DEBUG_VFS, "filp %p datasync %x\n", filp, datasync);
 
  fid = filp->private_data;
  v9fs_blank_wstat(&wstat);
 
  retval = p9_client_wstat(fid, &wstat);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return retval;
 }
@@ -472,13 +472,13 @@ int v9fs_file_fsync_dotl(struct file *filp, loff_t start, loff_t end,
  if (retval)
  return retval;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  p9_debug(P9_DEBUG_VFS, "filp %p datasync %x\n", filp, datasync);
 
  fid = filp->private_data;
 
  retval = p9_client_fsync(fid, datasync);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return retval;
 }
diff --git a/fs/affs/file.c b/fs/affs/file.c
index 659c579c4588..0548c53f41d5 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -33,11 +33,11 @@ affs_file_release(struct inode *inode, struct file *filp)
  inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt));
 
  if (atomic_dec_and_test(&AFFS_I(inode)->i_opencnt)) {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  if (inode->i_size != AFFS_I(inode)->mmu_private)
  affs_truncate(inode);
  affs_free_prealloc(inode);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
 
  return 0;
@@ -958,12 +958,12 @@ int affs_file_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
  if (err)
  return err;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  ret = write_inode_now(inode, 0);
  err = sync_blockdev(inode->i_sb->s_bdev);
  if (!ret)
  ret = err;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
 const struct file_operations affs_file_operations = {
diff --git a/fs/afs/flock.c b/fs/afs/flock.c
index 4baf1d2b39e4..d91a9c9cfbd0 100644
--- a/fs/afs/flock.c
+++ b/fs/afs/flock.c
@@ -483,7 +483,7 @@ static int afs_do_getlk(struct file *file, struct file_lock *fl)
 
  fl->fl_type = F_UNLCK;
 
- mutex_lock(&vnode->vfs_inode.i_mutex);
+ inode_lock(&vnode->vfs_inode);
 
  /* check local lock records first */
  ret = 0;
@@ -505,7 +505,7 @@ static int afs_do_getlk(struct file *file, struct file_lock *fl)
  }
 
 error:
- mutex_unlock(&vnode->vfs_inode.i_mutex);
+ inode_unlock(&vnode->vfs_inode);
  _leave(" = %d [%hd]", ret, fl->fl_type);
  return ret;
 }
diff --git a/fs/afs/write.c b/fs/afs/write.c
index 0714abcd7f32..dfef94f70667 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -693,7 +693,7 @@ int afs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
  ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
  if (ret)
  return ret;
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  /* use a writeback record as a marker in the queue - when this reaches
  * the front of the queue, all the outstanding writes are either
@@ -735,7 +735,7 @@ int afs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
  afs_put_writeback(wb);
  _leave(" = %d", ret);
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
 
diff --git a/fs/attr.c b/fs/attr.c
index df05bc167360..7861340d8bd3 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -213,7 +213,7 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de
  struct timespec now;
  unsigned int ia_valid = attr->ia_valid;
 
- WARN_ON_ONCE(!mutex_is_locked(&inode->i_mutex));
+ WARN_ON_ONCE(!inode_is_locked(inode));
 
  if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
  if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
diff --git a/fs/aufs/cpup.c b/fs/aufs/cpup.c
index dbf847ac5c6c..3cf3afdf5d52 100644
--- a/fs/aufs/cpup.c
+++ b/fs/aufs/cpup.c
@@ -435,7 +435,7 @@ static int au_do_cpup_regular(struct au_cp_generic *cpg,
  cpg->len = l;
  if (cpg->len) {
  /* try stopping to update while we are referencing */
- mutex_lock_nested(&h_src_inode->i_mutex, AuLsc_I_CHILD);
+ inode_lock_nested(h_src_inode, AuLsc_I_CHILD);
  au_pin_hdir_unlock(cpg->pin);
 
  h_path.dentry = au_h_dptr(cpg->dentry, cpg->bsrc);
@@ -444,17 +444,17 @@ static int au_do_cpup_regular(struct au_cp_generic *cpg,
  if (!au_test_nfs(h_src_inode->i_sb))
  err = vfs_getattr(&h_path, &h_src_attr->st);
  else {
- mutex_unlock(&h_src_inode->i_mutex);
+ inode_unlock(h_src_inode);
  err = vfs_getattr(&h_path, &h_src_attr->st);
- mutex_lock_nested(&h_src_inode->i_mutex, AuLsc_I_CHILD);
+ inode_lock_nested(h_src_inode, AuLsc_I_CHILD);
  }
  if (unlikely(err)) {
- mutex_unlock(&h_src_inode->i_mutex);
+ inode_unlock(h_src_inode);
  goto out;
  }
  h_src_attr->valid = 1;
  err = au_cp_regular(cpg);
- mutex_unlock(&h_src_inode->i_mutex);
+ inode_unlock(h_src_inode);
  rerr = au_pin_hdir_relock(cpg->pin);
  if (!err && rerr)
  err = rerr;
@@ -761,7 +761,7 @@ static int au_cpup_single(struct au_cp_generic *cpg, struct dentry *dst_parent)
  if (unlikely(err))
  goto out_rev;
  dst_inode = d_inode(h_dst);
- mutex_lock_nested(&dst_inode->i_mutex, AuLsc_I_CHILD2);
+ inode_lock_nested(dst_inode, AuLsc_I_CHILD2);
  /* todo: necessary? */
  /* au_pin_hdir_unlock(cpg->pin); */
 
@@ -769,7 +769,7 @@ static int au_cpup_single(struct au_cp_generic *cpg, struct dentry *dst_parent)
  if (unlikely(err)) {
  /* todo: necessary? */
  /* au_pin_hdir_relock(cpg->pin); */ /* ignore an error */
- mutex_unlock(&dst_inode->i_mutex);
+ inode_unlock(dst_inode);
  goto out_rev;
  }
 
@@ -779,7 +779,7 @@ static int au_cpup_single(struct au_cp_generic *cpg, struct dentry *dst_parent)
  if (unlikely(err)) {
  /* ignore an error */
  /* au_pin_hdir_relock(cpg->pin); */
- mutex_unlock(&dst_inode->i_mutex);
+ inode_unlock(dst_inode);
  goto out_rev;
  }
  }
@@ -791,7 +791,7 @@ static int au_cpup_single(struct au_cp_generic *cpg, struct dentry *dst_parent)
 
  /* todo: necessary? */
  /* err = au_pin_hdir_relock(cpg->pin); */
- mutex_unlock(&dst_inode->i_mutex);
+ inode_unlock(dst_inode);
  if (unlikely(err))
  goto out_rev;
 
@@ -1165,7 +1165,7 @@ int au_sio_cpup_wh(struct au_cp_generic *cpg, struct file *file)
  h_tmpdir = d_inode(h_orph);
  au_set_h_iptr(dir, bdst, au_igrab(h_tmpdir), /*flags*/0);
 
- mutex_lock_nested(&h_tmpdir->i_mutex, AuLsc_I_PARENT3);
+ inode_lock_nested(h_tmpdir, AuLsc_I_PARENT3);
  /* todo: au_h_open_pre()? */
 
  pin_orig = cpg->pin;
@@ -1189,7 +1189,7 @@ int au_sio_cpup_wh(struct au_cp_generic *cpg, struct file *file)
  }
 
  if (h_orph) {
- mutex_unlock(&h_tmpdir->i_mutex);
+ inode_unlock(h_tmpdir);
  /* todo: au_h_open_post()? */
  au_set_h_iptr(dir, bdst, au_igrab(h_dir), /*flags*/0);
  au_set_h_dptr(parent, bdst, h_parent);
diff --git a/fs/aufs/dentry.c b/fs/aufs/dentry.c
index 6c5965d20f5e..1122bc53177b 100644
--- a/fs/aufs/dentry.c
+++ b/fs/aufs/dentry.c
@@ -101,9 +101,9 @@ real_lookup:
     || (d_really_is_positive(dentry) && !d_is_dir(dentry)))
  goto out; /* success */
 
- mutex_lock_nested(&h_inode->i_mutex, AuLsc_I_CHILD);
+ inode_lock_nested(h_inode, AuLsc_I_CHILD);
  opq = au_diropq_test(h_dentry);
- mutex_unlock(&h_inode->i_mutex);
+ inode_unlock(h_inode);
  if (opq > 0)
  au_set_dbdiropq(dentry, bindex);
  else if (unlikely(opq < 0)) {
@@ -180,10 +180,10 @@ int au_lkup_dentry(struct dentry *dentry, aufs_bindex_t bstart, mode_t type)
  continue;
 
  h_dir = d_inode(h_parent);
- mutex_lock_nested(&h_dir->i_mutex, AuLsc_I_PARENT);
+ inode_lock_nested(h_dir, AuLsc_I_PARENT);
  h_dentry = au_do_lookup(h_parent, dentry, bindex, &whname,
  &args);
- mutex_unlock(&h_dir->i_mutex);
+ inode_unlock(h_dir);
  err = PTR_ERR(h_dentry);
  if (IS_ERR(h_dentry))
  goto out_parent;
diff --git a/fs/aufs/dir.c b/fs/aufs/dir.c
index b3493ca28af1..e4ff46eefc10 100644
--- a/fs/aufs/dir.c
+++ b/fs/aufs/dir.c
@@ -631,9 +631,9 @@ static int sio_test_empty(struct dentry *dentry, struct test_empty_arg *arg)
  h_dentry = au_h_dptr(dentry, arg->bindex);
  h_inode = d_inode(h_dentry);
  /* todo: i_mode changes anytime? */
- mutex_lock_nested(&h_inode->i_mutex, AuLsc_I_CHILD);
+ inode_lock_nested(h_inode, AuLsc_I_CHILD);
  err = au_test_h_perm_sio(h_inode, MAY_EXEC | MAY_READ);
- mutex_unlock(&h_inode->i_mutex);
+ inode_unlock(h_inode);
  if (!err)
  err = do_test_empty(dentry, arg);
  else {
diff --git a/fs/aufs/export.c b/fs/aufs/export.c
index c85b036b817f..c2a566c7caef 100644
--- a/fs/aufs/export.c
+++ b/fs/aufs/export.c
@@ -406,9 +406,9 @@ static struct dentry *au_lkup_by_ino(struct path *path, ino_t ino,
 
  /* do not call vfsub_lkup_one() */
  dir = d_inode(parent);
- mutex_lock(&dir->i_mutex);
+ inode_lock(dir);
  dentry = vfsub_lookup_one_len(arg.name, parent, arg.namelen);
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
  AuTraceErrPtr(dentry);
  if (IS_ERR(dentry))
  goto out_name;
diff --git a/fs/aufs/f_op.c b/fs/aufs/f_op.c
index 2c348641cb4e..5f841048a0c8 100644
--- a/fs/aufs/f_op.c
+++ b/fs/aufs/f_op.c
@@ -263,11 +263,11 @@ static void au_mtx_and_read_lock(struct inode *inode)
  struct super_block *sb = inode->i_sb;
 
  while (1) {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  err = si_read_lock(sb, AuLock_FLUSH | AuLock_NOPLM);
  if (!err)
  break;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  si_read_lock(sb, AuLock_NOPLMW);
  si_read_unlock(sb);
  }
@@ -295,7 +295,7 @@ static ssize_t aufs_write(struct file *file, const char __user *ubuf,
 
 out:
  si_read_unlock(inode->i_sb);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return err;
 }
 
@@ -380,7 +380,7 @@ static ssize_t aufs_write_iter(struct kiocb *kio, struct iov_iter *iov_iter)
 
 out:
  si_read_unlock(inode->i_sb);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return err;
 }
 
@@ -443,7 +443,7 @@ aufs_splice_write(struct pipe_inode_info *pipe, struct file *file, loff_t *ppos,
 
 out:
  si_read_unlock(inode->i_sb);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return err;
 }
 
@@ -470,7 +470,7 @@ static long aufs_fallocate(struct file *file, int mode, loff_t offset,
 
 out:
  si_read_unlock(inode->i_sb);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return err;
 }
 
@@ -613,7 +613,7 @@ static int aufs_fsync_nondir(struct file *file, loff_t start, loff_t end,
 
 out_unlock:
  si_read_unlock(inode->i_sb);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 out:
  return err;
 }
@@ -662,7 +662,7 @@ static int aufs_aio_fsync_nondir(struct kiocb *kio, int datasync)
 
 out_unlock:
  si_read_unlock(inode->sb);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 out:
  return err;
 }
diff --git a/fs/aufs/hnotify.c b/fs/aufs/hnotify.c
index 643bc57c595f..c6ef9f018ae0 100644
--- a/fs/aufs/hnotify.c
+++ b/fs/aufs/hnotify.c
@@ -83,7 +83,7 @@ void au_hn_reset(struct inode *inode, unsigned int flags)
  if (!hi)
  continue;
 
- /* mutex_lock_nested(&hi->i_mutex, AuLsc_I_CHILD); */
+ /* inode_lock_nested(hi, AuLsc_I_CHILD); */
  iwhdentry = au_hi_wh(inode, bindex);
  if (iwhdentry)
  dget(iwhdentry);
@@ -93,7 +93,7 @@ void au_hn_reset(struct inode *inode, unsigned int flags)
       flags & ~AuHi_XINO);
  iput(hi);
  dput(iwhdentry);
- /* mutex_unlock(&hi->i_mutex); */
+ /* inode_unlock(hi); */
  }
 }
 
@@ -322,11 +322,11 @@ static int hn_job(struct hn_job_args *a)
  if (au_ftest_hnjob(a->flags, TRYXINO0)
     && a->inode
     && a->h_inode) {
- mutex_lock_nested(&a->h_inode->i_mutex, AuLsc_I_CHILD);
+ inode_lock_nested(a->h_inode, AuLsc_I_CHILD);
  if (!a->h_inode->i_nlink
     && !(a->h_inode->i_state & I_LINKABLE))
  hn_xino(a->inode, a->h_inode); /* ignore this error */
- mutex_unlock(&a->h_inode->i_mutex);
+ inode_unlock(a->h_inode);
  }
 
  /* make the generation obsolete */
diff --git a/fs/aufs/i_op.c b/fs/aufs/i_op.c
index b19007a4d514..5f1a9cdbec80 100644
--- a/fs/aufs/i_op.c
+++ b/fs/aufs/i_op.c
@@ -427,10 +427,10 @@ static int au_wr_dir_cpup(struct dentry *dentry, struct dentry *parent,
  if (!err && add_entry && !au_ftest_wrdir(add_entry, TMPFILE)) {
  h_parent = au_h_dptr(parent, bcpup);
  h_dir = d_inode(h_parent);
- mutex_lock_nested(&h_dir->i_mutex, AuLsc_I_PARENT);
+ inode_lock_nested(h_dir, AuLsc_I_PARENT);
  err = au_lkup_neg(dentry, bcpup, /*wh*/0);
  /* todo: no unlock here */
- mutex_unlock(&h_dir->i_mutex);
+ inode_unlock(h_dir);
 
  AuDbg("bcpup %d\n", bcpup);
  if (!err) {
@@ -814,10 +814,10 @@ int au_pin_and_icpup(struct dentry *dentry, struct iattr *ia,
  sz = -1;
  a->h_inode = d_inode(a->h_path.dentry);
  if (ia && (ia->ia_valid & ATTR_SIZE)) {
- mutex_lock_nested(&a->h_inode->i_mutex, AuLsc_I_CHILD);
+ inode_lock_nested(a->h_inode, AuLsc_I_CHILD);
  if (ia->ia_size < i_size_read(a->h_inode))
  sz = ia->ia_size;
- mutex_unlock(&a->h_inode->i_mutex);
+ inode_unlock(a->h_inode);
  }
 
  hi_wh = NULL;
@@ -877,7 +877,7 @@ out_parent:
  }
 out:
  if (!err)
- mutex_lock_nested(&a->h_inode->i_mutex, AuLsc_I_CHILD);
+ inode_lock_nested(a->h_inode, AuLsc_I_CHILD);
  return err;
 }
 
@@ -961,9 +961,9 @@ static int aufs_setattr(struct dentry *dentry, struct iattr *ia)
  f = NULL;
  if (ia->ia_valid & ATTR_FILE)
  f = ia->ia_file;
- mutex_unlock(&a->h_inode->i_mutex);
+ inode_unlock(a->h_inode);
  err = vfsub_trunc(&a->h_path, ia->ia_size, ia->ia_valid, f);
- mutex_lock_nested(&a->h_inode->i_mutex, AuLsc_I_CHILD);
+ inode_lock_nested(a->h_inode, AuLsc_I_CHILD);
  } else {
  delegated = NULL;
  while (1) {
@@ -980,7 +980,7 @@ static int aufs_setattr(struct dentry *dentry, struct iattr *ia)
  au_cpup_attr_changeable(inode);
 
 out_unlock:
- mutex_unlock(&a->h_inode->i_mutex);
+ inode_unlock(a->h_inode);
  au_unpin(&a->pin);
  if (unlikely(err))
  au_update_dbstart(dentry);
@@ -1056,7 +1056,7 @@ ssize_t au_srxattr(struct dentry *dentry, struct au_srxattr *arg)
  if (unlikely(err))
  goto out_di;
 
- mutex_unlock(&a->h_inode->i_mutex);
+ inode_unlock(a->h_inode);
  switch (arg->type) {
  case AU_XATTR_SET:
  err = vfsub_setxattr(h_path.dentry,
diff --git a/fs/aufs/i_op_add.c b/fs/aufs/i_op_add.c
index 209b268641a6..9a83fe52c670 100644
--- a/fs/aufs/i_op_add.c
+++ b/fs/aufs/i_op_add.c
@@ -414,7 +414,7 @@ int aufs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
  };
 
  /* copy-up may happen */
- mutex_lock(&dir->i_mutex);
+ inode_lock(dir);
 
  sb = dir->i_sb;
  err = si_read_lock(sb, AuLock_FLUSH | AuLock_NOPLM);
@@ -511,7 +511,7 @@ out_parent:
 out_si:
  si_read_unlock(sb);
 out:
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
  return err;
 }
 
diff --git a/fs/aufs/inode.h b/fs/aufs/inode.h
index 34aebba64a22..dabaa351e0d7 100644
--- a/fs/aufs/inode.h
+++ b/fs/aufs/inode.h
@@ -664,21 +664,21 @@ static inline void au_hn_resume(struct au_hinode *hdir)
 
 static inline void au_hn_imtx_lock(struct au_hinode *hdir)
 {
- mutex_lock(&hdir->hi_inode->i_mutex);
+ inode_lock(hdir->hi_inode);
  au_hn_suspend(hdir);
 }
 
 static inline void au_hn_imtx_lock_nested(struct au_hinode *hdir,
   unsigned int sc __maybe_unused)
 {
- mutex_lock_nested(&hdir->hi_inode->i_mutex, sc);
+ inode_lock_nested(hdir->hi_inode, sc);
  au_hn_suspend(hdir);
 }
 
 static inline void au_hn_imtx_unlock(struct au_hinode *hdir)
 {
  au_hn_resume(hdir);
- mutex_unlock(&hdir->hi_inode->i_mutex);
+ inode_unlock(hdir->hi_inode);
 }
 
 #endif /* __KERNEL__ */
diff --git a/fs/aufs/mvdown.c b/fs/aufs/mvdown.c
index fbef056b40e1..e33677bd1b3b 100644
--- a/fs/aufs/mvdown.c
+++ b/fs/aufs/mvdown.c
@@ -658,14 +658,14 @@ int au_mvdown(struct dentry *dentry, struct aufs_mvdown __user *uarg)
  dmsg = !!(args->mvdown.flags & AUFS_MVDOWN_DMSG);
  args->parent = dget_parent(dentry);
  args->dir = d_inode(args->parent);
- mutex_lock_nested(&args->dir->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(args->dir, I_MUTEX_PARENT);
  dput(args->parent);
  if (unlikely(args->parent != dentry->d_parent)) {
  AU_MVD_PR(dmsg, "parent dir is moved\n");
  goto out_dir;
  }
 
- mutex_lock_nested(&inode->i_mutex, I_MUTEX_CHILD);
+ inode_lock_nested(inode, I_MUTEX_CHILD);
  err = aufs_read_lock(dentry, AuLock_DW | AuLock_FLUSH | AuLock_NOPLMW);
  if (unlikely(err))
  goto out_inode;
@@ -689,9 +689,9 @@ out_parent:
  di_write_unlock(args->parent);
  aufs_read_unlock(dentry, AuLock_DW);
 out_inode:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 out_dir:
- mutex_unlock(&args->dir->i_mutex);
+ inode_unlock(args->dir);
 out_free:
  e = copy_to_user(uarg, &args->mvdown, sizeof(args->mvdown));
  if (unlikely(e))
diff --git a/fs/aufs/plink.c b/fs/aufs/plink.c
index 988fba94085c..e9403b1c411d 100644
--- a/fs/aufs/plink.c
+++ b/fs/aufs/plink.c
@@ -258,7 +258,7 @@ static int do_whplink(struct qstr *tgt, struct dentry *h_parent,
  struct inode *h_dir, *delegated;
 
  h_dir = d_inode(h_parent);
- mutex_lock_nested(&h_dir->i_mutex, AuLsc_I_CHILD2);
+ inode_lock_nested(h_dir, AuLsc_I_CHILD2);
 again:
  h_path.dentry = vfsub_lkup_one(tgt, h_parent);
  err = PTR_ERR(h_path.dentry);
@@ -294,7 +294,7 @@ again:
  dput(h_path.dentry);
 
 out:
- mutex_unlock(&h_dir->i_mutex);
+ inode_unlock(h_dir);
  return err;
 }
 
diff --git a/fs/aufs/posix_acl.c b/fs/aufs/posix_acl.c
index d5266ef767e5..ab825becab2b 100644
--- a/fs/aufs/posix_acl.c
+++ b/fs/aufs/posix_acl.c
@@ -72,7 +72,7 @@ int aufs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
  },
  };
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  if (inode->i_ino == AUFS_ROOT_INO)
  dentry = dget(inode->i_sb->s_root);
  else {
@@ -94,6 +94,6 @@ int aufs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
  err = 0;
 
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return err;
 }
diff --git a/fs/aufs/rdu.c b/fs/aufs/rdu.c
index 3beba1806612..f8efc56cc3cc 100644
--- a/fs/aufs/rdu.c
+++ b/fs/aufs/rdu.c
@@ -159,7 +159,7 @@ static int au_rdu(struct file *file, struct aufs_rdu *rdu)
  dentry = file->f_path.dentry;
  inode = d_inode(dentry);
 #if 1
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 #else
  err = mutex_lock_killable(&inode->i_mutex);
  AuTraceErr(err);
@@ -222,7 +222,7 @@ out_unlock:
 out_si:
  si_read_unlock(arg.sb);
 out_mtx:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 out:
  AuTraceErr(err);
  return err;
diff --git a/fs/aufs/super.c b/fs/aufs/super.c
index 42d145ceefe4..33afa93de9c5 100644
--- a/fs/aufs/super.c
+++ b/fs/aufs/super.c
@@ -804,7 +804,7 @@ static int aufs_remount_fs(struct super_block *sb, int *flags, char *data)
 
  sbinfo = au_sbi(sb);
  inode = d_inode(root);
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  err = si_write_lock(sb, AuLock_FLUSH | AuLock_NOPLM);
  if (unlikely(err))
  goto out_mtx;
@@ -827,7 +827,7 @@ static int aufs_remount_fs(struct super_block *sb, int *flags, char *data)
  aufs_write_unlock(root);
 
 out_mtx:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 out_opts:
  free_page((unsigned long)opts.opt);
 out:
@@ -949,7 +949,7 @@ static int aufs_fill_super(struct super_block *sb, void *raw_data,
  goto out_root;
 
  /* lock vfs_inode first, then aufs. */
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  aufs_write_lock(root);
  err = au_opts_mount(sb, &opts);
  au_opts_free(&opts);
@@ -961,7 +961,7 @@ static int aufs_fill_super(struct super_block *sb, void *raw_data,
  au_refresh_iop(inode, /*force_getattr*/0);
  }
  aufs_write_unlock(root);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  if (!err)
  goto out_opts; /* success */
 
diff --git a/fs/aufs/wbr_policy.c b/fs/aufs/wbr_policy.c
index 3949efb50dce..0df39fd8a993 100644
--- a/fs/aufs/wbr_policy.c
+++ b/fs/aufs/wbr_policy.c
@@ -140,17 +140,17 @@ static int au_cpdown_dir(struct dentry *dentry, aufs_bindex_t bdst,
  if (!au_ftest_cpdown(*flags, PARENT_OPQ) && bopq <= bdst)
  au_fset_cpdown(*flags, PARENT_OPQ);
  h_inode = d_inode(h_path.dentry);
- mutex_lock_nested(&h_inode->i_mutex, AuLsc_I_CHILD);
+ inode_lock_nested(h_inode, AuLsc_I_CHILD);
  if (au_ftest_cpdown(*flags, WHED)) {
  err = au_cpdown_dir_opq(dentry, bdst, flags);
  if (unlikely(err)) {
- mutex_unlock(&h_inode->i_mutex);
+ inode_unlock(h_inode);
  goto out_dir;
  }
  }
 
  err = au_cpdown_attr(&h_path, au_h_dptr(dentry, bstart));
- mutex_unlock(&h_inode->i_mutex);
+ inode_unlock(h_inode);
  if (unlikely(err))
  goto out_opq;
 
@@ -171,9 +171,9 @@ static int au_cpdown_dir(struct dentry *dentry, aufs_bindex_t bdst,
  /* revert */
 out_opq:
  if (au_ftest_cpdown(*flags, DIROPQ)) {
- mutex_lock_nested(&h_inode->i_mutex, AuLsc_I_CHILD);
+ inode_lock_nested(h_inode, AuLsc_I_CHILD);
  rerr = au_diropq_remove(dentry, bdst);
- mutex_unlock(&h_inode->i_mutex);
+ inode_unlock(h_inode);
  if (unlikely(rerr)) {
  AuIOErr("failed removing diropq for %pd b%d (%d)\n",
  dentry, bdst, rerr);
diff --git a/fs/aufs/whout.c b/fs/aufs/whout.c
index d244a6ac9ce5..4e6d0c272e49 100644
--- a/fs/aufs/whout.c
+++ b/fs/aufs/whout.c
@@ -942,7 +942,7 @@ int au_whtmp_rmdir(struct inode *dir, aufs_bindex_t bindex,
 
  br = au_sbr(dir->i_sb, bindex);
  wh_inode = d_inode(wh_dentry);
- mutex_lock_nested(&wh_inode->i_mutex, AuLsc_I_CHILD);
+ inode_lock_nested(wh_inode, AuLsc_I_CHILD);
 
  /*
  * someone else might change some whiteouts while we were sleeping.
@@ -964,7 +964,7 @@ int au_whtmp_rmdir(struct inode *dir, aufs_bindex_t bindex,
  if (unlikely(wkq_err))
  err = wkq_err;
  }
- mutex_unlock(&wh_inode->i_mutex);
+ inode_unlock(wh_inode);
 
  if (!err) {
  h_tmp.dentry = wh_dentry;
@@ -1000,7 +1000,7 @@ static void call_rmdir_whtmp(void *args)
  struct au_hinode *hdir;
 
  /* rmdir by nfsd may cause deadlock with this i_mutex */
- /* mutex_lock(&a->dir->i_mutex); */
+ /* inode_lock(a->dir); */
  err = -EROFS;
  sb = a->dir->i_sb;
  si_read_lock(sb, !AuLock_FLUSH);
@@ -1030,7 +1030,7 @@ out_mnt:
  dput(h_parent);
  ii_write_unlock(a->dir);
 out:
- /* mutex_unlock(&a->dir->i_mutex); */
+ /* inode_unlock(a->dir); */
  au_whtmp_rmdir_free(a);
  si_read_unlock(sb);
  au_nwt_done(&au_sbi(sb)->si_nowait);
diff --git a/fs/aufs/xattr.c b/fs/aufs/xattr.c
index b7e13ca3ecc6..466888784704 100644
--- a/fs/aufs/xattr.c
+++ b/fs/aufs/xattr.c
@@ -88,9 +88,9 @@ static int au_do_cpup_xattr(struct dentry *h_dst, struct dentry *h_src,
 
  /* unlock it temporary */
  h_idst = d_inode(h_dst);
- mutex_unlock(&h_idst->i_mutex);
+ inode_unlock(h_idst);
  err = vfsub_setxattr(h_dst, name, *buf, ssz, /*flags*/0);
- mutex_lock_nested(&h_idst->i_mutex, AuLsc_I_CHILD2);
+ inode_lock_nested(h_idst, AuLsc_I_CHILD2);
  if (unlikely(err)) {
  if (verbose || au_debug_test())
  pr_err("%s, err %d\n", name, err);
@@ -113,9 +113,9 @@ int au_cpup_xattr(struct dentry *h_dst, struct dentry *h_src, int ignore_flags,
  /* there should not be the parent-child relationship between them */
  h_isrc = d_inode(h_src);
  h_idst = d_inode(h_dst);
- mutex_unlock(&h_idst->i_mutex);
- mutex_lock_nested(&h_isrc->i_mutex, AuLsc_I_CHILD);
- mutex_lock_nested(&h_idst->i_mutex, AuLsc_I_CHILD2);
+ inode_unlock(h_idst);
+ inode_lock_nested(h_isrc, AuLsc_I_CHILD);
+ inode_lock_nested(h_idst, AuLsc_I_CHILD2);
  unlocked = 0;
 
  /* some filesystems don't list POSIX ACL, for example tmpfs */
@@ -140,7 +140,7 @@ int au_cpup_xattr(struct dentry *h_dst, struct dentry *h_src, int ignore_flags,
  goto out;
  err = vfs_listxattr(h_src, p, ssz);
  }
- mutex_unlock(&h_isrc->i_mutex);
+ inode_unlock(h_isrc);
  unlocked = 1;
  AuDbg("err %d, ssz %zd\n", err, ssz);
  if (unlikely(err < 0))
@@ -182,7 +182,7 @@ out_free:
  kfree(o);
 out:
  if (!unlocked)
- mutex_unlock(&h_isrc->i_mutex);
+ inode_unlock(h_isrc);
  AuTraceErr(err);
  return err;
 }
diff --git a/fs/aufs/xino.c b/fs/aufs/xino.c
index e3cab07bb5a4..36799d203f07 100644
--- a/fs/aufs/xino.c
+++ b/fs/aufs/xino.c
@@ -773,13 +773,13 @@ struct file *au_xino_create(struct super_block *sb, char *fname, int silent)
  inode = file_inode(file);
  h_parent = dget_parent(file->f_path.dentry);
  h_dir = d_inode(h_parent);
- mutex_lock_nested(&h_dir->i_mutex, AuLsc_I_PARENT);
+ inode_lock_nested(h_dir, AuLsc_I_PARENT);
  /* mnt_want_write() is unnecessary here */
  /* no delegation since it is just created */
  if (inode->i_nlink)
  err = vfsub_unlink(h_dir, &file->f_path, /*delegated*/NULL,
    /*force*/0);
- mutex_unlock(&h_dir->i_mutex);
+ inode_unlock(h_dir);
  dput(h_parent);
  if (unlikely(err)) {
  if (!silent)
@@ -1214,14 +1214,14 @@ int au_xino_set(struct super_block *sb, struct au_opt_xino *xino, int remount)
 
  au_opt_set(sbinfo->si_mntflags, XINO);
  dir = d_inode(parent);
- mutex_lock_nested(&dir->i_mutex, AuLsc_I_PARENT);
+ inode_lock_nested(dir, AuLsc_I_PARENT);
  /* mnt_want_write() is unnecessary here */
  err = au_xino_set_xib(sb, xino->file);
  if (!err)
  err = au_xigen_set(sb, xino->file);
  if (!err)
  err = au_xino_set_br(sb, xino->file);
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
  if (!err)
  goto out; /* success */
 
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 78f005f37847..3a3ced779fc7 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -638,11 +638,11 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
  case 3:
  /* Delete this handler. */
  root = dget(file->f_path.dentry->d_sb->s_root);
- mutex_lock(&d_inode(root)->i_mutex);
+ inode_lock(d_inode(root));
 
  kill_node(e);
 
- mutex_unlock(&d_inode(root)->i_mutex);
+ inode_unlock(d_inode(root));
  dput(root);
  break;
  default:
@@ -675,7 +675,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
  return PTR_ERR(e);
 
  root = dget(sb->s_root);
- mutex_lock(&d_inode(root)->i_mutex);
+ inode_lock(d_inode(root));
  dentry = lookup_one_len(e->name, root, strlen(e->name));
  err = PTR_ERR(dentry);
  if (IS_ERR(dentry))
@@ -711,7 +711,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
 out2:
  dput(dentry);
 out:
- mutex_unlock(&d_inode(root)->i_mutex);
+ inode_unlock(d_inode(root));
  dput(root);
 
  if (err) {
@@ -754,12 +754,12 @@ static ssize_t bm_status_write(struct file *file, const char __user *buffer,
  case 3:
  /* Delete all handlers. */
  root = dget(file->f_path.dentry->d_sb->s_root);
- mutex_lock(&d_inode(root)->i_mutex);
+ inode_lock(d_inode(root));
 
  while (!list_empty(&entries))
  kill_node(list_entry(entries.next, Node, list));
 
- mutex_unlock(&d_inode(root)->i_mutex);
+ inode_unlock(d_inode(root));
  dput(root);
  break;
  default:
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 5785132fdaf1..2c4e071dd41a 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -340,9 +340,9 @@ static loff_t block_llseek(struct file *file, loff_t offset, int whence)
  struct inode *bd_inode = file->f_mapping->host;
  loff_t retval;
 
- mutex_lock(&bd_inode->i_mutex);
+ inode_lock(bd_inode);
  retval = fixed_size_llseek(file, offset, whence, i_size_read(bd_inode));
- mutex_unlock(&bd_inode->i_mutex);
+ inode_unlock(bd_inode);
  return retval;
 }
 
@@ -1173,9 +1173,9 @@ void bd_set_size(struct block_device *bdev, loff_t size)
 {
  unsigned bsize = bdev_logical_block_size(bdev);
 
- mutex_lock(&bdev->bd_inode->i_mutex);
+ inode_lock(bdev->bd_inode);
  i_size_write(bdev->bd_inode, size);
- mutex_unlock(&bdev->bd_inode->i_mutex);
+ inode_unlock(bdev->bd_inode);
  while (bsize < PAGE_CACHE_SIZE) {
  if (size & bsize)
  break;
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index e2e8666455cb..1d22fd74968d 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1761,17 +1761,17 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
  loff_t pos;
  size_t count;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  err = generic_write_checks(iocb, from);
  if (err <= 0) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return err;
  }
 
  current->backing_dev_info = inode_to_bdi(inode);
  err = file_remove_privs(file);
  if (err) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  goto out;
  }
 
@@ -1782,7 +1782,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
  * to stop this write operation to ensure FS consistency.
  */
  if (test_bit(BTRFS_FS_STATE_ERROR, &root->fs_info->fs_state)) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  err = -EROFS;
  goto out;
  }
@@ -1803,7 +1803,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
  end_pos = round_up(pos + count, root->sectorsize);
  err = btrfs_cont_expand(inode, i_size_read(inode), end_pos);
  if (err) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  goto out;
  }
  }
@@ -1819,7 +1819,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
  iocb->ki_pos = pos + num_written;
  }
 
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  /*
  * We also have to set last_sub_trans to the current log transid,
@@ -1908,7 +1908,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
  if (ret)
  return ret;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  atomic_inc(&root->log_batch);
  full_sync = test_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
      &BTRFS_I(inode)->runtime_flags);
@@ -1960,7 +1960,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
  ret = start_ordered_ops(inode, start, end);
  }
  if (ret) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  goto out;
  }
  atomic_inc(&root->log_batch);
@@ -2006,7 +2006,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
  */
  clear_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
   &BTRFS_I(inode)->runtime_flags);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  goto out;
  }
 
@@ -2030,7 +2030,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
  trans = btrfs_start_transaction(root, 0);
  if (IS_ERR(trans)) {
  ret = PTR_ERR(trans);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  goto out;
  }
  trans->sync = true;
@@ -2053,7 +2053,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
  * file again, but that will end up using the synchronization
  * inside btrfs_sync_log to keep things safe.
  */
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  /*
  * If any of the ordered extents had an error, just return it to user
@@ -2302,7 +2302,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
  if (ret)
  return ret;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  ino_size = round_up(inode->i_size, PAGE_CACHE_SIZE);
  ret = find_first_non_hole(inode, &offset, &len);
  if (ret < 0)
@@ -2342,7 +2342,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
  truncated_page = true;
  ret = btrfs_truncate_page(inode, offset, 0, 0);
  if (ret) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
  }
  }
@@ -2418,7 +2418,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
  ret = btrfs_wait_ordered_range(inode, lockstart,
        lockend - lockstart + 1);
  if (ret) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
  }
  }
@@ -2573,7 +2573,7 @@ out_only_mutex:
  ret = btrfs_end_transaction(trans, root);
  }
  }
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  if (ret && !err)
  err = ret;
  return err;
@@ -2657,7 +2657,7 @@ static long btrfs_fallocate(struct file *file, int mode,
  if (ret < 0)
  return ret;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  ret = inode_newsize_ok(inode, alloc_end);
  if (ret)
  goto out;
@@ -2815,7 +2815,7 @@ out:
  * So this is completely used as cleanup.
  */
  btrfs_qgroup_free_data(inode, alloc_start, alloc_end - alloc_start);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  /* Let go of our reservation. */
  btrfs_free_reserved_data_space(inode, alloc_start,
        alloc_end - alloc_start);
@@ -2891,7 +2891,7 @@ static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int whence)
  struct inode *inode = file->f_mapping->host;
  int ret;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  switch (whence) {
  case SEEK_END:
  case SEEK_CUR:
@@ -2900,20 +2900,20 @@ static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int whence)
  case SEEK_DATA:
  case SEEK_HOLE:
  if (offset >= i_size_read(inode)) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return -ENXIO;
  }
 
  ret = find_desired_extent(inode, &offset, whence);
  if (ret) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
  }
  }
 
  offset = vfs_setpos(file, offset, inode->i_sb->s_maxbytes);
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return offset;
 }
 
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 579bf50cf74f..5410f33fae28 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8493,7 +8493,7 @@ static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
  * not unlock the i_mutex at this case.
  */
  if (offset + count <= inode->i_size) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  relock = true;
  }
  ret = btrfs_delalloc_reserve_space(inode, offset, count);
@@ -8535,7 +8535,7 @@ out:
  if (wakeup)
  inode_dio_end(inode);
  if (relock)
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  return ret;
 }
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 70ee7c628012..b161de63b239 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -240,7 +240,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
  if (ret)
  return ret;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  ip_oldflags = ip->flags;
  i_oldflags = inode->i_flags;
@@ -358,7 +358,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
  }
 
  out_unlock:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  mnt_drop_write_file(file);
  return ret;
 }
@@ -872,7 +872,7 @@ out_up_read:
 out_dput:
  dput(dentry);
 out_unlock:
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
  return error;
 }
 
@@ -1384,18 +1384,18 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
  ra_index += cluster;
  }
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  if (range->flags & BTRFS_DEFRAG_RANGE_COMPRESS)
  BTRFS_I(inode)->force_compress = compress_type;
  ret = cluster_pages_for_defrag(inode, pages, i, cluster);
  if (ret < 0) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  goto out_ra;
  }
 
  defrag_count += ret;
  balance_dirty_pages_ratelimited(inode->i_mapping);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  if (newer_than) {
  if (newer_off == (u64)-1)
@@ -1457,9 +1457,9 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
 
 out_ra:
  if (range->flags & BTRFS_DEFRAG_RANGE_COMPRESS) {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  BTRFS_I(inode)->force_compress = BTRFS_COMPRESS_NONE;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
  if (!file)
  kfree(ra);
@@ -2434,7 +2434,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
  goto out_dput;
  }
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  /*
  * Don't allow to delete a subvolume with send in progress. This is
@@ -2547,7 +2547,7 @@ out_up_write:
  spin_unlock(&dest->root_item_lock);
  }
 out_unlock_inode:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  if (!err) {
  d_invalidate(dentry);
  btrfs_invalidate_inodes(dest);
@@ -2563,7 +2563,7 @@ out_unlock_inode:
 out_dput:
  dput(dentry);
 out_unlock_dir:
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
 out_drop_write:
  mnt_drop_write_file(file);
 out:
@@ -2883,8 +2883,8 @@ static int lock_extent_range(struct inode *inode, u64 off, u64 len,
 
 static void btrfs_double_inode_unlock(struct inode *inode1, struct inode *inode2)
 {
- mutex_unlock(&inode1->i_mutex);
- mutex_unlock(&inode2->i_mutex);
+ inode_unlock(inode1);
+ inode_unlock(inode2);
 }
 
 static void btrfs_double_inode_lock(struct inode *inode1, struct inode *inode2)
@@ -2892,8 +2892,8 @@ static void btrfs_double_inode_lock(struct inode *inode1, struct inode *inode2)
  if (inode1 < inode2)
  swap(inode1, inode2);
 
- mutex_lock_nested(&inode1->i_mutex, I_MUTEX_PARENT);
- mutex_lock_nested(&inode2->i_mutex, I_MUTEX_CHILD);
+ inode_lock_nested(inode1, I_MUTEX_PARENT);
+ inode_lock_nested(inode2, I_MUTEX_CHILD);
 }
 
 static void btrfs_double_extent_unlock(struct inode *inode1, u64 loff1,
@@ -3067,7 +3067,7 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
  return 0;
 
  if (same_inode) {
- mutex_lock(&src->i_mutex);
+ inode_lock(src);
 
  ret = extent_same_check_offsets(src, loff, &len, olen);
  if (ret)
@@ -3174,7 +3174,7 @@ again:
  btrfs_cmp_data_free(&cmp);
 out_unlock:
  if (same_inode)
- mutex_unlock(&src->i_mutex);
+ inode_unlock(src);
  else
  btrfs_double_inode_unlock(src, dst);
 
@@ -3939,7 +3939,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
  if (!same_inode) {
  btrfs_double_inode_lock(src, inode);
  } else {
- mutex_lock(&src->i_mutex);
+ inode_lock(src);
  }
 
  /* determine range to clone */
@@ -4016,7 +4016,7 @@ out_unlock:
  if (!same_inode)
  btrfs_double_inode_unlock(src, inode);
  else
- mutex_unlock(&src->i_mutex);
+ inode_unlock(src);
 out_fput:
  fdput(src_file);
 out_drop_write:
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 9ebe027cc4b7..f35eec5b4ff8 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -3045,7 +3045,7 @@ int prealloc_file_extent_cluster(struct inode *inode,
  int ret = 0;
 
  BUG_ON(cluster->start != cluster->boundary[0]);
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  ret = btrfs_check_data_free_space(inode, cluster->start,
   cluster->end + 1 - cluster->start);
@@ -3072,7 +3072,7 @@ int prealloc_file_extent_cluster(struct inode *inode,
  btrfs_free_reserved_data_space(inode, cluster->start,
        cluster->end + 1 - cluster->start);
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
 
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index b091d94ceef6..65cdebbebfb2 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -4281,7 +4281,7 @@ static int copy_nocow_pages_for_inode(u64 inum, u64 offset, u64 root,
  return PTR_ERR(inode);
 
  /* Avoid truncate/dio/punch hole.. */
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  inode_dio_wait(inode);
 
  physical_for_dev_replace = nocow_ctx->physical_for_dev_replace;
@@ -4360,7 +4360,7 @@ next_page:
  }
  ret = COPY_COMPLETE;
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  iput(inode);
  return ret;
 }
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
index 1fcd7b6e7564..e25508ffa2ee 100644
--- a/fs/btrfs/xattr.c
+++ b/fs/btrfs/xattr.c
@@ -126,7 +126,7 @@ static int do_setxattr(struct btrfs_trans_handle *trans,
  * locks the inode's i_mutex before calling setxattr or removexattr.
  */
  if (flags & XATTR_REPLACE) {
- ASSERT(mutex_is_locked(&inode->i_mutex));
+ ASSERT(inode_is_locked(inode));
  di = btrfs_lookup_xattr(NULL, root, path, btrfs_ino(inode),
  name, name_len, 0);
  if (!di)
diff --git a/fs/cachefiles/interface.c b/fs/cachefiles/interface.c
index afa023dded5b..675a3332d72f 100644
--- a/fs/cachefiles/interface.c
+++ b/fs/cachefiles/interface.c
@@ -446,7 +446,7 @@ static int cachefiles_attr_changed(struct fscache_object *_object)
  return 0;
 
  cachefiles_begin_secure(cache, &saved_cred);
- mutex_lock(&d_inode(object->backer)->i_mutex);
+ inode_lock(d_inode(object->backer));
 
  /* if there's an extension to a partial page at the end of the backing
  * file, we need to discard the partial page so that we pick up new
@@ -465,7 +465,7 @@ static int cachefiles_attr_changed(struct fscache_object *_object)
  ret = notify_change(object->backer, &newattrs, NULL);
 
 truncate_failed:
- mutex_unlock(&d_inode(object->backer)->i_mutex);
+ inode_unlock(d_inode(object->backer));
  cachefiles_end_secure(cache, saved_cred);
 
  if (ret == -EIO) {
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
index c4b893453e0e..1c2334c163dd 100644
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -295,7 +295,7 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache,
  cachefiles_mark_object_buried(cache, rep, why);
  }
 
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
 
  if (ret == -EIO)
  cachefiles_io_error(cache, "Unlink failed");
@@ -306,7 +306,7 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache,
 
  /* directories have to be moved to the graveyard */
  _debug("move stale object to graveyard");
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
 
 try_again:
  /* first step is to make up a grave dentry in the graveyard */
@@ -423,13 +423,13 @@ int cachefiles_delete_object(struct cachefiles_cache *cache,
 
  dir = dget_parent(object->dentry);
 
- mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(d_inode(dir), I_MUTEX_PARENT);
 
  if (test_bit(FSCACHE_OBJECT_KILLED_BY_CACHE, &object->fscache.flags)) {
  /* object allocation for the same key preemptively deleted this
  * object's file so that it could create its own file */
  _debug("object preemptively buried");
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
  ret = 0;
  } else {
  /* we need to check that our parent is _still_ our parent - it
@@ -442,7 +442,7 @@ int cachefiles_delete_object(struct cachefiles_cache *cache,
  /* it got moved, presumably by cachefilesd culling it,
  * so it's no longer in the key path and we can ignore
  * it */
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
  ret = 0;
  }
  }
@@ -501,7 +501,7 @@ lookup_again:
  /* search the current directory for the element name */
  _debug("lookup '%s'", name);
 
- mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(d_inode(dir), I_MUTEX_PARENT);
 
  start = jiffies;
  next = lookup_one_len(name, dir, nlen);
@@ -585,7 +585,7 @@ lookup_again:
  /* process the next component */
  if (key) {
  _debug("advance");
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
  dput(dir);
  dir = next;
  next = NULL;
@@ -623,7 +623,7 @@ lookup_again:
  /* note that we're now using this object */
  ret = cachefiles_mark_object_active(cache, object);
 
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
  dput(dir);
  dir = NULL;
 
@@ -705,7 +705,7 @@ lookup_error:
  cachefiles_io_error(cache, "Lookup failed");
  next = NULL;
 error:
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
  dput(next);
 error_out2:
  dput(dir);
@@ -729,7 +729,7 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache,
  _enter(",,%s", dirname);
 
  /* search the current directory for the element name */
- mutex_lock(&d_inode(dir)->i_mutex);
+ inode_lock(d_inode(dir));
 
  start = jiffies;
  subdir = lookup_one_len(dirname, dir, strlen(dirname));
@@ -768,7 +768,7 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache,
        d_backing_inode(subdir)->i_ino);
  }
 
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
 
  /* we need to make sure the subdir is a directory */
  ASSERT(d_backing_inode(subdir));
@@ -800,19 +800,19 @@ check_error:
  return ERR_PTR(ret);
 
 mkdir_error:
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
  dput(subdir);
  pr_err("mkdir %s failed with error %d\n", dirname, ret);
  return ERR_PTR(ret);
 
 lookup_error:
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
  ret = PTR_ERR(subdir);
  pr_err("Lookup %s failed with error %d\n", dirname, ret);
  return ERR_PTR(ret);
 
 nomem_d_alloc:
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
  _leave(" = -ENOMEM");
  return ERR_PTR(-ENOMEM);
 }
@@ -837,7 +837,7 @@ static struct dentry *cachefiles_check_active(struct cachefiles_cache *cache,
  //       dir, filename);
 
  /* look up the victim */
- mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(d_inode(dir), I_MUTEX_PARENT);
 
  start = jiffies;
  victim = lookup_one_len(filename, dir, strlen(filename));
@@ -852,7 +852,7 @@ static struct dentry *cachefiles_check_active(struct cachefiles_cache *cache,
  * at the netfs's request whilst the cull was in progress
  */
  if (d_is_negative(victim)) {
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
  dput(victim);
  _leave(" = -ENOENT [absent]");
  return ERR_PTR(-ENOENT);
@@ -881,13 +881,13 @@ static struct dentry *cachefiles_check_active(struct cachefiles_cache *cache,
 
 object_in_use:
  read_unlock(&cache->active_lock);
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
  dput(victim);
  //_leave(" = -EBUSY [in use]");
  return ERR_PTR(-EBUSY);
 
 lookup_error:
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
  ret = PTR_ERR(victim);
  if (ret == -ENOENT) {
  /* file or dir now absent - probably retired by netfs */
@@ -947,7 +947,7 @@ int cachefiles_cull(struct cachefiles_cache *cache, struct dentry *dir,
  return 0;
 
 error_unlock:
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
 error:
  dput(victim);
  if (ret == -ENOENT) {
@@ -982,7 +982,7 @@ int cachefiles_check_in_use(struct cachefiles_cache *cache, struct dentry *dir,
  if (IS_ERR(victim))
  return PTR_ERR(victim);
 
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
  dput(victim);
  //_leave(" = 0");
  return 0;
diff --git a/fs/ceph/cache.c b/fs/ceph/cache.c
index ff1cfd7b1083..cab47fb68226 100644
--- a/fs/ceph/cache.c
+++ b/fs/ceph/cache.c
@@ -197,7 +197,7 @@ void ceph_fscache_register_inode_cookie(struct ceph_fs_client* fsc,
  return;
 
  /* Avoid multiple racing open requests */
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  if (ci->fscache)
  goto done;
@@ -207,7 +207,7 @@ void ceph_fscache_register_inode_cookie(struct ceph_fs_client* fsc,
      ci, true);
  fscache_check_consistency(ci->fscache);
 done:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
 }
 
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 0e3de1bb6500..e3e64ed59629 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2033,7 +2033,7 @@ int ceph_fsync(struct file *file, loff_t start, loff_t end, int datasync)
  if (datasync)
  goto out;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  dirty = try_flush_caps(inode, &flush_tid);
  dout("fsync dirty caps are %s\n", ceph_cap_string(dirty));
@@ -2049,7 +2049,7 @@ int ceph_fsync(struct file *file, loff_t start, loff_t end, int datasync)
  ret = wait_event_interruptible(ci->i_cap_wq,
  caps_are_flushed(inode, flush_tid));
  }
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 out:
  dout("fsync %p%s result=%d\n", inode, datasync ? " datasync" : "", ret);
  return ret;
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index be7d187d53fd..297e7eb5d0f9 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -512,7 +512,7 @@ static loff_t ceph_dir_llseek(struct file *file, loff_t offset, int whence)
  loff_t old_offset = ceph_make_fpos(fi->frag, fi->next_offset);
  loff_t retval;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  retval = -EINVAL;
  switch (whence) {
  case SEEK_CUR:
@@ -547,7 +547,7 @@ static loff_t ceph_dir_llseek(struct file *file, loff_t offset, int whence)
  }
  }
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return retval;
 }
 
diff --git a/fs/ceph/export.c b/fs/ceph/export.c
index fe02ae7f056a..3b3172357326 100644
--- a/fs/ceph/export.c
+++ b/fs/ceph/export.c
@@ -215,7 +215,7 @@ static int ceph_get_name(struct dentry *parent, char *name,
  if (IS_ERR(req))
  return PTR_ERR(req);
 
- mutex_lock(&d_inode(parent)->i_mutex);
+ inode_lock(d_inode(parent));
 
  req->r_inode = d_inode(child);
  ihold(d_inode(child));
@@ -224,7 +224,7 @@ static int ceph_get_name(struct dentry *parent, char *name,
  req->r_num_caps = 2;
  err = ceph_mdsc_do_request(mdsc, NULL, req);
 
- mutex_unlock(&d_inode(parent)->i_mutex);
+ inode_unlock(d_inode(parent));
 
  if (!err) {
  struct ceph_mds_reply_info_parsed *rinfo = &req->r_reply_info;
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index c8222bfe1e56..cd596779aa80 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -1015,7 +1015,7 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from)
  if (!prealloc_cf)
  return -ENOMEM;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  /* We can write back this queue in page reclaim */
  current->backing_dev_info = inode_to_bdi(inode);
@@ -1071,7 +1071,7 @@ retry_snap:
     (iocb->ki_flags & IOCB_DIRECT) || (fi->flags & CEPH_F_SYNC)) {
  struct ceph_snap_context *snapc;
  struct iov_iter data;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  spin_lock(&ci->i_ceph_lock);
  if (__ceph_have_pending_cap_snap(ci)) {
@@ -1098,7 +1098,7 @@ retry_snap:
  "got EOLDSNAPC, retrying\n",
  inode, ceph_vinop(inode),
  pos, (unsigned)count);
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  goto retry_snap;
  }
  if (written > 0)
@@ -1118,7 +1118,7 @@ retry_snap:
  iocb->ki_pos = pos + written;
  if (inode->i_size > old_size)
  ceph_fscache_update_objectsize(inode);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
 
  if (written >= 0) {
@@ -1148,7 +1148,7 @@ retry_snap:
  goto out_unlocked;
 
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 out_unlocked:
  ceph_free_cap_flush(prealloc_cf);
  current->backing_dev_info = NULL;
@@ -1163,7 +1163,7 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int whence)
  struct inode *inode = file->f_mapping->host;
  int ret;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  if (whence == SEEK_END || whence == SEEK_DATA || whence == SEEK_HOLE) {
  ret = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE, false);
@@ -1208,7 +1208,7 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int whence)
  offset = vfs_setpos(file, offset, inode->i_sb->s_maxbytes);
 
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return offset;
 }
 
@@ -1364,7 +1364,7 @@ static long ceph_fallocate(struct file *file, int mode,
  if (!prealloc_cf)
  return -ENOMEM;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  if (ceph_snap(inode) != CEPH_NOSNAP) {
  ret = -EROFS;
@@ -1419,7 +1419,7 @@ static long ceph_fallocate(struct file *file, int mode,
 
  ceph_put_cap_refs(ci, got);
 unlock:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  ceph_free_cap_flush(prealloc_cf);
  return ret;
 }
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 10c8c9b8b5df..4a95fc209423 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -642,9 +642,9 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)
  while (*s && *s != sep)
  s++;
 
- mutex_lock(&dir->i_mutex);
+ inode_lock(dir);
  child = lookup_one_len(p, dentry, s - p);
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
  dput(dentry);
  dentry = child;
  } while (!IS_ERR(dentry));
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 9d86b3228c27..29f1e8fee2e6 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2284,7 +2284,7 @@ int cifs_strict_fsync(struct file *file, loff_t start, loff_t end,
  rc = filemap_write_and_wait_range(inode->i_mapping, start, end);
  if (rc)
  return rc;
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  xid = get_xid();
 
@@ -2309,7 +2309,7 @@ int cifs_strict_fsync(struct file *file, loff_t start, loff_t end,
  }
 
  free_xid(xid);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return rc;
 }
 
@@ -2326,7 +2326,7 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
  rc = filemap_write_and_wait_range(inode->i_mapping, start, end);
  if (rc)
  return rc;
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  xid = get_xid();
 
@@ -2343,7 +2343,7 @@ int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
  }
 
  free_xid(xid);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return rc;
 }
 
@@ -2689,7 +2689,7 @@ cifs_writev(struct kiocb *iocb, struct iov_iter *from)
  * with a brlock that prevents writing.
  */
  down_read(&cinode->lock_sem);
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  rc = generic_write_checks(iocb, from);
  if (rc <= 0)
@@ -2702,7 +2702,7 @@ cifs_writev(struct kiocb *iocb, struct iov_iter *from)
  else
  rc = -EACCES;
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  if (rc > 0) {
  ssize_t err = generic_write_sync(file, iocb->ki_pos - rc, rc);
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index fda9f4311212..42e731b8c80a 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -427,13 +427,13 @@ static int coda_readdir(struct file *coda_file, struct dir_context *ctx)
  if (host_file->f_op->iterate) {
  struct inode *host_inode = file_inode(host_file);
 
- mutex_lock(&host_inode->i_mutex);
+ inode_lock(host_inode);
  ret = -ENOENT;
  if (!IS_DEADDIR(host_inode)) {
  ret = host_file->f_op->iterate(host_file, ctx);
  file_accessed(host_file);
  }
- mutex_unlock(&host_inode->i_mutex);
+ inode_unlock(host_inode);
  return ret;
  }
  /* Venus: we must read Venus dirents from a file */
diff --git a/fs/coda/file.c b/fs/coda/file.c
index 1da3805f3ddc..f47c7483863b 100644
--- a/fs/coda/file.c
+++ b/fs/coda/file.c
@@ -71,12 +71,12 @@ coda_file_write_iter(struct kiocb *iocb, struct iov_iter *to)
 
  host_file = cfi->cfi_container;
  file_start_write(host_file);
- mutex_lock(&coda_inode->i_mutex);
+ inode_lock(coda_inode);
  ret = vfs_iter_write(cfi->cfi_container, to, &iocb->ki_pos);
  coda_inode->i_size = file_inode(host_file)->i_size;
  coda_inode->i_blocks = (coda_inode->i_size + 511) >> 9;
  coda_inode->i_mtime = coda_inode->i_ctime = CURRENT_TIME_SEC;
- mutex_unlock(&coda_inode->i_mutex);
+ inode_unlock(coda_inode);
  file_end_write(host_file);
  return ret;
 }
@@ -203,7 +203,7 @@ int coda_fsync(struct file *coda_file, loff_t start, loff_t end, int datasync)
  err = filemap_write_and_wait_range(coda_inode->i_mapping, start, end);
  if (err)
  return err;
- mutex_lock(&coda_inode->i_mutex);
+ inode_lock(coda_inode);
 
  cfi = CODA_FTOC(coda_file);
  BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
@@ -212,7 +212,7 @@ int coda_fsync(struct file *coda_file, loff_t start, loff_t end, int datasync)
  err = vfs_fsync(host_file, datasync);
  if (!err && !datasync)
  err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode));
- mutex_unlock(&coda_inode->i_mutex);
+ inode_unlock(coda_inode);
 
  return err;
 }
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index a7a1b218f308..6159bb94b01e 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -624,13 +624,13 @@ static void detach_groups(struct config_group *group)
 
  child = sd->s_dentry;
 
- mutex_lock(&d_inode(child)->i_mutex);
+ inode_lock(d_inode(child));
 
  configfs_detach_group(sd->s_element);
  d_inode(child)->i_flags |= S_DEAD;
  dont_mount(child);
 
- mutex_unlock(&d_inode(child)->i_mutex);
+ inode_unlock(d_inode(child));
 
  d_delete(child);
  dput(child);
@@ -818,11 +818,11 @@ static int configfs_attach_item(struct config_item *parent_item,
  * the VFS may already have hit and used them. Thus,
  * we must lock them as rmdir() would.
  */
- mutex_lock(&d_inode(dentry)->i_mutex);
+ inode_lock(d_inode(dentry));
  configfs_remove_dir(item);
  d_inode(dentry)->i_flags |= S_DEAD;
  dont_mount(dentry);
- mutex_unlock(&d_inode(dentry)->i_mutex);
+ inode_unlock(d_inode(dentry));
  d_delete(dentry);
  }
  }
@@ -858,7 +858,7 @@ static int configfs_attach_group(struct config_item *parent_item,
  * We must also lock the inode to remove it safely in case of
  * error, as rmdir() would.
  */
- mutex_lock_nested(&d_inode(dentry)->i_mutex, I_MUTEX_CHILD);
+ inode_lock_nested(d_inode(dentry), I_MUTEX_CHILD);
  configfs_adjust_dir_dirent_depth_before_populate(sd);
  ret = populate_groups(to_config_group(item));
  if (ret) {
@@ -867,7 +867,7 @@ static int configfs_attach_group(struct config_item *parent_item,
  dont_mount(dentry);
  }
  configfs_adjust_dir_dirent_depth_after_populate(sd);
- mutex_unlock(&d_inode(dentry)->i_mutex);
+ inode_unlock(d_inode(dentry));
  if (ret)
  d_delete(dentry);
  }
@@ -1075,7 +1075,7 @@ int configfs_depend_item(struct configfs_subsystem *subsys,
  * subsystem is really registered, and so we need to lock out
  * configfs_[un]register_subsystem().
  */
- mutex_lock(&d_inode(root)->i_mutex);
+ inode_lock(d_inode(root));
 
  root_sd = root->d_fsdata;
 
@@ -1111,7 +1111,7 @@ int configfs_depend_item(struct configfs_subsystem *subsys,
 out_unlock_dirent_lock:
  spin_unlock(&configfs_dirent_lock);
 out_unlock_fs:
- mutex_unlock(&d_inode(root)->i_mutex);
+ inode_unlock(d_inode(root));
 
  /*
  * If we succeeded, the fs is pinned via other methods.  If not,
@@ -1453,7 +1453,7 @@ int configfs_rename_dir(struct config_item * item, const char *new_name)
  down_write(&configfs_rename_sem);
  parent = item->parent->dentry;
 
- mutex_lock(&d_inode(parent)->i_mutex);
+ inode_lock(d_inode(parent));
 
  new_dentry = lookup_one_len(new_name, parent, strlen(new_name));
  if (!IS_ERR(new_dentry)) {
@@ -1469,7 +1469,7 @@ int configfs_rename_dir(struct config_item * item, const char *new_name)
  error = -EEXIST;
  dput(new_dentry);
  }
- mutex_unlock(&d_inode(parent)->i_mutex);
+ inode_unlock(d_inode(parent));
  up_write(&configfs_rename_sem);
 
  return error;
@@ -1482,7 +1482,7 @@ static int configfs_dir_open(struct inode *inode, struct file *file)
  struct configfs_dirent * parent_sd = dentry->d_fsdata;
  int err;
 
- mutex_lock(&d_inode(dentry)->i_mutex);
+ inode_lock(d_inode(dentry));
  /*
  * Fake invisibility if dir belongs to a group/default groups hierarchy
  * being attached
@@ -1495,7 +1495,7 @@ static int configfs_dir_open(struct inode *inode, struct file *file)
  else
  err = 0;
  }
- mutex_unlock(&d_inode(dentry)->i_mutex);
+ inode_unlock(d_inode(dentry));
 
  return err;
 }
@@ -1505,11 +1505,11 @@ static int configfs_dir_close(struct inode *inode, struct file *file)
  struct dentry * dentry = file->f_path.dentry;
  struct configfs_dirent * cursor = file->private_data;
 
- mutex_lock(&d_inode(dentry)->i_mutex);
+ inode_lock(d_inode(dentry));
  spin_lock(&configfs_dirent_lock);
  list_del_init(&cursor->s_sibling);
  spin_unlock(&configfs_dirent_lock);
- mutex_unlock(&d_inode(dentry)->i_mutex);
+ inode_unlock(d_inode(dentry));
 
  release_configfs_dirent(cursor);
 
@@ -1590,7 +1590,7 @@ static loff_t configfs_dir_lseek(struct file *file, loff_t offset, int whence)
 {
  struct dentry * dentry = file->f_path.dentry;
 
- mutex_lock(&d_inode(dentry)->i_mutex);
+ inode_lock(d_inode(dentry));
  switch (whence) {
  case 1:
  offset += file->f_pos;
@@ -1598,7 +1598,7 @@ static loff_t configfs_dir_lseek(struct file *file, loff_t offset, int whence)
  if (offset >= 0)
  break;
  default:
- mutex_unlock(&d_inode(dentry)->i_mutex);
+ inode_unlock(d_inode(dentry));
  return -EINVAL;
  }
  if (offset != file->f_pos) {
@@ -1624,7 +1624,7 @@ static loff_t configfs_dir_lseek(struct file *file, loff_t offset, int whence)
  spin_unlock(&configfs_dirent_lock);
  }
  }
- mutex_unlock(&d_inode(dentry)->i_mutex);
+ inode_unlock(d_inode(dentry));
  return offset;
 }
 
@@ -1659,14 +1659,14 @@ int configfs_register_group(struct config_group *parent_group,
 
  parent = parent_group->cg_item.ci_dentry;
 
- mutex_lock_nested(&d_inode(parent)->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(d_inode(parent), I_MUTEX_PARENT);
  ret = create_default_group(parent_group, group);
  if (!ret) {
  spin_lock(&configfs_dirent_lock);
  configfs_dir_set_ready(group->cg_item.ci_dentry->d_fsdata);
  spin_unlock(&configfs_dirent_lock);
  }
- mutex_unlock(&d_inode(parent)->i_mutex);
+ inode_unlock(d_inode(parent));
  return ret;
 }
 EXPORT_SYMBOL(configfs_register_group);
@@ -1683,7 +1683,7 @@ void configfs_unregister_group(struct config_group *group)
  struct dentry *dentry = group->cg_item.ci_dentry;
  struct dentry *parent = group->cg_item.ci_parent->ci_dentry;
 
- mutex_lock_nested(&d_inode(parent)->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(d_inode(parent), I_MUTEX_PARENT);
  spin_lock(&configfs_dirent_lock);
  configfs_detach_prep(dentry, NULL);
  spin_unlock(&configfs_dirent_lock);
@@ -1692,7 +1692,7 @@ void configfs_unregister_group(struct config_group *group)
  d_inode(dentry)->i_flags |= S_DEAD;
  dont_mount(dentry);
  d_delete(dentry);
- mutex_unlock(&d_inode(parent)->i_mutex);
+ inode_unlock(d_inode(parent));
 
  dput(dentry);
 
@@ -1764,7 +1764,7 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys)
  sd = root->d_fsdata;
  link_group(to_config_group(sd->s_element), group);
 
- mutex_lock_nested(&d_inode(root)->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(d_inode(root), I_MUTEX_PARENT);
 
  err = -ENOMEM;
  dentry = d_alloc_name(root, group->cg_item.ci_name);
@@ -1784,7 +1784,7 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys)
  }
  }
 
- mutex_unlock(&d_inode(root)->i_mutex);
+ inode_unlock(d_inode(root));
 
  if (err) {
  unlink_group(group);
@@ -1805,9 +1805,9 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys)
  return;
  }
 
- mutex_lock_nested(&d_inode(root)->i_mutex,
+ inode_lock_nested(d_inode(root),
   I_MUTEX_PARENT);
- mutex_lock_nested(&d_inode(dentry)->i_mutex, I_MUTEX_CHILD);
+ inode_lock_nested(d_inode(dentry), I_MUTEX_CHILD);
  mutex_lock(&configfs_symlink_mutex);
  spin_lock(&configfs_dirent_lock);
  if (configfs_detach_prep(dentry, NULL)) {
@@ -1818,11 +1818,11 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys)
  configfs_detach_group(&group->cg_item);
  d_inode(dentry)->i_flags |= S_DEAD;
  dont_mount(dentry);
- mutex_unlock(&d_inode(dentry)->i_mutex);
+ inode_unlock(d_inode(dentry));
 
  d_delete(dentry);
 
- mutex_unlock(&d_inode(root)->i_mutex);
+ inode_unlock(d_inode(root));
 
  dput(dentry);
 
diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index d39099ea7df7..d034a26f7e02 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -324,10 +324,10 @@ int configfs_create_file(struct config_item * item, const struct configfs_attrib
  umode_t mode = (attr->ca_mode & S_IALLUGO) | S_IFREG;
  int error = 0;
 
- mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_NORMAL);
+ inode_lock_nested(d_inode(dir), I_MUTEX_NORMAL);
  error = configfs_make_dirent(parent_sd, NULL, (void *) attr, mode,
      CONFIGFS_ITEM_ATTR);
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
 
  return error;
 }
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index eae87575e681..2e2ffceeb281 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -255,7 +255,7 @@ void configfs_hash_and_remove(struct dentry * dir, const char * name)
  /* no inode means this hasn't been made visible yet */
  return;
 
- mutex_lock(&d_inode(dir)->i_mutex);
+ inode_lock(d_inode(dir));
  list_for_each_entry(sd, &parent_sd->s_children, s_sibling) {
  if (!sd->s_element)
  continue;
@@ -268,5 +268,5 @@ void configfs_hash_and_remove(struct dentry * dir, const char * name)
  break;
  }
  }
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
 }
diff --git a/fs/dax.c b/fs/dax.c
index 43671b68220e..93d0e12dc24d 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -218,10 +218,10 @@ ssize_t dax_do_io(struct kiocb *iocb, struct inode *inode,
 
  if ((flags & DIO_LOCKING) && iov_iter_rw(iter) == READ) {
  struct address_space *mapping = inode->i_mapping;
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  retval = filemap_write_and_wait_range(mapping, pos, end - 1);
  if (retval) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  goto out;
  }
  }
@@ -233,7 +233,7 @@ ssize_t dax_do_io(struct kiocb *iocb, struct inode *inode,
  retval = dax_io(inode, iter, pos, end, get_block, &bh);
 
  if ((flags & DIO_LOCKING) && iov_iter_rw(iter) == READ)
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  if ((retval > 0) && end_io)
  end_io(iocb, pos, retval, bh.b_private);
diff --git a/fs/dcache.c b/fs/dcache.c
index 164722ebca8d..57a8b11f0cb4 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2488,7 +2488,7 @@ EXPORT_SYMBOL(d_rehash);
  */
 void dentry_update_name_case(struct dentry *dentry, struct qstr *name)
 {
- BUG_ON(!mutex_is_locked(&dentry->d_parent->d_inode->i_mutex));
+ BUG_ON(!inode_is_locked(dentry->d_parent->d_inode));
  BUG_ON(dentry->d_name.len != name->len); /* d_lookup gives this */
 
  spin_lock(&dentry->d_lock);
@@ -2765,7 +2765,7 @@ static int __d_unalias(struct inode *inode,
  if (!mutex_trylock(&dentry->d_sb->s_vfs_rename_mutex))
  goto out_err;
  m1 = &dentry->d_sb->s_vfs_rename_mutex;
- if (!mutex_trylock(&alias->d_parent->d_inode->i_mutex))
+ if (!inode_trylock(alias->d_parent->d_inode))
  goto out_err;
  m2 = &alias->d_parent->d_inode->i_mutex;
 out_unalias:
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 8dcf376d2486..2e8332f81b86 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -265,7 +265,7 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
  if (!parent)
  parent = debugfs_mount->mnt_root;
 
- mutex_lock(&d_inode(parent)->i_mutex);
+ inode_lock(d_inode(parent));
  dentry = lookup_one_len(name, parent, strlen(name));
  if (!IS_ERR(dentry) && d_really_is_positive(dentry)) {
  dput(dentry);
@@ -273,7 +273,7 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
  }
 
  if (IS_ERR(dentry)) {
- mutex_unlock(&d_inode(parent)->i_mutex);
+ inode_unlock(d_inode(parent));
  simple_release_fs(&debugfs_mount, &debugfs_mount_count);
  }
 
@@ -282,7 +282,7 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
 
 static struct dentry *failed_creating(struct dentry *dentry)
 {
- mutex_unlock(&d_inode(dentry->d_parent)->i_mutex);
+ inode_unlock(d_inode(dentry->d_parent));
  dput(dentry);
  simple_release_fs(&debugfs_mount, &debugfs_mount_count);
  return NULL;
@@ -290,7 +290,7 @@ static struct dentry *failed_creating(struct dentry *dentry)
 
 static struct dentry *end_creating(struct dentry *dentry)
 {
- mutex_unlock(&d_inode(dentry->d_parent)->i_mutex);
+ inode_unlock(d_inode(dentry->d_parent));
  return dentry;
 }
 
@@ -560,9 +560,9 @@ void debugfs_remove(struct dentry *dentry)
  if (!parent || d_really_is_negative(parent))
  return;
 
- mutex_lock(&d_inode(parent)->i_mutex);
+ inode_lock(d_inode(parent));
  ret = __debugfs_remove(dentry, parent);
- mutex_unlock(&d_inode(parent)->i_mutex);
+ inode_unlock(d_inode(parent));
  if (!ret)
  simple_release_fs(&debugfs_mount, &debugfs_mount_count);
 }
@@ -594,7 +594,7 @@ void debugfs_remove_recursive(struct dentry *dentry)
 
  parent = dentry;
  down:
- mutex_lock(&d_inode(parent)->i_mutex);
+ inode_lock(d_inode(parent));
  loop:
  /*
  * The parent->d_subdirs is protected by the d_lock. Outside that
@@ -609,7 +609,7 @@ void debugfs_remove_recursive(struct dentry *dentry)
  /* perhaps simple_empty(child) makes more sense */
  if (!list_empty(&child->d_subdirs)) {
  spin_unlock(&parent->d_lock);
- mutex_unlock(&d_inode(parent)->i_mutex);
+ inode_unlock(d_inode(parent));
  parent = child;
  goto down;
  }
@@ -630,10 +630,10 @@ void debugfs_remove_recursive(struct dentry *dentry)
  }
  spin_unlock(&parent->d_lock);
 
- mutex_unlock(&d_inode(parent)->i_mutex);
+ inode_unlock(d_inode(parent));
  child = parent;
  parent = parent->d_parent;
- mutex_lock(&d_inode(parent)->i_mutex);
+ inode_lock(d_inode(parent));
 
  if (child != dentry)
  /* go up */
@@ -641,7 +641,7 @@ void debugfs_remove_recursive(struct dentry *dentry)
 
  if (!__debugfs_remove(child, parent))
  simple_release_fs(&debugfs_mount, &debugfs_mount_count);
- mutex_unlock(&d_inode(parent)->i_mutex);
+ inode_unlock(d_inode(parent));
 }
 EXPORT_SYMBOL_GPL(debugfs_remove_recursive);
 
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index c82edb049117..0af8e7d70d27 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -256,7 +256,7 @@ static int mknod_ptmx(struct super_block *sb)
  if (!uid_valid(root_uid) || !gid_valid(root_gid))
  return -EINVAL;
 
- mutex_lock(&d_inode(root)->i_mutex);
+ inode_lock(d_inode(root));
 
  /* If we have already created ptmx node, return */
  if (fsi->ptmx_dentry) {
@@ -293,7 +293,7 @@ static int mknod_ptmx(struct super_block *sb)
  fsi->ptmx_dentry = dentry;
  rc = 0;
 out:
- mutex_unlock(&d_inode(root)->i_mutex);
+ inode_unlock(d_inode(root));
  return rc;
 }
 
@@ -634,7 +634,7 @@ struct inode *devpts_pty_new(struct pts_fs_info *fsi, dev_t device, int index,
 
  sprintf(s, "%d", index);
 
- mutex_lock(&d_inode(root)->i_mutex);
+ inode_lock(d_inode(root));
 
  dentry = d_alloc_name(root, s);
  if (dentry) {
@@ -645,7 +645,7 @@ struct inode *devpts_pty_new(struct pts_fs_info *fsi, dev_t device, int index,
  inode = ERR_PTR(-ENOMEM);
  }
 
- mutex_unlock(&d_inode(root)->i_mutex);
+ inode_unlock(d_inode(root));
 
  return inode;
 }
@@ -690,7 +690,7 @@ void devpts_pty_kill(struct inode *inode)
 
  BUG_ON(inode->i_rdev == MKDEV(TTYAUX_MAJOR, PTMX_MINOR));
 
- mutex_lock(&d_inode(root)->i_mutex);
+ inode_lock(d_inode(root));
 
  dentry = d_find_alias(inode);
 
@@ -699,7 +699,7 @@ void devpts_pty_kill(struct inode *inode)
  dput(dentry); /* d_alloc_name() in devpts_pty_new() */
  dput(dentry); /* d_find_alias above */
 
- mutex_unlock(&d_inode(root)->i_mutex);
+ inode_unlock(d_inode(root));
 }
 
 static int __init init_devpts_fs(void)
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 44f49d86d714..f59546235fce 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -1158,12 +1158,12 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
  iocb->ki_filp->f_mapping;
 
  /* will be released by direct_io_worker */
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  retval = filemap_write_and_wait_range(mapping, offset,
       end - 1);
  if (retval) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  kmem_cache_free(dio_cache, dio);
  goto out;
  }
@@ -1174,7 +1174,7 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
  dio->i_size = i_size_read(inode);
  if (iov_iter_rw(iter) == READ && offset >= dio->i_size) {
  if (dio->flags & DIO_LOCKING)
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  kmem_cache_free(dio_cache, dio);
  retval = 0;
  goto out;
@@ -1296,7 +1296,7 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
  * of protecting us from looking up uninitialized blocks.
  */
  if (iov_iter_rw(iter) == READ && (dio->flags & DIO_LOCKING))
- mutex_unlock(&dio->inode->i_mutex);
+ inode_unlock(dio->inode);
 
  /*
  * The only time we want to leave bios in flight is when a successful
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index e2e47ba5d313..f630bcab92e7 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -41,13 +41,13 @@ static struct dentry *lock_parent(struct dentry *dentry)
  struct dentry *dir;
 
  dir = dget_parent(dentry);
- mutex_lock_nested(&(d_inode(dir)->i_mutex), I_MUTEX_PARENT);
+ inode_lock_nested((d_inode(dir)), I_MUTEX_PARENT);
  return dir;
 }
 
 static void unlock_dir(struct dentry *dir)
 {
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
  dput(dir);
 }
 
@@ -399,11 +399,11 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
  int rc = 0;
 
  lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent);
- mutex_lock(&d_inode(lower_dir_dentry)->i_mutex);
+ inode_lock(d_inode(lower_dir_dentry));
  lower_dentry = lookup_one_len(ecryptfs_dentry->d_name.name,
       lower_dir_dentry,
       ecryptfs_dentry->d_name.len);
- mutex_unlock(&d_inode(lower_dir_dentry)->i_mutex);
+ inode_unlock(d_inode(lower_dir_dentry));
  if (IS_ERR(lower_dentry)) {
  rc = PTR_ERR(lower_dentry);
  ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned "
@@ -428,11 +428,11 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
        "filename; rc = [%d]\n", __func__, rc);
  goto out;
  }
- mutex_lock(&d_inode(lower_dir_dentry)->i_mutex);
+ inode_lock(d_inode(lower_dir_dentry));
  lower_dentry = lookup_one_len(encrypted_and_encoded_name,
       lower_dir_dentry,
       encrypted_and_encoded_name_size);
- mutex_unlock(&d_inode(lower_dir_dentry)->i_mutex);
+ inode_unlock(d_inode(lower_dir_dentry));
  if (IS_ERR(lower_dentry)) {
  rc = PTR_ERR(lower_dentry);
  ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned "
@@ -863,9 +863,9 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length)
  if (!rc && lower_ia.ia_valid & ATTR_SIZE) {
  struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
 
- mutex_lock(&d_inode(lower_dentry)->i_mutex);
+ inode_lock(d_inode(lower_dentry));
  rc = notify_change(lower_dentry, &lower_ia, NULL);
- mutex_unlock(&d_inode(lower_dentry)->i_mutex);
+ inode_unlock(d_inode(lower_dentry));
  }
  return rc;
 }
@@ -964,9 +964,9 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)
  if (lower_ia.ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID))
  lower_ia.ia_valid &= ~ATTR_MODE;
 
- mutex_lock(&d_inode(lower_dentry)->i_mutex);
+ inode_lock(d_inode(lower_dentry));
  rc = notify_change(lower_dentry, &lower_ia, NULL);
- mutex_unlock(&d_inode(lower_dentry)->i_mutex);
+ inode_unlock(d_inode(lower_dentry));
 out:
  fsstack_copy_attr_all(inode, lower_inode);
  return rc;
@@ -1042,10 +1042,10 @@ ecryptfs_getxattr_lower(struct dentry *lower_dentry, const char *name,
  rc = -EOPNOTSUPP;
  goto out;
  }
- mutex_lock(&d_inode(lower_dentry)->i_mutex);
+ inode_lock(d_inode(lower_dentry));
  rc = d_inode(lower_dentry)->i_op->getxattr(lower_dentry, name, value,
    size);
- mutex_unlock(&d_inode(lower_dentry)->i_mutex);
+ inode_unlock(d_inode(lower_dentry));
 out:
  return rc;
 }
@@ -1069,9 +1069,9 @@ ecryptfs_listxattr(struct dentry *dentry, char *list, size_t size)
  rc = -EOPNOTSUPP;
  goto out;
  }
- mutex_lock(&d_inode(lower_dentry)->i_mutex);
+ inode_lock(d_inode(lower_dentry));
  rc = d_inode(lower_dentry)->i_op->listxattr(lower_dentry, list, size);
- mutex_unlock(&d_inode(lower_dentry)->i_mutex);
+ inode_unlock(d_inode(lower_dentry));
 out:
  return rc;
 }
@@ -1086,9 +1086,9 @@ static int ecryptfs_removexattr(struct dentry *dentry, const char *name)
  rc = -EOPNOTSUPP;
  goto out;
  }
- mutex_lock(&d_inode(lower_dentry)->i_mutex);
+ inode_lock(d_inode(lower_dentry));
  rc = d_inode(lower_dentry)->i_op->removexattr(lower_dentry, name);
- mutex_unlock(&d_inode(lower_dentry)->i_mutex);
+ inode_unlock(d_inode(lower_dentry));
 out:
  return rc;
 }
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index caba848ac763..c6ced4cbf0cf 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -436,7 +436,7 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode)
  rc = -ENOMEM;
  goto out;
  }
- mutex_lock(&lower_inode->i_mutex);
+ inode_lock(lower_inode);
  size = lower_inode->i_op->getxattr(lower_dentry, ECRYPTFS_XATTR_NAME,
    xattr_virt, PAGE_CACHE_SIZE);
  if (size < 0)
@@ -444,7 +444,7 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode)
  put_unaligned_be64(i_size_read(ecryptfs_inode), xattr_virt);
  rc = lower_inode->i_op->setxattr(lower_dentry, ECRYPTFS_XATTR_NAME,
  xattr_virt, size, 0);
- mutex_unlock(&lower_inode->i_mutex);
+ inode_unlock(lower_inode);
  if (rc)
  printk(KERN_ERR "Error whilst attempting to write inode size "
        "to lower file xattr; rc = [%d]\n", rc);
diff --git a/fs/efivarfs/file.c b/fs/efivarfs/file.c
index 66842e55c48c..d48e0d261d78 100644
--- a/fs/efivarfs/file.c
+++ b/fs/efivarfs/file.c
@@ -51,9 +51,9 @@ static ssize_t efivarfs_file_write(struct file *file,
  d_delete(file->f_path.dentry);
  dput(file->f_path.dentry);
  } else {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  i_size_write(inode, datasize + sizeof(attributes));
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
 
  bytes = count;
@@ -148,9 +148,9 @@ efivarfs_ioc_setxflags(struct file *file, void __user *arg)
  if (error)
  return error;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  inode_set_flags(inode, i_flags, S_IMMUTABLE);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  mnt_drop_write_file(file);
 
diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
index abb244b06024..dd029d13ea61 100644
--- a/fs/efivarfs/super.c
+++ b/fs/efivarfs/super.c
@@ -164,10 +164,10 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
  efivar_entry_size(entry, &size);
  efivar_entry_add(entry, &efivarfs_list);
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  inode->i_private = entry;
  i_size_write(inode, size + sizeof(entry->var.Attributes));
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  d_add(dentry, inode);
 
  return 0;
diff --git a/fs/exec.c b/fs/exec.c
index 455c86f533d2..3cf17eda3b1d 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1369,13 +1369,13 @@ static void bprm_fill_uid(struct linux_binprm *bprm)
  return;
 
  /* Be careful if suid/sgid is set */
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  /* reload atomically mode/uid/gid now that lock held */
  mode = inode->i_mode;
  uid = inode->i_uid;
  gid = inode->i_gid;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  /* We ignore suid/sgid if there are no mappings for them in the ns */
  if (!kuid_has_mapping(bprm->cred->user_ns, uid) ||
diff --git a/fs/exofs/file.c b/fs/exofs/file.c
index 906de66e8e7e..28645f0640f7 100644
--- a/fs/exofs/file.c
+++ b/fs/exofs/file.c
@@ -52,9 +52,9 @@ static int exofs_file_fsync(struct file *filp, loff_t start, loff_t end,
  if (ret)
  return ret;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  ret = sync_inode_metadata(filp->f_mapping->host, 1);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
 
diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
index 714cd37a6ba3..c46f1a190b8d 100644
--- a/fs/exportfs/expfs.c
+++ b/fs/exportfs/expfs.c
@@ -124,10 +124,10 @@ static struct dentry *reconnect_one(struct vfsmount *mnt,
  int err;
 
  parent = ERR_PTR(-EACCES);
- mutex_lock(&dentry->d_inode->i_mutex);
+ inode_lock(dentry->d_inode);
  if (mnt->mnt_sb->s_export_op->get_parent)
  parent = mnt->mnt_sb->s_export_op->get_parent(dentry);
- mutex_unlock(&dentry->d_inode->i_mutex);
+ inode_unlock(dentry->d_inode);
 
  if (IS_ERR(parent)) {
  dprintk("%s: get_parent of %ld failed, err %d\n",
@@ -143,9 +143,9 @@ static struct dentry *reconnect_one(struct vfsmount *mnt,
  if (err)
  goto out_err;
  dprintk("%s: found name: %s\n", __func__, nbuf);
- mutex_lock(&parent->d_inode->i_mutex);
+ inode_lock(parent->d_inode);
  tmp = lookup_one_len(nbuf, parent, strlen(nbuf));
- mutex_unlock(&parent->d_inode->i_mutex);
+ inode_unlock(parent->d_inode);
  if (IS_ERR(tmp)) {
  dprintk("%s: lookup failed: %d\n", __func__, PTR_ERR(tmp));
  goto out_err;
@@ -503,10 +503,10 @@ struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,
  */
  err = exportfs_get_name(mnt, target_dir, nbuf, result);
  if (!err) {
- mutex_lock(&target_dir->d_inode->i_mutex);
+ inode_lock(target_dir->d_inode);
  nresult = lookup_one_len(nbuf, target_dir,
  strlen(nbuf));
- mutex_unlock(&target_dir->d_inode->i_mutex);
+ inode_unlock(target_dir->d_inode);
  if (!IS_ERR(nresult)) {
  if (nresult->d_inode) {
  dput(result);
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
index 5d46c09863f0..b386af2e45f4 100644
--- a/fs/ext2/ioctl.c
+++ b/fs/ext2/ioctl.c
@@ -51,10 +51,10 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 
  flags = ext2_mask_flags(inode->i_mode, flags);
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  /* Is it quota file? Do not allow user to mess with it */
  if (IS_NOQUOTA(inode)) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  ret = -EPERM;
  goto setflags_out;
  }
@@ -68,7 +68,7 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
  */
  if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
  if (!capable(CAP_LINUX_IMMUTABLE)) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  ret = -EPERM;
  goto setflags_out;
  }
@@ -80,7 +80,7 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 
  ext2_set_inode_flags(inode);
  inode->i_ctime = CURRENT_TIME_SEC;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  mark_inode_dirty(inode);
 setflags_out:
@@ -102,10 +102,10 @@ setflags_out:
  goto setversion_out;
  }
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  inode->i_ctime = CURRENT_TIME_SEC;
  inode->i_generation = generation;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  mark_inode_dirty(inode);
 setversion_out:
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 331f82510d15..68ed1c1ac515 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2853,7 +2853,7 @@ do { \
 static inline void ext4_update_i_disksize(struct inode *inode, loff_t newsize)
 {
  WARN_ON_ONCE(S_ISREG(inode->i_mode) &&
-     !mutex_is_locked(&inode->i_mutex));
+     !inode_is_locked(inode));
  down_write(&EXT4_I(inode)->i_data_sem);
  if (newsize > EXT4_I(inode)->i_disksize)
  EXT4_I(inode)->i_disksize = newsize;
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 3351948ff240..010871afe44f 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4828,7 +4828,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
  else
  max_blocks -= lblk;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  /*
  * Indirect files do not support unwritten extnets
@@ -4933,7 +4933,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
 out_dio:
  ext4_inode_resume_unlocked_dio(inode);
 out_mutex:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
 
@@ -5004,7 +5004,7 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
  if (mode & FALLOC_FL_KEEP_SIZE)
  flags |= EXT4_GET_BLOCKS_KEEP_SIZE;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  /*
  * We only support preallocation for extent-based files only
@@ -5037,7 +5037,7 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
  EXT4_I(inode)->i_sync_tid);
  }
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  trace_ext4_fallocate_exit(inode, offset, max_blocks, ret);
  return ret;
 }
@@ -5532,7 +5532,7 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
  return ret;
  }
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  /*
  * There is no need to overlap collapse range with EOF, in which case
  * it is effectively a truncate operation
@@ -5628,7 +5628,7 @@ out_mmap:
  up_write(&EXT4_I(inode)->i_mmap_sem);
  ext4_inode_resume_unlocked_dio(inode);
 out_mutex:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
 
@@ -5679,7 +5679,7 @@ int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len)
  return ret;
  }
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  /* Currently just for extent based files */
  if (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) {
  ret = -EOPNOTSUPP;
@@ -5803,7 +5803,7 @@ out_mmap:
  up_write(&EXT4_I(inode)->i_mmap_sem);
  ext4_inode_resume_unlocked_dio(inode);
 out_mutex:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
 
@@ -5838,8 +5838,8 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
 
  BUG_ON(!rwsem_is_locked(&EXT4_I(inode1)->i_data_sem));
  BUG_ON(!rwsem_is_locked(&EXT4_I(inode2)->i_data_sem));
- BUG_ON(!mutex_is_locked(&inode1->i_mutex));
- BUG_ON(!mutex_is_locked(&inode2->i_mutex));
+ BUG_ON(!inode_is_locked(inode1));
+ BUG_ON(!inode_is_locked(inode2));
 
  *erp = ext4_es_remove_extent(inode1, lblk1, count);
  if (unlikely(*erp))
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 98ea8cbbc684..450c0291ddf6 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -113,7 +113,7 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
  ext4_unwritten_wait(inode);
  }
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  ret = generic_write_checks(iocb, from);
  if (ret <= 0)
  goto out;
@@ -169,7 +169,7 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
  }
 
  ret = __generic_file_write_iter(iocb, from);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  if (ret > 0) {
  ssize_t err;
@@ -186,7 +186,7 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
  return ret;
 
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  if (aio_mutex)
  mutex_unlock(aio_mutex);
  return ret;
@@ -555,11 +555,11 @@ static loff_t ext4_seek_data(struct file *file, loff_t offset, loff_t maxsize)
  int blkbits;
  int ret;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  isize = i_size_read(inode);
  if (offset < 0 || offset >= isize) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return -ENXIO;
  }
 
@@ -575,7 +575,7 @@ static loff_t ext4_seek_data(struct file *file, loff_t offset, loff_t maxsize)
  /* No extent found -> no data */
  if (ret == 0)
  ret = -ENXIO;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
  }
 
@@ -598,7 +598,7 @@ static loff_t ext4_seek_data(struct file *file, loff_t offset, loff_t maxsize)
  cond_resched();
  } while (last <= end);
 
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  if (dataoff > isize)
  return -ENXIO;
@@ -618,11 +618,11 @@ static loff_t ext4_seek_hole(struct file *file, loff_t offset, loff_t maxsize)
  int blkbits;
  int ret;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  isize = i_size_read(inode);
  if (offset < 0 || offset >= isize) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return -ENXIO;
  }
 
@@ -635,7 +635,7 @@ static loff_t ext4_seek_hole(struct file *file, loff_t offset, loff_t maxsize)
  do {
  ret = ext4_get_next_extent(inode, last, end - last + 1, &es);
  if (ret < 0) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
  }
  /* Found a hole? */
@@ -659,7 +659,7 @@ static loff_t ext4_seek_hole(struct file *file, loff_t offset, loff_t maxsize)
  cond_resched();
  } while (last <= end);
 
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  if (holeoff > isize)
  holeoff = isize;
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 12700e6729f6..2690f53b046a 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3238,7 +3238,7 @@ static ssize_t ext4_ext_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
 
  if (overwrite) {
  down_read(&EXT4_I(inode)->i_data_sem);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
 
  /*
@@ -3340,7 +3340,7 @@ retake_lock:
  /* take i_mutex locking again if we do a ovewrite dio */
  if (overwrite) {
  up_read(&EXT4_I(inode)->i_data_sem);
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  }
 
  return ret;
@@ -3667,7 +3667,7 @@ int ext4_update_disksize_before_punch(struct inode *inode, loff_t offset,
  handle_t *handle;
  loff_t size = i_size_read(inode);
 
- WARN_ON(!mutex_is_locked(&inode->i_mutex));
+ WARN_ON(!inode_is_locked(inode));
  if (offset > size || offset + len < size)
  return 0;
 
@@ -3721,7 +3721,7 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
  return ret;
  }
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  /* No need to punch hole beyond i_size */
  if (offset >= inode->i_size)
@@ -3825,7 +3825,7 @@ out_dio:
  up_write(&EXT4_I(inode)->i_mmap_sem);
  ext4_inode_resume_unlocked_dio(inode);
 out_mutex:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
 
@@ -3895,7 +3895,7 @@ void ext4_truncate(struct inode *inode)
  * have i_mutex locked because it's not necessary.
  */
  if (!(inode->i_state & (I_NEW|I_FREEING)))
- WARN_ON(!mutex_is_locked(&inode->i_mutex));
+ WARN_ON(!inode_is_locked(inode));
  trace_ext4_truncate_enter(inode);
 
  if (!ext4_can_truncate(inode))
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 606a116a476b..171e40bd6250 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -236,7 +236,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
  flags = ext4_mask_flags(inode->i_mode, flags);
 
  err = -EPERM;
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  /* Is it quota file? Do not allow user to mess with it */
  if (IS_NOQUOTA(inode))
  goto flags_out;
@@ -318,7 +318,7 @@ flags_err:
  }
 
 flags_out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  mnt_drop_write_file(filp);
  return err;
  }
@@ -349,7 +349,7 @@ flags_out:
  goto setversion_out;
  }
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
  if (IS_ERR(handle)) {
  err = PTR_ERR(handle);
@@ -364,7 +364,7 @@ flags_out:
  ext4_journal_stop(handle);
 
 unlock_out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 setversion_out:
  mnt_drop_write_file(filp);
  return err;
@@ -510,9 +510,9 @@ group_add_out:
  * ext4_ext_swap_inode_data before we switch the
  * inode format to prevent read.
  */
- mutex_lock(&(inode->i_mutex));
+ inode_lock((inode));
  err = ext4_ext_migrate(inode);
- mutex_unlock(&(inode->i_mutex));
+ inode_unlock((inode));
  mnt_drop_write_file(filp);
  return err;
  }
@@ -636,11 +636,11 @@ resizefs_out:
  if (err)
  goto encryption_policy_out;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  err = ext4_process_policy(&policy, inode);
 
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  mnt_drop_write_file(filp);
 encryption_policy_out:
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 6445d84266fa..bf4802fb56dc 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2771,7 +2771,7 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
  return 0;
 
  WARN_ON_ONCE(!(inode->i_state & (I_NEW | I_FREEING)) &&
-     !mutex_is_locked(&inode->i_mutex));
+     !inode_is_locked(inode));
  /*
  * Exit early if inode already is on orphan list. This is a big speedup
  * since we don't have to contend on the global s_orphan_lock.
@@ -2853,7 +2853,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
  return 0;
 
  WARN_ON_ONCE(!(inode->i_state & (I_NEW | I_FREEING)) &&
-     !mutex_is_locked(&inode->i_mutex));
+     !inode_is_locked(inode));
  /* Do this quick check before taking global s_orphan_lock. */
  if (list_empty(&ei->i_orphan))
  return 0;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 9181cec0224c..9884655ff02c 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2327,10 +2327,10 @@ static void ext4_orphan_cleanup(struct super_block *sb,
  __func__, inode->i_ino, inode->i_size);
  jbd_debug(2, "truncating inode %lu to %lld bytes\n",
   inode->i_ino, inode->i_size);
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  truncate_inode_pages(inode->i_mapping, inode->i_size);
  ext4_truncate(inode);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  nr_truncates++;
  } else {
  if (test_opt(sb, DEBUG))
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 98b2fc2678ff..5173d32a1730 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -777,7 +777,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
  return ret;
  }
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  if (len >= isize) {
  whole_file = true;
@@ -862,7 +862,7 @@ out:
  if (ret == 1)
  ret = 0;
 
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
 
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 01eed94b01ea..be91de267337 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -332,7 +332,7 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
  loff_t isize;
  int err = 0;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  isize = i_size_read(inode);
  if (offset >= isize)
@@ -387,10 +387,10 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
 found:
  if (whence == SEEK_HOLE && data_ofs > isize)
  data_ofs = isize;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return vfs_setpos(file, data_ofs, maxbytes);
 fail:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return -ENXIO;
 }
 
@@ -1226,7 +1226,7 @@ static long f2fs_fallocate(struct file *file, int mode,
  FALLOC_FL_INSERT_RANGE))
  return -EOPNOTSUPP;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  if (mode & FALLOC_FL_PUNCH_HOLE) {
  if (offset >= inode->i_size)
@@ -1249,7 +1249,7 @@ static long f2fs_fallocate(struct file *file, int mode,
  }
 
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  trace_f2fs_fallocate(inode, mode, offset, len, ret);
  return ret;
@@ -1313,13 +1313,13 @@ static int f2fs_ioc_setflags(struct file *filp, unsigned long arg)
 
  flags = f2fs_mask_flags(inode->i_mode, flags);
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  oldflags = fi->i_flags;
 
  if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
  if (!capable(CAP_LINUX_IMMUTABLE)) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  ret = -EPERM;
  goto out;
  }
@@ -1328,7 +1328,7 @@ static int f2fs_ioc_setflags(struct file *filp, unsigned long arg)
  flags = flags & FS_FL_USER_MODIFIABLE;
  flags |= oldflags & ~FS_FL_USER_MODIFIABLE;
  fi->i_flags = flags;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  f2fs_set_inode_flags(inode);
  inode->i_ctime = CURRENT_TIME;
@@ -1545,11 +1545,11 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg)
  if (err)
  return err;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  err = f2fs_process_policy(&policy, inode);
 
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  mnt_drop_write_file(filp);
 
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 8b2127ffb226..c9a85f4bfcc2 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -769,7 +769,7 @@ static int fat_ioctl_readdir(struct inode *inode, struct file *file,
 
  buf.dirent = dirent;
  buf.result = 0;
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  buf.ctx.pos = file->f_pos;
  ret = -ENOENT;
  if (!IS_DEADDIR(inode)) {
@@ -777,7 +777,7 @@ static int fat_ioctl_readdir(struct inode *inode, struct file *file,
     short_only, both ? &buf : NULL);
  file->f_pos = buf.ctx.pos;
  }
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  if (ret >= 0)
  ret = buf.result;
  return ret;
diff --git a/fs/fat/file.c b/fs/fat/file.c
index a08f1039909a..6a8217512de0 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -20,9 +20,9 @@ static int fat_ioctl_get_attributes(struct inode *inode, u32 __user *user_attr)
 {
  u32 attr;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  attr = fat_make_attrs(inode);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return put_user(attr, user_attr);
 }
@@ -43,7 +43,7 @@ static int fat_ioctl_set_attributes(struct file *file, u32 __user *user_attr)
  err = mnt_want_write_file(file);
  if (err)
  goto out;
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  /*
  * ATTR_VOLUME and ATTR_DIR cannot be changed; this also
@@ -105,7 +105,7 @@ static int fat_ioctl_set_attributes(struct file *file, u32 __user *user_attr)
  fat_save_attrs(inode, attr);
  mark_inode_dirty(inode);
 out_unlock_inode:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  mnt_drop_write_file(file);
 out:
  return err;
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 9c5eaab79df5..aa6d459e8c30 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -946,7 +946,7 @@ int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid,
  if (!parent)
  return -ENOENT;
 
- mutex_lock(&parent->i_mutex);
+ inode_lock(parent);
  if (!S_ISDIR(parent->i_mode))
  goto unlock;
 
@@ -964,7 +964,7 @@ int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid,
  fuse_invalidate_entry(entry);
 
  if (child_nodeid != 0 && d_really_is_positive(entry)) {
- mutex_lock(&d_inode(entry)->i_mutex);
+ inode_lock(d_inode(entry));
  if (get_node_id(d_inode(entry)) != child_nodeid) {
  err = -ENOENT;
  goto badentry;
@@ -985,7 +985,7 @@ int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid,
  clear_nlink(d_inode(entry));
  err = 0;
  badentry:
- mutex_unlock(&d_inode(entry)->i_mutex);
+ inode_unlock(d_inode(entry));
  if (!err)
  d_delete(entry);
  } else {
@@ -994,7 +994,7 @@ int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid,
  dput(entry);
 
  unlock:
- mutex_unlock(&parent->i_mutex);
+ inode_unlock(parent);
  iput(parent);
  return err;
 }
@@ -1503,7 +1503,7 @@ void fuse_set_nowrite(struct inode *inode)
  struct fuse_conn *fc = get_fuse_conn(inode);
  struct fuse_inode *fi = get_fuse_inode(inode);
 
- BUG_ON(!mutex_is_locked(&inode->i_mutex));
+ BUG_ON(!inode_is_locked(inode));
 
  spin_lock(&fc->lock);
  BUG_ON(fi->writectr < 0);
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index da0193b6322b..b00bc25d7c90 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -208,7 +208,7 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir)
  return err;
 
  if (lock_inode)
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  err = fuse_do_open(fc, get_node_id(inode), file, isdir);
 
@@ -216,7 +216,7 @@ int fuse_open_common(struct inode *inode, struct file *file, bool isdir)
  fuse_finish_open(inode, file);
 
  if (lock_inode)
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return err;
 }
@@ -414,9 +414,9 @@ static int fuse_flush(struct file *file, fl_owner_t id)
  if (err)
  return err;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  fuse_sync_writes(inode);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  if (test_bit(AS_ENOSPC, &file->f_mapping->flags) &&
     test_and_clear_bit(AS_ENOSPC, &file->f_mapping->flags))
@@ -460,7 +460,7 @@ int fuse_fsync_common(struct file *file, loff_t start, loff_t end,
  if (is_bad_inode(inode))
  return -EIO;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  /*
  * Start writeback against all dirty pages of the inode, then
@@ -511,7 +511,7 @@ int fuse_fsync_common(struct file *file, loff_t start, loff_t end,
  err = 0;
  }
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return err;
 }
 
@@ -1192,7 +1192,7 @@ static ssize_t fuse_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
  return generic_file_write_iter(iocb, from);
  }
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  /* We can write back this queue in page reclaim */
  current->backing_dev_info = inode_to_bdi(inode);
@@ -1242,7 +1242,7 @@ static ssize_t fuse_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
  }
 out:
  current->backing_dev_info = NULL;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return written ? written : err;
 }
@@ -1355,10 +1355,10 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
 
  if (!cuse && fuse_range_is_writeback(inode, idx_from, idx_to)) {
  if (!write)
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  fuse_sync_writes(inode);
  if (!write)
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
 
  while (count) {
@@ -1446,14 +1446,14 @@ static ssize_t fuse_direct_write_iter(struct kiocb *iocb, struct iov_iter *from)
  return -EIO;
 
  /* Don't allow parallel writes to the same file */
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  res = generic_write_checks(iocb, from);
  if (res > 0)
  res = fuse_direct_io(&io, from, &iocb->ki_pos, FUSE_DIO_WRITE);
  fuse_invalidate_attr(inode);
  if (res > 0)
  fuse_write_update_size(inode, iocb->ki_pos);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return res;
 }
@@ -2291,11 +2291,11 @@ static loff_t fuse_file_llseek(struct file *file, loff_t offset, int whence)
  if (whence == SEEK_CUR || whence == SEEK_SET)
  return generic_file_llseek(file, offset, whence);
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  retval = fuse_update_attributes(inode, NULL, file, NULL);
  if (!retval)
  retval = generic_file_llseek(file, offset, whence);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return retval;
 }
@@ -2946,7 +2946,7 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset,
  return -EOPNOTSUPP;
 
  if (lock_inode) {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  if (mode & FALLOC_FL_PUNCH_HOLE) {
  loff_t endbyte = offset + length - 1;
  err = filemap_write_and_wait_range(inode->i_mapping,
@@ -2992,7 +2992,7 @@ out:
  clear_bit(FUSE_I_SIZE_UNSTABLE, &fi->state);
 
  if (lock_inode)
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return err;
 }
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 5e425469f0c2..cf15646b5b8f 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -920,7 +920,7 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t le
  if ((mode & ~FALLOC_FL_KEEP_SIZE) || gfs2_is_jdata(ip))
  return -EOPNOTSUPP;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
  ret = gfs2_glock_nq(&gh);
@@ -951,7 +951,7 @@ out_unlock:
  gfs2_glock_dq(&gh);
 out_uninit:
  gfs2_holder_uninit(&gh);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
 
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 063fdfcf8275..970dd21055e3 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -2063,7 +2063,7 @@ static int gfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
  if (ret)
  return ret;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh);
  if (ret)
@@ -2090,7 +2090,7 @@ static int gfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 
  gfs2_glock_dq_uninit(&gh);
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
 
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index 3a31226531ea..9daf9779f182 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -855,7 +855,7 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda)
  return -ENOMEM;
 
  sort(qda, num_qd, sizeof(struct gfs2_quota_data *), sort_qd, NULL);
- mutex_lock(&ip->i_inode.i_mutex);
+ inode_lock(&ip->i_inode);
  for (qx = 0; qx < num_qd; qx++) {
  error = gfs2_glock_nq_init(qda[qx]->qd_gl, LM_ST_EXCLUSIVE,
    GL_NOCACHE, &ghs[qx]);
@@ -920,7 +920,7 @@ out_alloc:
 out:
  while (qx--)
  gfs2_glock_dq_uninit(&ghs[qx]);
- mutex_unlock(&ip->i_inode.i_mutex);
+ inode_unlock(&ip->i_inode);
  kfree(ghs);
  gfs2_log_flush(ip->i_gl->gl_name.ln_sbd, ip->i_gl, NORMAL_FLUSH);
  return error;
@@ -1639,7 +1639,7 @@ static int gfs2_set_dqblk(struct super_block *sb, struct kqid qid,
  if (error)
  goto out_put;
 
- mutex_lock(&ip->i_inode.i_mutex);
+ inode_lock(&ip->i_inode);
  error = gfs2_glock_nq_init(qd->qd_gl, LM_ST_EXCLUSIVE, 0, &q_gh);
  if (error)
  goto out_unlockput;
@@ -1704,7 +1704,7 @@ out_i:
 out_q:
  gfs2_glock_dq_uninit(&q_gh);
 out_unlockput:
- mutex_unlock(&ip->i_inode.i_mutex);
+ inode_unlock(&ip->i_inode);
 out_put:
  qd_put(qd);
  return error;
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index 70788e03820a..e9f2b855f831 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -173,9 +173,9 @@ static int hfs_dir_release(struct inode *inode, struct file *file)
 {
  struct hfs_readdir_data *rd = file->private_data;
  if (rd) {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  list_del(&rd->list);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  kfree(rd);
  }
  return 0;
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index b99ebddb10cb..6686bf39a5b5 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -570,13 +570,13 @@ static int hfs_file_release(struct inode *inode, struct file *file)
  if (HFS_IS_RSRC(inode))
  inode = HFS_I(inode)->rsrc_inode;
  if (atomic_dec_and_test(&HFS_I(inode)->opencnt)) {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  hfs_file_truncate(inode);
  //if (inode->i_flags & S_DEAD) {
  // hfs_delete_cat(inode->i_ino, HFSPLUS_SB(sb).hidden_dir, NULL);
  // hfs_delete_inode(inode);
  //}
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
  return 0;
 }
@@ -656,7 +656,7 @@ static int hfs_file_fsync(struct file *filp, loff_t start, loff_t end,
  ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
  if (ret)
  return ret;
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  /* sync the inode to buffers */
  ret = write_inode_now(inode, 0);
@@ -668,7 +668,7 @@ static int hfs_file_fsync(struct file *filp, loff_t start, loff_t end,
  err = sync_blockdev(sb->s_bdev);
  if (!ret)
  ret = err;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
 
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index d0f39dcbb58e..a4e867e08947 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -284,9 +284,9 @@ static int hfsplus_dir_release(struct inode *inode, struct file *file)
 {
  struct hfsplus_readdir_data *rd = file->private_data;
  if (rd) {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  list_del(&rd->list);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  kfree(rd);
  }
  return 0;
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 6dd107d7421e..dcc7afb9a9a8 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -229,14 +229,14 @@ static int hfsplus_file_release(struct inode *inode, struct file *file)
  if (HFSPLUS_IS_RSRC(inode))
  inode = HFSPLUS_I(inode)->rsrc_inode;
  if (atomic_dec_and_test(&HFSPLUS_I(inode)->opencnt)) {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  hfsplus_file_truncate(inode);
  if (inode->i_flags & S_DEAD) {
  hfsplus_delete_cat(inode->i_ino,
    HFSPLUS_SB(sb)->hidden_dir, NULL);
  hfsplus_delete_inode(inode);
  }
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
  return 0;
 }
@@ -286,7 +286,7 @@ int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
  error = filemap_write_and_wait_range(inode->i_mapping, start, end);
  if (error)
  return error;
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  /*
  * Sync inode metadata into the catalog and extent trees.
@@ -327,7 +327,7 @@ int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
  if (!test_bit(HFSPLUS_SB_NOBARRIER, &sbi->flags))
  blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
 
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return error;
 }
diff --git a/fs/hfsplus/ioctl.c b/fs/hfsplus/ioctl.c
index 0624ce4e0702..32a49e292b6a 100644
--- a/fs/hfsplus/ioctl.c
+++ b/fs/hfsplus/ioctl.c
@@ -93,7 +93,7 @@ static int hfsplus_ioctl_setflags(struct file *file, int __user *user_flags)
  goto out_drop_write;
  }
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  if ((flags & (FS_IMMUTABLE_FL|FS_APPEND_FL)) ||
     inode->i_flags & (S_IMMUTABLE|S_APPEND)) {
@@ -126,7 +126,7 @@ static int hfsplus_ioctl_setflags(struct file *file, int __user *user_flags)
  mark_inode_dirty(inode);
 
 out_unlock_inode:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 out_drop_write:
  mnt_drop_write_file(file);
 out:
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index f34d6f5a5aca..6fbb47ca2656 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -378,9 +378,9 @@ static int hostfs_fsync(struct file *file, loff_t start, loff_t end,
  if (ret)
  return ret;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  ret = fsync_file(HOSTFS_I(inode)->fd, datasync);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return ret;
 }
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c
index dc540bfcee1d..e57a53c13d86 100644
--- a/fs/hpfs/dir.c
+++ b/fs/hpfs/dir.c
@@ -33,7 +33,7 @@ static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence)
  if (whence == SEEK_DATA || whence == SEEK_HOLE)
  return -EINVAL;
 
- mutex_lock(&i->i_mutex);
+ inode_lock(i);
  hpfs_lock(s);
 
  /*pr_info("dir lseek\n");*/
@@ -48,12 +48,12 @@ static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence)
 ok:
  filp->f_pos = new_off;
  hpfs_unlock(s);
- mutex_unlock(&i->i_mutex);
+ inode_unlock(i);
  return new_off;
 fail:
  /*pr_warn("illegal lseek: %016llx\n", new_off);*/
  hpfs_unlock(s);
- mutex_unlock(&i->i_mutex);
+ inode_unlock(i);
  return -ESPIPE;
 }
 
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index a17da8b57fc6..0e909b1176c0 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -141,7 +141,7 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
 
  vma_len = (loff_t)(vma->vm_end - vma->vm_start);
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  file_accessed(file);
 
  ret = -ENOMEM;
@@ -157,7 +157,7 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
  if (vma->vm_flags & VM_WRITE && inode->i_size < len)
  inode->i_size = len;
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return ret;
 }
@@ -524,7 +524,7 @@ static long hugetlbfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
  if (hole_end > hole_start) {
  struct address_space *mapping = inode->i_mapping;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  i_mmap_lock_write(mapping);
  if (!RB_EMPTY_ROOT(&mapping->i_mmap))
  hugetlb_vmdelete_list(&mapping->i_mmap,
@@ -532,7 +532,7 @@ static long hugetlbfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
  hole_end  >> PAGE_SHIFT);
  i_mmap_unlock_write(mapping);
  remove_inode_hugepages(inode, hole_start, hole_end);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
 
  return 0;
@@ -566,7 +566,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
  start = offset >> hpage_shift;
  end = (offset + len + hpage_size - 1) >> hpage_shift;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  /* We need to check rlimit even when FALLOC_FL_KEEP_SIZE */
  error = inode_newsize_ok(inode, offset + len);
@@ -653,7 +653,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
  i_size_write(inode, offset + len);
  inode->i_ctime = CURRENT_TIME;
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return error;
 }
 
diff --git a/fs/inode.c b/fs/inode.c
index 037e2f42852b..b3c79e0bf978 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -966,9 +966,9 @@ void lock_two_nondirectories(struct inode *inode1, struct inode *inode2)
  swap(inode1, inode2);
 
  if (inode1 && !S_ISDIR(inode1->i_mode))
- mutex_lock(&inode1->i_mutex);
+ inode_lock(inode1);
  if (inode2 && !S_ISDIR(inode2->i_mode) && inode2 != inode1)
- mutex_lock_nested(&inode2->i_mutex, I_MUTEX_NONDIR2);
+ inode_lock_nested(inode2, I_MUTEX_NONDIR2);
 }
 EXPORT_SYMBOL(lock_two_nondirectories);
 
@@ -980,9 +980,9 @@ EXPORT_SYMBOL(lock_two_nondirectories);
 void unlock_two_nondirectories(struct inode *inode1, struct inode *inode2)
 {
  if (inode1 && !S_ISDIR(inode1->i_mode))
- mutex_unlock(&inode1->i_mutex);
+ inode_unlock(inode1);
  if (inode2 && !S_ISDIR(inode2->i_mode) && inode2 != inode1)
- mutex_unlock(&inode2->i_mutex);
+ inode_unlock(inode2);
 }
 EXPORT_SYMBOL(unlock_two_nondirectories);
 
diff --git a/fs/ioctl.c b/fs/ioctl.c
index fb89998bf395..5ce92fa7b0e2 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -411,9 +411,9 @@ int generic_block_fiemap(struct inode *inode,
  u64 len, get_block_t *get_block)
 {
  int ret;
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  ret = __generic_block_fiemap(inode, fieinfo, start, len, get_block);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
 EXPORT_SYMBOL(generic_block_fiemap);
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index 3361979d728c..cad86bac3453 100644
--- a/fs/jffs2/file.c
+++ b/fs/jffs2/file.c
@@ -39,10 +39,10 @@ int jffs2_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
  if (ret)
  return ret;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  /* Trigger GC to flush any pending writes for this inode */
  jffs2_flush_wbuf_gc(c, inode->i_ino);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return 0;
 }
diff --git a/fs/jfs/file.c b/fs/jfs/file.c
index 0e026a7bdcd4..4ce7735dd042 100644
--- a/fs/jfs/file.c
+++ b/fs/jfs/file.c
@@ -38,17 +38,17 @@ int jfs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
  if (rc)
  return rc;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  if (!(inode->i_state & I_DIRTY_ALL) ||
     (datasync && !(inode->i_state & I_DIRTY_DATASYNC))) {
  /* Make sure committed changes hit the disk */
  jfs_flush_journal(JFS_SBI(inode->i_sb)->log, 1);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return rc;
  }
 
  rc |= jfs_commit_inode(inode, 1);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return rc ? -EIO : 0;
 }
diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c
index 8db8b7d61e40..8653cac7e12e 100644
--- a/fs/jfs/ioctl.c
+++ b/fs/jfs/ioctl.c
@@ -96,7 +96,7 @@ long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
  }
 
  /* Lock against other parallel changes of flags */
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  jfs_get_inode_flags(jfs_inode);
  oldflags = jfs_inode->mode2;
@@ -109,7 +109,7 @@ long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
  ((flags ^ oldflags) &
  (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
  if (!capable(CAP_LINUX_IMMUTABLE)) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  err = -EPERM;
  goto setflags_out;
  }
@@ -120,7 +120,7 @@ long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
  jfs_inode->mode2 = flags;
 
  jfs_set_inode_flags(inode);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  inode->i_ctime = CURRENT_TIME_SEC;
  mark_inode_dirty(inode);
 setflags_out:
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index c8d58c5ac8ae..f65de13ede18 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -792,7 +792,7 @@ static ssize_t jfs_quota_write(struct super_block *sb, int type,
  struct buffer_head tmp_bh;
  struct buffer_head *bh;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  while (towrite > 0) {
  tocopy = sb->s_blocksize - offset < towrite ?
  sb->s_blocksize - offset : towrite;
@@ -824,7 +824,7 @@ static ssize_t jfs_quota_write(struct super_block *sb, int type,
  }
 out:
  if (len == towrite) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return err;
  }
  if (inode->i_size < off+len-towrite)
@@ -832,7 +832,7 @@ out:
  inode->i_version++;
  inode->i_mtime = inode->i_ctime = CURRENT_TIME;
  mark_inode_dirty(inode);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return len - towrite;
 }
 
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 70939b36c4b1..2134c80df27f 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -1602,9 +1602,9 @@ static loff_t kernfs_dir_fop_llseek(struct file *file, loff_t offset,
  struct inode *inode = file_inode(file);
  loff_t ret;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  ret = generic_file_llseek(file, offset, whence);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return ret;
 }
diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c
index 77e5bb75c621..76b969f9aec0 100644
--- a/fs/kernfs/mount.c
+++ b/fs/kernfs/mount.c
@@ -135,9 +135,9 @@ struct dentry *kernfs_node_dentry(struct kernfs_node *kn,
  kntmp = find_next_ancestor(kn, knparent);
  if (WARN_ON(!kntmp))
  return ERR_PTR(-EINVAL);
- mutex_lock(&d_inode(dentry)->i_mutex);
+ inode_lock(d_inode(dentry));
  dtmp = lookup_one_len(kntmp->name, dentry, strlen(kntmp->name));
- mutex_unlock(&d_inode(dentry)->i_mutex);
+ inode_unlock(d_inode(dentry));
  dput(dentry);
  if (IS_ERR(dtmp))
  return dtmp;
diff --git a/fs/libfs.c b/fs/libfs.c
index c7cbfb092e94..72c09d8819d1 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -89,7 +89,7 @@ EXPORT_SYMBOL(dcache_dir_close);
 loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence)
 {
  struct dentry *dentry = file->f_path.dentry;
- mutex_lock(&d_inode(dentry)->i_mutex);
+ inode_lock(d_inode(dentry));
  switch (whence) {
  case 1:
  offset += file->f_pos;
@@ -97,7 +97,7 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence)
  if (offset >= 0)
  break;
  default:
- mutex_unlock(&d_inode(dentry)->i_mutex);
+ inode_unlock(d_inode(dentry));
  return -EINVAL;
  }
  if (offset != file->f_pos) {
@@ -124,7 +124,7 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence)
  spin_unlock(&dentry->d_lock);
  }
  }
- mutex_unlock(&d_inode(dentry)->i_mutex);
+ inode_unlock(d_inode(dentry));
  return offset;
 }
 EXPORT_SYMBOL(dcache_dir_lseek);
@@ -941,7 +941,7 @@ int __generic_file_fsync(struct file *file, loff_t start, loff_t end,
  if (err)
  return err;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  ret = sync_mapping_buffers(inode->i_mapping);
  if (!(inode->i_state & I_DIRTY_ALL))
  goto out;
@@ -953,7 +953,7 @@ int __generic_file_fsync(struct file *file, loff_t start, loff_t end,
  ret = err;
 
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
 EXPORT_SYMBOL(__generic_file_fsync);
diff --git a/fs/locks.c b/fs/locks.c
index 8eddae23e10b..2506bbc9a81f 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1624,12 +1624,12 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
  * bother, maybe that's a sign this just isn't a good file to
  * hand out a delegation on.
  */
- if (is_deleg && !mutex_trylock(&inode->i_mutex))
+ if (is_deleg && !inode_trylock(inode))
  return -EAGAIN;
 
  if (is_deleg && arg == F_WRLCK) {
  /* Write delegations are not currently supported: */
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  WARN_ON_ONCE(1);
  return -EINVAL;
  }
@@ -1706,7 +1706,7 @@ out:
  spin_unlock(&ctx->flc_lock);
  locks_dispose_list(&dispose);
  if (is_deleg)
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  if (!error && !my_fl)
  *flp = NULL;
  return error;
diff --git a/fs/logfs/file.c b/fs/logfs/file.c
index 1a6f0167b16a..61eaeb1b6cac 100644
--- a/fs/logfs/file.c
+++ b/fs/logfs/file.c
@@ -204,12 +204,12 @@ long logfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  if (err)
  return err;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  oldflags = li->li_flags;
  flags &= LOGFS_FL_USER_MODIFIABLE;
  flags |= oldflags & ~LOGFS_FL_USER_MODIFIABLE;
  li->li_flags = flags;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  inode->i_ctime = CURRENT_TIME;
  mark_inode_dirty_sync(inode);
@@ -230,11 +230,11 @@ int logfs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
  if (ret)
  return ret;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  logfs_get_wblocks(sb, NULL, WF_LOCK);
  logfs_write_anchor(sb);
  logfs_put_wblocks(sb, NULL, WF_LOCK);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return 0;
 }
diff --git a/fs/namei.c b/fs/namei.c
index 58272fd20234..ab1de2c3c4bf 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1644,9 +1644,9 @@ static int lookup_slow(struct nameidata *nd, struct path *path)
  parent = nd->path.dentry;
  BUG_ON(nd->inode != parent->d_inode);
 
- mutex_lock(&parent->d_inode->i_mutex);
+ inode_lock(parent->d_inode);
  dentry = __lookup_hash(&nd->last, parent, nd->flags);
- mutex_unlock(&parent->d_inode->i_mutex);
+ inode_unlock(parent->d_inode);
  if (IS_ERR(dentry))
  return PTR_ERR(dentry);
  path->mnt = nd->path.mnt;
@@ -2253,10 +2253,10 @@ struct dentry *kern_path_locked(const char *name, struct path *path)
  putname(filename);
  return ERR_PTR(-EINVAL);
  }
- mutex_lock_nested(&path->dentry->d_inode->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(path->dentry->d_inode, I_MUTEX_PARENT);
  d = __lookup_hash(&last, path->dentry, 0);
  if (IS_ERR(d)) {
- mutex_unlock(&path->dentry->d_inode->i_mutex);
+ inode_unlock(path->dentry->d_inode);
  path_put(path);
  }
  putname(filename);
@@ -2304,7 +2304,7 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
  unsigned int c;
  int err;
 
- WARN_ON_ONCE(!mutex_is_locked(&base->d_inode->i_mutex));
+ WARN_ON_ONCE(!inode_is_locked(base->d_inode));
 
  this.name = name;
  this.len = len;
@@ -2416,7 +2416,7 @@ mountpoint_last(struct nameidata *nd, struct path *path)
  goto done;
  }
 
- mutex_lock(&dir->d_inode->i_mutex);
+ inode_lock(dir->d_inode);
  dentry = d_lookup(dir, &nd->last);
  if (!dentry) {
  /*
@@ -2426,16 +2426,16 @@ mountpoint_last(struct nameidata *nd, struct path *path)
  */
  dentry = d_alloc(dir, &nd->last);
  if (!dentry) {
- mutex_unlock(&dir->d_inode->i_mutex);
+ inode_unlock(dir->d_inode);
  return -ENOMEM;
  }
  dentry = lookup_real(dir->d_inode, dentry, nd->flags);
  if (IS_ERR(dentry)) {
- mutex_unlock(&dir->d_inode->i_mutex);
+ inode_unlock(dir->d_inode);
  return PTR_ERR(dentry);
  }
  }
- mutex_unlock(&dir->d_inode->i_mutex);
+ inode_unlock(dir->d_inode);
 
 done:
  if (d_is_negative(dentry)) {
@@ -2632,7 +2632,7 @@ struct dentry *lock_rename(struct dentry *p1, struct dentry *p2)
  struct dentry *p;
 
  if (p1 == p2) {
- mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(p1->d_inode, I_MUTEX_PARENT);
  return NULL;
  }
 
@@ -2640,29 +2640,29 @@ struct dentry *lock_rename(struct dentry *p1, struct dentry *p2)
 
  p = d_ancestor(p2, p1);
  if (p) {
- mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_PARENT);
- mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_CHILD);
+ inode_lock_nested(p2->d_inode, I_MUTEX_PARENT);
+ inode_lock_nested(p1->d_inode, I_MUTEX_CHILD);
  return p;
  }
 
  p = d_ancestor(p1, p2);
  if (p) {
- mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT);
- mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_CHILD);
+ inode_lock_nested(p1->d_inode, I_MUTEX_PARENT);
+ inode_lock_nested(p2->d_inode, I_MUTEX_CHILD);
  return p;
  }
 
- mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT);
- mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_PARENT2);
+ inode_lock_nested(p1->d_inode, I_MUTEX_PARENT);
+ inode_lock_nested(p2->d_inode, I_MUTEX_PARENT2);
  return NULL;
 }
 EXPORT_SYMBOL(lock_rename);
 
 void unlock_rename(struct dentry *p1, struct dentry *p2)
 {
- mutex_unlock(&p1->d_inode->i_mutex);
+ inode_unlock(p1->d_inode);
  if (p1 != p2) {
- mutex_unlock(&p2->d_inode->i_mutex);
+ inode_unlock(p2->d_inode);
  mutex_unlock(&p1->d_inode->i_sb->s_vfs_rename_mutex);
  }
 }
@@ -3093,9 +3093,9 @@ retry_lookup:
  * dropping this one anyway.
  */
  }
- mutex_lock(&dir->d_inode->i_mutex);
+ inode_lock(dir->d_inode);
  error = lookup_open(nd, &path, file, op, got_write, opened);
- mutex_unlock(&dir->d_inode->i_mutex);
+ inode_unlock(dir->d_inode);
 
  if (error <= 0) {
  if (error)
@@ -3443,7 +3443,7 @@ static struct dentry *filename_create(int dfd, struct filename *name,
  * Do the final lookup.
  */
  lookup_flags |= LOOKUP_CREATE | LOOKUP_EXCL;
- mutex_lock_nested(&path->dentry->d_inode->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(path->dentry->d_inode, I_MUTEX_PARENT);
  dentry = __lookup_hash(&last, path->dentry, lookup_flags);
  if (IS_ERR(dentry))
  goto unlock;
@@ -3472,7 +3472,7 @@ fail:
  dput(dentry);
  dentry = ERR_PTR(error);
 unlock:
- mutex_unlock(&path->dentry->d_inode->i_mutex);
+ inode_unlock(path->dentry->d_inode);
  if (!err2)
  mnt_drop_write(path->mnt);
 out:
@@ -3492,7 +3492,7 @@ EXPORT_SYMBOL(kern_path_create);
 void done_path_create(struct path *path, struct dentry *dentry)
 {
  dput(dentry);
- mutex_unlock(&path->dentry->d_inode->i_mutex);
+ inode_unlock(path->dentry->d_inode);
  mnt_drop_write(path->mnt);
  path_put(path);
 }
@@ -3689,7 +3689,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
  return -EPERM;
 
  dget(dentry);
- mutex_lock(&dentry->d_inode->i_mutex);
+ inode_lock(dentry->d_inode);
 
  error = -EBUSY;
  if (is_local_mountpoint(dentry))
@@ -3709,7 +3709,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
  detach_mounts(dentry);
 
 out:
- mutex_unlock(&dentry->d_inode->i_mutex);
+ inode_unlock(dentry->d_inode);
  dput(dentry);
  if (!error)
  d_delete(dentry);
@@ -3748,7 +3748,7 @@ retry:
  if (error)
  goto exit1;
 
- mutex_lock_nested(&path.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(path.dentry->d_inode, I_MUTEX_PARENT);
  dentry = __lookup_hash(&last, path.dentry, lookup_flags);
  error = PTR_ERR(dentry);
  if (IS_ERR(dentry))
@@ -3764,7 +3764,7 @@ retry:
 exit3:
  dput(dentry);
 exit2:
- mutex_unlock(&path.dentry->d_inode->i_mutex);
+ inode_unlock(path.dentry->d_inode);
  mnt_drop_write(path.mnt);
 exit1:
  path_put(&path);
@@ -3810,7 +3810,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry, struct inode **delegate
  if (!dir->i_op->unlink)
  return -EPERM;
 
- mutex_lock(&target->i_mutex);
+ inode_lock(target);
  if (is_local_mountpoint(dentry))
  error = -EBUSY;
  else {
@@ -3827,7 +3827,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry, struct inode **delegate
  }
  }
 out:
- mutex_unlock(&target->i_mutex);
+ inode_unlock(target);
 
  /* We don't d_delete() NFS sillyrenamed files--they still exist. */
  if (!error && !(dentry->d_flags & DCACHE_NFSFS_RENAMED)) {
@@ -3870,7 +3870,7 @@ retry:
  if (error)
  goto exit1;
 retry_deleg:
- mutex_lock_nested(&path.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(path.dentry->d_inode, I_MUTEX_PARENT);
  dentry = __lookup_hash(&last, path.dentry, lookup_flags);
  error = PTR_ERR(dentry);
  if (!IS_ERR(dentry)) {
@@ -3888,7 +3888,7 @@ retry_deleg:
 exit2:
  dput(dentry);
  }
- mutex_unlock(&path.dentry->d_inode->i_mutex);
+ inode_unlock(path.dentry->d_inode);
  if (inode)
  iput(inode); /* truncate the inode here */
  inode = NULL;
@@ -4047,7 +4047,7 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
  if (error)
  return error;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  /* Make sure we don't allow creating hardlink to an unlinked file */
  if (inode->i_nlink == 0 && !(inode->i_state & I_LINKABLE))
  error =  -ENOENT;
@@ -4064,7 +4064,7 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
  inode->i_state &= ~I_LINKABLE;
  spin_unlock(&inode->i_lock);
  }
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  if (!error)
  fsnotify_link(dir, inode, new_dentry);
  return error;
@@ -4268,7 +4268,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
  if (!is_dir || (flags & RENAME_EXCHANGE))
  lock_two_nondirectories(source, target);
  else if (target)
- mutex_lock(&target->i_mutex);
+ inode_lock(target);
 
  error = -EBUSY;
  if (is_local_mountpoint(old_dentry) || is_local_mountpoint(new_dentry))
@@ -4321,7 +4321,7 @@ out:
  if (!is_dir || (flags & RENAME_EXCHANGE))
  unlock_two_nondirectories(source, target);
  else if (target)
- mutex_unlock(&target->i_mutex);
+ inode_unlock(target);
  dput(new_dentry);
  if (!error) {
  fsnotify_move(old_dir, new_dir, old_name.name, is_dir,
diff --git a/fs/namespace.c b/fs/namespace.c
index e0bbe2c3cac6..196bf1fc2a26 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2048,9 +2048,9 @@ static struct mountpoint *lock_mount(struct path *path)
  struct vfsmount *mnt;
  struct dentry *dentry = path->dentry;
 retry:
- mutex_lock(&dentry->d_inode->i_mutex);
+ inode_lock(dentry->d_inode);
  if (unlikely(cant_mount(dentry))) {
- mutex_unlock(&dentry->d_inode->i_mutex);
+ inode_unlock(dentry->d_inode);
  return ERR_PTR(-ENOENT);
  }
  namespace_lock();
@@ -2059,13 +2059,13 @@ retry:
  struct mountpoint *mp = get_mountpoint(dentry);
  if (IS_ERR(mp)) {
  namespace_unlock();
- mutex_unlock(&dentry->d_inode->i_mutex);
+ inode_unlock(dentry->d_inode);
  return mp;
  }
  return mp;
  }
  namespace_unlock();
- mutex_unlock(&path->dentry->d_inode->i_mutex);
+ inode_unlock(path->dentry->d_inode);
  path_put(path);
  path->mnt = mnt;
  dentry = path->dentry = dget(mnt->mnt_root);
@@ -2081,7 +2081,7 @@ static void unlock_mount(struct mountpoint *where)
  read_sequnlock_excl(&mount_lock);
 
  namespace_unlock();
- mutex_unlock(&dentry->d_inode->i_mutex);
+ inode_unlock(dentry->d_inode);
 }
 
 static int graft_tree(struct mount *mnt, struct mount *p, struct mountpoint *mp)
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index 03446c5a3ec1..b7f8eaeea5d8 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -369,7 +369,7 @@ ncp_lookup_validate(struct dentry *dentry, unsigned int flags)
  if (!res) {
  struct inode *inode = d_inode(dentry);
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  if (finfo.i.dirEntNum == NCP_FINFO(inode)->dirEntNum) {
  ncp_new_dentry(dentry);
  val=1;
@@ -377,7 +377,7 @@ ncp_lookup_validate(struct dentry *dentry, unsigned int flags)
  ncp_dbg(2, "found, but dirEntNum changed\n");
 
  ncp_update_inode2(inode, &finfo);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
 
 finished:
@@ -639,9 +639,9 @@ ncp_fill_cache(struct file *file, struct dir_context *ctx,
  } else {
  struct inode *inode = d_inode(newdent);
 
- mutex_lock_nested(&inode->i_mutex, I_MUTEX_CHILD);
+ inode_lock_nested(inode, I_MUTEX_CHILD);
  ncp_update_inode2(inode, entry);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
 
  if (ctl.idx >= NCP_DIRCACHE_SIZE) {
diff --git a/fs/ncpfs/file.c b/fs/ncpfs/file.c
index 011324ce9df2..dd38ca1f2ecb 100644
--- a/fs/ncpfs/file.c
+++ b/fs/ncpfs/file.c
@@ -224,10 +224,10 @@ ncp_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
  iocb->ki_pos = pos;
 
  if (pos > i_size_read(inode)) {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  if (pos > i_size_read(inode))
  i_size_write(inode, pos);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
  ncp_dbg(1, "exit %pD2\n", file);
 outrel:
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 348e0a05bd18..6cda3ef95f64 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -929,7 +929,7 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence)
  dfprintk(FILE, "NFS: llseek dir(%pD2, %lld, %d)\n",
  filp, offset, whence);
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  switch (whence) {
  case 1:
  offset += filp->f_pos;
@@ -946,7 +946,7 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence)
  dir_ctx->duped = 0;
  }
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return offset;
 }
 
@@ -961,9 +961,9 @@ static int nfs_fsync_dir(struct file *filp, loff_t start, loff_t end,
 
  dfprintk(FILE, "NFS: fsync dir(%pD2) datasync %d\n", filp, datasync);
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  nfs_inc_stats(inode, NFSIOS_VFSFSYNC);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return 0;
 }
 
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 4b1d08f56aba..9a3eb31d09d1 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -586,7 +586,7 @@ ssize_t nfs_file_direct_read(struct kiocb *iocb, struct iov_iter *iter,
  if (!count)
  goto out;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  result = nfs_sync_mapping(mapping);
  if (result)
  goto out_unlock;
@@ -614,7 +614,7 @@ ssize_t nfs_file_direct_read(struct kiocb *iocb, struct iov_iter *iter,
  NFS_I(inode)->read_io += count;
  result = nfs_direct_read_schedule_iovec(dreq, iter, pos);
 
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  if (!result) {
  result = nfs_direct_wait(dreq);
@@ -628,7 +628,7 @@ ssize_t nfs_file_direct_read(struct kiocb *iocb, struct iov_iter *iter,
 out_release:
  nfs_direct_req_release(dreq);
 out_unlock:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 out:
  return result;
 }
@@ -977,7 +977,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter)
  pos = iocb->ki_pos;
  end = (pos + iov_iter_count(iter) - 1) >> PAGE_CACHE_SHIFT;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  result = nfs_sync_mapping(mapping);
  if (result)
@@ -1017,7 +1017,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter)
       pos >> PAGE_CACHE_SHIFT, end);
  }
 
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  if (!result) {
  result = nfs_direct_wait(dreq);
@@ -1038,7 +1038,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter)
 out_release:
  nfs_direct_req_release(dreq);
 out_unlock:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return result;
 }
 
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index dc875cd0e11d..bcc49660a5f3 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -278,9 +278,9 @@ nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
  ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
  if (ret != 0)
  break;
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  ret = nfs_file_fsync_commit(file, start, end, datasync);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  /*
  * If nfs_file_fsync_commit detected a server reboot, then
  * resend all dirty pages that might have been covered by
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 668ac19af58f..0cf4ce371d9a 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -654,9 +654,9 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
  trace_nfs_getattr_enter(inode);
  /* Flush out writes to the server in order to update c/mtime.  */
  if (S_ISREG(inode->i_mode)) {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  err = nfs_sync_inode(inode);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  if (err)
  goto out;
  }
@@ -1144,9 +1144,9 @@ static int __nfs_revalidate_mapping(struct inode *inode,
  spin_unlock(&inode->i_lock);
  trace_nfs_invalidate_mapping_enter(inode);
  if (may_lock) {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  ret = nfs_invalidate_mapping(inode, mapping);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  } else
  ret = nfs_invalidate_mapping(inode, mapping);
  trace_nfs_invalidate_mapping_exit(inode, ret);
diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index 7f1a0fb8c493..daeacf21252a 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -101,13 +101,13 @@ int nfs42_proc_allocate(struct file *filep, loff_t offset, loff_t len)
  if (!nfs_server_capable(inode, NFS_CAP_ALLOCATE))
  return -EOPNOTSUPP;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  err = nfs42_proc_fallocate(&msg, filep, offset, len);
  if (err == -EOPNOTSUPP)
  NFS_SERVER(inode)->caps &= ~NFS_CAP_ALLOCATE;
 
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return err;
 }
 
@@ -123,7 +123,7 @@ int nfs42_proc_deallocate(struct file *filep, loff_t offset, loff_t len)
  return -EOPNOTSUPP;
 
  nfs_wb_all(inode);
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  err = nfs42_proc_fallocate(&msg, filep, offset, len);
  if (err == 0)
@@ -131,7 +131,7 @@ int nfs42_proc_deallocate(struct file *filep, loff_t offset, loff_t len)
  if (err == -EOPNOTSUPP)
  NFS_SERVER(inode)->caps &= ~NFS_CAP_DEALLOCATE;
 
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return err;
 }
 
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
index 679e003818b1..1594065cd6c2 100644
--- a/fs/nfs/nfs4file.c
+++ b/fs/nfs/nfs4file.c
@@ -141,11 +141,11 @@ nfs4_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
  ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
  if (ret != 0)
  break;
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  ret = nfs_file_fsync_commit(file, start, end, datasync);
  if (!ret)
  ret = pnfs_sync_inode(inode, !!datasync);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  /*
  * If nfs_file_fsync_commit detected a server reboot, then
  * resend all dirty pages that might have been covered by
@@ -257,13 +257,13 @@ nfs42_ioctl_clone(struct file *dst_file, unsigned long srcfd,
 
  /* XXX: do we lock at all? what if server needs CB_RECALL_LAYOUT? */
  if (same_inode) {
- mutex_lock(&src_inode->i_mutex);
+ inode_lock(src_inode);
  } else if (dst_inode < src_inode) {
- mutex_lock_nested(&dst_inode->i_mutex, I_MUTEX_PARENT);
- mutex_lock_nested(&src_inode->i_mutex, I_MUTEX_CHILD);
+ inode_lock_nested(dst_inode, I_MUTEX_PARENT);
+ inode_lock_nested(src_inode, I_MUTEX_CHILD);
  } else {
- mutex_lock_nested(&src_inode->i_mutex, I_MUTEX_PARENT);
- mutex_lock_nested(&dst_inode->i_mutex, I_MUTEX_CHILD);
+ inode_lock_nested(src_inode, I_MUTEX_PARENT);
+ inode_lock_nested(dst_inode, I_MUTEX_CHILD);
  }
 
  /* flush all pending writes on both src and dst so that server
@@ -284,13 +284,13 @@ nfs42_ioctl_clone(struct file *dst_file, unsigned long srcfd,
 
 out_unlock:
  if (same_inode) {
- mutex_unlock(&src_inode->i_mutex);
+ inode_unlock(src_inode);
  } else if (dst_inode < src_inode) {
- mutex_unlock(&src_inode->i_mutex);
- mutex_unlock(&dst_inode->i_mutex);
+ inode_unlock(src_inode);
+ inode_unlock(dst_inode);
  } else {
- mutex_unlock(&dst_inode->i_mutex);
- mutex_unlock(&src_inode->i_mutex);
+ inode_unlock(dst_inode);
+ inode_unlock(src_inode);
  }
 out_fput:
  fdput(src_file);
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 209dbfc50cd4..00482339b7e7 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -55,10 +55,10 @@ nfsd4_security_inode_setsecctx(struct svc_fh *resfh, struct xdr_netobj *label, u
  struct inode *inode = d_inode(resfh->fh_dentry);
  int status;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  status = security_inode_setsecctx(resfh->fh_dentry,
  label->data, label->len);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  if (status)
  /*
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index e3d47091b191..2cbb37d456c7 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -192,7 +192,7 @@ nfsd4_create_clid_dir(struct nfs4_client *clp)
 
  dir = nn->rec_file->f_path.dentry;
  /* lock the parent */
- mutex_lock(&d_inode(dir)->i_mutex);
+ inode_lock(d_inode(dir));
 
  dentry = lookup_one_len(dname, dir, HEXDIR_LEN-1);
  if (IS_ERR(dentry)) {
@@ -213,7 +213,7 @@ nfsd4_create_clid_dir(struct nfs4_client *clp)
 out_put:
  dput(dentry);
 out_unlock:
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
  if (status == 0) {
  if (nn->in_grace) {
  crp = nfs4_client_to_reclaim(dname, nn);
@@ -286,7 +286,7 @@ nfsd4_list_rec_dir(recdir_func *f, struct nfsd_net *nn)
  }
 
  status = iterate_dir(nn->rec_file, &ctx.ctx);
- mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(d_inode(dir), I_MUTEX_PARENT);
 
  list_for_each_entry_safe(entry, tmp, &ctx.names, list) {
  if (!status) {
@@ -302,7 +302,7 @@ nfsd4_list_rec_dir(recdir_func *f, struct nfsd_net *nn)
  list_del(&entry->list);
  kfree(entry);
  }
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
  nfs4_reset_creds(original_cred);
 
  list_for_each_entry_safe(entry, tmp, &ctx.names, list) {
@@ -322,7 +322,7 @@ nfsd4_unlink_clid_dir(char *name, int namlen, struct nfsd_net *nn)
  dprintk("NFSD: nfsd4_unlink_clid_dir. name %.*s\n", namlen, name);
 
  dir = nn->rec_file->f_path.dentry;
- mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(d_inode(dir), I_MUTEX_PARENT);
  dentry = lookup_one_len(name, dir, namlen);
  if (IS_ERR(dentry)) {
  status = PTR_ERR(dentry);
@@ -335,7 +335,7 @@ nfsd4_unlink_clid_dir(char *name, int namlen, struct nfsd_net *nn)
 out:
  dput(dentry);
 out_unlock:
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
  return status;
 }
 
diff --git a/fs/nfsd/nfsfh.h b/fs/nfsd/nfsfh.h
index 2087bae17582..0f26b99f890f 100644
--- a/fs/nfsd/nfsfh.h
+++ b/fs/nfsd/nfsfh.h
@@ -265,7 +265,7 @@ fh_lock_nested(struct svc_fh *fhp, unsigned int subclass)
  }
 
  inode = d_inode(dentry);
- mutex_lock_nested(&inode->i_mutex, subclass);
+ inode_lock_nested(inode, subclass);
  fill_pre_wcc(fhp);
  fhp->fh_locked = true;
 }
@@ -284,7 +284,7 @@ fh_unlock(struct svc_fh *fhp)
 {
  if (fhp->fh_locked) {
  fill_post_wcc(fhp);
- mutex_unlock(&d_inode(fhp->fh_dentry)->i_mutex);
+ inode_unlock(d_inode(fhp->fh_dentry));
  fhp->fh_locked = false;
  }
 }
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 91e0c5429b4d..ba0e9e1b6b0f 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -500,9 +500,9 @@ __be32 nfsd4_set_nfs4_label(struct svc_rqst *rqstp, struct svc_fh *fhp,
 
  dentry = fhp->fh_dentry;
 
- mutex_lock(&d_inode(dentry)->i_mutex);
+ inode_lock(d_inode(dentry));
  host_error = security_inode_setsecctx(dentry, label->data, label->len);
- mutex_unlock(&d_inode(dentry)->i_mutex);
+ inode_unlock(d_inode(dentry));
  return nfserrno(host_error);
 }
 #else
@@ -1868,7 +1868,7 @@ static __be32 nfsd_buffered_readdir(struct file *file, nfsd_filldir_t func,
  size -= reclen;
  de = (struct buffered_dirent *)((char *)de + reclen);
  }
- mutex_unlock(&dir_inode->i_mutex);
+ inode_unlock(dir_inode);
  if (size > 0) /* We bailed out early */
  break;
 
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 00877ef0b120..03328d1a25fa 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -1002,7 +1002,7 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
  if (ret)
  return ret;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  isize = i_size_read(inode);
 
@@ -1112,6 +1112,6 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
  if (ret == 1)
  ret = 0;
 
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index aba43811d6ef..e8fe24882b5b 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -158,7 +158,7 @@ static int nilfs_ioctl_setflags(struct inode *inode, struct file *filp,
 
  flags = nilfs_mask_flags(inode->i_mode, flags);
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  oldflags = NILFS_I(inode)->i_flags;
 
@@ -186,7 +186,7 @@ static int nilfs_ioctl_setflags(struct inode *inode, struct file *filp,
  nilfs_mark_inode_dirty(inode);
  ret = nilfs_transaction_commit(inode->i_sb);
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  mnt_drop_write_file(filp);
  return ret;
 }
diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
index 9e38dafa3bc7..b2eff5816adc 100644
--- a/fs/ntfs/dir.c
+++ b/fs/ntfs/dir.c
@@ -1509,7 +1509,7 @@ static int ntfs_dir_fsync(struct file *filp, loff_t start, loff_t end,
  err = filemap_write_and_wait_range(vi->i_mapping, start, end);
  if (err)
  return err;
- mutex_lock(&vi->i_mutex);
+ inode_lock(vi);
 
  BUG_ON(!S_ISDIR(vi->i_mode));
  /* If the bitmap attribute inode is in memory sync it, too. */
@@ -1532,7 +1532,7 @@ static int ntfs_dir_fsync(struct file *filp, loff_t start, loff_t end,
  else
  ntfs_warning(vi->i_sb, "Failed to f%ssync inode 0x%lx.  Error "
  "%u.", datasync ? "data" : "", vi->i_ino, -ret);
- mutex_unlock(&vi->i_mutex);
+ inode_unlock(vi);
  return ret;
 }
 
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 9d383e5eff0e..bed4d427dfae 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -1944,14 +1944,14 @@ static ssize_t ntfs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
  ssize_t written = 0;
  ssize_t err;
 
- mutex_lock(&vi->i_mutex);
+ inode_lock(vi);
  /* We can write back this queue in page reclaim. */
  current->backing_dev_info = inode_to_bdi(vi);
  err = ntfs_prepare_file_for_write(iocb, from);
  if (iov_iter_count(from) && !err)
  written = ntfs_perform_write(file, from, iocb->ki_pos);
  current->backing_dev_info = NULL;
- mutex_unlock(&vi->i_mutex);
+ inode_unlock(vi);
  if (likely(written > 0)) {
  err = generic_write_sync(file, iocb->ki_pos, written);
  if (err < 0)
@@ -1996,7 +1996,7 @@ static int ntfs_file_fsync(struct file *filp, loff_t start, loff_t end,
  err = filemap_write_and_wait_range(vi->i_mapping, start, end);
  if (err)
  return err;
- mutex_lock(&vi->i_mutex);
+ inode_lock(vi);
 
  BUG_ON(S_ISDIR(vi->i_mode));
  if (!datasync || !NInoNonResident(NTFS_I(vi)))
@@ -2015,7 +2015,7 @@ static int ntfs_file_fsync(struct file *filp, loff_t start, loff_t end,
  else
  ntfs_warning(vi->i_sb, "Failed to f%ssync inode 0x%lx.  Error "
  "%u.", datasync ? "data" : "", vi->i_ino, -ret);
- mutex_unlock(&vi->i_mutex);
+ inode_unlock(vi);
  return ret;
 }
 
diff --git a/fs/ntfs/quota.c b/fs/ntfs/quota.c
index d80e3315cab0..9793e68ba1dd 100644
--- a/fs/ntfs/quota.c
+++ b/fs/ntfs/quota.c
@@ -48,7 +48,7 @@ bool ntfs_mark_quotas_out_of_date(ntfs_volume *vol)
  ntfs_error(vol->sb, "Quota inodes are not open.");
  return false;
  }
- mutex_lock(&vol->quota_q_ino->i_mutex);
+ inode_lock(vol->quota_q_ino);
  ictx = ntfs_index_ctx_get(NTFS_I(vol->quota_q_ino));
  if (!ictx) {
  ntfs_error(vol->sb, "Failed to get index context.");
@@ -98,7 +98,7 @@ bool ntfs_mark_quotas_out_of_date(ntfs_volume *vol)
  ntfs_index_entry_mark_dirty(ictx);
 set_done:
  ntfs_index_ctx_put(ictx);
- mutex_unlock(&vol->quota_q_ino->i_mutex);
+ inode_unlock(vol->quota_q_ino);
  /*
  * We set the flag so we do not try to mark the quotas out of date
  * again on remount.
@@ -110,7 +110,7 @@ done:
 err_out:
  if (ictx)
  ntfs_index_ctx_put(ictx);
- mutex_unlock(&vol->quota_q_ino->i_mutex);
+ inode_unlock(vol->quota_q_ino);
  return false;
 }
 
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index d1a853585b53..c3e6bec0684d 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -1284,10 +1284,10 @@ static int check_windows_hibernation_status(ntfs_volume *vol)
  * Find the inode number for the hibernation file by looking up the
  * filename hiberfil.sys in the root directory.
  */
- mutex_lock(&vol->root_ino->i_mutex);
+ inode_lock(vol->root_ino);
  mref = ntfs_lookup_inode_by_name(NTFS_I(vol->root_ino), hiberfil, 12,
  &name);
- mutex_unlock(&vol->root_ino->i_mutex);
+ inode_unlock(vol->root_ino);
  if (IS_ERR_MREF(mref)) {
  ret = MREF_ERR(mref);
  /* If the file does not exist, Windows is not hibernated. */
@@ -1377,10 +1377,10 @@ static bool load_and_init_quota(ntfs_volume *vol)
  * Find the inode number for the quota file by looking up the filename
  * $Quota in the extended system files directory $Extend.
  */
- mutex_lock(&vol->extend_ino->i_mutex);
+ inode_lock(vol->extend_ino);
  mref = ntfs_lookup_inode_by_name(NTFS_I(vol->extend_ino), Quota, 6,
  &name);
- mutex_unlock(&vol->extend_ino->i_mutex);
+ inode_unlock(vol->extend_ino);
  if (IS_ERR_MREF(mref)) {
  /*
  * If the file does not exist, quotas are disabled and have
@@ -1460,10 +1460,10 @@ static bool load_and_init_usnjrnl(ntfs_volume *vol)
  * Find the inode number for the transaction log file by looking up the
  * filename $UsnJrnl in the extended system files directory $Extend.
  */
- mutex_lock(&vol->extend_ino->i_mutex);
+ inode_lock(vol->extend_ino);
  mref = ntfs_lookup_inode_by_name(NTFS_I(vol->extend_ino), UsnJrnl, 8,
  &name);
- mutex_unlock(&vol->extend_ino->i_mutex);
+ inode_unlock(vol->extend_ino);
  if (IS_ERR_MREF(mref)) {
  /*
  * If the file does not exist, transaction logging is disabled,
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 93e6f029a322..44bf1ced16cd 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -5719,7 +5719,7 @@ int ocfs2_remove_btree_range(struct inode *inode,
  goto bail;
  }
 
- mutex_lock(&tl_inode->i_mutex);
+ inode_lock(tl_inode);
 
  if (ocfs2_truncate_log_needs_flush(osb)) {
  ret = __ocfs2_flush_truncate_log(osb);
@@ -5776,7 +5776,7 @@ int ocfs2_remove_btree_range(struct inode *inode,
 out_commit:
  ocfs2_commit_trans(osb, handle);
 out:
- mutex_unlock(&tl_inode->i_mutex);
+ inode_unlock(tl_inode);
 bail:
  if (meta_ac)
  ocfs2_free_alloc_context(meta_ac);
@@ -5832,7 +5832,7 @@ int ocfs2_truncate_log_append(struct ocfs2_super *osb,
  struct ocfs2_dinode *di;
  struct ocfs2_truncate_log *tl;
 
- BUG_ON(mutex_trylock(&tl_inode->i_mutex));
+ BUG_ON(inode_trylock(tl_inode));
 
  start_cluster = ocfs2_blocks_to_clusters(osb->sb, start_blk);
 
@@ -5980,7 +5980,7 @@ int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
  struct ocfs2_dinode *di;
  struct ocfs2_truncate_log *tl;
 
- BUG_ON(mutex_trylock(&tl_inode->i_mutex));
+ BUG_ON(inode_trylock(tl_inode));
 
  di = (struct ocfs2_dinode *) tl_bh->b_data;
 
@@ -6008,7 +6008,7 @@ int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
  goto out;
  }
 
- mutex_lock(&data_alloc_inode->i_mutex);
+ inode_lock(data_alloc_inode);
 
  status = ocfs2_inode_lock(data_alloc_inode, &data_alloc_bh, 1);
  if (status < 0) {
@@ -6035,7 +6035,7 @@ out_unlock:
  ocfs2_inode_unlock(data_alloc_inode, 1);
 
 out_mutex:
- mutex_unlock(&data_alloc_inode->i_mutex);
+ inode_unlock(data_alloc_inode);
  iput(data_alloc_inode);
 
 out:
@@ -6047,9 +6047,9 @@ int ocfs2_flush_truncate_log(struct ocfs2_super *osb)
  int status;
  struct inode *tl_inode = osb->osb_tl_inode;
 
- mutex_lock(&tl_inode->i_mutex);
+ inode_lock(tl_inode);
  status = __ocfs2_flush_truncate_log(osb);
- mutex_unlock(&tl_inode->i_mutex);
+ inode_unlock(tl_inode);
 
  return status;
 }
@@ -6209,7 +6209,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb,
  (unsigned long long)le64_to_cpu(tl_copy->i_blkno),
  num_recs);
 
- mutex_lock(&tl_inode->i_mutex);
+ inode_lock(tl_inode);
  for(i = 0; i < num_recs; i++) {
  if (ocfs2_truncate_log_needs_flush(osb)) {
  status = __ocfs2_flush_truncate_log(osb);
@@ -6240,7 +6240,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb,
  }
 
 bail_up:
- mutex_unlock(&tl_inode->i_mutex);
+ inode_unlock(tl_inode);
 
  return status;
 }
@@ -6347,7 +6347,7 @@ static int ocfs2_free_cached_blocks(struct ocfs2_super *osb,
  goto out;
  }
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  ret = ocfs2_inode_lock(inode, &di_bh, 1);
  if (ret) {
@@ -6396,7 +6396,7 @@ out_unlock:
  ocfs2_inode_unlock(inode, 1);
  brelse(di_bh);
 out_mutex:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  iput(inode);
 out:
  while(head) {
@@ -6440,7 +6440,7 @@ static int ocfs2_free_cached_clusters(struct ocfs2_super *osb,
  handle_t *handle;
  int ret = 0;
 
- mutex_lock(&tl_inode->i_mutex);
+ inode_lock(tl_inode);
 
  while (head) {
  if (ocfs2_truncate_log_needs_flush(osb)) {
@@ -6472,7 +6472,7 @@ static int ocfs2_free_cached_clusters(struct ocfs2_super *osb,
  }
  }
 
- mutex_unlock(&tl_inode->i_mutex);
+ inode_unlock(tl_inode);
 
  while (head) {
  /* Premature exit may have left some dangling items. */
@@ -7367,7 +7367,7 @@ int ocfs2_trim_fs(struct super_block *sb, struct fstrim_range *range)
  goto out;
  }
 
- mutex_lock(&main_bm_inode->i_mutex);
+ inode_lock(main_bm_inode);
 
  ret = ocfs2_inode_lock(main_bm_inode, &main_bm_bh, 0);
  if (ret < 0) {
@@ -7435,7 +7435,7 @@ out_unlock:
  ocfs2_inode_unlock(main_bm_inode, 0);
  brelse(main_bm_bh);
 out_mutex:
- mutex_unlock(&main_bm_inode->i_mutex);
+ inode_unlock(main_bm_inode);
  iput(main_bm_inode);
 out:
  return ret;
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index e4184bd2a954..7913cd6b67b2 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -2047,9 +2047,9 @@ static int ocfs2_try_to_free_truncate_log(struct ocfs2_super *osb,
  int ret = 0;
  unsigned int truncated_clusters;
 
- mutex_lock(&osb->osb_tl_inode->i_mutex);
+ inode_lock(osb->osb_tl_inode);
  truncated_clusters = osb->truncated_clusters;
- mutex_unlock(&osb->osb_tl_inode->i_mutex);
+ inode_unlock(osb->osb_tl_inode);
 
  /*
  * Check whether we can succeed in allocating if we free
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index ffecf89c8c1c..e1adf285fc31 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -4361,7 +4361,7 @@ static int ocfs2_dx_dir_remove_index(struct inode *dir,
  mlog_errno(ret);
  goto out;
  }
- mutex_lock(&dx_alloc_inode->i_mutex);
+ inode_lock(dx_alloc_inode);
 
  ret = ocfs2_inode_lock(dx_alloc_inode, &dx_alloc_bh, 1);
  if (ret) {
@@ -4410,7 +4410,7 @@ out_unlock:
  ocfs2_inode_unlock(dx_alloc_inode, 1);
 
 out_mutex:
- mutex_unlock(&dx_alloc_inode->i_mutex);
+ inode_unlock(dx_alloc_inode);
  brelse(dx_alloc_bh);
 out:
  iput(dx_alloc_inode);
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 1d738723a41a..c8d2c85de564 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1878,7 +1878,7 @@ static int __ocfs2_change_file_space(struct file *file, struct inode *inode,
  if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb))
  return -EROFS;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  /*
  * This prevents concurrent writes on other nodes
@@ -1997,7 +1997,7 @@ out_rw_unlock:
  ocfs2_rw_unlock(inode, 1);
 
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return ret;
 }
 
@@ -2305,7 +2305,7 @@ static ssize_t ocfs2_file_write_iter(struct kiocb *iocb,
  appending = iocb->ki_flags & IOCB_APPEND ? 1 : 0;
  direct_io = iocb->ki_flags & IOCB_DIRECT ? 1 : 0;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
 relock:
  /*
@@ -2441,7 +2441,7 @@ out:
  ocfs2_rw_unlock(inode, rw_level);
 
 out_mutex:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  if (written)
  ret = written;
@@ -2553,7 +2553,7 @@ static loff_t ocfs2_file_llseek(struct file *file, loff_t offset, int whence)
  struct inode *inode = file->f_mapping->host;
  int ret = 0;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  switch (whence) {
  case SEEK_SET:
@@ -2591,7 +2591,7 @@ static loff_t ocfs2_file_llseek(struct file *file, loff_t offset, int whence)
  offset = vfs_setpos(file, offset, inode->i_sb->s_maxbytes);
 
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  if (ret)
  return ret;
  return offset;
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 8f87e05ee25d..55ca5ffc0bbf 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -629,10 +629,10 @@ static int ocfs2_remove_inode(struct inode *inode,
  goto bail;
  }
 
- mutex_lock(&inode_alloc_inode->i_mutex);
+ inode_lock(inode_alloc_inode);
  status = ocfs2_inode_lock(inode_alloc_inode, &inode_alloc_bh, 1);
  if (status < 0) {
- mutex_unlock(&inode_alloc_inode->i_mutex);
+ inode_unlock(inode_alloc_inode);
 
  mlog_errno(status);
  goto bail;
@@ -679,7 +679,7 @@ bail_commit:
  ocfs2_commit_trans(osb, handle);
 bail_unlock:
  ocfs2_inode_unlock(inode_alloc_inode, 1);
- mutex_unlock(&inode_alloc_inode->i_mutex);
+ inode_unlock(inode_alloc_inode);
  brelse(inode_alloc_bh);
 bail:
  iput(inode_alloc_inode);
@@ -750,10 +750,10 @@ static int ocfs2_wipe_inode(struct inode *inode,
  /* Lock the orphan dir. The lock will be held for the entire
  * delete_inode operation. We do this now to avoid races with
  * recovery completion on other nodes. */
- mutex_lock(&orphan_dir_inode->i_mutex);
+ inode_lock(orphan_dir_inode);
  status = ocfs2_inode_lock(orphan_dir_inode, &orphan_dir_bh, 1);
  if (status < 0) {
- mutex_unlock(&orphan_dir_inode->i_mutex);
+ inode_unlock(orphan_dir_inode);
 
  mlog_errno(status);
  goto bail;
@@ -802,7 +802,7 @@ bail_unlock_dir:
  return status;
 
  ocfs2_inode_unlock(orphan_dir_inode, 1);
- mutex_unlock(&orphan_dir_inode->i_mutex);
+ inode_unlock(orphan_dir_inode);
  brelse(orphan_dir_bh);
 bail:
  iput(orphan_dir_inode);
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
index 3cb097ccce60..c55754c95acb 100644
--- a/fs/ocfs2/ioctl.c
+++ b/fs/ocfs2/ioctl.c
@@ -86,7 +86,7 @@ static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
  unsigned oldflags;
  int status;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  status = ocfs2_inode_lock(inode, &bh, 1);
  if (status < 0) {
@@ -135,7 +135,7 @@ static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
 bail_unlock:
  ocfs2_inode_unlock(inode, 1);
 bail:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  brelse(bh);
 
@@ -287,7 +287,7 @@ static int ocfs2_info_scan_inode_alloc(struct ocfs2_super *osb,
  struct ocfs2_dinode *dinode_alloc = NULL;
 
  if (inode_alloc)
- mutex_lock(&inode_alloc->i_mutex);
+ inode_lock(inode_alloc);
 
  if (o2info_coherent(&fi->ifi_req)) {
  status = ocfs2_inode_lock(inode_alloc, &bh, 0);
@@ -317,7 +317,7 @@ bail:
  ocfs2_inode_unlock(inode_alloc, 0);
 
  if (inode_alloc)
- mutex_unlock(&inode_alloc->i_mutex);
+ inode_unlock(inode_alloc);
 
  brelse(bh);
 
@@ -547,7 +547,7 @@ static int ocfs2_info_freefrag_scan_bitmap(struct ocfs2_super *osb,
  struct ocfs2_dinode *gb_dinode = NULL;
 
  if (gb_inode)
- mutex_lock(&gb_inode->i_mutex);
+ inode_lock(gb_inode);
 
  if (o2info_coherent(&ffg->iff_req)) {
  status = ocfs2_inode_lock(gb_inode, &bh, 0);
@@ -604,7 +604,7 @@ bail:
  ocfs2_inode_unlock(gb_inode, 0);
 
  if (gb_inode)
- mutex_unlock(&gb_inode->i_mutex);
+ inode_unlock(gb_inode);
 
  if (gb_inode)
  iput(gb_inode);
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 13534f4fe5b5..200a30b7f51d 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -2092,7 +2092,7 @@ static int ocfs2_queue_orphans(struct ocfs2_super *osb,
  return status;
  }
 
- mutex_lock(&orphan_dir_inode->i_mutex);
+ inode_lock(orphan_dir_inode);
  status = ocfs2_inode_lock(orphan_dir_inode, NULL, 0);
  if (status < 0) {
  mlog_errno(status);
@@ -2110,7 +2110,7 @@ static int ocfs2_queue_orphans(struct ocfs2_super *osb,
 out_cluster:
  ocfs2_inode_unlock(orphan_dir_inode, 0);
 out:
- mutex_unlock(&orphan_dir_inode->i_mutex);
+ inode_unlock(orphan_dir_inode);
  iput(orphan_dir_inode);
  return status;
 }
@@ -2200,7 +2200,7 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb,
  oi->ip_next_orphan = NULL;
 
  if (oi->ip_flags & OCFS2_INODE_DIO_ORPHAN_ENTRY) {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  ret = ocfs2_rw_lock(inode, 1);
  if (ret < 0) {
  mlog_errno(ret);
@@ -2239,7 +2239,7 @@ unlock_inode:
 unlock_rw:
  ocfs2_rw_unlock(inode, 1);
 unlock_mutex:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  /* clear dio flag in ocfs2_inode_info */
  oi->ip_flags &= ~OCFS2_INODE_DIO_ORPHAN_ENTRY;
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 0a4457fb0711..c1c376509c84 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -415,7 +415,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
  goto out;
  }
 
- mutex_lock(&main_bm_inode->i_mutex);
+ inode_lock(main_bm_inode);
 
  status = ocfs2_inode_lock(main_bm_inode, &main_bm_bh, 1);
  if (status < 0) {
@@ -469,7 +469,7 @@ out_unlock:
  ocfs2_inode_unlock(main_bm_inode, 1);
 
 out_mutex:
- mutex_unlock(&main_bm_inode->i_mutex);
+ inode_unlock(main_bm_inode);
  iput(main_bm_inode);
 
 out:
@@ -508,7 +508,7 @@ int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb,
  goto bail;
  }
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  status = ocfs2_read_inode_block_full(inode, &alloc_bh,
      OCFS2_BH_IGNORE_CACHE);
@@ -541,7 +541,7 @@ bail:
  brelse(alloc_bh);
 
  if (inode) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  iput(inode);
  }
 
@@ -573,7 +573,7 @@ int ocfs2_complete_local_alloc_recovery(struct ocfs2_super *osb,
  goto out;
  }
 
- mutex_lock(&main_bm_inode->i_mutex);
+ inode_lock(main_bm_inode);
 
  status = ocfs2_inode_lock(main_bm_inode, &main_bm_bh, 1);
  if (status < 0) {
@@ -603,7 +603,7 @@ out_unlock:
  ocfs2_inode_unlock(main_bm_inode, 1);
 
 out_mutex:
- mutex_unlock(&main_bm_inode->i_mutex);
+ inode_unlock(main_bm_inode);
 
  brelse(main_bm_bh);
 
@@ -645,7 +645,7 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
  goto bail;
  }
 
- mutex_lock(&local_alloc_inode->i_mutex);
+ inode_lock(local_alloc_inode);
 
  /*
  * We must double check state and allocator bits because
@@ -711,7 +711,7 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
  status = 0;
 bail:
  if (status < 0 && local_alloc_inode) {
- mutex_unlock(&local_alloc_inode->i_mutex);
+ inode_unlock(local_alloc_inode);
  iput(local_alloc_inode);
  }
 
diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
index 124471d26a73..e3d05d9901a3 100644
--- a/fs/ocfs2/move_extents.c
+++ b/fs/ocfs2/move_extents.c
@@ -276,7 +276,7 @@ static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context,
  * context->data_ac->ac_resv = &OCFS2_I(inode)->ip_la_data_resv;
  */
 
- mutex_lock(&tl_inode->i_mutex);
+ inode_lock(tl_inode);
 
  if (ocfs2_truncate_log_needs_flush(osb)) {
  ret = __ocfs2_flush_truncate_log(osb);
@@ -338,7 +338,7 @@ out_commit:
  ocfs2_commit_trans(osb, handle);
 
 out_unlock_mutex:
- mutex_unlock(&tl_inode->i_mutex);
+ inode_unlock(tl_inode);
 
  if (context->data_ac) {
  ocfs2_free_alloc_context(context->data_ac);
@@ -632,7 +632,7 @@ static int ocfs2_move_extent(struct ocfs2_move_extents_context *context,
  goto out;
  }
 
- mutex_lock(&gb_inode->i_mutex);
+ inode_lock(gb_inode);
 
  ret = ocfs2_inode_lock(gb_inode, &gb_bh, 1);
  if (ret) {
@@ -640,7 +640,7 @@ static int ocfs2_move_extent(struct ocfs2_move_extents_context *context,
  goto out_unlock_gb_mutex;
  }
 
- mutex_lock(&tl_inode->i_mutex);
+ inode_lock(tl_inode);
 
  handle = ocfs2_start_trans(osb, credits);
  if (IS_ERR(handle)) {
@@ -708,11 +708,11 @@ out_commit:
  brelse(gd_bh);
 
 out_unlock_tl_inode:
- mutex_unlock(&tl_inode->i_mutex);
+ inode_unlock(tl_inode);
 
  ocfs2_inode_unlock(gb_inode, 1);
 out_unlock_gb_mutex:
- mutex_unlock(&gb_inode->i_mutex);
+ inode_unlock(gb_inode);
  brelse(gb_bh);
  iput(gb_inode);
 
@@ -905,7 +905,7 @@ static int ocfs2_move_extents(struct ocfs2_move_extents_context *context)
  if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb))
  return -EROFS;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  /*
  * This prevents concurrent writes from other nodes
@@ -969,7 +969,7 @@ out_inode_unlock:
 out_rw_unlock:
  ocfs2_rw_unlock(inode, 1);
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  return status;
 }
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 62af9554541d..b9b20615ad29 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -1026,7 +1026,7 @@ leave:
  if (orphan_dir) {
  /* This was locked for us in ocfs2_prepare_orphan_dir() */
  ocfs2_inode_unlock(orphan_dir, 1);
- mutex_unlock(&orphan_dir->i_mutex);
+ inode_unlock(orphan_dir);
  iput(orphan_dir);
  }
 
@@ -1645,7 +1645,7 @@ bail:
  if (orphan_dir) {
  /* This was locked for us in ocfs2_prepare_orphan_dir() */
  ocfs2_inode_unlock(orphan_dir, 1);
- mutex_unlock(&orphan_dir->i_mutex);
+ inode_unlock(orphan_dir);
  iput(orphan_dir);
  }
 
@@ -2102,11 +2102,11 @@ static int ocfs2_lookup_lock_orphan_dir(struct ocfs2_super *osb,
  return ret;
  }
 
- mutex_lock(&orphan_dir_inode->i_mutex);
+ inode_lock(orphan_dir_inode);
 
  ret = ocfs2_inode_lock(orphan_dir_inode, &orphan_dir_bh, 1);
  if (ret < 0) {
- mutex_unlock(&orphan_dir_inode->i_mutex);
+ inode_unlock(orphan_dir_inode);
  iput(orphan_dir_inode);
 
  mlog_errno(ret);
@@ -2207,7 +2207,7 @@ out:
 
  if (ret) {
  ocfs2_inode_unlock(orphan_dir_inode, 1);
- mutex_unlock(&orphan_dir_inode->i_mutex);
+ inode_unlock(orphan_dir_inode);
  iput(orphan_dir_inode);
  }
 
@@ -2476,7 +2476,7 @@ out:
  ocfs2_free_alloc_context(inode_ac);
 
  /* Unroll orphan dir locking */
- mutex_unlock(&orphan_dir->i_mutex);
+ inode_unlock(orphan_dir);
  ocfs2_inode_unlock(orphan_dir, 1);
  iput(orphan_dir);
  }
@@ -2583,7 +2583,7 @@ leave:
  if (orphan_dir) {
  /* This was locked for us in ocfs2_prepare_orphan_dir() */
  ocfs2_inode_unlock(orphan_dir, 1);
- mutex_unlock(&orphan_dir->i_mutex);
+ inode_unlock(orphan_dir);
  iput(orphan_dir);
  }
 
@@ -2670,7 +2670,7 @@ int ocfs2_add_inode_to_orphan(struct ocfs2_super *osb,
 
 bail_unlock_orphan:
  ocfs2_inode_unlock(orphan_dir_inode, 1);
- mutex_unlock(&orphan_dir_inode->i_mutex);
+ inode_unlock(orphan_dir_inode);
  iput(orphan_dir_inode);
 
  ocfs2_free_dir_lookup_result(&orphan_insert);
@@ -2702,10 +2702,10 @@ int ocfs2_del_inode_from_orphan(struct ocfs2_super *osb,
  goto bail;
  }
 
- mutex_lock(&orphan_dir_inode->i_mutex);
+ inode_lock(orphan_dir_inode);
  status = ocfs2_inode_lock(orphan_dir_inode, &orphan_dir_bh, 1);
  if (status < 0) {
- mutex_unlock(&orphan_dir_inode->i_mutex);
+ inode_unlock(orphan_dir_inode);
  iput(orphan_dir_inode);
  mlog_errno(status);
  goto bail;
@@ -2751,7 +2751,7 @@ bail_commit:
 
 bail_unlock_orphan:
  ocfs2_inode_unlock(orphan_dir_inode, 1);
- mutex_unlock(&orphan_dir_inode->i_mutex);
+ inode_unlock(orphan_dir_inode);
  brelse(orphan_dir_bh);
  iput(orphan_dir_inode);
 
@@ -2815,12 +2815,12 @@ int ocfs2_mv_orphaned_inode_to_new(struct inode *dir,
  goto leave;
  }
 
- mutex_lock(&orphan_dir_inode->i_mutex);
+ inode_lock(orphan_dir_inode);
 
  status = ocfs2_inode_lock(orphan_dir_inode, &orphan_dir_bh, 1);
  if (status < 0) {
  mlog_errno(status);
- mutex_unlock(&orphan_dir_inode->i_mutex);
+ inode_unlock(orphan_dir_inode);
  iput(orphan_dir_inode);
  goto leave;
  }
@@ -2882,7 +2882,7 @@ out_commit:
  ocfs2_commit_trans(osb, handle);
 orphan_unlock:
  ocfs2_inode_unlock(orphan_dir_inode, 1);
- mutex_unlock(&orphan_dir_inode->i_mutex);
+ inode_unlock(orphan_dir_inode);
  iput(orphan_dir_inode);
 leave:
 
diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c
index c93d67220887..9061b7ce7127 100644
--- a/fs/ocfs2/quota_global.c
+++ b/fs/ocfs2/quota_global.c
@@ -308,7 +308,7 @@ int ocfs2_lock_global_qf(struct ocfs2_mem_dqinfo *oinfo, int ex)
  WARN_ON(bh != oinfo->dqi_gqi_bh);
  spin_unlock(&dq_data_lock);
  if (ex) {
- mutex_lock(&oinfo->dqi_gqinode->i_mutex);
+ inode_lock(oinfo->dqi_gqinode);
  down_write(&OCFS2_I(oinfo->dqi_gqinode)->ip_alloc_sem);
  } else {
  down_read(&OCFS2_I(oinfo->dqi_gqinode)->ip_alloc_sem);
@@ -320,7 +320,7 @@ void ocfs2_unlock_global_qf(struct ocfs2_mem_dqinfo *oinfo, int ex)
 {
  if (ex) {
  up_write(&OCFS2_I(oinfo->dqi_gqinode)->ip_alloc_sem);
- mutex_unlock(&oinfo->dqi_gqinode->i_mutex);
+ inode_unlock(oinfo->dqi_gqinode);
  } else {
  up_read(&OCFS2_I(oinfo->dqi_gqinode)->ip_alloc_sem);
  }
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 6a0c55d7dff0..9919964c5b3b 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -807,7 +807,7 @@ int ocfs2_remove_refcount_tree(struct inode *inode, struct buffer_head *di_bh)
  mlog_errno(ret);
  goto out;
  }
- mutex_lock(&alloc_inode->i_mutex);
+ inode_lock(alloc_inode);
 
  ret = ocfs2_inode_lock(alloc_inode, &alloc_bh, 1);
  if (ret) {
@@ -867,7 +867,7 @@ out_unlock:
  }
 out_mutex:
  if (alloc_inode) {
- mutex_unlock(&alloc_inode->i_mutex);
+ inode_unlock(alloc_inode);
  iput(alloc_inode);
  }
 out:
@@ -4197,7 +4197,7 @@ static int __ocfs2_reflink(struct dentry *old_dentry,
  goto out;
  }
 
- mutex_lock_nested(&new_inode->i_mutex, I_MUTEX_CHILD);
+ inode_lock_nested(new_inode, I_MUTEX_CHILD);
  ret = ocfs2_inode_lock_nested(new_inode, &new_bh, 1,
       OI_LS_REFLINK_TARGET);
  if (ret) {
@@ -4231,7 +4231,7 @@ inode_unlock:
  ocfs2_inode_unlock(new_inode, 1);
  brelse(new_bh);
 out_unlock:
- mutex_unlock(&new_inode->i_mutex);
+ inode_unlock(new_inode);
 out:
  if (!ret) {
  ret = filemap_fdatawait(inode->i_mapping);
@@ -4389,11 +4389,11 @@ static int ocfs2_vfs_reflink(struct dentry *old_dentry, struct inode *dir,
  return error;
  }
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  error = dquot_initialize(dir);
  if (!error)
  error = ocfs2_reflink(old_dentry, dir, new_dentry, preserve);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  if (!error)
  fsnotify_create(dir, new_dentry);
  return error;
diff --git a/fs/ocfs2/resize.c b/fs/ocfs2/resize.c
index 79b8021302b3..576b9a04873f 100644
--- a/fs/ocfs2/resize.c
+++ b/fs/ocfs2/resize.c
@@ -301,7 +301,7 @@ int ocfs2_group_extend(struct inode * inode, int new_clusters)
  goto out;
  }
 
- mutex_lock(&main_bm_inode->i_mutex);
+ inode_lock(main_bm_inode);
 
  ret = ocfs2_inode_lock(main_bm_inode, &main_bm_bh, 1);
  if (ret < 0) {
@@ -375,7 +375,7 @@ out_unlock:
  ocfs2_inode_unlock(main_bm_inode, 1);
 
 out_mutex:
- mutex_unlock(&main_bm_inode->i_mutex);
+ inode_unlock(main_bm_inode);
  iput(main_bm_inode);
 
 out:
@@ -486,7 +486,7 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input)
  goto out;
  }
 
- mutex_lock(&main_bm_inode->i_mutex);
+ inode_lock(main_bm_inode);
 
  ret = ocfs2_inode_lock(main_bm_inode, &main_bm_bh, 1);
  if (ret < 0) {
@@ -590,7 +590,7 @@ out_unlock:
  ocfs2_inode_unlock(main_bm_inode, 1);
 
 out_mutex:
- mutex_unlock(&main_bm_inode->i_mutex);
+ inode_unlock(main_bm_inode);
  iput(main_bm_inode);
 
 out:
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index fc6d25f6d444..2f19aeec5482 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -141,7 +141,7 @@ void ocfs2_free_ac_resource(struct ocfs2_alloc_context *ac)
  if (ac->ac_which != OCFS2_AC_USE_LOCAL)
  ocfs2_inode_unlock(inode, 1);
 
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  iput(inode);
  ac->ac_inode = NULL;
@@ -797,11 +797,11 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
  return -EINVAL;
  }
 
- mutex_lock(&alloc_inode->i_mutex);
+ inode_lock(alloc_inode);
 
  status = ocfs2_inode_lock(alloc_inode, &bh, 1);
  if (status < 0) {
- mutex_unlock(&alloc_inode->i_mutex);
+ inode_unlock(alloc_inode);
  iput(alloc_inode);
 
  mlog_errno(status);
@@ -2875,10 +2875,10 @@ int ocfs2_test_inode_bit(struct ocfs2_super *osb, u64 blkno, int *res)
  goto bail;
  }
 
- mutex_lock(&inode_alloc_inode->i_mutex);
+ inode_lock(inode_alloc_inode);
  status = ocfs2_inode_lock(inode_alloc_inode, &alloc_bh, 0);
  if (status < 0) {
- mutex_unlock(&inode_alloc_inode->i_mutex);
+ inode_unlock(inode_alloc_inode);
  iput(inode_alloc_inode);
  mlog(ML_ERROR, "lock on alloc inode on slot %u failed %d\n",
      (u32)suballoc_slot, status);
@@ -2891,7 +2891,7 @@ int ocfs2_test_inode_bit(struct ocfs2_super *osb, u64 blkno, int *res)
  mlog(ML_ERROR, "test suballoc bit failed %d\n", status);
 
  ocfs2_inode_unlock(inode_alloc_inode, 0);
- mutex_unlock(&inode_alloc_inode->i_mutex);
+ inode_unlock(inode_alloc_inode);
 
  iput(inode_alloc_inode);
  brelse(alloc_bh);
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 877830b05e12..8203c050a006 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -2503,7 +2503,7 @@ static int ocfs2_xattr_free_block(struct inode *inode,
  mlog_errno(ret);
  goto out;
  }
- mutex_lock(&xb_alloc_inode->i_mutex);
+ inode_lock(xb_alloc_inode);
 
  ret = ocfs2_inode_lock(xb_alloc_inode, &xb_alloc_bh, 1);
  if (ret < 0) {
@@ -2528,7 +2528,7 @@ out_unlock:
  ocfs2_inode_unlock(xb_alloc_inode, 1);
  brelse(xb_alloc_bh);
 out_mutex:
- mutex_unlock(&xb_alloc_inode->i_mutex);
+ inode_unlock(xb_alloc_inode);
  iput(xb_alloc_inode);
 out:
  brelse(blk_bh);
@@ -3598,17 +3598,17 @@ int ocfs2_xattr_set(struct inode *inode,
  }
  }
 
- mutex_lock(&tl_inode->i_mutex);
+ inode_lock(tl_inode);
 
  if (ocfs2_truncate_log_needs_flush(osb)) {
  ret = __ocfs2_flush_truncate_log(osb);
  if (ret < 0) {
- mutex_unlock(&tl_inode->i_mutex);
+ inode_unlock(tl_inode);
  mlog_errno(ret);
  goto cleanup;
  }
  }
- mutex_unlock(&tl_inode->i_mutex);
+ inode_unlock(tl_inode);
 
  ret = ocfs2_init_xattr_set_ctxt(inode, di, &xi, &xis,
  &xbs, &ctxt, ref_meta, &credits);
@@ -5441,7 +5441,7 @@ static int ocfs2_rm_xattr_cluster(struct inode *inode,
  return ret;
  }
 
- mutex_lock(&tl_inode->i_mutex);
+ inode_lock(tl_inode);
 
  if (ocfs2_truncate_log_needs_flush(osb)) {
  ret = __ocfs2_flush_truncate_log(osb);
@@ -5485,7 +5485,7 @@ out_commit:
 out:
  ocfs2_schedule_truncate_log_flush(osb, 1);
 
- mutex_unlock(&tl_inode->i_mutex);
+ inode_unlock(tl_inode);
 
  if (meta_ac)
  ocfs2_free_alloc_context(meta_ac);
diff --git a/fs/open.c b/fs/open.c
index 79e8d93b35c7..0b105d5ce184 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -61,10 +61,10 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
  if (ret)
  newattrs.ia_valid |= ret | ATTR_FORCE;
 
- mutex_lock(&dentry->d_inode->i_mutex);
+ inode_lock(dentry->d_inode);
  /* Note any delegations or leases have already been broken: */
  ret = notify_change(dentry, &newattrs, NULL);
- mutex_unlock(&dentry->d_inode->i_mutex);
+ inode_unlock(dentry->d_inode);
  return ret;
 }
 EXPORT_SYMBOL(do_truncate);
@@ -514,7 +514,7 @@ static int chmod_common(struct path *path, umode_t mode)
  if (error)
  return error;
 retry_deleg:
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  error = security_path_chmod(path, mode);
  if (error)
  goto out_unlock;
@@ -522,7 +522,7 @@ retry_deleg:
  newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
  error = notify_change(path->dentry, &newattrs, &delegated_inode);
 out_unlock:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  if (delegated_inode) {
  error = break_deleg_wait(&delegated_inode);
  if (!error)
@@ -597,11 +597,11 @@ retry_deleg:
  if (!S_ISDIR(inode->i_mode))
  newattrs.ia_valid |=
  ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_KILL_PRIV;
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  error = security_path_chown(path, uid, gid);
  if (!error)
  error = notify_change(path->dentry, &newattrs, &delegated_inode);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  if (delegated_inode) {
  error = break_deleg_wait(&delegated_inode);
  if (!error)
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index 2772494ef2b6..5af7413b5397 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -279,9 +279,9 @@ static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir,
  if (err)
  goto out_cleanup;
 
- mutex_lock(&newdentry->d_inode->i_mutex);
+ inode_lock(newdentry->d_inode);
  err = ovl_set_attr(newdentry, stat);
- mutex_unlock(&newdentry->d_inode->i_mutex);
+ inode_unlock(newdentry->d_inode);
  if (err)
  goto out_cleanup;
 
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 6e0c7274b0f2..00d168f0c2ad 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -199,7 +199,7 @@ static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
  struct dentry *newdentry;
  int err;
 
- mutex_lock_nested(&udir->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(udir, I_MUTEX_PARENT);
  newdentry = lookup_one_len(dentry->d_name.name, upperdir,
    dentry->d_name.len);
  err = PTR_ERR(newdentry);
@@ -217,7 +217,7 @@ static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
 out_dput:
  dput(newdentry);
 out_unlock:
- mutex_unlock(&udir->i_mutex);
+ inode_unlock(udir);
  return err;
 }
 
@@ -290,9 +290,9 @@ static struct dentry *ovl_clear_empty(struct dentry *dentry,
  if (err)
  goto out_cleanup;
 
- mutex_lock(&opaquedir->d_inode->i_mutex);
+ inode_lock(opaquedir->d_inode);
  err = ovl_set_attr(opaquedir, &stat);
- mutex_unlock(&opaquedir->d_inode->i_mutex);
+ inode_unlock(opaquedir->d_inode);
  if (err)
  goto out_cleanup;
 
@@ -383,9 +383,9 @@ static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
  err = ovl_create_real(wdir, newdentry, stat, link, hardlink, true);
  if (err)
  goto out_dput2;
- mutex_lock(&newdentry->d_inode->i_mutex);
+ inode_lock(newdentry->d_inode);
  err = notify_change(newdentry, &attr, NULL);
- mutex_unlock(&newdentry->d_inode->i_mutex);
+ inode_unlock(newdentry->d_inode);
  if (err)
  goto out_cleanup;
 
@@ -618,7 +618,7 @@ static int ovl_remove_upper(struct dentry *dentry, bool is_dir)
  struct dentry *upper;
  int err;
 
- mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(dir, I_MUTEX_PARENT);
  upper = lookup_one_len(dentry->d_name.name, upperdir,
        dentry->d_name.len);
  err = PTR_ERR(upper);
@@ -644,7 +644,7 @@ static int ovl_remove_upper(struct dentry *dentry, bool is_dir)
  if (!err)
  d_drop(dentry);
 out_unlock:
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
 
  return err;
 }
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 220b04f04523..be57d343d875 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -66,11 +66,11 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
  if (attr->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID))
  attr->ia_valid &= ~ATTR_MODE;
 
- mutex_lock(&upperdentry->d_inode->i_mutex);
+ inode_lock(upperdentry->d_inode);
  err = notify_change(upperdentry, attr, NULL);
  if (!err)
  ovl_copyattr(upperdentry->d_inode, dentry->d_inode);
- mutex_unlock(&upperdentry->d_inode->i_mutex);
+ inode_unlock(upperdentry->d_inode);
  }
  ovl_drop_write(dentry);
 out:
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 5ab50cd102af..9c83496b58f0 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -98,10 +98,10 @@ static inline int ovl_do_setxattr(struct dentry *dentry, const char *name,
  struct inode *inode = dentry->d_inode;
  int err = -EOPNOTSUPP;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  if (inode->i_op->setxattr)
  err = inode->i_op->setxattr(dentry, name, value, size, flags);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  pr_debug("setxattr(%pd2, \"%s\", \"%*s\", 0x%x) = %i\n",
  dentry, name, (int) size, (char *) value, flags, err);
@@ -113,10 +113,10 @@ static inline int ovl_do_removexattr(struct dentry *dentry, const char *name)
  struct inode *inode = dentry->d_inode;
  int err = -EOPNOTSUPP;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  if (inode->i_op->removexattr)
  err = inode->i_op->removexattr(dentry, name);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  pr_debug("removexattr(%pd2, \"%s\") = %i\n", dentry, name, err);
  return err;
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index 8261421e31ef..42ee315b6d29 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -222,7 +222,7 @@ static int ovl_check_whiteouts(struct dentry *dir, struct ovl_readdir_data *rdd)
  dput(dentry);
  }
  }
- mutex_unlock(&dir->d_inode->i_mutex);
+ inode_unlock(dir->d_inode);
  }
  revert_creds(old_cred);
 
@@ -403,7 +403,7 @@ static loff_t ovl_dir_llseek(struct file *file, loff_t offset, int origin)
  loff_t res;
  struct ovl_dir_file *od = file->private_data;
 
- mutex_lock(&file_inode(file)->i_mutex);
+ inode_lock(file_inode(file));
  if (!file->f_pos)
  ovl_dir_reset(file);
 
@@ -433,7 +433,7 @@ static loff_t ovl_dir_llseek(struct file *file, loff_t offset, int origin)
  res = offset;
  }
 out_unlock:
- mutex_unlock(&file_inode(file)->i_mutex);
+ inode_unlock(file_inode(file));
 
  return res;
 }
@@ -458,10 +458,10 @@ static int ovl_dir_fsync(struct file *file, loff_t start, loff_t end,
  ovl_path_upper(dentry, &upperpath);
  realfile = ovl_path_open(&upperpath, O_RDONLY);
  smp_mb__before_spinlock();
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  if (!od->upperfile) {
  if (IS_ERR(realfile)) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return PTR_ERR(realfile);
  }
  od->upperfile = realfile;
@@ -471,7 +471,7 @@ static int ovl_dir_fsync(struct file *file, loff_t start, loff_t end,
  fput(realfile);
  realfile = od->upperfile;
  }
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
  }
 
@@ -483,9 +483,9 @@ static int ovl_dir_release(struct inode *inode, struct file *file)
  struct ovl_dir_file *od = file->private_data;
 
  if (od->cache) {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  ovl_cache_put(od, file->f_path.dentry);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
  fput(od->realfile);
  if (od->upperfile)
@@ -561,7 +561,7 @@ void ovl_cleanup_whiteouts(struct dentry *upper, struct list_head *list)
 {
  struct ovl_cache_entry *p;
 
- mutex_lock_nested(&upper->d_inode->i_mutex, I_MUTEX_CHILD);
+ inode_lock_nested(upper->d_inode, I_MUTEX_CHILD);
  list_for_each_entry(p, list, l_node) {
  struct dentry *dentry;
 
@@ -579,5 +579,5 @@ void ovl_cleanup_whiteouts(struct dentry *upper, struct list_head *list)
  ovl_cleanup(upper->d_inode, dentry);
  dput(dentry);
  }
- mutex_unlock(&upper->d_inode->i_mutex);
+ inode_unlock(upper->d_inode);
 }
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 6c3077473fa8..8716b764700f 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -221,7 +221,7 @@ void ovl_dentry_update(struct dentry *dentry, struct dentry *upperdentry)
 {
  struct ovl_entry *oe = dentry->d_fsdata;
 
- WARN_ON(!mutex_is_locked(&upperdentry->d_parent->d_inode->i_mutex));
+ WARN_ON(!inode_is_locked(upperdentry->d_parent->d_inode));
  WARN_ON(oe->__upperdentry);
  BUG_ON(!upperdentry->d_inode);
  /*
@@ -236,7 +236,7 @@ void ovl_dentry_version_inc(struct dentry *dentry)
 {
  struct ovl_entry *oe = dentry->d_fsdata;
 
- WARN_ON(!mutex_is_locked(&dentry->d_inode->i_mutex));
+ WARN_ON(!inode_is_locked(dentry->d_inode));
  oe->version++;
 }
 
@@ -244,7 +244,7 @@ u64 ovl_dentry_version_get(struct dentry *dentry)
 {
  struct ovl_entry *oe = dentry->d_fsdata;
 
- WARN_ON(!mutex_is_locked(&dentry->d_inode->i_mutex));
+ WARN_ON(!inode_is_locked(dentry->d_inode));
  return oe->version;
 }
 
@@ -464,9 +464,9 @@ static inline struct dentry *ovl_lookup_real(struct super_block *ovl_sb,
  struct dentry *dentry;
 
  old_cred = ovl_override_creds(ovl_sb);
- mutex_lock(&dir->d_inode->i_mutex);
+ inode_lock(dir->d_inode);
  dentry = lookup_one_len(name->name, dir, name->len);
- mutex_unlock(&dir->d_inode->i_mutex);
+ inode_unlock(dir->d_inode);
  revert_creds(old_cred);
 
  if (IS_ERR(dentry)) {
@@ -829,7 +829,7 @@ static struct dentry *ovl_workdir_create(struct vfsmount *mnt,
  if (err)
  return ERR_PTR(err);
 
- mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(dir, I_MUTEX_PARENT);
 retry:
  work = lookup_one_len(OVL_WORKDIR_NAME, dentry,
       strlen(OVL_WORKDIR_NAME));
@@ -874,7 +874,7 @@ retry:
  goto out_dput;
  }
 out_unlock:
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
  mnt_drop_write(mnt);
 
  return work;
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index 92e6726f6e37..a939f5ed7f89 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -552,9 +552,9 @@ static int open_kcore(struct inode *inode, struct file *filp)
  if (kcore_need_update)
  kcore_update_ram();
  if (i_size_read(inode) != proc_root_kcore->size) {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  i_size_write(inode, proc_root_kcore->size);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
  return 0;
 }
diff --git a/fs/proc/self.c b/fs/proc/self.c
index 113b8d061fc0..ce2264365b67 100644
--- a/fs/proc/self.c
+++ b/fs/proc/self.c
@@ -48,7 +48,7 @@ int proc_setup_self(struct super_block *s)
  struct pid_namespace *ns = s->s_fs_info;
  struct dentry *self;
 
- mutex_lock(&root_inode->i_mutex);
+ inode_lock(root_inode);
  self = d_alloc_name(s->s_root, "self");
  if (self) {
  struct inode *inode = new_inode_pseudo(s);
@@ -67,7 +67,7 @@ int proc_setup_self(struct super_block *s)
  } else {
  self = ERR_PTR(-ENOMEM);
  }
- mutex_unlock(&root_inode->i_mutex);
+ inode_unlock(root_inode);
  if (IS_ERR(self)) {
  pr_err("proc_fill_super: can't allocate /proc/self\n");
  return PTR_ERR(self);
diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c
index 947b0f4fd0a1..eea20179c8d0 100644
--- a/fs/proc/thread_self.c
+++ b/fs/proc/thread_self.c
@@ -49,7 +49,7 @@ int proc_setup_thread_self(struct super_block *s)
  struct pid_namespace *ns = s->s_fs_info;
  struct dentry *thread_self;
 
- mutex_lock(&root_inode->i_mutex);
+ inode_lock(root_inode);
  thread_self = d_alloc_name(s->s_root, "thread-self");
  if (thread_self) {
  struct inode *inode = new_inode_pseudo(s);
@@ -68,7 +68,7 @@ int proc_setup_thread_self(struct super_block *s)
  } else {
  thread_self = ERR_PTR(-ENOMEM);
  }
- mutex_unlock(&root_inode->i_mutex);
+ inode_unlock(root_inode);
  if (IS_ERR(thread_self)) {
  pr_err("proc_fill_super: can't allocate /proc/thread_self\n");
  return PTR_ERR(thread_self);
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index ac6c78fe19cf..e0e151d22071 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -376,7 +376,7 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count,
  break;
  }
 
- mutex_lock(&d_inode(root)->i_mutex);
+ inode_lock(d_inode(root));
 
  dentry = d_alloc_name(root, name);
  if (!dentry)
@@ -396,12 +396,12 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, u64 id, int count,
  list_add(&private->list, &allpstore);
  spin_unlock_irqrestore(&allpstore_lock, flags);
 
- mutex_unlock(&d_inode(root)->i_mutex);
+ inode_unlock(d_inode(root));
 
  return 0;
 
 fail_lockedalloc:
- mutex_unlock(&d_inode(root)->i_mutex);
+ inode_unlock(d_inode(root));
  kfree(private);
 fail_alloc:
  iput(inode);
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 1f90c5eef419..101e24123549 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -682,9 +682,9 @@ int dquot_quota_sync(struct super_block *sb, int type)
  continue;
  if (!sb_has_quota_active(sb, cnt))
  continue;
- mutex_lock(&dqopt->files[cnt]->i_mutex);
+ inode_lock(dqopt->files[cnt]);
  truncate_inode_pages(&dqopt->files[cnt]->i_data, 0);
- mutex_unlock(&dqopt->files[cnt]->i_mutex);
+ inode_unlock(dqopt->files[cnt]);
  }
  mutex_unlock(&dqopt->dqonoff_mutex);
 
@@ -2164,12 +2164,12 @@ int dquot_disable(struct super_block *sb, int type, unsigned int flags)
  /* If quota was reenabled in the meantime, we have
  * nothing to do */
  if (!sb_has_quota_loaded(sb, cnt)) {
- mutex_lock(&toputinode[cnt]->i_mutex);
+ inode_lock(toputinode[cnt]);
  toputinode[cnt]->i_flags &= ~(S_IMMUTABLE |
   S_NOATIME | S_NOQUOTA);
  truncate_inode_pages(&toputinode[cnt]->i_data,
      0);
- mutex_unlock(&toputinode[cnt]->i_mutex);
+ inode_unlock(toputinode[cnt]);
  mark_inode_dirty_sync(toputinode[cnt]);
  }
  mutex_unlock(&dqopt->dqonoff_mutex);
@@ -2265,11 +2265,11 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
  /* We don't want quota and atime on quota files (deadlocks
  * possible) Also nobody should write to the file - we use
  * special IO operations which ignore the immutable bit. */
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  oldflags = inode->i_flags & (S_NOATIME | S_IMMUTABLE |
      S_NOQUOTA);
  inode->i_flags |= S_NOQUOTA | S_NOATIME | S_IMMUTABLE;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  /*
  * When S_NOQUOTA is set, remove dquot references as no more
  * references can be added
@@ -2312,12 +2312,12 @@ out_file_init:
  iput(inode);
 out_lock:
  if (oldflags != -1) {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  /* Set the flags back (in the case of accidental quotaon()
  * on a wrong file we don't want to mess up the flags) */
  inode->i_flags &= ~(S_NOATIME | S_NOQUOTA | S_IMMUTABLE);
  inode->i_flags |= oldflags;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
  mutex_unlock(&dqopt->dqonoff_mutex);
 out_fmt:
@@ -2437,9 +2437,9 @@ int dquot_quota_on_mount(struct super_block *sb, char *qf_name,
  struct dentry *dentry;
  int error;
 
- mutex_lock(&d_inode(sb->s_root)->i_mutex);
+ inode_lock(d_inode(sb->s_root));
  dentry = lookup_one_len(qf_name, sb->s_root, strlen(qf_name));
- mutex_unlock(&d_inode(sb->s_root)->i_mutex);
+ inode_unlock(d_inode(sb->s_root));
  if (IS_ERR(dentry))
  return PTR_ERR(dentry);
 
diff --git a/fs/read_write.c b/fs/read_write.c
index 83139b62c0ac..afbafa11feb9 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -198,7 +198,7 @@ loff_t default_llseek(struct file *file, loff_t offset, int whence)
  struct inode *inode = file_inode(file);
  loff_t retval;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  switch (whence) {
  case SEEK_END:
  offset += i_size_read(inode);
@@ -243,7 +243,7 @@ loff_t default_llseek(struct file *file, loff_t offset, int whence)
  retval = offset;
  }
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return retval;
 }
 EXPORT_SYMBOL(default_llseek);
diff --git a/fs/readdir.c b/fs/readdir.c
index ced679179cac..e69ef3b79787 100644
--- a/fs/readdir.c
+++ b/fs/readdir.c
@@ -44,7 +44,7 @@ int iterate_dir(struct file *file, struct dir_context *ctx)
  fsnotify_access(file);
  file_accessed(file);
  }
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 out:
  return res;
 }
diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c
index 4a024e2ceb9f..3abd4004184b 100644
--- a/fs/reiserfs/dir.c
+++ b/fs/reiserfs/dir.c
@@ -38,11 +38,11 @@ static int reiserfs_dir_fsync(struct file *filp, loff_t start, loff_t end,
  if (err)
  return err;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  reiserfs_write_lock(inode->i_sb);
  err = reiserfs_commit_for_inode(inode);
  reiserfs_write_unlock(inode->i_sb);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  if (err < 0)
  return err;
  return 0;
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index 38187300a2b4..181c260d0a8e 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -158,7 +158,7 @@ static int reiserfs_sync_file(struct file *filp, loff_t start, loff_t end,
  if (err)
  return err;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  BUG_ON(!S_ISREG(inode->i_mode));
  err = sync_mapping_buffers(inode->i_mapping);
  reiserfs_write_lock(inode->i_sb);
@@ -166,7 +166,7 @@ static int reiserfs_sync_file(struct file *filp, loff_t start, loff_t end,
  reiserfs_write_unlock(inode->i_sb);
  if (barrier_done != 1 && reiserfs_barrier_flush(inode->i_sb))
  blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  if (barrier_done < 0)
  return barrier_done;
  return (err < 0) ? -EIO : 0;
diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c
index 6ec8a30a0911..036a1fc0a8c3 100644
--- a/fs/reiserfs/ioctl.c
+++ b/fs/reiserfs/ioctl.c
@@ -224,7 +224,7 @@ out_unlock:
  page_cache_release(page);
 
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  reiserfs_write_unlock(inode->i_sb);
  return retval;
 }
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index a8dbc93e45eb..5a1a71fe9bc7 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -64,14 +64,14 @@
 #ifdef CONFIG_REISERFS_FS_XATTR
 static int xattr_create(struct inode *dir, struct dentry *dentry, int mode)
 {
- BUG_ON(!mutex_is_locked(&dir->i_mutex));
+ BUG_ON(!inode_is_locked(dir));
  return dir->i_op->create(dir, dentry, mode, true);
 }
 #endif
 
 static int xattr_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 {
- BUG_ON(!mutex_is_locked(&dir->i_mutex));
+ BUG_ON(!inode_is_locked(dir));
  return dir->i_op->mkdir(dir, dentry, mode);
 }
 
@@ -85,11 +85,11 @@ static int xattr_unlink(struct inode *dir, struct dentry *dentry)
 {
  int error;
 
- BUG_ON(!mutex_is_locked(&dir->i_mutex));
+ BUG_ON(!inode_is_locked(dir));
 
- mutex_lock_nested(&d_inode(dentry)->i_mutex, I_MUTEX_CHILD);
+ inode_lock_nested(d_inode(dentry), I_MUTEX_CHILD);
  error = dir->i_op->unlink(dir, dentry);
- mutex_unlock(&d_inode(dentry)->i_mutex);
+ inode_unlock(d_inode(dentry));
 
  if (!error)
  d_delete(dentry);
@@ -100,13 +100,13 @@ static int xattr_rmdir(struct inode *dir, struct dentry *dentry)
 {
  int error;
 
- BUG_ON(!mutex_is_locked(&dir->i_mutex));
+ BUG_ON(!inode_is_locked(dir));
 
- mutex_lock_nested(&d_inode(dentry)->i_mutex, I_MUTEX_CHILD);
+ inode_lock_nested(d_inode(dentry), I_MUTEX_CHILD);
  error = dir->i_op->rmdir(dir, dentry);
  if (!error)
  d_inode(dentry)->i_flags |= S_DEAD;
- mutex_unlock(&d_inode(dentry)->i_mutex);
+ inode_unlock(d_inode(dentry));
  if (!error)
  d_delete(dentry);
 
@@ -123,7 +123,7 @@ static struct dentry *open_xa_root(struct super_block *sb, int flags)
  if (d_really_is_negative(privroot))
  return ERR_PTR(-ENODATA);
 
- mutex_lock_nested(&d_inode(privroot)->i_mutex, I_MUTEX_XATTR);
+ inode_lock_nested(d_inode(privroot), I_MUTEX_XATTR);
 
  xaroot = dget(REISERFS_SB(sb)->xattr_root);
  if (!xaroot)
@@ -139,7 +139,7 @@ static struct dentry *open_xa_root(struct super_block *sb, int flags)
  }
  }
 
- mutex_unlock(&d_inode(privroot)->i_mutex);
+ inode_unlock(d_inode(privroot));
  return xaroot;
 }
 
@@ -156,7 +156,7 @@ static struct dentry *open_xa_dir(const struct inode *inode, int flags)
  le32_to_cpu(INODE_PKEY(inode)->k_objectid),
  inode->i_generation);
 
- mutex_lock_nested(&d_inode(xaroot)->i_mutex, I_MUTEX_XATTR);
+ inode_lock_nested(d_inode(xaroot), I_MUTEX_XATTR);
 
  xadir = lookup_one_len(namebuf, xaroot, strlen(namebuf));
  if (!IS_ERR(xadir) && d_really_is_negative(xadir)) {
@@ -170,7 +170,7 @@ static struct dentry *open_xa_dir(const struct inode *inode, int flags)
  }
  }
 
- mutex_unlock(&d_inode(xaroot)->i_mutex);
+ inode_unlock(d_inode(xaroot));
  dput(xaroot);
  return xadir;
 }
@@ -195,7 +195,7 @@ fill_with_dentries(struct dir_context *ctx, const char *name, int namelen,
  container_of(ctx, struct reiserfs_dentry_buf, ctx);
  struct dentry *dentry;
 
- WARN_ON_ONCE(!mutex_is_locked(&d_inode(dbuf->xadir)->i_mutex));
+ WARN_ON_ONCE(!inode_is_locked(d_inode(dbuf->xadir)));
 
  if (dbuf->count == ARRAY_SIZE(dbuf->dentries))
  return -ENOSPC;
@@ -254,7 +254,7 @@ static int reiserfs_for_each_xattr(struct inode *inode,
  goto out_dir;
  }
 
- mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_XATTR);
+ inode_lock_nested(d_inode(dir), I_MUTEX_XATTR);
 
  buf.xadir = dir;
  while (1) {
@@ -276,7 +276,7 @@ static int reiserfs_for_each_xattr(struct inode *inode,
  break;
  buf.count = 0;
  }
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
 
  cleanup_dentry_buf(&buf);
 
@@ -298,13 +298,13 @@ static int reiserfs_for_each_xattr(struct inode *inode,
  if (!err) {
  int jerror;
 
- mutex_lock_nested(&d_inode(dir->d_parent)->i_mutex,
+ inode_lock_nested(d_inode(dir->d_parent),
   I_MUTEX_XATTR);
  err = action(dir, data);
  reiserfs_write_lock(inode->i_sb);
  jerror = journal_end(&th);
  reiserfs_write_unlock(inode->i_sb);
- mutex_unlock(&d_inode(dir->d_parent)->i_mutex);
+ inode_unlock(d_inode(dir->d_parent));
  err = jerror ?: err;
  }
  }
@@ -384,7 +384,7 @@ static struct dentry *xattr_lookup(struct inode *inode, const char *name,
  if (IS_ERR(xadir))
  return ERR_CAST(xadir);
 
- mutex_lock_nested(&d_inode(xadir)->i_mutex, I_MUTEX_XATTR);
+ inode_lock_nested(d_inode(xadir), I_MUTEX_XATTR);
  xafile = lookup_one_len(name, xadir, strlen(name));
  if (IS_ERR(xafile)) {
  err = PTR_ERR(xafile);
@@ -404,7 +404,7 @@ static struct dentry *xattr_lookup(struct inode *inode, const char *name,
  if (err)
  dput(xafile);
 out:
- mutex_unlock(&d_inode(xadir)->i_mutex);
+ inode_unlock(d_inode(xadir));
  dput(xadir);
  if (err)
  return ERR_PTR(err);
@@ -469,7 +469,7 @@ static int lookup_and_delete_xattr(struct inode *inode, const char *name)
  if (IS_ERR(xadir))
  return PTR_ERR(xadir);
 
- mutex_lock_nested(&d_inode(xadir)->i_mutex, I_MUTEX_XATTR);
+ inode_lock_nested(d_inode(xadir), I_MUTEX_XATTR);
  dentry = lookup_one_len(name, xadir, strlen(name));
  if (IS_ERR(dentry)) {
  err = PTR_ERR(dentry);
@@ -483,7 +483,7 @@ static int lookup_and_delete_xattr(struct inode *inode, const char *name)
 
  dput(dentry);
 out_dput:
- mutex_unlock(&d_inode(xadir)->i_mutex);
+ inode_unlock(d_inode(xadir));
  dput(xadir);
  return err;
 }
@@ -580,11 +580,11 @@ reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *th,
  .ia_valid = ATTR_SIZE | ATTR_CTIME,
  };
 
- mutex_lock_nested(&d_inode(dentry)->i_mutex, I_MUTEX_XATTR);
+ inode_lock_nested(d_inode(dentry), I_MUTEX_XATTR);
  inode_dio_wait(d_inode(dentry));
 
  err = reiserfs_setattr(dentry, &newattrs);
- mutex_unlock(&d_inode(dentry)->i_mutex);
+ inode_unlock(d_inode(dentry));
  } else
  update_ctime(inode);
 out_unlock:
@@ -836,9 +836,9 @@ ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
  goto out;
  }
 
- mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_XATTR);
+ inode_lock_nested(d_inode(dir), I_MUTEX_XATTR);
  err = reiserfs_readdir_inode(d_inode(dir), &buf.ctx);
- mutex_unlock(&d_inode(dir)->i_mutex);
+ inode_unlock(d_inode(dir));
 
  if (!err)
  err = buf.pos;
@@ -853,7 +853,7 @@ static int create_privroot(struct dentry *dentry)
  int err;
  struct inode *inode = d_inode(dentry->d_parent);
 
- WARN_ON_ONCE(!mutex_is_locked(&inode->i_mutex));
+ WARN_ON_ONCE(!inode_is_locked(inode));
 
  err = xattr_mkdir(inode, dentry, 0700);
  if (err || d_really_is_negative(dentry)) {
@@ -943,7 +943,7 @@ int reiserfs_lookup_privroot(struct super_block *s)
  int err = 0;
 
  /* If we don't have the privroot located yet - go find it */
- mutex_lock(&d_inode(s->s_root)->i_mutex);
+ inode_lock(d_inode(s->s_root));
  dentry = lookup_one_len(PRIVROOT_NAME, s->s_root,
  strlen(PRIVROOT_NAME));
  if (!IS_ERR(dentry)) {
@@ -953,7 +953,7 @@ int reiserfs_lookup_privroot(struct super_block *s)
  d_inode(dentry)->i_flags |= S_PRIVATE;
  } else
  err = PTR_ERR(dentry);
- mutex_unlock(&d_inode(s->s_root)->i_mutex);
+ inode_unlock(d_inode(s->s_root));
 
  return err;
 }
@@ -973,14 +973,14 @@ int reiserfs_xattr_init(struct super_block *s, int mount_flags)
  goto error;
 
  if (d_really_is_negative(privroot) && !(mount_flags & MS_RDONLY)) {
- mutex_lock(&d_inode(s->s_root)->i_mutex);
+ inode_lock(d_inode(s->s_root));
  err = create_privroot(REISERFS_SB(s)->priv_root);
- mutex_unlock(&d_inode(s->s_root)->i_mutex);
+ inode_unlock(d_inode(s->s_root));
  }
 
  if (d_really_is_positive(privroot)) {
  s->s_xattr = reiserfs_xattr_handlers;
- mutex_lock(&d_inode(privroot)->i_mutex);
+ inode_lock(d_inode(privroot));
  if (!REISERFS_SB(s)->xattr_root) {
  struct dentry *dentry;
 
@@ -991,7 +991,7 @@ int reiserfs_xattr_init(struct super_block *s, int mount_flags)
  else
  err = PTR_ERR(dentry);
  }
- mutex_unlock(&d_inode(privroot)->i_mutex);
+ inode_unlock(d_inode(privroot));
  }
 
 error:
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index c66f2423e1f5..4a0e48f92104 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -84,9 +84,9 @@ static int tracefs_syscall_mkdir(struct inode *inode, struct dentry *dentry, umo
  * the files within the tracefs system. It is up to the individual
  * mkdir routine to handle races.
  */
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  ret = tracefs_ops.mkdir(name);
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  kfree(name);
 
@@ -109,13 +109,13 @@ static int tracefs_syscall_rmdir(struct inode *inode, struct dentry *dentry)
  * This time we need to unlock not only the parent (inode) but
  * also the directory that is being deleted.
  */
- mutex_unlock(&inode->i_mutex);
- mutex_unlock(&dentry->d_inode->i_mutex);
+ inode_unlock(inode);
+ inode_unlock(dentry->d_inode);
 
  ret = tracefs_ops.rmdir(name);
 
- mutex_lock_nested(&inode->i_mutex, I_MUTEX_PARENT);
- mutex_lock(&dentry->d_inode->i_mutex);
+ inode_lock_nested(inode, I_MUTEX_PARENT);
+ inode_lock(dentry->d_inode);
 
  kfree(name);
 
@@ -334,7 +334,7 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
  if (!parent)
  parent = tracefs_mount->mnt_root;
 
- mutex_lock(&parent->d_inode->i_mutex);
+ inode_lock(parent->d_inode);
  dentry = lookup_one_len(name, parent, strlen(name));
  if (!IS_ERR(dentry) && dentry->d_inode) {
  dput(dentry);
@@ -342,7 +342,7 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
  }
 
  if (IS_ERR(dentry)) {
- mutex_unlock(&parent->d_inode->i_mutex);
+ inode_unlock(parent->d_inode);
  simple_release_fs(&tracefs_mount, &tracefs_mount_count);
  }
 
@@ -351,7 +351,7 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
 
 static struct dentry *failed_creating(struct dentry *dentry)
 {
- mutex_unlock(&dentry->d_parent->d_inode->i_mutex);
+ inode_unlock(dentry->d_parent->d_inode);
  dput(dentry);
  simple_release_fs(&tracefs_mount, &tracefs_mount_count);
  return NULL;
@@ -359,7 +359,7 @@ static struct dentry *failed_creating(struct dentry *dentry)
 
 static struct dentry *end_creating(struct dentry *dentry)
 {
- mutex_unlock(&dentry->d_parent->d_inode->i_mutex);
+ inode_unlock(dentry->d_parent->d_inode);
  return dentry;
 }
 
@@ -544,9 +544,9 @@ void tracefs_remove(struct dentry *dentry)
  if (!parent || !parent->d_inode)
  return;
 
- mutex_lock(&parent->d_inode->i_mutex);
+ inode_lock(parent->d_inode);
  ret = __tracefs_remove(dentry, parent);
- mutex_unlock(&parent->d_inode->i_mutex);
+ inode_unlock(parent->d_inode);
  if (!ret)
  simple_release_fs(&tracefs_mount, &tracefs_mount_count);
 }
@@ -572,7 +572,7 @@ void tracefs_remove_recursive(struct dentry *dentry)
 
  parent = dentry;
  down:
- mutex_lock(&parent->d_inode->i_mutex);
+ inode_lock(parent->d_inode);
  loop:
  /*
  * The parent->d_subdirs is protected by the d_lock. Outside that
@@ -587,7 +587,7 @@ void tracefs_remove_recursive(struct dentry *dentry)
  /* perhaps simple_empty(child) makes more sense */
  if (!list_empty(&child->d_subdirs)) {
  spin_unlock(&parent->d_lock);
- mutex_unlock(&parent->d_inode->i_mutex);
+ inode_unlock(parent->d_inode);
  parent = child;
  goto down;
  }
@@ -608,10 +608,10 @@ void tracefs_remove_recursive(struct dentry *dentry)
  }
  spin_unlock(&parent->d_lock);
 
- mutex_unlock(&parent->d_inode->i_mutex);
+ inode_unlock(parent->d_inode);
  child = parent;
  parent = parent->d_parent;
- mutex_lock(&parent->d_inode->i_mutex);
+ inode_lock(parent->d_inode);
 
  if (child != dentry)
  /* go up */
@@ -619,7 +619,7 @@ void tracefs_remove_recursive(struct dentry *dentry)
 
  if (!__tracefs_remove(child, parent))
  simple_release_fs(&tracefs_mount, &tracefs_mount_count);
- mutex_unlock(&parent->d_inode->i_mutex);
+ inode_unlock(parent->d_inode);
 }
 
 /**
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index f5d5ee43ae6e..b25bfa4d4d1e 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -521,8 +521,8 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
  dbg_gen("dent '%pd' to ino %lu (nlink %d) in dir ino %lu",
  dentry, inode->i_ino,
  inode->i_nlink, dir->i_ino);
- ubifs_assert(mutex_is_locked(&dir->i_mutex));
- ubifs_assert(mutex_is_locked(&inode->i_mutex));
+ ubifs_assert(inode_is_locked(dir));
+ ubifs_assert(inode_is_locked(inode));
 
  err = dbg_check_synced_i_size(c, inode);
  if (err)
@@ -578,8 +578,8 @@ static int ubifs_unlink(struct inode *dir, struct dentry *dentry)
  dbg_gen("dent '%pd' from ino %lu (nlink %d) in dir ino %lu",
  dentry, inode->i_ino,
  inode->i_nlink, dir->i_ino);
- ubifs_assert(mutex_is_locked(&dir->i_mutex));
- ubifs_assert(mutex_is_locked(&inode->i_mutex));
+ ubifs_assert(inode_is_locked(dir));
+ ubifs_assert(inode_is_locked(inode));
  err = dbg_check_synced_i_size(c, inode);
  if (err)
  return err;
@@ -667,8 +667,8 @@ static int ubifs_rmdir(struct inode *dir, struct dentry *dentry)
 
  dbg_gen("directory '%pd', ino %lu in dir ino %lu", dentry,
  inode->i_ino, dir->i_ino);
- ubifs_assert(mutex_is_locked(&dir->i_mutex));
- ubifs_assert(mutex_is_locked(&inode->i_mutex));
+ ubifs_assert(inode_is_locked(dir));
+ ubifs_assert(inode_is_locked(inode));
  err = check_dir_empty(c, d_inode(dentry));
  if (err)
  return err;
@@ -1002,10 +1002,10 @@ static int ubifs_rename(struct inode *old_dir, struct dentry *old_dentry,
  dbg_gen("dent '%pd' ino %lu in dir ino %lu to dent '%pd' in dir ino %lu",
  old_dentry, old_inode->i_ino, old_dir->i_ino,
  new_dentry, new_dir->i_ino);
- ubifs_assert(mutex_is_locked(&old_dir->i_mutex));
- ubifs_assert(mutex_is_locked(&new_dir->i_mutex));
+ ubifs_assert(inode_is_locked(old_dir));
+ ubifs_assert(inode_is_locked(new_dir));
  if (unlink)
- ubifs_assert(mutex_is_locked(&new_inode->i_mutex));
+ ubifs_assert(inode_is_locked(new_inode));
 
 
  if (unlink && is_dir) {
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index b895af7d8d80..739d201dba09 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1318,7 +1318,7 @@ int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
  err = filemap_write_and_wait_range(inode->i_mapping, start, end);
  if (err)
  return err;
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  /* Synchronize the inode unless this is a 'datasync()' call. */
  if (!datasync || (inode->i_state & I_DIRTY_DATASYNC)) {
@@ -1333,7 +1333,7 @@ int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
  */
  err = ubifs_sync_wbufs_by_inode(c, inode);
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return err;
 }
 
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index b5bf23b34241..cabe709e5bd6 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -314,7 +314,7 @@ static int setxattr(struct inode *host, const char *name, const void *value,
  union ubifs_key key;
  int err, type;
 
- ubifs_assert(mutex_is_locked(&host->i_mutex));
+ ubifs_assert(inode_is_locked(host));
 
  if (size > UBIFS_MAX_INO_DATA)
  return -ERANGE;
@@ -552,7 +552,7 @@ int ubifs_removexattr(struct dentry *dentry, const char *name)
 
  dbg_gen("xattr '%s', ino %lu ('%pd')", name,
  host->i_ino, dentry);
- ubifs_assert(mutex_is_locked(&host->i_mutex));
+ ubifs_assert(inode_is_locked(host));
 
  err = check_namespace(&nm);
  if (err < 0)
diff --git a/fs/udf/file.c b/fs/udf/file.c
index bddf3d071dae..1af98963d860 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -122,7 +122,7 @@ static ssize_t udf_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
  struct udf_inode_info *iinfo = UDF_I(inode);
  int err;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  retval = generic_write_checks(iocb, from);
  if (retval <= 0)
@@ -136,7 +136,7 @@ static ssize_t udf_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
  (udf_file_entry_alloc_offset(inode) + end)) {
  err = udf_expand_file_adinicb(inode);
  if (err) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  udf_debug("udf_expand_adinicb: err=%d\n", err);
  return err;
  }
@@ -149,7 +149,7 @@ static ssize_t udf_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 
  retval = __generic_file_write_iter(iocb, from);
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  if (retval > 0) {
  mark_inode_dirty(inode);
@@ -223,12 +223,12 @@ static int udf_release_file(struct inode *inode, struct file *filp)
  * Grab i_mutex to avoid races with writes changing i_size
  * while we are running.
  */
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  down_write(&UDF_I(inode)->i_data_sem);
  udf_discard_prealloc(inode);
  udf_truncate_tail_extent(inode);
  up_write(&UDF_I(inode)->i_data_sem);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
  return 0;
 }
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 0e659d9c69a1..4a259cfbec92 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -262,7 +262,7 @@ int udf_expand_file_adinicb(struct inode *inode)
  .nr_to_write = 1,
  };
 
- WARN_ON_ONCE(!mutex_is_locked(&inode->i_mutex));
+ WARN_ON_ONCE(!inode_is_locked(inode));
  if (!iinfo->i_lenAlloc) {
  if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))
  iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT;
diff --git a/fs/utimes.c b/fs/utimes.c
index cb771c30d102..ba54b9e648c9 100644
--- a/fs/utimes.c
+++ b/fs/utimes.c
@@ -90,9 +90,9 @@ static int utimes_common(struct path *path, struct timespec *times)
  newattrs.ia_valid |= ATTR_TOUCH;
  }
 retry_deleg:
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  error = notify_change(path->dentry, &newattrs, &delegated_inode);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  if (delegated_inode) {
  error = break_deleg_wait(&delegated_inode);
  if (!error)
diff --git a/fs/xattr.c b/fs/xattr.c
index 9d536be324ce..d2d6c4073546 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -136,7 +136,7 @@ vfs_setxattr(struct dentry *dentry, const char *name, const void *value,
  if (error)
  return error;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  error = security_inode_setxattr(dentry, name, value, size, flags);
  if (error)
  goto out;
@@ -144,7 +144,7 @@ vfs_setxattr(struct dentry *dentry, const char *name, const void *value,
  error = __vfs_setxattr_noperm(dentry, name, value, size, flags);
 
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return error;
 }
 EXPORT_SYMBOL_GPL(vfs_setxattr);
@@ -304,7 +304,7 @@ vfs_removexattr(struct dentry *dentry, const char *name)
  if (error)
  return error;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  error = security_inode_removexattr(dentry, name);
  if (error)
  goto out;
@@ -317,7 +317,7 @@ vfs_removexattr(struct dentry *dentry, const char *name)
  }
 
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return error;
 }
 EXPORT_SYMBOL_GPL(vfs_removexattr);
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index b40f34e8c9bf..dcfe39860b98 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -55,7 +55,7 @@ xfs_rw_ilock(
  int type)
 {
  if (type & XFS_IOLOCK_EXCL)
- mutex_lock(&VFS_I(ip)->i_mutex);
+ inode_lock(VFS_I(ip));
  xfs_ilock(ip, type);
 }
 
@@ -66,7 +66,7 @@ xfs_rw_iunlock(
 {
  xfs_iunlock(ip, type);
  if (type & XFS_IOLOCK_EXCL)
- mutex_unlock(&VFS_I(ip)->i_mutex);
+ inode_unlock(VFS_I(ip));
 }
 
 static inline void
@@ -76,7 +76,7 @@ xfs_rw_ilock_demote(
 {
  xfs_ilock_demote(ip, type);
  if (type & XFS_IOLOCK_EXCL)
- mutex_unlock(&VFS_I(ip)->i_mutex);
+ inode_unlock(VFS_I(ip));
 }
 
 /*
diff --git a/fs/xfs/xfs_pnfs.c b/fs/xfs/xfs_pnfs.c
index dc6221942b85..ade236e90bb3 100644
--- a/fs/xfs/xfs_pnfs.c
+++ b/fs/xfs/xfs_pnfs.c
@@ -42,11 +42,11 @@ xfs_break_layouts(
  while ((error = break_layout(inode, false) == -EWOULDBLOCK)) {
  xfs_iunlock(ip, *iolock);
  if (with_imutex && (*iolock & XFS_IOLOCK_EXCL))
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  error = break_layout(inode, true);
  *iolock = XFS_IOLOCK_EXCL;
  if (with_imutex)
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  xfs_ilock(ip, *iolock);
  }
 
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 5cad589d3df5..3a9730873948 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -793,7 +793,7 @@ SYSCALL_DEFINE4(mq_open, const char __user *, u_name, int, oflag, umode_t, mode,
 
  ro = mnt_want_write(mnt); /* we'll drop it in any case */
  error = 0;
- mutex_lock(&d_inode(root)->i_mutex);
+ inode_lock(d_inode(root));
  path.dentry = lookup_one_len(name->name, root, strlen(name->name));
  if (IS_ERR(path.dentry)) {
  error = PTR_ERR(path.dentry);
@@ -839,7 +839,7 @@ out_putfd:
  put_unused_fd(fd);
  fd = error;
  }
- mutex_unlock(&d_inode(root)->i_mutex);
+ inode_unlock(d_inode(root));
  if (!ro)
  mnt_drop_write(mnt);
 out_putname:
@@ -864,7 +864,7 @@ SYSCALL_DEFINE1(mq_unlink, const char __user *, u_name)
  err = mnt_want_write(mnt);
  if (err)
  goto out_name;
- mutex_lock_nested(&d_inode(mnt->mnt_root)->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(d_inode(mnt->mnt_root), I_MUTEX_PARENT);
  dentry = lookup_one_len(name->name, mnt->mnt_root,
  strlen(name->name));
  if (IS_ERR(dentry)) {
@@ -882,7 +882,7 @@ SYSCALL_DEFINE1(mq_unlink, const char __user *, u_name)
  dput(dentry);
 
 out_unlock:
- mutex_unlock(&d_inode(mnt->mnt_root)->i_mutex);
+ inode_unlock(d_inode(mnt->mnt_root));
  if (inode)
  iput(inode);
  mnt_drop_write(mnt);
diff --git a/kernel/audit_fsnotify.c b/kernel/audit_fsnotify.c
index 27c6046c2c3d..f84f8d06e1f6 100644
--- a/kernel/audit_fsnotify.c
+++ b/kernel/audit_fsnotify.c
@@ -95,7 +95,7 @@ struct audit_fsnotify_mark *audit_alloc_mark(struct audit_krule *krule, char *pa
  if (IS_ERR(dentry))
  return (void *)dentry; /* returning an error */
  inode = path.dentry->d_inode;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  audit_mark = kzalloc(sizeof(*audit_mark), GFP_KERNEL);
  if (unlikely(!audit_mark)) {
diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c
index a162661c9d60..c960c308db87 100644
--- a/kernel/audit_watch.c
+++ b/kernel/audit_watch.c
@@ -365,7 +365,7 @@ static int audit_get_nd(struct audit_watch *watch, struct path *parent)
  struct dentry *d = kern_path_locked(watch->path, parent);
  if (IS_ERR(d))
  return PTR_ERR(d);
- mutex_unlock(&d_backing_inode(parent->dentry)->i_mutex);
+ inode_unlock(d_backing_inode(parent->dentry));
  if (d_is_positive(d)) {
  /* update watch filter fields */
  watch->dev = d_backing_inode(d)->i_sb->s_dev;
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 8f75386e61a7..195f6b074cb6 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4952,9 +4952,9 @@ static int perf_fasync(int fd, struct file *filp, int on)
  struct perf_event *event = filp->private_data;
  int retval;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  retval = fasync_helper(fd, filp, on, &event->fasync);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  if (retval < 0)
  return retval;
diff --git a/kernel/relay.c b/kernel/relay.c
index 0b4570cfacae..074994bcfa9b 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -1133,7 +1133,7 @@ static ssize_t relay_file_read_subbufs(struct file *filp, loff_t *ppos,
  if (!desc->count)
  return 0;
 
- mutex_lock(&file_inode(filp)->i_mutex);
+ inode_lock(file_inode(filp));
  do {
  if (!relay_file_read_avail(buf, *ppos))
  break;
@@ -1153,7 +1153,7 @@ static ssize_t relay_file_read_subbufs(struct file *filp, loff_t *ppos,
  *ppos = relay_file_read_end_pos(buf, read_start, ret);
  }
  } while (desc->count && ret);
- mutex_unlock(&file_inode(filp)->i_mutex);
+ inode_unlock(file_inode(filp));
 
  return desc->written;
 }
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b5d372083624..832b848a1019 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -222,9 +222,9 @@ sched_feat_write(struct file *filp, const char __user *ubuf,
 
  /* Ensure the static_key remains in a consistent state */
  inode = file_inode(filp);
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  i = sched_feat_set(cmp);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  if (i == __SCHED_FEAT_NR)
  return -EINVAL;
 
diff --git a/mm/filemap.c b/mm/filemap.c
index 9cacd97150b2..135e3e25b7bc 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2697,11 +2697,11 @@ ssize_t generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
  struct inode *inode = file->f_mapping->host;
  ssize_t ret;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  ret = generic_write_checks(iocb, from);
  if (ret > 0)
  ret = __generic_file_write_iter(iocb, from);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 
  if (ret > 0) {
  ssize_t err;
diff --git a/mm/shmem.c b/mm/shmem.c
index e4731006035b..9e949c4cdf30 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1842,7 +1842,7 @@ static loff_t shmem_file_llseek(struct file *file, loff_t offset, int whence)
  if (whence != SEEK_DATA && whence != SEEK_HOLE)
  return generic_file_llseek_size(file, offset, whence,
  MAX_LFS_FILESIZE, i_size_read(inode));
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  /* We're holding i_mutex so we can access i_size directly */
 
  if (offset < 0)
@@ -1866,7 +1866,7 @@ static loff_t shmem_file_llseek(struct file *file, loff_t offset, int whence)
 
  if (offset >= 0)
  offset = vfs_setpos(file, offset, MAX_LFS_FILESIZE);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return offset;
 }
 
@@ -2031,7 +2031,7 @@ int shmem_add_seals(struct file *file, unsigned int seals)
  if (seals & ~(unsigned int)F_ALL_SEALS)
  return -EINVAL;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  if (info->seals & F_SEAL_SEAL) {
  error = -EPERM;
@@ -2054,7 +2054,7 @@ int shmem_add_seals(struct file *file, unsigned int seals)
  error = 0;
 
 unlock:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return error;
 }
 EXPORT_SYMBOL_GPL(shmem_add_seals);
@@ -2104,7 +2104,7 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset,
  if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
  return -EOPNOTSUPP;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  if (mode & FALLOC_FL_PUNCH_HOLE) {
  struct address_space *mapping = file->f_mapping;
@@ -2219,7 +2219,7 @@ undone:
  inode->i_private = NULL;
  spin_unlock(&inode->i_lock);
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return error;
 }
 
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 566f4ea8505f..8082b4a9c405 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1976,9 +1976,9 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
  set_blocksize(bdev, old_block_size);
  blkdev_put(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL);
  } else {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  inode->i_flags &= ~S_SWAPFILE;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
  filp_close(swap_file, NULL);
 
@@ -2203,7 +2203,7 @@ static int claim_swapfile(struct swap_info_struct *p, struct inode *inode)
  p->flags |= SWP_BLKDEV;
  } else if (S_ISREG(inode->i_mode)) {
  p->bdev = inode->i_sb->s_bdev;
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  if (IS_SWAPFILE(inode))
  return -EBUSY;
  } else
@@ -2438,7 +2438,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
  mapping = swap_file->f_mapping;
  inode = mapping->host;
 
- /* If S_ISREG(inode->i_mode) will do mutex_lock(&inode->i_mutex); */
+ /* If S_ISREG(inode->i_mode) will do inode_lock(inode); */
  error = claim_swapfile(p, inode);
  if (unlikely(error))
  goto bad_swap;
@@ -2583,7 +2583,7 @@ bad_swap:
  vfree(cluster_info);
  if (swap_file) {
  if (inode && S_ISREG(inode->i_mode)) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  inode = NULL;
  }
  filp_close(swap_file, NULL);
@@ -2596,7 +2596,7 @@ out:
  if (name)
  putname(name);
  if (inode && S_ISREG(inode->i_mode))
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return error;
 }
 
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 63fb5ee212cf..008c25d1b9f9 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -771,7 +771,7 @@ static ssize_t cache_read(struct file *filp, char __user *buf, size_t count,
  if (count == 0)
  return 0;
 
- mutex_lock(&inode->i_mutex); /* protect against multiple concurrent
+ inode_lock(inode); /* protect against multiple concurrent
       * readers on this file */
  again:
  spin_lock(&queue_lock);
@@ -784,7 +784,7 @@ static ssize_t cache_read(struct file *filp, char __user *buf, size_t count,
  }
  if (rp->q.list.next == &cd->queue) {
  spin_unlock(&queue_lock);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  WARN_ON_ONCE(rp->offset);
  return 0;
  }
@@ -838,7 +838,7 @@ static ssize_t cache_read(struct file *filp, char __user *buf, size_t count,
  }
  if (err == -EAGAIN)
  goto again;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return err ? err :  count;
 }
 
@@ -909,9 +909,9 @@ static ssize_t cache_write(struct file *filp, const char __user *buf,
  if (!cd->cache_parse)
  goto out;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  ret = cache_downcall(mapping, buf, count, cd);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 out:
  return ret;
 }
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 76cf985f3cc5..9df605f961dd 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -172,7 +172,7 @@ rpc_close_pipes(struct inode *inode)
  int need_release;
  LIST_HEAD(free_list);
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  spin_lock(&pipe->lock);
  need_release = pipe->nreaders != 0 || pipe->nwriters != 0;
  pipe->nreaders = 0;
@@ -188,7 +188,7 @@ rpc_close_pipes(struct inode *inode)
  cancel_delayed_work_sync(&pipe->queue_timeout);
  rpc_inode_setowner(inode, NULL);
  RPC_I(inode)->pipe = NULL;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 }
 
 static struct inode *
@@ -221,7 +221,7 @@ rpc_pipe_open(struct inode *inode, struct file *filp)
  int first_open;
  int res = -ENXIO;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  pipe = RPC_I(inode)->pipe;
  if (pipe == NULL)
  goto out;
@@ -237,7 +237,7 @@ rpc_pipe_open(struct inode *inode, struct file *filp)
  pipe->nwriters++;
  res = 0;
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return res;
 }
 
@@ -248,7 +248,7 @@ rpc_pipe_release(struct inode *inode, struct file *filp)
  struct rpc_pipe_msg *msg;
  int last_close;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  pipe = RPC_I(inode)->pipe;
  if (pipe == NULL)
  goto out;
@@ -278,7 +278,7 @@ rpc_pipe_release(struct inode *inode, struct file *filp)
  if (last_close && pipe->ops->release_pipe)
  pipe->ops->release_pipe(inode);
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return 0;
 }
 
@@ -290,7 +290,7 @@ rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
  struct rpc_pipe_msg *msg;
  int res = 0;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  pipe = RPC_I(inode)->pipe;
  if (pipe == NULL) {
  res = -EPIPE;
@@ -322,7 +322,7 @@ rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
  pipe->ops->destroy_msg(msg);
  }
 out_unlock:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return res;
 }
 
@@ -332,11 +332,11 @@ rpc_pipe_write(struct file *filp, const char __user *buf, size_t len, loff_t *of
  struct inode *inode = file_inode(filp);
  int res;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  res = -EPIPE;
  if (RPC_I(inode)->pipe != NULL)
  res = RPC_I(inode)->pipe->ops->downcall(filp, buf, len);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return res;
 }
 
@@ -349,12 +349,12 @@ rpc_pipe_poll(struct file *filp, struct poll_table_struct *wait)
 
  poll_wait(filp, &rpci->waitq, wait);
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  if (rpci->pipe == NULL)
  mask |= POLLERR | POLLHUP;
  else if (filp->private_data || !list_empty(&rpci->pipe->pipe))
  mask |= POLLIN | POLLRDNORM;
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return mask;
 }
 
@@ -367,10 +367,10 @@ rpc_pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 
  switch (cmd) {
  case FIONREAD:
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  pipe = RPC_I(inode)->pipe;
  if (pipe == NULL) {
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return -EPIPE;
  }
  spin_lock(&pipe->lock);
@@ -381,7 +381,7 @@ rpc_pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
  len += msg->len - msg->copied;
  }
  spin_unlock(&pipe->lock);
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  return put_user(len, (int __user *)arg);
  default:
  return -EINVAL;
@@ -617,9 +617,9 @@ int rpc_rmdir(struct dentry *dentry)
 
  parent = dget_parent(dentry);
  dir = d_inode(parent);
- mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(dir, I_MUTEX_PARENT);
  error = __rpc_rmdir(dir, dentry);
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
  dput(parent);
  return error;
 }
@@ -701,9 +701,9 @@ static void rpc_depopulate(struct dentry *parent,
 {
  struct inode *dir = d_inode(parent);
 
- mutex_lock_nested(&dir->i_mutex, I_MUTEX_CHILD);
+ inode_lock_nested(dir, I_MUTEX_CHILD);
  __rpc_depopulate(parent, files, start, eof);
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
 }
 
 static int rpc_populate(struct dentry *parent,
@@ -715,7 +715,7 @@ static int rpc_populate(struct dentry *parent,
  struct dentry *dentry;
  int i, err;
 
- mutex_lock(&dir->i_mutex);
+ inode_lock(dir);
  for (i = start; i < eof; i++) {
  dentry = __rpc_lookup_create_exclusive(parent, files[i].name);
  err = PTR_ERR(dentry);
@@ -739,11 +739,11 @@ static int rpc_populate(struct dentry *parent,
  if (err != 0)
  goto out_bad;
  }
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
  return 0;
 out_bad:
  __rpc_depopulate(parent, files, start, eof);
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
  printk(KERN_WARNING "%s: %s failed to populate directory %pd\n",
  __FILE__, __func__, parent);
  return err;
@@ -757,7 +757,7 @@ static struct dentry *rpc_mkdir_populate(struct dentry *parent,
  struct inode *dir = d_inode(parent);
  int error;
 
- mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(dir, I_MUTEX_PARENT);
  dentry = __rpc_lookup_create_exclusive(parent, name);
  if (IS_ERR(dentry))
  goto out;
@@ -770,7 +770,7 @@ static struct dentry *rpc_mkdir_populate(struct dentry *parent,
  goto err_rmdir;
  }
 out:
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
  return dentry;
 err_rmdir:
  __rpc_rmdir(dir, dentry);
@@ -788,11 +788,11 @@ static int rpc_rmdir_depopulate(struct dentry *dentry,
 
  parent = dget_parent(dentry);
  dir = d_inode(parent);
- mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(dir, I_MUTEX_PARENT);
  if (depopulate != NULL)
  depopulate(dentry);
  error = __rpc_rmdir(dir, dentry);
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
  dput(parent);
  return error;
 }
@@ -828,7 +828,7 @@ struct dentry *rpc_mkpipe_dentry(struct dentry *parent, const char *name,
  if (pipe->ops->downcall == NULL)
  umode &= ~S_IWUGO;
 
- mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(dir, I_MUTEX_PARENT);
  dentry = __rpc_lookup_create_exclusive(parent, name);
  if (IS_ERR(dentry))
  goto out;
@@ -837,7 +837,7 @@ struct dentry *rpc_mkpipe_dentry(struct dentry *parent, const char *name,
  if (err)
  goto out_err;
 out:
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
  return dentry;
 out_err:
  dentry = ERR_PTR(err);
@@ -865,9 +865,9 @@ rpc_unlink(struct dentry *dentry)
 
  parent = dget_parent(dentry);
  dir = d_inode(parent);
- mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
+ inode_lock_nested(dir, I_MUTEX_PARENT);
  error = __rpc_rmpipe(dir, dentry);
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
  dput(parent);
  return error;
 }
diff --git a/security/inode.c b/security/inode.c
index 692b28403860..59886cdcd983 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -136,7 +136,7 @@ struct dentry *securityfs_create_dentry(const char *name, umode_t mode,
 
  dir = d_inode(parent);
 
- mutex_lock(&dir->i_mutex);
+ inode_lock(dir);
  dentry = lookup_one_len(name, parent, strlen(name));
  if (IS_ERR(dentry))
  goto out;
@@ -149,14 +149,14 @@ struct dentry *securityfs_create_dentry(const char *name, umode_t mode,
  error = __securityfs_setup_d_inode(dir, dentry, mode, data, fops, iops);
  if (error)
  goto out1;
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
  return dentry;
 
 out1:
  dput(dentry);
  dentry = ERR_PTR(error);
 out:
- mutex_unlock(&dir->i_mutex);
+ inode_unlock(dir);
  simple_release_fs(&mount, &mount_count);
  return dentry;
 }
@@ -248,7 +248,7 @@ void securityfs_remove(struct dentry *dentry)
  if (!parent || d_really_is_negative(parent))
  return;
 
- mutex_lock(&d_inode(parent)->i_mutex);
+ inode_lock(d_inode(parent));
  if (simple_positive(dentry)) {
  if (d_is_dir(dentry))
  simple_rmdir(d_inode(parent), dentry);
@@ -256,7 +256,7 @@ void securityfs_remove(struct dentry *dentry)
  simple_unlink(d_inode(parent), dentry);
  dput(dentry);
  }
- mutex_unlock(&d_inode(parent)->i_mutex);
+ inode_unlock(d_inode(parent));
  simple_release_fs(&mount, &mount_count);
 }
 EXPORT_SYMBOL_GPL(securityfs_remove);
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index c21f09bf8b99..9d96551d0196 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -121,7 +121,7 @@ static void ima_check_last_writer(struct integrity_iint_cache *iint,
  if (!(mode & FMODE_WRITE))
  return;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  if (atomic_read(&inode->i_writecount) == 1) {
  if ((iint->version != inode->i_version) ||
     (iint->flags & IMA_NEW_FILE)) {
@@ -130,7 +130,7 @@ static void ima_check_last_writer(struct integrity_iint_cache *iint,
  ima_update_xattr(iint, file);
  }
  }
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
 }
 
 /**
@@ -186,7 +186,7 @@ static int process_measurement(struct file *file, int mask, int function,
  if (action & IMA_FILE_APPRAISE)
  function = FILE_CHECK;
 
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
 
  if (action) {
  iint = integrity_inode_get(inode);
@@ -250,7 +250,7 @@ out_free:
  if (pathbuf)
  __putname(pathbuf);
 out:
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  if ((rc && must_appraise) && (ima_appraise & IMA_APPRAISE_ENFORCE))
  return -EACCES;
  return 0;
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index c02da25d7b63..f0de43d50e7c 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -393,9 +393,9 @@ static int sel_open_policy(struct inode *inode, struct file *filp)
  goto err;
 
  if (i_size_read(inode) != security_policydb_len()) {
- mutex_lock(&inode->i_mutex);
+ inode_lock(inode);
  i_size_write(inode, security_policydb_len());
- mutex_unlock(&inode->i_mutex);
+ inode_unlock(inode);
  }
 
  rc = security_read_policy(&plm->data, &plm->len);
diff --git a/spl/include/linux/file_compat.h b/spl/include/linux/file_compat.h
index a2db2590a235..d2846d3a3f06 100644
--- a/spl/include/linux/file_compat.h
+++ b/spl/include/linux/file_compat.h
@@ -76,8 +76,8 @@ spl_filp_fallocate(struct file *fp, int mode, loff_t offset, loff_t len)
 #define spl_filp_fsync(fp, sync) vfs_fsync(fp, (fp)->f_dentry, sync)
 #endif /* HAVE_2ARGS_VFS_FSYNC */
 
-#define spl_inode_lock(ip) mutex_lock(&(ip)->i_mutex)
-#define spl_inode_unlock(ip) mutex_unlock(&(ip)->i_mutex)
+#define spl_inode_lock(ip) inode_lock((ip))
+#define spl_inode_unlock(ip) inode_unlock((ip))
 
 #endif /* SPL_FILE_COMPAT_H */
 
--
2.14.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[Xenial][PATCH 3/9] xattr_handler: pass dentry and inode as separate arguments of ->get()

Khalid Elmously
In reply to this post by Khalid Elmously
BugLink: http://bugs.launchpad.net/bugs/1415636

commit b296821a7c42fa58baa17513b2b7b30ae66f3336 upstream.

... and do not assume they are already attached to each other

Signed-off-by: Khalid Elmously <[hidden email]>
---
 fs/9p/acl.c                        |  6 +++---
 fs/9p/xattr.c                      |  4 ++--
 fs/ext2/xattr_security.c           |  6 +++---
 fs/ext2/xattr_trusted.c            |  6 +++---
 fs/ext2/xattr_user.c               |  8 ++++----
 fs/ext4/xattr_security.c           |  6 +++---
 fs/ext4/xattr_trusted.c            |  6 +++---
 fs/ext4/xattr_user.c               |  8 ++++----
 fs/f2fs/xattr.c                    | 14 ++++++--------
 fs/gfs2/xattr.c                    |  6 +++---
 fs/hfsplus/xattr.c                 | 10 +++++-----
 fs/hfsplus/xattr.h                 |  2 +-
 fs/hfsplus/xattr_security.c        |  6 +++---
 fs/hfsplus/xattr_trusted.c         |  6 +++---
 fs/hfsplus/xattr_user.c            |  6 +++---
 fs/jffs2/security.c                |  6 +++---
 fs/jffs2/xattr_trusted.c           |  6 +++---
 fs/jffs2/xattr_user.c              |  6 +++---
 fs/nfs/nfs4proc.c                  | 12 ++++++------
 fs/ocfs2/xattr.c                   | 20 ++++++++++----------
 fs/posix_acl.c                     | 10 +++++-----
 fs/reiserfs/xattr_security.c       |  9 ++++-----
 fs/reiserfs/xattr_trusted.c        |  9 ++++-----
 fs/reiserfs/xattr_user.c           |  9 ++++-----
 fs/squashfs/xattr.c                |  6 ++++--
 fs/xattr.c                         |  3 ++-
 fs/xfs/xfs_xattr.c                 |  6 +++---
 include/linux/xattr.h              |  3 ++-
 zfs/config/kernel-xattr-handler.m4 |  2 +-
 zfs/include/linux/xattr_compat.h   |  4 ++--
 30 files changed, 105 insertions(+), 106 deletions(-)

diff --git a/fs/9p/acl.c b/fs/9p/acl.c
index 4bd4bffd6116..7ecd14060d10 100644
--- a/fs/9p/acl.c
+++ b/fs/9p/acl.c
@@ -213,8 +213,8 @@ int v9fs_acl_mode(struct inode *dir, umode_t *modep,
 }
 
 static int v9fs_xattr_get_acl(const struct xattr_handler *handler,
-      struct dentry *dentry, const char *name,
-      void *buffer, size_t size)
+      struct dentry *dentry, struct inode *inode,
+      const char *name, void *buffer, size_t size)
 {
  struct v9fs_session_info *v9ses;
  struct posix_acl *acl;
@@ -230,7 +230,7 @@ static int v9fs_xattr_get_acl(const struct xattr_handler *handler,
  if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
  return v9fs_xattr_get(dentry, handler->prefix, buffer, size);
 
- acl = v9fs_get_cached_acl(d_inode(dentry), handler->flags);
+ acl = v9fs_get_cached_acl(inode, handler->flags);
  if (IS_ERR(acl))
  return PTR_ERR(acl);
  if (acl == NULL)
diff --git a/fs/9p/xattr.c b/fs/9p/xattr.c
index e3d026ac382e..ef0dae2a50f8 100644
--- a/fs/9p/xattr.c
+++ b/fs/9p/xattr.c
@@ -138,8 +138,8 @@ ssize_t v9fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
 }
 
 static int v9fs_xattr_handler_get(const struct xattr_handler *handler,
-  struct dentry *dentry, const char *name,
-  void *buffer, size_t size)
+  struct dentry *dentry, struct inode *inode,
+  const char *name, void *buffer, size_t size)
 {
  const char *full_name = xattr_full_name(handler, name);
 
diff --git a/fs/ext2/xattr_security.c b/fs/ext2/xattr_security.c
index dfb08750370d..b478e8224386 100644
--- a/fs/ext2/xattr_security.c
+++ b/fs/ext2/xattr_security.c
@@ -25,12 +25,12 @@ ext2_xattr_security_list(const struct xattr_handler *handler,
 
 static int
 ext2_xattr_security_get(const struct xattr_handler *handler,
- struct dentry *dentry, const char *name,
- void *buffer, size_t size)
+ struct dentry *unused, struct inode *inode,
+ const char *name, void *buffer, size_t size)
 {
  if (strcmp(name, "") == 0)
  return -EINVAL;
- return ext2_xattr_get(d_inode(dentry), EXT2_XATTR_INDEX_SECURITY, name,
+ return ext2_xattr_get(inode, EXT2_XATTR_INDEX_SECURITY, name,
       buffer, size);
 }
 
diff --git a/fs/ext2/xattr_trusted.c b/fs/ext2/xattr_trusted.c
index 3150dd3a7859..4d8e63e5f8dd 100644
--- a/fs/ext2/xattr_trusted.c
+++ b/fs/ext2/xattr_trusted.c
@@ -29,12 +29,12 @@ ext2_xattr_trusted_list(const struct xattr_handler *handler,
 
 static int
 ext2_xattr_trusted_get(const struct xattr_handler *handler,
-       struct dentry *dentry, const char *name,
-       void *buffer, size_t size)
+       struct dentry *unused, struct inode *inode,
+       const char *name, void *buffer, size_t size)
 {
  if (strcmp(name, "") == 0)
  return -EINVAL;
- return ext2_xattr_get(d_inode(dentry), EXT2_XATTR_INDEX_TRUSTED, name,
+ return ext2_xattr_get(inode, EXT2_XATTR_INDEX_TRUSTED, name,
       buffer, size);
 }
 
diff --git a/fs/ext2/xattr_user.c b/fs/ext2/xattr_user.c
index 339a49bbb8ef..8c7aad0a3d6c 100644
--- a/fs/ext2/xattr_user.c
+++ b/fs/ext2/xattr_user.c
@@ -31,14 +31,14 @@ ext2_xattr_user_list(const struct xattr_handler *handler,
 
 static int
 ext2_xattr_user_get(const struct xattr_handler *handler,
-    struct dentry *dentry, const char *name,
-    void *buffer, size_t size)
+    struct dentry *unused, struct inode *inode,
+    const char *name, void *buffer, size_t size)
 {
  if (strcmp(name, "") == 0)
  return -EINVAL;
- if (!test_opt(dentry->d_sb, XATTR_USER))
+ if (!test_opt(inode->i_sb, XATTR_USER))
  return -EOPNOTSUPP;
- return ext2_xattr_get(d_inode(dentry), EXT2_XATTR_INDEX_USER,
+ return ext2_xattr_get(inode, EXT2_XATTR_INDEX_USER,
       name, buffer, size);
 }
 
diff --git a/fs/ext4/xattr_security.c b/fs/ext4/xattr_security.c
index 36f4c1a84c21..362bc4b7643b 100644
--- a/fs/ext4/xattr_security.c
+++ b/fs/ext4/xattr_security.c
@@ -30,12 +30,12 @@ ext4_xattr_security_list(const struct xattr_handler *handler,
 
 static int
 ext4_xattr_security_get(const struct xattr_handler *handler,
- struct dentry *dentry, const char *name,
- void *buffer, size_t size)
+ struct dentry *unused, struct inode *inode,
+ const char *name, void *buffer, size_t size)
 {
  if (strcmp(name, "") == 0)
  return -EINVAL;
- return ext4_xattr_get(d_inode(dentry), EXT4_XATTR_INDEX_SECURITY,
+ return ext4_xattr_get(inode, EXT4_XATTR_INDEX_SECURITY,
       name, buffer, size);
 }
 
diff --git a/fs/ext4/xattr_trusted.c b/fs/ext4/xattr_trusted.c
index 488089053342..667ee47b2fa9 100644
--- a/fs/ext4/xattr_trusted.c
+++ b/fs/ext4/xattr_trusted.c
@@ -33,12 +33,12 @@ ext4_xattr_trusted_list(const struct xattr_handler *handler,
 
 static int
 ext4_xattr_trusted_get(const struct xattr_handler *handler,
-       struct dentry *dentry, const char *name, void *buffer,
-       size_t size)
+       struct dentry *unused, struct inode *inode,
+       const char *name, void *buffer, size_t size)
 {
  if (strcmp(name, "") == 0)
  return -EINVAL;
- return ext4_xattr_get(d_inode(dentry), EXT4_XATTR_INDEX_TRUSTED,
+ return ext4_xattr_get(inode, EXT4_XATTR_INDEX_TRUSTED,
       name, buffer, size);
 }
 
diff --git a/fs/ext4/xattr_user.c b/fs/ext4/xattr_user.c
index d2dec3364062..400de4687a58 100644
--- a/fs/ext4/xattr_user.c
+++ b/fs/ext4/xattr_user.c
@@ -32,14 +32,14 @@ ext4_xattr_user_list(const struct xattr_handler *handler,
 
 static int
 ext4_xattr_user_get(const struct xattr_handler *handler,
-    struct dentry *dentry, const char *name,
-    void *buffer, size_t size)
+    struct dentry *unused, struct inode *inode,
+    const char *name, void *buffer, size_t size)
 {
  if (strcmp(name, "") == 0)
  return -EINVAL;
- if (!test_opt(dentry->d_sb, XATTR_USER))
+ if (!test_opt(inode->i_sb, XATTR_USER))
  return -EOPNOTSUPP;
- return ext4_xattr_get(d_inode(dentry), EXT4_XATTR_INDEX_USER,
+ return ext4_xattr_get(inode, EXT4_XATTR_INDEX_USER,
       name, buffer, size);
 }
 
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index 862368a32e53..c294d55777f9 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -58,10 +58,10 @@ static size_t f2fs_xattr_generic_list(const struct xattr_handler *handler,
 }
 
 static int f2fs_xattr_generic_get(const struct xattr_handler *handler,
- struct dentry *dentry, const char *name, void *buffer,
- size_t size)
+ struct dentry *unused, struct inode *inode,
+ const char *name, void *buffer, size_t size)
 {
- struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb);
+ struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
 
  switch (handler->flags) {
  case F2FS_XATTR_INDEX_USER:
@@ -79,7 +79,7 @@ static int f2fs_xattr_generic_get(const struct xattr_handler *handler,
  }
  if (strcmp(name, "") == 0)
  return -EINVAL;
- return f2fs_getxattr(d_inode(dentry), handler->flags, name,
+ return f2fs_getxattr(inode, handler->flags, name,
      buffer, size, NULL);
 }
 
@@ -124,11 +124,9 @@ static size_t f2fs_xattr_advise_list(const struct xattr_handler *handler,
 }
 
 static int f2fs_xattr_advise_get(const struct xattr_handler *handler,
- struct dentry *dentry, const char *name, void *buffer,
- size_t size)
+ struct dentry *unused, struct inode *inode,
+ const char *name, void *buffer, size_t size)
 {
- struct inode *inode = d_inode(dentry);
-
  if (strcmp(name, "") != 0)
  return -EINVAL;
 
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c
index 53ce76a374fe..f59e861f5728 100644
--- a/fs/gfs2/xattr.c
+++ b/fs/gfs2/xattr.c
@@ -584,10 +584,10 @@ out:
  * Returns: actual size of data on success, -errno on error
  */
 static int gfs2_xattr_get(const struct xattr_handler *handler,
-  struct dentry *dentry, const char *name,
-  void *buffer, size_t size)
+  struct dentry *unused, struct inode *inode,
+  const char *name, void *buffer, size_t size)
 {
- struct gfs2_inode *ip = GFS2_I(d_inode(dentry));
+ struct gfs2_inode *ip = GFS2_I(inode);
  struct gfs2_ea_location el;
  int type = handler->flags;
  int error;
diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
index e41a010cd89c..9f76fe0ed68f 100644
--- a/fs/hfsplus/xattr.c
+++ b/fs/hfsplus/xattr.c
@@ -582,7 +582,7 @@ failed_getxattr_init:
  return res;
 }
 
-ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name,
+ssize_t hfsplus_getxattr(struct inode *inode, const char *name,
  void *value, size_t size,
  const char *prefix, size_t prefixlen)
 {
@@ -600,7 +600,7 @@ ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name,
  strcpy(xattr_name, prefix);
  strcpy(xattr_name + prefixlen, name);
 
- res = __hfsplus_getxattr(d_inode(dentry), xattr_name, value, size);
+ res = __hfsplus_getxattr(inode, xattr_name, value, size);
  kfree(xattr_name);
  return res;
 
@@ -850,8 +850,8 @@ end_removexattr:
 }
 
 static int hfsplus_osx_getxattr(const struct xattr_handler *handler,
- struct dentry *dentry, const char *name,
- void *buffer, size_t size)
+ struct dentry *unused, struct inode *inode,
+ const char *name, void *buffer, size_t size)
 {
  if (!strcmp(name, ""))
  return -EINVAL;
@@ -869,7 +869,7 @@ static int hfsplus_osx_getxattr(const struct xattr_handler *handler,
  * creates), so we pass the name through unmodified (after
  * ensuring it doesn't conflict with another namespace).
  */
- return __hfsplus_getxattr(d_inode(dentry), name, buffer, size);
+ return __hfsplus_getxattr(inode, name, buffer, size);
 }
 
 static int hfsplus_osx_setxattr(const struct xattr_handler *handler,
diff --git a/fs/hfsplus/xattr.h b/fs/hfsplus/xattr.h
index f9b0955b3d28..d04ba6f58df2 100644
--- a/fs/hfsplus/xattr.h
+++ b/fs/hfsplus/xattr.h
@@ -28,7 +28,7 @@ int hfsplus_setxattr(struct dentry *dentry, const char *name,
 ssize_t __hfsplus_getxattr(struct inode *inode, const char *name,
    void *value, size_t size);
 
-ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name,
+ssize_t hfsplus_getxattr(struct inode *inode, const char *name,
  void *value, size_t size,
  const char *prefix, size_t prefixlen);
 
diff --git a/fs/hfsplus/xattr_security.c b/fs/hfsplus/xattr_security.c
index 72a68a3a0c99..ae2ca8c2e335 100644
--- a/fs/hfsplus/xattr_security.c
+++ b/fs/hfsplus/xattr_security.c
@@ -14,10 +14,10 @@
 #include "acl.h"
 
 static int hfsplus_security_getxattr(const struct xattr_handler *handler,
-     struct dentry *dentry, const char *name,
-     void *buffer, size_t size)
+     struct dentry *unused, struct inode *inode,
+     const char *name, void *buffer, size_t size)
 {
- return hfsplus_getxattr(dentry, name, buffer, size,
+ return hfsplus_getxattr(inode, name, buffer, size,
  XATTR_SECURITY_PREFIX,
  XATTR_SECURITY_PREFIX_LEN);
 }
diff --git a/fs/hfsplus/xattr_trusted.c b/fs/hfsplus/xattr_trusted.c
index 95a7704c7abb..eae2947060aa 100644
--- a/fs/hfsplus/xattr_trusted.c
+++ b/fs/hfsplus/xattr_trusted.c
@@ -12,10 +12,10 @@
 #include "xattr.h"
 
 static int hfsplus_trusted_getxattr(const struct xattr_handler *handler,
-    struct dentry *dentry, const char *name,
-    void *buffer, size_t size)
+    struct dentry *unused, struct inode *inode,
+    const char *name, void *buffer, size_t size)
 {
- return hfsplus_getxattr(dentry, name, buffer, size,
+ return hfsplus_getxattr(inode, name, buffer, size,
  XATTR_TRUSTED_PREFIX,
  XATTR_TRUSTED_PREFIX_LEN);
 }
diff --git a/fs/hfsplus/xattr_user.c b/fs/hfsplus/xattr_user.c
index 6fc269baf959..3c9eec3e4c7b 100644
--- a/fs/hfsplus/xattr_user.c
+++ b/fs/hfsplus/xattr_user.c
@@ -12,11 +12,11 @@
 #include "xattr.h"
 
 static int hfsplus_user_getxattr(const struct xattr_handler *handler,
- struct dentry *dentry, const char *name,
- void *buffer, size_t size)
+ struct dentry *unused, struct inode *inode,
+ const char *name, void *buffer, size_t size)
 {
 
- return hfsplus_getxattr(dentry, name, buffer, size,
+ return hfsplus_getxattr(inode, name, buffer, size,
  XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN);
 }
 
diff --git a/fs/jffs2/security.c b/fs/jffs2/security.c
index bf12fe5f83d7..ee0c2651513a 100644
--- a/fs/jffs2/security.c
+++ b/fs/jffs2/security.c
@@ -49,13 +49,13 @@ int jffs2_init_security(struct inode *inode, struct inode *dir,
 
 /* ---- XATTR Handler for "security.*" ----------------- */
 static int jffs2_security_getxattr(const struct xattr_handler *handler,
-   struct dentry *dentry, const char *name,
-   void *buffer, size_t size)
+   struct dentry *unused, struct inode *inode,
+   const char *name, void *buffer, size_t size)
 {
  if (!strcmp(name, ""))
  return -EINVAL;
 
- return do_jffs2_getxattr(d_inode(dentry), JFFS2_XPREFIX_SECURITY,
+ return do_jffs2_getxattr(inode, JFFS2_XPREFIX_SECURITY,
  name, buffer, size);
 }
 
diff --git a/fs/jffs2/xattr_trusted.c b/fs/jffs2/xattr_trusted.c
index a562da0d6a26..1f406acea950 100644
--- a/fs/jffs2/xattr_trusted.c
+++ b/fs/jffs2/xattr_trusted.c
@@ -17,12 +17,12 @@
 #include "nodelist.h"
 
 static int jffs2_trusted_getxattr(const struct xattr_handler *handler,
-  struct dentry *dentry, const char *name,
-  void *buffer, size_t size)
+  struct dentry *unused, struct inode *inode,
+  const char *name, void *buffer, size_t size)
 {
  if (!strcmp(name, ""))
  return -EINVAL;
- return do_jffs2_getxattr(d_inode(dentry), JFFS2_XPREFIX_TRUSTED,
+ return do_jffs2_getxattr(inode, JFFS2_XPREFIX_TRUSTED,
  name, buffer, size);
 }
 
diff --git a/fs/jffs2/xattr_user.c b/fs/jffs2/xattr_user.c
index cbc0472e59a8..0d6962efcfdd 100644
--- a/fs/jffs2/xattr_user.c
+++ b/fs/jffs2/xattr_user.c
@@ -17,12 +17,12 @@
 #include "nodelist.h"
 
 static int jffs2_user_getxattr(const struct xattr_handler *handler,
-       struct dentry *dentry, const char *name,
-       void *buffer, size_t size)
+       struct dentry *unused, struct inode *inode,
+       const char *name, void *buffer, size_t size)
 {
  if (!strcmp(name, ""))
  return -EINVAL;
- return do_jffs2_getxattr(d_inode(dentry), JFFS2_XPREFIX_USER,
+ return do_jffs2_getxattr(inode, JFFS2_XPREFIX_USER,
  name, buffer, size);
 }
 
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 8e425f2c5ddd..9a5e5700b974 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -6254,13 +6254,13 @@ static int nfs4_xattr_set_nfs4_acl(const struct xattr_handler *handler,
 }
 
 static int nfs4_xattr_get_nfs4_acl(const struct xattr_handler *handler,
-   struct dentry *dentry, const char *key,
-   void *buf, size_t buflen)
+   struct dentry *unused, struct inode *inode,
+   const char *key, void *buf, size_t buflen)
 {
  if (strcmp(key, "") != 0)
  return -EINVAL;
 
- return nfs4_proc_get_acl(d_inode(dentry), buf, buflen);
+ return nfs4_proc_get_acl(inode, buf, buflen);
 }
 
 static size_t nfs4_xattr_list_nfs4_acl(const struct xattr_handler *handler,
@@ -6296,11 +6296,11 @@ static int nfs4_xattr_set_nfs4_label(const struct xattr_handler *handler,
 }
 
 static int nfs4_xattr_get_nfs4_label(const struct xattr_handler *handler,
-     struct dentry *dentry, const char *key,
-     void *buf, size_t buflen)
+     struct dentry *unused, struct inode *inode,
+     const char *key, void *buf, size_t buflen)
 {
  if (security_ismaclabel(key))
- return nfs4_get_security_label(d_inode(dentry), buf, buflen);
+ return nfs4_get_security_label(inode, buf, buflen);
  return -EOPNOTSUPP;
 }
 
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 8203c050a006..a5349ade37a8 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -7242,12 +7242,12 @@ static size_t ocfs2_xattr_security_list(const struct xattr_handler *handler,
 }
 
 static int ocfs2_xattr_security_get(const struct xattr_handler *handler,
-    struct dentry *dentry, const char *name,
-    void *buffer, size_t size)
+    struct dentry *unused, struct inode *inode,
+    const char *name, void *buffer, size_t size)
 {
  if (strcmp(name, "") == 0)
  return -EINVAL;
- return ocfs2_xattr_get(d_inode(dentry), OCFS2_XATTR_INDEX_SECURITY,
+ return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_SECURITY,
        name, buffer, size);
 }
 
@@ -7338,12 +7338,12 @@ static size_t ocfs2_xattr_trusted_list(const struct xattr_handler *handler,
 }
 
 static int ocfs2_xattr_trusted_get(const struct xattr_handler *handler,
-   struct dentry *dentry, const char *name,
-   void *buffer, size_t size)
+   struct dentry *unused, struct inode *inode,
+   const char *name, void *buffer, size_t size)
 {
  if (strcmp(name, "") == 0)
  return -EINVAL;
- return ocfs2_xattr_get(d_inode(dentry), OCFS2_XATTR_INDEX_TRUSTED,
+ return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED,
        name, buffer, size);
 }
 
@@ -7389,16 +7389,16 @@ static size_t ocfs2_xattr_user_list(const struct xattr_handler *handler,
 }
 
 static int ocfs2_xattr_user_get(const struct xattr_handler *handler,
- struct dentry *dentry, const char *name,
- void *buffer, size_t size)
+ struct dentry *unusde, struct inode *inode,
+ const char *name, void *buffer, size_t size)
 {
- struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
+ struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
 
  if (strcmp(name, "") == 0)
  return -EINVAL;
  if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
  return -EOPNOTSUPP;
- return ocfs2_xattr_get(d_inode(dentry), OCFS2_XATTR_INDEX_USER, name,
+ return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name,
        buffer, size);
 }
 
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index fa8725ed61c7..9488b5758c6e 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -804,20 +804,20 @@ EXPORT_SYMBOL (posix_acl_to_xattr);
 
 static int
 posix_acl_xattr_get(const struct xattr_handler *handler,
-    struct dentry *dentry, const char *name,
-    void *value, size_t size)
+    struct dentry *unused, struct inode *inode,
+    const char *name, void *value, size_t size)
 {
  struct posix_acl *acl;
  int error;
 
  if (strcmp(name, "") != 0)
  return -EINVAL;
- if (!IS_POSIXACL(d_backing_inode(dentry)))
+ if (!IS_POSIXACL(inode))
  return -EOPNOTSUPP;
- if (d_is_symlink(dentry))
+ if (S_ISLNK(inode->i_mode))
  return -EOPNOTSUPP;
 
- acl = get_acl(d_backing_inode(dentry), handler->flags);
+ acl = get_acl(inode, handler->flags);
  if (IS_ERR(acl))
  return PTR_ERR(acl);
  if (acl == NULL)
diff --git a/fs/reiserfs/xattr_security.c b/fs/reiserfs/xattr_security.c
index 60de069225ba..365a9f9ebd09 100644
--- a/fs/reiserfs/xattr_security.c
+++ b/fs/reiserfs/xattr_security.c
@@ -9,14 +9,13 @@
 #include <linux/uaccess.h>
 
 static int
-security_get(const struct xattr_handler *handler, struct dentry *dentry,
-     const char *name, void *buffer, size_t size)
+security_get(const struct xattr_handler *handler, struct dentry *unused,
+     struct inode *inode, const char *name, void *buffer, size_t size)
 {
- if (IS_PRIVATE(d_inode(dentry)))
+ if (IS_PRIVATE(inode))
  return -EPERM;
 
- return reiserfs_xattr_get(d_inode(dentry),
-  xattr_full_name(handler, name),
+ return reiserfs_xattr_get(inode, xattr_full_name(handler, name),
   buffer, size);
 }
 
diff --git a/fs/reiserfs/xattr_trusted.c b/fs/reiserfs/xattr_trusted.c
index ebba1ebf28ad..6d2cc21c3a54 100644
--- a/fs/reiserfs/xattr_trusted.c
+++ b/fs/reiserfs/xattr_trusted.c
@@ -8,14 +8,13 @@
 #include <linux/uaccess.h>
 
 static int
-trusted_get(const struct xattr_handler *handler, struct dentry *dentry,
-    const char *name, void *buffer, size_t size)
+trusted_get(const struct xattr_handler *handler, struct dentry *unused,
+    struct inode *inode, const char *name, void *buffer, size_t size)
 {
- if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(d_inode(dentry)))
+ if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))
  return -EPERM;
 
- return reiserfs_xattr_get(d_inode(dentry),
-  xattr_full_name(handler, name),
+ return reiserfs_xattr_get(inode, xattr_full_name(handler, name),
   buffer, size);
 }
 
diff --git a/fs/reiserfs/xattr_user.c b/fs/reiserfs/xattr_user.c
index 6ac8a8c8bd9c..267808fcbaa8 100644
--- a/fs/reiserfs/xattr_user.c
+++ b/fs/reiserfs/xattr_user.c
@@ -7,13 +7,12 @@
 #include <linux/uaccess.h>
 
 static int
-user_get(const struct xattr_handler *handler, struct dentry *dentry,
- const char *name, void *buffer, size_t size)
+user_get(const struct xattr_handler *handler, struct dentry *unused,
+ struct inode *inode, const char *name, void *buffer, size_t size)
 {
- if (!reiserfs_xattrs_user(dentry->d_sb))
+ if (!reiserfs_xattrs_user(inode->i_sb))
  return -EOPNOTSUPP;
- return reiserfs_xattr_get(d_inode(dentry),
-  xattr_full_name(handler, name),
+ return reiserfs_xattr_get(inode, xattr_full_name(handler, name),
   buffer, size);
 }
 
diff --git a/fs/squashfs/xattr.c b/fs/squashfs/xattr.c
index 6a4cc344085c..b13a6b811a8b 100644
--- a/fs/squashfs/xattr.c
+++ b/fs/squashfs/xattr.c
@@ -225,13 +225,15 @@ static size_t squashfs_xattr_handler_list(const struct xattr_handler *handler,
 }
 
 static int squashfs_xattr_handler_get(const struct xattr_handler *handler,
-      struct dentry *d, const char *name,
+      struct dentry *unused,
+      struct inode *inode,
+      const char *name,
       void *buffer, size_t size)
 {
  if (name[0] == '\0')
  return  -EINVAL;
 
- return squashfs_xattr_get(d_inode(d), handler->flags, name,
+ return squashfs_xattr_get(inode, handler->flags, name,
  buffer, size);
 }
 
diff --git a/fs/xattr.c b/fs/xattr.c
index d2d6c4073546..630689a1e21c 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -728,7 +728,8 @@ generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t s
  handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
  if (!handler)
  return -EOPNOTSUPP;
- return handler->get(handler, dentry, name, buffer, size);
+ return handler->get(handler, dentry, d_inode(dentry),
+    name, buffer, size);
 }
 
 /*
diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c
index 9beaf192b4bb..fd707bec1a38 100644
--- a/fs/xfs/xfs_xattr.c
+++ b/fs/xfs/xfs_xattr.c
@@ -32,11 +32,11 @@
 
 
 static int
-xfs_xattr_get(const struct xattr_handler *handler, struct dentry *dentry,
- const char *name, void *value, size_t size)
+xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused,
+ struct inode *inode, const char *name, void *value, size_t size)
 {
  int xflags = handler->flags;
- struct xfs_inode *ip = XFS_I(d_inode(dentry));
+ struct xfs_inode *ip = XFS_I(inode);
  int error, asize = size;
 
  if (strcmp(name, "") == 0)
diff --git a/include/linux/xattr.h b/include/linux/xattr.h
index 89474b9d260c..e79e7c95182c 100644
--- a/include/linux/xattr.h
+++ b/include/linux/xattr.h
@@ -26,7 +26,8 @@ struct xattr_handler {
        char *list, size_t list_size, const char *name,
        size_t name_len);
  int (*get)(const struct xattr_handler *, struct dentry *dentry,
-   const char *name, void *buffer, size_t size);
+   struct inode *inode, const char *name, void *buffer,
+   size_t size);
  int (*set)(const struct xattr_handler *, struct dentry *dentry,
    const char *name, const void *buffer, size_t size,
    int flags);
diff --git a/zfs/config/kernel-xattr-handler.m4 b/zfs/config/kernel-xattr-handler.m4
index e1881f68ba83..29bff8f05d71 100644
--- a/zfs/config/kernel-xattr-handler.m4
+++ b/zfs/config/kernel-xattr-handler.m4
@@ -47,7 +47,7 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_GET], [
  #include <linux/xattr.h>
 
  int get(const struct xattr_handler *handler,
-    struct dentry *dentry, const char *name,
+    struct dentry *dentry, struct inode *inode, const char *name,
     void *buffer, size_t size) { return 0; }
  static const struct xattr_handler
     xops __attribute__ ((unused)) = {
diff --git a/zfs/include/linux/xattr_compat.h b/zfs/include/linux/xattr_compat.h
index 5e19ea1e5cc9..5d1573557e37 100644
--- a/zfs/include/linux/xattr_compat.h
+++ b/zfs/include/linux/xattr_compat.h
@@ -111,9 +111,9 @@ fn(struct inode *ip, char *list, size_t list_size, \
 #define ZPL_XATTR_GET_WRAPPER(fn) \
 static int \
 fn(const struct xattr_handler *handler, struct dentry *dentry, \
-    const char *name, void *buffer, size_t size) \
+    struct inode *inode, const char *name, void *buffer, size_t size) \
 { \
- return (__ ## fn(dentry->d_inode, name, buffer, size)); \
+ return (__ ## fn(inode, name, buffer, size)); \
 }
 /*
  * 2.6.33 API change,
--
2.14.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[Xenial][PATCH 4/9] ->getxattr(): pass dentry and inode as separate arguments

Khalid Elmously
In reply to this post by Khalid Elmously
BugLink: http://bugs.launchpad.net/bugs/1415636

commit ce23e640133484eebc20ca7b7668388213e11327 upstream.

Signed-off-by: Al Viro <[hidden email]>
Signed-off-by: Khalid Elmously <[hidden email]>
---
 Documentation/filesystems/porting                  |  6 ++++++
 .../staging/lustre/lustre/llite/llite_internal.h   |  4 ++--
 drivers/staging/lustre/lustre/llite/xattr.c        |  6 ++----
 fs/bad_inode.c                                     |  4 ++--
 fs/btrfs/xattr.c                                   |  6 +++---
 fs/btrfs/xattr.h                                   |  4 ++--
 fs/ceph/super.h                                    |  2 +-
 fs/ceph/xattr.c                                    |  8 ++++----
 fs/cifs/cifsfs.h                                   |  2 +-
 fs/cifs/xattr.c                                    |  6 +++---
 fs/ecryptfs/crypto.c                               |  5 ++++-
 fs/ecryptfs/ecryptfs_kernel.h                      |  4 ++--
 fs/ecryptfs/inode.c                                | 23 +++++++++++-----------
 fs/ecryptfs/mmap.c                                 |  3 ++-
 fs/fuse/dir.c                                      |  5 ++---
 fs/gfs2/inode.c                                    |  9 ++++-----
 fs/hfs/attr.c                                      |  5 ++---
 fs/hfs/hfs_fs.h                                    |  4 ++--
 fs/jfs/jfs_xattr.h                                 |  2 +-
 fs/jfs/xattr.c                                     |  8 ++++----
 fs/kernfs/inode.c                                  |  6 +++---
 fs/kernfs/kernfs-internal.h                        |  4 ++--
 fs/libfs.c                                         |  4 ++--
 fs/overlayfs/inode.c                               |  4 ++--
 fs/overlayfs/overlayfs.h                           |  4 ++--
 fs/overlayfs/super.c                               |  7 +++++--
 fs/ubifs/ubifs.h                                   |  4 ++--
 fs/ubifs/xattr.c                                   |  6 +++---
 fs/xattr.c                                         | 12 +++++------
 include/linux/fs.h                                 |  3 ++-
 include/linux/xattr.h                              |  2 +-
 mm/shmem.c                                         |  2 +-
 net/socket.c                                       |  2 +-
 security/commoncap.c                               |  6 +++---
 security/integrity/evm/evm_main.c                  |  2 +-
 security/selinux/hooks.c                           |  9 +++++----
 security/smack/smack_lsm.c                         |  4 ++--
 37 files changed, 104 insertions(+), 93 deletions(-)

diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting
index f24d1b833957..d5f6834ed51a 100644
--- a/Documentation/filesystems/porting
+++ b/Documentation/filesystems/porting
@@ -504,3 +504,9 @@ in your dentry operations instead.
 [mandatory]
  __fd_install() & fd_install() can now sleep. Callers should not
  hold a spinlock or other resources that do not allow a schedule.
+--
+[mandatory]
+ ->getxattr() and xattr_handler.get() get dentry and inode passed separately.
+ dentry might be yet to be attached to inode, so do _not_ use its ->d_inode
+ in the instances.  Rationale: !@#!@# security_d_instantiate() needs to be
+ called before we attach dentry to inode.
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h
index c2d9b793759d..c350b01feab7 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -1032,8 +1032,8 @@ static inline __u64 ll_file_maxbytes(struct inode *inode)
 /* llite/xattr.c */
 int ll_setxattr(struct dentry *dentry, const char *name,
  const void *value, size_t size, int flags);
-ssize_t ll_getxattr(struct dentry *dentry, const char *name,
-    void *buffer, size_t size);
+ssize_t ll_getxattr(struct dentry *dentry, struct inode *inode,
+    const char *name, void *buffer, size_t size);
 ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size);
 int ll_removexattr(struct dentry *dentry, const char *name);
 
diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c
index 4b7eb33f7d01..8102740d39e4 100644
--- a/drivers/staging/lustre/lustre/llite/xattr.c
+++ b/drivers/staging/lustre/lustre/llite/xattr.c
@@ -449,11 +449,9 @@ out:
  return rc;
 }
 
-ssize_t ll_getxattr(struct dentry *dentry, const char *name,
-    void *buffer, size_t size)
+ssize_t ll_getxattr(struct dentry *dentry, struct inode *inode,
+    const char *name, void *buffer, size_t size)
 {
- struct inode *inode = d_inode(dentry);
-
  LASSERT(inode);
  LASSERT(name);
 
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 861b1e1c4777..86df8d475d1f 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -106,8 +106,8 @@ static int bad_inode_setxattr(struct dentry *dentry, const char *name,
  return -EIO;
 }
 
-static ssize_t bad_inode_getxattr(struct dentry *dentry, const char *name,
- void *buffer, size_t size)
+static ssize_t bad_inode_getxattr(struct dentry *dentry, struct inode *inode,
+ const char *name, void *buffer, size_t size)
 {
  return -EIO;
 }
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
index e25508ffa2ee..e0a7f8b81dd2 100644
--- a/fs/btrfs/xattr.c
+++ b/fs/btrfs/xattr.c
@@ -397,8 +397,8 @@ static int btrfs_is_valid_xattr(const char *name)
  return 0;
 }
 
-ssize_t btrfs_getxattr(struct dentry *dentry, const char *name,
-       void *buffer, size_t size)
+ssize_t btrfs_getxattr(struct dentry *dentry, struct inode *inode,
+      const char *name, void *buffer, size_t size)
 {
  int ret;
 
@@ -408,7 +408,7 @@ ssize_t btrfs_getxattr(struct dentry *dentry, const char *name,
  * for it via sb->s_xattr.
  */
  if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
- return generic_getxattr(dentry, name, buffer, size);
+ return generic_getxattr(dentry, inode, name, buffer, size);
 
  ret = btrfs_is_valid_xattr(name);
  if (ret)
diff --git a/fs/btrfs/xattr.h b/fs/btrfs/xattr.h
index 5049608d1388..8cb374859e51 100644
--- a/fs/btrfs/xattr.h
+++ b/fs/btrfs/xattr.h
@@ -28,8 +28,8 @@ extern ssize_t __btrfs_getxattr(struct inode *inode, const char *name,
 extern int __btrfs_setxattr(struct btrfs_trans_handle *trans,
     struct inode *inode, const char *name,
     const void *value, size_t size, int flags);
-extern ssize_t btrfs_getxattr(struct dentry *dentry, const char *name,
- void *buffer, size_t size);
+extern ssize_t btrfs_getxattr(struct dentry *dentry, struct inode *inode,
+      const char *name, void *buffer, size_t size);
 extern int btrfs_setxattr(struct dentry *dentry, const char *name,
  const void *value, size_t size, int flags);
 extern int btrfs_removexattr(struct dentry *dentry, const char *name);
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 8c8cb8fe3d32..2793ae2c0ff6 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -799,7 +799,7 @@ extern int ceph_setxattr(struct dentry *, const char *, const void *,
 int __ceph_setxattr(struct dentry *, const char *, const void *, size_t, int);
 ssize_t __ceph_getxattr(struct inode *, const char *, void *, size_t);
 int __ceph_removexattr(struct dentry *, const char *);
-extern ssize_t ceph_getxattr(struct dentry *, const char *, void *, size_t);
+extern ssize_t ceph_getxattr(struct dentry *, struct inode *, const char *, void *, size_t);
 extern ssize_t ceph_listxattr(struct dentry *, char *, size_t);
 extern int ceph_removexattr(struct dentry *, const char *);
 extern void __ceph_build_xattrs_blob(struct ceph_inode_info *ci);
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index b24275ef97f7..4e4d0b7df85a 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -773,13 +773,13 @@ out:
  return err;
 }
 
-ssize_t ceph_getxattr(struct dentry *dentry, const char *name, void *value,
-      size_t size)
+ssize_t ceph_getxattr(struct dentry *dentry, struct inode *inode,
+      const char *name, void *value, size_t size)
 {
  if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
- return generic_getxattr(dentry, name, value, size);
+ return generic_getxattr(dentry, inode, name, value, size);
 
- return __ceph_getxattr(d_inode(dentry), name, value, size);
+ return __ceph_getxattr(inode, name, value, size);
 }
 
 ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size)
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index 44b3d4280abb..39c380cd0b90 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -124,7 +124,7 @@ extern int cifs_symlink(struct inode *inode, struct dentry *direntry,
 extern int cifs_removexattr(struct dentry *, const char *);
 extern int cifs_setxattr(struct dentry *, const char *, const void *,
  size_t, int);
-extern ssize_t cifs_getxattr(struct dentry *, const char *, void *, size_t);
+extern ssize_t cifs_getxattr(struct dentry *, struct inode *, const char *, void *, size_t);
 extern ssize_t cifs_listxattr(struct dentry *, char *, size_t);
 extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
 
diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c
index ff9e1f8b16a4..0de08cd2e561 100644
--- a/fs/cifs/xattr.c
+++ b/fs/cifs/xattr.c
@@ -232,8 +232,8 @@ set_ea_exit:
  return rc;
 }
 
-ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,
- void *ea_value, size_t buf_size)
+ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode,
+ const char *ea_name, void *ea_value, size_t buf_size)
 {
  ssize_t rc = -EOPNOTSUPP;
 #ifdef CONFIG_CIFS_XATTR
@@ -324,7 +324,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,
  goto get_ea_exit; /* rc already EOPNOTSUPP */
 
  pacl = pTcon->ses->server->ops->get_acl(cifs_sb,
- d_inode(direntry), full_path, &acllen);
+ inode, full_path, &acllen);
  if (IS_ERR(pacl)) {
  rc = PTR_ERR(pacl);
  cifs_dbg(VFS, "%s: error %zd getting sec desc\n",
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 80d6901493cf..81701fdedbeb 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -1376,7 +1376,9 @@ int ecryptfs_read_xattr_region(char *page_virt, struct inode *ecryptfs_inode)
  ssize_t size;
  int rc = 0;
 
- size = ecryptfs_getxattr_lower(lower_dentry, ECRYPTFS_XATTR_NAME,
+ size = ecryptfs_getxattr_lower(lower_dentry,
+       ecryptfs_inode_to_lower(ecryptfs_inode),
+       ECRYPTFS_XATTR_NAME,
        page_virt, ECRYPTFS_DEFAULT_EXTENT_SIZE);
  if (size < 0) {
  if (unlikely(ecryptfs_verbosity > 0))
@@ -1398,6 +1400,7 @@ int ecryptfs_read_and_validate_xattr_region(struct dentry *dentry,
  int rc;
 
  rc = ecryptfs_getxattr_lower(ecryptfs_dentry_to_lower(dentry),
+     ecryptfs_inode_to_lower(inode),
      ECRYPTFS_XATTR_NAME, file_size,
      ECRYPTFS_SIZE_AND_MARKER_BYTES);
  if (rc < ECRYPTFS_SIZE_AND_MARKER_BYTES)
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index eae9cdb8af46..7d2e3933ec92 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -618,8 +618,8 @@ ecryptfs_parse_packet_set(struct ecryptfs_crypt_stat *crypt_stat,
   unsigned char *src, struct dentry *ecryptfs_dentry);
 int ecryptfs_truncate(struct dentry *dentry, loff_t new_length);
 ssize_t
-ecryptfs_getxattr_lower(struct dentry *lower_dentry, const char *name,
- void *value, size_t size);
+ecryptfs_getxattr_lower(struct dentry *lower_dentry, struct inode *lower_inode,
+ const char *name, void *value, size_t size);
 int
 ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value,
   size_t size, int flags);
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index f630bcab92e7..68333c331087 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -1033,29 +1033,30 @@ out:
 }
 
 ssize_t
-ecryptfs_getxattr_lower(struct dentry *lower_dentry, const char *name,
- void *value, size_t size)
+ecryptfs_getxattr_lower(struct dentry *lower_dentry, struct inode *lower_inode,
+ const char *name, void *value, size_t size)
 {
  int rc = 0;
 
- if (!d_inode(lower_dentry)->i_op->getxattr) {
+ if (!lower_inode->i_op->getxattr) {
  rc = -EOPNOTSUPP;
  goto out;
  }
- inode_lock(d_inode(lower_dentry));
- rc = d_inode(lower_dentry)->i_op->getxattr(lower_dentry, name, value,
-   size);
- inode_unlock(d_inode(lower_dentry));
+ inode_lock(lower_inode);
+ rc = lower_inode->i_op->getxattr(lower_dentry, lower_inode,
+ name, value, size);
+ inode_unlock(lower_inode);
 out:
  return rc;
 }
 
 static ssize_t
-ecryptfs_getxattr(struct dentry *dentry, const char *name, void *value,
-  size_t size)
+ecryptfs_getxattr(struct dentry *dentry, struct inode *inode,
+  const char *name, void *value, size_t size)
 {
- return ecryptfs_getxattr_lower(ecryptfs_dentry_to_lower(dentry), name,
-       value, size);
+ return ecryptfs_getxattr_lower(ecryptfs_dentry_to_lower(dentry),
+       ecryptfs_inode_to_lower(inode),
+       name, value, size);
 }
 
 static ssize_t
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index c6ced4cbf0cf..950fb2102a82 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -437,7 +437,8 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode)
  goto out;
  }
  inode_lock(lower_inode);
- size = lower_inode->i_op->getxattr(lower_dentry, ECRYPTFS_XATTR_NAME,
+ size = lower_inode->i_op->getxattr(lower_dentry, lower_inode,
+   ECRYPTFS_XATTR_NAME,
    xattr_virt, PAGE_CACHE_SIZE);
  if (size < 0)
  size = 8;
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index aa6d459e8c30..bf76591c3dd7 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1804,10 +1804,9 @@ out:
  return err;
 }
 
-static ssize_t fuse_getxattr(struct dentry *entry, const char *name,
-     void *value, size_t size)
+static ssize_t fuse_getxattr(struct dentry *entry, struct inode *inode,
+     const char *name, void *value, size_t size)
 {
- struct inode *inode = d_inode(entry);
  struct fuse_conn *fc = get_fuse_conn(inode);
  FUSE_ARGS(args);
  struct fuse_getxattr_in inarg;
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 970dd21055e3..0f73d32cc9ea 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -2011,22 +2011,21 @@ static int gfs2_setxattr(struct dentry *dentry, const char *name,
  return ret;
 }
 
-static ssize_t gfs2_getxattr(struct dentry *dentry, const char *name,
-     void *data, size_t size)
+static ssize_t gfs2_getxattr(struct dentry *dentry, struct inode *inode,
+     const char *name, void *data, size_t size)
 {
- struct inode *inode = d_inode(dentry);
  struct gfs2_inode *ip = GFS2_I(inode);
  struct gfs2_holder gh;
  int ret;
 
  /* For selinux during lookup */
  if (gfs2_glock_is_locked_by_me(ip->i_gl))
- return generic_getxattr(dentry, name, data, size);
+ return generic_getxattr(dentry, inode, name, data, size);
 
  gfs2_holder_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh);
  ret = gfs2_glock_nq(&gh);
  if (ret == 0) {
- ret = generic_getxattr(dentry, name, data, size);
+ ret = generic_getxattr(dentry, inode, name, data, size);
  gfs2_glock_dq(&gh);
  }
  gfs2_holder_uninit(&gh);
diff --git a/fs/hfs/attr.c b/fs/hfs/attr.c
index 8d931b157bbe..064f92f17efc 100644
--- a/fs/hfs/attr.c
+++ b/fs/hfs/attr.c
@@ -56,10 +56,9 @@ out:
  return res;
 }
 
-ssize_t hfs_getxattr(struct dentry *dentry, const char *name,
- void *value, size_t size)
+ssize_t hfs_getxattr(struct dentry *unused, struct inode *inode,
+     const char *name, void *value, size_t size)
 {
- struct inode *inode = d_inode(dentry);
  struct hfs_find_data fd;
  hfs_cat_rec rec;
  struct hfs_cat_file *file;
diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
index 1f1c7dcbcc2f..79daa097929a 100644
--- a/fs/hfs/hfs_fs.h
+++ b/fs/hfs/hfs_fs.h
@@ -213,8 +213,8 @@ extern void hfs_delete_inode(struct inode *);
 /* attr.c */
 extern int hfs_setxattr(struct dentry *dentry, const char *name,
  const void *value, size_t size, int flags);
-extern ssize_t hfs_getxattr(struct dentry *dentry, const char *name,
-    void *value, size_t size);
+extern ssize_t hfs_getxattr(struct dentry *dentry, struct inode *inode,
+    const char *name, void *value, size_t size);
 extern ssize_t hfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
 
 /* mdb.c */
diff --git a/fs/jfs/jfs_xattr.h b/fs/jfs/jfs_xattr.h
index e8d717dabca3..e69e14f3777b 100644
--- a/fs/jfs/jfs_xattr.h
+++ b/fs/jfs/jfs_xattr.h
@@ -57,7 +57,7 @@ extern int __jfs_setxattr(tid_t, struct inode *, const char *, const void *,
 extern int jfs_setxattr(struct dentry *, const char *, const void *, size_t,
  int);
 extern ssize_t __jfs_getxattr(struct inode *, const char *, void *, size_t);
-extern ssize_t jfs_getxattr(struct dentry *, const char *, void *, size_t);
+extern ssize_t jfs_getxattr(struct dentry *, struct inode *, const char *, void *, size_t);
 extern ssize_t jfs_listxattr(struct dentry *, char *, size_t);
 extern int jfs_removexattr(struct dentry *, const char *);
 
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c
index 48b15a6e5558..5becc6a3ff8c 100644
--- a/fs/jfs/xattr.c
+++ b/fs/jfs/xattr.c
@@ -933,8 +933,8 @@ ssize_t __jfs_getxattr(struct inode *inode, const char *name, void *data,
  return size;
 }
 
-ssize_t jfs_getxattr(struct dentry *dentry, const char *name, void *data,
-     size_t buf_size)
+ssize_t jfs_getxattr(struct dentry *dentry, struct inode *inode,
+     const char *name, void *data, size_t buf_size)
 {
  int err;
 
@@ -944,7 +944,7 @@ ssize_t jfs_getxattr(struct dentry *dentry, const char *name, void *data,
  * for it via sb->s_xattr.
  */
  if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
- return generic_getxattr(dentry, name, data, buf_size);
+ return generic_getxattr(dentry, inode, name, data, buf_size);
 
  if (strncmp(name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) == 0) {
  /*
@@ -959,7 +959,7 @@ ssize_t jfs_getxattr(struct dentry *dentry, const char *name, void *data,
  return -EOPNOTSUPP;
  }
 
- err = __jfs_getxattr(d_inode(dentry), name, data, buf_size);
+ err = __jfs_getxattr(inode, name, data, buf_size);
 
  return err;
 }
diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
index 756dd56aaf60..4c643c128c22 100644
--- a/fs/kernfs/inode.c
+++ b/fs/kernfs/inode.c
@@ -208,10 +208,10 @@ int kernfs_iop_removexattr(struct dentry *dentry, const char *name)
  return simple_xattr_remove(&attrs->xattrs, name);
 }
 
-ssize_t kernfs_iop_getxattr(struct dentry *dentry, const char *name, void *buf,
-    size_t size)
+ssize_t kernfs_iop_getxattr(struct dentry *unused, struct inode *inode,
+    const char *name, void *buf, size_t size)
 {
- struct kernfs_node *kn = dentry->d_fsdata;
+ struct kernfs_node *kn = inode->i_private;
  struct kernfs_iattrs *attrs;
 
  attrs = kernfs_iattrs(kn);
diff --git a/fs/kernfs/kernfs-internal.h b/fs/kernfs/kernfs-internal.h
index 6762bfbd8207..45c9192c276e 100644
--- a/fs/kernfs/kernfs-internal.h
+++ b/fs/kernfs/kernfs-internal.h
@@ -84,8 +84,8 @@ int kernfs_iop_getattr(struct vfsmount *mnt, struct dentry *dentry,
 int kernfs_iop_setxattr(struct dentry *dentry, const char *name, const void *value,
  size_t size, int flags);
 int kernfs_iop_removexattr(struct dentry *dentry, const char *name);
-ssize_t kernfs_iop_getxattr(struct dentry *dentry, const char *name, void *buf,
-    size_t size);
+ssize_t kernfs_iop_getxattr(struct dentry *dentry, struct inode *inode,
+    const char *name, void *buf, size_t size);
 ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size);
 
 /*
diff --git a/fs/libfs.c b/fs/libfs.c
index 72c09d8819d1..68e82827a4ae 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -1131,8 +1131,8 @@ static int empty_dir_setxattr(struct dentry *dentry, const char *name,
  return -EOPNOTSUPP;
 }
 
-static ssize_t empty_dir_getxattr(struct dentry *dentry, const char *name,
-  void *value, size_t size)
+static ssize_t empty_dir_getxattr(struct dentry *dentry, struct inode *inode,
+  const char *name, void *value, size_t size)
 {
  return -EOPNOTSUPP;
 }
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index be57d343d875..02effb046ccf 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -260,8 +260,8 @@ static bool ovl_need_xattr_filter(struct dentry *dentry,
  return false;
 }
 
-ssize_t ovl_getxattr(struct dentry *dentry, const char *name,
-     void *value, size_t size)
+ssize_t ovl_getxattr(struct dentry *dentry, struct inode *inode,
+     const char *name, void *value, size_t size)
 {
  struct path realpath;
  enum ovl_path_type type = ovl_path_real(dentry, &realpath);
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 9c83496b58f0..8ba2f2e882db 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -203,8 +203,8 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr);
 int ovl_permission(struct inode *inode, int mask);
 int ovl_setxattr(struct dentry *dentry, const char *name,
  const void *value, size_t size, int flags);
-ssize_t ovl_getxattr(struct dentry *dentry, const char *name,
-     void *value, size_t size);
+ssize_t ovl_getxattr(struct dentry *dentry, struct inode *inode,
+     const char *name, void *value, size_t size);
 ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size);
 int ovl_removexattr(struct dentry *dentry, const char *name);
 struct inode *ovl_d_select_inode(struct dentry *dentry, unsigned file_flags);
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 8716b764700f..ced01f5741a3 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -289,7 +289,10 @@ bool ovl_is_whiteout_v1(struct dentry *dentry)
  if (!dentry->d_inode->i_op->getxattr)
  return false;
 
- res = dentry->d_inode->i_op->getxattr(dentry, ovl_whiteout_xattr, &val, 1);
+ /* XXX is d_inode(dentry) correct here or should we receive the inode separately
+   all the other FSs?
+ */
+ res = dentry->d_inode->i_op->getxattr(dentry, d_inode(dentry), ovl_whiteout_xattr, &val, 1);
  if (res == 1 && val == 'y')
  return true;
 
@@ -323,7 +326,7 @@ static bool ovl_is_opaquedir(struct dentry *dentry)
  if (!S_ISDIR(inode->i_mode) || !inode->i_op->getxattr)
  return false;
 
- res = inode->i_op->getxattr(dentry, OVL_XATTR_OPAQUE, &val, 1);
+ res = inode->i_op->getxattr(dentry, inode, OVL_XATTR_OPAQUE, &val, 1);
  if (res == 1 && val == 'y')
  return true;
 
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index a5697de763f5..f2115158214f 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -1758,8 +1758,8 @@ int ubifs_getattr(struct vfsmount *mnt, struct dentry *dentry,
 /* xattr.c */
 int ubifs_setxattr(struct dentry *dentry, const char *name,
    const void *value, size_t size, int flags);
-ssize_t ubifs_getxattr(struct dentry *dentry, const char *name, void *buf,
-       size_t size);
+ssize_t ubifs_getxattr(struct dentry *dentry, struct inode *host,
+       const char *name, void *buf, size_t size);
 ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size);
 int ubifs_removexattr(struct dentry *dentry, const char *name);
 int ubifs_init_security(struct inode *dentry, struct inode *inode,
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index cabe709e5bd6..d7747aa33cd2 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -374,10 +374,10 @@ int ubifs_setxattr(struct dentry *dentry, const char *name,
  return setxattr(d_inode(dentry), name, value, size, flags);
 }
 
-ssize_t ubifs_getxattr(struct dentry *dentry, const char *name, void *buf,
-       size_t size)
+ssize_t ubifs_getxattr(struct dentry *dentry, struct inode *host,
+       const char *name, void *buf, size_t size)
 {
- struct inode *inode, *host = d_inode(dentry);
+ struct inode *inode;
  struct ubifs_info *c = host->i_sb->s_fs_info;
  struct qstr nm = QSTR_INIT(name, strlen(name));
  struct ubifs_inode *ui;
diff --git a/fs/xattr.c b/fs/xattr.c
index 630689a1e21c..ec9cd9bfd965 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -199,7 +199,7 @@ vfs_getxattr_alloc(struct dentry *dentry, const char *name, char **xattr_value,
  if (!inode->i_op->getxattr)
  return -EOPNOTSUPP;
 
- error = inode->i_op->getxattr(dentry, name, NULL, 0);
+ error = inode->i_op->getxattr(dentry, inode, name, NULL, 0);
  if (error < 0)
  return error;
 
@@ -210,7 +210,7 @@ vfs_getxattr_alloc(struct dentry *dentry, const char *name, char **xattr_value,
  memset(value, 0, error + 1);
  }
 
- error = inode->i_op->getxattr(dentry, name, value, error);
+ error = inode->i_op->getxattr(dentry, inode, name, value, error);
  *xattr_value = value;
  return error;
 }
@@ -263,7 +263,7 @@ vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
  }
 nolsm:
  if (inode->i_op->getxattr)
- error = inode->i_op->getxattr(dentry, name, value, size);
+ error = inode->i_op->getxattr(dentry, inode, name, value, size);
  else
  error = -EOPNOTSUPP;
 
@@ -721,15 +721,15 @@ xattr_resolve_name(const struct xattr_handler **handlers, const char **name)
  * Find the handler for the prefix and dispatch its get() operation.
  */
 ssize_t
-generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size)
+generic_getxattr(struct dentry *dentry, struct inode *inode,
+ const char *name, void *buffer, size_t size)
 {
  const struct xattr_handler *handler;
 
  handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
  if (!handler)
  return -EOPNOTSUPP;
- return handler->get(handler, dentry, d_inode(dentry),
-    name, buffer, size);
+ return handler->get(handler, dentry, inode, name, buffer, size);
 }
 
 /*
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 63213a3a953a..faef16cfcdc6 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1704,7 +1704,8 @@ struct inode_operations {
  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);
- ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
+ ssize_t (*getxattr) (struct dentry *, struct inode *,
+     const char *, void *, size_t);
  ssize_t (*listxattr) (struct dentry *, char *, size_t);
  int (*removexattr) (struct dentry *, const char *);
  int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
diff --git a/include/linux/xattr.h b/include/linux/xattr.h
index e79e7c95182c..7b23333c8d6c 100644
--- a/include/linux/xattr.h
+++ b/include/linux/xattr.h
@@ -48,7 +48,7 @@ int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, i
 int vfs_setxattr(struct dentry *, const char *, const void *, size_t, int);
 int vfs_removexattr(struct dentry *, const char *);
 
-ssize_t generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size);
+ssize_t generic_getxattr(struct dentry *dentry, struct inode *inode, const char *name, void *buffer, size_t size);
 ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size);
 int generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags);
 int generic_removexattr(struct dentry *dentry, const char *name);
diff --git a/mm/shmem.c b/mm/shmem.c
index 9e949c4cdf30..56a2aa045bb5 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2623,7 +2623,7 @@ static ssize_t shmem_getxattr(struct dentry *dentry, const char *name,
  * for it via sb->s_xattr.
  */
  if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
- return generic_getxattr(dentry, name, buffer, size);
+ return generic_getxattr(dentry, d_inode(dentry), name, buffer, size);
 
  err = shmem_xattr_validate(name);
  if (err)
diff --git a/net/socket.c b/net/socket.c
index 3cdfd05204fc..300344eee0c0 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -466,7 +466,7 @@ static struct socket *sockfd_lookup_light(int fd, int *err, int *fput_needed)
 #define XATTR_SOCKPROTONAME_SUFFIX "sockprotoname"
 #define XATTR_NAME_SOCKPROTONAME (XATTR_SYSTEM_PREFIX XATTR_SOCKPROTONAME_SUFFIX)
 #define XATTR_NAME_SOCKPROTONAME_LEN (sizeof(XATTR_NAME_SOCKPROTONAME)-1)
-static ssize_t sockfs_getxattr(struct dentry *dentry,
+static ssize_t sockfs_getxattr(struct dentry *dentry, struct inode *inode,
        const char *name, void *value, size_t size)
 {
  const char *proto_name;
diff --git a/security/commoncap.c b/security/commoncap.c
index 9b3edba566b1..b0b479abe92f 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -313,7 +313,7 @@ int cap_inode_need_killpriv(struct dentry *dentry)
  if (!inode->i_op->getxattr)
        return 0;
 
- error = inode->i_op->getxattr(dentry, XATTR_NAME_CAPS, NULL, 0);
+ error = inode->i_op->getxattr(dentry, inode, XATTR_NAME_CAPS, NULL, 0);
  if (error <= 0)
  return 0;
  return 1;
@@ -397,8 +397,8 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
  if (!inode || !inode->i_op->getxattr)
  return -ENODATA;
 
- size = inode->i_op->getxattr((struct dentry *)dentry, XATTR_NAME_CAPS, &caps,
-   XATTR_CAPS_SZ);
+ size = inode->i_op->getxattr((struct dentry *)dentry, inode,
+     XATTR_NAME_CAPS, &caps, XATTR_CAPS_SZ);
  if (size == -ENODATA || size == -EOPNOTSUPP)
  /* no data, that's ok */
  return -ENODATA;
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index 20554d84952f..710fae52cc7f 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -82,7 +82,7 @@ static int evm_find_protected_xattrs(struct dentry *dentry)
  return -EOPNOTSUPP;
 
  for (xattr = evm_config_xattrnames; *xattr != NULL; xattr++) {
- error = inode->i_op->getxattr(dentry, *xattr, NULL, 0);
+ error = inode->i_op->getxattr(dentry, inode, *xattr, NULL, 0);
  if (error < 0) {
  if (error == -ENODATA)
  continue;
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 1ed8fefe3774..779e43e52b8a 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -442,7 +442,8 @@ static int sb_finish_set_opts(struct super_block *sb)
  rc = -EOPNOTSUPP;
  goto out;
  }
- rc = root_inode->i_op->getxattr(root, XATTR_NAME_SELINUX, NULL, 0);
+ rc = root_inode->i_op->getxattr(root, root_inode,
+ XATTR_NAME_SELINUX, NULL, 0);
  if (rc < 0 && rc != -ENODATA) {
  if (rc == -EOPNOTSUPP)
  printk(KERN_WARNING "SELinux: (dev %s, type "
@@ -1374,13 +1375,13 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
  goto out_unlock;
  }
  context[len] = '\0';
- rc = inode->i_op->getxattr(dentry, XATTR_NAME_SELINUX,
+ rc = inode->i_op->getxattr(dentry, inode, XATTR_NAME_SELINUX,
    context, len);
  if (rc == -ERANGE) {
  kfree(context);
 
  /* Need a larger buffer.  Query for the right size. */
- rc = inode->i_op->getxattr(dentry, XATTR_NAME_SELINUX,
+ rc = inode->i_op->getxattr(dentry, inode, XATTR_NAME_SELINUX,
    NULL, 0);
  if (rc < 0) {
  dput(dentry);
@@ -1394,7 +1395,7 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
  goto out_unlock;
  }
  context[len] = '\0';
- rc = inode->i_op->getxattr(dentry,
+ rc = inode->i_op->getxattr(dentry, inode,
    XATTR_NAME_SELINUX,
    context, len);
  }
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 4f859e9eb486..7ca54bd5e260 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -272,7 +272,7 @@ static struct smack_known *smk_fetch(const char *name, struct inode *ip,
  if (buffer == NULL)
  return ERR_PTR(-ENOMEM);
 
- rc = ip->i_op->getxattr(dp, name, buffer, SMK_LONGLABEL);
+ rc = ip->i_op->getxattr(dp, ip, name, buffer, SMK_LONGLABEL);
  if (rc < 0)
  skp = ERR_PTR(rc);
  else if (rc == 0)
@@ -3526,7 +3526,7 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode)
  TRANS_TRUE, TRANS_TRUE_SIZE,
  0);
  } else {
- rc = inode->i_op->getxattr(dp,
+ rc = inode->i_op->getxattr(dp, inode,
  XATTR_NAME_SMACKTRANSMUTE, trattr,
  TRANS_TRUE_SIZE);
  if (rc >= 0 && strncmp(trattr, TRANS_TRUE,
--
2.14.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[Xenial][PATCH 5/9] ceph: Get rid of d_find_alias in ceph_set_acl

Khalid Elmously
In reply to this post by Khalid Elmously
BugLink: http://bugs.launchpad.net/bugs/1415636

commit a26feccaba296bd0ae410eabce79cb3443c8a701 upstream.

Create a variant of ceph_setattr that takes an inode instead of a
dentry.  Change __ceph_setxattr (and also __ceph_removexattr) to take an
inode instead of a dentry.  Use those in ceph_set_acl so that we no
longer need a dentry there.

Signed-off-by: Andreas Gruenbacher <[hidden email]>
Signed-off-by: "Yan, Zheng" <[hidden email]>
Signed-off-by: Al Viro <[hidden email]>
Signed-off-by: Khalid Elmously <[hidden email]>
---
 fs/ceph/acl.c   | 14 +++++---------
 fs/ceph/inode.c | 12 +++++++-----
 fs/ceph/super.h |  5 ++---
 fs/ceph/xattr.c | 28 ++++++++++++----------------
 4 files changed, 26 insertions(+), 33 deletions(-)

diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c
index bdb9c94335f1..722c93f84ef4 100644
--- a/fs/ceph/acl.c
+++ b/fs/ceph/acl.c
@@ -88,7 +88,6 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)
  char *value = NULL;
  struct iattr newattrs;
  umode_t new_mode = inode->i_mode, old_mode = inode->i_mode;
- struct dentry *dentry;
 
  switch (type) {
  case ACL_TYPE_ACCESS:
@@ -124,29 +123,26 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)
  goto out_free;
  }
 
- dentry = d_find_alias(inode);
  if (new_mode != old_mode) {
  newattrs.ia_mode = new_mode;
  newattrs.ia_valid = ATTR_MODE;
- ret = __ceph_setattr(dentry, &newattrs);
+ ret = __ceph_setattr(inode, &newattrs);
  if (ret)
- goto out_dput;
+ goto out_free;
  }
 
- ret = __ceph_setxattr(dentry, name, value, size, 0);
+ ret = __ceph_setxattr(inode, name, value, size, 0);
  if (ret) {
  if (new_mode != old_mode) {
  newattrs.ia_mode = old_mode;
  newattrs.ia_valid = ATTR_MODE;
- __ceph_setattr(dentry, &newattrs);
+ __ceph_setattr(inode, &newattrs);
  }
- goto out_dput;
+ goto out_free;
  }
 
  ceph_set_cached_acl(inode, type, acl);
 
-out_dput:
- dput(dentry);
 out_free:
  kfree(value);
 out:
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 9f0d99094cc1..5db076410d23 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1773,13 +1773,12 @@ static const struct inode_operations ceph_symlink_iops = {
 /*
  * setattr
  */
-int __ceph_setattr(struct dentry *dentry, struct iattr *attr)
+int __ceph_setattr(struct inode *inode, struct iattr *attr)
 {
- struct inode *inode = d_inode(dentry);
  struct ceph_inode_info *ci = ceph_inode(inode);
  const unsigned int ia_valid = attr->ia_valid;
  struct ceph_mds_request *req;
- struct ceph_mds_client *mdsc = ceph_sb_to_client(dentry->d_sb)->mdsc;
+ struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
  struct ceph_cap_flush *prealloc_cf;
  int issued;
  int release = 0, dirtied = 0;
@@ -1998,16 +1997,19 @@ int __ceph_setattr(struct dentry *dentry, struct iattr *attr)
 
 int ceph_setattr(struct dentry *dentry, struct iattr *attr)
 {
+ struct inode *inode = d_inode(dentry);
+
  int err;
 
- err = __ceph_setattr(dentry, attr);
+ err = __ceph_setattr(inode, attr);
 
  if (err >= 0 && (attr->ia_valid & ATTR_MODE))
- err = posix_acl_chmod(d_inode(dentry), attr->ia_mode);
+ err = posix_acl_chmod(inode, attr->ia_mode);
 
  return err;
 }
 
+
 /*
  * Verify that we have a lease on the given mask.  If not,
  * do a getattr against an mds.
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 2793ae2c0ff6..209e16d43c33 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -788,7 +788,7 @@ static inline int ceph_do_getattr(struct inode *inode, int mask, bool force)
  return __ceph_do_getattr(inode, NULL, mask, force);
 }
 extern int ceph_permission(struct inode *inode, int mask);
-extern int __ceph_setattr(struct dentry *dentry, struct iattr *attr);
+extern int __ceph_setattr(struct inode *inode, struct iattr *attr);
 extern int ceph_setattr(struct dentry *dentry, struct iattr *attr);
 extern int ceph_getattr(struct vfsmount *mnt, struct dentry *dentry,
  struct kstat *stat);
@@ -796,9 +796,8 @@ extern int ceph_getattr(struct vfsmount *mnt, struct dentry *dentry,
 /* xattr.c */
 extern int ceph_setxattr(struct dentry *, const char *, const void *,
  size_t, int);
-int __ceph_setxattr(struct dentry *, const char *, const void *, size_t, int);
+int __ceph_setxattr(struct inode *, const char *, const void *, size_t, int);
 ssize_t __ceph_getxattr(struct inode *, const char *, void *, size_t);
-int __ceph_removexattr(struct dentry *, const char *);
 extern ssize_t ceph_getxattr(struct dentry *, struct inode *, const char *, void *, size_t);
 extern ssize_t ceph_listxattr(struct dentry *, char *, size_t);
 extern int ceph_removexattr(struct dentry *, const char *);
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 4e4d0b7df85a..0f122130f68c 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -846,11 +846,10 @@ out:
  return err;
 }
 
-static int ceph_sync_setxattr(struct dentry *dentry, const char *name,
+static int ceph_sync_setxattr(struct inode *inode, const char *name,
       const char *value, size_t size, int flags)
 {
- struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb);
- struct inode *inode = d_inode(dentry);
+ struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb);
  struct ceph_inode_info *ci = ceph_inode(inode);
  struct ceph_mds_request *req;
  struct ceph_mds_client *mdsc = fsc->mdsc;
@@ -908,13 +907,12 @@ out:
  return err;
 }
 
-int __ceph_setxattr(struct dentry *dentry, const char *name,
+int __ceph_setxattr(struct inode *inode, const char *name,
  const void *value, size_t size, int flags)
 {
- struct inode *inode = d_inode(dentry);
  struct ceph_vxattr *vxattr;
  struct ceph_inode_info *ci = ceph_inode(inode);
- struct ceph_mds_client *mdsc = ceph_sb_to_client(dentry->d_sb)->mdsc;
+ struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
  struct ceph_cap_flush *prealloc_cf = NULL;
  int issued;
  int err;
@@ -1018,7 +1016,7 @@ do_sync:
 do_sync_unlocked:
  if (lock_snap_rwsem)
  up_read(&mdsc->snap_rwsem);
- err = ceph_sync_setxattr(dentry, name, value, size, flags);
+ err = ceph_sync_setxattr(inode, name, value, size, flags);
 out:
  ceph_free_cap_flush(prealloc_cf);
  kfree(newname);
@@ -1039,14 +1037,13 @@ int ceph_setxattr(struct dentry *dentry, const char *name,
  if (size == 0)
  value = "";  /* empty EA, do not remove */
 
- return __ceph_setxattr(dentry, name, value, size, flags);
+ return __ceph_setxattr(d_inode(dentry), name, value, size, flags);
 }
 
-static int ceph_send_removexattr(struct dentry *dentry, const char *name)
+static int ceph_send_removexattr(struct inode *inode, const char *name)
 {
- struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb);
+ struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb);
  struct ceph_mds_client *mdsc = fsc->mdsc;
- struct inode *inode = d_inode(dentry);
  struct ceph_mds_request *req;
  int err;
 
@@ -1067,12 +1064,11 @@ static int ceph_send_removexattr(struct dentry *dentry, const char *name)
  return err;
 }
 
-int __ceph_removexattr(struct dentry *dentry, const char *name)
+static int __ceph_removexattr(struct inode *inode, const char *name)
 {
- struct inode *inode = d_inode(dentry);
  struct ceph_vxattr *vxattr;
  struct ceph_inode_info *ci = ceph_inode(inode);
- struct ceph_mds_client *mdsc = ceph_sb_to_client(dentry->d_sb)->mdsc;
+ struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
  struct ceph_cap_flush *prealloc_cf = NULL;
  int issued;
  int err;
@@ -1153,7 +1149,7 @@ do_sync_unlocked:
  if (lock_snap_rwsem)
  up_read(&mdsc->snap_rwsem);
  ceph_free_cap_flush(prealloc_cf);
- err = ceph_send_removexattr(dentry, name);
+ err = ceph_send_removexattr(inode, name);
  return err;
 }
 
@@ -1165,5 +1161,5 @@ int ceph_removexattr(struct dentry *dentry, const char *name)
  if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
  return generic_removexattr(dentry, name);
 
- return __ceph_removexattr(dentry, name);
+ return __ceph_removexattr(d_inode(dentry), name);
 }
--
2.14.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[Xenial][PATCH 6/9] ceph: Propagate dentry down to inode_change_ok()

Khalid Elmously
In reply to this post by Khalid Elmously
BugLink: http://bugs.launchpad.net/bugs/1415636

commit fd5472ed44683cf593322a2ef54b9a7675dc780a upstream.

To avoid clearing of capabilities or security related extended
attributes too early, inode_change_ok() will need to take dentry instead
of inode. ceph_setattr() has the dentry easily available but
__ceph_setattr() is also called from ceph_set_acl() where dentry is not
easily available. Luckily that call path does not need inode_change_ok()
to be called anyway. So reorganize functions a bit so that
inode_change_ok() is called only from paths where dentry is available.

Reviewed-by: Christoph Hellwig <[hidden email]>
Acked-by: Jeff Layton <[hidden email]>
Signed-off-by: Jan Kara <[hidden email]>
Signed-off-by: Khalid Elmously <[hidden email]>
---
 fs/ceph/acl.c   |  5 +++++
 fs/ceph/inode.c | 15 +++++++--------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c
index 722c93f84ef4..b2f248fa2724 100644
--- a/fs/ceph/acl.c
+++ b/fs/ceph/acl.c
@@ -123,6 +123,11 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)
  goto out_free;
  }
 
+ if (ceph_snap(inode) != CEPH_NOSNAP) {
+ ret = -EROFS;
+ goto out_free;
+ }
+
  if (new_mode != old_mode) {
  newattrs.ia_mode = new_mode;
  newattrs.ia_valid = ATTR_MODE;
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 5db076410d23..4e544cf34cc1 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1787,13 +1787,6 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr)
  int inode_dirty_flags = 0;
  bool lock_snap_rwsem = false;
 
- if (ceph_snap(inode) != CEPH_NOSNAP)
- return -EROFS;
-
- err = inode_change_ok(inode, attr);
- if (err != 0)
- return err;
-
  prealloc_cf = ceph_alloc_cap_flush();
  if (!prealloc_cf)
  return -ENOMEM;
@@ -1998,9 +1991,15 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr)
 int ceph_setattr(struct dentry *dentry, struct iattr *attr)
 {
  struct inode *inode = d_inode(dentry);
-
  int err;
 
+ if (ceph_snap(inode) != CEPH_NOSNAP)
+ return -EROFS;
+
+ err = inode_change_ok(inode, attr);
+ if (err != 0)
+ return err;
+
  err = __ceph_setattr(inode, attr);
 
  if (err >= 0 && (attr->ia_valid & ATTR_MODE))
--
2.14.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[Xenial][PATCH 7/9] fuse: Propagate dentry down to inode_change_ok()

Khalid Elmously
In reply to this post by Khalid Elmously
BugLink: http://bugs.launchpad.net/bugs/1415636

commit 62490330769c1ce5dcba3f1f3e8f4005e9b797e6 upstream.

To avoid clearing of capabilities or security related extended
attributes too early, inode_change_ok() will need to take dentry instead
of inode. Propagate it down to fuse_do_setattr().

Acked-by: Miklos Szeredi <[hidden email]>
Reviewed-by: Christoph Hellwig <[hidden email]>
Signed-off-by: Jan Kara <[hidden email]>
Signed-off-by: Khalid Elmously <[hidden email]>
---
 fs/fuse/dir.c    | 5 +++--
 fs/fuse/file.c   | 2 +-
 fs/fuse/fuse_i.h | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index bf76591c3dd7..43a74c1f83dc 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1589,9 +1589,10 @@ int fuse_flush_times(struct inode *inode, struct fuse_file *ff)
  * vmtruncate() doesn't allow for this case, so do the rlimit checking
  * and the actual truncation by hand.
  */
-int fuse_do_setattr(struct inode *inode, struct iattr *attr,
+int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
     struct file *file)
 {
+ struct inode *inode = d_inode(dentry);
  struct fuse_conn *fc = get_fuse_conn(inode);
  struct fuse_inode *fi = get_fuse_inode(inode);
  FUSE_ARGS(args);
@@ -1733,7 +1734,7 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr)
  if (!attr->ia_valid)
  return 0;
 
- ret = fuse_do_setattr(inode, attr, file);
+ ret = fuse_do_setattr(entry, attr, file);
  if (!ret) {
  /* Directory mode changed, may need to revalidate access */
  if (d_is_dir(entry) && (attr->ia_valid & ATTR_MODE))
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index b00bc25d7c90..9fbf4a86147c 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -2816,7 +2816,7 @@ static void fuse_do_truncate(struct file *file)
  attr.ia_file = file;
  attr.ia_valid |= ATTR_FILE;
 
- fuse_do_setattr(inode, &attr, file);
+ fuse_do_setattr(file_dentry(file), &attr, file);
 }
 
 static inline loff_t fuse_round_up(loff_t off)
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index d761934f7ec1..b8d3d35e1afe 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -956,7 +956,7 @@ bool fuse_write_update_size(struct inode *inode, loff_t pos);
 int fuse_flush_times(struct inode *inode, struct fuse_file *ff);
 int fuse_write_inode(struct inode *inode, struct writeback_control *wbc);
 
-int fuse_do_setattr(struct inode *inode, struct iattr *attr,
+int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
     struct file *file);
 
 void fuse_set_initialized(struct fuse_conn *fc);
--
2.14.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[Xenial][PATCH 8/9] fs: Give dentry to inode_change_ok() instead of inode

Khalid Elmously
In reply to this post by Khalid Elmously
BugLink: http://bugs.launchpad.net/bugs/1415636

commit 31051c85b5e2aaaf6315f74c72a732673632a905 upstream.

inode_change_ok() will be resposible for clearing capabilities and IMA
extended attributes and as such will need dentry. Give it as an argument
to inode_change_ok() instead of an inode. Also rename inode_change_ok()
to setattr_prepare() to better relect that it does also some
modifications in addition to checks.

Reviewed-by: Christoph Hellwig <[hidden email]>
Signed-off-by: Jan Kara <[hidden email]>
Signed-off-by: Khalid Elmously <[hidden email]>
---
 Documentation/filesystems/porting               |  4 ++--
 drivers/staging/lustre/lustre/llite/llite_lib.c |  2 +-
 fs/9p/vfs_inode.c                               |  2 +-
 fs/9p/vfs_inode_dotl.c                          |  2 +-
 fs/adfs/inode.c                                 |  2 +-
 fs/affs/inode.c                                 |  2 +-
 fs/attr.c                                       | 15 +++++++++------
 fs/btrfs/inode.c                                |  2 +-
 fs/ceph/inode.c                                 |  2 +-
 fs/cifs/inode.c                                 |  4 ++--
 fs/ecryptfs/inode.c                             |  2 +-
 fs/exofs/inode.c                                |  2 +-
 fs/ext2/inode.c                                 |  2 +-
 fs/ext4/inode.c                                 |  2 +-
 fs/f2fs/file.c                                  |  2 +-
 fs/fat/file.c                                   |  2 +-
 fs/fuse/dir.c                                   |  2 +-
 fs/gfs2/inode.c                                 |  2 +-
 fs/hfs/inode.c                                  |  2 +-
 fs/hfsplus/inode.c                              |  2 +-
 fs/hostfs/hostfs_kern.c                         |  2 +-
 fs/hpfs/inode.c                                 |  2 +-
 fs/hugetlbfs/inode.c                            |  2 +-
 fs/jffs2/fs.c                                   |  2 +-
 fs/jfs/file.c                                   |  2 +-
 fs/kernfs/inode.c                               |  2 +-
 fs/libfs.c                                      |  2 +-
 fs/logfs/file.c                                 |  2 +-
 fs/minix/file.c                                 |  2 +-
 fs/ncpfs/inode.c                                |  2 +-
 fs/nfsd/nfsproc.c                               |  8 +++-----
 fs/nilfs2/inode.c                               |  2 +-
 fs/ntfs/inode.c                                 |  2 +-
 fs/ocfs2/dlmfs/dlmfs.c                          |  2 +-
 fs/ocfs2/file.c                                 |  2 +-
 fs/omfs/file.c                                  |  2 +-
 fs/overlayfs/inode.c                            |  2 +-
 fs/posix_acl.c                                  |  2 +-
 fs/proc/base.c                                  |  2 +-
 fs/proc/generic.c                               |  2 +-
 fs/proc/proc_sysctl.c                           |  2 +-
 fs/ramfs/file-nommu.c                           |  2 +-
 fs/reiserfs/inode.c                             |  2 +-
 fs/sysv/file.c                                  |  2 +-
 fs/ubifs/file.c                                 |  2 +-
 fs/udf/file.c                                   |  2 +-
 fs/ufs/inode.c                                  |  2 +-
 fs/utimes.c                                     |  2 +-
 fs/xfs/xfs_iops.c                               | 10 ++++------
 include/linux/fs.h                              |  2 +-
 mm/shmem.c                                      |  2 +-
 zfs/module/zfs/zpl_inode.c                      |  2 +-
 52 files changed, 67 insertions(+), 68 deletions(-)

diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting
index d5f6834ed51a..0e85a23e1ef0 100644
--- a/Documentation/filesystems/porting
+++ b/Documentation/filesystems/porting
@@ -287,8 +287,8 @@ implementing on-disk size changes.  Start with a copy of the old inode_setattr
 and vmtruncate, and the reorder the vmtruncate + foofs_vmtruncate sequence to
 be in order of zeroing blocks using block_truncate_page or similar helpers,
 size update and on finally on-disk truncation which should not fail.
-inode_change_ok now includes the size checks for ATTR_SIZE and must be called
-in the beginning of ->setattr unconditionally.
+setattr_prepare (which used to be inode_change_ok) now includes the size checks
+for ATTR_SIZE and must be called in the beginning of ->setattr unconditionally.
 
 [mandatory]
 
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index fc008e6dae74..7885347ebc4e 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -1233,7 +1233,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
  attr->ia_valid |= ATTR_MTIME | ATTR_CTIME;
  }
 
- /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */
+ /* POSIX: check before ATTR_*TIME_SET set (from setattr_prepare) */
  if (attr->ia_valid & TIMES_SET_FLAGS) {
  if ((!uid_eq(current_fsuid(), inode->i_uid)) &&
     !capable(CFS_CAP_FOWNER))
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 511078586fa1..ba3d9f08f30a 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -1094,7 +1094,7 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
  struct p9_wstat wstat;
 
  p9_debug(P9_DEBUG_VFS, "\n");
- retval = inode_change_ok(d_inode(dentry), iattr);
+ retval = setattr_prepare(dentry, iattr);
  if (retval)
  return retval;
 
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index cb899af1babc..914808cd9101 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -560,7 +560,7 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
 
  p9_debug(P9_DEBUG_VFS, "\n");
 
- retval = inode_change_ok(inode, iattr);
+ retval = setattr_prepare(dentry, iattr);
  if (retval)
  return retval;
 
diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c
index 335055d828e4..f57baaa511aa 100644
--- a/fs/adfs/inode.c
+++ b/fs/adfs/inode.c
@@ -303,7 +303,7 @@ adfs_notify_change(struct dentry *dentry, struct iattr *attr)
  unsigned int ia_valid = attr->ia_valid;
  int error;
 
- error = inode_change_ok(inode, attr);
+ error = setattr_prepare(dentry, attr);
 
  /*
  * we can't change the UID or GID of any file -
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 17349500592d..1d6f012926be 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -218,7 +218,7 @@ affs_notify_change(struct dentry *dentry, struct iattr *attr)
 
  pr_debug("notify_change(%lu,0x%x)\n", inode->i_ino, attr->ia_valid);
 
- error = inode_change_ok(inode,attr);
+ error = setattr_prepare(dentry, attr);
  if (error)
  goto out;
 
diff --git a/fs/attr.c b/fs/attr.c
index 7861340d8bd3..111d2a896ede 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -41,19 +41,22 @@ static bool chgrp_ok(const struct inode *inode, kgid_t gid)
 }
 
 /**
- * inode_change_ok - check if attribute changes to an inode are allowed
- * @inode: inode to check
+ * setattr_prepare - check if attribute changes to a dentry are allowed
+ * @dentry: dentry to check
  * @attr: attributes to change
  *
  * Check if we are allowed to change the attributes contained in @attr
- * in the given inode.  This includes the normal unix access permission
- * checks, as well as checks for rlimits and others.
+ * in the given dentry.  This includes the normal unix access permission
+ * checks, as well as checks for rlimits and others. The function also clears
+ * SGID bit from mode if user is not allowed to set it. Also file capabilities
+ * and IMA extended attributes are cleared if ATTR_KILL_PRIV is set.
  *
  * Should be called as the first thing in ->setattr implementations,
  * possibly after taking additional locks.
  */
-int inode_change_ok(const struct inode *inode, struct iattr *attr)
+int setattr_prepare(struct dentry *dentry, struct iattr *attr)
 {
+ struct inode *inode = d_inode(dentry);
  unsigned int ia_valid = attr->ia_valid;
 
  /*
@@ -97,7 +100,7 @@ int inode_change_ok(const struct inode *inode, struct iattr *attr)
 
  return 0;
 }
-EXPORT_SYMBOL(inode_change_ok);
+EXPORT_SYMBOL(setattr_prepare);
 
 /**
  * inode_newsize_ok - may this inode be truncated to a given size
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 5410f33fae28..cc1ed3e2775e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5028,7 +5028,7 @@ static int btrfs_setattr(struct dentry *dentry, struct iattr *attr)
  if (btrfs_root_readonly(root))
  return -EROFS;
 
- err = inode_change_ok(inode, attr);
+ err = setattr_prepare(dentry, attr);
  if (err)
  return err;
 
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 4e544cf34cc1..2a25735c94ca 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1996,7 +1996,7 @@ int ceph_setattr(struct dentry *dentry, struct iattr *attr)
  if (ceph_snap(inode) != CEPH_NOSNAP)
  return -EROFS;
 
- err = inode_change_ok(inode, attr);
+ err = setattr_prepare(dentry, attr);
  if (err != 0)
  return err;
 
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 9cdeb0293267..a228116f1c23 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -2134,7 +2134,7 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
  if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
  attrs->ia_valid |= ATTR_FORCE;
 
- rc = inode_change_ok(inode, attrs);
+ rc = setattr_prepare(direntry, attrs);
  if (rc < 0)
  goto out;
 
@@ -2274,7 +2274,7 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
  if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
  attrs->ia_valid |= ATTR_FORCE;
 
- rc = inode_change_ok(inode, attrs);
+ rc = setattr_prepare(direntry, attrs);
  if (rc < 0) {
  free_xid(xid);
  return rc;
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 68333c331087..278f90cceb19 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -939,7 +939,7 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)
  }
  mutex_unlock(&crypt_stat->cs_mutex);
 
- rc = inode_change_ok(inode, ia);
+ rc = setattr_prepare(dentry, ia);
  if (rc)
  goto out;
  if (ia->ia_valid & ATTR_SIZE) {
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
index 60f03b78914e..b1f619d6b937 100644
--- a/fs/exofs/inode.c
+++ b/fs/exofs/inode.c
@@ -1035,7 +1035,7 @@ int exofs_setattr(struct dentry *dentry, struct iattr *iattr)
  if (unlikely(error))
  return error;
 
- error = inode_change_ok(inode, iattr);
+ error = setattr_prepare(dentry, iattr);
  if (unlikely(error))
  return error;
 
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 0aa9bf6e6e53..f8270e40f9a0 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -1559,7 +1559,7 @@ int ext2_setattr(struct dentry *dentry, struct iattr *iattr)
  struct inode *inode = d_inode(dentry);
  int error;
 
- error = inode_change_ok(inode, iattr);
+ error = setattr_prepare(dentry, iattr);
  if (error)
  return error;
 
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 2690f53b046a..cd8dba26af31 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4847,7 +4847,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
  int orphan = 0;
  const unsigned int ia_valid = attr->ia_valid;
 
- error = inode_change_ok(inode, attr);
+ error = setattr_prepare(dentry, attr);
  if (error)
  return error;
 
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index be91de267337..b1f1debd798d 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -665,7 +665,7 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
  struct f2fs_inode_info *fi = F2FS_I(inode);
  int err;
 
- err = inode_change_ok(inode, attr);
+ err = setattr_prepare(dentry, attr);
  if (err)
  return err;
 
diff --git a/fs/fat/file.c b/fs/fat/file.c
index 6a8217512de0..71562e288b01 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -389,7 +389,7 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr)
  attr->ia_valid &= ~TIMES_SET_FLAGS;
  }
 
- error = inode_change_ok(inode, attr);
+ error = setattr_prepare(dentry, attr);
  attr->ia_valid = ia_valid;
  if (error) {
  if (sbi->options.quiet)
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 43a74c1f83dc..df63d1c6e5e3 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1607,7 +1607,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
  if (!(fc->flags & FUSE_DEFAULT_PERMISSIONS))
  attr->ia_valid |= ATTR_FORCE;
 
- err = inode_change_ok(inode, attr);
+ err = setattr_prepare(dentry, attr);
  if (err)
  return err;
 
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 0f73d32cc9ea..e804fe4088c4 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -1932,7 +1932,7 @@ static int gfs2_setattr(struct dentry *dentry, struct iattr *attr)
  if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
  goto out;
 
- error = inode_change_ok(inode, attr);
+ error = setattr_prepare(dentry, attr);
  if (error)
  goto out;
 
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 6686bf39a5b5..8ecb63d5db34 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -604,7 +604,7 @@ int hfs_inode_setattr(struct dentry *dentry, struct iattr * attr)
  struct hfs_sb_info *hsb = HFS_SB(inode->i_sb);
  int error;
 
- error = inode_change_ok(inode, attr); /* basic permission checks */
+ error = setattr_prepare(dentry, attr); /* basic permission checks */
  if (error)
  return error;
 
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index dcc7afb9a9a8..2e60d797ce9f 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -246,7 +246,7 @@ static int hfsplus_setattr(struct dentry *dentry, struct iattr *attr)
  struct inode *inode = d_inode(dentry);
  int error;
 
- error = inode_change_ok(inode, attr);
+ error = setattr_prepare(dentry, attr);
  if (error)
  return error;
 
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 6fbb47ca2656..c8dd92e52b49 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -812,7 +812,7 @@ static int hostfs_setattr(struct dentry *dentry, struct iattr *attr)
 
  int fd = HOSTFS_I(inode)->fd;
 
- err = inode_change_ok(inode, attr);
+ err = setattr_prepare(dentry, attr);
  if (err)
  return err;
 
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index 933c73780813..efbed9520fdc 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -272,7 +272,7 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
  if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size)
  goto out_unlock;
 
- error = inode_change_ok(inode, attr);
+ error = setattr_prepare(dentry, attr);
  if (error)
  goto out_unlock;
 
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 0e909b1176c0..2708cf508d4a 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -666,7 +666,7 @@ static int hugetlbfs_setattr(struct dentry *dentry, struct iattr *attr)
 
  BUG_ON(!inode);
 
- error = inode_change_ok(inode, attr);
+ error = setattr_prepare(dentry, attr);
  if (error)
  return error;
 
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 2caf1682036d..5a5b18dea08c 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -193,7 +193,7 @@ int jffs2_setattr(struct dentry *dentry, struct iattr *iattr)
  struct inode *inode = d_inode(dentry);
  int rc;
 
- rc = inode_change_ok(inode, iattr);
+ rc = setattr_prepare(dentry, iattr);
  if (rc)
  return rc;
 
diff --git a/fs/jfs/file.c b/fs/jfs/file.c
index 4ce7735dd042..b43c0a999fa2 100644
--- a/fs/jfs/file.c
+++ b/fs/jfs/file.c
@@ -103,7 +103,7 @@ int jfs_setattr(struct dentry *dentry, struct iattr *iattr)
  struct inode *inode = d_inode(dentry);
  int rc;
 
- rc = inode_change_ok(inode, iattr);
+ rc = setattr_prepare(dentry, iattr);
  if (rc)
  return rc;
 
diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
index 4c643c128c22..25beca314be3 100644
--- a/fs/kernfs/inode.c
+++ b/fs/kernfs/inode.c
@@ -119,7 +119,7 @@ int kernfs_iop_setattr(struct dentry *dentry, struct iattr *iattr)
  return -EINVAL;
 
  mutex_lock(&kernfs_mutex);
- error = inode_change_ok(inode, iattr);
+ error = setattr_prepare(dentry, iattr);
  if (error)
  goto out;
 
diff --git a/fs/libfs.c b/fs/libfs.c
index 68e82827a4ae..58a069bf7ca6 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -366,7 +366,7 @@ int simple_setattr(struct dentry *dentry, struct iattr *iattr)
  struct inode *inode = d_inode(dentry);
  int error;
 
- error = inode_change_ok(inode, iattr);
+ error = setattr_prepare(dentry, iattr);
  if (error)
  return error;
 
diff --git a/fs/logfs/file.c b/fs/logfs/file.c
index 61eaeb1b6cac..352fc0d80456 100644
--- a/fs/logfs/file.c
+++ b/fs/logfs/file.c
@@ -244,7 +244,7 @@ static int logfs_setattr(struct dentry *dentry, struct iattr *attr)
  struct inode *inode = d_inode(dentry);
  int err = 0;
 
- err = inode_change_ok(inode, attr);
+ err = setattr_prepare(dentry, attr);
  if (err)
  return err;
 
diff --git a/fs/minix/file.c b/fs/minix/file.c
index 94f0eb9a6e2c..a6a4797aa0d4 100644
--- a/fs/minix/file.c
+++ b/fs/minix/file.c
@@ -26,7 +26,7 @@ static int minix_setattr(struct dentry *dentry, struct iattr *attr)
  struct inode *inode = d_inode(dentry);
  int error;
 
- error = inode_change_ok(inode, attr);
+ error = setattr_prepare(dentry, attr);
  if (error)
  return error;
 
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 9605a2f63549..7b1261bc2dee 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -884,7 +884,7 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr)
  /* ageing the dentry to force validation */
  ncp_age_dentry(server, dentry);
 
- result = inode_change_ok(inode, attr);
+ result = setattr_prepare(dentry, attr);
  if (result < 0)
  goto out;
 
diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c
index 4cd78ef4c95c..44f6f4f5eee0 100644
--- a/fs/nfsd/nfsproc.c
+++ b/fs/nfsd/nfsproc.c
@@ -74,10 +74,10 @@ nfsd_proc_setattr(struct svc_rqst *rqstp, struct nfsd_sattrargs *argp,
  * which only requires access, and "set-[ac]time-to-X" which
  * requires ownership.
  * So if it looks like it might be "set both to the same time which
- * is close to now", and if inode_change_ok fails, then we
+ * is close to now", and if setattr_prepare fails, then we
  * convert to "set to now" instead of "set to explicit time"
  *
- * We only call inode_change_ok as the last test as technically
+ * We only call setattr_prepare as the last test as technically
  * it is not an interface that we should be using.
  */
 #define BOTH_TIME_SET (ATTR_ATIME_SET | ATTR_MTIME_SET)
@@ -92,17 +92,15 @@ nfsd_proc_setattr(struct svc_rqst *rqstp, struct nfsd_sattrargs *argp,
  * request is.  We require it be within 30 minutes of now.
  */
  time_t delta = iap->ia_atime.tv_sec - get_seconds();
- struct inode *inode;
 
  nfserr = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP);
  if (nfserr)
  goto done;
- inode = d_inode(fhp->fh_dentry);
 
  if (delta < 0)
  delta = -delta;
  if (delta < MAX_TOUCH_TIME_ERROR &&
-    inode_change_ok(inode, iap) != 0) {
+    setattr_prepare(fhp->fh_dentry, iap) != 0) {
  /*
  * Turn off ATTR_[AM]TIME_SET but leave ATTR_[AM]TIME.
  * This will cause notify_change to set these times
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 03328d1a25fa..ce49e6ac4b14 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -821,7 +821,7 @@ int nilfs_setattr(struct dentry *dentry, struct iattr *iattr)
  struct super_block *sb = inode->i_sb;
  int err;
 
- err = inode_change_ok(inode, iattr);
+ err = setattr_prepare(dentry, iattr);
  if (err)
  return err;
 
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index d284f07eda77..c178763893f3 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -2893,7 +2893,7 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr)
  int err;
  unsigned int ia_valid = attr->ia_valid;
 
- err = inode_change_ok(vi, attr);
+ err = setattr_prepare(dentry, attr);
  if (err)
  goto out;
  /* We do not support NTFS ACLs yet. */
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
index b5cf27dcb18a..43ac2289c613 100644
--- a/fs/ocfs2/dlmfs/dlmfs.c
+++ b/fs/ocfs2/dlmfs/dlmfs.c
@@ -211,7 +211,7 @@ static int dlmfs_file_setattr(struct dentry *dentry, struct iattr *attr)
  struct inode *inode = d_inode(dentry);
 
  attr->ia_valid &= ~ATTR_SIZE;
- error = inode_change_ok(inode, attr);
+ error = setattr_prepare(dentry, attr);
  if (error)
  return error;
 
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index c8d2c85de564..8001bbcb1e56 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1155,7 +1155,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
  if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
  return 0;
 
- status = inode_change_ok(inode, attr);
+ status = setattr_prepare(dentry, attr);
  if (status)
  return status;
 
diff --git a/fs/omfs/file.c b/fs/omfs/file.c
index d9e26cfbb793..bf83e6644333 100644
--- a/fs/omfs/file.c
+++ b/fs/omfs/file.c
@@ -349,7 +349,7 @@ static int omfs_setattr(struct dentry *dentry, struct iattr *attr)
  struct inode *inode = d_inode(dentry);
  int error;
 
- error = inode_change_ok(inode, attr);
+ error = setattr_prepare(dentry, attr);
  if (error)
  return error;
 
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 02effb046ccf..f505128b7945 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -51,7 +51,7 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
  * inode_newsize_ok() will always check against MAX_LFS_FILESIZE and not
  * check for a swapfile (which this won't be anyway).
  */
- err = inode_change_ok(dentry->d_inode, attr);
+ err = setattr_prepare(dentry, attr);
  if (err)
  return err;
 
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 9488b5758c6e..d7598df2620d 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -600,7 +600,7 @@ EXPORT_SYMBOL_GPL(posix_acl_create);
  * file mode, set *acl to NULL to indicate that no ACL should be set.
  *
  * As with chmod, clear the setgit bit if the caller is not in the owning group
- * or capable of CAP_FSETID (see inode_change_ok).
+ * or capable of CAP_FSETID (see setattr_prepare()).
  *
  * Called from set_acl inode operations.
  */
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 560449975df6..247d7d53f9df 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -719,7 +719,7 @@ int proc_setattr(struct dentry *dentry, struct iattr *attr)
     !kgid_has_mapping(s_user_ns, inode->i_gid))
  return -EPERM;
 
- error = inode_change_ok(inode, attr);
+ error = setattr_prepare(dentry, attr);
  if (error)
  return error;
 
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index fe14a3f16bf8..202ba4f05c53 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -112,7 +112,7 @@ static int proc_notify_change(struct dentry *dentry, struct iattr *iattr)
     !kgid_has_mapping(s_user_ns, inode->i_gid))
  return -EPERM;
 
- error = inode_change_ok(inode, iattr);
+ error = setattr_prepare(dentry, iattr);
  if (error)
  return error;
 
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index c52ee358c817..8944ab66fa93 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -761,7 +761,7 @@ static int proc_sys_setattr(struct dentry *dentry, struct iattr *attr)
     !kgid_has_mapping(s_user_ns, inode->i_gid))
  return -EPERM;
 
- error = inode_change_ok(inode, attr);
+ error = setattr_prepare(dentry, attr);
  if (error)
  return error;
 
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index a586467f6ff6..c33f9f90eae1 100644
--- a/fs/ramfs/file-nommu.c
+++ b/fs/ramfs/file-nommu.c
@@ -169,7 +169,7 @@ static int ramfs_nommu_setattr(struct dentry *dentry, struct iattr *ia)
  int ret = 0;
 
  /* POSIX UID/GID verification for setting inode attributes */
- ret = inode_change_ok(inode, ia);
+ ret = setattr_prepare(dentry, ia);
  if (ret)
  return ret;
 
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 60ba35087d12..5a0059a520da 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -3312,7 +3312,7 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
  unsigned int ia_valid;
  int error;
 
- error = inode_change_ok(inode, attr);
+ error = setattr_prepare(dentry, attr);
  if (error)
  return error;
 
diff --git a/fs/sysv/file.c b/fs/sysv/file.c
index 82ddc09061e2..7ba997e31aeb 100644
--- a/fs/sysv/file.c
+++ b/fs/sysv/file.c
@@ -33,7 +33,7 @@ static int sysv_setattr(struct dentry *dentry, struct iattr *attr)
  struct inode *inode = d_inode(dentry);
  int error;
 
- error = inode_change_ok(inode, attr);
+ error = setattr_prepare(dentry, attr);
  if (error)
  return error;
 
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 739d201dba09..b086a4a7a193 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1262,7 +1262,7 @@ int ubifs_setattr(struct dentry *dentry, struct iattr *attr)
 
  dbg_gen("ino %lu, mode %#x, ia_valid %#x",
  inode->i_ino, inode->i_mode, attr->ia_valid);
- err = inode_change_ok(inode, attr);
+ err = setattr_prepare(dentry, attr);
  if (err)
  return err;
 
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 1af98963d860..49f2a4949d0d 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -250,7 +250,7 @@ static int udf_setattr(struct dentry *dentry, struct iattr *attr)
  struct inode *inode = d_inode(dentry);
  int error;
 
- error = inode_change_ok(inode, attr);
+ error = setattr_prepare(dentry, attr);
  if (error)
  return error;
 
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 1f69bb9b1e9d..ba9269db5e56 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -1210,7 +1210,7 @@ int ufs_setattr(struct dentry *dentry, struct iattr *attr)
  unsigned int ia_valid = attr->ia_valid;
  int error;
 
- error = inode_change_ok(inode, attr);
+ error = setattr_prepare(dentry, attr);
  if (error)
  return error;
 
diff --git a/fs/utimes.c b/fs/utimes.c
index ba54b9e648c9..22307cdf7014 100644
--- a/fs/utimes.c
+++ b/fs/utimes.c
@@ -81,7 +81,7 @@ static int utimes_common(struct path *path, struct timespec *times)
  newattrs.ia_valid |= ATTR_MTIME_SET;
  }
  /*
- * Tell inode_change_ok(), that this is an explicit time
+ * Tell setattr_prepare(), that this is an explicit time
  * update, even if neither ATTR_ATIME_SET nor ATTR_MTIME_SET
  * were used.
  */
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 01511afe266a..6e524c5fe5c5 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -539,9 +539,7 @@ xfs_vn_change_ok(
  struct dentry *dentry,
  struct iattr *iattr)
 {
- struct inode *inode = d_inode(dentry);
- struct xfs_inode *ip = XFS_I(inode);
- struct xfs_mount *mp = ip->i_mount;
+ struct xfs_mount *mp = XFS_I(d_inode(dentry))->i_mount;
 
  if (mp->m_flags & XFS_MOUNT_RDONLY)
  return -EROFS;
@@ -549,14 +547,14 @@ xfs_vn_change_ok(
  if (XFS_FORCED_SHUTDOWN(mp))
  return -EIO;
 
- return inode_change_ok(inode, iattr);
+ return setattr_prepare(dentry, iattr);
 }
 
 /*
  * Set non-size attributes of an inode.
  *
  * Caution: The caller of this function is responsible for calling
- * inode_change_ok() or otherwise verifying the change is fine.
+ * setattr_prepare() or otherwise verifying the change is fine.
  */
 int
 xfs_setattr_nonsize(
@@ -767,7 +765,7 @@ xfs_vn_setattr_nonsize(
  * Truncate file.  Must have write permission and not be a directory.
  *
  * Caution: The caller of this function is responsible for calling
- * inode_change_ok() or otherwise verifying the change is fine.
+ * setattr_prepare() or otherwise verifying the change is fine.
  */
 int
 xfs_setattr_size(
diff --git a/include/linux/fs.h b/include/linux/fs.h
index faef16cfcdc6..9dc6bfaa9ce4 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2914,7 +2914,7 @@ extern int buffer_migrate_page(struct address_space *,
 #define buffer_migrate_page NULL
 #endif
 
-extern int inode_change_ok(const struct inode *, struct iattr *);
+extern int setattr_prepare(struct dentry *, struct iattr *);
 extern int inode_newsize_ok(const struct inode *, loff_t offset);
 extern void setattr_copy(struct inode *inode, const struct iattr *attr);
 
diff --git a/mm/shmem.c b/mm/shmem.c
index 56a2aa045bb5..4ebdf73da397 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -569,7 +569,7 @@ static int shmem_setattr(struct dentry *dentry, struct iattr *attr)
  struct shmem_inode_info *info = SHMEM_I(inode);
  int error;
 
- error = inode_change_ok(inode, attr);
+ error = setattr_prepare(dentry, attr);
  if (error)
  return error;
 
diff --git a/zfs/module/zfs/zpl_inode.c b/zfs/module/zfs/zpl_inode.c
index cbdab7d3003b..06611bc39c8d 100644
--- a/zfs/module/zfs/zpl_inode.c
+++ b/zfs/module/zfs/zpl_inode.c
@@ -320,7 +320,7 @@ zpl_setattr(struct dentry *dentry, struct iattr *ia)
  int error;
  fstrans_cookie_t cookie;
 
- error = inode_change_ok(ip, ia);
+ error = setattr_prepare(dentry, ia);
  if (error)
  return (error);
 
--
2.14.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[Xenial][PATCH 9/9] fs: Avoid premature clearing of capabilities

Khalid Elmously
In reply to this post by Khalid Elmously
BugLink: http://bugs.launchpad.net/bugs/1415636

commit 030b533c4fd4d2ec3402363323de4bb2983c9cee upstream.

Currently, notify_change() clears capabilities or IMA attributes by
calling security_inode_killpriv() before calling into ->setattr. Thus it
happens before any other permission checks in inode_change_ok() and user
is thus allowed to trigger clearing of capabilities or IMA attributes
for any file he can look up e.g. by calling chown for that file. This is
unexpected and can lead to user DoSing a system.

Fix the problem by calling security_inode_killpriv() at the end of
inode_change_ok() instead of from notify_change(). At that moment we are
sure user has permissions to do the requested change.

References: CVE-2015-1350
Reviewed-by: Christoph Hellwig <[hidden email]>
Signed-off-by: Jan Kara <[hidden email]>
Signed-off-by: Khalid Elmously <[hidden email]>
---
 fs/attr.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/fs/attr.c b/fs/attr.c
index 111d2a896ede..33150844de27 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -71,7 +71,7 @@ int setattr_prepare(struct dentry *dentry, struct iattr *attr)
 
  /* If force is set do it anyway. */
  if (ia_valid & ATTR_FORCE)
- return 0;
+ goto kill_priv;
 
  /* Make sure a caller can chown. */
  if ((ia_valid & ATTR_UID) && !chown_ok(inode, attr->ia_uid))
@@ -98,6 +98,16 @@ int setattr_prepare(struct dentry *dentry, struct iattr *attr)
  return -EPERM;
  }
 
+kill_priv:
+ /* User has permission for the change */
+ if (ia_valid & ATTR_KILL_PRIV) {
+ int error;
+
+ error = security_inode_killpriv(dentry);
+ if (error)
+ return error;
+ }
+
  return 0;
 }
 EXPORT_SYMBOL(setattr_prepare);
@@ -253,13 +263,11 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de
  if (!(ia_valid & ATTR_MTIME_SET))
  attr->ia_mtime = now;
  if (ia_valid & ATTR_KILL_PRIV) {
- attr->ia_valid &= ~ATTR_KILL_PRIV;
- ia_valid &= ~ATTR_KILL_PRIV;
  error = security_inode_need_killpriv(dentry);
- if (error > 0)
- error = security_inode_killpriv(dentry);
- if (error)
+ if (error < 0)
  return error;
+ if (error == 0)
+ ia_valid = attr->ia_valid &= ~ATTR_KILL_PRIV;
  }
 
  /*
--
2.14.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

NACK: [Xenial][PATCH 2/9] wrappers for ->i_mutex access

Kleber Souza
In reply to this post by Khalid Elmously
Since you are not the original author of the patch, we need to have a
'From:' tag with the name/email of the original author as first line of
the patch. Just like it's done if you do 'git format-patch' and 'git
send-email'.

On 12/07/17 09:37, Khalid Elmously wrote:
> BugLink: http://bugs.launchpad.net/bugs/1415636
>
> commit 5955102c9984fa081b2d570cfac75c97eecf8f3b upstream.

In order for us to know if the upstream commit was cherry-picked or
backported, this information should to go in the SOB block below in the
form of:

(cherry picked from commit <sha1>)

or

(backported from commit <sha1>)

>
> 5955102c9984fa081b2d570cfac75c97eecf8f3b was only partially implemented before this - this is the rest of the change
>

When submitting a patch, it must contain the whole commit text from the
original commit upstream to keep the history. Comments related to the
backport changes should to be added to the SOB block below, together
with some identification of who is making the comment. E.g.

[kmously: 5955102c9984fa081b2d570cfac75c97eecf8f3b was only
 partially...]


> Signed-off-by: Khalid Elmously <[hidden email]>

The patch must have the whole Signed-off-by block from the original
commit and we add our SOB's and ACK's below it.

So for this patch, the email body before the diff itself would be
something like this:

--------------------------------------------------------------
From: Al Viro <[hidden email]>

BugLink: http://bugs.launchpad.net/bugs/1415636

parallel to mutex_{lock,unlock,trylock,is_locked,lock_nested},
inode_foo(inode) being mutex_foo(&inode->i_mutex).

Please, use those for access to ->i_mutex; over the coming cycle
->i_mutex will become rwsem, with ->lookup() done with it held
only shared.

Signed-off-by: Al Viro <[hidden email]>
(backported from commit 5955102c9984fa081b2d570cfac75c97eecf8f3b)
[kmously: <some comments here regarding the changes for the backport>]
Signed-off-by: Khalid Elmously <[hidden email]>
--------------------------------------------------------------


Kleber

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Re: [Xenial][PATCH 0/9] Fix for CVE-2015-1350

Thadeu Lima de Souza Cascardo-3
In reply to this post by Khalid Elmously
On Thu, Dec 07, 2017 at 03:37:48AM -0500, Khalid Elmously wrote:

> The VFS subsystem in the Linux kernel 3.x provides an incomplete set of
> requirements for setattr operations that underspecifies removing extended
> privilege attributes, which allows local users to cause a denial of service
> (capability stripping) via a failed invocation of a system call, as
> demonstrated by using chown to remove a capability from the ping or
> Wireshark dumpcap program.
>
>
>
> Al Viro (1):
>   ->getxattr(): pass dentry and inode as separate arguments
>
> Andreas Gruenbacher (1):
>   ceph: Get rid of d_find_alias in ceph_set_acl
>
> Jan Kara (5):
>   xfs: Propagate dentry down to inode_change_ok()
>   ceph: Propagate dentry down to inode_change_ok()
>   fuse: Propagate dentry down to inode_change_ok()
>   fs: Give dentry to inode_change_ok() instead of inode
>   fs: Avoid premature clearing of capabilities
>
> Khalid Elmously (2):
>   wrappers for ->i_mutex access
>   xattr_handler: pass dentry and inode as separate arguments of ->get()

The whole point of the fix is patch 9 ("fs: Avoid premature clearing of
capabilities"). I see how picking up patch 8 ("fs: Give dentry to
inode_change_ok() instead of inode") will make it a clean cherry-pick.
But that makes you bring all those changes to all filesystems and all
those other patches, then, are needed.

Why not just backport patch 9 and make the change to inode_change_ok? I
see how it uses the dentry instead of the inode, but why not just call
d_obtain_alias (with corresponding dput after dentry use)? That would
simplify the whole patchset. Though after some review of the other
patches, they seem to be fine aside from the usual style that we have
for backports (using -x from cherry-pick, instead of Upstream commit
style).

Regards.
Cascardo.

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

Re: [Xenial][PATCH 0/9] Fix for CVE-2015-1350

Thadeu Lima de Souza Cascardo-3
In reply to this post by Khalid Elmously
On Thu, Dec 07, 2017 at 03:37:48AM -0500, Khalid Elmously wrote:
> The VFS subsystem in the Linux kernel 3.x provides an incomplete set of
> requirements for setattr operations that underspecifies removing extended
> privilege attributes, which allows local users to cause a denial of service
> (capability stripping) via a failed invocation of a system call, as
> demonstrated by using chown to remove a capability from the ping or
> Wireshark dumpcap program.

One other thing: we stopped using bugs for CVEs. So, instead of a
BugLink, you should have a line as the one below all by itself. I
usually put it after the cherry-pick/backport line, right before my
SOB.

CVE-2015-1350

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team