xfs: fix reporting supported extra file attributes for statx()
[sfrench/cifs-2.6.git] / fs / xfs / xfs_iops.c
index f48ffd7a8d3e491d76defe66961194a635276115..74047bd0c1aeb44709ceae3ef779921778c4be0e 100644 (file)
@@ -191,9 +191,18 @@ xfs_generic_create(
 
        xfs_setup_iops(ip);
 
-       if (tmpfile)
+       if (tmpfile) {
+               /*
+                * The VFS requires that any inode fed to d_tmpfile must have
+                * nlink == 1 so that it can decrement the nlink in d_tmpfile.
+                * However, we created the temp file with nlink == 0 because
+                * we're not allowed to put an inode with nlink > 0 on the
+                * unlinked list.  Therefore we have to set nlink to 1 so that
+                * d_tmpfile can immediately set it back to zero.
+                */
+               set_nlink(inode, 1);
                d_tmpfile(dentry, inode);
-       else
+       else
                d_instantiate(dentry, inode);
 
        xfs_finish_inode_setup(ip);
@@ -522,6 +531,10 @@ xfs_vn_getattr(
                }
        }
 
+       /*
+        * Note: If you add another clause to set an attribute flag, please
+        * update attributes_mask below.
+        */
        if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
                stat->attributes |= STATX_ATTR_IMMUTABLE;
        if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
@@ -529,6 +542,10 @@ xfs_vn_getattr(
        if (ip->i_d.di_flags & XFS_DIFLAG_NODUMP)
                stat->attributes |= STATX_ATTR_NODUMP;
 
+       stat->attributes_mask |= (STATX_ATTR_IMMUTABLE |
+                                 STATX_ATTR_APPEND |
+                                 STATX_ATTR_NODUMP);
+
        switch (inode->i_mode & S_IFMT) {
        case S_IFBLK:
        case S_IFCHR: