]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
xfs: cancel pending CoW reservations when destroying inodes
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 3 Oct 2016 16:11:38 +0000 (09:11 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Wed, 5 Oct 2016 23:26:05 +0000 (16:26 -0700)
When destroying the inode, cancel all pending reservations in the CoW
fork so that all the reserved blocks go back to the free pile.  In
theory this sort of cleanup is only needed to clean up after write
errors.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_super.c

index 35c04a7907546088a4bf980b3ac97e51c3e1dafe..b65b97997f99e20311002b7509ffa7cf5ff0ed76 100644 (file)
@@ -49,6 +49,7 @@
 #include "xfs_rmap_item.h"
 #include "xfs_refcount_item.h"
 #include "xfs_bmap_item.h"
+#include "xfs_reflink.h"
 
 #include <linux/namei.h>
 #include <linux/init.h>
@@ -938,6 +939,7 @@ xfs_fs_destroy_inode(
        struct inode            *inode)
 {
        struct xfs_inode        *ip = XFS_I(inode);
+       int                     error;
 
        trace_xfs_destroy_inode(ip);
 
@@ -945,6 +947,12 @@ xfs_fs_destroy_inode(
        XFS_STATS_INC(ip->i_mount, vn_rele);
        XFS_STATS_INC(ip->i_mount, vn_remove);
 
+       error = xfs_reflink_cancel_cow_range(ip, 0, NULLFILEOFF);
+       if (error && !XFS_FORCED_SHUTDOWN(ip->i_mount))
+               xfs_warn(ip->i_mount, "Error %d while evicting CoW blocks "
+                               "for inode %llu.",
+                               error, ip->i_ino);
+
        xfs_inactive(ip);
 
        ASSERT(XFS_FORCED_SHUTDOWN(ip->i_mount) || ip->i_delayed_blks == 0);