aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-10-10 16:04:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-10 16:04:49 -0400
commitabb5a14fa20fdd400995926134b7be9eb8ce6048 (patch)
tree085add41cae3193b8c8293d25b453fd1ecae0c19
parent911f9dab301e8583143c7e75b552eadd434ea0a8 (diff)
parente55f1d1d13e7f1c364672d667d78fd1f640ab9f9 (diff)
Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull misc vfs updates from Al Viro: "Assorted misc bits and pieces. There are several single-topic branches left after this (rename2 series from Miklos, current_time series from Deepa Dinamani, xattr series from Andreas, uaccess stuff from from me) and I'd prefer to send those separately" * 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (39 commits) proc: switch auxv to use of __mem_open() hpfs: support FIEMAP cifs: get rid of unused arguments of CIFSSMBWrite() posix_acl: uapi header split posix_acl: xattr representation cleanups fs/aio.c: eliminate redundant loads in put_aio_ring_file fs/internal.h: add const to ns_dentry_operations declaration compat: remove compat_printk() fs/buffer.c: make __getblk_slow() static proc: unsigned file descriptors fs/file: more unsigned file descriptors fs: compat: remove redundant check of nr_segs cachefiles: Fix attempt to read i_blocks after deleting file [ver #2] cifs: don't use memcpy() to copy struct iov_iter get rid of separate multipage fault-in primitives fs: Avoid premature clearing of capabilities fs: Give dentry to inode_change_ok() instead of inode fuse: Propagate dentry down to inode_change_ok() ceph: Propagate dentry down to inode_change_ok() xfs: Propagate dentry down to inode_change_ok() ...
-rw-r--r--Documentation/filesystems/porting4
-rw-r--r--arch/parisc/kernel/cache.c2
-rw-r--r--drivers/gpu/drm/armada/armada_gem.c2
-rw-r--r--drivers/gpu/drm/drm_debugfs.c4
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c6
-rw-r--r--drivers/gpu/drm/i915/i915_gem_execbuffer.c2
-rw-r--r--drivers/gpu/drm/msm/msm_perf.c4
-rw-r--r--drivers/gpu/drm/msm/msm_rd.c4
-rw-r--r--drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c6
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c16
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c4
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_acl.h6
-rw-r--r--drivers/staging/lustre/lustre/llite/file.c4
-rw-r--r--drivers/staging/lustre/lustre/llite/llite_lib.c2
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/wiretest.c44
-rw-r--r--fs/9p/acl.c40
-rw-r--r--fs/9p/vfs_inode.c2
-rw-r--r--fs/9p/vfs_inode_dotl.c2
-rw-r--r--fs/adfs/inode.c2
-rw-r--r--fs/affs/inode.c2
-rw-r--r--fs/aio.c9
-rw-r--r--fs/attr.c50
-rw-r--r--fs/btrfs/acl.c6
-rw-r--r--fs/btrfs/ctree.h1
-rw-r--r--fs/btrfs/file.c2
-rw-r--r--fs/btrfs/inode.c17
-rw-r--r--fs/btrfs/send.c2
-rw-r--r--fs/btrfs/tree-log.c4
-rw-r--r--fs/buffer.c3
-rw-r--r--fs/cachefiles/interface.c8
-rw-r--r--fs/cachefiles/internal.h3
-rw-r--r--fs/cachefiles/namei.c8
-rw-r--r--fs/ceph/acl.c11
-rw-r--r--fs/ceph/inode.c19
-rw-r--r--fs/cifs/cifsfs.h10
-rw-r--r--fs/cifs/cifsproto.h3
-rw-r--r--fs/cifs/cifssmb.c27
-rw-r--r--fs/cifs/dir.c6
-rw-r--r--fs/cifs/file.c14
-rw-r--r--fs/cifs/inode.c6
-rw-r--r--fs/cifs/link.c2
-rw-r--r--fs/compat.c16
-rw-r--r--fs/ecryptfs/inode.c2
-rw-r--r--fs/exofs/inode.c2
-rw-r--r--fs/ext2/acl.c12
-rw-r--r--fs/ext2/inode.c2
-rw-r--r--fs/ext4/acl.c12
-rw-r--r--fs/ext4/inode.c2
-rw-r--r--fs/f2fs/acl.c6
-rw-r--r--fs/f2fs/file.c2
-rw-r--r--fs/f2fs/node.c7
-rw-r--r--fs/fat/file.c2
-rw-r--r--fs/fat/namei_vfat.c19
-rw-r--r--fs/file.c34
-rw-r--r--fs/fuse/dir.c7
-rw-r--r--fs/fuse/file.c2
-rw-r--r--fs/fuse/fuse_i.h2
-rw-r--r--fs/gfs2/acl.c12
-rw-r--r--fs/gfs2/inode.c2
-rw-r--r--fs/hfs/inode.c2
-rw-r--r--fs/hfsplus/inode.c2
-rw-r--r--fs/hfsplus/posix_acl.c4
-rw-r--r--fs/hostfs/hostfs_kern.c2
-rw-r--r--fs/hpfs/file.c6
-rw-r--r--fs/hpfs/inode.c2
-rw-r--r--fs/hugetlbfs/inode.c2
-rw-r--r--fs/inode.c74
-rw-r--r--fs/internal.h11
-rw-r--r--fs/jffs2/acl.c9
-rw-r--r--fs/jffs2/fs.c2
-rw-r--r--fs/jfs/acl.c6
-rw-r--r--fs/jfs/file.c2
-rw-r--r--fs/kernfs/inode.c2
-rw-r--r--fs/libfs.c2
-rw-r--r--fs/locks.c53
-rw-r--r--fs/logfs/file.c2
-rw-r--r--fs/minix/file.c2
-rw-r--r--fs/namei.c2
-rw-r--r--fs/namespace.c2
-rw-r--r--fs/ncpfs/inode.c2
-rw-r--r--fs/nfsd/nfsproc.c8
-rw-r--r--fs/nilfs2/inode.c2
-rw-r--r--fs/ntfs/file.c2
-rw-r--r--fs/ntfs/inode.c2
-rw-r--r--fs/ocfs2/acl.c10
-rw-r--r--fs/ocfs2/dlmfs/dlmfs.c2
-rw-r--r--fs/ocfs2/file.c2
-rw-r--r--fs/omfs/file.c2
-rw-r--r--fs/open.c17
-rw-r--r--fs/orangefs/acl.c15
-rw-r--r--fs/orangefs/dir.c4
-rw-r--r--fs/orangefs/file.c4
-rw-r--r--fs/orangefs/inode.c14
-rw-r--r--fs/orangefs/namei.c44
-rw-r--r--fs/orangefs/orangefs-debugfs.c4
-rw-r--r--fs/overlayfs/inode.c2
-rw-r--r--fs/overlayfs/super.c2
-rw-r--r--fs/posix_acl.c60
-rw-r--r--fs/proc/base.c47
-rw-r--r--fs/proc/fd.c8
-rw-r--r--fs/proc/fd.h2
-rw-r--r--fs/proc/generic.c2
-rw-r--r--fs/proc/internal.h2
-rw-r--r--fs/proc/proc_sysctl.c2
-rw-r--r--fs/ramfs/file-nommu.c2
-rw-r--r--fs/reiserfs/inode.c2
-rw-r--r--fs/reiserfs/xattr_acl.c8
-rw-r--r--fs/sysv/file.c2
-rw-r--r--fs/ubifs/file.c2
-rw-r--r--fs/udf/file.c2
-rw-r--r--fs/ufs/inode.c2
-rw-r--r--fs/utimes.c19
-rw-r--r--fs/xfs/xfs_acl.c13
-rw-r--r--fs/xfs/xfs_file.c2
-rw-r--r--fs/xfs/xfs_inode.c2
-rw-r--r--fs/xfs/xfs_ioctl.c2
-rw-r--r--fs/xfs/xfs_iops.c92
-rw-r--r--fs/xfs/xfs_iops.h3
-rw-r--r--include/linux/compat.h1
-rw-r--r--include/linux/dcache.h5
-rw-r--r--include/linux/fdtable.h6
-rw-r--r--include/linux/fs.h22
-rw-r--r--include/linux/fsnotify.h14
-rw-r--r--include/linux/pagemap.h54
-rw-r--r--include/linux/posix_acl.h23
-rw-r--r--include/linux/posix_acl_xattr.h31
-rw-r--r--include/linux/uio.h1
-rw-r--r--include/uapi/linux/Kbuild2
-rw-r--r--include/uapi/linux/fs.h1
-rw-r--r--include/uapi/linux/posix_acl.h39
-rw-r--r--include/uapi/linux/posix_acl_xattr.h38
-rw-r--r--kernel/sysctl.c14
-rw-r--r--lib/iov_iter.c3
-rw-r--r--mm/shmem.c2
-rw-r--r--security/integrity/ima/ima_appraise.c4
-rw-r--r--security/integrity/ima/ima_main.c2
136 files changed, 737 insertions, 640 deletions
diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting
index b1bd05ea66b2..ab320c77147a 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
287and vmtruncate, and the reorder the vmtruncate + foofs_vmtruncate sequence to 287and vmtruncate, and the reorder the vmtruncate + foofs_vmtruncate sequence to
288be in order of zeroing blocks using block_truncate_page or similar helpers, 288be in order of zeroing blocks using block_truncate_page or similar helpers,
289size update and on finally on-disk truncation which should not fail. 289size update and on finally on-disk truncation which should not fail.
290inode_change_ok now includes the size checks for ATTR_SIZE and must be called 290setattr_prepare (which used to be inode_change_ok) now includes the size checks
291in the beginning of ->setattr unconditionally. 291for ATTR_SIZE and must be called in the beginning of ->setattr unconditionally.
292 292
293[mandatory] 293[mandatory]
294 294
diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
index 67001277256c..629eb464d5ba 100644
--- a/arch/parisc/kernel/cache.c
+++ b/arch/parisc/kernel/cache.c
@@ -345,7 +345,7 @@ void flush_dcache_page(struct page *page)
345 != (addr & (SHM_COLOUR - 1))) { 345 != (addr & (SHM_COLOUR - 1))) {
346 __flush_cache_page(mpnt, addr, page_to_phys(page)); 346 __flush_cache_page(mpnt, addr, page_to_phys(page));
347 if (old_addr) 347 if (old_addr)
348 printk(KERN_ERR "INEQUIVALENT ALIASES 0x%lx and 0x%lx in file %s\n", old_addr, addr, mpnt->vm_file ? (char *)mpnt->vm_file->f_path.dentry->d_name.name : "(null)"); 348 printk(KERN_ERR "INEQUIVALENT ALIASES 0x%lx and 0x%lx in file %pD\n", old_addr, addr, mpnt->vm_file);
349 old_addr = addr; 349 old_addr = addr;
350 } 350 }
351 } 351 }
diff --git a/drivers/gpu/drm/armada/armada_gem.c b/drivers/gpu/drm/armada/armada_gem.c
index cb8f0347b934..ff843160c600 100644
--- a/drivers/gpu/drm/armada/armada_gem.c
+++ b/drivers/gpu/drm/armada/armada_gem.c
@@ -387,7 +387,7 @@ int armada_gem_pwrite_ioctl(struct drm_device *dev, void *data,
387 if (!access_ok(VERIFY_READ, ptr, args->size)) 387 if (!access_ok(VERIFY_READ, ptr, args->size))
388 return -EFAULT; 388 return -EFAULT;
389 389
390 ret = fault_in_multipages_readable(ptr, args->size); 390 ret = fault_in_pages_readable(ptr, args->size);
391 if (ret) 391 if (ret)
392 return ret; 392 return ret;
393 393
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index fa10cef2ba37..1205790ed960 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -104,8 +104,8 @@ int drm_debugfs_create_files(const struct drm_info_list *files, int count,
104 ent = debugfs_create_file(files[i].name, S_IFREG | S_IRUGO, 104 ent = debugfs_create_file(files[i].name, S_IFREG | S_IRUGO,
105 root, tmp, &drm_debugfs_fops); 105 root, tmp, &drm_debugfs_fops);
106 if (!ent) { 106 if (!ent) {
107 DRM_ERROR("Cannot create /sys/kernel/debug/dri/%s/%s\n", 107 DRM_ERROR("Cannot create /sys/kernel/debug/dri/%pd/%s\n",
108 root->d_name.name, files[i].name); 108 root, files[i].name);
109 kfree(tmp); 109 kfree(tmp);
110 ret = -1; 110 ret = -1;
111 goto fail; 111 goto fail;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index a77ce9983f69..ccf56c60e6e8 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -675,7 +675,7 @@ i915_gem_gtt_pread(struct drm_device *dev,
675 675
676 mutex_unlock(&dev->struct_mutex); 676 mutex_unlock(&dev->struct_mutex);
677 if (likely(!i915.prefault_disable)) { 677 if (likely(!i915.prefault_disable)) {
678 ret = fault_in_multipages_writeable(user_data, remain); 678 ret = fault_in_pages_writeable(user_data, remain);
679 if (ret) { 679 if (ret) {
680 mutex_lock(&dev->struct_mutex); 680 mutex_lock(&dev->struct_mutex);
681 goto out_unpin; 681 goto out_unpin;
@@ -803,7 +803,7 @@ i915_gem_shmem_pread(struct drm_device *dev,
803 mutex_unlock(&dev->struct_mutex); 803 mutex_unlock(&dev->struct_mutex);
804 804
805 if (likely(!i915.prefault_disable) && !prefaulted) { 805 if (likely(!i915.prefault_disable) && !prefaulted) {
806 ret = fault_in_multipages_writeable(user_data, remain); 806 ret = fault_in_pages_writeable(user_data, remain);
807 /* Userspace is tricking us, but we've already clobbered 807 /* Userspace is tricking us, but we've already clobbered
808 * its pages with the prefault and promised to write the 808 * its pages with the prefault and promised to write the
809 * data up to the first fault. Hence ignore any errors 809 * data up to the first fault. Hence ignore any errors
@@ -1267,7 +1267,7 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
1267 return -EFAULT; 1267 return -EFAULT;
1268 1268
1269 if (likely(!i915.prefault_disable)) { 1269 if (likely(!i915.prefault_disable)) {
1270 ret = fault_in_multipages_readable(u64_to_user_ptr(args->data_ptr), 1270 ret = fault_in_pages_readable(u64_to_user_ptr(args->data_ptr),
1271 args->size); 1271 args->size);
1272 if (ret) 1272 if (ret)
1273 return -EFAULT; 1273 return -EFAULT;
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index b35e5b6475b2..72628edda376 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1048,7 +1048,7 @@ validate_exec_list(struct drm_device *dev,
1048 return -EFAULT; 1048 return -EFAULT;
1049 1049
1050 if (likely(!i915.prefault_disable)) { 1050 if (likely(!i915.prefault_disable)) {
1051 if (fault_in_multipages_readable(ptr, length)) 1051 if (fault_in_pages_readable(ptr, length))
1052 return -EFAULT; 1052 return -EFAULT;
1053 } 1053 }
1054 } 1054 }
diff --git a/drivers/gpu/drm/msm/msm_perf.c b/drivers/gpu/drm/msm/msm_perf.c
index 17fe4e53e0d1..1627294575cb 100644
--- a/drivers/gpu/drm/msm/msm_perf.c
+++ b/drivers/gpu/drm/msm/msm_perf.c
@@ -229,8 +229,8 @@ int msm_perf_debugfs_init(struct drm_minor *minor)
229 perf->ent = debugfs_create_file("perf", S_IFREG | S_IRUGO, 229 perf->ent = debugfs_create_file("perf", S_IFREG | S_IRUGO,
230 minor->debugfs_root, perf, &perf_debugfs_fops); 230 minor->debugfs_root, perf, &perf_debugfs_fops);
231 if (!perf->ent) { 231 if (!perf->ent) {
232 DRM_ERROR("Cannot create /sys/kernel/debug/dri/%s/perf\n", 232 DRM_ERROR("Cannot create /sys/kernel/debug/dri/%pd/perf\n",
233 minor->debugfs_root->d_name.name); 233 minor->debugfs_root);
234 goto fail; 234 goto fail;
235 } 235 }
236 236
diff --git a/drivers/gpu/drm/msm/msm_rd.c b/drivers/gpu/drm/msm/msm_rd.c
index 3a5fdfcd67ae..8487f461f05f 100644
--- a/drivers/gpu/drm/msm/msm_rd.c
+++ b/drivers/gpu/drm/msm/msm_rd.c
@@ -243,8 +243,8 @@ int msm_rd_debugfs_init(struct drm_minor *minor)
243 rd->ent = debugfs_create_file("rd", S_IFREG | S_IRUGO, 243 rd->ent = debugfs_create_file("rd", S_IFREG | S_IRUGO,
244 minor->debugfs_root, rd, &rd_debugfs_fops); 244 minor->debugfs_root, rd, &rd_debugfs_fops);
245 if (!rd->ent) { 245 if (!rd->ent) {
246 DRM_ERROR("Cannot create /sys/kernel/debug/dri/%s/rd\n", 246 DRM_ERROR("Cannot create /sys/kernel/debug/dri/%pd/rd\n",
247 minor->debugfs_root->d_name.name); 247 minor->debugfs_root);
248 goto fail; 248 goto fail;
249 } 249 }
250 250
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c
index f6591c83d636..affe760c8c22 100644
--- a/drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c
@@ -2422,14 +2422,12 @@ int iwl_dbgfs_register(struct iwl_priv *priv, struct dentry *dbgfs_dir)
2422 */ 2422 */
2423 if (priv->mac80211_registered) { 2423 if (priv->mac80211_registered) {
2424 char buf[100]; 2424 char buf[100];
2425 struct dentry *mac80211_dir, *dev_dir, *root_dir; 2425 struct dentry *mac80211_dir, *dev_dir;
2426 2426
2427 dev_dir = dbgfs_dir->d_parent; 2427 dev_dir = dbgfs_dir->d_parent;
2428 root_dir = dev_dir->d_parent;
2429 mac80211_dir = priv->hw->wiphy->debugfsdir; 2428 mac80211_dir = priv->hw->wiphy->debugfsdir;
2430 2429
2431 snprintf(buf, 100, "../../%s/%s", root_dir->d_name.name, 2430 snprintf(buf, 100, "../../%pd2", dev_dir);
2432 dev_dir->d_name.name);
2433 2431
2434 if (!debugfs_create_symlink("iwlwifi", mac80211_dir, buf)) 2432 if (!debugfs_create_symlink("iwlwifi", mac80211_dir, buf))
2435 goto err; 2433 goto err;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
index 2d6f44fbaf62..f4d75ffe3d8a 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
@@ -1571,8 +1571,8 @@ void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
1571 mvmvif->dbgfs_dir = debugfs_create_dir("iwlmvm", dbgfs_dir); 1571 mvmvif->dbgfs_dir = debugfs_create_dir("iwlmvm", dbgfs_dir);
1572 1572
1573 if (!mvmvif->dbgfs_dir) { 1573 if (!mvmvif->dbgfs_dir) {
1574 IWL_ERR(mvm, "Failed to create debugfs directory under %s\n", 1574 IWL_ERR(mvm, "Failed to create debugfs directory under %pd\n",
1575 dbgfs_dir->d_name.name); 1575 dbgfs_dir);
1576 return; 1576 return;
1577 } 1577 }
1578 1578
@@ -1627,17 +1627,15 @@ void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
1627 * find 1627 * find
1628 * netdev:wlan0 -> ../../../ieee80211/phy0/netdev:wlan0/iwlmvm/ 1628 * netdev:wlan0 -> ../../../ieee80211/phy0/netdev:wlan0/iwlmvm/
1629 */ 1629 */
1630 snprintf(buf, 100, "../../../%s/%s/%s/%s", 1630 snprintf(buf, 100, "../../../%pd3/%pd",
1631 dbgfs_dir->d_parent->d_parent->d_name.name, 1631 dbgfs_dir,
1632 dbgfs_dir->d_parent->d_name.name, 1632 mvmvif->dbgfs_dir);
1633 dbgfs_dir->d_name.name,
1634 mvmvif->dbgfs_dir->d_name.name);
1635 1633
1636 mvmvif->dbgfs_slink = debugfs_create_symlink(dbgfs_dir->d_name.name, 1634 mvmvif->dbgfs_slink = debugfs_create_symlink(dbgfs_dir->d_name.name,
1637 mvm->debugfs_dir, buf); 1635 mvm->debugfs_dir, buf);
1638 if (!mvmvif->dbgfs_slink) 1636 if (!mvmvif->dbgfs_slink)
1639 IWL_ERR(mvm, "Can't create debugfs symbolic link under %s\n", 1637 IWL_ERR(mvm, "Can't create debugfs symbolic link under %pd\n",
1640 dbgfs_dir->d_name.name); 1638 dbgfs_dir);
1641 return; 1639 return;
1642err: 1640err:
1643 IWL_ERR(mvm, "Can't create debugfs entity\n"); 1641 IWL_ERR(mvm, "Can't create debugfs entity\n");
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
index 539d718df797..07da4efe8458 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
@@ -1748,9 +1748,7 @@ int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir)
1748 * Create a symlink with mac80211. It will be removed when mac80211 1748 * Create a symlink with mac80211. It will be removed when mac80211
1749 * exists (before the opmode exists which removes the target.) 1749 * exists (before the opmode exists which removes the target.)
1750 */ 1750 */
1751 snprintf(buf, 100, "../../%s/%s", 1751 snprintf(buf, 100, "../../%pd2", dbgfs_dir->d_parent);
1752 dbgfs_dir->d_parent->d_parent->d_name.name,
1753 dbgfs_dir->d_parent->d_name.name);
1754 if (!debugfs_create_symlink("iwlwifi", mvm->hw->wiphy->debugfsdir, buf)) 1752 if (!debugfs_create_symlink("iwlwifi", mvm->hw->wiphy->debugfsdir, buf))
1755 goto err; 1753 goto err;
1756 1754
diff --git a/drivers/staging/lustre/lustre/include/lustre_acl.h b/drivers/staging/lustre/lustre/include/lustre_acl.h
index fecabe139b1f..9786f6caaade 100644
--- a/drivers/staging/lustre/lustre/include/lustre_acl.h
+++ b/drivers/staging/lustre/lustre/include/lustre_acl.h
@@ -38,8 +38,8 @@
38#include <linux/posix_acl_xattr.h> 38#include <linux/posix_acl_xattr.h>
39 39
40#define LUSTRE_POSIX_ACL_MAX_ENTRIES 32 40#define LUSTRE_POSIX_ACL_MAX_ENTRIES 32
41#define LUSTRE_POSIX_ACL_MAX_SIZE \ 41#define LUSTRE_POSIX_ACL_MAX_SIZE \
42 (sizeof(posix_acl_xattr_header) + \ 42 (sizeof(struct posix_acl_xattr_header) + \
43 LUSTRE_POSIX_ACL_MAX_ENTRIES * sizeof(posix_acl_xattr_entry)) 43 LUSTRE_POSIX_ACL_MAX_ENTRIES * sizeof(struct posix_acl_xattr_entry))
44 44
45#endif 45#endif
diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
index d56863ff5866..65c945d8bae2 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -1121,8 +1121,8 @@ ll_file_io_generic(const struct lu_env *env, struct vvp_io_args *args,
1121 struct cl_io *io; 1121 struct cl_io *io;
1122 ssize_t result; 1122 ssize_t result;
1123 1123
1124 CDEBUG(D_VFSTRACE, "file: %s, type: %d ppos: %llu, count: %zu\n", 1124 CDEBUG(D_VFSTRACE, "file: %pD, type: %d ppos: %llu, count: %zu\n",
1125 file->f_path.dentry->d_name.name, iot, *ppos, count); 1125 file, iot, *ppos, count);
1126 1126
1127restart: 1127restart:
1128 io = vvp_env_thread_io(env); 1128 io = vvp_env_thread_io(env);
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 6bb41b09172e..e5c62f4ce3d8 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -1459,7 +1459,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
1459 attr->ia_valid |= ATTR_MTIME | ATTR_CTIME; 1459 attr->ia_valid |= ATTR_MTIME | ATTR_CTIME;
1460 } 1460 }
1461 1461
1462 /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */ 1462 /* POSIX: check before ATTR_*TIME_SET set (from setattr_prepare) */
1463 if (attr->ia_valid & TIMES_SET_FLAGS) { 1463 if (attr->ia_valid & TIMES_SET_FLAGS) {
1464 if ((!uid_eq(current_fsuid(), inode->i_uid)) && 1464 if ((!uid_eq(current_fsuid(), inode->i_uid)) &&
1465 !capable(CFS_CAP_FOWNER)) 1465 !capable(CFS_CAP_FOWNER))
diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c
index e5945e2ccc49..b05b1f935e4c 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c
@@ -3742,32 +3742,28 @@ void lustre_assert_wire_constants(void)
3742 CLASSERT(FIEMAP_EXTENT_NET == 0x80000000); 3742 CLASSERT(FIEMAP_EXTENT_NET == 0x80000000);
3743 3743
3744 /* Checks for type posix_acl_xattr_entry */ 3744 /* Checks for type posix_acl_xattr_entry */
3745 LASSERTF((int)sizeof(posix_acl_xattr_entry) == 8, "found %lld\n", 3745 LASSERTF((int)sizeof(struct posix_acl_xattr_entry) == 8, "found %lld\n",
3746 (long long)(int)sizeof(posix_acl_xattr_entry)); 3746 (long long)(int)sizeof(struct posix_acl_xattr_entry));
3747 LASSERTF((int)offsetof(posix_acl_xattr_entry, e_tag) == 0, "found %lld\n", 3747 LASSERTF((int)offsetof(struct posix_acl_xattr_entry, e_tag) == 0, "found %lld\n",
3748 (long long)(int)offsetof(posix_acl_xattr_entry, e_tag)); 3748 (long long)(int)offsetof(struct posix_acl_xattr_entry, e_tag));
3749 LASSERTF((int)sizeof(((posix_acl_xattr_entry *)0)->e_tag) == 2, "found %lld\n", 3749 LASSERTF((int)sizeof(((struct posix_acl_xattr_entry *)0)->e_tag) == 2, "found %lld\n",
3750 (long long)(int)sizeof(((posix_acl_xattr_entry *)0)->e_tag)); 3750 (long long)(int)sizeof(((struct posix_acl_xattr_entry *)0)->e_tag));
3751 LASSERTF((int)offsetof(posix_acl_xattr_entry, e_perm) == 2, "found %lld\n", 3751 LASSERTF((int)offsetof(struct posix_acl_xattr_entry, e_perm) == 2, "found %lld\n",
3752 (long long)(int)offsetof(posix_acl_xattr_entry, e_perm)); 3752 (long long)(int)offsetof(struct posix_acl_xattr_entry, e_perm));
3753 LASSERTF((int)sizeof(((posix_acl_xattr_entry *)0)->e_perm) == 2, "found %lld\n", 3753 LASSERTF((int)sizeof(((struct posix_acl_xattr_entry *)0)->e_perm) == 2, "found %lld\n",
3754 (long long)(int)sizeof(((posix_acl_xattr_entry *)0)->e_perm)); 3754 (long long)(int)sizeof(((struct posix_acl_xattr_entry *)0)->e_perm));
3755 LASSERTF((int)offsetof(posix_acl_xattr_entry, e_id) == 4, "found %lld\n", 3755 LASSERTF((int)offsetof(struct posix_acl_xattr_entry, e_id) == 4, "found %lld\n",
3756 (long long)(int)offsetof(posix_acl_xattr_entry, e_id)); 3756 (long long)(int)offsetof(struct posix_acl_xattr_entry, e_id));
3757 LASSERTF((int)sizeof(((posix_acl_xattr_entry *)0)->e_id) == 4, "found %lld\n", 3757 LASSERTF((int)sizeof(((struct posix_acl_xattr_entry *)0)->e_id) == 4, "found %lld\n",
3758 (long long)(int)sizeof(((posix_acl_xattr_entry *)0)->e_id)); 3758 (long long)(int)sizeof(((struct posix_acl_xattr_entry *)0)->e_id));
3759 3759
3760 /* Checks for type posix_acl_xattr_header */ 3760 /* Checks for type posix_acl_xattr_header */
3761 LASSERTF((int)sizeof(posix_acl_xattr_header) == 4, "found %lld\n", 3761 LASSERTF((int)sizeof(struct posix_acl_xattr_header) == 4, "found %lld\n",
3762 (long long)(int)sizeof(posix_acl_xattr_header)); 3762 (long long)(int)sizeof(struct posix_acl_xattr_header));
3763 LASSERTF((int)offsetof(posix_acl_xattr_header, a_version) == 0, "found %lld\n", 3763 LASSERTF((int)offsetof(struct posix_acl_xattr_header, a_version) == 0, "found %lld\n",
3764 (long long)(int)offsetof(posix_acl_xattr_header, a_version)); 3764 (long long)(int)offsetof(struct posix_acl_xattr_header, a_version));
3765 LASSERTF((int)sizeof(((posix_acl_xattr_header *)0)->a_version) == 4, "found %lld\n", 3765 LASSERTF((int)sizeof(((struct posix_acl_xattr_header *)0)->a_version) == 4, "found %lld\n",
3766 (long long)(int)sizeof(((posix_acl_xattr_header *)0)->a_version)); 3766 (long long)(int)sizeof(((struct posix_acl_xattr_header *)0)->a_version));
3767 LASSERTF((int)offsetof(posix_acl_xattr_header, a_entries) == 4, "found %lld\n",
3768 (long long)(int)offsetof(posix_acl_xattr_header, a_entries));
3769 LASSERTF((int)sizeof(((posix_acl_xattr_header *)0)->a_entries) == 0, "found %lld\n",
3770 (long long)(int)sizeof(((posix_acl_xattr_header *)0)->a_entries));
3771 3767
3772 /* Checks for struct link_ea_header */ 3768 /* Checks for struct link_ea_header */
3773 LASSERTF((int)sizeof(struct link_ea_header) == 24, "found %lld\n", 3769 LASSERTF((int)sizeof(struct link_ea_header) == 24, "found %lld\n",
diff --git a/fs/9p/acl.c b/fs/9p/acl.c
index 5b6a1743ea17..b3c2cc79c20d 100644
--- a/fs/9p/acl.c
+++ b/fs/9p/acl.c
@@ -276,32 +276,26 @@ static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
276 switch (handler->flags) { 276 switch (handler->flags) {
277 case ACL_TYPE_ACCESS: 277 case ACL_TYPE_ACCESS:
278 if (acl) { 278 if (acl) {
279 umode_t mode = inode->i_mode; 279 struct iattr iattr;
280 retval = posix_acl_equiv_mode(acl, &mode); 280
281 if (retval < 0) 281 retval = posix_acl_update_mode(inode, &iattr.ia_mode, &acl);
282 if (retval)
282 goto err_out; 283 goto err_out;
283 else { 284 if (!acl) {
284 struct iattr iattr; 285 /*
285 if (retval == 0) { 286 * ACL can be represented
286 /* 287 * by the mode bits. So don't
287 * ACL can be represented 288 * update ACL.
288 * by the mode bits. So don't
289 * update ACL.
290 */
291 acl = NULL;
292 value = NULL;
293 size = 0;
294 }
295 /* Updte the mode bits */
296 iattr.ia_mode = ((mode & S_IALLUGO) |
297 (inode->i_mode & ~S_IALLUGO));
298 iattr.ia_valid = ATTR_MODE;
299 /* FIXME should we update ctime ?
300 * What is the following setxattr update the
301 * mode ?
302 */ 289 */
303 v9fs_vfs_setattr_dotl(dentry, &iattr); 290 value = NULL;
291 size = 0;
304 } 292 }
293 iattr.ia_valid = ATTR_MODE;
294 /* FIXME should we update ctime ?
295 * What is the following setxattr update the
296 * mode ?
297 */
298 v9fs_vfs_setattr_dotl(dentry, &iattr);
305 } 299 }
306 break; 300 break;
307 case ACL_TYPE_DEFAULT: 301 case ACL_TYPE_DEFAULT:
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 8b1999b528e9..aa639bb1f289 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)
1094 struct p9_wstat wstat; 1094 struct p9_wstat wstat;
1095 1095
1096 p9_debug(P9_DEBUG_VFS, "\n"); 1096 p9_debug(P9_DEBUG_VFS, "\n");
1097 retval = inode_change_ok(d_inode(dentry), iattr); 1097 retval = setattr_prepare(dentry, iattr);
1098 if (retval) 1098 if (retval)
1099 return retval; 1099 return retval;
1100 1100
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index eeabcb0bad12..0e6ad3019711 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -558,7 +558,7 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
558 558
559 p9_debug(P9_DEBUG_VFS, "\n"); 559 p9_debug(P9_DEBUG_VFS, "\n");
560 560
561 retval = inode_change_ok(inode, iattr); 561 retval = setattr_prepare(dentry, iattr);
562 if (retval) 562 if (retval)
563 return retval; 563 return retval;
564 564
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)
303 unsigned int ia_valid = attr->ia_valid; 303 unsigned int ia_valid = attr->ia_valid;
304 int error; 304 int error;
305 305
306 error = inode_change_ok(inode, attr); 306 error = setattr_prepare(dentry, attr);
307 307
308 /* 308 /*
309 * we can't change the UID or GID of any file - 309 * we can't change the UID or GID of any file -
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 0fdb0f5b2239..1aa243502c7f 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -219,7 +219,7 @@ affs_notify_change(struct dentry *dentry, struct iattr *attr)
219 219
220 pr_debug("notify_change(%lu,0x%x)\n", inode->i_ino, attr->ia_valid); 220 pr_debug("notify_change(%lu,0x%x)\n", inode->i_ino, attr->ia_valid);
221 221
222 error = inode_change_ok(inode,attr); 222 error = setattr_prepare(dentry, attr);
223 if (error) 223 if (error)
224 goto out; 224 goto out;
225 225
diff --git a/fs/aio.c b/fs/aio.c
index 4fe81d1c60f9..1157e13a36d6 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -274,14 +274,17 @@ __initcall(aio_setup);
274static void put_aio_ring_file(struct kioctx *ctx) 274static void put_aio_ring_file(struct kioctx *ctx)
275{ 275{
276 struct file *aio_ring_file = ctx->aio_ring_file; 276 struct file *aio_ring_file = ctx->aio_ring_file;
277 struct address_space *i_mapping;
278
277 if (aio_ring_file) { 279 if (aio_ring_file) {
278 truncate_setsize(aio_ring_file->f_inode, 0); 280 truncate_setsize(aio_ring_file->f_inode, 0);
279 281
280 /* Prevent further access to the kioctx from migratepages */ 282 /* Prevent further access to the kioctx from migratepages */
281 spin_lock(&aio_ring_file->f_inode->i_mapping->private_lock); 283 i_mapping = aio_ring_file->f_inode->i_mapping;
282 aio_ring_file->f_inode->i_mapping->private_data = NULL; 284 spin_lock(&i_mapping->private_lock);
285 i_mapping->private_data = NULL;
283 ctx->aio_ring_file = NULL; 286 ctx->aio_ring_file = NULL;
284 spin_unlock(&aio_ring_file->f_inode->i_mapping->private_lock); 287 spin_unlock(&i_mapping->private_lock);
285 288
286 fput(aio_ring_file); 289 fput(aio_ring_file);
287 } 290 }
diff --git a/fs/attr.c b/fs/attr.c
index 42bb42bb3c72..a19a64d41e7e 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -17,19 +17,22 @@
17#include <linux/ima.h> 17#include <linux/ima.h>
18 18
19/** 19/**
20 * inode_change_ok - check if attribute changes to an inode are allowed 20 * setattr_prepare - check if attribute changes to a dentry are allowed
21 * @inode: inode to check 21 * @dentry: dentry to check
22 * @attr: attributes to change 22 * @attr: attributes to change
23 * 23 *
24 * Check if we are allowed to change the attributes contained in @attr 24 * Check if we are allowed to change the attributes contained in @attr
25 * in the given inode. This includes the normal unix access permission 25 * in the given dentry. This includes the normal unix access permission
26 * checks, as well as checks for rlimits and others. 26 * checks, as well as checks for rlimits and others. The function also clears
27 * SGID bit from mode if user is not allowed to set it. Also file capabilities
28 * and IMA extended attributes are cleared if ATTR_KILL_PRIV is set.
27 * 29 *
28 * Should be called as the first thing in ->setattr implementations, 30 * Should be called as the first thing in ->setattr implementations,
29 * possibly after taking additional locks. 31 * possibly after taking additional locks.
30 */ 32 */
31int inode_change_ok(const struct inode *inode, struct iattr *attr) 33int setattr_prepare(struct dentry *dentry, struct iattr *attr)
32{ 34{
35 struct inode *inode = d_inode(dentry);
33 unsigned int ia_valid = attr->ia_valid; 36 unsigned int ia_valid = attr->ia_valid;
34 37
35 /* 38 /*
@@ -44,7 +47,7 @@ int inode_change_ok(const struct inode *inode, struct iattr *attr)
44 47
45 /* If force is set do it anyway. */ 48 /* If force is set do it anyway. */
46 if (ia_valid & ATTR_FORCE) 49 if (ia_valid & ATTR_FORCE)
47 return 0; 50 goto kill_priv;
48 51
49 /* Make sure a caller can chown. */ 52 /* Make sure a caller can chown. */
50 if ((ia_valid & ATTR_UID) && 53 if ((ia_valid & ATTR_UID) &&
@@ -77,9 +80,19 @@ int inode_change_ok(const struct inode *inode, struct iattr *attr)
77 return -EPERM; 80 return -EPERM;
78 } 81 }
79 82
83kill_priv:
84 /* User has permission for the change */
85 if (ia_valid & ATTR_KILL_PRIV) {
86 int error;
87
88 error = security_inode_killpriv(dentry);
89 if (error)
90 return error;
91 }
92
80 return 0; 93 return 0;
81} 94}
82EXPORT_SYMBOL(inode_change_ok); 95EXPORT_SYMBOL(setattr_prepare);
83 96
84/** 97/**
85 * inode_newsize_ok - may this inode be truncated to a given size 98 * inode_newsize_ok - may this inode be truncated to a given size
@@ -202,6 +215,21 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de
202 return -EPERM; 215 return -EPERM;
203 } 216 }
204 217
218 /*
219 * If utimes(2) and friends are called with times == NULL (or both
220 * times are UTIME_NOW), then we need to check for write permission
221 */
222 if (ia_valid & ATTR_TOUCH) {
223 if (IS_IMMUTABLE(inode))
224 return -EPERM;
225
226 if (!inode_owner_or_capable(inode)) {
227 error = inode_permission(inode, MAY_WRITE);
228 if (error)
229 return error;
230 }
231 }
232
205 if ((ia_valid & ATTR_MODE)) { 233 if ((ia_valid & ATTR_MODE)) {
206 umode_t amode = attr->ia_mode; 234 umode_t amode = attr->ia_mode;
207 /* Flag setting protected by i_mutex */ 235 /* Flag setting protected by i_mutex */
@@ -217,13 +245,11 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de
217 if (!(ia_valid & ATTR_MTIME_SET)) 245 if (!(ia_valid & ATTR_MTIME_SET))
218 attr->ia_mtime = now; 246 attr->ia_mtime = now;
219 if (ia_valid & ATTR_KILL_PRIV) { 247 if (ia_valid & ATTR_KILL_PRIV) {
220 attr->ia_valid &= ~ATTR_KILL_PRIV;
221 ia_valid &= ~ATTR_KILL_PRIV;
222 error = security_inode_need_killpriv(dentry); 248 error = security_inode_need_killpriv(dentry);
223 if (error > 0) 249 if (error < 0)
224 error = security_inode_killpriv(dentry);
225 if (error)
226 return error; 250 return error;
251 if (error == 0)
252 ia_valid = attr->ia_valid &= ~ATTR_KILL_PRIV;
227 } 253 }
228 254
229 /* 255 /*
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
index 53bb7af4e5f0..247b8dfaf6e5 100644
--- a/fs/btrfs/acl.c
+++ b/fs/btrfs/acl.c
@@ -79,11 +79,9 @@ static int __btrfs_set_acl(struct btrfs_trans_handle *trans,
79 case ACL_TYPE_ACCESS: 79 case ACL_TYPE_ACCESS:
80 name = XATTR_NAME_POSIX_ACL_ACCESS; 80 name = XATTR_NAME_POSIX_ACL_ACCESS;
81 if (acl) { 81 if (acl) {
82 ret = posix_acl_equiv_mode(acl, &inode->i_mode); 82 ret = posix_acl_update_mode(inode, &inode->i_mode, &acl);
83 if (ret < 0) 83 if (ret)
84 return ret; 84 return ret;
85 if (ret == 0)
86 acl = NULL;
87 } 85 }
88 ret = 0; 86 ret = 0;
89 break; 87 break;
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 33fe03551105..e62fd50237e4 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3161,7 +3161,6 @@ int btrfs_prealloc_file_range_trans(struct inode *inode,
3161 struct btrfs_trans_handle *trans, int mode, 3161 struct btrfs_trans_handle *trans, int mode,
3162 u64 start, u64 num_bytes, u64 min_size, 3162 u64 start, u64 num_bytes, u64 min_size,
3163 loff_t actual_len, u64 *alloc_hint); 3163 loff_t actual_len, u64 *alloc_hint);
3164int btrfs_inode_check_errors(struct inode *inode);
3165extern const struct dentry_operations btrfs_dentry_operations; 3164extern const struct dentry_operations btrfs_dentry_operations;
3166#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS 3165#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
3167void btrfs_test_inode_set_ops(struct inode *inode); 3166void btrfs_test_inode_set_ops(struct inode *inode);
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index fea31a4a6e36..4843cb994835 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2040,7 +2040,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
2040 * flags for any errors that might have happened while doing 2040 * flags for any errors that might have happened while doing
2041 * writeback of file data. 2041 * writeback of file data.
2042 */ 2042 */
2043 ret = btrfs_inode_check_errors(inode); 2043 ret = filemap_check_errors(inode->i_mapping);
2044 inode_unlock(inode); 2044 inode_unlock(inode);
2045 goto out; 2045 goto out;
2046 } 2046 }
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index ca01106795ea..92346a403a89 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5072,7 +5072,7 @@ static int btrfs_setattr(struct dentry *dentry, struct iattr *attr)
5072 if (btrfs_root_readonly(root)) 5072 if (btrfs_root_readonly(root))
5073 return -EROFS; 5073 return -EROFS;
5074 5074
5075 err = inode_change_ok(inode, attr); 5075 err = setattr_prepare(dentry, attr);
5076 if (err) 5076 if (err)
5077 return err; 5077 return err;
5078 5078
@@ -10544,21 +10544,6 @@ out_inode:
10544 10544
10545} 10545}
10546 10546
10547/* Inspired by filemap_check_errors() */
10548int btrfs_inode_check_errors(struct inode *inode)
10549{
10550 int ret = 0;
10551
10552 if (test_bit(AS_ENOSPC, &inode->i_mapping->flags) &&
10553 test_and_clear_bit(AS_ENOSPC, &inode->i_mapping->flags))
10554 ret = -ENOSPC;
10555 if (test_bit(AS_EIO, &inode->i_mapping->flags) &&
10556 test_and_clear_bit(AS_EIO, &inode->i_mapping->flags))
10557 ret = -EIO;
10558
10559 return ret;
10560}
10561
10562static const struct inode_operations btrfs_dir_inode_operations = { 10547static const struct inode_operations btrfs_dir_inode_operations = {
10563 .getattr = btrfs_getattr, 10548 .getattr = btrfs_getattr,
10564 .lookup = btrfs_lookup, 10549 .lookup = btrfs_lookup,
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index a87675ffd02b..1379e59277e2 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -4329,7 +4329,7 @@ static int __process_new_xattr(int num, struct btrfs_key *di_key,
4329 int ret; 4329 int ret;
4330 struct send_ctx *sctx = ctx; 4330 struct send_ctx *sctx = ctx;
4331 struct fs_path *p; 4331 struct fs_path *p;
4332 posix_acl_xattr_header dummy_acl; 4332 struct posix_acl_xattr_header dummy_acl;
4333 4333
4334 p = fs_path_alloc(); 4334 p = fs_path_alloc();
4335 if (!p) 4335 if (!p)
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index ef9c55bc7907..8a84ebd8e7cc 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3961,7 +3961,7 @@ static int wait_ordered_extents(struct btrfs_trans_handle *trans,
3961 * i_mapping flags, so that the next fsync won't get 3961 * i_mapping flags, so that the next fsync won't get
3962 * an outdated io error too. 3962 * an outdated io error too.
3963 */ 3963 */
3964 btrfs_inode_check_errors(inode); 3964 filemap_check_errors(inode->i_mapping);
3965 *ordered_io_error = true; 3965 *ordered_io_error = true;
3966 break; 3966 break;
3967 } 3967 }
@@ -4198,7 +4198,7 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
4198 * without writing to the log tree and the fsync must report the 4198 * without writing to the log tree and the fsync must report the
4199 * file data write error and not commit the current transaction. 4199 * file data write error and not commit the current transaction.
4200 */ 4200 */
4201 ret = btrfs_inode_check_errors(inode); 4201 ret = filemap_check_errors(inode->i_mapping);
4202 if (ret) 4202 if (ret)
4203 ctx->io_err = ret; 4203 ctx->io_err = ret;
4204process: 4204process:
diff --git a/fs/buffer.c b/fs/buffer.c
index 9c8eb9b6db6a..7dad8713fac8 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1078,7 +1078,7 @@ grow_buffers(struct block_device *bdev, sector_t block, int size, gfp_t gfp)
1078 return grow_dev_page(bdev, block, index, size, sizebits, gfp); 1078 return grow_dev_page(bdev, block, index, size, sizebits, gfp);
1079} 1079}
1080 1080
1081struct buffer_head * 1081static struct buffer_head *
1082__getblk_slow(struct block_device *bdev, sector_t block, 1082__getblk_slow(struct block_device *bdev, sector_t block,
1083 unsigned size, gfp_t gfp) 1083 unsigned size, gfp_t gfp)
1084{ 1084{
@@ -1109,7 +1109,6 @@ __getblk_slow(struct block_device *bdev, sector_t block,
1109 free_more_memory(); 1109 free_more_memory();
1110 } 1110 }
1111} 1111}
1112EXPORT_SYMBOL(__getblk_slow);
1113 1112
1114/* 1113/*
1115 * The relationship between dirty buffers and dirty pages: 1114 * The relationship between dirty buffers and dirty pages:
diff --git a/fs/cachefiles/interface.c b/fs/cachefiles/interface.c
index ce5f345d70f5..e7f16a77a22a 100644
--- a/fs/cachefiles/interface.c
+++ b/fs/cachefiles/interface.c
@@ -253,6 +253,8 @@ static void cachefiles_drop_object(struct fscache_object *_object)
253 struct cachefiles_object *object; 253 struct cachefiles_object *object;
254 struct cachefiles_cache *cache; 254 struct cachefiles_cache *cache;
255 const struct cred *saved_cred; 255 const struct cred *saved_cred;
256 struct inode *inode;
257 blkcnt_t i_blocks = 0;
256 258
257 ASSERT(_object); 259 ASSERT(_object);
258 260
@@ -279,6 +281,10 @@ static void cachefiles_drop_object(struct fscache_object *_object)
279 _object != cache->cache.fsdef 281 _object != cache->cache.fsdef
280 ) { 282 ) {
281 _debug("- retire object OBJ%x", object->fscache.debug_id); 283 _debug("- retire object OBJ%x", object->fscache.debug_id);
284 inode = d_backing_inode(object->dentry);
285 if (inode)
286 i_blocks = inode->i_blocks;
287
282 cachefiles_begin_secure(cache, &saved_cred); 288 cachefiles_begin_secure(cache, &saved_cred);
283 cachefiles_delete_object(cache, object); 289 cachefiles_delete_object(cache, object);
284 cachefiles_end_secure(cache, saved_cred); 290 cachefiles_end_secure(cache, saved_cred);
@@ -292,7 +298,7 @@ static void cachefiles_drop_object(struct fscache_object *_object)
292 298
293 /* note that the object is now inactive */ 299 /* note that the object is now inactive */
294 if (test_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags)) 300 if (test_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags))
295 cachefiles_mark_object_inactive(cache, object); 301 cachefiles_mark_object_inactive(cache, object, i_blocks);
296 302
297 dput(object->dentry); 303 dput(object->dentry);
298 object->dentry = NULL; 304 object->dentry = NULL;
diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
index 2fcde1a34b7c..cd1effee8a49 100644
--- a/fs/cachefiles/internal.h
+++ b/fs/cachefiles/internal.h
@@ -160,7 +160,8 @@ extern char *cachefiles_cook_key(const u8 *raw, int keylen, uint8_t type);
160 * namei.c 160 * namei.c
161 */ 161 */
162extern void cachefiles_mark_object_inactive(struct cachefiles_cache *cache, 162extern void cachefiles_mark_object_inactive(struct cachefiles_cache *cache,
163 struct cachefiles_object *object); 163 struct cachefiles_object *object,
164 blkcnt_t i_blocks);
164extern int cachefiles_delete_object(struct cachefiles_cache *cache, 165extern int cachefiles_delete_object(struct cachefiles_cache *cache,
165 struct cachefiles_object *object); 166 struct cachefiles_object *object);
166extern int cachefiles_walk_to_object(struct cachefiles_object *parent, 167extern int cachefiles_walk_to_object(struct cachefiles_object *parent,
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
index 3f7c2cd41f8f..c6ee4b5fb7e6 100644
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -261,10 +261,9 @@ requeue:
261 * Mark an object as being inactive. 261 * Mark an object as being inactive.
262 */ 262 */
263void cachefiles_mark_object_inactive(struct cachefiles_cache *cache, 263void cachefiles_mark_object_inactive(struct cachefiles_cache *cache,
264 struct cachefiles_object *object) 264 struct cachefiles_object *object,
265 blkcnt_t i_blocks)
265{ 266{
266 blkcnt_t i_blocks = d_backing_inode(object->dentry)->i_blocks;
267
268 write_lock(&cache->active_lock); 267 write_lock(&cache->active_lock);
269 rb_erase(&object->active_node, &cache->active_nodes); 268 rb_erase(&object->active_node, &cache->active_nodes);
270 clear_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags); 269 clear_bit(CACHEFILES_OBJECT_ACTIVE, &object->flags);
@@ -707,7 +706,8 @@ mark_active_timed_out:
707 706
708check_error: 707check_error:
709 _debug("check error %d", ret); 708 _debug("check error %d", ret);
710 cachefiles_mark_object_inactive(cache, object); 709 cachefiles_mark_object_inactive(
710 cache, object, d_backing_inode(object->dentry)->i_blocks);
711release_dentry: 711release_dentry:
712 dput(object->dentry); 712 dput(object->dentry);
713 object->dentry = NULL; 713 object->dentry = NULL;
diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c
index 4f67227f69a5..987044bca1c2 100644
--- a/fs/ceph/acl.c
+++ b/fs/ceph/acl.c
@@ -95,11 +95,9 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)
95 case ACL_TYPE_ACCESS: 95 case ACL_TYPE_ACCESS:
96 name = XATTR_NAME_POSIX_ACL_ACCESS; 96 name = XATTR_NAME_POSIX_ACL_ACCESS;
97 if (acl) { 97 if (acl) {
98 ret = posix_acl_equiv_mode(acl, &new_mode); 98 ret = posix_acl_update_mode(inode, &new_mode, &acl);
99 if (ret < 0) 99 if (ret)
100 goto out; 100 goto out;
101 if (ret == 0)
102 acl = NULL;
103 } 101 }
104 break; 102 break;
105 case ACL_TYPE_DEFAULT: 103 case ACL_TYPE_DEFAULT:
@@ -127,6 +125,11 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)
127 goto out_free; 125 goto out_free;
128 } 126 }
129 127
128 if (ceph_snap(inode) != CEPH_NOSNAP) {
129 ret = -EROFS;
130 goto out_free;
131 }
132
130 if (new_mode != old_mode) { 133 if (new_mode != old_mode) {
131 newattrs.ia_mode = new_mode; 134 newattrs.ia_mode = new_mode;
132 newattrs.ia_valid = ATTR_MODE; 135 newattrs.ia_valid = ATTR_MODE;
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index dd3a6dbf71eb..082e82dcbaa4 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1905,13 +1905,6 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr)
1905 int inode_dirty_flags = 0; 1905 int inode_dirty_flags = 0;
1906 bool lock_snap_rwsem = false; 1906 bool lock_snap_rwsem = false;
1907 1907
1908 if (ceph_snap(inode) != CEPH_NOSNAP)
1909 return -EROFS;
1910
1911 err = inode_change_ok(inode, attr);
1912 if (err != 0)
1913 return err;
1914
1915 prealloc_cf = ceph_alloc_cap_flush(); 1908 prealloc_cf = ceph_alloc_cap_flush();
1916 if (!prealloc_cf) 1909 if (!prealloc_cf)
1917 return -ENOMEM; 1910 return -ENOMEM;
@@ -2124,7 +2117,17 @@ out_put:
2124 */ 2117 */
2125int ceph_setattr(struct dentry *dentry, struct iattr *attr) 2118int ceph_setattr(struct dentry *dentry, struct iattr *attr)
2126{ 2119{
2127 return __ceph_setattr(d_inode(dentry), attr); 2120 struct inode *inode = d_inode(dentry);
2121 int err;
2122
2123 if (ceph_snap(inode) != CEPH_NOSNAP)
2124 return -EROFS;
2125
2126 err = setattr_prepare(dentry, attr);
2127 if (err != 0)
2128 return err;
2129
2130 return __ceph_setattr(inode, attr);
2128} 2131}
2129 2132
2130/* 2133/*
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index 9dcf974acc47..c9c00a862036 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -41,6 +41,16 @@ cifs_uniqueid_to_ino_t(u64 fileid)
41 41
42} 42}
43 43
44static inline void cifs_set_time(struct dentry *dentry, unsigned long time)
45{
46 dentry->d_fsdata = (void *) time;
47}
48
49static inline unsigned long cifs_get_time(struct dentry *dentry)
50{
51 return (unsigned long) dentry->d_fsdata;
52}
53
44extern struct file_system_type cifs_fs_type; 54extern struct file_system_type cifs_fs_type;
45extern const struct address_space_operations cifs_addr_ops; 55extern const struct address_space_operations cifs_addr_ops;
46extern const struct address_space_operations cifs_addr_ops_smallbuf; 56extern const struct address_space_operations cifs_addr_ops_smallbuf;
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 95dab43646f0..4ead72a001f9 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -392,8 +392,7 @@ extern int CIFSSMBRead(const unsigned int xid, struct cifs_io_parms *io_parms,
392 unsigned int *nbytes, char **buf, 392 unsigned int *nbytes, char **buf,
393 int *return_buf_type); 393 int *return_buf_type);
394extern int CIFSSMBWrite(const unsigned int xid, struct cifs_io_parms *io_parms, 394extern int CIFSSMBWrite(const unsigned int xid, struct cifs_io_parms *io_parms,
395 unsigned int *nbytes, const char *buf, 395 unsigned int *nbytes, const char *buf);
396 const char __user *ubuf, const int long_op);
397extern int CIFSSMBWrite2(const unsigned int xid, struct cifs_io_parms *io_parms, 396extern int CIFSSMBWrite2(const unsigned int xid, struct cifs_io_parms *io_parms,
398 unsigned int *nbytes, struct kvec *iov, const int nvec); 397 unsigned int *nbytes, struct kvec *iov, const int nvec);
399extern int CIFSGetSrvInodeNumber(const unsigned int xid, struct cifs_tcon *tcon, 398extern int CIFSGetSrvInodeNumber(const unsigned int xid, struct cifs_tcon *tcon,
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index d47197ea4ab6..f82d2823622f 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -1228,7 +1228,6 @@ OldOpenRetry:
1228 inc_rfc1001_len(pSMB, count); 1228 inc_rfc1001_len(pSMB, count);
1229 1229
1230 pSMB->ByteCount = cpu_to_le16(count); 1230 pSMB->ByteCount = cpu_to_le16(count);
1231 /* long_op set to 1 to allow for oplock break timeouts */
1232 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 1231 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
1233 (struct smb_hdr *)pSMBr, &bytes_returned, 0); 1232 (struct smb_hdr *)pSMBr, &bytes_returned, 0);
1234 cifs_stats_inc(&tcon->stats.cifs_stats.num_opens); 1233 cifs_stats_inc(&tcon->stats.cifs_stats.num_opens);
@@ -1768,8 +1767,7 @@ CIFSSMBRead(const unsigned int xid, struct cifs_io_parms *io_parms,
1768 1767
1769int 1768int
1770CIFSSMBWrite(const unsigned int xid, struct cifs_io_parms *io_parms, 1769CIFSSMBWrite(const unsigned int xid, struct cifs_io_parms *io_parms,
1771 unsigned int *nbytes, const char *buf, 1770 unsigned int *nbytes, const char *buf)
1772 const char __user *ubuf, const int long_op)
1773{ 1771{
1774 int rc = -EACCES; 1772 int rc = -EACCES;
1775 WRITE_REQ *pSMB = NULL; 1773 WRITE_REQ *pSMB = NULL;
@@ -1838,12 +1836,7 @@ CIFSSMBWrite(const unsigned int xid, struct cifs_io_parms *io_parms,
1838 cpu_to_le16(offsetof(struct smb_com_write_req, Data) - 4); 1836 cpu_to_le16(offsetof(struct smb_com_write_req, Data) - 4);
1839 if (buf) 1837 if (buf)
1840 memcpy(pSMB->Data, buf, bytes_sent); 1838 memcpy(pSMB->Data, buf, bytes_sent);
1841 else if (ubuf) { 1839 else if (count != 0) {
1842 if (copy_from_user(pSMB->Data, ubuf, bytes_sent)) {
1843 cifs_buf_release(pSMB);
1844 return -EFAULT;
1845 }
1846 } else if (count != 0) {
1847 /* No buffer */ 1840 /* No buffer */
1848 cifs_buf_release(pSMB); 1841 cifs_buf_release(pSMB);
1849 return -EINVAL; 1842 return -EINVAL;
@@ -1867,7 +1860,7 @@ CIFSSMBWrite(const unsigned int xid, struct cifs_io_parms *io_parms,
1867 } 1860 }
1868 1861
1869 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, 1862 rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
1870 (struct smb_hdr *) pSMBr, &bytes_returned, long_op); 1863 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
1871 cifs_stats_inc(&tcon->stats.cifs_stats.num_writes); 1864 cifs_stats_inc(&tcon->stats.cifs_stats.num_writes);
1872 if (rc) { 1865 if (rc) {
1873 cifs_dbg(FYI, "Send error in write = %d\n", rc); 1866 cifs_dbg(FYI, "Send error in write = %d\n", rc);
@@ -3334,7 +3327,7 @@ CIFSSMB_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
3334#ifdef CONFIG_CIFS_POSIX 3327#ifdef CONFIG_CIFS_POSIX
3335 3328
3336/*Convert an Access Control Entry from wire format to local POSIX xattr format*/ 3329/*Convert an Access Control Entry from wire format to local POSIX xattr format*/
3337static void cifs_convert_ace(posix_acl_xattr_entry *ace, 3330static void cifs_convert_ace(struct posix_acl_xattr_entry *ace,
3338 struct cifs_posix_ace *cifs_ace) 3331 struct cifs_posix_ace *cifs_ace)
3339{ 3332{
3340 /* u8 cifs fields do not need le conversion */ 3333 /* u8 cifs fields do not need le conversion */
@@ -3358,7 +3351,7 @@ static int cifs_copy_posix_acl(char *trgt, char *src, const int buflen,
3358 __u16 count; 3351 __u16 count;
3359 struct cifs_posix_ace *pACE; 3352 struct cifs_posix_ace *pACE;
3360 struct cifs_posix_acl *cifs_acl = (struct cifs_posix_acl *)src; 3353 struct cifs_posix_acl *cifs_acl = (struct cifs_posix_acl *)src;
3361 posix_acl_xattr_header *local_acl = (posix_acl_xattr_header *)trgt; 3354 struct posix_acl_xattr_header *local_acl = (void *)trgt;
3362 3355
3363 if (le16_to_cpu(cifs_acl->version) != CIFS_ACL_VERSION) 3356 if (le16_to_cpu(cifs_acl->version) != CIFS_ACL_VERSION)
3364 return -EOPNOTSUPP; 3357 return -EOPNOTSUPP;
@@ -3396,9 +3389,11 @@ static int cifs_copy_posix_acl(char *trgt, char *src, const int buflen,
3396 } else if (size > buflen) { 3389 } else if (size > buflen) {
3397 return -ERANGE; 3390 return -ERANGE;
3398 } else /* buffer big enough */ { 3391 } else /* buffer big enough */ {
3392 struct posix_acl_xattr_entry *ace = (void *)(local_acl + 1);
3393
3399 local_acl->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION); 3394 local_acl->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION);
3400 for (i = 0; i < count ; i++) { 3395 for (i = 0; i < count ; i++) {
3401 cifs_convert_ace(&local_acl->a_entries[i], pACE); 3396 cifs_convert_ace(&ace[i], pACE);
3402 pACE++; 3397 pACE++;
3403 } 3398 }
3404 } 3399 }
@@ -3406,7 +3401,7 @@ static int cifs_copy_posix_acl(char *trgt, char *src, const int buflen,
3406} 3401}
3407 3402
3408static __u16 convert_ace_to_cifs_ace(struct cifs_posix_ace *cifs_ace, 3403static __u16 convert_ace_to_cifs_ace(struct cifs_posix_ace *cifs_ace,
3409 const posix_acl_xattr_entry *local_ace) 3404 const struct posix_acl_xattr_entry *local_ace)
3410{ 3405{
3411 __u16 rc = 0; /* 0 = ACL converted ok */ 3406 __u16 rc = 0; /* 0 = ACL converted ok */
3412 3407
@@ -3431,7 +3426,7 @@ static __u16 ACL_to_cifs_posix(char *parm_data, const char *pACL,
3431{ 3426{
3432 __u16 rc = 0; 3427 __u16 rc = 0;
3433 struct cifs_posix_acl *cifs_acl = (struct cifs_posix_acl *)parm_data; 3428 struct cifs_posix_acl *cifs_acl = (struct cifs_posix_acl *)parm_data;
3434 posix_acl_xattr_header *local_acl = (posix_acl_xattr_header *)pACL; 3429 struct posix_acl_xattr_header *local_acl = (void *)pACL;
3435 int count; 3430 int count;
3436 int i; 3431 int i;
3437 3432
@@ -3459,7 +3454,7 @@ static __u16 ACL_to_cifs_posix(char *parm_data, const char *pACL,
3459 } 3454 }
3460 for (i = 0; i < count; i++) { 3455 for (i = 0; i < count; i++) {
3461 rc = convert_ace_to_cifs_ace(&cifs_acl->ace_array[i], 3456 rc = convert_ace_to_cifs_ace(&cifs_acl->ace_array[i],
3462 &local_acl->a_entries[i]); 3457 (struct posix_acl_xattr_entry *)(local_acl + 1));
3463 if (rc != 0) { 3458 if (rc != 0) {
3464 /* ACE not converted */ 3459 /* ACE not converted */
3465 break; 3460 break;
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 4716c54dbfc6..789ff1df2d8d 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -40,7 +40,7 @@ renew_parental_timestamps(struct dentry *direntry)
40 /* BB check if there is a way to get the kernel to do this or if we 40 /* BB check if there is a way to get the kernel to do this or if we
41 really need this */ 41 really need this */
42 do { 42 do {
43 direntry->d_time = jiffies; 43 cifs_set_time(direntry, jiffies);
44 direntry = direntry->d_parent; 44 direntry = direntry->d_parent;
45 } while (!IS_ROOT(direntry)); 45 } while (!IS_ROOT(direntry));
46} 46}
@@ -802,7 +802,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
802 802
803 } else if (rc == -ENOENT) { 803 } else if (rc == -ENOENT) {
804 rc = 0; 804 rc = 0;
805 direntry->d_time = jiffies; 805 cifs_set_time(direntry, jiffies);
806 d_add(direntry, NULL); 806 d_add(direntry, NULL);
807 /* if it was once a directory (but how can we tell?) we could do 807 /* if it was once a directory (but how can we tell?) we could do
808 shrink_dcache_parent(direntry); */ 808 shrink_dcache_parent(direntry); */
@@ -862,7 +862,7 @@ cifs_d_revalidate(struct dentry *direntry, unsigned int flags)
862 if (flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET)) 862 if (flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET))
863 return 0; 863 return 0;
864 864
865 if (time_after(jiffies, direntry->d_time + HZ) || !lookupCacheEnabled) 865 if (time_after(jiffies, cifs_get_time(direntry) + HZ) || !lookupCacheEnabled)
866 return 0; 866 return 0;
867 867
868 return 1; 868 return 1;
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 579e41b350a2..42b99af74e0a 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2478,7 +2478,7 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from,
2478 size_t cur_len; 2478 size_t cur_len;
2479 unsigned long nr_pages, num_pages, i; 2479 unsigned long nr_pages, num_pages, i;
2480 struct cifs_writedata *wdata; 2480 struct cifs_writedata *wdata;
2481 struct iov_iter saved_from; 2481 struct iov_iter saved_from = *from;
2482 loff_t saved_offset = offset; 2482 loff_t saved_offset = offset;
2483 pid_t pid; 2483 pid_t pid;
2484 struct TCP_Server_Info *server; 2484 struct TCP_Server_Info *server;
@@ -2489,7 +2489,6 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from,
2489 pid = current->tgid; 2489 pid = current->tgid;
2490 2490
2491 server = tlink_tcon(open_file->tlink)->ses->server; 2491 server = tlink_tcon(open_file->tlink)->ses->server;
2492 memcpy(&saved_from, from, sizeof(struct iov_iter));
2493 2492
2494 do { 2493 do {
2495 unsigned int wsize, credits; 2494 unsigned int wsize, credits;
@@ -2551,8 +2550,7 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from,
2551 kref_put(&wdata->refcount, 2550 kref_put(&wdata->refcount,
2552 cifs_uncached_writedata_release); 2551 cifs_uncached_writedata_release);
2553 if (rc == -EAGAIN) { 2552 if (rc == -EAGAIN) {
2554 memcpy(from, &saved_from, 2553 *from = saved_from;
2555 sizeof(struct iov_iter));
2556 iov_iter_advance(from, offset - saved_offset); 2554 iov_iter_advance(from, offset - saved_offset);
2557 continue; 2555 continue;
2558 } 2556 }
@@ -2576,7 +2574,7 @@ ssize_t cifs_user_writev(struct kiocb *iocb, struct iov_iter *from)
2576 struct cifs_sb_info *cifs_sb; 2574 struct cifs_sb_info *cifs_sb;
2577 struct cifs_writedata *wdata, *tmp; 2575 struct cifs_writedata *wdata, *tmp;
2578 struct list_head wdata_list; 2576 struct list_head wdata_list;
2579 struct iov_iter saved_from; 2577 struct iov_iter saved_from = *from;
2580 int rc; 2578 int rc;
2581 2579
2582 /* 2580 /*
@@ -2597,8 +2595,6 @@ ssize_t cifs_user_writev(struct kiocb *iocb, struct iov_iter *from)
2597 if (!tcon->ses->server->ops->async_writev) 2595 if (!tcon->ses->server->ops->async_writev)
2598 return -ENOSYS; 2596 return -ENOSYS;
2599 2597
2600 memcpy(&saved_from, from, sizeof(struct iov_iter));
2601
2602 rc = cifs_write_from_iter(iocb->ki_pos, iov_iter_count(from), from, 2598 rc = cifs_write_from_iter(iocb->ki_pos, iov_iter_count(from), from,
2603 open_file, cifs_sb, &wdata_list); 2599 open_file, cifs_sb, &wdata_list);
2604 2600
@@ -2631,13 +2627,11 @@ restart_loop:
2631 /* resend call if it's a retryable error */ 2627 /* resend call if it's a retryable error */
2632 if (rc == -EAGAIN) { 2628 if (rc == -EAGAIN) {
2633 struct list_head tmp_list; 2629 struct list_head tmp_list;
2634 struct iov_iter tmp_from; 2630 struct iov_iter tmp_from = saved_from;
2635 2631
2636 INIT_LIST_HEAD(&tmp_list); 2632 INIT_LIST_HEAD(&tmp_list);
2637 list_del_init(&wdata->list); 2633 list_del_init(&wdata->list);
2638 2634
2639 memcpy(&tmp_from, &saved_from,
2640 sizeof(struct iov_iter));
2641 iov_iter_advance(&tmp_from, 2635 iov_iter_advance(&tmp_from,
2642 wdata->offset - iocb->ki_pos); 2636 wdata->offset - iocb->ki_pos);
2643 2637
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index b87efd0c92d6..7ab5be7944aa 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -1951,7 +1951,7 @@ int cifs_revalidate_dentry_attr(struct dentry *dentry)
1951 1951
1952 cifs_dbg(FYI, "Update attributes: %s inode 0x%p count %d dentry: 0x%p d_time %ld jiffies %ld\n", 1952 cifs_dbg(FYI, "Update attributes: %s inode 0x%p count %d dentry: 0x%p d_time %ld jiffies %ld\n",
1953 full_path, inode, inode->i_count.counter, 1953 full_path, inode, inode->i_count.counter,
1954 dentry, dentry->d_time, jiffies); 1954 dentry, cifs_get_time(dentry), jiffies);
1955 1955
1956 if (cifs_sb_master_tcon(CIFS_SB(sb))->unix_ext) 1956 if (cifs_sb_master_tcon(CIFS_SB(sb))->unix_ext)
1957 rc = cifs_get_inode_info_unix(&inode, full_path, sb, xid); 1957 rc = cifs_get_inode_info_unix(&inode, full_path, sb, xid);
@@ -2154,7 +2154,7 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
2154 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) 2154 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
2155 attrs->ia_valid |= ATTR_FORCE; 2155 attrs->ia_valid |= ATTR_FORCE;
2156 2156
2157 rc = inode_change_ok(inode, attrs); 2157 rc = setattr_prepare(direntry, attrs);
2158 if (rc < 0) 2158 if (rc < 0)
2159 goto out; 2159 goto out;
2160 2160
@@ -2294,7 +2294,7 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
2294 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) 2294 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
2295 attrs->ia_valid |= ATTR_FORCE; 2295 attrs->ia_valid |= ATTR_FORCE;
2296 2296
2297 rc = inode_change_ok(inode, attrs); 2297 rc = setattr_prepare(direntry, attrs);
2298 if (rc < 0) { 2298 if (rc < 0) {
2299 free_xid(xid); 2299 free_xid(xid);
2300 return rc; 2300 return rc;
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index 062c2375549a..d031af8d3d4d 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -399,7 +399,7 @@ cifs_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
399 io_parms.offset = 0; 399 io_parms.offset = 0;
400 io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE; 400 io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE;
401 401
402 rc = CIFSSMBWrite(xid, &io_parms, pbytes_written, pbuf, NULL, 0); 402 rc = CIFSSMBWrite(xid, &io_parms, pbytes_written, pbuf);
403 CIFSSMBClose(xid, tcon, fid.netfid); 403 CIFSSMBClose(xid, tcon, fid.netfid);
404 return rc; 404 return rc;
405} 405}
diff --git a/fs/compat.c b/fs/compat.c
index be6e48b0a46c..bd064a2c3550 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -54,20 +54,6 @@
54#include <asm/ioctls.h> 54#include <asm/ioctls.h>
55#include "internal.h" 55#include "internal.h"
56 56
57int compat_log = 1;
58
59int compat_printk(const char *fmt, ...)
60{
61 va_list ap;
62 int ret;
63 if (!compat_log)
64 return 0;
65 va_start(ap, fmt);
66 ret = vprintk(fmt, ap);
67 va_end(ap);
68 return ret;
69}
70
71/* 57/*
72 * Not all architectures have sys_utime, so implement this in terms 58 * Not all architectures have sys_utime, so implement this in terms
73 * of sys_utimes. 59 * of sys_utimes.
@@ -562,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
562 goto out; 548 goto out;
563 549
564 ret = -EINVAL; 550 ret = -EINVAL;
565 if (nr_segs > UIO_MAXIOV || nr_segs < 0) 551 if (nr_segs > UIO_MAXIOV)
566 goto out; 552 goto out;
567 if (nr_segs > fast_segs) { 553 if (nr_segs > fast_segs) {
568 ret = -ENOMEM; 554 ret = -ENOMEM;
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 9d153b6a1d72..5ffba186f352 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -927,7 +927,7 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)
927 } 927 }
928 mutex_unlock(&crypt_stat->cs_mutex); 928 mutex_unlock(&crypt_stat->cs_mutex);
929 929
930 rc = inode_change_ok(inode, ia); 930 rc = setattr_prepare(dentry, ia);
931 if (rc) 931 if (rc)
932 goto out; 932 goto out;
933 if (ia->ia_valid & ATTR_SIZE) { 933 if (ia->ia_valid & ATTR_SIZE) {
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
index 9dc4c6dbf3c9..5e68daee5fe4 100644
--- a/fs/exofs/inode.c
+++ b/fs/exofs/inode.c
@@ -1034,7 +1034,7 @@ int exofs_setattr(struct dentry *dentry, struct iattr *iattr)
1034 if (unlikely(error)) 1034 if (unlikely(error))
1035 return error; 1035 return error;
1036 1036
1037 error = inode_change_ok(inode, iattr); 1037 error = setattr_prepare(dentry, iattr);
1038 if (unlikely(error)) 1038 if (unlikely(error))
1039 return error; 1039 return error;
1040 1040
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index 42f1d1814083..e725aa0890e0 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -190,15 +190,11 @@ ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
190 case ACL_TYPE_ACCESS: 190 case ACL_TYPE_ACCESS:
191 name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS; 191 name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS;
192 if (acl) { 192 if (acl) {
193 error = posix_acl_equiv_mode(acl, &inode->i_mode); 193 error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
194 if (error < 0) 194 if (error)
195 return error; 195 return error;
196 else { 196 inode->i_ctime = CURRENT_TIME_SEC;
197 inode->i_ctime = CURRENT_TIME_SEC; 197 mark_inode_dirty(inode);
198 mark_inode_dirty(inode);
199 if (error == 0)
200 acl = NULL;
201 }
202 } 198 }
203 break; 199 break;
204 200
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 1e72d425fd3b..6831534924e1 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -1652,7 +1652,7 @@ int ext2_setattr(struct dentry *dentry, struct iattr *iattr)
1652 struct inode *inode = d_inode(dentry); 1652 struct inode *inode = d_inode(dentry);
1653 int error; 1653 int error;
1654 1654
1655 error = inode_change_ok(inode, iattr); 1655 error = setattr_prepare(dentry, iattr);
1656 if (error) 1656 if (error)
1657 return error; 1657 return error;
1658 1658
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index c6601a476c02..dfa519979038 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -193,15 +193,11 @@ __ext4_set_acl(handle_t *handle, struct inode *inode, int type,
193 case ACL_TYPE_ACCESS: 193 case ACL_TYPE_ACCESS:
194 name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS; 194 name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS;
195 if (acl) { 195 if (acl) {
196 error = posix_acl_equiv_mode(acl, &inode->i_mode); 196 error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
197 if (error < 0) 197 if (error)
198 return error; 198 return error;
199 else { 199 inode->i_ctime = ext4_current_time(inode);
200 inode->i_ctime = ext4_current_time(inode); 200 ext4_mark_inode_dirty(handle, inode);
201 ext4_mark_inode_dirty(handle, inode);
202 if (error == 0)
203 acl = NULL;
204 }
205 } 201 }
206 break; 202 break;
207 203
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index cd918823b352..9c064727ed62 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5078,7 +5078,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
5078 int orphan = 0; 5078 int orphan = 0;
5079 const unsigned int ia_valid = attr->ia_valid; 5079 const unsigned int ia_valid = attr->ia_valid;
5080 5080
5081 error = inode_change_ok(inode, attr); 5081 error = setattr_prepare(dentry, attr);
5082 if (error) 5082 if (error)
5083 return error; 5083 return error;
5084 5084
diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
index 1e29630f49c1..6fe23af509e1 100644
--- a/fs/f2fs/acl.c
+++ b/fs/f2fs/acl.c
@@ -212,12 +212,10 @@ static int __f2fs_set_acl(struct inode *inode, int type,
212 case ACL_TYPE_ACCESS: 212 case ACL_TYPE_ACCESS:
213 name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS; 213 name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS;
214 if (acl) { 214 if (acl) {
215 error = posix_acl_equiv_mode(acl, &inode->i_mode); 215 error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
216 if (error < 0) 216 if (error)
217 return error; 217 return error;
218 set_acl_inode(inode, inode->i_mode); 218 set_acl_inode(inode, inode->i_mode);
219 if (error == 0)
220 acl = NULL;
221 } 219 }
222 break; 220 break;
223 221
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index f8b4fe05385d..90455974c2ae 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -680,7 +680,7 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
680 struct inode *inode = d_inode(dentry); 680 struct inode *inode = d_inode(dentry);
681 int err; 681 int err;
682 682
683 err = inode_change_ok(inode, attr); 683 err = setattr_prepare(dentry, attr);
684 if (err) 684 if (err)
685 return err; 685 return err;
686 686
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 883103593f33..01177ecdeab8 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1525,7 +1525,7 @@ int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino)
1525{ 1525{
1526 pgoff_t index = 0, end = ULONG_MAX; 1526 pgoff_t index = 0, end = ULONG_MAX;
1527 struct pagevec pvec; 1527 struct pagevec pvec;
1528 int ret2 = 0, ret = 0; 1528 int ret2, ret = 0;
1529 1529
1530 pagevec_init(&pvec, 0); 1530 pagevec_init(&pvec, 0);
1531 1531
@@ -1554,10 +1554,7 @@ int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino)
1554 cond_resched(); 1554 cond_resched();
1555 } 1555 }
1556 1556
1557 if (unlikely(test_and_clear_bit(AS_ENOSPC, &NODE_MAPPING(sbi)->flags))) 1557 ret2 = filemap_check_errors(NODE_MAPPING(sbi));
1558 ret2 = -ENOSPC;
1559 if (unlikely(test_and_clear_bit(AS_EIO, &NODE_MAPPING(sbi)->flags)))
1560 ret2 = -EIO;
1561 if (!ret) 1558 if (!ret)
1562 ret = ret2; 1559 ret = ret2;
1563 return ret; 1560 return ret;
diff --git a/fs/fat/file.c b/fs/fat/file.c
index f70185668832..c09ab4e108e5 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -450,7 +450,7 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr)
450 attr->ia_valid &= ~TIMES_SET_FLAGS; 450 attr->ia_valid &= ~TIMES_SET_FLAGS;
451 } 451 }
452 452
453 error = inode_change_ok(inode, attr); 453 error = setattr_prepare(dentry, attr);
454 attr->ia_valid = ia_valid; 454 attr->ia_valid = ia_valid;
455 if (error) { 455 if (error) {
456 if (sbi->options.quiet) 456 if (sbi->options.quiet)
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index 92b7363dafa9..4afdc3f36470 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -21,6 +21,17 @@
21#include <linux/namei.h> 21#include <linux/namei.h>
22#include "fat.h" 22#include "fat.h"
23 23
24static inline unsigned long vfat_d_version(struct dentry *dentry)
25{
26 return (unsigned long) dentry->d_fsdata;
27}
28
29static inline void vfat_d_version_set(struct dentry *dentry,
30 unsigned long version)
31{
32 dentry->d_fsdata = (void *) version;
33}
34
24/* 35/*
25 * If new entry was created in the parent, it could create the 8.3 36 * If new entry was created in the parent, it could create the 8.3
26 * alias (the shortname of logname). So, the parent may have the 37 * alias (the shortname of logname). So, the parent may have the
@@ -33,7 +44,7 @@ static int vfat_revalidate_shortname(struct dentry *dentry)
33{ 44{
34 int ret = 1; 45 int ret = 1;
35 spin_lock(&dentry->d_lock); 46 spin_lock(&dentry->d_lock);
36 if (dentry->d_time != d_inode(dentry->d_parent)->i_version) 47 if (vfat_d_version(dentry) != d_inode(dentry->d_parent)->i_version)
37 ret = 0; 48 ret = 0;
38 spin_unlock(&dentry->d_lock); 49 spin_unlock(&dentry->d_lock);
39 return ret; 50 return ret;
@@ -759,7 +770,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
759out: 770out:
760 mutex_unlock(&MSDOS_SB(sb)->s_lock); 771 mutex_unlock(&MSDOS_SB(sb)->s_lock);
761 if (!inode) 772 if (!inode)
762 dentry->d_time = dir->i_version; 773 vfat_d_version_set(dentry, dir->i_version);
763 return d_splice_alias(inode, dentry); 774 return d_splice_alias(inode, dentry);
764error: 775error:
765 mutex_unlock(&MSDOS_SB(sb)->s_lock); 776 mutex_unlock(&MSDOS_SB(sb)->s_lock);
@@ -823,7 +834,7 @@ static int vfat_rmdir(struct inode *dir, struct dentry *dentry)
823 clear_nlink(inode); 834 clear_nlink(inode);
824 inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; 835 inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
825 fat_detach(inode); 836 fat_detach(inode);
826 dentry->d_time = dir->i_version; 837 vfat_d_version_set(dentry, dir->i_version);
827out: 838out:
828 mutex_unlock(&MSDOS_SB(sb)->s_lock); 839 mutex_unlock(&MSDOS_SB(sb)->s_lock);
829 840
@@ -849,7 +860,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry)
849 clear_nlink(inode); 860 clear_nlink(inode);
850 inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; 861 inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
851 fat_detach(inode); 862 fat_detach(inode);
852 dentry->d_time = dir->i_version; 863 vfat_d_version_set(dentry, dir->i_version);
853out: 864out:
854 mutex_unlock(&MSDOS_SB(sb)->s_lock); 865 mutex_unlock(&MSDOS_SB(sb)->s_lock);
855 866
diff --git a/fs/file.c b/fs/file.c
index 6b1acdfe59da..69d6990e3021 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -23,12 +23,12 @@
23#include <linux/rcupdate.h> 23#include <linux/rcupdate.h>
24#include <linux/workqueue.h> 24#include <linux/workqueue.h>
25 25
26int sysctl_nr_open __read_mostly = 1024*1024; 26unsigned int sysctl_nr_open __read_mostly = 1024*1024;
27int sysctl_nr_open_min = BITS_PER_LONG; 27unsigned int sysctl_nr_open_min = BITS_PER_LONG;
28/* our min() is unusable in constant expressions ;-/ */ 28/* our min() is unusable in constant expressions ;-/ */
29#define __const_min(x, y) ((x) < (y) ? (x) : (y)) 29#define __const_min(x, y) ((x) < (y) ? (x) : (y))
30int sysctl_nr_open_max = __const_min(INT_MAX, ~(size_t)0/sizeof(void *)) & 30unsigned int sysctl_nr_open_max =
31 -BITS_PER_LONG; 31 __const_min(INT_MAX, ~(size_t)0/sizeof(void *)) & -BITS_PER_LONG;
32 32
33static void *alloc_fdmem(size_t size) 33static void *alloc_fdmem(size_t size)
34{ 34{
@@ -163,7 +163,7 @@ out:
163 * Return <0 error code on error; 1 on successful completion. 163 * Return <0 error code on error; 1 on successful completion.
164 * The files->file_lock should be held on entry, and will be held on exit. 164 * The files->file_lock should be held on entry, and will be held on exit.
165 */ 165 */
166static int expand_fdtable(struct files_struct *files, int nr) 166static int expand_fdtable(struct files_struct *files, unsigned int nr)
167 __releases(files->file_lock) 167 __releases(files->file_lock)
168 __acquires(files->file_lock) 168 __acquires(files->file_lock)
169{ 169{
@@ -208,7 +208,7 @@ static int expand_fdtable(struct files_struct *files, int nr)
208 * expanded and execution may have blocked. 208 * expanded and execution may have blocked.
209 * The files->file_lock should be held on entry, and will be held on exit. 209 * The files->file_lock should be held on entry, and will be held on exit.
210 */ 210 */
211static int expand_files(struct files_struct *files, int nr) 211static int expand_files(struct files_struct *files, unsigned int nr)
212 __releases(files->file_lock) 212 __releases(files->file_lock)
213 __acquires(files->file_lock) 213 __acquires(files->file_lock)
214{ 214{
@@ -243,12 +243,12 @@ repeat:
243 return expanded; 243 return expanded;
244} 244}
245 245
246static inline void __set_close_on_exec(int fd, struct fdtable *fdt) 246static inline void __set_close_on_exec(unsigned int fd, struct fdtable *fdt)
247{ 247{
248 __set_bit(fd, fdt->close_on_exec); 248 __set_bit(fd, fdt->close_on_exec);
249} 249}
250 250
251static inline void __clear_close_on_exec(int fd, struct fdtable *fdt) 251static inline void __clear_close_on_exec(unsigned int fd, struct fdtable *fdt)
252{ 252{
253 if (test_bit(fd, fdt->close_on_exec)) 253 if (test_bit(fd, fdt->close_on_exec))
254 __clear_bit(fd, fdt->close_on_exec); 254 __clear_bit(fd, fdt->close_on_exec);
@@ -268,10 +268,10 @@ static inline void __clear_open_fd(unsigned int fd, struct fdtable *fdt)
268 __clear_bit(fd / BITS_PER_LONG, fdt->full_fds_bits); 268 __clear_bit(fd / BITS_PER_LONG, fdt->full_fds_bits);
269} 269}
270 270
271static int count_open_files(struct fdtable *fdt) 271static unsigned int count_open_files(struct fdtable *fdt)
272{ 272{
273 int size = fdt->max_fds; 273 unsigned int size = fdt->max_fds;
274 int i; 274 unsigned int i;
275 275
276 /* Find the last open fd */ 276 /* Find the last open fd */
277 for (i = size / BITS_PER_LONG; i > 0; ) { 277 for (i = size / BITS_PER_LONG; i > 0; ) {
@@ -291,7 +291,7 @@ struct files_struct *dup_fd(struct files_struct *oldf, int *errorp)
291{ 291{
292 struct files_struct *newf; 292 struct files_struct *newf;
293 struct file **old_fds, **new_fds; 293 struct file **old_fds, **new_fds;
294 int open_files, i; 294 unsigned int open_files, i;
295 struct fdtable *old_fdt, *new_fdt; 295 struct fdtable *old_fdt, *new_fdt;
296 296
297 *errorp = -ENOMEM; 297 *errorp = -ENOMEM;
@@ -391,7 +391,7 @@ static struct fdtable *close_files(struct files_struct * files)
391 * files structure. 391 * files structure.
392 */ 392 */
393 struct fdtable *fdt = rcu_dereference_raw(files->fdt); 393 struct fdtable *fdt = rcu_dereference_raw(files->fdt);
394 int i, j = 0; 394 unsigned int i, j = 0;
395 395
396 for (;;) { 396 for (;;) {
397 unsigned long set; 397 unsigned long set;
@@ -477,11 +477,11 @@ struct files_struct init_files = {
477 .file_lock = __SPIN_LOCK_UNLOCKED(init_files.file_lock), 477 .file_lock = __SPIN_LOCK_UNLOCKED(init_files.file_lock),
478}; 478};
479 479
480static unsigned long find_next_fd(struct fdtable *fdt, unsigned long start) 480static unsigned int find_next_fd(struct fdtable *fdt, unsigned int start)
481{ 481{
482 unsigned long maxfd = fdt->max_fds; 482 unsigned int maxfd = fdt->max_fds;
483 unsigned long maxbit = maxfd / BITS_PER_LONG; 483 unsigned int maxbit = maxfd / BITS_PER_LONG;
484 unsigned long bitbit = start / BITS_PER_LONG; 484 unsigned int bitbit = start / BITS_PER_LONG;
485 485
486 bitbit = find_next_zero_bit(fdt->full_fds_bits, maxbit, bitbit) * BITS_PER_LONG; 486 bitbit = find_next_zero_bit(fdt->full_fds_bits, maxbit, bitbit) * BITS_PER_LONG;
487 if (bitbit > maxfd) 487 if (bitbit > maxfd)
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index f7c84ab835ca..a430c19607f4 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1604,9 +1604,10 @@ int fuse_flush_times(struct inode *inode, struct fuse_file *ff)
1604 * vmtruncate() doesn't allow for this case, so do the rlimit checking 1604 * vmtruncate() doesn't allow for this case, so do the rlimit checking
1605 * and the actual truncation by hand. 1605 * and the actual truncation by hand.
1606 */ 1606 */
1607int fuse_do_setattr(struct inode *inode, struct iattr *attr, 1607int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
1608 struct file *file) 1608 struct file *file)
1609{ 1609{
1610 struct inode *inode = d_inode(dentry);
1610 struct fuse_conn *fc = get_fuse_conn(inode); 1611 struct fuse_conn *fc = get_fuse_conn(inode);
1611 struct fuse_inode *fi = get_fuse_inode(inode); 1612 struct fuse_inode *fi = get_fuse_inode(inode);
1612 FUSE_ARGS(args); 1613 FUSE_ARGS(args);
@@ -1621,7 +1622,7 @@ int fuse_do_setattr(struct inode *inode, struct iattr *attr,
1621 if (!fc->default_permissions) 1622 if (!fc->default_permissions)
1622 attr->ia_valid |= ATTR_FORCE; 1623 attr->ia_valid |= ATTR_FORCE;
1623 1624
1624 err = inode_change_ok(inode, attr); 1625 err = setattr_prepare(dentry, attr);
1625 if (err) 1626 if (err)
1626 return err; 1627 return err;
1627 1628
@@ -1758,7 +1759,7 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr)
1758 if (!attr->ia_valid) 1759 if (!attr->ia_valid)
1759 return 0; 1760 return 0;
1760 1761
1761 ret = fuse_do_setattr(inode, attr, file); 1762 ret = fuse_do_setattr(entry, attr, file);
1762 if (!ret) { 1763 if (!ret) {
1763 /* 1764 /*
1764 * If filesystem supports acls it may have updated acl xattrs in 1765 * If filesystem supports acls it may have updated acl xattrs in
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index b7beb67bf005..abc66a6237fd 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -2810,7 +2810,7 @@ static void fuse_do_truncate(struct file *file)
2810 attr.ia_file = file; 2810 attr.ia_file = file;
2811 attr.ia_valid |= ATTR_FILE; 2811 attr.ia_valid |= ATTR_FILE;
2812 2812
2813 fuse_do_setattr(inode, &attr, file); 2813 fuse_do_setattr(file_dentry(file), &attr, file);
2814} 2814}
2815 2815
2816static inline loff_t fuse_round_up(loff_t off) 2816static inline loff_t fuse_round_up(loff_t off)
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 24ada5dc4dae..0dfbb136e59a 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -961,7 +961,7 @@ bool fuse_write_update_size(struct inode *inode, loff_t pos);
961int fuse_flush_times(struct inode *inode, struct fuse_file *ff); 961int fuse_flush_times(struct inode *inode, struct fuse_file *ff);
962int fuse_write_inode(struct inode *inode, struct writeback_control *wbc); 962int fuse_write_inode(struct inode *inode, struct writeback_control *wbc);
963 963
964int fuse_do_setattr(struct inode *inode, struct iattr *attr, 964int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
965 struct file *file); 965 struct file *file);
966 966
967void fuse_set_initialized(struct fuse_conn *fc); 967void fuse_set_initialized(struct fuse_conn *fc);
diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c
index 363ba9e9d8d0..2524807ee070 100644
--- a/fs/gfs2/acl.c
+++ b/fs/gfs2/acl.c
@@ -92,17 +92,11 @@ int __gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
92 if (type == ACL_TYPE_ACCESS) { 92 if (type == ACL_TYPE_ACCESS) {
93 umode_t mode = inode->i_mode; 93 umode_t mode = inode->i_mode;
94 94
95 error = posix_acl_equiv_mode(acl, &mode); 95 error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
96 if (error < 0) 96 if (error)
97 return error; 97 return error;
98 98 if (mode != inode->i_mode)
99 if (error == 0)
100 acl = NULL;
101
102 if (mode != inode->i_mode) {
103 inode->i_mode = mode;
104 mark_inode_dirty(inode); 99 mark_inode_dirty(inode);
105 }
106 } 100 }
107 101
108 if (acl) { 102 if (acl) {
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index fb3a810b506f..7efd1d19d325 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -1936,7 +1936,7 @@ static int gfs2_setattr(struct dentry *dentry, struct iattr *attr)
1936 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 1936 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1937 goto out; 1937 goto out;
1938 1938
1939 error = inode_change_ok(inode, attr); 1939 error = setattr_prepare(dentry, attr);
1940 if (error) 1940 if (error)
1941 goto out; 1941 goto out;
1942 1942
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index c6a32415735b..09cce23864da 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -605,7 +605,7 @@ int hfs_inode_setattr(struct dentry *dentry, struct iattr * attr)
605 struct hfs_sb_info *hsb = HFS_SB(inode->i_sb); 605 struct hfs_sb_info *hsb = HFS_SB(inode->i_sb);
606 int error; 606 int error;
607 607
608 error = inode_change_ok(inode, attr); /* basic permission checks */ 608 error = setattr_prepare(dentry, attr); /* basic permission checks */
609 if (error) 609 if (error)
610 return error; 610 return error;
611 611
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 19462d773fe2..c43ef397a3aa 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -245,7 +245,7 @@ static int hfsplus_setattr(struct dentry *dentry, struct iattr *attr)
245 struct inode *inode = d_inode(dentry); 245 struct inode *inode = d_inode(dentry);
246 int error; 246 int error;
247 247
248 error = inode_change_ok(inode, attr); 248 error = setattr_prepare(dentry, attr);
249 if (error) 249 if (error)
250 return error; 250 return error;
251 251
diff --git a/fs/hfsplus/posix_acl.c b/fs/hfsplus/posix_acl.c
index ab7ea2506b4d..9b92058a1240 100644
--- a/fs/hfsplus/posix_acl.c
+++ b/fs/hfsplus/posix_acl.c
@@ -65,8 +65,8 @@ int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl,
65 case ACL_TYPE_ACCESS: 65 case ACL_TYPE_ACCESS:
66 xattr_name = XATTR_NAME_POSIX_ACL_ACCESS; 66 xattr_name = XATTR_NAME_POSIX_ACL_ACCESS;
67 if (acl) { 67 if (acl) {
68 err = posix_acl_equiv_mode(acl, &inode->i_mode); 68 err = posix_acl_update_mode(inode, &inode->i_mode, &acl);
69 if (err < 0) 69 if (err)
70 return err; 70 return err;
71 } 71 }
72 err = 0; 72 err = 0;
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 90e46cd752fe..44aa96ba1df8 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)
812 812
813 int fd = HOSTFS_I(inode)->fd; 813 int fd = HOSTFS_I(inode)->fd;
814 814
815 err = inode_change_ok(inode, attr); 815 err = setattr_prepare(dentry, attr);
816 if (err) 816 if (err)
817 return err; 817 return err;
818 818
diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c
index d3bcdd975700..b3be1b5a62e2 100644
--- a/fs/hpfs/file.c
+++ b/fs/hpfs/file.c
@@ -189,6 +189,11 @@ static sector_t _hpfs_bmap(struct address_space *mapping, sector_t block)
189 return generic_block_bmap(mapping, block, hpfs_get_block); 189 return generic_block_bmap(mapping, block, hpfs_get_block);
190} 190}
191 191
192static int hpfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, u64 start, u64 len)
193{
194 return generic_block_fiemap(inode, fieinfo, start, len, hpfs_get_block);
195}
196
192const struct address_space_operations hpfs_aops = { 197const struct address_space_operations hpfs_aops = {
193 .readpage = hpfs_readpage, 198 .readpage = hpfs_readpage,
194 .writepage = hpfs_writepage, 199 .writepage = hpfs_writepage,
@@ -214,4 +219,5 @@ const struct file_operations hpfs_file_ops =
214const struct inode_operations hpfs_file_iops = 219const struct inode_operations hpfs_file_iops =
215{ 220{
216 .setattr = hpfs_setattr, 221 .setattr = hpfs_setattr,
222 .fiemap = hpfs_fiemap,
217}; 223};
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index 1f3c6d76200b..b9c724ed1e7e 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -273,7 +273,7 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
273 if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size) 273 if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size)
274 goto out_unlock; 274 goto out_unlock;
275 275
276 error = inode_change_ok(inode, attr); 276 error = setattr_prepare(dentry, attr);
277 if (error) 277 if (error)
278 goto out_unlock; 278 goto out_unlock;
279 279
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 7337cac29e9e..2c0c3a017a6a 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -670,7 +670,7 @@ static int hugetlbfs_setattr(struct dentry *dentry, struct iattr *attr)
670 670
671 BUG_ON(!inode); 671 BUG_ON(!inode);
672 672
673 error = inode_change_ok(inode, attr); 673 error = setattr_prepare(dentry, attr);
674 if (error) 674 if (error)
675 return error; 675 return error;
676 676
diff --git a/fs/inode.c b/fs/inode.c
index 7e3ef3af3db9..a3c7ba7f6b59 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1021,13 +1021,17 @@ struct inode *iget5_locked(struct super_block *sb, unsigned long hashval,
1021{ 1021{
1022 struct hlist_head *head = inode_hashtable + hash(sb, hashval); 1022 struct hlist_head *head = inode_hashtable + hash(sb, hashval);
1023 struct inode *inode; 1023 struct inode *inode;
1024 1024again:
1025 spin_lock(&inode_hash_lock); 1025 spin_lock(&inode_hash_lock);
1026 inode = find_inode(sb, head, test, data); 1026 inode = find_inode(sb, head, test, data);
1027 spin_unlock(&inode_hash_lock); 1027 spin_unlock(&inode_hash_lock);
1028 1028
1029 if (inode) { 1029 if (inode) {
1030 wait_on_inode(inode); 1030 wait_on_inode(inode);
1031 if (unlikely(inode_unhashed(inode))) {
1032 iput(inode);
1033 goto again;
1034 }
1031 return inode; 1035 return inode;
1032 } 1036 }
1033 1037
@@ -1064,6 +1068,10 @@ struct inode *iget5_locked(struct super_block *sb, unsigned long hashval,
1064 destroy_inode(inode); 1068 destroy_inode(inode);
1065 inode = old; 1069 inode = old;
1066 wait_on_inode(inode); 1070 wait_on_inode(inode);
1071 if (unlikely(inode_unhashed(inode))) {
1072 iput(inode);
1073 goto again;
1074 }
1067 } 1075 }
1068 return inode; 1076 return inode;
1069 1077
@@ -1091,12 +1099,16 @@ struct inode *iget_locked(struct super_block *sb, unsigned long ino)
1091{ 1099{
1092 struct hlist_head *head = inode_hashtable + hash(sb, ino); 1100 struct hlist_head *head = inode_hashtable + hash(sb, ino);
1093 struct inode *inode; 1101 struct inode *inode;
1094 1102again:
1095 spin_lock(&inode_hash_lock); 1103 spin_lock(&inode_hash_lock);
1096 inode = find_inode_fast(sb, head, ino); 1104 inode = find_inode_fast(sb, head, ino);
1097 spin_unlock(&inode_hash_lock); 1105 spin_unlock(&inode_hash_lock);
1098 if (inode) { 1106 if (inode) {
1099 wait_on_inode(inode); 1107 wait_on_inode(inode);
1108 if (unlikely(inode_unhashed(inode))) {
1109 iput(inode);
1110 goto again;
1111 }
1100 return inode; 1112 return inode;
1101 } 1113 }
1102 1114
@@ -1131,6 +1143,10 @@ struct inode *iget_locked(struct super_block *sb, unsigned long ino)
1131 destroy_inode(inode); 1143 destroy_inode(inode);
1132 inode = old; 1144 inode = old;
1133 wait_on_inode(inode); 1145 wait_on_inode(inode);
1146 if (unlikely(inode_unhashed(inode))) {
1147 iput(inode);
1148 goto again;
1149 }
1134 } 1150 }
1135 return inode; 1151 return inode;
1136} 1152}
@@ -1266,10 +1282,16 @@ EXPORT_SYMBOL(ilookup5_nowait);
1266struct inode *ilookup5(struct super_block *sb, unsigned long hashval, 1282struct inode *ilookup5(struct super_block *sb, unsigned long hashval,
1267 int (*test)(struct inode *, void *), void *data) 1283 int (*test)(struct inode *, void *), void *data)
1268{ 1284{
1269 struct inode *inode = ilookup5_nowait(sb, hashval, test, data); 1285 struct inode *inode;
1270 1286again:
1271 if (inode) 1287 inode = ilookup5_nowait(sb, hashval, test, data);
1288 if (inode) {
1272 wait_on_inode(inode); 1289 wait_on_inode(inode);
1290 if (unlikely(inode_unhashed(inode))) {
1291 iput(inode);
1292 goto again;
1293 }
1294 }
1273 return inode; 1295 return inode;
1274} 1296}
1275EXPORT_SYMBOL(ilookup5); 1297EXPORT_SYMBOL(ilookup5);
@@ -1286,13 +1308,18 @@ struct inode *ilookup(struct super_block *sb, unsigned long ino)
1286{ 1308{
1287 struct hlist_head *head = inode_hashtable + hash(sb, ino); 1309 struct hlist_head *head = inode_hashtable + hash(sb, ino);
1288 struct inode *inode; 1310 struct inode *inode;
1289 1311again:
1290 spin_lock(&inode_hash_lock); 1312 spin_lock(&inode_hash_lock);
1291 inode = find_inode_fast(sb, head, ino); 1313 inode = find_inode_fast(sb, head, ino);
1292 spin_unlock(&inode_hash_lock); 1314 spin_unlock(&inode_hash_lock);
1293 1315
1294 if (inode) 1316 if (inode) {
1295 wait_on_inode(inode); 1317 wait_on_inode(inode);
1318 if (unlikely(inode_unhashed(inode))) {
1319 iput(inode);
1320 goto again;
1321 }
1322 }
1296 return inode; 1323 return inode;
1297} 1324}
1298EXPORT_SYMBOL(ilookup); 1325EXPORT_SYMBOL(ilookup);
@@ -1536,16 +1563,36 @@ sector_t bmap(struct inode *inode, sector_t block)
1536EXPORT_SYMBOL(bmap); 1563EXPORT_SYMBOL(bmap);
1537 1564
1538/* 1565/*
1566 * Update times in overlayed inode from underlying real inode
1567 */
1568static void update_ovl_inode_times(struct dentry *dentry, struct inode *inode,
1569 bool rcu)
1570{
1571 if (!rcu) {
1572 struct inode *realinode = d_real_inode(dentry);
1573
1574 if (unlikely(inode != realinode) &&
1575 (!timespec_equal(&inode->i_mtime, &realinode->i_mtime) ||
1576 !timespec_equal(&inode->i_ctime, &realinode->i_ctime))) {
1577 inode->i_mtime = realinode->i_mtime;
1578 inode->i_ctime = realinode->i_ctime;
1579 }
1580 }
1581}
1582
1583/*
1539 * With relative atime, only update atime if the previous atime is 1584 * With relative atime, only update atime if the previous atime is
1540 * earlier than either the ctime or mtime or if at least a day has 1585 * earlier than either the ctime or mtime or if at least a day has
1541 * passed since the last atime update. 1586 * passed since the last atime update.
1542 */ 1587 */
1543static int relatime_need_update(struct vfsmount *mnt, struct inode *inode, 1588static int relatime_need_update(const struct path *path, struct inode *inode,
1544 struct timespec now) 1589 struct timespec now, bool rcu)
1545{ 1590{
1546 1591
1547 if (!(mnt->mnt_flags & MNT_RELATIME)) 1592 if (!(path->mnt->mnt_flags & MNT_RELATIME))
1548 return 1; 1593 return 1;
1594
1595 update_ovl_inode_times(path->dentry, inode, rcu);
1549 /* 1596 /*
1550 * Is mtime younger than atime? If yes, update atime: 1597 * Is mtime younger than atime? If yes, update atime:
1551 */ 1598 */
@@ -1612,7 +1659,8 @@ static int update_time(struct inode *inode, struct timespec *time, int flags)
1612 * This function automatically handles read only file systems and media, 1659 * This function automatically handles read only file systems and media,
1613 * as well as the "noatime" flag and inode specific "noatime" markers. 1660 * as well as the "noatime" flag and inode specific "noatime" markers.
1614 */ 1661 */
1615bool atime_needs_update(const struct path *path, struct inode *inode) 1662bool __atime_needs_update(const struct path *path, struct inode *inode,
1663 bool rcu)
1616{ 1664{
1617 struct vfsmount *mnt = path->mnt; 1665 struct vfsmount *mnt = path->mnt;
1618 struct timespec now; 1666 struct timespec now;
@@ -1638,7 +1686,7 @@ bool atime_needs_update(const struct path *path, struct inode *inode)
1638 1686
1639 now = current_fs_time(inode->i_sb); 1687 now = current_fs_time(inode->i_sb);
1640 1688
1641 if (!relatime_need_update(mnt, inode, now)) 1689 if (!relatime_need_update(path, inode, now, rcu))
1642 return false; 1690 return false;
1643 1691
1644 if (timespec_equal(&inode->i_atime, &now)) 1692 if (timespec_equal(&inode->i_atime, &now))
@@ -1653,7 +1701,7 @@ void touch_atime(const struct path *path)
1653 struct inode *inode = d_inode(path->dentry); 1701 struct inode *inode = d_inode(path->dentry);
1654 struct timespec now; 1702 struct timespec now;
1655 1703
1656 if (!atime_needs_update(path, inode)) 1704 if (!__atime_needs_update(path, inode, false))
1657 return; 1705 return;
1658 1706
1659 if (!sb_start_write_trylock(inode->i_sb)) 1707 if (!sb_start_write_trylock(inode->i_sb))
diff --git a/fs/internal.h b/fs/internal.h
index 859178692ce4..f4da3341b4a3 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -121,6 +121,15 @@ extern long prune_icache_sb(struct super_block *sb, struct shrink_control *sc);
121extern void inode_add_lru(struct inode *inode); 121extern void inode_add_lru(struct inode *inode);
122extern int dentry_needs_remove_privs(struct dentry *dentry); 122extern int dentry_needs_remove_privs(struct dentry *dentry);
123 123
124extern bool __atime_needs_update(const struct path *, struct inode *, bool);
125static inline bool atime_needs_update_rcu(const struct path *path,
126 struct inode *inode)
127{
128 return __atime_needs_update(path, inode, true);
129}
130
131extern bool atime_needs_update_rcu(const struct path *, struct inode *);
132
124/* 133/*
125 * fs-writeback.c 134 * fs-writeback.c
126 */ 135 */
@@ -157,7 +166,7 @@ extern void mnt_pin_kill(struct mount *m);
157/* 166/*
158 * fs/nsfs.c 167 * fs/nsfs.c
159 */ 168 */
160extern struct dentry_operations ns_dentry_operations; 169extern const struct dentry_operations ns_dentry_operations;
161 170
162/* 171/*
163 * fs/ioctl.c 172 * fs/ioctl.c
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c
index bc2693d56298..2a0f2a1044c1 100644
--- a/fs/jffs2/acl.c
+++ b/fs/jffs2/acl.c
@@ -233,9 +233,10 @@ int jffs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
233 case ACL_TYPE_ACCESS: 233 case ACL_TYPE_ACCESS:
234 xprefix = JFFS2_XPREFIX_ACL_ACCESS; 234 xprefix = JFFS2_XPREFIX_ACL_ACCESS;
235 if (acl) { 235 if (acl) {
236 umode_t mode = inode->i_mode; 236 umode_t mode;
237 rc = posix_acl_equiv_mode(acl, &mode); 237
238 if (rc < 0) 238 rc = posix_acl_update_mode(inode, &mode, &acl);
239 if (rc)
239 return rc; 240 return rc;
240 if (inode->i_mode != mode) { 241 if (inode->i_mode != mode) {
241 struct iattr attr; 242 struct iattr attr;
@@ -247,8 +248,6 @@ int jffs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
247 if (rc < 0) 248 if (rc < 0)
248 return rc; 249 return rc;
249 } 250 }
250 if (rc == 0)
251 acl = NULL;
252 } 251 }
253 break; 252 break;
254 case ACL_TYPE_DEFAULT: 253 case ACL_TYPE_DEFAULT:
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index ae2ebb26b446..3773b24b4db0 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -193,7 +193,7 @@ int jffs2_setattr(struct dentry *dentry, struct iattr *iattr)
193 struct inode *inode = d_inode(dentry); 193 struct inode *inode = d_inode(dentry);
194 int rc; 194 int rc;
195 195
196 rc = inode_change_ok(inode, iattr); 196 rc = setattr_prepare(dentry, iattr);
197 if (rc) 197 if (rc)
198 return rc; 198 return rc;
199 199
diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c
index 21fa92ba2c19..3a1e1554a4e3 100644
--- a/fs/jfs/acl.c
+++ b/fs/jfs/acl.c
@@ -78,13 +78,11 @@ static int __jfs_set_acl(tid_t tid, struct inode *inode, int type,
78 case ACL_TYPE_ACCESS: 78 case ACL_TYPE_ACCESS:
79 ea_name = XATTR_NAME_POSIX_ACL_ACCESS; 79 ea_name = XATTR_NAME_POSIX_ACL_ACCESS;
80 if (acl) { 80 if (acl) {
81 rc = posix_acl_equiv_mode(acl, &inode->i_mode); 81 rc = posix_acl_update_mode(inode, &inode->i_mode, &acl);
82 if (rc < 0) 82 if (rc)
83 return rc; 83 return rc;
84 inode->i_ctime = CURRENT_TIME; 84 inode->i_ctime = CURRENT_TIME;
85 mark_inode_dirty(inode); 85 mark_inode_dirty(inode);
86 if (rc == 0)
87 acl = NULL;
88 } 86 }
89 break; 87 break;
90 case ACL_TYPE_DEFAULT: 88 case ACL_TYPE_DEFAULT:
diff --git a/fs/jfs/file.c b/fs/jfs/file.c
index 7f1a585a0a94..cf62037b8a04 100644
--- a/fs/jfs/file.c
+++ b/fs/jfs/file.c
@@ -103,7 +103,7 @@ int jfs_setattr(struct dentry *dentry, struct iattr *iattr)
103 struct inode *inode = d_inode(dentry); 103 struct inode *inode = d_inode(dentry);
104 int rc; 104 int rc;
105 105
106 rc = inode_change_ok(inode, iattr); 106 rc = setattr_prepare(dentry, iattr);
107 if (rc) 107 if (rc)
108 return rc; 108 return rc;
109 109
diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
index 63b925d5ba1e..df21f5b75549 100644
--- a/fs/kernfs/inode.c
+++ b/fs/kernfs/inode.c
@@ -122,7 +122,7 @@ int kernfs_iop_setattr(struct dentry *dentry, struct iattr *iattr)
122 return -EINVAL; 122 return -EINVAL;
123 123
124 mutex_lock(&kernfs_mutex); 124 mutex_lock(&kernfs_mutex);
125 error = inode_change_ok(inode, iattr); 125 error = setattr_prepare(dentry, iattr);
126 if (error) 126 if (error)
127 goto out; 127 goto out;
128 128
diff --git a/fs/libfs.c b/fs/libfs.c
index 74dc8b9e7f53..2b3c3ae70153 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -394,7 +394,7 @@ int simple_setattr(struct dentry *dentry, struct iattr *iattr)
394 struct inode *inode = d_inode(dentry); 394 struct inode *inode = d_inode(dentry);
395 int error; 395 int error;
396 396
397 error = inode_change_ok(inode, iattr); 397 error = setattr_prepare(dentry, iattr);
398 if (error) 398 if (error)
399 return error; 399 return error;
400 400
diff --git a/fs/locks.c b/fs/locks.c
index 90ec67108b22..8cc218d7a039 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -138,6 +138,11 @@
138#define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG|FL_LAYOUT)) 138#define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG|FL_LAYOUT))
139#define IS_OFDLCK(fl) (fl->fl_flags & FL_OFDLCK) 139#define IS_OFDLCK(fl) (fl->fl_flags & FL_OFDLCK)
140 140
141static inline bool is_remote_lock(struct file *filp)
142{
143 return likely(!(filp->f_path.dentry->d_sb->s_flags & MS_NOREMOTELOCK));
144}
145
141static bool lease_breaking(struct file_lock *fl) 146static bool lease_breaking(struct file_lock *fl)
142{ 147{
143 return fl->fl_flags & (FL_UNLOCK_PENDING | FL_DOWNGRADE_PENDING); 148 return fl->fl_flags & (FL_UNLOCK_PENDING | FL_DOWNGRADE_PENDING);
@@ -806,7 +811,7 @@ posix_test_lock(struct file *filp, struct file_lock *fl)
806{ 811{
807 struct file_lock *cfl; 812 struct file_lock *cfl;
808 struct file_lock_context *ctx; 813 struct file_lock_context *ctx;
809 struct inode *inode = file_inode(filp); 814 struct inode *inode = locks_inode(filp);
810 815
811 ctx = smp_load_acquire(&inode->i_flctx); 816 ctx = smp_load_acquire(&inode->i_flctx);
812 if (!ctx || list_empty_careful(&ctx->flc_posix)) { 817 if (!ctx || list_empty_careful(&ctx->flc_posix)) {
@@ -1211,7 +1216,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request,
1211int posix_lock_file(struct file *filp, struct file_lock *fl, 1216int posix_lock_file(struct file *filp, struct file_lock *fl,
1212 struct file_lock *conflock) 1217 struct file_lock *conflock)
1213{ 1218{
1214 return posix_lock_inode(file_inode(filp), fl, conflock); 1219 return posix_lock_inode(locks_inode(filp), fl, conflock);
1215} 1220}
1216EXPORT_SYMBOL(posix_lock_file); 1221EXPORT_SYMBOL(posix_lock_file);
1217 1222
@@ -1251,7 +1256,7 @@ static int posix_lock_inode_wait(struct inode *inode, struct file_lock *fl)
1251int locks_mandatory_locked(struct file *file) 1256int locks_mandatory_locked(struct file *file)
1252{ 1257{
1253 int ret; 1258 int ret;
1254 struct inode *inode = file_inode(file); 1259 struct inode *inode = locks_inode(file);
1255 struct file_lock_context *ctx; 1260 struct file_lock_context *ctx;
1256 struct file_lock *fl; 1261 struct file_lock *fl;
1257 1262
@@ -1597,7 +1602,7 @@ EXPORT_SYMBOL(lease_get_mtime);
1597int fcntl_getlease(struct file *filp) 1602int fcntl_getlease(struct file *filp)
1598{ 1603{
1599 struct file_lock *fl; 1604 struct file_lock *fl;
1600 struct inode *inode = file_inode(filp); 1605 struct inode *inode = locks_inode(filp);
1601 struct file_lock_context *ctx; 1606 struct file_lock_context *ctx;
1602 int type = F_UNLCK; 1607 int type = F_UNLCK;
1603 LIST_HEAD(dispose); 1608 LIST_HEAD(dispose);
@@ -1605,7 +1610,7 @@ int fcntl_getlease(struct file *filp)
1605 ctx = smp_load_acquire(&inode->i_flctx); 1610 ctx = smp_load_acquire(&inode->i_flctx);
1606 if (ctx && !list_empty_careful(&ctx->flc_lease)) { 1611 if (ctx && !list_empty_careful(&ctx->flc_lease)) {
1607 spin_lock(&ctx->flc_lock); 1612 spin_lock(&ctx->flc_lock);
1608 time_out_leases(file_inode(filp), &dispose); 1613 time_out_leases(inode, &dispose);
1609 list_for_each_entry(fl, &ctx->flc_lease, fl_list) { 1614 list_for_each_entry(fl, &ctx->flc_lease, fl_list) {
1610 if (fl->fl_file != filp) 1615 if (fl->fl_file != filp)
1611 continue; 1616 continue;
@@ -1638,7 +1643,8 @@ check_conflicting_open(const struct dentry *dentry, const long arg, int flags)
1638 if (flags & FL_LAYOUT) 1643 if (flags & FL_LAYOUT)
1639 return 0; 1644 return 0;
1640 1645
1641 if ((arg == F_RDLCK) && (atomic_read(&inode->i_writecount) > 0)) 1646 if ((arg == F_RDLCK) &&
1647 (atomic_read(&d_real_inode(dentry)->i_writecount) > 0))
1642 return -EAGAIN; 1648 return -EAGAIN;
1643 1649
1644 if ((arg == F_WRLCK) && ((d_count(dentry) > 1) || 1650 if ((arg == F_WRLCK) && ((d_count(dentry) > 1) ||
@@ -1653,7 +1659,7 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
1653{ 1659{
1654 struct file_lock *fl, *my_fl = NULL, *lease; 1660 struct file_lock *fl, *my_fl = NULL, *lease;
1655 struct dentry *dentry = filp->f_path.dentry; 1661 struct dentry *dentry = filp->f_path.dentry;
1656 struct inode *inode = file_inode(filp); 1662 struct inode *inode = dentry->d_inode;
1657 struct file_lock_context *ctx; 1663 struct file_lock_context *ctx;
1658 bool is_deleg = (*flp)->fl_flags & FL_DELEG; 1664 bool is_deleg = (*flp)->fl_flags & FL_DELEG;
1659 int error; 1665 int error;
@@ -1769,7 +1775,7 @@ static int generic_delete_lease(struct file *filp, void *owner)
1769{ 1775{
1770 int error = -EAGAIN; 1776 int error = -EAGAIN;
1771 struct file_lock *fl, *victim = NULL; 1777 struct file_lock *fl, *victim = NULL;
1772 struct inode *inode = file_inode(filp); 1778 struct inode *inode = locks_inode(filp);
1773 struct file_lock_context *ctx; 1779 struct file_lock_context *ctx;
1774 LIST_HEAD(dispose); 1780 LIST_HEAD(dispose);
1775 1781
@@ -1811,7 +1817,7 @@ static int generic_delete_lease(struct file *filp, void *owner)
1811int generic_setlease(struct file *filp, long arg, struct file_lock **flp, 1817int generic_setlease(struct file *filp, long arg, struct file_lock **flp,
1812 void **priv) 1818 void **priv)
1813{ 1819{
1814 struct inode *inode = file_inode(filp); 1820 struct inode *inode = locks_inode(filp);
1815 int error; 1821 int error;
1816 1822
1817 if ((!uid_eq(current_fsuid(), inode->i_uid)) && !capable(CAP_LEASE)) 1823 if ((!uid_eq(current_fsuid(), inode->i_uid)) && !capable(CAP_LEASE))
@@ -1859,7 +1865,7 @@ EXPORT_SYMBOL(generic_setlease);
1859int 1865int
1860vfs_setlease(struct file *filp, long arg, struct file_lock **lease, void **priv) 1866vfs_setlease(struct file *filp, long arg, struct file_lock **lease, void **priv)
1861{ 1867{
1862 if (filp->f_op->setlease) 1868 if (filp->f_op->setlease && is_remote_lock(filp))
1863 return filp->f_op->setlease(filp, arg, lease, priv); 1869 return filp->f_op->setlease(filp, arg, lease, priv);
1864 else 1870 else
1865 return generic_setlease(filp, arg, lease, priv); 1871 return generic_setlease(filp, arg, lease, priv);
@@ -2008,7 +2014,7 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd)
2008 if (error) 2014 if (error)
2009 goto out_free; 2015 goto out_free;
2010 2016
2011 if (f.file->f_op->flock) 2017 if (f.file->f_op->flock && is_remote_lock(f.file))
2012 error = f.file->f_op->flock(f.file, 2018 error = f.file->f_op->flock(f.file,
2013 (can_sleep) ? F_SETLKW : F_SETLK, 2019 (can_sleep) ? F_SETLKW : F_SETLK,
2014 lock); 2020 lock);
@@ -2034,7 +2040,7 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd)
2034 */ 2040 */
2035int vfs_test_lock(struct file *filp, struct file_lock *fl) 2041int vfs_test_lock(struct file *filp, struct file_lock *fl)
2036{ 2042{
2037 if (filp->f_op->lock) 2043 if (filp->f_op->lock && is_remote_lock(filp))
2038 return filp->f_op->lock(filp, F_GETLK, fl); 2044 return filp->f_op->lock(filp, F_GETLK, fl);
2039 posix_test_lock(filp, fl); 2045 posix_test_lock(filp, fl);
2040 return 0; 2046 return 0;
@@ -2158,7 +2164,7 @@ out:
2158 */ 2164 */
2159int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf) 2165int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf)
2160{ 2166{
2161 if (filp->f_op->lock) 2167 if (filp->f_op->lock && is_remote_lock(filp))
2162 return filp->f_op->lock(filp, cmd, fl); 2168 return filp->f_op->lock(filp, cmd, fl);
2163 else 2169 else
2164 return posix_lock_file(filp, fl, conf); 2170 return posix_lock_file(filp, fl, conf);
@@ -2220,7 +2226,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
2220 if (file_lock == NULL) 2226 if (file_lock == NULL)
2221 return -ENOLCK; 2227 return -ENOLCK;
2222 2228
2223 inode = file_inode(filp); 2229 inode = locks_inode(filp);
2224 2230
2225 /* 2231 /*
2226 * This might block, so we do it before checking the inode. 2232 * This might block, so we do it before checking the inode.
@@ -2372,7 +2378,7 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
2372 if (copy_from_user(&flock, l, sizeof(flock))) 2378 if (copy_from_user(&flock, l, sizeof(flock)))
2373 goto out; 2379 goto out;
2374 2380
2375 inode = file_inode(filp); 2381 inode = locks_inode(filp);
2376 2382
2377 /* Don't allow mandatory locks on files that may be memory mapped 2383 /* Don't allow mandatory locks on files that may be memory mapped
2378 * and shared. 2384 * and shared.
@@ -2455,6 +2461,7 @@ out:
2455void locks_remove_posix(struct file *filp, fl_owner_t owner) 2461void locks_remove_posix(struct file *filp, fl_owner_t owner)
2456{ 2462{
2457 int error; 2463 int error;
2464 struct inode *inode = locks_inode(filp);
2458 struct file_lock lock; 2465 struct file_lock lock;
2459 struct file_lock_context *ctx; 2466 struct file_lock_context *ctx;
2460 2467
@@ -2463,7 +2470,7 @@ void locks_remove_posix(struct file *filp, fl_owner_t owner)
2463 * posix_lock_file(). Another process could be setting a lock on this 2470 * posix_lock_file(). Another process could be setting a lock on this
2464 * file at the same time, but we wouldn't remove that lock anyway. 2471 * file at the same time, but we wouldn't remove that lock anyway.
2465 */ 2472 */
2466 ctx = smp_load_acquire(&file_inode(filp)->i_flctx); 2473 ctx = smp_load_acquire(&inode->i_flctx);
2467 if (!ctx || list_empty(&ctx->flc_posix)) 2474 if (!ctx || list_empty(&ctx->flc_posix))
2468 return; 2475 return;
2469 2476
@@ -2481,7 +2488,7 @@ void locks_remove_posix(struct file *filp, fl_owner_t owner)
2481 2488
2482 if (lock.fl_ops && lock.fl_ops->fl_release_private) 2489 if (lock.fl_ops && lock.fl_ops->fl_release_private)
2483 lock.fl_ops->fl_release_private(&lock); 2490 lock.fl_ops->fl_release_private(&lock);
2484 trace_locks_remove_posix(file_inode(filp), &lock, error); 2491 trace_locks_remove_posix(inode, &lock, error);
2485} 2492}
2486 2493
2487EXPORT_SYMBOL(locks_remove_posix); 2494EXPORT_SYMBOL(locks_remove_posix);
@@ -2498,12 +2505,12 @@ locks_remove_flock(struct file *filp, struct file_lock_context *flctx)
2498 .fl_type = F_UNLCK, 2505 .fl_type = F_UNLCK,
2499 .fl_end = OFFSET_MAX, 2506 .fl_end = OFFSET_MAX,
2500 }; 2507 };
2501 struct inode *inode = file_inode(filp); 2508 struct inode *inode = locks_inode(filp);
2502 2509
2503 if (list_empty(&flctx->flc_flock)) 2510 if (list_empty(&flctx->flc_flock))
2504 return; 2511 return;
2505 2512
2506 if (filp->f_op->flock) 2513 if (filp->f_op->flock && is_remote_lock(filp))
2507 filp->f_op->flock(filp, F_SETLKW, &fl); 2514 filp->f_op->flock(filp, F_SETLKW, &fl);
2508 else 2515 else
2509 flock_lock_inode(inode, &fl); 2516 flock_lock_inode(inode, &fl);
@@ -2537,7 +2544,7 @@ void locks_remove_file(struct file *filp)
2537{ 2544{
2538 struct file_lock_context *ctx; 2545 struct file_lock_context *ctx;
2539 2546
2540 ctx = smp_load_acquire(&file_inode(filp)->i_flctx); 2547 ctx = smp_load_acquire(&locks_inode(filp)->i_flctx);
2541 if (!ctx) 2548 if (!ctx)
2542 return; 2549 return;
2543 2550
@@ -2581,7 +2588,7 @@ EXPORT_SYMBOL(posix_unblock_lock);
2581 */ 2588 */
2582int vfs_cancel_lock(struct file *filp, struct file_lock *fl) 2589int vfs_cancel_lock(struct file *filp, struct file_lock *fl)
2583{ 2590{
2584 if (filp->f_op->lock) 2591 if (filp->f_op->lock && is_remote_lock(filp))
2585 return filp->f_op->lock(filp, F_CANCELLK, fl); 2592 return filp->f_op->lock(filp, F_CANCELLK, fl);
2586 return 0; 2593 return 0;
2587} 2594}
@@ -2620,7 +2627,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
2620 fl_pid = fl->fl_pid; 2627 fl_pid = fl->fl_pid;
2621 2628
2622 if (fl->fl_file != NULL) 2629 if (fl->fl_file != NULL)
2623 inode = file_inode(fl->fl_file); 2630 inode = locks_inode(fl->fl_file);
2624 2631
2625 seq_printf(f, "%lld:%s ", id, pfx); 2632 seq_printf(f, "%lld:%s ", id, pfx);
2626 if (IS_POSIX(fl)) { 2633 if (IS_POSIX(fl)) {
@@ -2726,7 +2733,7 @@ static void __show_fd_locks(struct seq_file *f,
2726void show_fd_locks(struct seq_file *f, 2733void show_fd_locks(struct seq_file *f,
2727 struct file *filp, struct files_struct *files) 2734 struct file *filp, struct files_struct *files)
2728{ 2735{
2729 struct inode *inode = file_inode(filp); 2736 struct inode *inode = locks_inode(filp);
2730 struct file_lock_context *ctx; 2737 struct file_lock_context *ctx;
2731 int id = 0; 2738 int id = 0;
2732 2739
diff --git a/fs/logfs/file.c b/fs/logfs/file.c
index f01ddfb1a03b..5d9fe466bbc9 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)
244 struct inode *inode = d_inode(dentry); 244 struct inode *inode = d_inode(dentry);
245 int err = 0; 245 int err = 0;
246 246
247 err = inode_change_ok(inode, attr); 247 err = setattr_prepare(dentry, attr);
248 if (err) 248 if (err)
249 return err; 249 return err;
250 250
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)
26 struct inode *inode = d_inode(dentry); 26 struct inode *inode = d_inode(dentry);
27 int error; 27 int error;
28 28
29 error = inode_change_ok(inode, attr); 29 error = setattr_prepare(dentry, attr);
30 if (error) 30 if (error)
31 return error; 31 return error;
32 32
diff --git a/fs/namei.c b/fs/namei.c
index adb04146df09..4bbcae1ba58e 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1015,7 +1015,7 @@ const char *get_link(struct nameidata *nd)
1015 if (!(nd->flags & LOOKUP_RCU)) { 1015 if (!(nd->flags & LOOKUP_RCU)) {
1016 touch_atime(&last->link); 1016 touch_atime(&last->link);
1017 cond_resched(); 1017 cond_resched();
1018 } else if (atime_needs_update(&last->link, inode)) { 1018 } else if (atime_needs_update_rcu(&last->link, inode)) {
1019 if (unlikely(unlazy_walk(nd, NULL, 0))) 1019 if (unlikely(unlazy_walk(nd, NULL, 0)))
1020 return ERR_PTR(-ECHILD); 1020 return ERR_PTR(-ECHILD);
1021 touch_atime(&last->link); 1021 touch_atime(&last->link);
diff --git a/fs/namespace.c b/fs/namespace.c
index db1b5a38864e..58aca9c931ac 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2743,7 +2743,7 @@ long do_mount(const char *dev_name, const char __user *dir_name,
2743 2743
2744 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN | 2744 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
2745 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT | 2745 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
2746 MS_STRICTATIME); 2746 MS_STRICTATIME | MS_NOREMOTELOCK);
2747 2747
2748 if (flags & MS_REMOUNT) 2748 if (flags & MS_REMOUNT)
2749 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags, 2749 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 1af15fcbe57b..f6cf4c7e92b1 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)
884 /* ageing the dentry to force validation */ 884 /* ageing the dentry to force validation */
885 ncp_age_dentry(server, dentry); 885 ncp_age_dentry(server, dentry);
886 886
887 result = inode_change_ok(inode, attr); 887 result = setattr_prepare(dentry, attr);
888 if (result < 0) 888 if (result < 0)
889 goto out; 889 goto out;
890 890
diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c
index e9214768cde9..08188743db53 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,
74 * which only requires access, and "set-[ac]time-to-X" which 74 * which only requires access, and "set-[ac]time-to-X" which
75 * requires ownership. 75 * requires ownership.
76 * So if it looks like it might be "set both to the same time which 76 * So if it looks like it might be "set both to the same time which
77 * is close to now", and if inode_change_ok fails, then we 77 * is close to now", and if setattr_prepare fails, then we
78 * convert to "set to now" instead of "set to explicit time" 78 * convert to "set to now" instead of "set to explicit time"
79 * 79 *
80 * We only call inode_change_ok as the last test as technically 80 * We only call setattr_prepare as the last test as technically
81 * it is not an interface that we should be using. 81 * it is not an interface that we should be using.
82 */ 82 */
83#define BOTH_TIME_SET (ATTR_ATIME_SET | ATTR_MTIME_SET) 83#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,
92 * request is. We require it be within 30 minutes of now. 92 * request is. We require it be within 30 minutes of now.
93 */ 93 */
94 time_t delta = iap->ia_atime.tv_sec - get_seconds(); 94 time_t delta = iap->ia_atime.tv_sec - get_seconds();
95 struct inode *inode;
96 95
97 nfserr = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP); 96 nfserr = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP);
98 if (nfserr) 97 if (nfserr)
99 goto done; 98 goto done;
100 inode = d_inode(fhp->fh_dentry);
101 99
102 if (delta < 0) 100 if (delta < 0)
103 delta = -delta; 101 delta = -delta;
104 if (delta < MAX_TOUCH_TIME_ERROR && 102 if (delta < MAX_TOUCH_TIME_ERROR &&
105 inode_change_ok(inode, iap) != 0) { 103 setattr_prepare(fhp->fh_dentry, iap) != 0) {
106 /* 104 /*
107 * Turn off ATTR_[AM]TIME_SET but leave ATTR_[AM]TIME. 105 * Turn off ATTR_[AM]TIME_SET but leave ATTR_[AM]TIME.
108 * This will cause notify_change to set these times 106 * This will cause notify_change to set these times
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index af04f553d7c9..402c325e0467 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -829,7 +829,7 @@ int nilfs_setattr(struct dentry *dentry, struct iattr *iattr)
829 struct super_block *sb = inode->i_sb; 829 struct super_block *sb = inode->i_sb;
830 int err; 830 int err;
831 831
832 err = inode_change_ok(inode, iattr); 832 err = setattr_prepare(dentry, iattr);
833 if (err) 833 if (err)
834 return err; 834 return err;
835 835
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index f548629dfaac..bf72a2c58b75 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -1850,7 +1850,7 @@ again:
1850 * pages being swapped out between us bringing them into memory 1850 * pages being swapped out between us bringing them into memory
1851 * and doing the actual copying. 1851 * and doing the actual copying.
1852 */ 1852 */
1853 if (unlikely(iov_iter_fault_in_multipages_readable(i, bytes))) { 1853 if (unlikely(iov_iter_fault_in_readable(i, bytes))) {
1854 status = -EFAULT; 1854 status = -EFAULT;
1855 break; 1855 break;
1856 } 1856 }
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index e01287c964a8..9d7a44872df5 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -2893,7 +2893,7 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr)
2893 int err; 2893 int err;
2894 unsigned int ia_valid = attr->ia_valid; 2894 unsigned int ia_valid = attr->ia_valid;
2895 2895
2896 err = inode_change_ok(vi, attr); 2896 err = setattr_prepare(dentry, attr);
2897 if (err) 2897 if (err)
2898 goto out; 2898 goto out;
2899 /* We do not support NTFS ACLs yet. */ 2899 /* We do not support NTFS ACLs yet. */
diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
index 2162434728c0..164307b99405 100644
--- a/fs/ocfs2/acl.c
+++ b/fs/ocfs2/acl.c
@@ -241,13 +241,11 @@ int ocfs2_set_acl(handle_t *handle,
241 case ACL_TYPE_ACCESS: 241 case ACL_TYPE_ACCESS:
242 name_index = OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS; 242 name_index = OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS;
243 if (acl) { 243 if (acl) {
244 umode_t mode = inode->i_mode; 244 umode_t mode;
245 ret = posix_acl_equiv_mode(acl, &mode);
246 if (ret < 0)
247 return ret;
248 245
249 if (ret == 0) 246 ret = posix_acl_update_mode(inode, &mode, &acl);
250 acl = NULL; 247 if (ret)
248 return ret;
251 249
252 ret = ocfs2_acl_set_mode(inode, di_bh, 250 ret = ocfs2_acl_set_mode(inode, di_bh,
253 handle, mode); 251 handle, mode);
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
index 354cdf9714aa..a0c3e03f9cd3 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)
211 struct inode *inode = d_inode(dentry); 211 struct inode *inode = d_inode(dentry);
212 212
213 attr->ia_valid &= ~ATTR_SIZE; 213 attr->ia_valid &= ~ATTR_SIZE;
214 error = inode_change_ok(inode, attr); 214 error = setattr_prepare(dentry, attr);
215 if (error) 215 if (error)
216 return error; 216 return error;
217 217
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 8f91639f8364..5e1901546868 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1155,7 +1155,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
1155 if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) 1155 if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
1156 return 0; 1156 return 0;
1157 1157
1158 status = inode_change_ok(inode, attr); 1158 status = setattr_prepare(dentry, attr);
1159 if (status) 1159 if (status)
1160 return status; 1160 return status;
1161 1161
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)
349 struct inode *inode = d_inode(dentry); 349 struct inode *inode = d_inode(dentry);
350 int error; 350 int error;
351 351
352 error = inode_change_ok(inode, attr); 352 error = setattr_prepare(dentry, attr);
353 if (error) 353 if (error)
354 return error; 354 return error;
355 355
diff --git a/fs/open.c b/fs/open.c
index 4fd6e256f4f4..8aeb08bb278b 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -68,6 +68,7 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
68long vfs_truncate(const struct path *path, loff_t length) 68long vfs_truncate(const struct path *path, loff_t length)
69{ 69{
70 struct inode *inode; 70 struct inode *inode;
71 struct dentry *upperdentry;
71 long error; 72 long error;
72 73
73 inode = path->dentry->d_inode; 74 inode = path->dentry->d_inode;
@@ -90,7 +91,17 @@ long vfs_truncate(const struct path *path, loff_t length)
90 if (IS_APPEND(inode)) 91 if (IS_APPEND(inode))
91 goto mnt_drop_write_and_out; 92 goto mnt_drop_write_and_out;
92 93
93 error = get_write_access(inode); 94 /*
95 * If this is an overlayfs then do as if opening the file so we get
96 * write access on the upper inode, not on the overlay inode. For
97 * non-overlay filesystems d_real() is an identity function.
98 */
99 upperdentry = d_real(path->dentry, NULL, O_WRONLY);
100 error = PTR_ERR(upperdentry);
101 if (IS_ERR(upperdentry))
102 goto mnt_drop_write_and_out;
103
104 error = get_write_access(upperdentry->d_inode);
94 if (error) 105 if (error)
95 goto mnt_drop_write_and_out; 106 goto mnt_drop_write_and_out;
96 107
@@ -109,7 +120,7 @@ long vfs_truncate(const struct path *path, loff_t length)
109 error = do_truncate(path->dentry, length, 0, NULL); 120 error = do_truncate(path->dentry, length, 0, NULL);
110 121
111put_write_and_out: 122put_write_and_out:
112 put_write_access(inode); 123 put_write_access(upperdentry->d_inode);
113mnt_drop_write_and_out: 124mnt_drop_write_and_out:
114 mnt_drop_write(path->mnt); 125 mnt_drop_write(path->mnt);
115out: 126out:
@@ -726,7 +737,7 @@ static int do_dentry_open(struct file *f,
726 if (error) 737 if (error)
727 goto cleanup_all; 738 goto cleanup_all;
728 739
729 error = break_lease(inode, f->f_flags); 740 error = break_lease(locks_inode(f), f->f_flags);
730 if (error) 741 if (error)
731 goto cleanup_all; 742 goto cleanup_all;
732 743
diff --git a/fs/orangefs/acl.c b/fs/orangefs/acl.c
index 28f2195cd798..7a3754488312 100644
--- a/fs/orangefs/acl.c
+++ b/fs/orangefs/acl.c
@@ -73,14 +73,11 @@ int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
73 case ACL_TYPE_ACCESS: 73 case ACL_TYPE_ACCESS:
74 name = XATTR_NAME_POSIX_ACL_ACCESS; 74 name = XATTR_NAME_POSIX_ACL_ACCESS;
75 if (acl) { 75 if (acl) {
76 umode_t mode = inode->i_mode; 76 umode_t mode;
77 /* 77
78 * can we represent this with the traditional file 78 error = posix_acl_update_mode(inode, &mode, &acl);
79 * mode permission bits? 79 if (error) {
80 */ 80 gossip_err("%s: posix_acl_update_mode err: %d\n",
81 error = posix_acl_equiv_mode(acl, &mode);
82 if (error < 0) {
83 gossip_err("%s: posix_acl_equiv_mode err: %d\n",
84 __func__, 81 __func__,
85 error); 82 error);
86 return error; 83 return error;
@@ -90,8 +87,6 @@ int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
90 SetModeFlag(orangefs_inode); 87 SetModeFlag(orangefs_inode);
91 inode->i_mode = mode; 88 inode->i_mode = mode;
92 mark_inode_dirty_sync(inode); 89 mark_inode_dirty_sync(inode);
93 if (error == 0)
94 acl = NULL;
95 } 90 }
96 break; 91 break;
97 case ACL_TYPE_DEFAULT: 92 case ACL_TYPE_DEFAULT:
diff --git a/fs/orangefs/dir.c b/fs/orangefs/dir.c
index 324f0af40d7b..284373a57a08 100644
--- a/fs/orangefs/dir.c
+++ b/fs/orangefs/dir.c
@@ -177,8 +177,8 @@ static int orangefs_readdir(struct file *file, struct dir_context *ctx)
177 } 177 }
178 178
179 gossip_debug(GOSSIP_DIR_DEBUG, 179 gossip_debug(GOSSIP_DIR_DEBUG,
180 "orangefs_readdir called on %s (pos=%llu)\n", 180 "orangefs_readdir called on %pd (pos=%llu)\n",
181 dentry->d_name.name, llu(pos)); 181 dentry, llu(pos));
182 182
183 memset(&readdir_response, 0, sizeof(readdir_response)); 183 memset(&readdir_response, 0, sizeof(readdir_response));
184 184
diff --git a/fs/orangefs/file.c b/fs/orangefs/file.c
index 3386886596d6..2aa088ab713b 100644
--- a/fs/orangefs/file.c
+++ b/fs/orangefs/file.c
@@ -611,8 +611,8 @@ static int orangefs_file_mmap(struct file *file, struct vm_area_struct *vma)
611static int orangefs_file_release(struct inode *inode, struct file *file) 611static int orangefs_file_release(struct inode *inode, struct file *file)
612{ 612{
613 gossip_debug(GOSSIP_FILE_DEBUG, 613 gossip_debug(GOSSIP_FILE_DEBUG,
614 "orangefs_file_release: called on %s\n", 614 "orangefs_file_release: called on %pD\n",
615 file->f_path.dentry->d_name.name); 615 file);
616 616
617 orangefs_flush_inode(inode); 617 orangefs_flush_inode(inode);
618 618
diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
index 28a0557a69be..c83846fb9b14 100644
--- a/fs/orangefs/inode.c
+++ b/fs/orangefs/inode.c
@@ -129,8 +129,8 @@ static ssize_t orangefs_direct_IO(struct kiocb *iocb,
129 struct iov_iter *iter) 129 struct iov_iter *iter)
130{ 130{
131 gossip_debug(GOSSIP_INODE_DEBUG, 131 gossip_debug(GOSSIP_INODE_DEBUG,
132 "orangefs_direct_IO: %s\n", 132 "orangefs_direct_IO: %pD\n",
133 iocb->ki_filp->f_path.dentry->d_name.name); 133 iocb->ki_filp);
134 134
135 return -EINVAL; 135 return -EINVAL;
136} 136}
@@ -216,10 +216,10 @@ int orangefs_setattr(struct dentry *dentry, struct iattr *iattr)
216 struct inode *inode = dentry->d_inode; 216 struct inode *inode = dentry->d_inode;
217 217
218 gossip_debug(GOSSIP_INODE_DEBUG, 218 gossip_debug(GOSSIP_INODE_DEBUG,
219 "orangefs_setattr: called on %s\n", 219 "orangefs_setattr: called on %pd\n",
220 dentry->d_name.name); 220 dentry);
221 221
222 ret = inode_change_ok(inode, iattr); 222 ret = setattr_prepare(dentry, iattr);
223 if (ret) 223 if (ret)
224 goto out; 224 goto out;
225 225
@@ -259,8 +259,8 @@ int orangefs_getattr(struct vfsmount *mnt,
259 struct orangefs_inode_s *orangefs_inode = NULL; 259 struct orangefs_inode_s *orangefs_inode = NULL;
260 260
261 gossip_debug(GOSSIP_INODE_DEBUG, 261 gossip_debug(GOSSIP_INODE_DEBUG,
262 "orangefs_getattr: called on %s\n", 262 "orangefs_getattr: called on %pd\n",
263 dentry->d_name.name); 263 dentry);
264 264
265 ret = orangefs_inode_getattr(inode, 0, 0); 265 ret = orangefs_inode_getattr(inode, 0, 0);
266 if (ret == 0) { 266 if (ret == 0) {
diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
index 35269e31de92..0e34fcfa4d51 100644
--- a/fs/orangefs/namei.c
+++ b/fs/orangefs/namei.c
@@ -24,9 +24,9 @@ static int orangefs_create(struct inode *dir,
24 struct inode *inode; 24 struct inode *inode;
25 int ret; 25 int ret;
26 26
27 gossip_debug(GOSSIP_NAME_DEBUG, "%s: %s\n", 27 gossip_debug(GOSSIP_NAME_DEBUG, "%s: %pd\n",
28 __func__, 28 __func__,
29 dentry->d_name.name); 29 dentry);
30 30
31 new_op = op_alloc(ORANGEFS_VFS_OP_CREATE); 31 new_op = op_alloc(ORANGEFS_VFS_OP_CREATE);
32 if (!new_op) 32 if (!new_op)
@@ -43,9 +43,9 @@ static int orangefs_create(struct inode *dir,
43 ret = service_operation(new_op, __func__, get_interruptible_flag(dir)); 43 ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
44 44
45 gossip_debug(GOSSIP_NAME_DEBUG, 45 gossip_debug(GOSSIP_NAME_DEBUG,
46 "%s: %s: handle:%pU: fsid:%d: new_op:%p: ret:%d:\n", 46 "%s: %pd: handle:%pU: fsid:%d: new_op:%p: ret:%d:\n",
47 __func__, 47 __func__,
48 dentry->d_name.name, 48 dentry,
49 &new_op->downcall.resp.create.refn.khandle, 49 &new_op->downcall.resp.create.refn.khandle,
50 new_op->downcall.resp.create.refn.fs_id, 50 new_op->downcall.resp.create.refn.fs_id,
51 new_op, 51 new_op,
@@ -57,18 +57,18 @@ static int orangefs_create(struct inode *dir,
57 inode = orangefs_new_inode(dir->i_sb, dir, S_IFREG | mode, 0, 57 inode = orangefs_new_inode(dir->i_sb, dir, S_IFREG | mode, 0,
58 &new_op->downcall.resp.create.refn); 58 &new_op->downcall.resp.create.refn);
59 if (IS_ERR(inode)) { 59 if (IS_ERR(inode)) {
60 gossip_err("%s: Failed to allocate inode for file :%s:\n", 60 gossip_err("%s: Failed to allocate inode for file :%pd:\n",
61 __func__, 61 __func__,
62 dentry->d_name.name); 62 dentry);
63 ret = PTR_ERR(inode); 63 ret = PTR_ERR(inode);
64 goto out; 64 goto out;
65 } 65 }
66 66
67 gossip_debug(GOSSIP_NAME_DEBUG, 67 gossip_debug(GOSSIP_NAME_DEBUG,
68 "%s: Assigned inode :%pU: for file :%s:\n", 68 "%s: Assigned inode :%pU: for file :%pd:\n",
69 __func__, 69 __func__,
70 get_khandle_from_ino(inode), 70 get_khandle_from_ino(inode),
71 dentry->d_name.name); 71 dentry);
72 72
73 d_instantiate(dentry, inode); 73 d_instantiate(dentry, inode);
74 unlock_new_inode(inode); 74 unlock_new_inode(inode);
@@ -76,9 +76,9 @@ static int orangefs_create(struct inode *dir,
76 ORANGEFS_I(inode)->getattr_time = jiffies - 1; 76 ORANGEFS_I(inode)->getattr_time = jiffies - 1;
77 77
78 gossip_debug(GOSSIP_NAME_DEBUG, 78 gossip_debug(GOSSIP_NAME_DEBUG,
79 "%s: dentry instantiated for %s\n", 79 "%s: dentry instantiated for %pd\n",
80 __func__, 80 __func__,
81 dentry->d_name.name); 81 dentry);
82 82
83 SetMtimeFlag(parent); 83 SetMtimeFlag(parent);
84 dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb); 84 dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb);
@@ -87,9 +87,9 @@ static int orangefs_create(struct inode *dir,
87out: 87out:
88 op_release(new_op); 88 op_release(new_op);
89 gossip_debug(GOSSIP_NAME_DEBUG, 89 gossip_debug(GOSSIP_NAME_DEBUG,
90 "%s: %s: returning %d\n", 90 "%s: %pd: returning %d\n",
91 __func__, 91 __func__,
92 dentry->d_name.name, 92 dentry,
93 ret); 93 ret);
94 return ret; 94 return ret;
95} 95}
@@ -115,8 +115,8 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry,
115 * -EEXIST on O_EXCL opens, which is broken if we skip this lookup 115 * -EEXIST on O_EXCL opens, which is broken if we skip this lookup
116 * in the create path) 116 * in the create path)
117 */ 117 */
118 gossip_debug(GOSSIP_NAME_DEBUG, "%s called on %s\n", 118 gossip_debug(GOSSIP_NAME_DEBUG, "%s called on %pd\n",
119 __func__, dentry->d_name.name); 119 __func__, dentry);
120 120
121 if (dentry->d_name.len > (ORANGEFS_NAME_MAX - 1)) 121 if (dentry->d_name.len > (ORANGEFS_NAME_MAX - 1))
122 return ERR_PTR(-ENAMETOOLONG); 122 return ERR_PTR(-ENAMETOOLONG);
@@ -169,9 +169,9 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry,
169 169
170 gossip_debug(GOSSIP_NAME_DEBUG, 170 gossip_debug(GOSSIP_NAME_DEBUG,
171 "orangefs_lookup: Adding *negative* dentry " 171 "orangefs_lookup: Adding *negative* dentry "
172 "%p for %s\n", 172 "%p for %pd\n",
173 dentry, 173 dentry,
174 dentry->d_name.name); 174 dentry);
175 175
176 d_add(dentry, NULL); 176 d_add(dentry, NULL);
177 res = NULL; 177 res = NULL;
@@ -224,10 +224,10 @@ static int orangefs_unlink(struct inode *dir, struct dentry *dentry)
224 int ret; 224 int ret;
225 225
226 gossip_debug(GOSSIP_NAME_DEBUG, 226 gossip_debug(GOSSIP_NAME_DEBUG,
227 "%s: called on %s\n" 227 "%s: called on %pd\n"
228 " (inode %pU): Parent is %pU | fs_id %d\n", 228 " (inode %pU): Parent is %pU | fs_id %d\n",
229 __func__, 229 __func__,
230 dentry->d_name.name, 230 dentry,
231 get_khandle_from_ino(inode), 231 get_khandle_from_ino(inode),
232 &parent->refn.khandle, 232 &parent->refn.khandle,
233 parent->refn.fs_id); 233 parent->refn.fs_id);
@@ -326,9 +326,9 @@ static int orangefs_symlink(struct inode *dir,
326 ORANGEFS_I(inode)->getattr_time = jiffies - 1; 326 ORANGEFS_I(inode)->getattr_time = jiffies - 1;
327 327
328 gossip_debug(GOSSIP_NAME_DEBUG, 328 gossip_debug(GOSSIP_NAME_DEBUG,
329 "Inode (Symlink) %pU -> %s\n", 329 "Inode (Symlink) %pU -> %pd\n",
330 get_khandle_from_ino(inode), 330 get_khandle_from_ino(inode),
331 dentry->d_name.name); 331 dentry);
332 332
333 SetMtimeFlag(parent); 333 SetMtimeFlag(parent);
334 dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb); 334 dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb);
@@ -390,9 +390,9 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
390 ORANGEFS_I(inode)->getattr_time = jiffies - 1; 390 ORANGEFS_I(inode)->getattr_time = jiffies - 1;
391 391
392 gossip_debug(GOSSIP_NAME_DEBUG, 392 gossip_debug(GOSSIP_NAME_DEBUG,
393 "Inode (Directory) %pU -> %s\n", 393 "Inode (Directory) %pU -> %pd\n",
394 get_khandle_from_ino(inode), 394 get_khandle_from_ino(inode),
395 dentry->d_name.name); 395 dentry);
396 396
397 /* 397 /*
398 * NOTE: we have no good way to keep nlink consistent for directories 398 * NOTE: we have no good way to keep nlink consistent for directories
diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c
index 9b24107c82a8..eb09aa026723 100644
--- a/fs/orangefs/orangefs-debugfs.c
+++ b/fs/orangefs/orangefs-debugfs.c
@@ -428,8 +428,8 @@ static ssize_t orangefs_debug_write(struct file *file,
428 struct client_debug_mask c_mask = { NULL, 0, 0 }; 428 struct client_debug_mask c_mask = { NULL, 0, 0 };
429 429
430 gossip_debug(GOSSIP_DEBUGFS_DEBUG, 430 gossip_debug(GOSSIP_DEBUGFS_DEBUG,
431 "orangefs_debug_write: %s\n", 431 "orangefs_debug_write: %pD\n",
432 file->f_path.dentry->d_name.name); 432 file);
433 433
434 /* 434 /*
435 * Thwart users who try to jamb a ridiculous number 435 * Thwart users who try to jamb a ridiculous number
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index c75625c1efa3..251e5253f2c1 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -53,7 +53,7 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
53 * inode_newsize_ok() will always check against MAX_LFS_FILESIZE and not 53 * inode_newsize_ok() will always check against MAX_LFS_FILESIZE and not
54 * check for a swapfile (which this won't be anyway). 54 * check for a swapfile (which this won't be anyway).
55 */ 55 */
56 err = inode_change_ok(dentry->d_inode, attr); 56 err = setattr_prepare(dentry, attr);
57 if (err) 57 if (err)
58 return err; 58 return err;
59 59
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index e2a94a26767b..3d0b9dee2b76 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -1320,7 +1320,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
1320 sb->s_xattr = ovl_xattr_handlers; 1320 sb->s_xattr = ovl_xattr_handlers;
1321 sb->s_root = root_dentry; 1321 sb->s_root = root_dentry;
1322 sb->s_fs_info = ufs; 1322 sb->s_fs_info = ufs;
1323 sb->s_flags |= MS_POSIXACL; 1323 sb->s_flags |= MS_POSIXACL | MS_NOREMOTELOCK;
1324 1324
1325 return 0; 1325 return 0;
1326 1326
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 59d47ab0791a..da3f760a7e88 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -598,13 +598,14 @@ posix_acl_create(struct inode *dir, umode_t *mode,
598 if (IS_ERR(p)) 598 if (IS_ERR(p))
599 return PTR_ERR(p); 599 return PTR_ERR(p);
600 600
601 ret = -ENOMEM;
601 clone = posix_acl_clone(p, GFP_NOFS); 602 clone = posix_acl_clone(p, GFP_NOFS);
602 if (!clone) 603 if (!clone)
603 goto no_mem; 604 goto err_release;
604 605
605 ret = posix_acl_create_masq(clone, mode); 606 ret = posix_acl_create_masq(clone, mode);
606 if (ret < 0) 607 if (ret < 0)
607 goto no_mem_clone; 608 goto err_release_clone;
608 609
609 if (ret == 0) 610 if (ret == 0)
610 posix_acl_release(clone); 611 posix_acl_release(clone);
@@ -618,14 +619,45 @@ posix_acl_create(struct inode *dir, umode_t *mode,
618 619
619 return 0; 620 return 0;
620 621
621no_mem_clone: 622err_release_clone:
622 posix_acl_release(clone); 623 posix_acl_release(clone);
623no_mem: 624err_release:
624 posix_acl_release(p); 625 posix_acl_release(p);
625 return -ENOMEM; 626 return ret;
626} 627}
627EXPORT_SYMBOL_GPL(posix_acl_create); 628EXPORT_SYMBOL_GPL(posix_acl_create);
628 629
630/**
631 * posix_acl_update_mode - update mode in set_acl
632 *
633 * Update the file mode when setting an ACL: compute the new file permission
634 * bits based on the ACL. In addition, if the ACL is equivalent to the new
635 * file mode, set *acl to NULL to indicate that no ACL should be set.
636 *
637 * As with chmod, clear the setgit bit if the caller is not in the owning group
638 * or capable of CAP_FSETID (see inode_change_ok).
639 *
640 * Called from set_acl inode operations.
641 */
642int posix_acl_update_mode(struct inode *inode, umode_t *mode_p,
643 struct posix_acl **acl)
644{
645 umode_t mode = inode->i_mode;
646 int error;
647
648 error = posix_acl_equiv_mode(*acl, &mode);
649 if (error < 0)
650 return error;
651 if (error == 0)
652 *acl = NULL;
653 if (!in_group_p(inode->i_gid) &&
654 !capable_wrt_inode_uidgid(inode, CAP_FSETID))
655 mode &= ~S_ISGID;
656 *mode_p = mode;
657 return 0;
658}
659EXPORT_SYMBOL(posix_acl_update_mode);
660
629/* 661/*
630 * Fix up the uids and gids in posix acl extended attributes in place. 662 * Fix up the uids and gids in posix acl extended attributes in place.
631 */ 663 */
@@ -633,15 +665,15 @@ static void posix_acl_fix_xattr_userns(
633 struct user_namespace *to, struct user_namespace *from, 665 struct user_namespace *to, struct user_namespace *from,
634 void *value, size_t size) 666 void *value, size_t size)
635{ 667{
636 posix_acl_xattr_header *header = (posix_acl_xattr_header *)value; 668 struct posix_acl_xattr_header *header = value;
637 posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end; 669 struct posix_acl_xattr_entry *entry = (void *)(header + 1), *end;
638 int count; 670 int count;
639 kuid_t uid; 671 kuid_t uid;
640 kgid_t gid; 672 kgid_t gid;
641 673
642 if (!value) 674 if (!value)
643 return; 675 return;
644 if (size < sizeof(posix_acl_xattr_header)) 676 if (size < sizeof(struct posix_acl_xattr_header))
645 return; 677 return;
646 if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION)) 678 if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION))
647 return; 679 return;
@@ -691,15 +723,15 @@ struct posix_acl *
691posix_acl_from_xattr(struct user_namespace *user_ns, 723posix_acl_from_xattr(struct user_namespace *user_ns,
692 const void *value, size_t size) 724 const void *value, size_t size)
693{ 725{
694 posix_acl_xattr_header *header = (posix_acl_xattr_header *)value; 726 const struct posix_acl_xattr_header *header = value;
695 posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end; 727 const struct posix_acl_xattr_entry *entry = (const void *)(header + 1), *end;
696 int count; 728 int count;
697 struct posix_acl *acl; 729 struct posix_acl *acl;
698 struct posix_acl_entry *acl_e; 730 struct posix_acl_entry *acl_e;
699 731
700 if (!value) 732 if (!value)
701 return NULL; 733 return NULL;
702 if (size < sizeof(posix_acl_xattr_header)) 734 if (size < sizeof(struct posix_acl_xattr_header))
703 return ERR_PTR(-EINVAL); 735 return ERR_PTR(-EINVAL);
704 if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION)) 736 if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION))
705 return ERR_PTR(-EOPNOTSUPP); 737 return ERR_PTR(-EOPNOTSUPP);
@@ -760,8 +792,8 @@ int
760posix_acl_to_xattr(struct user_namespace *user_ns, const struct posix_acl *acl, 792posix_acl_to_xattr(struct user_namespace *user_ns, const struct posix_acl *acl,
761 void *buffer, size_t size) 793 void *buffer, size_t size)
762{ 794{
763 posix_acl_xattr_header *ext_acl = (posix_acl_xattr_header *)buffer; 795 struct posix_acl_xattr_header *ext_acl = buffer;
764 posix_acl_xattr_entry *ext_entry; 796 struct posix_acl_xattr_entry *ext_entry;
765 int real_size, n; 797 int real_size, n;
766 798
767 real_size = posix_acl_xattr_size(acl->a_count); 799 real_size = posix_acl_xattr_size(acl->a_count);
@@ -770,7 +802,7 @@ posix_acl_to_xattr(struct user_namespace *user_ns, const struct posix_acl *acl,
770 if (real_size > size) 802 if (real_size > size)
771 return -ERANGE; 803 return -ERANGE;
772 804
773 ext_entry = ext_acl->a_entries; 805 ext_entry = (void *)(ext_acl + 1);
774 ext_acl->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION); 806 ext_acl->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION);
775 807
776 for (n=0; n < acl->a_count; n++, ext_entry++) { 808 for (n=0; n < acl->a_count; n++, ext_entry++) {
diff --git a/fs/proc/base.c b/fs/proc/base.c
index dc7fe5f3a53c..29fd7ef97be9 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -400,23 +400,6 @@ static const struct file_operations proc_pid_cmdline_ops = {
400 .llseek = generic_file_llseek, 400 .llseek = generic_file_llseek,
401}; 401};
402 402
403static int proc_pid_auxv(struct seq_file *m, struct pid_namespace *ns,
404 struct pid *pid, struct task_struct *task)
405{
406 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ_FSCREDS);
407 if (mm && !IS_ERR(mm)) {
408 unsigned int nwords = 0;
409 do {
410 nwords += 2;
411 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
412 seq_write(m, mm->saved_auxv, nwords * sizeof(mm->saved_auxv[0]));
413 mmput(mm);
414 return 0;
415 } else
416 return PTR_ERR(mm);
417}
418
419
420#ifdef CONFIG_KALLSYMS 403#ifdef CONFIG_KALLSYMS
421/* 404/*
422 * Provides a wchan file via kallsyms in a proper one-value-per-file format. 405 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
@@ -709,7 +692,7 @@ int proc_setattr(struct dentry *dentry, struct iattr *attr)
709 if (attr->ia_valid & ATTR_MODE) 692 if (attr->ia_valid & ATTR_MODE)
710 return -EPERM; 693 return -EPERM;
711 694
712 error = inode_change_ok(inode, attr); 695 error = setattr_prepare(dentry, attr);
713 if (error) 696 if (error)
714 return error; 697 return error;
715 698
@@ -1014,6 +997,30 @@ static const struct file_operations proc_environ_operations = {
1014 .release = mem_release, 997 .release = mem_release,
1015}; 998};
1016 999
1000static int auxv_open(struct inode *inode, struct file *file)
1001{
1002 return __mem_open(inode, file, PTRACE_MODE_READ_FSCREDS);
1003}
1004
1005static ssize_t auxv_read(struct file *file, char __user *buf,
1006 size_t count, loff_t *ppos)
1007{
1008 struct mm_struct *mm = file->private_data;
1009 unsigned int nwords = 0;
1010 do {
1011 nwords += 2;
1012 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
1013 return simple_read_from_buffer(buf, count, ppos, mm->saved_auxv,
1014 nwords * sizeof(mm->saved_auxv[0]));
1015}
1016
1017static const struct file_operations proc_auxv_operations = {
1018 .open = auxv_open,
1019 .read = auxv_read,
1020 .llseek = generic_file_llseek,
1021 .release = mem_release,
1022};
1023
1017static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count, 1024static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count,
1018 loff_t *ppos) 1025 loff_t *ppos)
1019{ 1026{
@@ -2842,7 +2849,7 @@ static const struct pid_entry tgid_base_stuff[] = {
2842 DIR("net", S_IRUGO|S_IXUGO, proc_net_inode_operations, proc_net_operations), 2849 DIR("net", S_IRUGO|S_IXUGO, proc_net_inode_operations, proc_net_operations),
2843#endif 2850#endif
2844 REG("environ", S_IRUSR, proc_environ_operations), 2851 REG("environ", S_IRUSR, proc_environ_operations),
2845 ONE("auxv", S_IRUSR, proc_pid_auxv), 2852 REG("auxv", S_IRUSR, proc_auxv_operations),
2846 ONE("status", S_IRUGO, proc_pid_status), 2853 ONE("status", S_IRUGO, proc_pid_status),
2847 ONE("personality", S_IRUSR, proc_pid_personality), 2854 ONE("personality", S_IRUSR, proc_pid_personality),
2848 ONE("limits", S_IRUGO, proc_pid_limits), 2855 ONE("limits", S_IRUGO, proc_pid_limits),
@@ -3230,7 +3237,7 @@ static const struct pid_entry tid_base_stuff[] = {
3230 DIR("net", S_IRUGO|S_IXUGO, proc_net_inode_operations, proc_net_operations), 3237 DIR("net", S_IRUGO|S_IXUGO, proc_net_inode_operations, proc_net_operations),
3231#endif 3238#endif
3232 REG("environ", S_IRUSR, proc_environ_operations), 3239 REG("environ", S_IRUSR, proc_environ_operations),
3233 ONE("auxv", S_IRUSR, proc_pid_auxv), 3240 REG("auxv", S_IRUSR, proc_auxv_operations),
3234 ONE("status", S_IRUGO, proc_pid_status), 3241 ONE("status", S_IRUGO, proc_pid_status),
3235 ONE("personality", S_IRUSR, proc_pid_personality), 3242 ONE("personality", S_IRUSR, proc_pid_personality),
3236 ONE("limits", S_IRUGO, proc_pid_limits), 3243 ONE("limits", S_IRUGO, proc_pid_limits),
diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index 01df23cc81f6..d21dafef3102 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -31,7 +31,7 @@ static int seq_show(struct seq_file *m, void *v)
31 put_task_struct(task); 31 put_task_struct(task);
32 32
33 if (files) { 33 if (files) {
34 int fd = proc_fd(m->private); 34 unsigned int fd = proc_fd(m->private);
35 35
36 spin_lock(&files->file_lock); 36 spin_lock(&files->file_lock);
37 file = fcheck_files(files, fd); 37 file = fcheck_files(files, fd);
@@ -86,7 +86,7 @@ static int tid_fd_revalidate(struct dentry *dentry, unsigned int flags)
86 struct task_struct *task; 86 struct task_struct *task;
87 const struct cred *cred; 87 const struct cred *cred;
88 struct inode *inode; 88 struct inode *inode;
89 int fd; 89 unsigned int fd;
90 90
91 if (flags & LOOKUP_RCU) 91 if (flags & LOOKUP_RCU)
92 return -ECHILD; 92 return -ECHILD;
@@ -158,7 +158,7 @@ static int proc_fd_link(struct dentry *dentry, struct path *path)
158 } 158 }
159 159
160 if (files) { 160 if (files) {
161 int fd = proc_fd(d_inode(dentry)); 161 unsigned int fd = proc_fd(d_inode(dentry));
162 struct file *fd_file; 162 struct file *fd_file;
163 163
164 spin_lock(&files->file_lock); 164 spin_lock(&files->file_lock);
@@ -253,7 +253,7 @@ static int proc_readfd_common(struct file *file, struct dir_context *ctx,
253 continue; 253 continue;
254 rcu_read_unlock(); 254 rcu_read_unlock();
255 255
256 len = snprintf(name, sizeof(name), "%d", fd); 256 len = snprintf(name, sizeof(name), "%u", fd);
257 if (!proc_fill_cache(file, ctx, 257 if (!proc_fill_cache(file, ctx,
258 name, len, instantiate, p, 258 name, len, instantiate, p,
259 (void *)(unsigned long)fd)) 259 (void *)(unsigned long)fd))
diff --git a/fs/proc/fd.h b/fs/proc/fd.h
index 7c047f256ae2..46dafadd0083 100644
--- a/fs/proc/fd.h
+++ b/fs/proc/fd.h
@@ -11,7 +11,7 @@ extern const struct inode_operations proc_fdinfo_inode_operations;
11 11
12extern int proc_fd_permission(struct inode *inode, int mask); 12extern int proc_fd_permission(struct inode *inode, int mask);
13 13
14static inline int proc_fd(struct inode *inode) 14static inline unsigned int proc_fd(struct inode *inode)
15{ 15{
16 return PROC_I(inode)->fd; 16 return PROC_I(inode)->fd;
17} 17}
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index bca66d83a765..5f2dc2032c79 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -105,7 +105,7 @@ static int proc_notify_change(struct dentry *dentry, struct iattr *iattr)
105 struct proc_dir_entry *de = PDE(inode); 105 struct proc_dir_entry *de = PDE(inode);
106 int error; 106 int error;
107 107
108 error = inode_change_ok(inode, iattr); 108 error = setattr_prepare(dentry, iattr);
109 if (error) 109 if (error)
110 return error; 110 return error;
111 111
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index 7931c558c192..5378441ec1b7 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -60,7 +60,7 @@ union proc_op {
60 60
61struct proc_inode { 61struct proc_inode {
62 struct pid *pid; 62 struct pid *pid;
63 int fd; 63 unsigned int fd;
64 union proc_op op; 64 union proc_op op;
65 struct proc_dir_entry *pde; 65 struct proc_dir_entry *pde;
66 struct ctl_table_header *sysctl; 66 struct ctl_table_header *sysctl;
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 71025b9e2a4e..f908b78bce55 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -759,7 +759,7 @@ static int proc_sys_setattr(struct dentry *dentry, struct iattr *attr)
759 if (attr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID)) 759 if (attr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID))
760 return -EPERM; 760 return -EPERM;
761 761
762 error = inode_change_ok(inode, attr); 762 error = setattr_prepare(dentry, attr);
763 if (error) 763 if (error)
764 return error; 764 return error;
765 765
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index be3ddd189cd4..2bcbf4e77982 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)
169 int ret = 0; 169 int ret = 0;
170 170
171 /* POSIX UID/GID verification for setting inode attributes */ 171 /* POSIX UID/GID verification for setting inode attributes */
172 ret = inode_change_ok(inode, ia); 172 ret = setattr_prepare(dentry, ia);
173 if (ret) 173 if (ret)
174 return ret; 174 return ret;
175 175
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index c2c59f9ff04b..cb7f518d37ae 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -3312,7 +3312,7 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
3312 unsigned int ia_valid; 3312 unsigned int ia_valid;
3313 int error; 3313 int error;
3314 3314
3315 error = inode_change_ok(inode, attr); 3315 error = setattr_prepare(dentry, attr);
3316 if (error) 3316 if (error)
3317 return error; 3317 return error;
3318 3318
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
index dbed42f755e0..27376681c640 100644
--- a/fs/reiserfs/xattr_acl.c
+++ b/fs/reiserfs/xattr_acl.c
@@ -242,13 +242,9 @@ __reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
242 case ACL_TYPE_ACCESS: 242 case ACL_TYPE_ACCESS:
243 name = XATTR_NAME_POSIX_ACL_ACCESS; 243 name = XATTR_NAME_POSIX_ACL_ACCESS;
244 if (acl) { 244 if (acl) {
245 error = posix_acl_equiv_mode(acl, &inode->i_mode); 245 error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
246 if (error < 0) 246 if (error)
247 return error; 247 return error;
248 else {
249 if (error == 0)
250 acl = NULL;
251 }
252 } 248 }
253 break; 249 break;
254 case ACL_TYPE_DEFAULT: 250 case ACL_TYPE_DEFAULT:
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)
33 struct inode *inode = d_inode(dentry); 33 struct inode *inode = d_inode(dentry);
34 int error; 34 int error;
35 35
36 error = inode_change_ok(inode, attr); 36 error = setattr_prepare(dentry, attr);
37 if (error) 37 if (error)
38 return error; 38 return error;
39 39
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 7bbf420d1289..b0a6a53263f3 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1262,7 +1262,7 @@ int ubifs_setattr(struct dentry *dentry, struct iattr *attr)
1262 1262
1263 dbg_gen("ino %lu, mode %#x, ia_valid %#x", 1263 dbg_gen("ino %lu, mode %#x, ia_valid %#x",
1264 inode->i_ino, inode->i_mode, attr->ia_valid); 1264 inode->i_ino, inode->i_mode, attr->ia_valid);
1265 err = inode_change_ok(inode, attr); 1265 err = setattr_prepare(dentry, attr);
1266 if (err) 1266 if (err)
1267 return err; 1267 return err;
1268 1268
diff --git a/fs/udf/file.c b/fs/udf/file.c
index e855bf8d74b4..dbcb3a4a0cb9 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -261,7 +261,7 @@ static int udf_setattr(struct dentry *dentry, struct iattr *attr)
261 struct inode *inode = d_inode(dentry); 261 struct inode *inode = d_inode(dentry);
262 int error; 262 int error;
263 263
264 error = inode_change_ok(inode, attr); 264 error = setattr_prepare(dentry, attr);
265 if (error) 265 if (error)
266 return error; 266 return error;
267 267
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 9f49431e798d..e4a4d248a0f5 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -1208,7 +1208,7 @@ int ufs_setattr(struct dentry *dentry, struct iattr *attr)
1208 unsigned int ia_valid = attr->ia_valid; 1208 unsigned int ia_valid = attr->ia_valid;
1209 int error; 1209 int error;
1210 1210
1211 error = inode_change_ok(inode, attr); 1211 error = setattr_prepare(dentry, attr);
1212 if (error) 1212 if (error)
1213 return error; 1213 return error;
1214 1214
diff --git a/fs/utimes.c b/fs/utimes.c
index 794f5f5b1fb5..22307cdf7014 100644
--- a/fs/utimes.c
+++ b/fs/utimes.c
@@ -81,27 +81,13 @@ static int utimes_common(struct path *path, struct timespec *times)
81 newattrs.ia_valid |= ATTR_MTIME_SET; 81 newattrs.ia_valid |= ATTR_MTIME_SET;
82 } 82 }
83 /* 83 /*
84 * Tell inode_change_ok(), that this is an explicit time 84 * Tell setattr_prepare(), that this is an explicit time
85 * update, even if neither ATTR_ATIME_SET nor ATTR_MTIME_SET 85 * update, even if neither ATTR_ATIME_SET nor ATTR_MTIME_SET
86 * were used. 86 * were used.
87 */ 87 */
88 newattrs.ia_valid |= ATTR_TIMES_SET; 88 newattrs.ia_valid |= ATTR_TIMES_SET;
89 } else { 89 } else {
90 /* 90 newattrs.ia_valid |= ATTR_TOUCH;
91 * If times is NULL (or both times are UTIME_NOW),
92 * then we need to check permissions, because
93 * inode_change_ok() won't do it.
94 */
95 error = -EPERM;
96 if (IS_IMMUTABLE(inode))
97 goto mnt_drop_write_and_out;
98
99 error = -EACCES;
100 if (!inode_owner_or_capable(inode)) {
101 error = inode_permission(inode, MAY_WRITE);
102 if (error)
103 goto mnt_drop_write_and_out;
104 }
105 } 91 }
106retry_deleg: 92retry_deleg:
107 inode_lock(inode); 93 inode_lock(inode);
@@ -113,7 +99,6 @@ retry_deleg:
113 goto retry_deleg; 99 goto retry_deleg;
114 } 100 }
115 101
116mnt_drop_write_and_out:
117 mnt_drop_write(path->mnt); 102 mnt_drop_write(path->mnt);
118out: 103out:
119 return error; 104 return error;
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
index b6e527b8eccb..8a0dec89ca56 100644
--- a/fs/xfs/xfs_acl.c
+++ b/fs/xfs/xfs_acl.c
@@ -257,16 +257,11 @@ xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
257 return error; 257 return error;
258 258
259 if (type == ACL_TYPE_ACCESS) { 259 if (type == ACL_TYPE_ACCESS) {
260 umode_t mode = inode->i_mode; 260 umode_t mode;
261 error = posix_acl_equiv_mode(acl, &mode);
262
263 if (error <= 0) {
264 acl = NULL;
265
266 if (error < 0)
267 return error;
268 }
269 261
262 error = posix_acl_update_mode(inode, &mode, &acl);
263 if (error)
264 return error;
270 error = xfs_set_mode(inode, mode); 265 error = xfs_set_mode(inode, mode);
271 if (error) 266 if (error)
272 return error; 267 return error;
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 26acfbb331ae..62511687385c 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -901,7 +901,7 @@ xfs_file_fallocate(
901 901
902 iattr.ia_valid = ATTR_SIZE; 902 iattr.ia_valid = ATTR_SIZE;
903 iattr.ia_size = new_size; 903 iattr.ia_size = new_size;
904 error = xfs_setattr_size(ip, &iattr); 904 error = xfs_vn_setattr_size(file_dentry(file), &iattr);
905 if (error) 905 if (error)
906 goto out_unlock; 906 goto out_unlock;
907 } 907 }
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index e08eaea6327b..df22e1254c98 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1710,7 +1710,7 @@ xfs_inactive_truncate(
1710 /* 1710 /*
1711 * Log the inode size first to prevent stale data exposure in the event 1711 * Log the inode size first to prevent stale data exposure in the event
1712 * of a system crash before the truncate completes. See the related 1712 * of a system crash before the truncate completes. See the related
1713 * comment in xfs_setattr_size() for details. 1713 * comment in xfs_vn_setattr_size() for details.
1714 */ 1714 */
1715 ip->i_d.di_size = 0; 1715 ip->i_d.di_size = 0;
1716 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 1716 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 96a70fd1f5d6..0d9021f0551e 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -720,7 +720,7 @@ xfs_ioc_space(
720 iattr.ia_valid = ATTR_SIZE; 720 iattr.ia_valid = ATTR_SIZE;
721 iattr.ia_size = bf->l_start; 721 iattr.ia_size = bf->l_start;
722 722
723 error = xfs_setattr_size(ip, &iattr); 723 error = xfs_vn_setattr_size(file_dentry(filp), &iattr);
724 break; 724 break;
725 default: 725 default:
726 ASSERT(0); 726 ASSERT(0);
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index b24c3102fa93..ba99803eba98 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -542,6 +542,28 @@ xfs_setattr_time(
542 inode->i_mtime = iattr->ia_mtime; 542 inode->i_mtime = iattr->ia_mtime;
543} 543}
544 544
545static int
546xfs_vn_change_ok(
547 struct dentry *dentry,
548 struct iattr *iattr)
549{
550 struct xfs_mount *mp = XFS_I(d_inode(dentry))->i_mount;
551
552 if (mp->m_flags & XFS_MOUNT_RDONLY)
553 return -EROFS;
554
555 if (XFS_FORCED_SHUTDOWN(mp))
556 return -EIO;
557
558 return setattr_prepare(dentry, iattr);
559}
560
561/*
562 * Set non-size attributes of an inode.
563 *
564 * Caution: The caller of this function is responsible for calling
565 * setattr_prepare() or otherwise verifying the change is fine.
566 */
545int 567int
546xfs_setattr_nonsize( 568xfs_setattr_nonsize(
547 struct xfs_inode *ip, 569 struct xfs_inode *ip,
@@ -558,21 +580,6 @@ xfs_setattr_nonsize(
558 struct xfs_dquot *udqp = NULL, *gdqp = NULL; 580 struct xfs_dquot *udqp = NULL, *gdqp = NULL;
559 struct xfs_dquot *olddquot1 = NULL, *olddquot2 = NULL; 581 struct xfs_dquot *olddquot1 = NULL, *olddquot2 = NULL;
560 582
561 trace_xfs_setattr(ip);
562
563 /* If acls are being inherited, we already have this checked */
564 if (!(flags & XFS_ATTR_NOACL)) {
565 if (mp->m_flags & XFS_MOUNT_RDONLY)
566 return -EROFS;
567
568 if (XFS_FORCED_SHUTDOWN(mp))
569 return -EIO;
570
571 error = inode_change_ok(inode, iattr);
572 if (error)
573 return error;
574 }
575
576 ASSERT((mask & ATTR_SIZE) == 0); 583 ASSERT((mask & ATTR_SIZE) == 0);
577 584
578 /* 585 /*
@@ -743,8 +750,27 @@ out_dqrele:
743 return error; 750 return error;
744} 751}
745 752
753int
754xfs_vn_setattr_nonsize(
755 struct dentry *dentry,
756 struct iattr *iattr)
757{
758 struct xfs_inode *ip = XFS_I(d_inode(dentry));
759 int error;
760
761 trace_xfs_setattr(ip);
762
763 error = xfs_vn_change_ok(dentry, iattr);
764 if (error)
765 return error;
766 return xfs_setattr_nonsize(ip, iattr, 0);
767}
768
746/* 769/*
747 * Truncate file. Must have write permission and not be a directory. 770 * Truncate file. Must have write permission and not be a directory.
771 *
772 * Caution: The caller of this function is responsible for calling
773 * setattr_prepare() or otherwise verifying the change is fine.
748 */ 774 */
749int 775int
750xfs_setattr_size( 776xfs_setattr_size(
@@ -759,18 +785,6 @@ xfs_setattr_size(
759 uint lock_flags = 0; 785 uint lock_flags = 0;
760 bool did_zeroing = false; 786 bool did_zeroing = false;
761 787
762 trace_xfs_setattr(ip);
763
764 if (mp->m_flags & XFS_MOUNT_RDONLY)
765 return -EROFS;
766
767 if (XFS_FORCED_SHUTDOWN(mp))
768 return -EIO;
769
770 error = inode_change_ok(inode, iattr);
771 if (error)
772 return error;
773
774 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); 788 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL));
775 ASSERT(xfs_isilocked(ip, XFS_MMAPLOCK_EXCL)); 789 ASSERT(xfs_isilocked(ip, XFS_MMAPLOCK_EXCL));
776 ASSERT(S_ISREG(inode->i_mode)); 790 ASSERT(S_ISREG(inode->i_mode));
@@ -942,16 +956,32 @@ out_trans_cancel:
942 goto out_unlock; 956 goto out_unlock;
943} 957}
944 958
959int
960xfs_vn_setattr_size(
961 struct dentry *dentry,
962 struct iattr *iattr)
963{
964 struct xfs_inode *ip = XFS_I(d_inode(dentry));
965 int error;
966
967 trace_xfs_setattr(ip);
968
969 error = xfs_vn_change_ok(dentry, iattr);
970 if (error)
971 return error;
972 return xfs_setattr_size(ip, iattr);
973}
974
945STATIC int 975STATIC int
946xfs_vn_setattr( 976xfs_vn_setattr(
947 struct dentry *dentry, 977 struct dentry *dentry,
948 struct iattr *iattr) 978 struct iattr *iattr)
949{ 979{
950 struct xfs_inode *ip = XFS_I(d_inode(dentry));
951 int error; 980 int error;
952 981
953 if (iattr->ia_valid & ATTR_SIZE) { 982 if (iattr->ia_valid & ATTR_SIZE) {
954 uint iolock = XFS_IOLOCK_EXCL; 983 struct xfs_inode *ip = XFS_I(d_inode(dentry));
984 uint iolock = XFS_IOLOCK_EXCL;
955 985
956 xfs_ilock(ip, iolock); 986 xfs_ilock(ip, iolock);
957 error = xfs_break_layouts(d_inode(dentry), &iolock, true); 987 error = xfs_break_layouts(d_inode(dentry), &iolock, true);
@@ -959,11 +989,11 @@ xfs_vn_setattr(
959 xfs_ilock(ip, XFS_MMAPLOCK_EXCL); 989 xfs_ilock(ip, XFS_MMAPLOCK_EXCL);
960 iolock |= XFS_MMAPLOCK_EXCL; 990 iolock |= XFS_MMAPLOCK_EXCL;
961 991
962 error = xfs_setattr_size(ip, iattr); 992 error = xfs_vn_setattr_size(dentry, iattr);
963 } 993 }
964 xfs_iunlock(ip, iolock); 994 xfs_iunlock(ip, iolock);
965 } else { 995 } else {
966 error = xfs_setattr_nonsize(ip, iattr, 0); 996 error = xfs_vn_setattr_nonsize(dentry, iattr);
967 } 997 }
968 998
969 return error; 999 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);
33extern void xfs_setattr_time(struct xfs_inode *ip, struct iattr *iattr); 33extern void xfs_setattr_time(struct xfs_inode *ip, struct iattr *iattr);
34extern int xfs_setattr_nonsize(struct xfs_inode *ip, struct iattr *vap, 34extern int xfs_setattr_nonsize(struct xfs_inode *ip, struct iattr *vap,
35 int flags); 35 int flags);
36extern int xfs_setattr_size(struct xfs_inode *ip, struct iattr *vap); 36extern int xfs_vn_setattr_nonsize(struct dentry *dentry, struct iattr *vap);
37extern int xfs_vn_setattr_size(struct dentry *dentry, struct iattr *vap);
37 38
38#endif /* __XFS_IOPS_H__ */ 39#endif /* __XFS_IOPS_H__ */
diff --git a/include/linux/compat.h b/include/linux/compat.h
index f964ef79e0ad..63609398ef9f 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -432,7 +432,6 @@ asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv,
432 432
433asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp); 433asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
434 434
435extern __printf(1, 2) int compat_printk(const char *fmt, ...);
436extern void sigset_from_compat(sigset_t *set, const compat_sigset_t *compat); 435extern void sigset_from_compat(sigset_t *set, const compat_sigset_t *compat);
437extern void sigset_to_compat(compat_sigset_t *compat, const sigset_t *set); 436extern void sigset_to_compat(compat_sigset_t *compat, const sigset_t *set);
438 437
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 5ff3e9a4fe5f..5beed7b30561 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -584,9 +584,10 @@ static inline struct dentry *d_real(struct dentry *dentry,
584 * If dentry is on an union/overlay, then return the underlying, real inode. 584 * If dentry is on an union/overlay, then return the underlying, real inode.
585 * Otherwise return d_inode(). 585 * Otherwise return d_inode().
586 */ 586 */
587static inline struct inode *d_real_inode(struct dentry *dentry) 587static inline struct inode *d_real_inode(const struct dentry *dentry)
588{ 588{
589 return d_backing_inode(d_real(dentry, NULL, 0)); 589 /* This usage of d_real() results in const dentry */
590 return d_backing_inode(d_real((struct dentry *) dentry, NULL, 0));
590} 591}
591 592
592 593
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
index 5295535b60c6..aca2a6a1d035 100644
--- a/include/linux/fdtable.h
+++ b/include/linux/fdtable.h
@@ -30,12 +30,12 @@ struct fdtable {
30 struct rcu_head rcu; 30 struct rcu_head rcu;
31}; 31};
32 32
33static inline bool close_on_exec(int fd, const struct fdtable *fdt) 33static inline bool close_on_exec(unsigned int fd, const struct fdtable *fdt)
34{ 34{
35 return test_bit(fd, fdt->close_on_exec); 35 return test_bit(fd, fdt->close_on_exec);
36} 36}
37 37
38static inline bool fd_is_open(int fd, const struct fdtable *fdt) 38static inline bool fd_is_open(unsigned int fd, const struct fdtable *fdt)
39{ 39{
40 return test_bit(fd, fdt->open_fds); 40 return test_bit(fd, fdt->open_fds);
41} 41}
@@ -57,7 +57,7 @@ struct files_struct {
57 * written part on a separate cache line in SMP 57 * written part on a separate cache line in SMP
58 */ 58 */
59 spinlock_t file_lock ____cacheline_aligned_in_smp; 59 spinlock_t file_lock ____cacheline_aligned_in_smp;
60 int next_fd; 60 unsigned int next_fd;
61 unsigned long close_on_exec_init[1]; 61 unsigned long close_on_exec_init[1];
62 unsigned long open_fds_init[1]; 62 unsigned long open_fds_init[1];
63 unsigned long full_fds_bits_init[1]; 63 unsigned long full_fds_bits_init[1];
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b04883e74579..4ba5957ae089 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -63,7 +63,7 @@ extern void __init files_maxfiles_init(void);
63 63
64extern struct files_stat_struct files_stat; 64extern struct files_stat_struct files_stat;
65extern unsigned long get_max_files(void); 65extern unsigned long get_max_files(void);
66extern int sysctl_nr_open; 66extern unsigned int sysctl_nr_open;
67extern struct inodes_stat_t inodes_stat; 67extern struct inodes_stat_t inodes_stat;
68extern int leases_enable, lease_break_time; 68extern int leases_enable, lease_break_time;
69extern int sysctl_protected_symlinks; 69extern int sysctl_protected_symlinks;
@@ -224,6 +224,7 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
224#define ATTR_KILL_PRIV (1 << 14) 224#define ATTR_KILL_PRIV (1 << 14)
225#define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */ 225#define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
226#define ATTR_TIMES_SET (1 << 16) 226#define ATTR_TIMES_SET (1 << 16)
227#define ATTR_TOUCH (1 << 17)
227 228
228/* 229/*
229 * Whiteout is represented by a char device. The following constants define the 230 * Whiteout is represented by a char device. The following constants define the
@@ -1064,6 +1065,18 @@ struct file_lock_context {
1064 1065
1065extern void send_sigio(struct fown_struct *fown, int fd, int band); 1066extern void send_sigio(struct fown_struct *fown, int fd, int band);
1066 1067
1068/*
1069 * Return the inode to use for locking
1070 *
1071 * For overlayfs this should be the overlay inode, not the real inode returned
1072 * by file_inode(). For any other fs file_inode(filp) and locks_inode(filp) are
1073 * equal.
1074 */
1075static inline struct inode *locks_inode(const struct file *f)
1076{
1077 return f->f_path.dentry->d_inode;
1078}
1079
1067#ifdef CONFIG_FILE_LOCKING 1080#ifdef CONFIG_FILE_LOCKING
1068extern int fcntl_getlk(struct file *, unsigned int, struct flock __user *); 1081extern int fcntl_getlk(struct file *, unsigned int, struct flock __user *);
1069extern int fcntl_setlk(unsigned int, struct file *, unsigned int, 1082extern int fcntl_setlk(unsigned int, struct file *, unsigned int,
@@ -1251,7 +1264,7 @@ static inline struct dentry *file_dentry(const struct file *file)
1251 1264
1252static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl) 1265static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl)
1253{ 1266{
1254 return locks_lock_inode_wait(file_inode(filp), fl); 1267 return locks_lock_inode_wait(locks_inode(filp), fl);
1255} 1268}
1256 1269
1257struct fasync_struct { 1270struct fasync_struct {
@@ -2006,7 +2019,6 @@ enum file_time_flags {
2006 S_VERSION = 8, 2019 S_VERSION = 8,
2007}; 2020};
2008 2021
2009extern bool atime_needs_update(const struct path *, struct inode *);
2010extern void touch_atime(const struct path *); 2022extern void touch_atime(const struct path *);
2011static inline void file_accessed(struct file *file) 2023static inline void file_accessed(struct file *file)
2012{ 2024{
@@ -2155,7 +2167,7 @@ static inline int mandatory_lock(struct inode *ino)
2155 2167
2156static inline int locks_verify_locked(struct file *file) 2168static inline int locks_verify_locked(struct file *file)
2157{ 2169{
2158 if (mandatory_lock(file_inode(file))) 2170 if (mandatory_lock(locks_inode(file)))
2159 return locks_mandatory_locked(file); 2171 return locks_mandatory_locked(file);
2160 return 0; 2172 return 0;
2161} 2173}
@@ -2993,7 +3005,7 @@ extern int buffer_migrate_page(struct address_space *,
2993#define buffer_migrate_page NULL 3005#define buffer_migrate_page NULL
2994#endif 3006#endif
2995 3007
2996extern int inode_change_ok(const struct inode *, struct iattr *); 3008extern int setattr_prepare(struct dentry *, struct iattr *);
2997extern int inode_newsize_ok(const struct inode *, loff_t offset); 3009extern int inode_newsize_ok(const struct inode *, loff_t offset);
2998extern void setattr_copy(struct inode *inode, const struct iattr *attr); 3010extern void setattr_copy(struct inode *inode, const struct iattr *attr);
2999 3011
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index eed9e853a06f..b8bcc058e031 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -29,7 +29,11 @@ static inline int fsnotify_parent(struct path *path, struct dentry *dentry, __u3
29static inline int fsnotify_perm(struct file *file, int mask) 29static inline int fsnotify_perm(struct file *file, int mask)
30{ 30{
31 struct path *path = &file->f_path; 31 struct path *path = &file->f_path;
32 struct inode *inode = file_inode(file); 32 /*
33 * Do not use file_inode() here or anywhere in this file to get the
34 * inode. That would break *notity on overlayfs.
35 */
36 struct inode *inode = path->dentry->d_inode;
33 __u32 fsnotify_mask = 0; 37 __u32 fsnotify_mask = 0;
34 int ret; 38 int ret;
35 39
@@ -173,7 +177,7 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry)
173static inline void fsnotify_access(struct file *file) 177static inline void fsnotify_access(struct file *file)
174{ 178{
175 struct path *path = &file->f_path; 179 struct path *path = &file->f_path;
176 struct inode *inode = file_inode(file); 180 struct inode *inode = path->dentry->d_inode;
177 __u32 mask = FS_ACCESS; 181 __u32 mask = FS_ACCESS;
178 182
179 if (S_ISDIR(inode->i_mode)) 183 if (S_ISDIR(inode->i_mode))
@@ -191,7 +195,7 @@ static inline void fsnotify_access(struct file *file)
191static inline void fsnotify_modify(struct file *file) 195static inline void fsnotify_modify(struct file *file)
192{ 196{
193 struct path *path = &file->f_path; 197 struct path *path = &file->f_path;
194 struct inode *inode = file_inode(file); 198 struct inode *inode = path->dentry->d_inode;
195 __u32 mask = FS_MODIFY; 199 __u32 mask = FS_MODIFY;
196 200
197 if (S_ISDIR(inode->i_mode)) 201 if (S_ISDIR(inode->i_mode))
@@ -209,7 +213,7 @@ static inline void fsnotify_modify(struct file *file)
209static inline void fsnotify_open(struct file *file) 213static inline void fsnotify_open(struct file *file)
210{ 214{
211 struct path *path = &file->f_path; 215 struct path *path = &file->f_path;
212 struct inode *inode = file_inode(file); 216 struct inode *inode = path->dentry->d_inode;
213 __u32 mask = FS_OPEN; 217 __u32 mask = FS_OPEN;
214 218
215 if (S_ISDIR(inode->i_mode)) 219 if (S_ISDIR(inode->i_mode))
@@ -225,7 +229,7 @@ static inline void fsnotify_open(struct file *file)
225static inline void fsnotify_close(struct file *file) 229static inline void fsnotify_close(struct file *file)
226{ 230{
227 struct path *path = &file->f_path; 231 struct path *path = &file->f_path;
228 struct inode *inode = file_inode(file); 232 struct inode *inode = path->dentry->d_inode;
229 fmode_t mode = file->f_mode; 233 fmode_t mode = file->f_mode;
230 __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE; 234 __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE;
231 235
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 794dbcb91084..747f401cc312 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -530,59 +530,10 @@ void page_endio(struct page *page, bool is_write, int err);
530extern void add_page_wait_queue(struct page *page, wait_queue_t *waiter); 530extern void add_page_wait_queue(struct page *page, wait_queue_t *waiter);
531 531
532/* 532/*
533 * Fault one or two userspace pages into pagetables. 533 * Fault everything in given userspace address range in.
534 * Return -EINVAL if more than two pages would be needed.
535 * Return non-zero on a fault.
536 */ 534 */
537static inline int fault_in_pages_writeable(char __user *uaddr, int size) 535static inline int fault_in_pages_writeable(char __user *uaddr, int size)
538{ 536{
539 int span, ret;
540
541 if (unlikely(size == 0))
542 return 0;
543
544 span = offset_in_page(uaddr) + size;
545 if (span > 2 * PAGE_SIZE)
546 return -EINVAL;
547 /*
548 * Writing zeroes into userspace here is OK, because we know that if
549 * the zero gets there, we'll be overwriting it.
550 */
551 ret = __put_user(0, uaddr);
552 if (ret == 0 && span > PAGE_SIZE)
553 ret = __put_user(0, uaddr + size - 1);
554 return ret;
555}
556
557static inline int fault_in_pages_readable(const char __user *uaddr, int size)
558{
559 volatile char c;
560 int ret;
561
562 if (unlikely(size == 0))
563 return 0;
564
565 ret = __get_user(c, uaddr);
566 if (ret == 0) {
567 const char __user *end = uaddr + size - 1;
568
569 if (((unsigned long)uaddr & PAGE_MASK) !=
570 ((unsigned long)end & PAGE_MASK)) {
571 ret = __get_user(c, end);
572 (void)c;
573 }
574 }
575 return ret;
576}
577
578/*
579 * Multipage variants of the above prefault helpers, useful if more than
580 * PAGE_SIZE of data needs to be prefaulted. These are separate from the above
581 * functions (which only handle up to PAGE_SIZE) to avoid clobbering the
582 * filemap.c hotpaths.
583 */
584static inline int fault_in_multipages_writeable(char __user *uaddr, int size)
585{
586 char __user *end = uaddr + size - 1; 537 char __user *end = uaddr + size - 1;
587 538
588 if (unlikely(size == 0)) 539 if (unlikely(size == 0))
@@ -608,8 +559,7 @@ static inline int fault_in_multipages_writeable(char __user *uaddr, int size)
608 return 0; 559 return 0;
609} 560}
610 561
611static inline int fault_in_multipages_readable(const char __user *uaddr, 562static inline int fault_in_pages_readable(const char __user *uaddr, int size)
612 int size)
613{ 563{
614 volatile char c; 564 volatile char c;
615 const char __user *end = uaddr + size - 1; 565 const char __user *end = uaddr + size - 1;
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
index d5d3d741f028..5a9a739acdd5 100644
--- a/include/linux/posix_acl.h
+++ b/include/linux/posix_acl.h
@@ -11,27 +11,7 @@
11#include <linux/bug.h> 11#include <linux/bug.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/rcupdate.h> 13#include <linux/rcupdate.h>
14 14#include <uapi/linux/posix_acl.h>
15#define ACL_UNDEFINED_ID (-1)
16
17/* a_type field in acl_user_posix_entry_t */
18#define ACL_TYPE_ACCESS (0x8000)
19#define ACL_TYPE_DEFAULT (0x4000)
20
21/* e_tag entry in struct posix_acl_entry */
22#define ACL_USER_OBJ (0x01)
23#define ACL_USER (0x02)
24#define ACL_GROUP_OBJ (0x04)
25#define ACL_GROUP (0x08)
26#define ACL_MASK (0x10)
27#define ACL_OTHER (0x20)
28
29/* permissions in the e_perm field */
30#define ACL_READ (0x04)
31#define ACL_WRITE (0x02)
32#define ACL_EXECUTE (0x01)
33//#define ACL_ADD (0x08)
34//#define ACL_DELETE (0x10)
35 15
36struct posix_acl_entry { 16struct posix_acl_entry {
37 short e_tag; 17 short e_tag;
@@ -93,6 +73,7 @@ extern int set_posix_acl(struct inode *, int, struct posix_acl *);
93extern int posix_acl_chmod(struct inode *, umode_t); 73extern int posix_acl_chmod(struct inode *, umode_t);
94extern int posix_acl_create(struct inode *, umode_t *, struct posix_acl **, 74extern int posix_acl_create(struct inode *, umode_t *, struct posix_acl **,
95 struct posix_acl **); 75 struct posix_acl **);
76extern int posix_acl_update_mode(struct inode *, umode_t *, struct posix_acl **);
96 77
97extern int simple_set_acl(struct inode *, struct posix_acl *, int); 78extern int simple_set_acl(struct inode *, struct posix_acl *, int);
98extern int simple_acl_create(struct inode *, struct inode *); 79extern int simple_acl_create(struct inode *, struct inode *);
diff --git a/include/linux/posix_acl_xattr.h b/include/linux/posix_acl_xattr.h
index e5e8ec40278d..8b867e3bf3aa 100644
--- a/include/linux/posix_acl_xattr.h
+++ b/include/linux/posix_acl_xattr.h
@@ -10,42 +10,25 @@
10#define _POSIX_ACL_XATTR_H 10#define _POSIX_ACL_XATTR_H
11 11
12#include <uapi/linux/xattr.h> 12#include <uapi/linux/xattr.h>
13#include <uapi/linux/posix_acl_xattr.h>
13#include <linux/posix_acl.h> 14#include <linux/posix_acl.h>
14 15
15/* Supported ACL a_version fields */
16#define POSIX_ACL_XATTR_VERSION 0x0002
17
18/* An undefined entry e_id value */
19#define ACL_UNDEFINED_ID (-1)
20
21typedef struct {
22 __le16 e_tag;
23 __le16 e_perm;
24 __le32 e_id;
25} posix_acl_xattr_entry;
26
27typedef struct {
28 __le32 a_version;
29 posix_acl_xattr_entry a_entries[0];
30} posix_acl_xattr_header;
31
32
33static inline size_t 16static inline size_t
34posix_acl_xattr_size(int count) 17posix_acl_xattr_size(int count)
35{ 18{
36 return (sizeof(posix_acl_xattr_header) + 19 return (sizeof(struct posix_acl_xattr_header) +
37 (count * sizeof(posix_acl_xattr_entry))); 20 (count * sizeof(struct posix_acl_xattr_entry)));
38} 21}
39 22
40static inline int 23static inline int
41posix_acl_xattr_count(size_t size) 24posix_acl_xattr_count(size_t size)
42{ 25{
43 if (size < sizeof(posix_acl_xattr_header)) 26 if (size < sizeof(struct posix_acl_xattr_header))
44 return -1; 27 return -1;
45 size -= sizeof(posix_acl_xattr_header); 28 size -= sizeof(struct posix_acl_xattr_header);
46 if (size % sizeof(posix_acl_xattr_entry)) 29 if (size % sizeof(struct posix_acl_xattr_entry))
47 return -1; 30 return -1;
48 return size / sizeof(posix_acl_xattr_entry); 31 return size / sizeof(struct posix_acl_xattr_entry);
49} 32}
50 33
51#ifdef CONFIG_FS_POSIX_ACL 34#ifdef CONFIG_FS_POSIX_ACL
diff --git a/include/linux/uio.h b/include/linux/uio.h
index b5ebe6dca404..a00d525bbffa 100644
--- a/include/linux/uio.h
+++ b/include/linux/uio.h
@@ -82,7 +82,6 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
82 struct iov_iter *i, unsigned long offset, size_t bytes); 82 struct iov_iter *i, unsigned long offset, size_t bytes);
83void iov_iter_advance(struct iov_iter *i, size_t bytes); 83void iov_iter_advance(struct iov_iter *i, size_t bytes);
84int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes); 84int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes);
85#define iov_iter_fault_in_multipages_readable iov_iter_fault_in_readable
86size_t iov_iter_single_seg_count(const struct iov_iter *i); 85size_t iov_iter_single_seg_count(const struct iov_iter *i);
87size_t copy_page_to_iter(struct page *page, size_t offset, size_t bytes, 86size_t copy_page_to_iter(struct page *page, size_t offset, size_t bytes,
88 struct iov_iter *i); 87 struct iov_iter *i);
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index d0352a971ebd..929aba253764 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -336,6 +336,8 @@ header-y += pkt_cls.h
336header-y += pkt_sched.h 336header-y += pkt_sched.h
337header-y += pmu.h 337header-y += pmu.h
338header-y += poll.h 338header-y += poll.h
339header-y += posix_acl.h
340header-y += posix_acl_xattr.h
339header-y += posix_types.h 341header-y += posix_types.h
340header-y += ppdev.h 342header-y += ppdev.h
341header-y += ppp-comp.h 343header-y += ppp-comp.h
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 3b00f7c8943f..2473272169f2 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -132,6 +132,7 @@ struct inodes_stat_t {
132#define MS_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */ 132#define MS_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */
133 133
134/* These sb flags are internal to the kernel */ 134/* These sb flags are internal to the kernel */
135#define MS_NOREMOTELOCK (1<<27)
135#define MS_NOSEC (1<<28) 136#define MS_NOSEC (1<<28)
136#define MS_BORN (1<<29) 137#define MS_BORN (1<<29)
137#define MS_ACTIVE (1<<30) 138#define MS_ACTIVE (1<<30)
diff --git a/include/uapi/linux/posix_acl.h b/include/uapi/linux/posix_acl.h
new file mode 100644
index 000000000000..1037cb19aa17
--- /dev/null
+++ b/include/uapi/linux/posix_acl.h
@@ -0,0 +1,39 @@
1/*
2 * Copyright (C) 2002 Andreas Gruenbacher <a.gruenbacher@computer.org>
3 * Copyright (C) 2016 Red Hat, Inc.
4 *
5 * This file is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This file is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 */
16
17#ifndef __UAPI_POSIX_ACL_H
18#define __UAPI_POSIX_ACL_H
19
20#define ACL_UNDEFINED_ID (-1)
21
22/* a_type field in acl_user_posix_entry_t */
23#define ACL_TYPE_ACCESS (0x8000)
24#define ACL_TYPE_DEFAULT (0x4000)
25
26/* e_tag entry in struct posix_acl_entry */
27#define ACL_USER_OBJ (0x01)
28#define ACL_USER (0x02)
29#define ACL_GROUP_OBJ (0x04)
30#define ACL_GROUP (0x08)
31#define ACL_MASK (0x10)
32#define ACL_OTHER (0x20)
33
34/* permissions in the e_perm field */
35#define ACL_READ (0x04)
36#define ACL_WRITE (0x02)
37#define ACL_EXECUTE (0x01)
38
39#endif /* __UAPI_POSIX_ACL_H */
diff --git a/include/uapi/linux/posix_acl_xattr.h b/include/uapi/linux/posix_acl_xattr.h
new file mode 100644
index 000000000000..8b579844109b
--- /dev/null
+++ b/include/uapi/linux/posix_acl_xattr.h
@@ -0,0 +1,38 @@
1/*
2 * Copyright (C) 2002 Andreas Gruenbacher <a.gruenbacher@computer.org>
3 * Copyright (C) 2016 Red Hat, Inc.
4 *
5 * This file is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This file is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 */
16
17#ifndef __UAPI_POSIX_ACL_XATTR_H
18#define __UAPI_POSIX_ACL_XATTR_H
19
20#include <linux/types.h>
21
22/* Supported ACL a_version fields */
23#define POSIX_ACL_XATTR_VERSION 0x0002
24
25/* An undefined entry e_id value */
26#define ACL_UNDEFINED_ID (-1)
27
28struct posix_acl_xattr_entry {
29 __le16 e_tag;
30 __le16 e_perm;
31 __le32 e_id;
32};
33
34struct posix_acl_xattr_header {
35 __le32 a_version;
36};
37
38#endif /* __UAPI_POSIX_ACL_XATTR_H */
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index a43775c6646c..706309f9ed84 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -107,9 +107,8 @@ extern unsigned int core_pipe_limit;
107extern int pid_max; 107extern int pid_max;
108extern int pid_max_min, pid_max_max; 108extern int pid_max_min, pid_max_max;
109extern int percpu_pagelist_fraction; 109extern int percpu_pagelist_fraction;
110extern int compat_log;
111extern int latencytop_enabled; 110extern int latencytop_enabled;
112extern int sysctl_nr_open_min, sysctl_nr_open_max; 111extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
113#ifndef CONFIG_MMU 112#ifndef CONFIG_MMU
114extern int sysctl_nr_trim_pages; 113extern int sysctl_nr_trim_pages;
115#endif 114#endif
@@ -1085,15 +1084,6 @@ static struct ctl_table kern_table[] = {
1085 .extra1 = &neg_one, 1084 .extra1 = &neg_one,
1086 }, 1085 },
1087#endif 1086#endif
1088#ifdef CONFIG_COMPAT
1089 {
1090 .procname = "compat-log",
1091 .data = &compat_log,
1092 .maxlen = sizeof (int),
1093 .mode = 0644,
1094 .proc_handler = proc_dointvec,
1095 },
1096#endif
1097#ifdef CONFIG_RT_MUTEXES 1087#ifdef CONFIG_RT_MUTEXES
1098 { 1088 {
1099 .procname = "max_lock_depth", 1089 .procname = "max_lock_depth",
@@ -1693,7 +1683,7 @@ static struct ctl_table fs_table[] = {
1693 { 1683 {
1694 .procname = "nr_open", 1684 .procname = "nr_open",
1695 .data = &sysctl_nr_open, 1685 .data = &sysctl_nr_open,
1696 .maxlen = sizeof(int), 1686 .maxlen = sizeof(unsigned int),
1697 .mode = 0644, 1687 .mode = 0644,
1698 .proc_handler = proc_dointvec_minmax, 1688 .proc_handler = proc_dointvec_minmax,
1699 .extra1 = &sysctl_nr_open_min, 1689 .extra1 = &sysctl_nr_open_min,
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 48b8c27acabb..0ce341125195 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -396,8 +396,7 @@ int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes)
396 396
397 if (!(i->type & (ITER_BVEC|ITER_KVEC))) { 397 if (!(i->type & (ITER_BVEC|ITER_KVEC))) {
398 iterate_iovec(i, bytes, v, iov, skip, ({ 398 iterate_iovec(i, bytes, v, iov, skip, ({
399 err = fault_in_multipages_readable(v.iov_base, 399 err = fault_in_pages_readable(v.iov_base, v.iov_len);
400 v.iov_len);
401 if (unlikely(err)) 400 if (unlikely(err))
402 return err; 401 return err;
403 0;})) 402 0;}))
diff --git a/mm/shmem.c b/mm/shmem.c
index 0e9901e69d24..828253ab772c 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -960,7 +960,7 @@ static int shmem_setattr(struct dentry *dentry, struct iattr *attr)
960 struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); 960 struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
961 int error; 961 int error;
962 962
963 error = inode_change_ok(inode, attr); 963 error = setattr_prepare(dentry, attr);
964 if (error) 964 if (error)
965 return error; 965 return error;
966 966
diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
index 4b9b4a4e1b89..ef1e4e701780 100644
--- a/security/integrity/ima/ima_appraise.c
+++ b/security/integrity/ima/ima_appraise.c
@@ -190,7 +190,7 @@ int ima_appraise_measurement(enum ima_hooks func,
190{ 190{
191 static const char op[] = "appraise_data"; 191 static const char op[] = "appraise_data";
192 char *cause = "unknown"; 192 char *cause = "unknown";
193 struct dentry *dentry = file->f_path.dentry; 193 struct dentry *dentry = file_dentry(file);
194 struct inode *inode = d_backing_inode(dentry); 194 struct inode *inode = d_backing_inode(dentry);
195 enum integrity_status status = INTEGRITY_UNKNOWN; 195 enum integrity_status status = INTEGRITY_UNKNOWN;
196 int rc = xattr_len, hash_start = 0; 196 int rc = xattr_len, hash_start = 0;
@@ -295,7 +295,7 @@ out:
295 */ 295 */
296void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file) 296void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file)
297{ 297{
298 struct dentry *dentry = file->f_path.dentry; 298 struct dentry *dentry = file_dentry(file);
299 int rc = 0; 299 int rc = 0;
300 300
301 /* do not collect and update hash for digital signatures */ 301 /* do not collect and update hash for digital signatures */
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 596ef616ac21..423d111b3b94 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -228,7 +228,7 @@ static int process_measurement(struct file *file, char *buf, loff_t size,
228 if ((action & IMA_APPRAISE_SUBMASK) || 228 if ((action & IMA_APPRAISE_SUBMASK) ||
229 strcmp(template_desc->name, IMA_TEMPLATE_IMA_NAME) != 0) 229 strcmp(template_desc->name, IMA_TEMPLATE_IMA_NAME) != 0)
230 /* read 'security.ima' */ 230 /* read 'security.ima' */
231 xattr_len = ima_read_xattr(file->f_path.dentry, &xattr_value); 231 xattr_len = ima_read_xattr(file_dentry(file), &xattr_value);
232 232
233 hash_algo = ima_get_hash_algo(xattr_value, xattr_len); 233 hash_algo = ima_get_hash_algo(xattr_value, xattr_len);
234 234