Merge tag 'nfs-for-5.9-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
[linux-2.6-microblaze.git] / include / linux / fs.h
index 488c3ef..7c69dd7 100644 (file)
@@ -518,6 +518,16 @@ static inline void i_mmap_unlock_read(struct address_space *mapping)
        up_read(&mapping->i_mmap_rwsem);
 }
 
+static inline void i_mmap_assert_locked(struct address_space *mapping)
+{
+       lockdep_assert_held(&mapping->i_mmap_rwsem);
+}
+
+static inline void i_mmap_assert_write_locked(struct address_space *mapping)
+{
+       lockdep_assert_held_write(&mapping->i_mmap_rwsem);
+}
+
 /*
  * Might pages of this file be mapped into userspace?
  */
@@ -528,7 +538,7 @@ static inline int mapping_mapped(struct address_space *mapping)
 
 /*
  * Might pages of this file have been modified in userspace?
- * Note that i_mmap_writable counts all VM_SHARED vmas: do_mmap_pgoff
+ * Note that i_mmap_writable counts all VM_SHARED vmas: do_mmap
  * marks vma as VM_SHARED if it is shared, and the file was opened for
  * writing i.e. vma may be mprotected writable even if now readonly.
  *
@@ -1712,6 +1722,10 @@ int vfs_mkobj(struct dentry *, umode_t,
                int (*f)(struct dentry *, umode_t, void *),
                void *);
 
+int vfs_fchown(struct file *file, uid_t user, gid_t group);
+int vfs_fchmod(struct file *file, umode_t mode);
+int vfs_utimes(const struct path *path, struct timespec64 *times);
+
 extern long vfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
 
 #ifdef CONFIG_COMPAT
@@ -1942,27 +1956,27 @@ struct super_operations {
 /*
  * Inode flags - they have no relation to superblock flags now
  */
-#define S_SYNC         1       /* Writes are synced at once */
-#define S_NOATIME      2       /* Do not update access times */
-#define S_APPEND       4       /* Append-only file */
-#define S_IMMUTABLE    8       /* Immutable file */
-#define S_DEAD         16      /* removed, but still open directory */
-#define S_NOQUOTA      32      /* Inode is not counted to quota */
-#define S_DIRSYNC      64      /* Directory modifications are synchronous */
-#define S_NOCMTIME     128     /* Do not update file c/mtime */
-#define S_SWAPFILE     256     /* Do not truncate: swapon got its bmaps */
-#define S_PRIVATE      512     /* Inode is fs-internal */
-#define S_IMA          1024    /* Inode has an associated IMA struct */
-#define S_AUTOMOUNT    2048    /* Automount/referral quasi-directory */
-#define S_NOSEC                4096    /* no suid or xattr security attributes */
+#define S_SYNC         (1 << 0)  /* Writes are synced at once */
+#define S_NOATIME      (1 << 1)  /* Do not update access times */
+#define S_APPEND       (1 << 2)  /* Append-only file */
+#define S_IMMUTABLE    (1 << 3)  /* Immutable file */
+#define S_DEAD         (1 << 4)  /* removed, but still open directory */
+#define S_NOQUOTA      (1 << 5)  /* Inode is not counted to quota */
+#define S_DIRSYNC      (1 << 6)  /* Directory modifications are synchronous */
+#define S_NOCMTIME     (1 << 7)  /* Do not update file c/mtime */
+#define S_SWAPFILE     (1 << 8)  /* Do not truncate: swapon got its bmaps */
+#define S_PRIVATE      (1 << 9)  /* Inode is fs-internal */
+#define S_IMA          (1 << 10) /* Inode has an associated IMA struct */
+#define S_AUTOMOUNT    (1 << 11) /* Automount/referral quasi-directory */
+#define S_NOSEC                (1 << 12) /* no suid or xattr security attributes */
 #ifdef CONFIG_FS_DAX
-#define S_DAX          8192    /* Direct Access, avoiding the page cache */
+#define S_DAX          (1 << 13) /* Direct Access, avoiding the page cache */
 #else
-#define S_DAX          0       /* Make all the DAX code disappear */
+#define S_DAX          0         /* Make all the DAX code disappear */
 #endif
-#define S_ENCRYPTED    16384   /* Encrypted file (using fs/crypto/) */
-#define S_CASEFOLD     32768   /* Casefolded file */
-#define S_VERITY       65536   /* Verity file (using fs/verity/) */
+#define S_ENCRYPTED    (1 << 14) /* Encrypted file (using fs/crypto/) */
+#define S_CASEFOLD     (1 << 15) /* Casefolded file */
+#define S_VERITY       (1 << 16) /* Verity file (using fs/verity/) */
 
 /*
  * Note that nosuid etc flags are inode-specific: setting some file-system
@@ -2646,7 +2660,7 @@ static inline void filemap_set_wb_err(struct address_space *mapping, int err)
 }
 
 /**
- * filemap_check_wb_error - has an error occurred since the mark was sampled?
+ * filemap_check_wb_err - has an error occurred since the mark was sampled?
  * @mapping: mapping to check for writeback errors
  * @since: previously-sampled errseq_t
  *
@@ -2946,6 +2960,21 @@ extern void discard_new_inode(struct inode *);
 extern unsigned int get_next_ino(void);
 extern void evict_inodes(struct super_block *sb);
 
+/*
+ * Userspace may rely on the the inode number being non-zero. For example, glibc
+ * simply ignores files with zero i_ino in unlink() and other places.
+ *
+ * As an additional complication, if userspace was compiled with
+ * _FILE_OFFSET_BITS=32 on a 64-bit kernel we'll only end up reading out the
+ * lower 32 bits, so we need to check that those aren't zero explicitly. With
+ * _FILE_OFFSET_BITS=64, this may cause some harmless false-negatives, but
+ * better safe than sorry.
+ */
+static inline bool is_zero_ino(ino_t ino)
+{
+       return (u32)ino == 0;
+}
+
 extern void __iget(struct inode * inode);
 extern void iget_failed(struct inode *);
 extern void clear_inode(struct inode *);