From patchwork Tue Feb 14 13:03:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Foster X-Patchwork-Id: 9571899 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 292F46045F for ; Tue, 14 Feb 2017 13:04:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17DEE28305 for ; Tue, 14 Feb 2017 13:04:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CC0228404; Tue, 14 Feb 2017 13:04:42 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 9D63727CF3 for ; Tue, 14 Feb 2017 13:04:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752746AbdBNNEi (ORCPT ); Tue, 14 Feb 2017 08:04:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35766 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752611AbdBNNDP (ORCPT ); Tue, 14 Feb 2017 08:03:15 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C437C7E9DF for ; Tue, 14 Feb 2017 13:03:10 +0000 (UTC) Received: from bfoster.bfoster (dhcp-41-20.bos.redhat.com [10.18.41.20]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1ED3Ag6020230 for ; Tue, 14 Feb 2017 08:03:10 -0500 Received: by bfoster.bfoster (Postfix, from userid 1000) id 105641249D4; Tue, 14 Feb 2017 08:03:10 -0500 (EST) From: Brian Foster To: linux-xfs@vger.kernel.org Subject: [PATCH 2/4] xfs: resurrect debug mode drop buffered writes mechanism Date: Tue, 14 Feb 2017 08:03:07 -0500 Message-Id: <1487077389-5626-3-git-send-email-bfoster@redhat.com> In-Reply-To: <1487077389-5626-1-git-send-email-bfoster@redhat.com> References: <1487077389-5626-1-git-send-email-bfoster@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 14 Feb 2017 13:03:10 +0000 (UTC) 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 A debug mode write failure mechanism was introduced to XFS in commit 801cc4e17a ("xfs: debug mode forced buffered write failure") to facilitate targeted testing of delalloc indirect reservation management from userspace. This code was subsequently rendered ineffective by the move to iomap based buffered writes in commit 68a9f5e700 ("xfs: implement iomap based buffered write path"). This likely went unnoticed because the associated userspace code had not made it into xfstests. Resurrect this mechanism to facilitate effective indlen reservation testing from xfstests. The move to iomap based buffered writes relocated the hook this mechanism needs to return write failure from XFS to generic code. The failure trigger must remain in XFS. Given that limitation, convert this from a write failure mechanism to one that simply drops writes without returning failure to userspace. Rename all "fail_writes" references to "drop_writes" to illustrate the point. This is more hacky than preferred, but still triggers the XFS error handling behavior required to drive the indlen tests. This is only available in DEBUG mode and for testing purposes only. Signed-off-by: Brian Foster Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_iomap.c | 4 ++++ fs/xfs/xfs_mount.h | 15 ++++++++------- fs/xfs/xfs_sysfs.c | 14 +++++++------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index e2fbed4..01e8780 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1078,6 +1078,10 @@ xfs_file_iomap_end_delalloc( xfs_fileoff_t end_fsb; int error = 0; + /* behave as if the write failed if drop writes is enabled */ + if (xfs_mp_drop_writes(mp)) + written = 0; + start_fsb = XFS_B_TO_FSB(mp, offset + written); if (unlikely(!written)) start_fsb = XFS_B_TO_FSBT(mp, offset); diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 20e2981..6db6fd6 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -200,11 +200,12 @@ typedef struct xfs_mount { /* * DEBUG mode instrumentation to test and/or trigger delayed allocation * block killing in the event of failed writes. When enabled, all - * buffered writes are forced to fail. All delalloc blocks in the range - * of the write (including pre-existing delalloc blocks!) are tossed as - * part of the write failure error handling sequence. + * buffered writes are silenty dropped and handled as if they failed. + * All delalloc blocks in the range of the write (including pre-existing + * delalloc blocks!) are tossed as part of the write failure error + * handling sequence. */ - bool m_fail_writes; + bool m_drop_writes; #endif } xfs_mount_t; @@ -325,13 +326,13 @@ xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d) #ifdef DEBUG static inline bool -xfs_mp_fail_writes(struct xfs_mount *mp) +xfs_mp_drop_writes(struct xfs_mount *mp) { - return mp->m_fail_writes; + return mp->m_drop_writes; } #else static inline bool -xfs_mp_fail_writes(struct xfs_mount *mp) +xfs_mp_drop_writes(struct xfs_mount *mp) { return 0; } diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c index de6195e..80ac15f 100644 --- a/fs/xfs/xfs_sysfs.c +++ b/fs/xfs/xfs_sysfs.c @@ -93,7 +93,7 @@ to_mp(struct kobject *kobject) #ifdef DEBUG STATIC ssize_t -fail_writes_store( +drop_writes_store( struct kobject *kobject, const char *buf, size_t count) @@ -107,9 +107,9 @@ fail_writes_store( return ret; if (val == 1) - mp->m_fail_writes = true; + mp->m_drop_writes = true; else if (val == 0) - mp->m_fail_writes = false; + mp->m_drop_writes = false; else return -EINVAL; @@ -117,21 +117,21 @@ fail_writes_store( } STATIC ssize_t -fail_writes_show( +drop_writes_show( struct kobject *kobject, char *buf) { struct xfs_mount *mp = to_mp(kobject); - return snprintf(buf, PAGE_SIZE, "%d\n", mp->m_fail_writes ? 1 : 0); + return snprintf(buf, PAGE_SIZE, "%d\n", mp->m_drop_writes ? 1 : 0); } -XFS_SYSFS_ATTR_RW(fail_writes); +XFS_SYSFS_ATTR_RW(drop_writes); #endif /* DEBUG */ static struct attribute *xfs_mp_attrs[] = { #ifdef DEBUG - ATTR_LIST(fail_writes), + ATTR_LIST(drop_writes), #endif NULL, };