From patchwork Mon Mar 16 14:42:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11440501 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 3AE3F92A for ; Mon, 16 Mar 2020 14:46:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1BEEF20719 for ; Mon, 16 Mar 2020 14:46:59 +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="urej1d8k" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731475AbgCPOq6 (ORCPT ); Mon, 16 Mar 2020 10:46:58 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57114 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731445AbgCPOq6 (ORCPT ); Mon, 16 Mar 2020 10:46:58 -0400 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=5+2/fxqmRiuXtQcTQ8R4Q7CzfgmvYniXT8Mqcc2Bpxk=; b=urej1d8kSBedbTPuW/8yVYWiPs oGFYQ6mK2TtAY/fYKqq+5S2XjumSfQzkhK+B7eG2RB8xm8CyGKEmM8f0IYPGCm0ZPGovvADcO6n/g y8F7GKwhxXOV8pC0/ltZWpRWxS+SFmJjxqVzjf6HUi6EFMvERcNylN4D26hpuvSheSL2WxICVZA2i La7E0w49GR0FuCMBzcLrVr54rz41XQnxXXHh33qXN9+JfyHyjqjwaDJcAWoarX+0moD6OMqs4tTwB pFdWXZH45UjWslx2CXo5zFwiqt4e+TGSAop8ChEuHK8Du9Or1Lt/qqO/apk6rlYWTej/Y5KQ57VGT 3fTxnInA==; Received: from 089144202225.atnat0011.highway.a1.net ([89.144.202.225] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDr18-0006pB-3T; Mon, 16 Mar 2020 14:46:58 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 01/14] xfs: merge xlog_cil_push into xlog_cil_push_work Date: Mon, 16 Mar 2020 15:42:20 +0100 Message-Id: <20200316144233.900390-2-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200316144233.900390-1-hch@lst.de> References: <20200316144233.900390-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 xlog_cil_push is only called by xlog_cil_push_work, so merge the two functions. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Reviewed-by: Dave Chinner Reviewed-by: Brian Foster --- fs/xfs/xfs_log_cil.c | 46 +++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index 48435cf2aa16..6a6278b8eb2d 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c @@ -626,24 +626,26 @@ xlog_cil_process_committed( } /* - * Push the Committed Item List to the log. If @push_seq flag is zero, then it - * is a background flush and so we can chose to ignore it. Otherwise, if the - * current sequence is the same as @push_seq we need to do a flush. If - * @push_seq is less than the current sequence, then it has already been + * Push the Committed Item List to the log. + * + * If the current sequence is the same as xc_push_seq we need to do a flush. If + * xc_push_seq is less than the current sequence, then it has already been * flushed and we don't need to do anything - the caller will wait for it to * complete if necessary. * - * @push_seq is a value rather than a flag because that allows us to do an - * unlocked check of the sequence number for a match. Hence we can allows log - * forces to run racily and not issue pushes for the same sequence twice. If we - * get a race between multiple pushes for the same sequence they will block on - * the first one and then abort, hence avoiding needless pushes. + * xc_push_seq is checked unlocked against the sequence number for a match. + * Hence we can allows log forces to run racily and not issue pushes for the + * same sequence twice. If we get a race between multiple pushes for the same + * sequence they will block on the first one and then abort, hence avoiding + * needless pushes. */ -STATIC int -xlog_cil_push( - struct xlog *log) +static void +xlog_cil_push_work( + struct work_struct *work) { - struct xfs_cil *cil = log->l_cilp; + struct xfs_cil *cil = + container_of(work, struct xfs_cil, xc_push_work); + struct xlog *log = cil->xc_log; struct xfs_log_vec *lv; struct xfs_cil_ctx *ctx; struct xfs_cil_ctx *new_ctx; @@ -657,9 +659,6 @@ xlog_cil_push( xfs_lsn_t commit_lsn; xfs_lsn_t push_seq; - if (!cil) - return 0; - new_ctx = kmem_zalloc(sizeof(*new_ctx), KM_NOFS); new_ctx->ticket = xlog_cil_ticket_alloc(log); @@ -867,28 +866,19 @@ xlog_cil_push( spin_unlock(&cil->xc_push_lock); /* release the hounds! */ - return xfs_log_release_iclog(log->l_mp, commit_iclog); + xfs_log_release_iclog(log->l_mp, commit_iclog); + return; out_skip: up_write(&cil->xc_ctx_lock); xfs_log_ticket_put(new_ctx->ticket); kmem_free(new_ctx); - return 0; + return; out_abort_free_ticket: xfs_log_ticket_put(tic); out_abort: xlog_cil_committed(ctx, true); - return -EIO; -} - -static void -xlog_cil_push_work( - struct work_struct *work) -{ - struct xfs_cil *cil = container_of(work, struct xfs_cil, - xc_push_work); - xlog_cil_push(cil->xc_log); } /* From patchwork Mon Mar 16 14:42:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11440509 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 77B2A92A for ; Mon, 16 Mar 2020 14:49:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4C5ED21707 for ; Mon, 16 Mar 2020 14:49:12 +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="gektYv25" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731582AbgCPOtL (ORCPT ); Mon, 16 Mar 2020 10:49:11 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57432 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731549AbgCPOtL (ORCPT ); Mon, 16 Mar 2020 10:49:11 -0400 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=fo8/2wTa5CtmtlPQtM7qWjKZ+Bcm2Uvtz3QS4+jJFi0=; b=gektYv259R5TYi7yZ1cnHOw/cn 1BVsuIqo8DUEni1/q1h5Diqj+X3D05m9wZYJiU+pUlUu8LWLBJEMrQaCTzn9zrqixqZkmiq2907wJ Qx54N6VDNQQKHI19xDKebOn8KWjUVq0TN2ABleoYVKss0n4sfORpreCr7AjbUYVWQZ423oFkheyCr S3+IPvkX3Aj7xmytO8Sh6C3YMqzwDsGVfU9tOGWVdbVYarxMbHkMLOGxIplGGnBB9ACXoeOKuQ+6M gk7iIzq3ajuzD+XunCC9LIy4wH2WwOIo5qBZjMiOquqzBSVZQ9zstHE+P3jgEGztXb+5inEbFjl9S HLpHeCbA==; Received: from 089144202225.atnat0011.highway.a1.net ([89.144.202.225] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDr3H-0007BQ-7f; Mon, 16 Mar 2020 14:49:11 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 02/14] xfs: factor out a xlog_wait_on_iclog helper Date: Mon, 16 Mar 2020 15:42:21 +0100 Message-Id: <20200316144233.900390-3-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200316144233.900390-1-hch@lst.de> References: <20200316144233.900390-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 shared code to wait for a log force into a new helper. This helper uses the XLOG_FORCED_SHUTDOWN check previous only used by the unmount code over the equivalent iclog ioerror state used by the other two functions. There is a slight behavior change in that the force of the unmount record is now accounted in the log force statistics. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 76 ++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 45 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 0986983ef6b5..955df2902c2c 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -859,6 +859,31 @@ xfs_log_mount_cancel( xfs_log_unmount(mp); } +/* + * Wait for the iclog to be written disk, or return an error if the log has been + * shut down. + */ +static int +xlog_wait_on_iclog( + struct xlog_in_core *iclog) + __releases(iclog->ic_log->l_icloglock) +{ + struct xlog *log = iclog->ic_log; + + if (!XLOG_FORCED_SHUTDOWN(log) && + iclog->ic_state != XLOG_STATE_ACTIVE && + iclog->ic_state != XLOG_STATE_DIRTY) { + XFS_STATS_INC(log->l_mp, xs_log_force_sleep); + xlog_wait(&iclog->ic_force_wait, &log->l_icloglock); + } else { + spin_unlock(&log->l_icloglock); + } + + if (XLOG_FORCED_SHUTDOWN(log)) + return -EIO; + return 0; +} + /* * Final log writes as part of unmount. * @@ -926,18 +951,7 @@ xfs_log_write_unmount_record( atomic_inc(&iclog->ic_refcnt); xlog_state_want_sync(log, iclog); error = xlog_state_release_iclog(log, iclog); - switch (iclog->ic_state) { - default: - if (!XLOG_FORCED_SHUTDOWN(log)) { - xlog_wait(&iclog->ic_force_wait, &log->l_icloglock); - break; - } - /* fall through */ - case XLOG_STATE_ACTIVE: - case XLOG_STATE_DIRTY: - spin_unlock(&log->l_icloglock); - break; - } + xlog_wait_on_iclog(iclog); if (tic) { trace_xfs_log_umount_write(log, tic); @@ -3230,9 +3244,6 @@ xfs_log_force( * previous iclog and go to sleep. */ iclog = iclog->ic_prev; - if (iclog->ic_state == XLOG_STATE_ACTIVE || - iclog->ic_state == XLOG_STATE_DIRTY) - goto out_unlock; } else if (iclog->ic_state == XLOG_STATE_ACTIVE) { if (atomic_read(&iclog->ic_refcnt) == 0) { /* @@ -3248,8 +3259,7 @@ xfs_log_force( if (xlog_state_release_iclog(log, iclog)) goto out_error; - if (be64_to_cpu(iclog->ic_header.h_lsn) != lsn || - iclog->ic_state == XLOG_STATE_DIRTY) + if (be64_to_cpu(iclog->ic_header.h_lsn) != lsn) goto out_unlock; } else { /* @@ -3269,17 +3279,8 @@ xfs_log_force( ; } - if (!(flags & XFS_LOG_SYNC)) - goto out_unlock; - - if (iclog->ic_state == XLOG_STATE_IOERROR) - 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) - return -EIO; - return 0; - + if (flags & XFS_LOG_SYNC) + return xlog_wait_on_iclog(iclog); out_unlock: spin_unlock(&log->l_icloglock); return 0; @@ -3310,9 +3311,6 @@ __xfs_log_force_lsn( goto out_unlock; } - if (iclog->ic_state == XLOG_STATE_DIRTY) - goto out_unlock; - if (iclog->ic_state == XLOG_STATE_ACTIVE) { /* * We sleep here if we haven't already slept (e.g. this is the @@ -3346,20 +3344,8 @@ __xfs_log_force_lsn( *log_flushed = 1; } - if (!(flags & XFS_LOG_SYNC) || - (iclog->ic_state == XLOG_STATE_ACTIVE || - iclog->ic_state == XLOG_STATE_DIRTY)) - goto out_unlock; - - if (iclog->ic_state == XLOG_STATE_IOERROR) - 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) - return -EIO; - return 0; - + if (flags & XFS_LOG_SYNC) + return xlog_wait_on_iclog(iclog); out_unlock: spin_unlock(&log->l_icloglock); return 0; From patchwork Mon Mar 16 14:42:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11440511 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 C3E1714B4 for ; Mon, 16 Mar 2020 14:51:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A282C20753 for ; Mon, 16 Mar 2020 14:51:27 +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="KBZB4NWA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731534AbgCPOv1 (ORCPT ); Mon, 16 Mar 2020 10:51:27 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57616 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729643AbgCPOv1 (ORCPT ); Mon, 16 Mar 2020 10:51:27 -0400 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=dywp22k64Sgtqu5Qnvq/NOCs9xYMno6nUQ3Pd6gOGWI=; b=KBZB4NWAWDqvTsc+5h9Ok7h9fI Sfl6d2kErU6TkQAPhdoW2sujcV1OJQ1KflpQRcIf/4reoDFAAFL7AGvpiDG3TMBjE38MG5K/3xnom AZ4Guua7n/bNQzKU/U2Ks+eLTzHGbywVzbkFjkm/gbkrlMKGhq0+ClVhQSLgp0ceV87jcZ/DG+0Ns CWTT1bVmMfHGEiKR32PjpmvGhoJdZEFYV5D1em3lceOmE9xE3xG75SPEqKIsKsWTvIwW67q8RUzbO ScGEvLW/YGbOtQkld6Wb/G0KcbMnP6a0MYSxxVP592BtBBJD24/scIPfG8SgzD6BfgMH10quKC/Rz Etmi+8nQ==; Received: from 089144202225.atnat0011.highway.a1.net ([89.144.202.225] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDr5Q-00005Y-IT; Mon, 16 Mar 2020 14:51:26 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 03/14] xfs: simplify the xfs_log_release_iclog calling convention Date: Mon, 16 Mar 2020 15:42:22 +0100 Message-Id: <20200316144233.900390-4-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200316144233.900390-1-hch@lst.de> References: <20200316144233.900390-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 The only caller of xfs_log_release_iclog doesn't care about the return value, so remove it. Also don't bother passing the mount pointer, given that we can trivially derive it from the iclog. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 10 ++++------ fs/xfs/xfs_log.h | 3 +-- fs/xfs/xfs_log_cil.c | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 955df2902c2c..17ba92b115ea 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -597,12 +597,11 @@ xlog_state_release_iclog( return 0; } -int +void xfs_log_release_iclog( - struct xfs_mount *mp, struct xlog_in_core *iclog) { - struct xlog *log = mp->m_log; + struct xlog *log = iclog->ic_log; bool sync; if (iclog->ic_state == XLOG_STATE_IOERROR) @@ -618,10 +617,9 @@ xfs_log_release_iclog( if (sync) xlog_sync(log, iclog); } - return 0; + return; error: - xfs_force_shutdown(mp, SHUTDOWN_LOG_IO_ERROR); - return -EIO; + xfs_force_shutdown(log->l_mp, SHUTDOWN_LOG_IO_ERROR); } /* diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h index 84e06805160f..b38602216c5a 100644 --- a/fs/xfs/xfs_log.h +++ b/fs/xfs/xfs_log.h @@ -121,8 +121,7 @@ void xfs_log_mount_cancel(struct xfs_mount *); xfs_lsn_t xlog_assign_tail_lsn(struct xfs_mount *mp); xfs_lsn_t xlog_assign_tail_lsn_locked(struct xfs_mount *mp); void xfs_log_space_wake(struct xfs_mount *mp); -int xfs_log_release_iclog(struct xfs_mount *mp, - struct xlog_in_core *iclog); +void xfs_log_release_iclog(struct xlog_in_core *iclog); int xfs_log_reserve(struct xfs_mount *mp, int length, int count, diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index 6a6278b8eb2d..047ac253edfe 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c @@ -866,7 +866,7 @@ xlog_cil_push_work( spin_unlock(&cil->xc_push_lock); /* release the hounds! */ - xfs_log_release_iclog(log->l_mp, commit_iclog); + xfs_log_release_iclog(commit_iclog); return; out_skip: From patchwork Mon Mar 16 14:42:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11440513 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 0632A17E6 for ; Mon, 16 Mar 2020 14:51:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CDD9E20753 for ; Mon, 16 Mar 2020 14:51:29 +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="h7yh9363" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731549AbgCPOv3 (ORCPT ); Mon, 16 Mar 2020 10:51:29 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57622 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729643AbgCPOv3 (ORCPT ); Mon, 16 Mar 2020 10:51:29 -0400 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=wiQDVC7GBRyhNzPIgyRQa9vO6cIZtfevTIGYCvLD5m8=; b=h7yh9363tTs2IRQDYw5R6jbYa1 54UDFCyAojaVYTEBNcDy3YeVrYTlTnS/BlYM8mO+OgxoIUkQdO98a/uDgcHS15mTI171/ALBIn1Ni LZZa3JEcJ+DpMuwaxUXNFYPPknBWN+Mhj1hXuMeLEk57YZcqVFi10LoJKs21TwVWodj4GhgnoRFas eDW4ykDJ2H4cHMAxp70Mg7pJhw1ei40bf7JrJQUsXmqF229X870w1haKJ5a+fuNvvATl3i3QbtD1V XvA0pOj+sdk5N/Gl7qEwQ8keOpBn6bgaAW+MHZxQSNJ93Kuxa5YjOCIaA4UNUQ+bd9LjyNXFfwnJS Kfc+Sp3w==; Received: from [2001:4bb8:188:30cd:8026:d98c:a056:3e33] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDr5U-00005s-NF; Mon, 16 Mar 2020 14:51:29 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 04/14] xfs: simplify log shutdown checking in xfs_log_release_iclog Date: Mon, 16 Mar 2020 15:42:23 +0100 Message-Id: <20200316144233.900390-5-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200316144233.900390-1-hch@lst.de> References: <20200316144233.900390-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 There is no need to check for the ioerror state before the lock, as the shutdown case is not a fast path. Also remove the call to force shutdown the file system, as it must have been shut down already for an iclog to be in the ioerror state. Also clean up the flow of the function a bit. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 17ba92b115ea..7af9c292540b 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -602,24 +602,16 @@ xfs_log_release_iclog( struct xlog_in_core *iclog) { struct xlog *log = iclog->ic_log; - bool sync; - - if (iclog->ic_state == XLOG_STATE_IOERROR) - goto error; + bool sync = false; if (atomic_dec_and_lock(&iclog->ic_refcnt, &log->l_icloglock)) { - if (iclog->ic_state == XLOG_STATE_IOERROR) { - spin_unlock(&log->l_icloglock); - goto error; - } - sync = __xlog_state_release_iclog(log, iclog); + if (iclog->ic_state != XLOG_STATE_IOERROR) + sync = __xlog_state_release_iclog(log, iclog); spin_unlock(&log->l_icloglock); - if (sync) - xlog_sync(log, iclog); } - return; -error: - xfs_force_shutdown(log->l_mp, SHUTDOWN_LOG_IO_ERROR); + + if (sync) + xlog_sync(log, iclog); } /* From patchwork Mon Mar 16 14:42:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11440515 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 79E7D14B4 for ; Mon, 16 Mar 2020 14:51:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 51C362075E for ; Mon, 16 Mar 2020 14:51:32 +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="T8J5RFi5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731560AbgCPOvc (ORCPT ); Mon, 16 Mar 2020 10:51:32 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57638 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729643AbgCPOvb (ORCPT ); Mon, 16 Mar 2020 10:51:31 -0400 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=stgC4n6JF2yWEvggUewpLyCk+AREcfhOemi5clJSTLA=; b=T8J5RFi5CGn42xuIgZriEbNgrn uG/TD44UR7G8c8DieVFLAsdWDR9BbwhVXKc63vrRW7GpFP+aBR7dv0l9wc6BTr2mcZU48J3qG9qV0 dNGyFLrBegtQKozkeSZi9CgZ2f73Xnz6QIagaoq09Htb+m7P8S5d8TY1/S+t6f4c8F5b1POB44HrA yCPOhE1ex2zigdaISpAyUqd8UqrjwMcZU+MX0hqP561bGUapAfZXGI3hRvRRYh9zVEcUrIZlFBh2U rlXs+F3A0gVqOq2GTAdo21sbeVNWYw1UcJ71/MO83lx8MTB7U0M5plC0/c9uKL/YYXFVb9IcbDYRh kVTvORrw==; Received: from [2001:4bb8:188:30cd:8026:d98c:a056:3e33] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDr5X-00006C-6i; Mon, 16 Mar 2020 14:51:31 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 05/14] xfs: remove the aborted parameter to xlog_state_done_syncing Date: Mon, 16 Mar 2020 15:42:24 +0100 Message-Id: <20200316144233.900390-6-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200316144233.900390-1-hch@lst.de> References: <20200316144233.900390-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 Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 48 +++++++++++++++----------------------------- fs/xfs/xfs_log.h | 2 +- fs/xfs/xfs_log_cil.c | 12 +++++------ 3 files changed, 23 insertions(+), 39 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 7af9c292540b..8ede2852f104 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, @@ -1254,7 +1253,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); @@ -1270,17 +1268,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); /* @@ -1759,7 +1749,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; } @@ -2783,8 +2773,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) { @@ -2796,7 +2785,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); } @@ -2811,8 +2800,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; @@ -2853,7 +2841,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; @@ -2891,25 +2879,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 @@ -2918,9 +2903,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 @@ -3884,7 +3868,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 b38602216c5a..cc77cc36560a 100644 --- a/fs/xfs/xfs_log.h +++ b/fs/xfs/xfs_log.h @@ -137,7 +137,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 047ac253edfe..adc4af336c97 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,8 @@ xlog_cil_push_work( out_abort_free_ticket: xfs_log_ticket_put(tic); out_abort: - xlog_cil_committed(ctx, true); + ASSERT(XLOG_FORCED_SHUTDOWN(log)); + xlog_cil_committed(ctx); } /* From patchwork Mon Mar 16 14:42:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11440517 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 C0ABD14B4 for ; Mon, 16 Mar 2020 14:51:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 993062075E for ; Mon, 16 Mar 2020 14:51:34 +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="ccf5+1wM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731572AbgCPOve (ORCPT ); Mon, 16 Mar 2020 10:51:34 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57644 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729643AbgCPOve (ORCPT ); Mon, 16 Mar 2020 10:51:34 -0400 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=VSYF7QUvzFERgntfq4GTIQtlM21RvpAxG6/Lic+/NrA=; b=ccf5+1wMNWN/qy8c4hVVbCgE95 1umPtWZxzuiBRZ1igNL7CPa7mdO3acdFdwGChkOMlchhXdLMe1a+3AV0AnMXbJYD4GCTCyvkRdnb6 7NyTjq0wrujWoDPjDz3Tjv8FKQGnM0EkLpubwXljKbeJ3QJmIpswGtogu3zPgReaLgMfrMebmf3wc WWXGc4K0xZlQfWEdSKOq/1rnRczhWH25nm186pYawTw0X0csjTUhOvQjppBKiNpyeAIbch/qB054j HaGoLcctWYT3a2u/yPdCpnuH7cHWxwUOguOVTODAdW9L2FaMDAISGPf/Fj0iKP4RbfpzKGrU39qjf 3PinFD9w==; Received: from [2001:4bb8:188:30cd:8026:d98c:a056:3e33] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDr5Z-00006z-IX; Mon, 16 Mar 2020 14:51:33 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 06/14] xfs: refactor xlog_state_clean_iclog Date: Mon, 16 Mar 2020 15:42:25 +0100 Message-Id: <20200316144233.900390-7-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200316144233.900390-1-hch@lst.de> References: <20200316144233.900390-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 a few self-container helper from xlog_state_clean_iclog, and update the documentation so it primarily documents why things happens instead of how. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_log.c | 180 +++++++++++++++++++++++------------------------ 1 file changed, 87 insertions(+), 93 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 8ede2852f104..23979d08a2a3 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2540,112 +2540,106 @@ xlog_write( ***************************************************************************** */ +static void +xlog_state_activate_iclog( + struct xlog_in_core *iclog, + int *iclogs_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 (*iclogs_changed == 0 && + iclog->ic_header.h_num_logops == cpu_to_be32(XLOG_COVER_OPS)) { + *iclogs_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. + */ + *iclogs_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 - * prepare the iclog for cleaning, and then clean all the pending dirty iclogs - * starting from the head, and then wake up any threads that are waiting for the - * iclog to be marked clean. - * - * The ordering of marking iclogs ACTIVE must be maintained, so an iclog - * doesn't become ACTIVE beyond one that is SYNCING. This is also required to - * maintain the notion that we use a ordered wait queue to hold off would be - * writers to the log when every iclog is trying to sync to disk. - * - * Caller must hold the icloglock before calling us. - * - * State Change: !IOERROR -> DIRTY -> ACTIVE + * Loop through all iclogs and mark all iclogs currently marked DIRTY as + * ACTIVE after iclog I/O has completed. */ -STATIC void -xlog_state_clean_iclog( +static void +xlog_state_activate_iclogs( struct xlog *log, - struct xlog_in_core *dirty_iclog) + int *iclogs_changed) { - 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; + 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) { - 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 */ - iclog = iclog->ic_next; - } while (iclog != log->l_iclog); - + if (iclog->ic_state == XLOG_STATE_DIRTY) + xlog_state_activate_iclog(iclog, iclogs_changed); + /* + * The ordering of marking iclogs ACTIVE must be maintained, so + * an iclog doesn't become ACTIVE beyond one that is SYNCING. + */ + else if (iclog->ic_state != XLOG_STATE_ACTIVE) + break; + } while ((iclog = iclog->ic_next) != log->l_iclog); +} +static int +xlog_covered_state( + struct xlog *log, + int iclogs_changed) +{ /* - * Wake up threads waiting in xfs_log_force() for the dirty iclog - * to be cleaned. + * We usually go to NEED. But we go to NEED2 if the changed indicates we + * are done writing the dummy record. If we are done with the second + * dummy recored (DONE2), then we go to IDLE. */ - wake_up_all(&dirty_iclog->ic_force_wait); + switch (log->l_covered_state) { + case XLOG_STATE_COVER_IDLE: + case XLOG_STATE_COVER_NEED: + case XLOG_STATE_COVER_NEED2: + break; + case XLOG_STATE_COVER_DONE: + if (iclogs_changed == 1) + return XLOG_STATE_COVER_NEED2; + break; + case XLOG_STATE_COVER_DONE2: + if (iclogs_changed == 1) + return XLOG_STATE_COVER_IDLE; + break; + default: + ASSERT(0); + } - /* - * Change state for the dummy log recording. - * We usually go to NEED. But we go to NEED2 if the changed indicates - * we are done writing the dummy record. - * If we are done with the second dummy recored (DONE2), then - * we go to IDLE. - */ - if (changed) { - switch (log->l_covered_state) { - case XLOG_STATE_COVER_IDLE: - case XLOG_STATE_COVER_NEED: - case XLOG_STATE_COVER_NEED2: - log->l_covered_state = XLOG_STATE_COVER_NEED; - break; + return XLOG_STATE_COVER_NEED; +} - case XLOG_STATE_COVER_DONE: - if (changed == 1) - log->l_covered_state = XLOG_STATE_COVER_NEED2; - else - log->l_covered_state = XLOG_STATE_COVER_NEED; - break; +STATIC void +xlog_state_clean_iclog( + struct xlog *log, + struct xlog_in_core *dirty_iclog) +{ + int iclogs_changed = 0; - case XLOG_STATE_COVER_DONE2: - if (changed == 1) - log->l_covered_state = XLOG_STATE_COVER_IDLE; - else - log->l_covered_state = XLOG_STATE_COVER_NEED; - break; + if (dirty_iclog->ic_state != XLOG_STATE_IOERROR) + dirty_iclog->ic_state = XLOG_STATE_DIRTY; - default: - ASSERT(0); - } - } + xlog_state_activate_iclogs(log, &iclogs_changed); + wake_up_all(&dirty_iclog->ic_force_wait); + + if (iclogs_changed) + log->l_covered_state = xlog_covered_state(log, iclogs_changed); } STATIC xfs_lsn_t From patchwork Mon Mar 16 14:42:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11440519 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 5516814B4 for ; Mon, 16 Mar 2020 14:51:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2B6E820767 for ; Mon, 16 Mar 2020 14:51: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="OGfcbq5y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731577AbgCPOvg (ORCPT ); Mon, 16 Mar 2020 10:51:36 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57656 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729643AbgCPOvg (ORCPT ); Mon, 16 Mar 2020 10:51:36 -0400 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=or0HmCakARX90E/i52GuvIU7WIEDqsXBhdHF750qPtI=; b=OGfcbq5yRVH85pDRFEl3WUQlRj erIfCteN9FnbXTxn2OrqRJxnW3wy9IYzMeFXy7yyH/4e3snHPq1aEH3qR3/Vu6Ouh5tObF9VCqrqi T7JX1d3kX25kjd6WLl3p9PzvZ2fl7sbr/IpLZ6l3YpWCXiK15/Z2ov772REEOx9+a7FzEqS93pdQq AwFV793VXnYcvlV/eG4U6wTP8jlgPjHST7GOUlNxoTbHhCvY7SNraolyM9x+Kn89kKEMeTA9EnbhV 0BSNQfT9OmtVEn2nbvMZ7LxQ5ZUCyJBAxPOT5Fa5L044QKsCrsrQ+As0R9yCsNRrlwtBuf6teQjPq L01jTaDg==; Received: from [2001:4bb8:188:30cd:8026:d98c:a056:3e33] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDr5c-00007H-37; Mon, 16 Mar 2020 14:51:36 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 07/14] xfs: move the ioerror check out of xlog_state_clean_iclog Date: Mon, 16 Mar 2020 15:42:26 +0100 Message-Id: <20200316144233.900390-8-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200316144233.900390-1-hch@lst.de> References: <20200316144233.900390-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 xlog_state_clean_iclog entirely in case of a shut down log. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 23979d08a2a3..c490c5b0d8b7 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2632,8 +2632,7 @@ xlog_state_clean_iclog( { int iclogs_changed = 0; - if (dirty_iclog->ic_state != XLOG_STATE_IOERROR) - dirty_iclog->ic_state = XLOG_STATE_DIRTY; + dirty_iclog->ic_state = XLOG_STATE_DIRTY; xlog_state_activate_iclogs(log, &iclogs_changed); wake_up_all(&dirty_iclog->ic_force_wait); @@ -2836,8 +2835,10 @@ xlog_state_do_callback( */ cycled_icloglock = true; xlog_state_do_iclog_callbacks(log, iclog); - - xlog_state_clean_iclog(log, iclog); + if (XLOG_FORCED_SHUTDOWN(log)) + wake_up_all(&iclog->ic_force_wait); + else + xlog_state_clean_iclog(log, iclog); iclog = iclog->ic_next; } while (first_iclog != iclog); From patchwork Mon Mar 16 14:42:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11440521 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 CDFC792A for ; Mon, 16 Mar 2020 14:51:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AE8E820753 for ; Mon, 16 Mar 2020 14:51:39 +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="rniKnzr8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731603AbgCPOvj (ORCPT ); Mon, 16 Mar 2020 10:51:39 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57664 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729643AbgCPOvj (ORCPT ); Mon, 16 Mar 2020 10:51:39 -0400 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=5Pc6JPsBI5ieZ88bOSZHjuuTO1w7GqYvdW+/u9rokaY=; b=rniKnzr8FV+WwFlU9cs4GroHoI SYmfPhsm2p0dt3Xo/szzderlwEaGst6Y8vt0JbtdaUxPDHGZunWZ5ORkg5n8bq7J/dYymmmGAJ/6z LaxBU8hrMymVOVqvdMFYTQ8RHL4Vab9TR53oB/fmemgIIdBZcyGveXsGGB/Z17oc4iiHoyLMOilQy f7imKB7nNfeAExiGezemLHSFPa6A+bLO80pb0H92erQCXbukkAwceA8o2IkkmJhiknzwcmzmSBqtb /CJ62MEdna28oBwICUQMWTPiumLsuh9j/dsGBnbFeGp8AAd+G9M1EbSQUhSs2fs9XYPG1P96eOlW9 s4PYFb1g==; Received: from [2001:4bb8:188:30cd:8026:d98c:a056:3e33] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDr5e-00007Y-Iu; Mon, 16 Mar 2020 14:51:38 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 08/14] xfs: move xlog_state_do_iclog_callbacks up Date: Mon, 16 Mar 2020 15:42:27 +0100 Message-Id: <20200316144233.900390-9-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200316144233.900390-1-hch@lst.de> References: <20200316144233.900390-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 xlog_state_do_iclog_callbacks a little up, to avoid the need for a forward declaration with upcoming changes. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 74 ++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index c490c5b0d8b7..c534d7007aa3 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2701,6 +2701,43 @@ xlog_state_set_callback( xlog_grant_push_ail(log, 0); } +/* + * Keep processing entries in the iclog callback list until we come around and + * it is empty. We need to atomically see that the list is empty and change the + * state to DIRTY so that we don't miss any more callbacks being added. + * + * This function is called with the icloglock held and returns with it held. We + * drop it while running callbacks, however, as holding it over thousands of + * callbacks is unnecessary and causes excessive contention if we do. + */ +static void +xlog_state_do_iclog_callbacks( + struct xlog *log, + struct xlog_in_core *iclog) + __releases(&log->l_icloglock) + __acquires(&log->l_icloglock) +{ + spin_unlock(&log->l_icloglock); + spin_lock(&iclog->ic_callback_lock); + while (!list_empty(&iclog->ic_callbacks)) { + LIST_HEAD(tmp); + + list_splice_init(&iclog->ic_callbacks, &tmp); + + spin_unlock(&iclog->ic_callback_lock); + xlog_cil_process_committed(&tmp); + spin_lock(&iclog->ic_callback_lock); + } + + /* + * Pick up the icloglock while still holding the callback lock so we + * serialise against anyone trying to add more callbacks to this iclog + * now we've finished processing. + */ + spin_lock(&log->l_icloglock); + spin_unlock(&iclog->ic_callback_lock); +} + /* * Return true if we need to stop processing, false to continue to the next * iclog. The caller will need to run callbacks if the iclog is returned in the @@ -2754,43 +2791,6 @@ xlog_state_iodone_process_iclog( } } -/* - * Keep processing entries in the iclog callback list until we come around and - * it is empty. We need to atomically see that the list is empty and change the - * state to DIRTY so that we don't miss any more callbacks being added. - * - * This function is called with the icloglock held and returns with it held. We - * drop it while running callbacks, however, as holding it over thousands of - * callbacks is unnecessary and causes excessive contention if we do. - */ -static void -xlog_state_do_iclog_callbacks( - struct xlog *log, - struct xlog_in_core *iclog) - __releases(&log->l_icloglock) - __acquires(&log->l_icloglock) -{ - spin_unlock(&log->l_icloglock); - spin_lock(&iclog->ic_callback_lock); - while (!list_empty(&iclog->ic_callbacks)) { - LIST_HEAD(tmp); - - list_splice_init(&iclog->ic_callbacks, &tmp); - - spin_unlock(&iclog->ic_callback_lock); - xlog_cil_process_committed(&tmp); - spin_lock(&iclog->ic_callback_lock); - } - - /* - * Pick up the icloglock while still holding the callback lock so we - * serialise against anyone trying to add more callbacks to this iclog - * now we've finished processing. - */ - spin_lock(&log->l_icloglock); - spin_unlock(&iclog->ic_callback_lock); -} - STATIC void xlog_state_do_callback( struct xlog *log) From patchwork Mon Mar 16 14:42:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11440523 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 1CA2192A for ; Mon, 16 Mar 2020 14:51:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F2E692075E for ; Mon, 16 Mar 2020 14:51: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="Mso31FDh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731608AbgCPOvl (ORCPT ); Mon, 16 Mar 2020 10:51:41 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57672 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729643AbgCPOvl (ORCPT ); Mon, 16 Mar 2020 10:51:41 -0400 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=wheVG5B0kOSmAUn9rE1vmn5CRhPhTt2G9LEGlfEo7C4=; b=Mso31FDhX3hiQrdKQYKwEhNuiM 9rqqoMMcmy2wNdhPvB1ezmguyIKXTfK5Mm02vEP0RGT40obiD/2Hs5XkZMb2oNmvWFdn/TOcAiFpZ qUiHcfg7KHgDk5bhl0vSpQbQ6H26b3JhVOzaxoAWYWfYX+A6Zt1YqNW0WBUk1EBncTnSnmVrRPJoM WI5WTUDuPQhZCGN3XCyPsW8B1NAninJZjLMc8+giMHomineIvMZxHgzoYPCkcpgNB0xaWyYlLDuwZ sARKwe71+w0WmHNRDxDKeECi9yeeznFWUt96ZGXbZLySYhO54fZmRt6nJSb9cNfWoLk83S8gun04P 0RkY3UfQ==; Received: from [2001:4bb8:188:30cd:8026:d98c:a056:3e33] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDr5h-00007v-0a; Mon, 16 Mar 2020 14:51:41 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 09/14] xfs: move log shut down handling out of xlog_state_iodone_process_iclog Date: Mon, 16 Mar 2020 15:42:28 +0100 Message-Id: <20200316144233.900390-10-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200316144233.900390-1-hch@lst.de> References: <20200316144233.900390-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 handling of a shut down log out of xlog_state_iodone_process_iclog and into xlog_state_do_callback so that it can be moved into an entirely separate branch. While doing so switch to using XLOG_FORCED_SHUTDOWN to check the shutdown condition global to the log instead of the per-iclog flag, and make sure the comments match reality. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_log.c | 64 ++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 38 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index c534d7007aa3..4efaa248a03d 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2746,8 +2746,7 @@ xlog_state_do_iclog_callbacks( static bool xlog_state_iodone_process_iclog( struct xlog *log, - struct xlog_in_core *iclog, - bool *ioerror) + struct xlog_in_core *iclog) { xfs_lsn_t lowest_lsn; xfs_lsn_t header_lsn; @@ -2759,15 +2758,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 @@ -2795,39 +2785,41 @@ STATIC void xlog_state_do_callback( struct xlog *log) { - struct xlog_in_core *iclog; - struct xlog_in_core *first_iclog; bool cycled_icloglock; - bool ioerror; int flushcnt = 0; int repeats = 0; + /* + * Scan all iclogs starting with the one pointed to by the log. Reset + * this starting point each time the log is unlocked (during callbacks). + * + * Keep looping through iclogs until one full pass is made without + * running any callbacks. + * + * If the log has been shut down, still perform the callbacks once per + * iclog to abort all log items, but don't bother to restart the loop + * after dropping the log as no new callbacks can show up. + */ spin_lock(&log->l_icloglock); do { - /* - * Scan all iclogs starting with the one pointed to by the - * log. Reset this starting point each time the log is - * unlocked (during callbacks). - * - * Keep looping through iclogs until one full pass is made - * without running any callbacks. - */ - first_iclog = log->l_iclog; - iclog = log->l_iclog; + struct xlog_in_core *first_iclog = log->l_iclog; + struct xlog_in_core *iclog = first_iclog; + cycled_icloglock = false; - ioerror = false; repeats++; do { - if (xlog_state_iodone_process_iclog(log, iclog, - &ioerror)) + if (XLOG_FORCED_SHUTDOWN(log)) { + xlog_state_do_iclog_callbacks(log, iclog); + wake_up_all(&iclog->ic_force_wait); + continue; + } + + if (xlog_state_iodone_process_iclog(log, iclog)) break; - if (iclog->ic_state != XLOG_STATE_CALLBACK && - iclog->ic_state != XLOG_STATE_IOERROR) { - iclog = iclog->ic_next; + if (iclog->ic_state != XLOG_STATE_CALLBACK) continue; - } /* * Running callbacks will drop the icloglock which means @@ -2835,12 +2827,8 @@ xlog_state_do_callback( */ cycled_icloglock = true; xlog_state_do_iclog_callbacks(log, iclog); - if (XLOG_FORCED_SHUTDOWN(log)) - wake_up_all(&iclog->ic_force_wait); - else - xlog_state_clean_iclog(log, iclog); - iclog = iclog->ic_next; - } while (first_iclog != iclog); + xlog_state_clean_iclog(log, iclog); + } while ((iclog = iclog->ic_next) != first_iclog); if (repeats > 5000) { flushcnt += repeats; @@ -2849,7 +2837,7 @@ xlog_state_do_callback( "%s: possible infinite loop (%d iterations)", __func__, flushcnt); } - } while (!ioerror && cycled_icloglock); + } while (cycled_icloglock); if (log->l_iclog->ic_state == XLOG_STATE_ACTIVE || log->l_iclog->ic_state == XLOG_STATE_IOERROR) From patchwork Mon Mar 16 14:42:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11440525 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 7BB4914B4 for ; Mon, 16 Mar 2020 14:51:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5CE9D20753 for ; Mon, 16 Mar 2020 14:51:44 +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="TlmZYcml" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731614AbgCPOvo (ORCPT ); Mon, 16 Mar 2020 10:51:44 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57680 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729643AbgCPOvn (ORCPT ); Mon, 16 Mar 2020 10:51:43 -0400 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=HphUtX3nCPTOD4vjmlUm+urpRMO87ozpp1r6t9zqMcY=; b=TlmZYcml/E+aLjBHm+Z1AQDvZS I6MbqxE1qI1APLrdbJyyXf2Vydz02DtVPlrMprcptvnEj3O5Y9f3Ytbot/yGk1sTlqwAAELMq6J8/ 5RGHA5OJj/MR8OtduNzyI6OowonQuOT5zlybCsNOVNFkqK9MkxPkUwHLkkw7OtztIasinTVATp+Sc 4mcYHawQ5J3nz4Z/r4o+4jBKG7Tv1u1t1nxxEqi/nYe+py2+nYCPSJbTOJ3EGoM6R25of6dNPNcl7 bRjKVQGOWLiFjnhQ0sJLVJ2cjEhLAqqQfgTzeD/sOboJXpCVqEnK7v+ktF+BvN/5DvkwjWp/tV1Tx 1R2d7fmA==; Received: from [2001:4bb8:188:30cd:8026:d98c:a056:3e33] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDr5j-00008D-C1; Mon, 16 Mar 2020 14:51:43 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 10/14] xfs: refactor xlog_state_iodone_process_iclog Date: Mon, 16 Mar 2020 15:42:29 +0100 Message-Id: <20200316144233.900390-11-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200316144233.900390-1-hch@lst.de> References: <20200316144233.900390-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 all state checks into the caller to make the loop flow more clear, and instead move the callback processing together with marking the iclog for callbacks. This also allows to easily indicate when we actually dropped the icloglock instead of assuming we do so for any iclog processed. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_log.c | 82 ++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 45 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 4efaa248a03d..a38d495b6e81 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2738,47 +2738,28 @@ xlog_state_do_iclog_callbacks( spin_unlock(&iclog->ic_callback_lock); } -/* - * Return true if we need to stop processing, false to continue to the next - * iclog. The caller will need to run callbacks if the iclog is returned in the - * XLOG_STATE_CALLBACK state. - */ static bool xlog_state_iodone_process_iclog( struct xlog *log, struct xlog_in_core *iclog) { - xfs_lsn_t lowest_lsn; - xfs_lsn_t header_lsn; + xfs_lsn_t header_lsn, lowest_lsn; - switch (iclog->ic_state) { - case XLOG_STATE_ACTIVE: - case XLOG_STATE_DIRTY: - /* - * Skip all iclogs in the ACTIVE & DIRTY states: - */ - return false; - case XLOG_STATE_DONE_SYNC: - /* - * Now that we have an iclog that is in the DONE_SYNC state, do - * one more check here to see if we have chased our tail around. - * If this is not the lowest lsn iclog, then we will leave it - * for another completion to process. - */ - header_lsn = be64_to_cpu(iclog->ic_header.h_lsn); - lowest_lsn = xlog_get_lowest_lsn(log); - if (lowest_lsn && XFS_LSN_CMP(lowest_lsn, header_lsn) < 0) - return false; - xlog_state_set_callback(log, iclog, header_lsn); + /* + * Now that we have an iclog that is in the DONE_SYNC state, do one more + * check here to see if we have chased our tail around. If this is not + * the lowest lsn iclog, then we will leave it for another completion to + * process. + */ + header_lsn = be64_to_cpu(iclog->ic_header.h_lsn); + lowest_lsn = xlog_get_lowest_lsn(log); + if (lowest_lsn && XFS_LSN_CMP(lowest_lsn, header_lsn) < 0) return false; - default: - /* - * Can only perform callbacks in order. Since this iclog is not - * in the DONE_SYNC state, we skip the rest and just try to - * clean up. - */ - return true; - } + + xlog_state_set_callback(log, iclog, header_lsn); + xlog_state_do_iclog_callbacks(log, iclog); + xlog_state_clean_iclog(log, iclog); + return true; } STATIC void @@ -2795,10 +2776,6 @@ xlog_state_do_callback( * * Keep looping through iclogs until one full pass is made without * running any callbacks. - * - * If the log has been shut down, still perform the callbacks once per - * iclog to abort all log items, but don't bother to restart the loop - * after dropping the log as no new callbacks can show up. */ spin_lock(&log->l_icloglock); do { @@ -2809,25 +2786,40 @@ xlog_state_do_callback( repeats++; do { + /* + * If the log has been shut down, still perform the + * callbacks to abort all log items to clean up any + * allocate resource, but don't bother to restart the + * loop after dropping the log as no new callbacks can + * be attached now. + */ if (XLOG_FORCED_SHUTDOWN(log)) { xlog_state_do_iclog_callbacks(log, iclog); wake_up_all(&iclog->ic_force_wait); continue; } - if (xlog_state_iodone_process_iclog(log, iclog)) - break; - - if (iclog->ic_state != XLOG_STATE_CALLBACK) + /* + * Skip all iclogs in the ACTIVE & DIRTY states: + */ + if (iclog->ic_state == XLOG_STATE_ACTIVE || + iclog->ic_state == XLOG_STATE_DIRTY) continue; + /* + * We can only perform callbacks in order. If this + * iclog is not in the DONE_SYNC state, we skip the rest + * and just try to clean up. + */ + if (iclog->ic_state != XLOG_STATE_DONE_SYNC) + break; + /* * Running callbacks will drop the icloglock which means * we'll have to run at least one more complete loop. */ - cycled_icloglock = true; - xlog_state_do_iclog_callbacks(log, iclog); - xlog_state_clean_iclog(log, iclog); + if (xlog_state_iodone_process_iclog(log, iclog)) + cycled_icloglock = true; } while ((iclog = iclog->ic_next) != first_iclog); if (repeats > 5000) { From patchwork Mon Mar 16 14:42:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11440527 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 F396414B4 for ; Mon, 16 Mar 2020 14:51:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C9E772075E for ; Mon, 16 Mar 2020 14:51:46 +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="ZLxc3UAw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731616AbgCPOvq (ORCPT ); Mon, 16 Mar 2020 10:51:46 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57692 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729643AbgCPOvq (ORCPT ); Mon, 16 Mar 2020 10:51:46 -0400 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=TLsTbknoGwww1fS9CdEYfWZmbz+yhcRDhJfnXsoxH5Q=; b=ZLxc3UAw7ZxGE4ts7ngPjmg2Wa niZitxpORo25IOO6L3BIWJRjr/VqXseqt/C+zQJBipjiZL0fexobt9+DBtWcTnX0CWMvEqNhbM2ZH N1TrkruK9u+F2gBcHDzOP7npHWluyh69TSuygEASjeuJBGcX3t8uBD5gDwji7lHi0WHBx7LJMAVzl +02jsT4iU+pb1ZLVErgdsUfRQ3Tk3pAFEyiKUdK6osMiF0ypgPmTctEx786nisZa69CkksRpYMpYZ XRlTYfLwq5p5pgEght2lK2snRtVeTasGeXCebwbUtSyj2ITZfGj0sQV1N1kFaTIFTujQZRi7Kk8eX YmNqdsjw==; Received: from [2001:4bb8:188:30cd:8026:d98c:a056:3e33] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDr5l-00008W-Ol; Mon, 16 Mar 2020 14:51:46 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 11/14] xfs: merge xlog_state_clean_iclog into xlog_state_iodone_process_iclog Date: Mon, 16 Mar 2020 15:42:30 +0100 Message-Id: <20200316144233.900390-12-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200316144233.900390-1-hch@lst.de> References: <20200316144233.900390-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 Merge xlog_state_clean_iclog into its only caller, which makes the iclog I/O completion handling a little easier to follow. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index a38d495b6e81..899c324d07e2 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2625,22 +2625,6 @@ xlog_covered_state( return XLOG_STATE_COVER_NEED; } -STATIC void -xlog_state_clean_iclog( - struct xlog *log, - struct xlog_in_core *dirty_iclog) -{ - int iclogs_changed = 0; - - dirty_iclog->ic_state = XLOG_STATE_DIRTY; - - xlog_state_activate_iclogs(log, &iclogs_changed); - wake_up_all(&dirty_iclog->ic_force_wait); - - if (iclogs_changed) - log->l_covered_state = xlog_covered_state(log, iclogs_changed); -} - STATIC xfs_lsn_t xlog_get_lowest_lsn( struct xlog *log) @@ -2744,6 +2728,7 @@ xlog_state_iodone_process_iclog( struct xlog_in_core *iclog) { xfs_lsn_t header_lsn, lowest_lsn; + int iclogs_changed = 0; /* * Now that we have an iclog that is in the DONE_SYNC state, do one more @@ -2758,7 +2743,13 @@ xlog_state_iodone_process_iclog( xlog_state_set_callback(log, iclog, header_lsn); xlog_state_do_iclog_callbacks(log, iclog); - xlog_state_clean_iclog(log, iclog); + + iclog->ic_state = XLOG_STATE_DIRTY; + xlog_state_activate_iclogs(log, &iclogs_changed); + + wake_up_all(&iclog->ic_force_wait); + if (iclogs_changed) + log->l_covered_state = xlog_covered_state(log, iclogs_changed); return true; } From patchwork Mon Mar 16 14:42: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: 11440529 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 459D492A for ; Mon, 16 Mar 2020 14:51:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 270FF20753 for ; Mon, 16 Mar 2020 14:51:49 +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="RRkjzq6c" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731619AbgCPOvs (ORCPT ); Mon, 16 Mar 2020 10:51:48 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57702 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729643AbgCPOvs (ORCPT ); Mon, 16 Mar 2020 10:51:48 -0400 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=m8lXdWGSFBGSauY28HixaPWtPr7J68VmLTEPdAH1MlY=; b=RRkjzq6cLIBp62JMZui/61nX0v JuCSLT/+Yj95UakaftDo2mwGTOQ8os6QV6wnGD3UzH5zJH/NlF/xMZ0h52kkoYqbTu8rxSdKX39Qa T+IkqOFkpkzL92id46RK/2oc1IkRzA4K8tsnT1gBksAV0bxCjeBNc8N79Qa+3Cwi+P/8gSWhP8bu1 dplz2JfROu+J2ZHbkwTeS8A3FMla7qMjduoeg5HM6O780OW8ER1+9fOlBXWHWRzdBh4+3XrAFj9Fr BuQ1deSVs1uoBf9r2PwbSGRugRMLD3E//vpXLHoHi4YrSm9VqszB+YDyX06c/dthkhsCpDkm1HXpz BzdONY3g==; Received: from [2001:4bb8:188:30cd:8026:d98c:a056:3e33] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDr5o-000090-44; Mon, 16 Mar 2020 14:51:48 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 12/14] xfs: merge xlog_state_set_callback into xlog_state_iodone_process_iclog Date: Mon, 16 Mar 2020 15:42:31 +0100 Message-Id: <20200316144233.900390-13-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200316144233.900390-1-hch@lst.de> References: <20200316144233.900390-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 Merge xlog_state_set_callback into its only caller, which makes the iclog I/O completion handling a little easier to follow. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 74 +++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 41 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 899c324d07e2..865dd1e08679 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2645,46 +2645,6 @@ xlog_get_lowest_lsn( return lowest_lsn; } -/* - * Completion of a iclog IO does not imply that a transaction has completed, as - * transactions can be large enough to span many iclogs. We cannot change the - * tail of the log half way through a transaction as this may be the only - * transaction in the log and moving the tail to point to the middle of it - * will prevent recovery from finding the start of the transaction. Hence we - * should only update the last_sync_lsn if this iclog contains transaction - * completion callbacks on it. - * - * We have to do this before we drop the icloglock to ensure we are the only one - * that can update it. - * - * If we are moving the last_sync_lsn forwards, we also need to ensure we kick - * the reservation grant head pushing. This is due to the fact that the push - * target is bound by the current last_sync_lsn value. Hence if we have a large - * amount of log space bound up in this committing transaction then the - * last_sync_lsn value may be the limiting factor preventing tail pushing from - * freeing space in the log. Hence once we've updated the last_sync_lsn we - * should push the AIL to ensure the push target (and hence the grant head) is - * no longer bound by the old log head location and can move forwards and make - * progress again. - */ -static void -xlog_state_set_callback( - struct xlog *log, - struct xlog_in_core *iclog, - xfs_lsn_t header_lsn) -{ - iclog->ic_state = XLOG_STATE_CALLBACK; - - ASSERT(XFS_LSN_CMP(atomic64_read(&log->l_last_sync_lsn), - header_lsn) <= 0); - - if (list_empty_careful(&iclog->ic_callbacks)) - return; - - atomic64_set(&log->l_last_sync_lsn, header_lsn); - xlog_grant_push_ail(log, 0); -} - /* * Keep processing entries in the iclog callback list until we come around and * it is empty. We need to atomically see that the list is empty and change the @@ -2741,7 +2701,39 @@ xlog_state_iodone_process_iclog( if (lowest_lsn && XFS_LSN_CMP(lowest_lsn, header_lsn) < 0) return false; - xlog_state_set_callback(log, iclog, header_lsn); + iclog->ic_state = XLOG_STATE_CALLBACK; + + ASSERT(XFS_LSN_CMP(atomic64_read(&log->l_last_sync_lsn), + header_lsn) <= 0); + + /* + * Completion of an iclog I/O does not imply that a transaction has + * completed, as transactions can be large enough to span multiple + * iclogs. We cannot change the tail of the log half way through a + * transaction as this may be the only transaction in the log and moving + * the tail to point to the middle of it will prevent recovery from + * finding the start of the transaction. Hence we should only update + * the last_sync_lsn if this iclog contains transaction completion + * callbacks on it. + * + * We have to do this before we drop the icloglock to ensure we are the + * only one that can update it. + * + * If we are moving last_sync_lsn forwards, we also need to ensure we + * kick the reservation grant head pushing. This is due to the fact that + * the push target is bound by the current last_sync_lsn value. If we + * have a large amount of log space bound up in this committing + * transaction then the last_sync_lsn value may be the limiting factor + * preventing tail pushing from freeing space in the log. Hence once + * we've updated the last_sync_lsn we should push the AIL to ensure the + * push target (and hence the grant head) is no longer bound by the old + * log head location and can move forwards and make progress again. + */ + if (!list_empty_careful(&iclog->ic_callbacks)) { + atomic64_set(&log->l_last_sync_lsn, header_lsn); + xlog_grant_push_ail(log, 0); + } + xlog_state_do_iclog_callbacks(log, iclog); iclog->ic_state = XLOG_STATE_DIRTY; From patchwork Mon Mar 16 14:42: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: 11440531 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 A9CBB92A for ; Mon, 16 Mar 2020 14:51:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A26620752 for ; Mon, 16 Mar 2020 14:51:51 +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="n9IlsGQI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731622AbgCPOvv (ORCPT ); Mon, 16 Mar 2020 10:51:51 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57710 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729643AbgCPOvv (ORCPT ); Mon, 16 Mar 2020 10:51:51 -0400 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=cJhcTzjYOK2sGbuw49vYU2OzoV/HWdkKuPkUYVhQP5c=; b=n9IlsGQIy3ndG3m8bxdXYgnWex VUWMtFssuC784EmMFQ8YAmQuSnC/v3XwdaRCXsulDqdh9GhqQYJaKg619zQx8V7eW9A5JjUjUz4UF AGbyoxWEkwoleo5cjKO9/foRQxmEq99x2CzShZcscgv+4O0BE0eRRRNKO6tEqziVo1/hH4RE/5cVY c5f7ioQlcaWRfydbkRCXm5lGLfHbfeI3o8jm8uVStRHlmmK7FmM2c7yqrpRdkOFcLdtz6d6+4PVsv 1zSrYBJMQsSk2vrMlsEA92gDXFtYdRG7kVSXVEN+IZzAnPl5whQzfV7UwZTn//UrAhSDruq1KmKSb ELQe6lvA==; Received: from [2001:4bb8:188:30cd:8026:d98c:a056:3e33] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDr5q-00009I-Fn; Mon, 16 Mar 2020 14:51:50 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 13/14] xfs: remove xlog_state_want_sync Date: Mon, 16 Mar 2020 15:42:32 +0100 Message-Id: <20200316144233.900390-14-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200316144233.900390-1-hch@lst.de> References: <20200316144233.900390-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 Open code the xlog_state_want_sync logic in its two callers given that this function is a trivial wrapper around xlog_state_switch_iclogs. Move the lockdep assert into xlog_state_switch_iclogs to not lose this debugging aid, and improve the comment that documents xlog_state_switch_iclogs as well. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 50 +++++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 865dd1e08679..761b138d97ec 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -62,11 +62,6 @@ xlog_state_switch_iclogs( struct xlog_in_core *iclog, int eventual_size); STATIC void -xlog_state_want_sync( - struct xlog *log, - struct xlog_in_core *iclog); - -STATIC void xlog_grant_push_ail( struct xlog *log, int need_bytes); @@ -938,7 +933,11 @@ xfs_log_write_unmount_record( spin_lock(&log->l_icloglock); iclog = log->l_iclog; atomic_inc(&iclog->ic_refcnt); - xlog_state_want_sync(log, iclog); + if (iclog->ic_state == XLOG_STATE_ACTIVE) + xlog_state_switch_iclogs(log, iclog, 0); + else + ASSERT(iclog->ic_state == XLOG_STATE_WANT_SYNC || + iclog->ic_state == XLOG_STATE_IOERROR); error = xlog_state_release_iclog(log, iclog); xlog_wait_on_iclog(iclog); @@ -2293,7 +2292,11 @@ xlog_write_copy_finish( *record_cnt = 0; *data_cnt = 0; - xlog_state_want_sync(log, iclog); + if (iclog->ic_state == XLOG_STATE_ACTIVE) + xlog_state_switch_iclogs(log, iclog, 0); + else + ASSERT(iclog->ic_state == XLOG_STATE_WANT_SYNC || + iclog->ic_state == XLOG_STATE_IOERROR); if (!commit_iclog) goto release_iclog; spin_unlock(&log->l_icloglock); @@ -3069,11 +3072,12 @@ xlog_ungrant_log_space( } /* - * This routine will mark the current iclog in the ring as WANT_SYNC - * and move the current iclog pointer to the next iclog in the ring. - * When this routine is called from xlog_state_get_iclog_space(), the - * exact size of the iclog has not yet been determined. All we know is - * that every data block. We have run out of space in this log record. + * Mark the current iclog in the ring as WANT_SYNC and move the current iclog + * pointer to the next iclog in the ring. + * + * When called from xlog_state_get_iclog_space(), the exact size of the iclog + * has not yet been determined, all we know is that we have run out of space in + * the current iclog. */ STATIC void xlog_state_switch_iclogs( @@ -3082,6 +3086,8 @@ xlog_state_switch_iclogs( int eventual_size) { ASSERT(iclog->ic_state == XLOG_STATE_ACTIVE); + assert_spin_locked(&log->l_icloglock); + if (!eventual_size) eventual_size = iclog->ic_offset; iclog->ic_state = XLOG_STATE_WANT_SYNC; @@ -3323,26 +3329,6 @@ xfs_log_force_lsn( return ret; } -/* - * Called when we want to mark the current iclog as being ready to sync to - * disk. - */ -STATIC void -xlog_state_want_sync( - struct xlog *log, - struct xlog_in_core *iclog) -{ - assert_spin_locked(&log->l_icloglock); - - if (iclog->ic_state == XLOG_STATE_ACTIVE) { - xlog_state_switch_iclogs(log, iclog, 0); - } else { - ASSERT(iclog->ic_state == XLOG_STATE_WANT_SYNC || - iclog->ic_state == XLOG_STATE_IOERROR); - } -} - - /***************************************************************************** * * TICKET functions From patchwork Mon Mar 16 14:42: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: 11440533 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 5A20992A for ; Mon, 16 Mar 2020 14:51:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3A68D20753 for ; Mon, 16 Mar 2020 14:51:54 +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="dTDvHGZk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731624AbgCPOvx (ORCPT ); Mon, 16 Mar 2020 10:51:53 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57718 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729643AbgCPOvx (ORCPT ); Mon, 16 Mar 2020 10:51:53 -0400 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=vDBgVknwEKzotQYQKtz2L5ZNTjb1b5BA3YCHlq6puwo=; b=dTDvHGZkHiDetkC5/7sp6lO1mr fUljLfQ0urIWxjy7UQUqOw6u/MbzO7v2+9gHILEmHxFNIASkpecJf3Lq1vFByc+tbzSsBgXlog15h q+mL4tzWAOXbpjHDgOaynOR3NEyHsIXz5Au6dxLM+ROkFT+6KddgB+xQ0eUgTjtbxRNSnpxkSmUPn stchXL1IhbAQEPSdafLj1246YkmHc22zZXXN85JF77iqe8FU2TSyp1N9Tkz8H+ubNgUNstEi8dqu9 CyMNCTsqWGubo20A8bwrHvuSvldPis15841vEd74TVq0AIiwpXkCVF9UYMV1TvYOcbxTX3UHi/Xeg sJSGnjUg==; Received: from [2001:4bb8:188:30cd:8026:d98c:a056:3e33] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jDr5s-00009a-SI; Mon, 16 Mar 2020 14:51:53 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: Dave Chinner Subject: [PATCH 14/14] xfs: remove XLOG_STATE_IOERROR Date: Mon, 16 Mar 2020 15:42:33 +0100 Message-Id: <20200316144233.900390-15-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200316144233.900390-1-hch@lst.de> References: <20200316144233.900390-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. As the iclog state is now not overload with the shut down information various places that check for a specific state now don't need to account for the fake IOERROR state. Signed-off-by: Christoph Hellwig --- fs/xfs/xfs_log.c | 68 +++++++++++-------------------------------- fs/xfs/xfs_log_cil.c | 2 +- fs/xfs/xfs_log_priv.h | 1 - 3 files changed, 18 insertions(+), 53 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 761b138d97ec..07023372ccbd 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -578,7 +578,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) && @@ -599,7 +599,7 @@ xfs_log_release_iclog( bool sync = false; if (atomic_dec_and_lock(&iclog->ic_refcnt, &log->l_icloglock)) { - if (iclog->ic_state != XLOG_STATE_IOERROR) + if (!XLOG_FORCED_SHUTDOWN(log)) sync = __xlog_state_release_iclog(log, iclog); spin_unlock(&log->l_icloglock); } @@ -924,7 +924,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) @@ -936,8 +936,7 @@ xfs_log_write_unmount_record( if (iclog->ic_state == XLOG_STATE_ACTIVE) xlog_state_switch_iclogs(log, iclog, 0); else - ASSERT(iclog->ic_state == XLOG_STATE_WANT_SYNC || - iclog->ic_state == XLOG_STATE_IOERROR); + ASSERT(iclog->ic_state == XLOG_STATE_WANT_SYNC); error = xlog_state_release_iclog(log, iclog); xlog_wait_on_iclog(iclog); @@ -1740,7 +1739,7 @@ xlog_write_iclog( * across the log IO to archieve that. */ down(&iclog->ic_sema); - if (unlikely(iclog->ic_state == XLOG_STATE_IOERROR)) { + if (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 @@ -2295,8 +2294,7 @@ xlog_write_copy_finish( if (iclog->ic_state == XLOG_STATE_ACTIVE) xlog_state_switch_iclogs(log, iclog, 0); else - ASSERT(iclog->ic_state == XLOG_STATE_WANT_SYNC || - iclog->ic_state == XLOG_STATE_IOERROR); + ASSERT(iclog->ic_state == XLOG_STATE_WANT_SYNC); if (!commit_iclog) goto release_iclog; spin_unlock(&log->l_icloglock); @@ -2817,8 +2815,7 @@ xlog_state_do_callback( } } while (cycled_icloglock); - if (log->l_iclog->ic_state == XLOG_STATE_ACTIVE || - log->l_iclog->ic_state == XLOG_STATE_IOERROR) + if (log->l_iclog->ic_state == XLOG_STATE_ACTIVE) wake_up_all(&log->l_flush_wait); spin_unlock(&log->l_icloglock); @@ -3167,7 +3164,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 || @@ -3240,7 +3237,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) { @@ -3691,34 +3688,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. @@ -3740,10 +3709,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 @@ -3761,10 +3728,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 @@ -3786,11 +3751,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); /* @@ -3814,7 +3781,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 adc4af336c97..a93097cf0990 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c @@ -845,7 +845,7 @@ xlog_cil_push_work( 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 2b0aec37e73e..f3f4a35ce153 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 */ }; /*