From patchwork Tue Mar 13 10:49:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10278187 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2B0A1602BD for ; Tue, 13 Mar 2018 10:50:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B13428F8D for ; Tue, 13 Mar 2018 10:50:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 079BE28F84; Tue, 13 Mar 2018 10:50:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9183728F8A for ; Tue, 13 Mar 2018 10:50:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932657AbeCMKuG (ORCPT ); Tue, 13 Mar 2018 06:50:06 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38020 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932813AbeCMKt6 (ORCPT ); Tue, 13 Mar 2018 06:49:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kFEXGtD/pWE7LfvxD3JZzUUAau452K6ijLjp34x6wAI=; b=FMmRwgmPQuMxbVNVY/KnoKwy+ qD7IL+qbp5kP1y2PvxVCX7lphBrAOd14czJRQmlSOnL3d59STgVyIMY6mIOkPIMuDotoWu7PvEXkn VPd2Gncb5xSh0p5w7t3h5UtqxvRhfQDagMtguA4dNBn+17fG7jV+00izu3E3X7Vg0Do4wZ8CHiCuJ V3bzJZzB6w522IR8vncfpB84r1577gckqaH4Kjdr/ANBh2bWFX0aUOR2az0VvfWlG3UjnGtaMdsm+ FHMvK6ar0YIhpM/OOdefe3ezMe5TQN5fqiO1DWud8PrijzScwmyKOOrQ6Ih54PpSIyD6KSm8A5OGa d3DdUsG+g==; Received: from 77.117.139.172.wireless.dyn.drei.com ([77.117.139.172] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1evhVF-0006Iv-D1 for linux-xfs@vger.kernel.org; Tue, 13 Mar 2018 10:49:57 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 8/8] xfs: unwind the try_again loop in xfs_log_force Date: Tue, 13 Mar 2018 11:49:27 +0100 Message-Id: <20180313104927.12926-9-hch@lst.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180313104927.12926-1-hch@lst.de> References: <20180313104927.12926-1-hch@lst.de> 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 X-Virus-Scanned: ClamAV using ClamSMTP Instead split out a __xfs_log_fore_lsn helper that gets called again with the already_slept flag set to true in case we had to sleep. This prepares for aio_fsync support. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_log.c | 72 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index b6c6f227b2d7..9a2008646d57 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -3395,41 +3395,17 @@ xfs_log_force( return -EIO; } -/* - * Force the in-core log to disk for a specific LSN. - * - * Find in-core log with lsn. - * If it is in the DIRTY state, just return. - * If it is in the ACTIVE state, move the in-core log into the WANT_SYNC - * state and go to sleep or return. - * If it is in any other state, go to sleep or return. - * - * Synchronous forces are implemented with a wait queue. All callers to force a - * given lsn to disk will wait on a the queue attached to the specific in-core - * log. When given in-core log finally completes its write to disk, that thread - * will wake up all threads waiting on the queue. - */ -int -xfs_log_force_lsn( +static int +__xfs_log_force_lsn( struct xfs_mount *mp, xfs_lsn_t lsn, uint flags, - int *log_flushed) + int *log_flushed, + bool already_slept) { struct xlog *log = mp->m_log; struct xlog_in_core *iclog; - int already_slept = 0; - - ASSERT(lsn != 0); - - XFS_STATS_INC(mp, xs_log_force); - trace_xfs_log_force(mp, lsn, _RET_IP_); - - lsn = xlog_cil_force_lsn(log, lsn); - if (lsn == NULLCOMMITLSN) - return 0; -try_again: spin_lock(&log->l_icloglock); iclog = log->l_iclog; if (iclog->ic_state & XLOG_STATE_IOERROR) @@ -3469,8 +3445,7 @@ xfs_log_force_lsn( xlog_wait(&iclog->ic_prev->ic_write_wait, &log->l_icloglock); - already_slept = 1; - goto try_again; + return -EAGAIN; } atomic_inc(&iclog->ic_refcnt); xlog_state_switch_iclogs(log, iclog, 0); @@ -3503,6 +3478,43 @@ xfs_log_force_lsn( return -EIO; } +/* + * Force the in-core log to disk for a specific LSN. + * + * Find in-core log with lsn. + * If it is in the DIRTY state, just return. + * If it is in the ACTIVE state, move the in-core log into the WANT_SYNC + * state and go to sleep or return. + * If it is in any other state, go to sleep or return. + * + * Synchronous forces are implemented with a wait queue. All callers to force a + * given lsn to disk will wait on a the queue attached to the specific in-core + * log. When given in-core log finally completes its write to disk, that thread + * will wake up all threads waiting on the queue. + */ +int +xfs_log_force_lsn( + struct xfs_mount *mp, + xfs_lsn_t lsn, + uint flags, + int *log_flushed) +{ + int ret; + ASSERT(lsn != 0); + + XFS_STATS_INC(mp, xs_log_force); + trace_xfs_log_force(mp, lsn, _RET_IP_); + + lsn = xlog_cil_force_lsn(mp->m_log, lsn); + if (lsn == NULLCOMMITLSN) + return 0; + + ret = __xfs_log_force_lsn(mp, lsn, flags, log_flushed, false); + if (ret == -EAGAIN) + ret = __xfs_log_force_lsn(mp, lsn, flags, log_flushed, true); + return ret; +} + /* * Called when we want to mark the current iclog as being ready to sync to * disk.