Merge branch 'x86-apic-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[cascardo/linux.git] / fs / xfs / xfs_ioctl.c
index 3799695..a183198 100644 (file)
@@ -21,8 +21,6 @@
 #include "xfs_format.h"
 #include "xfs_log_format.h"
 #include "xfs_trans_resv.h"
-#include "xfs_sb.h"
-#include "xfs_ag.h"
 #include "xfs_mount.h"
 #include "xfs_inode.h"
 #include "xfs_ioctl.h"
@@ -40,7 +38,6 @@
 #include "xfs_trace.h"
 #include "xfs_icache.h"
 #include "xfs_symlink.h"
-#include "xfs_dinode.h"
 #include "xfs_trans.h"
 
 #include <linux/capability.h>
@@ -968,8 +965,6 @@ xfs_set_diflags(
                di_flags |= XFS_DIFLAG_NOATIME;
        if (xflags & XFS_XFLAG_NODUMP)
                di_flags |= XFS_DIFLAG_NODUMP;
-       if (xflags & XFS_XFLAG_PROJINHERIT)
-               di_flags |= XFS_DIFLAG_PROJINHERIT;
        if (xflags & XFS_XFLAG_NODEFRAG)
                di_flags |= XFS_DIFLAG_NODEFRAG;
        if (xflags & XFS_XFLAG_FILESTREAM)
@@ -981,6 +976,8 @@ xfs_set_diflags(
                        di_flags |= XFS_DIFLAG_NOSYMLINKS;
                if (xflags & XFS_XFLAG_EXTSZINHERIT)
                        di_flags |= XFS_DIFLAG_EXTSZINHERIT;
+               if (xflags & XFS_XFLAG_PROJINHERIT)
+                       di_flags |= XFS_DIFLAG_PROJINHERIT;
        } else if (S_ISREG(ip->i_d.di_mode)) {
                if (xflags & XFS_XFLAG_REALTIME)
                        di_flags |= XFS_DIFLAG_REALTIME;
@@ -1231,13 +1228,25 @@ xfs_ioctl_setattr(
 
        }
 
-       if (mask & FSX_EXTSIZE)
-               ip->i_d.di_extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog;
        if (mask & FSX_XFLAGS) {
                xfs_set_diflags(ip, fa->fsx_xflags);
                xfs_diflags_to_linux(ip);
        }
 
+       /*
+        * Only set the extent size hint if we've already determined that the
+        * extent size hint should be set on the inode. If no extent size flags
+        * are set on the inode then unconditionally clear the extent size hint.
+        */
+       if (mask & FSX_EXTSIZE) {
+               int     extsize = 0;
+
+               if (ip->i_d.di_flags &
+                               (XFS_DIFLAG_EXTSIZE | XFS_DIFLAG_EXTSZINHERIT))
+                       extsize = fa->fsx_extsize >> mp->m_sb.sb_blocklog;
+               ip->i_d.di_extsize = extsize;
+       }
+
        xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
        xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 
@@ -1349,7 +1358,7 @@ xfs_ioc_setxflags(
 STATIC int
 xfs_getbmap_format(void **ap, struct getbmapx *bmv, int *full)
 {
-       struct getbmap __user   *base = *ap;
+       struct getbmap __user   *base = (struct getbmap __user *)*ap;
 
        /* copy only getbmap portion (not getbmapx) */
        if (copy_to_user(base, bmv, sizeof(struct getbmap)))
@@ -1380,7 +1389,7 @@ xfs_ioc_getbmap(
                bmx.bmv_iflags |= BMV_IF_NO_DMAPI_READ;
 
        error = xfs_getbmap(ip, &bmx, xfs_getbmap_format,
-                           (struct getbmap *)arg+1);
+                           (__force struct getbmap *)arg+1);
        if (error)
                return error;
 
@@ -1393,7 +1402,7 @@ xfs_ioc_getbmap(
 STATIC int
 xfs_getbmapx_format(void **ap, struct getbmapx *bmv, int *full)
 {
-       struct getbmapx __user  *base = *ap;
+       struct getbmapx __user  *base = (struct getbmapx __user *)*ap;
 
        if (copy_to_user(base, bmv, sizeof(struct getbmapx)))
                return -EFAULT;
@@ -1420,7 +1429,7 @@ xfs_ioc_getbmapx(
                return -EINVAL;
 
        error = xfs_getbmap(ip, &bmx, xfs_getbmapx_format,
-                           (struct getbmapx *)arg+1);
+                           (__force struct getbmapx *)arg+1);
        if (error)
                return error;