From patchwork Tue Jan 1 02:17:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10745651 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C952746 for ; Tue, 1 Jan 2019 02:17:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4098828C99 for ; Tue, 1 Jan 2019 02:17:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 341AA28C9F; Tue, 1 Jan 2019 02:17:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C366428C99 for ; Tue, 1 Jan 2019 02:17:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728211AbfAACRz (ORCPT ); Mon, 31 Dec 2018 21:17:55 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:53534 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728133AbfAACRy (ORCPT ); Mon, 31 Dec 2018 21:17:54 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x012E4Lj168473 for ; Tue, 1 Jan 2019 02:17:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=4Tn78OuwijNqymXkgKjpl1DyQxU34H/umHzXZD8RCYE=; b=EiNtdNVhSJYuint/B6awQfYI8TzPv6P6psl3fyiHVqUKq+W+abVFp+m6yKL3Sd6Y435+ McwJZuQtDxYIrA8TRNvWkb02JQI4FCCLIwsYd230YDLSnLlaqIqF6r8Jbq1Wxn5cj3G3 h30mtYhMOcEVzCg/ZM7SrJ+XJuikelXlG1gxvVL+UMCvTcWxLErBCcw9bAl7TKBTF5GQ W84fCgRiw/Ku0j4CwAvuKr8cXHu2kBemZc/y11aQpWn1iO5THEboHtzRVoQ9Aipo9ppc 8u3fqgTT5otyNGmgg8M6Oz3Ep8L2n3dPJ1THBD+SRgFM09cbpNiPXIuTthb3Sixqf3Rf BQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2pnxedxar0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 01 Jan 2019 02:17:53 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x012Hlui002741 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 1 Jan 2019 02:17:48 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x012HlnU006359 for ; Tue, 1 Jan 2019 02:17:47 GMT Received: from localhost (/10.159.150.85) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 31 Dec 2018 18:17:47 -0800 Subject: [PATCH 09/12] xfs: retry fs writes when there isn't space From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 31 Dec 2018 18:17:46 -0800 Message-ID: <154630906634.16693.14439684008416608580.stgit@magnolia> In-Reply-To: <154630901076.16693.13111277988041606505.stgit@magnolia> References: <154630901076.16693.13111277988041606505.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9123 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901010019 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Any time we try a file write that fails due to ENOSPC or EDQUOT, force inactivation work to free up some resources and try one more time. Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_file.c | 11 +++++++++++ fs/xfs/xfs_inode.c | 1 + fs/xfs/xfs_iomap.c | 10 +++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index e47425071e65..7ba3b799702d 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -652,6 +652,9 @@ xfs_file_buffered_aio_write( if (enospc) goto write_retry; enospc = xfs_inode_free_quota_cowblocks(ip); + if (enospc) + goto write_retry; + enospc = xfs_inactive_free_quota(ip); if (enospc) goto write_retry; iolock = 0; @@ -665,6 +668,7 @@ xfs_file_buffered_aio_write( eofb.eof_flags = XFS_EOF_FLAGS_SYNC; xfs_icache_free_eofblocks(ip->i_mount, &eofb); xfs_icache_free_cowblocks(ip->i_mount, &eofb); + xfs_inactive_force(ip->i_mount); goto write_retry; } @@ -936,6 +940,7 @@ xfs_file_remap_range( struct xfs_mount *mp = src->i_mount; loff_t remapped = 0; xfs_extlen_t cowextsize; + bool can_retry = true; int ret; if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY)) @@ -955,8 +960,14 @@ xfs_file_remap_range( trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out); +retry: ret = xfs_reflink_remap_blocks(src, pos_in, dest, pos_out, len, &remapped); + if ((ret == -EDQUOT || ret == -ENOSPC) && can_retry) { + can_retry = false; + xfs_inactive_force(mp); + goto retry; + } if (ret) goto out_unlock; diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 26c8181f5760..2c7f8aeffa92 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1181,6 +1181,7 @@ xfs_create( if (error == -ENOSPC) { /* flush outstanding delalloc blocks and retry */ xfs_flush_inodes(mp); + xfs_inactive_force(mp); error = xfs_trans_alloc(mp, tres, resblks, 0, 0, &tp); } if (error) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 59772a7c7586..302ba859dd32 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -532,12 +532,13 @@ xfs_file_iomap_begin_delay( struct xfs_bmbt_irec got; struct xfs_iext_cursor icur; xfs_fsblock_t prealloc_blocks = 0; + bool flush_inactive = true; ASSERT(!XFS_IS_REALTIME_INODE(ip)); ASSERT(!xfs_get_extsz_hint(ip)); xfs_ilock(ip, XFS_ILOCK_EXCL); - +start_over: if (unlikely(XFS_TEST_ERROR( (XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) != XFS_DINODE_FMT_EXTENTS && XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) != XFS_DINODE_FMT_BTREE), @@ -632,6 +633,13 @@ xfs_file_iomap_begin_delay( break; case -ENOSPC: case -EDQUOT: + if (flush_inactive) { + flush_inactive = false; + xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_inactive_force(mp); + xfs_ilock(ip, XFS_ILOCK_EXCL); + goto start_over; + } /* retry without any preallocation */ trace_xfs_delalloc_enospc(ip, offset, count); if (prealloc_blocks) {