From patchwork Tue Jul 25 14:50:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 9862171 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 503F4600F5 for ; Tue, 25 Jul 2017 14:51:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C3D3286BB for ; Tue, 25 Jul 2017 14:51:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30BCE286CC; Tue, 25 Jul 2017 14:51:04 +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=unavailable 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 D0483286CA for ; Tue, 25 Jul 2017 14:51:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752455AbdGYOut (ORCPT ); Tue, 25 Jul 2017 10:50:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:54218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752068AbdGYOuq (ORCPT ); Tue, 25 Jul 2017 10:50:46 -0400 Received: from tleilax.poochiereds.net (cpe-45-37-196-243.nc.res.rr.com [45.37.196.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6B42422C8F; Tue, 25 Jul 2017 14:50:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B42422C8F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=jlayton@kernel.org From: Jeff Layton To: "Yan, Zheng" , Sage Weil , Ilya Dryomov Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] ceph: pagecache writeback fault injection switch Date: Tue, 25 Jul 2017 10:50:42 -0400 Message-Id: <20170725145042.26219-3-jlayton@kernel.org> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170725145042.26219-1-jlayton@kernel.org> References: <20170725145042.26219-1-jlayton@kernel.org> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jeff Layton Testing ceph for proper writeback error handling turns out to be quite difficult. I tried using iptables to block traffic but that didn't give reliable results. I hacked in this wb_fault switch that makes the filesystem pretend that writeback failed, even when it succeeds. With this, I could verify that cephfs fsync error reporting does work properly. Signed-off-by: Jeff Layton --- fs/ceph/addr.c | 7 +++++++ fs/ceph/debugfs.c | 8 +++++++- fs/ceph/super.h | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 50836280a6f8..a3831d100e16 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -584,6 +584,10 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc) page_off, len, truncate_seq, truncate_size, &inode->i_mtime, &page, 1); + + if (fsc->wb_fault && err >= 0) + err = -EIO; + if (err < 0) { struct writeback_control tmp_wbc; if (!wbc) @@ -666,6 +670,9 @@ static void writepages_finish(struct ceph_osd_request *req) struct ceph_fs_client *fsc = ceph_inode_to_client(inode); bool remove_page; + if (fsc->wb_fault && rc >= 0) + rc = -EIO; + dout("writepages_finish %p rc %d\n", inode, rc); if (rc < 0) { mapping_set_error(mapping, rc); diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c index 4e2d112c982f..e1e6eaa12031 100644 --- a/fs/ceph/debugfs.c +++ b/fs/ceph/debugfs.c @@ -197,7 +197,6 @@ CEPH_DEFINE_SHOW_FUNC(caps_show) CEPH_DEFINE_SHOW_FUNC(dentry_lru_show) CEPH_DEFINE_SHOW_FUNC(mds_sessions_show) - /* * debugfs */ @@ -231,6 +230,7 @@ void ceph_fs_debugfs_cleanup(struct ceph_fs_client *fsc) debugfs_remove(fsc->debugfs_caps); debugfs_remove(fsc->debugfs_mdsc); debugfs_remove(fsc->debugfs_dentry_lru); + debugfs_remove(fsc->debugfs_wb_fault); } int ceph_fs_debugfs_init(struct ceph_fs_client *fsc) @@ -298,6 +298,12 @@ int ceph_fs_debugfs_init(struct ceph_fs_client *fsc) if (!fsc->debugfs_dentry_lru) goto out; + fsc->debugfs_wb_fault = debugfs_create_bool("wb_fault", + 0600, fsc->client->debugfs_dir, + &fsc->wb_fault); + if (!fsc->debugfs_wb_fault) + goto out; + return 0; out: diff --git a/fs/ceph/super.h b/fs/ceph/super.h index f02a2225fe42..a38fd6203b77 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -84,6 +84,7 @@ struct ceph_fs_client { unsigned long mount_state; int min_caps; /* min caps i added */ + bool wb_fault; struct ceph_mds_client *mdsc; @@ -100,6 +101,7 @@ struct ceph_fs_client { struct dentry *debugfs_bdi; struct dentry *debugfs_mdsc, *debugfs_mdsmap; struct dentry *debugfs_mds_sessions; + struct dentry *debugfs_wb_fault; #endif #ifdef CONFIG_CEPH_FSCACHE