From patchwork Fri Mar 6 14:31:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11424135 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BABE914E3 for ; Fri, 6 Mar 2020 14:31:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9C7532072D for ; Fri, 6 Mar 2020 14:31:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="KonF0eVH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726733AbgCFObh (ORCPT ); Fri, 6 Mar 2020 09:31:37 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:39406 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726650AbgCFObh (ORCPT ); Fri, 6 Mar 2020 09:31:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=quvN83Iv0Rmc1Md4XSQ1Swg3IIsZIWdf7YeLJPuG3XU=; b=KonF0eVHg5SRdeigWZBB+nyg3M WnB6ZIwULajAj1LB72HgZymMafdJ9ktpX5vXfs0+CqObb0JHA0IEzQRnNpnW46AWCKAjK1JABEAtU hB1HxYYu7PunkcGXWKeXjEXPQiQUdL23EKalCvDlSvABl+3QbckxiNAOFI9kiLtoW9WxRQbmUHpkV O8c+VRuDi3dpsRJhEoU3y6jPF02g+6RMSdb4ThBLuu+uoLQBMwP6vR6P53GRjDKObOkjjepWA0oaZ mzxadB3tsA/nD9CRN8YN9iCTU3ERhGE0oNFwDPonBaEr9At1okiMyXd1FnmSjJ6RPxxsn9pwl0Z9o jdFfcTrA==; Received: from [162.248.129.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jAE0m-0008H2-Nk; Fri, 06 Mar 2020 14:31:36 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 1/7] xfs: remove the unused return value from xfs_log_unmount_write Date: Fri, 6 Mar 2020 07:31:31 -0700 Message-Id: <20200306143137.236478-2-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200306143137.236478-1-hch@lst.de> References: <20200306143137.236478-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Remove the ignored return value from xfs_log_unmount_write, and also remove a rather pointless assert on the return value from xfs_log_force. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 796ff37d5bb5..fa499ddedb94 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -953,8 +953,7 @@ xfs_log_write_unmount_record( * currently architecture converted and "Unmount" is a bit foo. * As far as I know, there weren't any dependencies on the old behaviour. */ - -static int +static void xfs_log_unmount_write(xfs_mount_t *mp) { struct xlog *log = mp->m_log; @@ -962,7 +961,6 @@ xfs_log_unmount_write(xfs_mount_t *mp) #ifdef DEBUG xlog_in_core_t *first_iclog; #endif - int error; /* * Don't write out unmount record on norecovery mounts or ro devices. @@ -971,11 +969,10 @@ xfs_log_unmount_write(xfs_mount_t *mp) if (mp->m_flags & XFS_MOUNT_NORECOVERY || xfs_readonly_buftarg(log->l_targ)) { ASSERT(mp->m_flags & XFS_MOUNT_RDONLY); - return 0; + return; } - error = xfs_log_force(mp, XFS_LOG_SYNC); - ASSERT(error || !(XLOG_FORCED_SHUTDOWN(log))); + xfs_log_force(mp, XFS_LOG_SYNC); #ifdef DEBUG first_iclog = iclog = log->l_iclog; @@ -1007,7 +1004,7 @@ xfs_log_unmount_write(xfs_mount_t *mp) iclog = log->l_iclog; atomic_inc(&iclog->ic_refcnt); xlog_state_want_sync(log, iclog); - error = xlog_state_release_iclog(log, iclog); + xlog_state_release_iclog(log, iclog); switch (iclog->ic_state) { case XLOG_STATE_ACTIVE: case XLOG_STATE_DIRTY: @@ -1019,9 +1016,7 @@ xfs_log_unmount_write(xfs_mount_t *mp) break; } } - - return error; -} /* xfs_log_unmount_write */ +} /* * Empty the log for unmount/freeze. From patchwork Fri Mar 6 14:31:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11424137 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 016A414E3 for ; Fri, 6 Mar 2020 14:31:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CBB5E2072D for ; Fri, 6 Mar 2020 14:31:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Q9Ldg5P2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726738AbgCFObi (ORCPT ); Fri, 6 Mar 2020 09:31:38 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:39410 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726650AbgCFObi (ORCPT ); Fri, 6 Mar 2020 09:31:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=ARbSQ59WsV2gqhk23CbSj4t5Gc5h+SfHwDpVXULTHqw=; b=Q9Ldg5P21Q+vkEyKeA6zZsa8Km 0kRbCZEtoDd93bjleBAdsAPGVIT6Doh4pAz16kwpvoKrgNcMcnoMnBrAuoS9eVEO0TMDyYr8IkaMX FnWXqLiRQiltSJEoFlqmBn0av4QfSotEothbU5/ZKjnlDIuwhCkuAUFeeXgo50nQ4moq3F2mziEQe 8z5IAJRAYu/M3Yps7VJcOhEUKGaTA5KEVpQ6oZgPjwOX6edEcnaHj/G2pqHza55f6dNrtsU+8qTF6 9Lijm08rvTE7kFK//4odmRYgQYaTtMk6+JDXPWpP6wGiZnRf7NoD9U4KHIgndshU85JldXs/Bx7J7 MNwuTs+g==; Received: from [162.248.129.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jAE0n-0008H7-TC; Fri, 06 Mar 2020 14:31:38 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 2/7] xfs: remove dead code from xfs_log_unmount_write Date: Fri, 6 Mar 2020 07:31:32 -0700 Message-Id: <20200306143137.236478-3-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200306143137.236478-1-hch@lst.de> References: <20200306143137.236478-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org When the log is shut down all iclogs are in the XLOG_STATE_IOERROR state, which means that xlog_state_want_sync and xlog_state_release_iclog are no-ops. Remove the whole section of code. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index fa499ddedb94..b56432d4a9b8 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -984,38 +984,9 @@ xfs_log_unmount_write(xfs_mount_t *mp) iclog = iclog->ic_next; } while (iclog != first_iclog); #endif - if (! (XLOG_FORCED_SHUTDOWN(log))) { - xfs_log_write_unmount_record(mp); - } else { - /* - * We're already in forced_shutdown mode, couldn't - * even attempt to write out the unmount transaction. - * - * Go through the motions of sync'ing and releasing - * the iclog, even though no I/O will actually happen, - * we need to wait for other log I/Os that may already - * be in progress. Do this as a separate section of - * code so we'll know if we ever get stuck here that - * we're in this odd situation of trying to unmount - * a file system that went into forced_shutdown as - * the result of an unmount.. - */ - spin_lock(&log->l_icloglock); - iclog = log->l_iclog; - atomic_inc(&iclog->ic_refcnt); - xlog_state_want_sync(log, iclog); - xlog_state_release_iclog(log, iclog); - switch (iclog->ic_state) { - case XLOG_STATE_ACTIVE: - case XLOG_STATE_DIRTY: - case XLOG_STATE_IOERROR: - spin_unlock(&log->l_icloglock); - break; - default: - xlog_wait(&iclog->ic_force_wait, &log->l_icloglock); - break; - } - } + if (XLOG_FORCED_SHUTDOWN(log)) + return; + xfs_log_write_unmount_record(mp); } /* From patchwork Fri Mar 6 14:31:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11424139 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 538D314BC for ; Fri, 6 Mar 2020 14:31:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 34B212072D for ; Fri, 6 Mar 2020 14:31:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="F4su1DKP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726769AbgCFObj (ORCPT ); Fri, 6 Mar 2020 09:31:39 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:39422 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726740AbgCFObj (ORCPT ); Fri, 6 Mar 2020 09:31:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=5n+WY7IMndO3+WvSd56tUoe9by01YBM8AxNS3tmsTPk=; b=F4su1DKPYK0/SSw830rpfSWqip u6eykWxpce6nBbB3yfwZKwxdQ18h3fpZC/240BN1lW4RPX4GUefGeE/V607jDghMiamgcrBk0sxkW Tr6JXl/oTarqu48U0CgViZF2V1gMxfHtwLTdWrDSm+VIKyDy/Zs9y6bupeVtYVTHXIfDPcDKUZuUV Uc8U2N//hOj4XxdZo9/ua6nnP7ojlhOuv13OlhrRm/orN3danoELkgF/WznlOO4lWbwjQQbIc2h/5 AbEEDQrLFvS0PXj2Jak6DrNi7b6/PmgyaTj482N5RLhj5SOaJBd7SZTWBaoxgbqdq7LLBAVA+ExIt HX/FRJqA==; Received: from [162.248.129.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jAE0p-0008HE-4Z; Fri, 06 Mar 2020 14:31:39 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 3/7] xfs: cleanup xfs_log_unmount_write Date: Fri, 6 Mar 2020 07:31:33 -0700 Message-Id: <20200306143137.236478-4-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200306143137.236478-1-hch@lst.de> References: <20200306143137.236478-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Move the code for verifying the iclog state on a clean unmount into a helper, and instead of checking the iclog state just rely on the shutdown check as they are equivalent. Also remove the ifdef DEBUG as the compiler is smart enough to eliminate the dead code for non-debug builds. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index b56432d4a9b8..89f2e68eb570 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -946,6 +946,18 @@ xfs_log_write_unmount_record( } } +static void +xfs_log_unmount_verify_iclog( + struct xlog *log) +{ + struct xlog_in_core *iclog = log->l_iclog; + + do { + ASSERT(iclog->ic_state == XLOG_STATE_ACTIVE); + ASSERT(iclog->ic_offset == 0); + } while ((iclog = iclog->ic_next) != log->l_iclog); +} + /* * Unmount record used to have a string "Unmount filesystem--" in the * data section where the "Un" was really a magic number (XLOG_UNMOUNT_TYPE). @@ -954,13 +966,10 @@ xfs_log_write_unmount_record( * As far as I know, there weren't any dependencies on the old behaviour. */ static void -xfs_log_unmount_write(xfs_mount_t *mp) +xfs_log_unmount_write( + struct xfs_mount *mp) { - struct xlog *log = mp->m_log; - xlog_in_core_t *iclog; -#ifdef DEBUG - xlog_in_core_t *first_iclog; -#endif + struct xlog *log = mp->m_log; /* * Don't write out unmount record on norecovery mounts or ro devices. @@ -974,18 +983,9 @@ xfs_log_unmount_write(xfs_mount_t *mp) xfs_log_force(mp, XFS_LOG_SYNC); -#ifdef DEBUG - first_iclog = iclog = log->l_iclog; - do { - if (iclog->ic_state != XLOG_STATE_IOERROR) { - ASSERT(iclog->ic_state == XLOG_STATE_ACTIVE); - ASSERT(iclog->ic_offset == 0); - } - iclog = iclog->ic_next; - } while (iclog != first_iclog); -#endif if (XLOG_FORCED_SHUTDOWN(log)) return; + xfs_log_unmount_verify_iclog(log); xfs_log_write_unmount_record(mp); } From patchwork Fri Mar 6 14:31:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11424141 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F13A14E3 for ; Fri, 6 Mar 2020 14:31:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4686120717 for ; Fri, 6 Mar 2020 14:31:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="uxQZwEP+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726740AbgCFObl (ORCPT ); Fri, 6 Mar 2020 09:31:41 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:39430 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726650AbgCFObk (ORCPT ); Fri, 6 Mar 2020 09:31:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=pK2BCR0fFdl0rED1BI2fLIxyk/AXR4c1TMcClOT7Eg4=; b=uxQZwEP+GBW9CGSxIKH3zvv1uE XdPwgUsLSgdoxHsfjyoLY6m7OhDaDbOHApimru56FG+BHq1fQhl4soROYdKuGl8xu4T0qDCpQwDyf N2kytU57exlJE2xRsKOc1k0mzo6LTUULQ3gKjTbqmG28+Es9hikJI1yNzzidDXhcjDOlKrxuox3c4 W5j+RnOuaertg3TpiJwzESB5cWqSrUiKRL7FDtN8zcgmiauMuS91lXKQfHKDxUjMDcesoAwjyy2kf JdzcnxtsItrij7kT18BNyqwAgclK+TSwOGv7HzMluWJD8resbGo/BNXErHo5blkuzGiRA8retEzc2 NKkRnhQA==; Received: from [162.248.129.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jAE0q-0008Hj-CK; Fri, 06 Mar 2020 14:31:40 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 4/7] xfs: remove the aborted parameter to xlog_state_done_syncing Date: Fri, 6 Mar 2020 07:31:34 -0700 Message-Id: <20200306143137.236478-5-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200306143137.236478-1-hch@lst.de> References: <20200306143137.236478-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org We can just check for a shut down log all the way down in xlog_cil_committed instead of passing the parameter. This means a slight behavior change in that we now also abort log items if the shutdown came in halfway into the I/O completion processing, which actually is the right thing to do. Signed-off-by: Christoph Hellwig --- fs/xfs/xfs_log.c | 48 +++++++++++++++----------------------------- fs/xfs/xfs_log.h | 2 +- fs/xfs/xfs_log_cil.c | 11 +++++----- 3 files changed, 22 insertions(+), 39 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 89f2e68eb570..45f7a6eaddea 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -47,8 +47,7 @@ xlog_dealloc_log( /* local state machine functions */ STATIC void xlog_state_done_syncing( - struct xlog_in_core *iclog, - bool aborted); + struct xlog_in_core *iclog); STATIC int xlog_state_get_iclog_space( struct xlog *log, @@ -1250,7 +1249,6 @@ xlog_ioend_work( struct xlog_in_core *iclog = container_of(work, struct xlog_in_core, ic_end_io_work); struct xlog *log = iclog->ic_log; - bool aborted = false; int error; error = blk_status_to_errno(iclog->ic_bio.bi_status); @@ -1266,17 +1264,9 @@ xlog_ioend_work( if (XFS_TEST_ERROR(error, log->l_mp, XFS_ERRTAG_IODONE_IOERR)) { xfs_alert(log->l_mp, "log I/O error %d", error); xfs_force_shutdown(log->l_mp, SHUTDOWN_LOG_IO_ERROR); - /* - * This flag will be propagated to the trans-committed - * callback routines to let them know that the log-commit - * didn't succeed. - */ - aborted = true; - } else if (iclog->ic_state == XLOG_STATE_IOERROR) { - aborted = true; } - xlog_state_done_syncing(iclog, aborted); + xlog_state_done_syncing(iclog); bio_uninit(&iclog->ic_bio); /* @@ -1755,7 +1745,7 @@ xlog_write_iclog( * the buffer manually, the code needs to be kept in sync * with the I/O completion path. */ - xlog_state_done_syncing(iclog, true); + xlog_state_done_syncing(iclog); up(&iclog->ic_sema); return; } @@ -2779,8 +2769,7 @@ xlog_state_iodone_process_iclog( static void xlog_state_do_iclog_callbacks( struct xlog *log, - struct xlog_in_core *iclog, - bool aborted) + struct xlog_in_core *iclog) __releases(&log->l_icloglock) __acquires(&log->l_icloglock) { @@ -2792,7 +2781,7 @@ xlog_state_do_iclog_callbacks( list_splice_init(&iclog->ic_callbacks, &tmp); spin_unlock(&iclog->ic_callback_lock); - xlog_cil_process_committed(&tmp, aborted); + xlog_cil_process_committed(&tmp); spin_lock(&iclog->ic_callback_lock); } @@ -2807,8 +2796,7 @@ xlog_state_do_iclog_callbacks( STATIC void xlog_state_do_callback( - struct xlog *log, - bool aborted) + struct xlog *log) { struct xlog_in_core *iclog; struct xlog_in_core *first_iclog; @@ -2849,7 +2837,7 @@ xlog_state_do_callback( * we'll have to run at least one more complete loop. */ cycled_icloglock = true; - xlog_state_do_iclog_callbacks(log, iclog, aborted); + xlog_state_do_iclog_callbacks(log, iclog); xlog_state_clean_iclog(log, iclog); iclog = iclog->ic_next; @@ -2887,25 +2875,22 @@ xlog_state_do_callback( */ STATIC void xlog_state_done_syncing( - struct xlog_in_core *iclog, - bool aborted) + struct xlog_in_core *iclog) { struct xlog *log = iclog->ic_log; spin_lock(&log->l_icloglock); - ASSERT(atomic_read(&iclog->ic_refcnt) == 0); /* * If we got an error, either on the first buffer, or in the case of - * split log writes, on the second, we mark ALL iclogs STATE_IOERROR, - * and none should ever be attempted to be written to disk - * again. + * split log writes, on the second, we shut down the file system and + * none should ever be attempted to be written to disk again. */ - if (iclog->ic_state == XLOG_STATE_SYNCING) + if (!XLOG_FORCED_SHUTDOWN(log)) { + ASSERT(iclog->ic_state == XLOG_STATE_SYNCING); iclog->ic_state = XLOG_STATE_DONE_SYNC; - else - ASSERT(iclog->ic_state == XLOG_STATE_IOERROR); + } /* * Someone could be sleeping prior to writing out the next @@ -2914,9 +2899,8 @@ xlog_state_done_syncing( */ wake_up_all(&iclog->ic_write_wait); spin_unlock(&log->l_icloglock); - xlog_state_do_callback(log, aborted); /* also cleans log */ -} /* xlog_state_done_syncing */ - + xlog_state_do_callback(log); /* also cleans log */ +} /* * If the head of the in-core log ring is not (ACTIVE or DIRTY), then we must @@ -3908,7 +3892,7 @@ xfs_log_force_umount( spin_lock(&log->l_cilp->xc_push_lock); wake_up_all(&log->l_cilp->xc_commit_wait); spin_unlock(&log->l_cilp->xc_push_lock); - xlog_state_do_callback(log, true); + xlog_state_do_callback(log); /* return non-zero if log IOERROR transition had already happened */ return retval; diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h index 84e06805160f..ad87c5593ebd 100644 --- a/fs/xfs/xfs_log.h +++ b/fs/xfs/xfs_log.h @@ -138,7 +138,7 @@ void xfs_log_ticket_put(struct xlog_ticket *ticket); void xfs_log_commit_cil(struct xfs_mount *mp, struct xfs_trans *tp, xfs_lsn_t *commit_lsn, bool regrant); -void xlog_cil_process_committed(struct list_head *list, bool aborted); +void xlog_cil_process_committed(struct list_head *list); bool xfs_log_item_in_current_chkpt(struct xfs_log_item *lip); void xfs_log_work_queue(struct xfs_mount *mp); diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index 48435cf2aa16..b5c4a45c208c 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c @@ -574,10 +574,10 @@ xlog_discard_busy_extents( */ static void xlog_cil_committed( - struct xfs_cil_ctx *ctx, - bool abort) + struct xfs_cil_ctx *ctx) { struct xfs_mount *mp = ctx->cil->xc_log->l_mp; + bool abort = XLOG_FORCED_SHUTDOWN(ctx->cil->xc_log); /* * If the I/O failed, we're aborting the commit and already shutdown. @@ -613,15 +613,14 @@ xlog_cil_committed( void xlog_cil_process_committed( - struct list_head *list, - bool aborted) + struct list_head *list) { struct xfs_cil_ctx *ctx; while ((ctx = list_first_entry_or_null(list, struct xfs_cil_ctx, iclog_entry))) { list_del(&ctx->iclog_entry); - xlog_cil_committed(ctx, aborted); + xlog_cil_committed(ctx); } } @@ -878,7 +877,7 @@ xlog_cil_push( out_abort_free_ticket: xfs_log_ticket_put(tic); out_abort: - xlog_cil_committed(ctx, true); + xlog_cil_committed(ctx); return -EIO; } From patchwork Fri Mar 6 14:31:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11424143 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9681014E3 for ; Fri, 6 Mar 2020 14:31:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 76E0220717 for ; Fri, 6 Mar 2020 14:31:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="NwP7i3Bd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726781AbgCFObm (ORCPT ); Fri, 6 Mar 2020 09:31:42 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:39434 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726650AbgCFObl (ORCPT ); Fri, 6 Mar 2020 09:31:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=mSzvQ4nOT9G0jvA6fGXyviaeQaAFuw3gUrLegIbJh64=; b=NwP7i3BdKKuuabLRTLXlGvSyxV lmdggvlDzgoBw0+ACqQiVd+99gGkGq8WBgUkW9OcrxSCByZe89L90rUe/PX3KapS7XCE/xSkCCi7N oA2cQ+Q07JaI/xAfz0aLH/ZquhKVD9yz3SihzuW5HPfI/K3WUG2UvIkbxS3vqeJnbsQHiTw+crSTl cjozNjywWzG6izCCL/E8EJ0u/go2OKxCXEpPuIyC1cx10CIfrYQjOU+31aMqkS/HahpQShWJaSiM0 Q8ZKZOzn5Udz3gTZd13v2tYzNU7UsxFKpq2cdwlUPP3iy/+Am6nkjKLBc+T8SSnJre9QjZQUZ+ifI s7NkqxFA==; Received: from [162.248.129.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jAE0r-0008I8-I8; Fri, 06 Mar 2020 14:31:41 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 5/7] xfs: factor out a xlog_state_activate_iclog helper Date: Fri, 6 Mar 2020 07:31:35 -0700 Message-Id: <20200306143137.236478-6-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200306143137.236478-1-hch@lst.de> References: <20200306143137.236478-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Factor out the code to mark an iclog a active into a new helper. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 68 +++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 45f7a6eaddea..d1accad13af4 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2536,6 +2536,38 @@ xlog_write( ***************************************************************************** */ +static void +xlog_state_activate_iclog( + struct xlog_in_core *iclog, + int *changed) +{ + ASSERT(list_empty_careful(&iclog->ic_callbacks)); + + /* + * If the number of ops in this iclog indicate it just contains the + * dummy transaction, we can change state into IDLE (the second time + * around). Otherwise we should change the state into NEED a dummy. + * We don't need to cover the dummy. + */ + if (!*changed && + iclog->ic_header.h_num_logops == cpu_to_be32(XLOG_COVER_OPS)) { + *changed = 1; + } else { + /* + * We have two dirty iclogs so start over. This could also be + * num of ops indicating this is not the dummy going out. + */ + *changed = 2; + } + + iclog->ic_state = XLOG_STATE_ACTIVE; + iclog->ic_offset = 0; + iclog->ic_header.h_num_logops = 0; + memset(iclog->ic_header.h_cycle_data, 0, + sizeof(iclog->ic_header.h_cycle_data)); + iclog->ic_header.h_lsn = 0; +} + /* * An iclog has just finished IO completion processing, so we need to update * the iclog state and propagate that up into the overall log state. Hence we @@ -2567,38 +2599,10 @@ xlog_state_clean_iclog( /* Walk all the iclogs to update the ordered active state. */ iclog = log->l_iclog; do { - if (iclog->ic_state == XLOG_STATE_DIRTY) { - iclog->ic_state = XLOG_STATE_ACTIVE; - iclog->ic_offset = 0; - ASSERT(list_empty_careful(&iclog->ic_callbacks)); - /* - * If the number of ops in this iclog indicate it just - * contains the dummy transaction, we can - * change state into IDLE (the second time around). - * Otherwise we should change the state into - * NEED a dummy. - * We don't need to cover the dummy. - */ - if (!changed && - (be32_to_cpu(iclog->ic_header.h_num_logops) == - XLOG_COVER_OPS)) { - changed = 1; - } else { - /* - * We have two dirty iclogs so start over - * This could also be num of ops indicates - * this is not the dummy going out. - */ - changed = 2; - } - iclog->ic_header.h_num_logops = 0; - memset(iclog->ic_header.h_cycle_data, 0, - sizeof(iclog->ic_header.h_cycle_data)); - iclog->ic_header.h_lsn = 0; - } else if (iclog->ic_state == XLOG_STATE_ACTIVE) - /* do nothing */; - else - break; /* stop cleaning */ + if (iclog->ic_state == XLOG_STATE_DIRTY) + xlog_state_activate_iclog(iclog, &changed); + else if (iclog->ic_state != XLOG_STATE_ACTIVE) + break; iclog = iclog->ic_next; } while (iclog != log->l_iclog); From patchwork Fri Mar 6 14:31:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11424145 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C237514BC for ; Fri, 6 Mar 2020 14:31:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 96CC520717 for ; Fri, 6 Mar 2020 14:31:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="TGMFWknT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726811AbgCFObn (ORCPT ); Fri, 6 Mar 2020 09:31:43 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:39442 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726788AbgCFObn (ORCPT ); Fri, 6 Mar 2020 09:31:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=eCXaL8KdyMEPxUiQBKztikRQ/PPImF5/+Ftx+hESWGk=; b=TGMFWknT7ziHkuUnXaYusTyQUm 6yNgVLKN3tBTe6RiMwJFY8kgBVj5Fs0PQxjKSAudd1etTCBEnV2QMmz7/nt0rURI0BG4dj8P7j+9z qCmQlXjlKH8Rx+L3Ol5yfMwZp1WaTPpMRyfk70CaaeCZH/TgHsYWZBCmPf0zNXuzdicpXPa0fFu8z XXlMkZT0nbGxJ7bfGiI4h9dOjA/eNHVEepuH70uE/wgAEP0spwem0YifVIwpDAbP/gzi1G31OqCcq 9XmkRd2gTyyGtSmYuqtQqRwfjBP/+yVys9fL28lRmVHpJCchAzkrWhf/AvmyAZSlbixgJD6neVFgj z/OeWtqQ==; Received: from [162.248.129.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jAE0s-0008IS-NI; Fri, 06 Mar 2020 14:31:42 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 6/7] xfs: cleanup xlog_state_clean_iclog Date: Fri, 6 Mar 2020 07:31:36 -0700 Message-Id: <20200306143137.236478-7-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200306143137.236478-1-hch@lst.de> References: <20200306143137.236478-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Use the shutdown flag in the log to bypass the iclog processing instead of looking at the ioerror flag, and slightly simplify the while loop processing. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index d1accad13af4..fae5107099b1 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2582,30 +2582,29 @@ xlog_state_activate_iclog( * * Caller must hold the icloglock before calling us. * - * State Change: !IOERROR -> DIRTY -> ACTIVE + * State Change: CALLBACK -> DIRTY -> ACTIVE */ STATIC void xlog_state_clean_iclog( struct xlog *log, struct xlog_in_core *dirty_iclog) { - struct xlog_in_core *iclog; int changed = 0; - /* Prepare the completed iclog. */ - if (dirty_iclog->ic_state != XLOG_STATE_IOERROR) - dirty_iclog->ic_state = XLOG_STATE_DIRTY; + if (!XLOG_FORCED_SHUTDOWN(log)) { + struct xlog_in_core *iclog = log->l_iclog; - /* Walk all the iclogs to update the ordered active state. */ - iclog = log->l_iclog; - do { - if (iclog->ic_state == XLOG_STATE_DIRTY) - xlog_state_activate_iclog(iclog, &changed); - else if (iclog->ic_state != XLOG_STATE_ACTIVE) - break; - iclog = iclog->ic_next; - } while (iclog != log->l_iclog); + /* Prepare the completed iclog. */ + dirty_iclog->ic_state = XLOG_STATE_DIRTY; + /* Walk all the iclogs to update the ordered active state. */ + do { + if (iclog->ic_state == XLOG_STATE_DIRTY) + xlog_state_activate_iclog(iclog, &changed); + else if (iclog->ic_state != XLOG_STATE_ACTIVE) + break; + } while ((iclog = iclog->ic_next) != log->l_iclog); + } /* * Wake up threads waiting in xfs_log_force() for the dirty iclog From patchwork Fri Mar 6 14:31:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11424147 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 33E9514E3 for ; Fri, 6 Mar 2020 14:31:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0AFBB2072D for ; Fri, 6 Mar 2020 14:31:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="K+lgLzJ0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726788AbgCFObo (ORCPT ); Fri, 6 Mar 2020 09:31:44 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:39450 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726650AbgCFObo (ORCPT ); Fri, 6 Mar 2020 09:31:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=6CSzyDMBsQeIwaawouhlHDnVyEJcEWAaqhajdOnU31w=; b=K+lgLzJ0L13U2/O9sz6wZnRF1G Ps2Wl7LHvOWGFr/oBTjHWfgYCM2t56Sz7mNllOJebzc5sMtHMrl0FFi0PhgMD4r2piJlBfgpNuaRi mD8mmJyuWaymxd9UBwyuNnYW8n0/o/fTtc39jxT2ZTiCfq8WWAVGOBVXZwSTc8w3IgVx9OT7inZiu y8oukGKR+SZwoEWRzG+KFBpMBm86vv41Nvtj8enqIs+hcnv6PPAebBgIVYLLRLmcHUeU0CQmzcU0x 0eXRlkn2dyf8ZBsh7UHebD25iUKNXP5FIzdkYF6S3IDDM7wtpIwm2D+yHVKFdJvEyeuUUICw6sYVS slGgLqbQ==; Received: from [162.248.129.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jAE0t-0008IY-SG; Fri, 06 Mar 2020 14:31:44 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 7/7] xfs: kill XLOG_STATE_IOERROR Date: Fri, 6 Mar 2020 07:31:37 -0700 Message-Id: <20200306143137.236478-8-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200306143137.236478-1-hch@lst.de> References: <20200306143137.236478-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Just check the shutdown flag in struct xlog, instead of replicating the information into each iclog and checking it there. Signed-off-by: Christoph Hellwig --- fs/xfs/xfs_log.c | 95 +++++++++++++++---------------------------- fs/xfs/xfs_log_cil.c | 2 +- fs/xfs/xfs_log_priv.h | 1 - 3 files changed, 34 insertions(+), 64 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index fae5107099b1..1bcd5c735d6b 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -583,7 +583,7 @@ xlog_state_release_iclog( { lockdep_assert_held(&log->l_icloglock); - if (iclog->ic_state == XLOG_STATE_IOERROR) + if (XLOG_FORCED_SHUTDOWN(log)) return -EIO; if (atomic_dec_and_test(&iclog->ic_refcnt) && @@ -604,11 +604,11 @@ xfs_log_release_iclog( struct xlog *log = mp->m_log; bool sync; - if (iclog->ic_state == XLOG_STATE_IOERROR) + if (XLOG_FORCED_SHUTDOWN(log)) goto error; if (atomic_dec_and_lock(&iclog->ic_refcnt, &log->l_icloglock)) { - if (iclog->ic_state == XLOG_STATE_IOERROR) { + if (XLOG_FORCED_SHUTDOWN(log)) { spin_unlock(&log->l_icloglock); goto error; } @@ -914,7 +914,7 @@ xfs_log_write_unmount_record( error = xlog_write(log, &vec, tic, &lsn, NULL, flags); /* * At this point, we're umounting anyway, so there's no point in - * transitioning log state to IOERROR. Just continue... + * transitioning log state to IO_ERROR. Just continue... */ out_err: if (error) @@ -1737,7 +1737,7 @@ xlog_write_iclog( * across the log IO to archieve that. */ down(&iclog->ic_sema); - if (unlikely(iclog->ic_state == XLOG_STATE_IOERROR)) { + if (unlikely(XLOG_FORCED_SHUTDOWN(log))) { /* * It would seem logical to return EIO here, but we rely on * the log state machine to propagate I/O errors instead of @@ -2721,6 +2721,17 @@ xlog_state_iodone_process_iclog( xfs_lsn_t lowest_lsn; xfs_lsn_t header_lsn; + /* + * Between marking a filesystem SHUTDOWN and stopping the log, we do + * flush all iclogs to disk (if there wasn't a log I/O error). So, we + * do want things to go smoothly in case of just a SHUTDOWN w/o a + * LOG_IO_ERROR. + */ + if (XLOG_FORCED_SHUTDOWN(log)) { + *ioerror = true; + return false; + } + switch (iclog->ic_state) { case XLOG_STATE_ACTIVE: case XLOG_STATE_DIRTY: @@ -2728,15 +2739,6 @@ xlog_state_iodone_process_iclog( * Skip all iclogs in the ACTIVE & DIRTY states: */ return false; - case XLOG_STATE_IOERROR: - /* - * Between marking a filesystem SHUTDOWN and stopping the log, - * we do flush all iclogs to disk (if there wasn't a log I/O - * error). So, we do want things to go smoothly in case of just - * a SHUTDOWN w/o a LOG_IO_ERROR. - */ - *ioerror = true; - return false; case XLOG_STATE_DONE_SYNC: /* * Now that we have an iclog that is in the DONE_SYNC state, do @@ -2830,7 +2832,7 @@ xlog_state_do_callback( break; if (iclog->ic_state != XLOG_STATE_CALLBACK && - iclog->ic_state != XLOG_STATE_IOERROR) { + !XLOG_FORCED_SHUTDOWN(log)) { iclog = iclog->ic_next; continue; } @@ -2856,7 +2858,7 @@ xlog_state_do_callback( } while (!ioerror && cycled_icloglock); if (log->l_iclog->ic_state == XLOG_STATE_ACTIVE || - log->l_iclog->ic_state == XLOG_STATE_IOERROR) + XLOG_FORCED_SHUTDOWN(log)) wake_up_all(&log->l_flush_wait); spin_unlock(&log->l_icloglock); @@ -3202,7 +3204,7 @@ xfs_log_force( spin_lock(&log->l_icloglock); iclog = log->l_iclog; - if (iclog->ic_state == XLOG_STATE_IOERROR) + if (XLOG_FORCED_SHUTDOWN(log)) goto out_error; if (iclog->ic_state == XLOG_STATE_DIRTY || @@ -3259,11 +3261,11 @@ xfs_log_force( if (!(flags & XFS_LOG_SYNC)) goto out_unlock; - if (iclog->ic_state == XLOG_STATE_IOERROR) + if (XLOG_FORCED_SHUTDOWN(log)) goto out_error; XFS_STATS_INC(mp, xs_log_force_sleep); xlog_wait(&iclog->ic_force_wait, &log->l_icloglock); - if (iclog->ic_state == XLOG_STATE_IOERROR) + if (XLOG_FORCED_SHUTDOWN(log)) return -EIO; return 0; @@ -3288,7 +3290,7 @@ __xfs_log_force_lsn( spin_lock(&log->l_icloglock); iclog = log->l_iclog; - if (iclog->ic_state == XLOG_STATE_IOERROR) + if (XLOG_FORCED_SHUTDOWN(log)) goto out_error; while (be64_to_cpu(iclog->ic_header.h_lsn) != lsn) { @@ -3338,12 +3340,12 @@ __xfs_log_force_lsn( iclog->ic_state == XLOG_STATE_DIRTY)) goto out_unlock; - if (iclog->ic_state == XLOG_STATE_IOERROR) + if (XLOG_FORCED_SHUTDOWN(log)) goto out_error; XFS_STATS_INC(mp, xs_log_force_sleep); xlog_wait(&iclog->ic_force_wait, &log->l_icloglock); - if (iclog->ic_state == XLOG_STATE_IOERROR) + if (XLOG_FORCED_SHUTDOWN(log)) return -EIO; return 0; @@ -3407,7 +3409,7 @@ xlog_state_want_sync( xlog_state_switch_iclogs(log, iclog, 0); } else { ASSERT(iclog->ic_state == XLOG_STATE_WANT_SYNC || - iclog->ic_state == XLOG_STATE_IOERROR); + XLOG_FORCED_SHUTDOWN(log)); } } @@ -3774,34 +3776,6 @@ xlog_verify_iclog( } /* xlog_verify_iclog */ #endif -/* - * Mark all iclogs IOERROR. l_icloglock is held by the caller. - */ -STATIC int -xlog_state_ioerror( - struct xlog *log) -{ - xlog_in_core_t *iclog, *ic; - - iclog = log->l_iclog; - if (iclog->ic_state != XLOG_STATE_IOERROR) { - /* - * Mark all the incore logs IOERROR. - * From now on, no log flushes will result. - */ - ic = iclog; - do { - ic->ic_state = XLOG_STATE_IOERROR; - ic = ic->ic_next; - } while (ic != iclog); - return 0; - } - /* - * Return non-zero, if state transition has already happened. - */ - return 1; -} - /* * This is called from xfs_force_shutdown, when we're forcibly * shutting down the filesystem, typically because of an IO error. @@ -3823,10 +3797,8 @@ xfs_log_force_umount( struct xfs_mount *mp, int logerror) { - struct xlog *log; - int retval; - - log = mp->m_log; + struct xlog *log = mp->m_log; + int retval = 0; /* * If this happens during log recovery, don't worry about @@ -3844,10 +3816,8 @@ xfs_log_force_umount( * Somebody could've already done the hard work for us. * No need to get locks for this. */ - if (logerror && log->l_iclog->ic_state == XLOG_STATE_IOERROR) { - ASSERT(XLOG_FORCED_SHUTDOWN(log)); + if (logerror && XLOG_FORCED_SHUTDOWN(log)) return 1; - } /* * Flush all the completed transactions to disk before marking the log @@ -3869,11 +3839,13 @@ xfs_log_force_umount( mp->m_sb_bp->b_flags |= XBF_DONE; /* - * Mark the log and the iclogs with IO error flags to prevent any - * further log IO from being issued or completed. + * Mark the log as shut down to prevent any further log IO from being + * issued or completed. Return non-zero if log IO_ERROR transition had + * already happened so that the caller can skip further processing. */ + if (XLOG_FORCED_SHUTDOWN(log)) + retval = 1; log->l_flags |= XLOG_IO_ERROR; - retval = xlog_state_ioerror(log); spin_unlock(&log->l_icloglock); /* @@ -3897,7 +3869,6 @@ xfs_log_force_umount( spin_unlock(&log->l_cilp->xc_push_lock); xlog_state_do_callback(log); - /* return non-zero if log IOERROR transition had already happened */ return retval; } diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index b5c4a45c208c..41a45d75a2d0 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c @@ -846,7 +846,7 @@ xlog_cil_push( goto out_abort; spin_lock(&commit_iclog->ic_callback_lock); - if (commit_iclog->ic_state == XLOG_STATE_IOERROR) { + if (XLOG_FORCED_SHUTDOWN(log)) { spin_unlock(&commit_iclog->ic_callback_lock); goto out_abort; } diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index b192c5a9f9fd..fd4c913ee7e6 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h @@ -47,7 +47,6 @@ enum xlog_iclog_state { XLOG_STATE_DONE_SYNC, /* Done syncing to disk */ XLOG_STATE_CALLBACK, /* Callback functions now */ XLOG_STATE_DIRTY, /* Dirty IC log, not ready for ACTIVE status */ - XLOG_STATE_IOERROR, /* IO error happened in sync'ing log */ }; /*