KVM: arm64: add workaround for Cortex-A57 erratum #852523
[cascardo/linux.git] / fs / xfs / xfs_attr_inactive.c
index 3fbf167..2bb959a 100644 (file)
@@ -394,7 +394,6 @@ xfs_attr_inactive(
 {
        struct xfs_trans        *trans;
        struct xfs_mount        *mp;
-       int                     cancel_flags = 0;
        int                     lock_mode = XFS_ILOCK_SHARED;
        int                     error = 0;
 
@@ -423,7 +422,6 @@ xfs_attr_inactive(
                goto out_cancel;
 
        lock_mode = XFS_ILOCK_EXCL;
-       cancel_flags = XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT;
        xfs_ilock(dp, lock_mode);
 
        if (!XFS_IFORK_Q(dp))
@@ -435,8 +433,14 @@ xfs_attr_inactive(
         */
        xfs_trans_ijoin(trans, dp, 0);
 
-       /* invalidate and truncate the attribute fork extents */
-       if (dp->i_d.di_aformat != XFS_DINODE_FMT_LOCAL) {
+       /*
+        * Invalidate and truncate the attribute fork extents. Make sure the
+        * fork actually has attributes as otherwise the invalidation has no
+        * blocks to read and returns an error. In this case, just do the fork
+        * removal below.
+        */
+       if (xfs_inode_hasattr(dp) &&
+           dp->i_d.di_aformat != XFS_DINODE_FMT_LOCAL) {
                error = xfs_attr3_root_inactive(&trans, dp);
                if (error)
                        goto out_cancel;
@@ -449,12 +453,12 @@ xfs_attr_inactive(
        /* Reset the attribute fork - this also destroys the in-core fork */
        xfs_attr_fork_remove(dp, trans);
 
-       error = xfs_trans_commit(trans, XFS_TRANS_RELEASE_LOG_RES);
+       error = xfs_trans_commit(trans);
        xfs_iunlock(dp, lock_mode);
        return error;
 
 out_cancel:
-       xfs_trans_cancel(trans, cancel_flags);
+       xfs_trans_cancel(trans);
 out_destroy_fork:
        /* kill the in-core attr fork before we drop the inode lock */
        if (dp->i_afp)