From patchwork Wed Mar 4 07:53:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 11419541 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 9D187930 for ; Wed, 4 Mar 2020 07:54:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 882482166E for ; Wed, 4 Mar 2020 07:54:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725271AbgCDHyI (ORCPT ); Wed, 4 Mar 2020 02:54:08 -0500 Received: from mail104.syd.optusnet.com.au ([211.29.132.246]:43854 "EHLO mail104.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728530AbgCDHyI (ORCPT ); Wed, 4 Mar 2020 02:54:08 -0500 Received: from dread.disaster.area (pa49-195-202-68.pa.nsw.optusnet.com.au [49.195.202.68]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id 3FE057EA120 for ; Wed, 4 Mar 2020 18:54:03 +1100 (AEDT) Received: from discord.disaster.area ([192.168.253.110]) by dread.disaster.area with esmtp (Exim 4.92.3) (envelope-from ) id 1j9Oqv-0007lQ-QB for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:01 +1100 Received: from dave by discord.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1j9Oqv-0005cT-MO for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:01 +1100 From: Dave Chinner To: linux-xfs@vger.kernel.org Subject: [PATCH 01/11] xfs: don't try to write a start record into every iclog Date: Wed, 4 Mar 2020 18:53:51 +1100 Message-Id: <20200304075401.21558-2-david@fromorbit.com> X-Mailer: git-send-email 2.24.0.rc0 In-Reply-To: <20200304075401.21558-1-david@fromorbit.com> References: <20200304075401.21558-1-david@fromorbit.com> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=W5xGqiek c=1 sm=1 tr=0 a=mqTaRPt+QsUAtUurwE173Q==:117 a=mqTaRPt+QsUAtUurwE173Q==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=SS2py6AdgQ4A:10 a=20KFwNOVAAAA:8 a=Go1iWFsYnf0d6w-0-8gA:9 a=l7ea9jAn6xmV8bzw:21 a=zP2MfwOD-wjrT4dR:21 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner The xlog_write() function iterates over iclogs until it completes writing all the log vectors passed in. The ticket tracks whether a start record has been written or not, so only the first iclog gets a start record. We only ever pass single use tickets to xlog_write() we only ever need to write a start record once per xlog_write() call. Hence we don't need to store whether we should write a start record in the ticket as the callers provide all the information we need to determine if a start record should be written. For the moment, we have to ensure that we clear the XLOG_TIC_INITED appropriately so the code in xfs_log_done() still works correctly for committing transactions. Signed-off-by: Dave Chinner --- fs/xfs/xfs_log.c | 68 +++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index f6006d94a581..5b0568a86c07 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2148,23 +2148,21 @@ xlog_print_trans( } /* - * Calculate the potential space needed by the log vector. Each region gets - * its own xlog_op_header_t and may need to be double word aligned. + * Calculate the potential space needed by the log vector. We may need a + * start record, and each region gets its own xlog_op_header_t and may need to + * be double word aligned. */ static int xlog_write_calc_vec_length( struct xlog_ticket *ticket, - struct xfs_log_vec *log_vector) + struct xfs_log_vec *log_vector, + bool need_start_rec) { struct xfs_log_vec *lv; - int headers = 0; + int headers = need_start_rec ? 1 : 0; int len = 0; int i; - /* acct for start rec of xact */ - if (ticket->t_flags & XLOG_TIC_INITED) - headers++; - for (lv = log_vector; lv; lv = lv->lv_next) { /* we don't write ordered log vectors */ if (lv->lv_buf_len == XFS_LOG_VEC_ORDERED) @@ -2186,27 +2184,16 @@ xlog_write_calc_vec_length( return len; } -/* - * If first write for transaction, insert start record We can't be trying to - * commit if we are inited. We can't have any "partial_copy" if we are inited. - */ -static int +static void xlog_write_start_rec( struct xlog_op_header *ophdr, struct xlog_ticket *ticket) { - if (!(ticket->t_flags & XLOG_TIC_INITED)) - return 0; - ophdr->oh_tid = cpu_to_be32(ticket->t_tid); ophdr->oh_clientid = ticket->t_clientid; ophdr->oh_len = 0; ophdr->oh_flags = XLOG_START_TRANS; ophdr->oh_res2 = 0; - - ticket->t_flags &= ~XLOG_TIC_INITED; - - return sizeof(struct xlog_op_header); } static xlog_op_header_t * @@ -2404,25 +2391,29 @@ xlog_write( int record_cnt = 0; int data_cnt = 0; int error = 0; + int start_rec_size = sizeof(struct xlog_op_header); *start_lsn = 0; - len = xlog_write_calc_vec_length(ticket, log_vector); /* * Region headers and bytes are already accounted for. * We only need to take into account start records and * split regions in this function. */ - if (ticket->t_flags & XLOG_TIC_INITED) + if (ticket->t_flags & XLOG_TIC_INITED) { ticket->t_curr_res -= sizeof(xlog_op_header_t); + ticket->t_flags &= ~XLOG_TIC_INITED; + } /* * Commit record headers need to be accounted for. These * come in as separate writes so are easy to detect. */ - if (flags & (XLOG_COMMIT_TRANS | XLOG_UNMOUNT_TRANS)) + if (flags & (XLOG_COMMIT_TRANS | XLOG_UNMOUNT_TRANS)) { ticket->t_curr_res -= sizeof(xlog_op_header_t); + start_rec_size = 0; + } if (ticket->t_curr_res < 0) { xfs_alert_tag(log->l_mp, XFS_PTAG_LOGRES, @@ -2431,6 +2422,8 @@ xlog_write( xfs_force_shutdown(log->l_mp, SHUTDOWN_LOG_IO_ERROR); } + len = xlog_write_calc_vec_length(ticket, log_vector, start_rec_size); + index = 0; lv = log_vector; vecp = lv->lv_iovecp; @@ -2446,9 +2439,20 @@ xlog_write( ASSERT(log_offset <= iclog->ic_size - 1); ptr = iclog->ic_datap + log_offset; - /* start_lsn is the first lsn written to. That's all we need. */ + /* + * Before we start formatting log vectors, we need to write a + * start record and record the lsn of the iclog that we write + * the start record into. Only do this for the first iclog we + * write to. + */ if (!*start_lsn) *start_lsn = be64_to_cpu(iclog->ic_header.h_lsn); + if (start_rec_size) { + xlog_write_start_rec(ptr, ticket); + xlog_write_adv_cnt(&ptr, &len, &log_offset, + start_rec_size); + record_cnt++; + } /* * This loop writes out as many regions as can fit in the amount @@ -2457,7 +2461,6 @@ xlog_write( while (lv && (!lv->lv_niovecs || index < lv->lv_niovecs)) { struct xfs_log_iovec *reg; struct xlog_op_header *ophdr; - int start_rec_copy; int copy_len; int copy_off; bool ordered = false; @@ -2473,13 +2476,6 @@ xlog_write( ASSERT(reg->i_len % sizeof(int32_t) == 0); ASSERT((unsigned long)ptr % sizeof(int32_t) == 0); - start_rec_copy = xlog_write_start_rec(ptr, ticket); - if (start_rec_copy) { - record_cnt++; - xlog_write_adv_cnt(&ptr, &len, &log_offset, - start_rec_copy); - } - ophdr = xlog_write_setup_ophdr(log, ptr, ticket, flags); if (!ophdr) return -EIO; @@ -2509,10 +2505,15 @@ xlog_write( xlog_write_adv_cnt(&ptr, &len, &log_offset, copy_len); } - copy_len += start_rec_copy + sizeof(xlog_op_header_t); + copy_len += sizeof(xlog_op_header_t); record_cnt++; data_cnt += contwr ? copy_len : 0; + if (start_rec_size) { + copy_len += start_rec_size; + start_rec_size = 0; + } + error = xlog_write_copy_finish(log, iclog, flags, &record_cnt, &data_cnt, &partial_copy, @@ -2550,6 +2551,7 @@ xlog_write( break; } } + start_rec_size = 0; } ASSERT(len == 0); From patchwork Wed Mar 4 07:53:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 11419527 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 38FD817E0 for ; Wed, 4 Mar 2020 07:54:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2431E215A4 for ; Wed, 4 Mar 2020 07:54:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725283AbgCDHyF (ORCPT ); Wed, 4 Mar 2020 02:54:05 -0500 Received: from mail105.syd.optusnet.com.au ([211.29.132.249]:33739 "EHLO mail105.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726137AbgCDHyF (ORCPT ); Wed, 4 Mar 2020 02:54:05 -0500 Received: from dread.disaster.area (pa49-195-202-68.pa.nsw.optusnet.com.au [49.195.202.68]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 0D9B43A278E for ; Wed, 4 Mar 2020 18:54:03 +1100 (AEDT) Received: from discord.disaster.area ([192.168.253.110]) by dread.disaster.area with esmtp (Exim 4.92.3) (envelope-from ) id 1j9Oqv-0007lR-RJ for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:01 +1100 Received: from dave by discord.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1j9Oqv-0005cW-Ou for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:01 +1100 From: Dave Chinner To: linux-xfs@vger.kernel.org Subject: [PATCH 02/11] xfs: re-order initial space accounting checks in xlog_write Date: Wed, 4 Mar 2020 18:53:52 +1100 Message-Id: <20200304075401.21558-3-david@fromorbit.com> X-Mailer: git-send-email 2.24.0.rc0 In-Reply-To: <20200304075401.21558-1-david@fromorbit.com> References: <20200304075401.21558-1-david@fromorbit.com> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=X6os11be c=1 sm=1 tr=0 a=mqTaRPt+QsUAtUurwE173Q==:117 a=mqTaRPt+QsUAtUurwE173Q==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=SS2py6AdgQ4A:10 a=20KFwNOVAAAA:8 a=0r_Sge7i62rNiU-H2-0A:9 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Commit and unmount records records do not need start records to be written, so rearrange the logic in xlog_write() to remove the need to check for XLOG_TIC_INITED to determine if we should account for the space used by a start record. Signed-off-by: Dave Chinner Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 5b0568a86c07..d6c42954b70c 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2381,10 +2381,10 @@ xlog_write( uint flags) { struct xlog_in_core *iclog = NULL; - struct xfs_log_iovec *vecp; - struct xfs_log_vec *lv; + struct xfs_log_vec *lv = log_vector; + struct xfs_log_iovec *vecp = lv->lv_iovecp; + int index = 0; int len; - int index; int partial_copy = 0; int partial_copy_len = 0; int contwr = 0; @@ -2393,27 +2393,17 @@ xlog_write( int error = 0; int start_rec_size = sizeof(struct xlog_op_header); - *start_lsn = 0; - - /* - * Region headers and bytes are already accounted for. - * We only need to take into account start records and - * split regions in this function. + * If this is a commit or unmount transaction, we don't need a start + * record to be written. We do, however, have to account for the + * commit or unmount header that gets written. Hence we always have + * to account for an extra xlog_op_header here. */ - if (ticket->t_flags & XLOG_TIC_INITED) { - ticket->t_curr_res -= sizeof(xlog_op_header_t); + ticket->t_curr_res -= sizeof(xlog_op_header_t); + if (ticket->t_flags & XLOG_TIC_INITED) ticket->t_flags &= ~XLOG_TIC_INITED; - } - - /* - * Commit record headers need to be accounted for. These - * come in as separate writes so are easy to detect. - */ - if (flags & (XLOG_COMMIT_TRANS | XLOG_UNMOUNT_TRANS)) { - ticket->t_curr_res -= sizeof(xlog_op_header_t); + if (flags & (XLOG_COMMIT_TRANS | XLOG_UNMOUNT_TRANS)) start_rec_size = 0; - } if (ticket->t_curr_res < 0) { xfs_alert_tag(log->l_mp, XFS_PTAG_LOGRES, @@ -2423,10 +2413,7 @@ xlog_write( } len = xlog_write_calc_vec_length(ticket, log_vector, start_rec_size); - - index = 0; - lv = log_vector; - vecp = lv->lv_iovecp; + *start_lsn = 0; while (lv && (!lv->lv_niovecs || index < lv->lv_niovecs)) { void *ptr; int log_offset; From patchwork Wed Mar 4 07:53:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 11419529 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 1F82E930 for ; Wed, 4 Mar 2020 07:54:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 02B20215A4 for ; Wed, 4 Mar 2020 07:54:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728554AbgCDHyG (ORCPT ); Wed, 4 Mar 2020 02:54:06 -0500 Received: from mail105.syd.optusnet.com.au ([211.29.132.249]:33749 "EHLO mail105.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726275AbgCDHyG (ORCPT ); Wed, 4 Mar 2020 02:54:06 -0500 Received: from dread.disaster.area (pa49-195-202-68.pa.nsw.optusnet.com.au [49.195.202.68]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 134FD3A27B1 for ; Wed, 4 Mar 2020 18:54:03 +1100 (AEDT) Received: from discord.disaster.area ([192.168.253.110]) by dread.disaster.area with esmtp (Exim 4.92.3) (envelope-from ) id 1j9Oqv-0007lU-Sj for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:01 +1100 Received: from dave by discord.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1j9Oqv-0005cY-Q6 for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:01 +1100 From: Dave Chinner To: linux-xfs@vger.kernel.org Subject: [PATCH 03/11] xfs: refactor and split xfs_log_done() Date: Wed, 4 Mar 2020 18:53:53 +1100 Message-Id: <20200304075401.21558-4-david@fromorbit.com> X-Mailer: git-send-email 2.24.0.rc0 In-Reply-To: <20200304075401.21558-1-david@fromorbit.com> References: <20200304075401.21558-1-david@fromorbit.com> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=W5xGqiek c=1 sm=1 tr=0 a=mqTaRPt+QsUAtUurwE173Q==:117 a=mqTaRPt+QsUAtUurwE173Q==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=SS2py6AdgQ4A:10 a=20KFwNOVAAAA:8 a=VfLmM3KQg9FqGSJa3SoA:9 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner xfs_log_done() does two separate things. Firstly, it triggers commit records to be written for permanent transactions, and secondly it releases or regrants transaction reservation space. Since delayed logging was introduced, transactions no longer write directly to the log, hence they never have the XLOG_TIC_INITED flag cleared on them. Hence transactions never write commit records to the log and only need to modify reservation space. Split up xfs_log_done into two parts, and only call the parts of the operation needed for the context xfs_log_done() is currently being called from. Signed-off-by: Dave Chinner --- fs/xfs/xfs_log.c | 64 ++++++++++++++----------------------------- fs/xfs/xfs_log.h | 4 --- fs/xfs/xfs_log_cil.c | 13 +++++---- fs/xfs/xfs_log_priv.h | 16 +++++------ fs/xfs/xfs_trans.c | 24 ++++++++-------- 5 files changed, 47 insertions(+), 74 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index d6c42954b70c..702b38e4db6e 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -493,62 +493,40 @@ xfs_log_reserve( */ /* - * This routine is called when a user of a log manager ticket is done with - * the reservation. If the ticket was ever used, then a commit record for - * the associated transaction is written out as a log operation header with - * no data. The flag XLOG_TIC_INITED is set when the first write occurs with - * a given ticket. If the ticket was one with a permanent reservation, then - * a few operations are done differently. Permanent reservation tickets by - * default don't release the reservation. They just commit the current - * transaction with the belief that the reservation is still needed. A flag - * must be passed in before permanent reservations are actually released. - * When these type of tickets are not released, they need to be set into - * the inited state again. By doing this, a start record will be written - * out when the next write occurs. + * Write a commit record to the log to close off a running log write. */ -xfs_lsn_t -xfs_log_done( - struct xfs_mount *mp, +int +xlog_write_done( + struct xlog *log, struct xlog_ticket *ticket, struct xlog_in_core **iclog, - bool regrant) + xfs_lsn_t *lsn) { - struct xlog *log = mp->m_log; - xfs_lsn_t lsn = 0; - - if (XLOG_FORCED_SHUTDOWN(log) || - /* - * If nothing was ever written, don't write out commit record. - * If we get an error, just continue and give back the log ticket. - */ - (((ticket->t_flags & XLOG_TIC_INITED) == 0) && - (xlog_commit_record(log, ticket, iclog, &lsn)))) { - lsn = (xfs_lsn_t) -1; - regrant = false; - } + if (XLOG_FORCED_SHUTDOWN(log)) + return -EIO; + return xlog_commit_record(log, ticket, iclog, lsn); +} +/* + * Release or regrant the ticket reservation now the transaction is done with + * it depending on caller context. Rolling transactions need the ticket + * regranted, otherwise we release it completely. + */ +void +xlog_ticket_done( + struct xlog *log, + struct xlog_ticket *ticket, + bool regrant) +{ if (!regrant) { trace_xfs_log_done_nonperm(log, ticket); - - /* - * Release ticket if not permanent reservation or a specific - * request has been made to release a permanent reservation. - */ xlog_ungrant_log_space(log, ticket); } else { trace_xfs_log_done_perm(log, ticket); - xlog_regrant_reserve_log_space(log, ticket); - /* If this ticket was a permanent reservation and we aren't - * trying to release it, reset the inited flags; so next time - * we write, a start record will be written out. - */ - ticket->t_flags |= XLOG_TIC_INITED; } - xfs_log_ticket_put(ticket); - return lsn; } static bool @@ -2400,8 +2378,6 @@ xlog_write( * to account for an extra xlog_op_header here. */ ticket->t_curr_res -= sizeof(xlog_op_header_t); - if (ticket->t_flags & XLOG_TIC_INITED) - ticket->t_flags &= ~XLOG_TIC_INITED; if (flags & (XLOG_COMMIT_TRANS | XLOG_UNMOUNT_TRANS)) start_rec_size = 0; diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h index 84e06805160f..85f8d0966811 100644 --- a/fs/xfs/xfs_log.h +++ b/fs/xfs/xfs_log.h @@ -105,10 +105,6 @@ struct xfs_log_item; struct xfs_item_ops; struct xfs_trans; -xfs_lsn_t xfs_log_done(struct xfs_mount *mp, - struct xlog_ticket *ticket, - struct xlog_in_core **iclog, - bool regrant); int xfs_log_force(struct xfs_mount *mp, uint flags); int xfs_log_force_lsn(struct xfs_mount *mp, xfs_lsn_t lsn, uint flags, int *log_forced); diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index 48435cf2aa16..255065d276fc 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c @@ -841,10 +841,11 @@ xlog_cil_push( } spin_unlock(&cil->xc_push_lock); - /* xfs_log_done always frees the ticket on error. */ - commit_lsn = xfs_log_done(log->l_mp, tic, &commit_iclog, false); - if (commit_lsn == -1) - goto out_abort; + error = xlog_write_done(log, tic, &commit_iclog, &commit_lsn); + if (error) + goto out_abort_free_ticket; + + xlog_ticket_done(log, tic, false); spin_lock(&commit_iclog->ic_callback_lock); if (commit_iclog->ic_state == XLOG_STATE_IOERROR) { @@ -876,7 +877,7 @@ xlog_cil_push( return 0; out_abort_free_ticket: - xfs_log_ticket_put(tic); + xlog_ticket_done(log, tic, false); out_abort: xlog_cil_committed(ctx, true); return -EIO; @@ -1017,7 +1018,7 @@ xfs_log_commit_cil( if (commit_lsn) *commit_lsn = xc_commit_lsn; - xfs_log_done(mp, tp->t_ticket, NULL, regrant); + xlog_ticket_done(log, tp->t_ticket, regrant); tp->t_ticket = NULL; xfs_trans_unreserve_and_mod_sb(tp); diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index b192c5a9f9fd..081d4c6de2c8 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h @@ -438,14 +438,14 @@ xlog_write_adv_cnt(void **ptr, int *len, int *off, size_t bytes) void xlog_print_tic_res(struct xfs_mount *mp, struct xlog_ticket *ticket); void xlog_print_trans(struct xfs_trans *); -int -xlog_write( - struct xlog *log, - struct xfs_log_vec *log_vector, - struct xlog_ticket *tic, - xfs_lsn_t *start_lsn, - struct xlog_in_core **commit_iclog, - uint flags); + +int xlog_write(struct xlog *log, struct xfs_log_vec *log_vector, + struct xlog_ticket *tic, xfs_lsn_t *start_lsn, + struct xlog_in_core **commit_iclog, uint flags); +int xlog_write_done(struct xlog *log, struct xlog_ticket *ticket, + struct xlog_in_core **iclog, xfs_lsn_t *lsn); +void xlog_ticket_done(struct xlog *log, struct xlog_ticket *ticket, + bool regrant); /* * When we crack an atomic LSN, we sample it first so that the value will not diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 3b208f9a865c..85ea3727878b 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -9,6 +9,7 @@ #include "xfs_shared.h" #include "xfs_format.h" #include "xfs_log_format.h" +#include "xfs_log_priv.h" #include "xfs_trans_resv.h" #include "xfs_mount.h" #include "xfs_extent_busy.h" @@ -150,8 +151,9 @@ xfs_trans_reserve( uint blocks, uint rtextents) { - int error = 0; - bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; + struct xfs_mount *mp = tp->t_mountp; + int error = 0; + bool rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; /* Mark this thread as being in a transaction */ current_set_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); @@ -162,7 +164,7 @@ xfs_trans_reserve( * fail if the count would go below zero. */ if (blocks > 0) { - error = xfs_mod_fdblocks(tp->t_mountp, -((int64_t)blocks), rsvd); + error = xfs_mod_fdblocks(mp, -((int64_t)blocks), rsvd); if (error != 0) { current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); return -ENOSPC; @@ -191,9 +193,9 @@ xfs_trans_reserve( if (tp->t_ticket != NULL) { ASSERT(resp->tr_logflags & XFS_TRANS_PERM_LOG_RES); - error = xfs_log_regrant(tp->t_mountp, tp->t_ticket); + error = xfs_log_regrant(mp, tp->t_ticket); } else { - error = xfs_log_reserve(tp->t_mountp, + error = xfs_log_reserve(mp, resp->tr_logres, resp->tr_logcount, &tp->t_ticket, XFS_TRANSACTION, @@ -213,7 +215,7 @@ xfs_trans_reserve( * fail if the count would go below zero. */ if (rtextents > 0) { - error = xfs_mod_frextents(tp->t_mountp, -((int64_t)rtextents)); + error = xfs_mod_frextents(mp, -((int64_t)rtextents)); if (error) { error = -ENOSPC; goto undo_log; @@ -229,7 +231,7 @@ xfs_trans_reserve( */ undo_log: if (resp->tr_logres > 0) { - xfs_log_done(tp->t_mountp, tp->t_ticket, NULL, false); + xlog_ticket_done(mp->m_log, tp->t_ticket, false); tp->t_ticket = NULL; tp->t_log_res = 0; tp->t_flags &= ~XFS_TRANS_PERM_LOG_RES; @@ -237,7 +239,7 @@ xfs_trans_reserve( undo_blocks: if (blocks > 0) { - xfs_mod_fdblocks(tp->t_mountp, (int64_t)blocks, rsvd); + xfs_mod_fdblocks(mp, (int64_t)blocks, rsvd); tp->t_blk_res = 0; } @@ -999,9 +1001,7 @@ __xfs_trans_commit( */ xfs_trans_unreserve_and_mod_dquots(tp); if (tp->t_ticket) { - commit_lsn = xfs_log_done(mp, tp->t_ticket, NULL, regrant); - if (commit_lsn == -1 && !error) - error = -EIO; + xlog_ticket_done(mp->m_log, tp->t_ticket, regrant); tp->t_ticket = NULL; } current_restore_flags_nested(&tp->t_pflags, PF_MEMALLOC_NOFS); @@ -1060,7 +1060,7 @@ xfs_trans_cancel( xfs_trans_unreserve_and_mod_dquots(tp); if (tp->t_ticket) { - xfs_log_done(mp, tp->t_ticket, NULL, false); + xlog_ticket_done(mp->m_log, tp->t_ticket, false); tp->t_ticket = NULL; } From patchwork Wed Mar 4 07:53:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 11419543 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 21FB41820 for ; Wed, 4 Mar 2020 07:54:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0C75C2166E for ; Wed, 4 Mar 2020 07:54:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728530AbgCDHyI (ORCPT ); Wed, 4 Mar 2020 02:54:08 -0500 Received: from mail105.syd.optusnet.com.au ([211.29.132.249]:33971 "EHLO mail105.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728539AbgCDHyI (ORCPT ); Wed, 4 Mar 2020 02:54:08 -0500 Received: from dread.disaster.area (pa49-195-202-68.pa.nsw.optusnet.com.au [49.195.202.68]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 0DA8F3A29F6 for ; Wed, 4 Mar 2020 18:54:02 +1100 (AEDT) Received: from discord.disaster.area ([192.168.253.110]) by dread.disaster.area with esmtp (Exim 4.92.3) (envelope-from ) id 1j9Oqv-0007lV-Tq for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:01 +1100 Received: from dave by discord.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1j9Oqv-0005cc-RY for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:01 +1100 From: Dave Chinner To: linux-xfs@vger.kernel.org Subject: [PATCH 04/11] xfs: merge xlog_commit_record with xlog_write_done() Date: Wed, 4 Mar 2020 18:53:54 +1100 Message-Id: <20200304075401.21558-5-david@fromorbit.com> X-Mailer: git-send-email 2.24.0.rc0 In-Reply-To: <20200304075401.21558-1-david@fromorbit.com> References: <20200304075401.21558-1-david@fromorbit.com> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=LYdCFQXi c=1 sm=1 tr=0 a=mqTaRPt+QsUAtUurwE173Q==:117 a=mqTaRPt+QsUAtUurwE173Q==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=SS2py6AdgQ4A:10 a=20KFwNOVAAAA:8 a=Ogm-NnU_ru6a6b32IXgA:9 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner xlog_write_done() is just a thin wrapper around xlog_commit_record(), so they can be merged together easily. Convert all the xlog_commit_record() callers to use xlog_write_done() and merge the implementations. Signed-off-by: Dave Chinner Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 60 +++++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 41 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 702b38e4db6e..100eeaed4a7d 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -24,13 +24,6 @@ kmem_zone_t *xfs_log_ticket_zone; /* Local miscellaneous function prototypes */ -STATIC int -xlog_commit_record( - struct xlog *log, - struct xlog_ticket *ticket, - struct xlog_in_core **iclog, - xfs_lsn_t *commitlsnp); - STATIC struct xlog * xlog_alloc_log( struct xfs_mount *mp, @@ -493,7 +486,8 @@ xfs_log_reserve( */ /* - * Write a commit record to the log to close off a running log write. + * Write out the commit record of a transaction associated with the given + * ticket to close off a running log write. Return the lsn of the commit record. */ int xlog_write_done( @@ -502,10 +496,26 @@ xlog_write_done( struct xlog_in_core **iclog, xfs_lsn_t *lsn) { + struct xfs_log_iovec reg = { + .i_addr = NULL, + .i_len = 0, + .i_type = XLOG_REG_TYPE_COMMIT, + }; + struct xfs_log_vec vec = { + .lv_niovecs = 1, + .lv_iovecp = ®, + }; + int error; + + ASSERT_ALWAYS(iclog); + if (XLOG_FORCED_SHUTDOWN(log)) return -EIO; - return xlog_commit_record(log, ticket, iclog, lsn); + error = xlog_write(log, &vec, ticket, lsn, iclog, XLOG_COMMIT_TRANS); + if (error) + xfs_force_shutdown(log->l_mp, SHUTDOWN_LOG_IO_ERROR); + return error; } /* @@ -1529,38 +1539,6 @@ xlog_alloc_log( return ERR_PTR(error); } /* xlog_alloc_log */ - -/* - * Write out the commit record of a transaction associated with the given - * ticket. Return the lsn of the commit record. - */ -STATIC int -xlog_commit_record( - struct xlog *log, - struct xlog_ticket *ticket, - struct xlog_in_core **iclog, - xfs_lsn_t *commitlsnp) -{ - struct xfs_mount *mp = log->l_mp; - int error; - struct xfs_log_iovec reg = { - .i_addr = NULL, - .i_len = 0, - .i_type = XLOG_REG_TYPE_COMMIT, - }; - struct xfs_log_vec vec = { - .lv_niovecs = 1, - .lv_iovecp = ®, - }; - - ASSERT_ALWAYS(iclog); - error = xlog_write(log, &vec, ticket, commitlsnp, iclog, - XLOG_COMMIT_TRANS); - if (error) - xfs_force_shutdown(mp, SHUTDOWN_LOG_IO_ERROR); - return error; -} - /* * Push on the buffer cache code if we ever use more than 75% of the on-disk * log space. This code pushes on the lsn which would supposedly free up From patchwork Wed Mar 4 07:53:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 11419533 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 20BCC930 for ; Wed, 4 Mar 2020 07:54:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0A877215A4 for ; Wed, 4 Mar 2020 07:54:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728569AbgCDHyH (ORCPT ); Wed, 4 Mar 2020 02:54:07 -0500 Received: from mail104.syd.optusnet.com.au ([211.29.132.246]:43852 "EHLO mail104.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726137AbgCDHyH (ORCPT ); Wed, 4 Mar 2020 02:54:07 -0500 Received: from dread.disaster.area (pa49-195-202-68.pa.nsw.optusnet.com.au [49.195.202.68]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id 8CB0D7EA137 for ; Wed, 4 Mar 2020 18:54:03 +1100 (AEDT) Received: from discord.disaster.area ([192.168.253.110]) by dread.disaster.area with esmtp (Exim 4.92.3) (envelope-from ) id 1j9Oqv-0007lY-VI for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:01 +1100 Received: from dave by discord.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1j9Oqv-0005ce-Sk for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:01 +1100 From: Dave Chinner To: linux-xfs@vger.kernel.org Subject: [PATCH 05/11] xfs: factor out unmount record writing Date: Wed, 4 Mar 2020 18:53:55 +1100 Message-Id: <20200304075401.21558-6-david@fromorbit.com> X-Mailer: git-send-email 2.24.0.rc0 In-Reply-To: <20200304075401.21558-1-david@fromorbit.com> References: <20200304075401.21558-1-david@fromorbit.com> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=X6os11be c=1 sm=1 tr=0 a=mqTaRPt+QsUAtUurwE173Q==:117 a=mqTaRPt+QsUAtUurwE173Q==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=SS2py6AdgQ4A:10 a=20KFwNOVAAAA:8 a=RJ33b4CtU-wh5j9jekAA:9 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Separate out the unmount record writing from the rest of the ticket and log state futzing necessary to make it work. This is a no-op, just makes the code cleaner and places the unmount record formatting and writing alongside the commit record formatting and writing code. We can also get rid of the ticket flag clearing before the xlog_write() call because it no longer cares about the state of XLOG_TIC_INITED. Signed-off-by: Dave Chinner Reviewed-by: Christoph Hellwig Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 59 ++++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 100eeaed4a7d..2e9f3baa7cc8 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -485,6 +485,38 @@ xfs_log_reserve( * marked as with WANT_SYNC. */ +/* + * Write out an unmount record using the ticket provided. We have to account for + * the data space used in the unmount ticket as this write is not done from a + * transaction context that has already done the accounting for us. + */ +static int +xlog_write_unmount( + struct xlog *log, + struct xlog_ticket *ticket, + xfs_lsn_t *lsn, + uint flags) +{ + /* the data section must be 32 bit size aligned */ + struct xfs_unmount_log_format magic = { + .magic = XLOG_UNMOUNT_TYPE, + }; + struct xfs_log_iovec reg = { + .i_addr = &magic, + .i_len = sizeof(magic), + .i_type = XLOG_REG_TYPE_UNMOUNT, + }; + struct xfs_log_vec vec = { + .lv_niovecs = 1, + .lv_iovecp = ®, + }; + + /* account for space used by record data */ + ticket->t_curr_res -= sizeof(magic); + + return xlog_write(log, &vec, ticket, lsn, NULL, flags); +} + /* * Write out the commit record of a transaction associated with the given * ticket to close off a running log write. Return the lsn of the commit record. @@ -843,31 +875,13 @@ xfs_log_mount_cancel( } /* - * Final log writes as part of unmount. - * - * Mark the filesystem clean as unmount happens. Note that during relocation - * this routine needs to be executed as part of source-bag while the - * deallocation must not be done until source-end. + * Mark the filesystem clean by writing an unmount record to the head of the + * log. */ - -/* Actually write the unmount record to disk. */ static void xfs_log_write_unmount_record( struct xfs_mount *mp) { - /* the data section must be 32 bit size aligned */ - struct xfs_unmount_log_format magic = { - .magic = XLOG_UNMOUNT_TYPE, - }; - struct xfs_log_iovec reg = { - .i_addr = &magic, - .i_len = sizeof(magic), - .i_type = XLOG_REG_TYPE_UNMOUNT, - }; - struct xfs_log_vec vec = { - .lv_niovecs = 1, - .lv_iovecp = ®, - }; struct xlog *log = mp->m_log; struct xlog_in_core *iclog; struct xlog_ticket *tic = NULL; @@ -892,10 +906,7 @@ xfs_log_write_unmount_record( flags &= ~XLOG_UNMOUNT_TRANS; } - /* remove inited flag, and account for space used */ - tic->t_flags = 0; - tic->t_curr_res -= sizeof(magic); - error = xlog_write(log, &vec, tic, &lsn, NULL, flags); + error = xlog_write_unmount(log, tic, &lsn, flags); /* * At this point, we're umounting anyway, so there's no point in * transitioning log state to IOERROR. Just continue... From patchwork Wed Mar 4 07:53:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 11419535 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 6E71D138D for ; Wed, 4 Mar 2020 07:54:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5930F215A4 for ; Wed, 4 Mar 2020 07:54:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726137AbgCDHyH (ORCPT ); Wed, 4 Mar 2020 02:54:07 -0500 Received: from mail105.syd.optusnet.com.au ([211.29.132.249]:34029 "EHLO mail105.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728557AbgCDHyH (ORCPT ); Wed, 4 Mar 2020 02:54:07 -0500 Received: from dread.disaster.area (pa49-195-202-68.pa.nsw.optusnet.com.au [49.195.202.68]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 244B13A2A29 for ; Wed, 4 Mar 2020 18:54:03 +1100 (AEDT) Received: from discord.disaster.area ([192.168.253.110]) by dread.disaster.area with esmtp (Exim 4.92.3) (envelope-from ) id 1j9Oqw-0007la-0T for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:02 +1100 Received: from dave by discord.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1j9Oqv-0005ci-Tq for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:01 +1100 From: Dave Chinner To: linux-xfs@vger.kernel.org Subject: [PATCH 06/11] xfs: move xlog_state_ioerror() Date: Wed, 4 Mar 2020 18:53:56 +1100 Message-Id: <20200304075401.21558-7-david@fromorbit.com> X-Mailer: git-send-email 2.24.0.rc0 In-Reply-To: <20200304075401.21558-1-david@fromorbit.com> References: <20200304075401.21558-1-david@fromorbit.com> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=LYdCFQXi c=1 sm=1 tr=0 a=mqTaRPt+QsUAtUurwE173Q==:117 a=mqTaRPt+QsUAtUurwE173Q==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=SS2py6AdgQ4A:10 a=20KFwNOVAAAA:8 a=bkf_lyP68qlAmJxVHm4A:9 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner To clean up unmount record writing error handling, we need to move xlog_state_ioerror() higher up in the file. Also move the setting of the XLOG_IO_ERROR state to inside the function. Signed-off-by: Dave Chinner Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 59 ++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 2e9f3baa7cc8..0de3c32d42b6 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -874,6 +874,36 @@ xfs_log_mount_cancel( xfs_log_unmount(mp); } +/* + * 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; + + log->l_flags |= XLOG_IO_ERROR; + + 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; +} + /* * Mark the filesystem clean by writing an unmount record to the head of the * log. @@ -3770,34 +3800,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. @@ -3868,7 +3870,6 @@ xfs_log_force_umount( * Mark the log and the iclogs with IO error flags to prevent any * further log IO from being issued or completed. */ - log->l_flags |= XLOG_IO_ERROR; retval = xlog_state_ioerror(log); spin_unlock(&log->l_icloglock); From patchwork Wed Mar 4 07:53:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 11419539 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 7EFBF138D for ; Wed, 4 Mar 2020 07:54:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5EB222166E for ; Wed, 4 Mar 2020 07:54:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728531AbgCDHyI (ORCPT ); Wed, 4 Mar 2020 02:54:08 -0500 Received: from mail105.syd.optusnet.com.au ([211.29.132.249]:34031 "EHLO mail105.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725271AbgCDHyI (ORCPT ); Wed, 4 Mar 2020 02:54:08 -0500 Received: from dread.disaster.area (pa49-195-202-68.pa.nsw.optusnet.com.au [49.195.202.68]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 4089A3A2A2B for ; Wed, 4 Mar 2020 18:54:03 +1100 (AEDT) Received: from discord.disaster.area ([192.168.253.110]) by dread.disaster.area with esmtp (Exim 4.92.3) (envelope-from ) id 1j9Oqw-0007li-24 for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:02 +1100 Received: from dave by discord.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1j9Oqv-0005cl-Va for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:01 +1100 From: Dave Chinner To: linux-xfs@vger.kernel.org Subject: [PATCH 07/11] xfs: clean up xlog_state_ioerror() Date: Wed, 4 Mar 2020 18:53:57 +1100 Message-Id: <20200304075401.21558-8-david@fromorbit.com> X-Mailer: git-send-email 2.24.0.rc0 In-Reply-To: <20200304075401.21558-1-david@fromorbit.com> References: <20200304075401.21558-1-david@fromorbit.com> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=LYdCFQXi c=1 sm=1 tr=0 a=mqTaRPt+QsUAtUurwE173Q==:117 a=mqTaRPt+QsUAtUurwE173Q==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=SS2py6AdgQ4A:10 a=20KFwNOVAAAA:8 a=oIrh420T3QSa8vw9ZH0A:9 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Signed-off-by: Dave Chinner Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 0de3c32d42b6..a310ca9e7615 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -875,33 +875,27 @@ xfs_log_mount_cancel( } /* - * Mark all iclogs IOERROR. l_icloglock is held by the caller. + * Mark all iclogs IOERROR. l_icloglock is held by the caller. Returns 1 if the + * log was already in an IO state, 0 otherwise. From now one, no log flushes + * will occur. */ STATIC int xlog_state_ioerror( - struct xlog *log) + struct xlog *log) { - xlog_in_core_t *iclog, *ic; + struct xlog_in_core *iclog = log->l_iclog; + struct xlog_in_core *ic = iclog; log->l_flags |= XLOG_IO_ERROR; + if (iclog->ic_state == XLOG_STATE_IOERROR) + return 1; - 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; + do { + ic->ic_state = XLOG_STATE_IOERROR; + ic = ic->ic_next; + } while (ic != iclog); + + return 0; } /* From patchwork Wed Mar 4 07:53:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 11419525 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 0BF5F930 for ; Wed, 4 Mar 2020 07:54:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EA5A020866 for ; Wed, 4 Mar 2020 07:54:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728515AbgCDHyF (ORCPT ); Wed, 4 Mar 2020 02:54:05 -0500 Received: from mail104.syd.optusnet.com.au ([211.29.132.246]:43674 "EHLO mail104.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbgCDHyF (ORCPT ); Wed, 4 Mar 2020 02:54:05 -0500 Received: from dread.disaster.area (pa49-195-202-68.pa.nsw.optusnet.com.au [49.195.202.68]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id 407937EA131 for ; Wed, 4 Mar 2020 18:54:03 +1100 (AEDT) Received: from discord.disaster.area ([192.168.253.110]) by dread.disaster.area with esmtp (Exim 4.92.3) (envelope-from ) id 1j9Oqw-0007ll-3M for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:02 +1100 Received: from dave by discord.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1j9Oqw-0005co-1G for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:02 +1100 From: Dave Chinner To: linux-xfs@vger.kernel.org Subject: [PATCH 08/11] xfs: rename the log unmount writing functions. Date: Wed, 4 Mar 2020 18:53:58 +1100 Message-Id: <20200304075401.21558-9-david@fromorbit.com> X-Mailer: git-send-email 2.24.0.rc0 In-Reply-To: <20200304075401.21558-1-david@fromorbit.com> References: <20200304075401.21558-1-david@fromorbit.com> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=LYdCFQXi c=1 sm=1 tr=0 a=mqTaRPt+QsUAtUurwE173Q==:117 a=mqTaRPt+QsUAtUurwE173Q==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=SS2py6AdgQ4A:10 a=20KFwNOVAAAA:8 a=pDtEVDZtZgkmEOs7AtQA:9 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner The naming and calling conventions are a bit of a mess. Clean it up so the call chain looks like: xfs_log_unmount_write(mp) xlog_unmount_write(log) xlog_write_unmount_record(log, ticket) Signed-off-by: Dave Chinner Reviewed-by: Christoph Hellwig Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index a310ca9e7615..bdf604d31d8c 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -491,7 +491,7 @@ xfs_log_reserve( * transaction context that has already done the accounting for us. */ static int -xlog_write_unmount( +xlog_write_unmount_record( struct xlog *log, struct xlog_ticket *ticket, xfs_lsn_t *lsn, @@ -903,10 +903,10 @@ xlog_state_ioerror( * log. */ static void -xfs_log_write_unmount_record( - struct xfs_mount *mp) +xlog_unmount_write( + struct xlog *log) { - struct xlog *log = mp->m_log; + struct xfs_mount *mp = log->l_mp; struct xlog_in_core *iclog; struct xlog_ticket *tic = NULL; xfs_lsn_t lsn; @@ -930,7 +930,7 @@ xfs_log_write_unmount_record( flags &= ~XLOG_UNMOUNT_TRANS; } - error = xlog_write_unmount(log, tic, &lsn, flags); + error = xlog_write_unmount_record(log, tic, &lsn, flags); /* * At this point, we're umounting anyway, so there's no point in * transitioning log state to IOERROR. Just continue... @@ -1006,7 +1006,7 @@ xfs_log_unmount_write(xfs_mount_t *mp) } while (iclog != first_iclog); #endif if (! (XLOG_FORCED_SHUTDOWN(log))) { - xfs_log_write_unmount_record(mp); + xlog_unmount_write(log); } else { /* * We're already in forced_shutdown mode, couldn't From patchwork Wed Mar 4 07:53:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 11419585 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 BAF80139A for ; Wed, 4 Mar 2020 08:11:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9D62C21739 for ; Wed, 4 Mar 2020 08:11:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725283AbgCDILc (ORCPT ); Wed, 4 Mar 2020 03:11:32 -0500 Received: from mail104.syd.optusnet.com.au ([211.29.132.246]:47621 "EHLO mail104.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725271AbgCDILc (ORCPT ); Wed, 4 Mar 2020 03:11:32 -0500 Received: from dread.disaster.area (pa49-195-202-68.pa.nsw.optusnet.com.au [49.195.202.68]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id D41667E919B for ; Wed, 4 Mar 2020 19:11:28 +1100 (AEDT) Received: from discord.disaster.area ([192.168.253.110]) by dread.disaster.area with esmtp (Exim 4.92.3) (envelope-from ) id 1j9Oqw-0007ln-4O for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:02 +1100 Received: from dave by discord.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1j9Oqw-0005cr-2G for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:02 +1100 From: Dave Chinner To: linux-xfs@vger.kernel.org Subject: [PATCH 09/11] xfs: merge unmount record write iclog cleanup. Date: Wed, 4 Mar 2020 18:53:59 +1100 Message-Id: <20200304075401.21558-10-david@fromorbit.com> X-Mailer: git-send-email 2.24.0.rc0 In-Reply-To: <20200304075401.21558-1-david@fromorbit.com> References: <20200304075401.21558-1-david@fromorbit.com> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=W5xGqiek c=1 sm=1 tr=0 a=mqTaRPt+QsUAtUurwE173Q==:117 a=mqTaRPt+QsUAtUurwE173Q==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=SS2py6AdgQ4A:10 a=20KFwNOVAAAA:8 a=_kU_IPfDU8L_TcjNku8A:9 a=uZXimcwsb_s-5M2f:21 a=AXX_iIusX2xWdw9j:21 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner The unmount iclog handling is duplicated in both xfs_log_unmount_write() and xfs_log_write_unmount_record(). We only need one copy of it in xfs_log_unmount_write() because that is the only function that calls xfs_log_write_unmount_record(). Signed-off-by: Dave Chinner Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 130 +++++++++++++++++------------------------------ 1 file changed, 48 insertions(+), 82 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index bdf604d31d8c..a687c20dd77d 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -898,16 +898,11 @@ xlog_state_ioerror( return 0; } -/* - * Mark the filesystem clean by writing an unmount record to the head of the - * log. - */ -static void +static int xlog_unmount_write( struct xlog *log) { struct xfs_mount *mp = log->l_mp; - struct xlog_in_core *iclog; struct xlog_ticket *tic = NULL; xfs_lsn_t lsn; uint flags = XLOG_UNMOUNT_TRANS; @@ -931,61 +926,41 @@ xlog_unmount_write( } error = xlog_write_unmount_record(log, tic, &lsn, flags); - /* - * At this point, we're umounting anyway, so there's no point in - * transitioning log state to IOERROR. Just continue... - */ -out_err: - if (error) - xfs_alert(mp, "%s: unmount record failed", __func__); - - spin_lock(&log->l_icloglock); - iclog = log->l_iclog; - 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: + if (error) { + /* A full shutdown is unnecessary at this point of unmount */ + spin_lock(&log->l_icloglock); + log->l_flags |= XLOG_IO_ERROR; + xlog_state_ioerror(log); spin_unlock(&log->l_icloglock); - break; } - if (tic) { - trace_xfs_log_umount_write(log, tic); - xlog_ungrant_log_space(log, tic); - xfs_log_ticket_put(tic); - } + trace_xfs_log_umount_write(log, tic); + xlog_ungrant_log_space(log, tic); + xfs_log_ticket_put(tic); +out_err: + if (error) + xfs_alert(mp, "%s: unmount record failed", __func__); + return error; } /* - * Unmount record used to have a string "Unmount filesystem--" in the - * data section where the "Un" was really a magic number (XLOG_UNMOUNT_TYPE). - * We just write the magic number now since that particular field isn't - * currently architecture converted and "Unmount" is a bit foo. - * As far as I know, there weren't any dependencies on the old behaviour. + * Finalise the unmount by writing the unmount record to the log. This is the + * mark that the filesystem was cleanly unmounted. + * + * Avoid writing the unmount record on no-recovery mounts, ro-devices, or when + * the log has already been shut down. */ - static int -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; + struct xlog *log = mp->m_log; + struct xlog_in_core *iclog; #ifdef DEBUG - xlog_in_core_t *first_iclog; + struct xlog_in_core *first_iclog; #endif - int error; + int error; - /* - * Don't write out unmount record on norecovery mounts or ro devices. - * Or, if we are doing a forced umount (typically because of IO errors). - */ if (mp->m_flags & XFS_MOUNT_NORECOVERY || xfs_readonly_buftarg(log->l_targ)) { ASSERT(mp->m_flags & XFS_MOUNT_RDONLY); @@ -1005,41 +980,32 @@ xfs_log_unmount_write(xfs_mount_t *mp) iclog = iclog->ic_next; } while (iclog != first_iclog); #endif - if (! (XLOG_FORCED_SHUTDOWN(log))) { - xlog_unmount_write(log); - } 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); - error = 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)) + error = xlog_unmount_write(log); + + /* + * Sync and release the current iclog so the unmount record gets to + * disk. If we are in a shutdown state, no IO will be done, but we still + * we need to wait for other log I/Os that may already be in progress. + */ + spin_lock(&log->l_icloglock); + iclog = log->l_iclog; + atomic_inc(&iclog->ic_refcnt); + xlog_state_want_sync(log, iclog); + error = 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; + } return error; -} /* xfs_log_unmount_write */ +} /* * Empty the log for unmount/freeze. From patchwork Wed Mar 4 07:54:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 11419537 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 F0A0917E0 for ; Wed, 4 Mar 2020 07:54:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB47E20866 for ; Wed, 4 Mar 2020 07:54:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728557AbgCDHyI (ORCPT ); Wed, 4 Mar 2020 02:54:08 -0500 Received: from mail105.syd.optusnet.com.au ([211.29.132.249]:33973 "EHLO mail105.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728531AbgCDHyI (ORCPT ); Wed, 4 Mar 2020 02:54:08 -0500 Received: from dread.disaster.area (pa49-195-202-68.pa.nsw.optusnet.com.au [49.195.202.68]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 1058A3A2A16 for ; Wed, 4 Mar 2020 18:54:02 +1100 (AEDT) Received: from discord.disaster.area ([192.168.253.110]) by dread.disaster.area with esmtp (Exim 4.92.3) (envelope-from ) id 1j9Oqw-0007lr-6o for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:02 +1100 Received: from dave by discord.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1j9Oqw-0005ct-3C for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:02 +1100 From: Dave Chinner To: linux-xfs@vger.kernel.org Subject: [PATCH 10/11] xfs: remove some stale comments from the log code Date: Wed, 4 Mar 2020 18:54:00 +1100 Message-Id: <20200304075401.21558-11-david@fromorbit.com> X-Mailer: git-send-email 2.24.0.rc0 In-Reply-To: <20200304075401.21558-1-david@fromorbit.com> References: <20200304075401.21558-1-david@fromorbit.com> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=X6os11be c=1 sm=1 tr=0 a=mqTaRPt+QsUAtUurwE173Q==:117 a=mqTaRPt+QsUAtUurwE173Q==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=SS2py6AdgQ4A:10 a=20KFwNOVAAAA:8 a=HAJyDiJqIqQbgm0xHfYA:9 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner Signed-off-by: Dave Chinner Reviewed-by: Christoph Hellwig Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 71 ++++++++++++++---------------------------------- 1 file changed, 20 insertions(+), 51 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index a687c20dd77d..89956484848f 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -477,14 +477,6 @@ xfs_log_reserve( return error; } - -/* - * NOTES: - * - * 1. currblock field gets updated at startup and after in-core logs - * marked as with WANT_SYNC. - */ - /* * Write out an unmount record using the ticket provided. We have to account for * the data space used in the unmount ticket as this write is not done from a @@ -1968,7 +1960,7 @@ xlog_dealloc_log( log->l_mp->m_log = NULL; destroy_workqueue(log->l_ioend_workqueue); kmem_free(log); -} /* xlog_dealloc_log */ +} /* * Update counters atomically now that memcpy is done. @@ -2511,14 +2503,6 @@ xlog_write( return error; } - -/***************************************************************************** - * - * State Machine functions - * - ***************************************************************************** - */ - /* * 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 @@ -2887,8 +2871,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, aborted); +} /* @@ -3008,14 +2992,14 @@ xlog_state_get_iclog_space( *logoffsetp = log_offset; return 0; -} /* xlog_state_get_iclog_space */ - -/* The first cnt-1 times through here we don't need to - * move the grant write head because the permanent - * reservation has reserved cnt times the unit amount. - * Release part of current permanent unit reservation and - * reset current reservation to be one units worth. Also - * move grant reservation head forward. +} + +/* + * The first cnt-1 times a ticket goes through here we don't need to move the + * grant write head because the permanent reservation has reserved cnt times the + * unit amount. Release part of current permanent unit reservation and reset + * current reservation to be one units worth. Also move grant reservation head + * forward. */ STATIC void xlog_regrant_reserve_log_space( @@ -3047,7 +3031,7 @@ xlog_regrant_reserve_log_space( ticket->t_curr_res = ticket->t_unit_res; xlog_tic_reset_res(ticket); -} /* xlog_regrant_reserve_log_space */ +} /* @@ -3096,11 +3080,11 @@ 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. + * 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. */ STATIC void xlog_state_switch_iclogs( @@ -3143,7 +3127,7 @@ xlog_state_switch_iclogs( } ASSERT(iclog == log->l_iclog); log->l_iclog = iclog->ic_next; -} /* xlog_state_switch_iclogs */ +} /* * Write out all data in the in-core log as of this exact moment in time. @@ -3397,14 +3381,6 @@ xlog_state_want_sync( } } - -/***************************************************************************** - * - * TICKET functions - * - ***************************************************************************** - */ - /* * Free a used ticket when its refcount falls to zero. */ @@ -3562,13 +3538,6 @@ xlog_ticket_alloc( return tic; } - -/****************************************************************************** - * - * Log debug routines - * - ****************************************************************************** - */ #if defined(DEBUG) /* * Make sure that the destination ptr is within the valid data region of @@ -3654,7 +3623,7 @@ xlog_verify_tail_lsn( if (blocks < BTOBB(iclog->ic_offset) + 1) xfs_emerg(log->l_mp, "%s: ran out of log space", __func__); } -} /* xlog_verify_tail_lsn */ +} /* * Perform a number of checks on the iclog before writing to disk. @@ -3757,7 +3726,7 @@ xlog_verify_iclog( } ptr += sizeof(xlog_op_header_t) + op_len; } -} /* xlog_verify_iclog */ +} #endif /* From patchwork Wed Mar 4 07:54:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 11419547 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 78F9517E0 for ; Wed, 4 Mar 2020 07:54:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5968A21741 for ; Wed, 4 Mar 2020 07:54:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728692AbgCDHyL (ORCPT ); Wed, 4 Mar 2020 02:54:11 -0500 Received: from mail105.syd.optusnet.com.au ([211.29.132.249]:34029 "EHLO mail105.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728539AbgCDHyK (ORCPT ); Wed, 4 Mar 2020 02:54:10 -0500 Received: from dread.disaster.area (pa49-195-202-68.pa.nsw.optusnet.com.au [49.195.202.68]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 5B8953A2A30 for ; Wed, 4 Mar 2020 18:54:03 +1100 (AEDT) Received: from discord.disaster.area ([192.168.253.110]) by dread.disaster.area with esmtp (Exim 4.92.3) (envelope-from ) id 1j9Oqw-0007lu-9L for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:02 +1100 Received: from dave by discord.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1j9Oqw-0005cx-4t for linux-xfs@vger.kernel.org; Wed, 04 Mar 2020 18:54:02 +1100 From: Dave Chinner To: linux-xfs@vger.kernel.org Subject: [PATCH 11/11] xfs: kill XLOG_TIC_INITED Date: Wed, 4 Mar 2020 18:54:01 +1100 Message-Id: <20200304075401.21558-12-david@fromorbit.com> X-Mailer: git-send-email 2.24.0.rc0 In-Reply-To: <20200304075401.21558-1-david@fromorbit.com> References: <20200304075401.21558-1-david@fromorbit.com> MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=LYdCFQXi c=1 sm=1 tr=0 a=mqTaRPt+QsUAtUurwE173Q==:117 a=mqTaRPt+QsUAtUurwE173Q==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=SS2py6AdgQ4A:10 a=20KFwNOVAAAA:8 a=HZAom3Fnrnec--42wGYA:9 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner It is not longer used or checked by anything, so remove the last traces from the log ticket code. Signed-off-by: Dave Chinner Reviewed-by: Christoph Hellwig Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 1 - fs/xfs/xfs_log_priv.h | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 89956484848f..b91efc5829e1 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -3529,7 +3529,6 @@ xlog_ticket_alloc( tic->t_ocnt = cnt; tic->t_tid = prandom_u32(); tic->t_clientid = client; - tic->t_flags = XLOG_TIC_INITED; if (permanent) tic->t_flags |= XLOG_TIC_PERM_RESERV; diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index 081d4c6de2c8..e989cf024ffe 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h @@ -51,13 +51,11 @@ enum xlog_iclog_state { }; /* - * Flags to log ticket + * Log ticket flags */ -#define XLOG_TIC_INITED 0x1 /* has been initialized */ -#define XLOG_TIC_PERM_RESERV 0x2 /* permanent reservation */ +#define XLOG_TIC_PERM_RESERV 0x1 /* permanent reservation */ #define XLOG_TIC_FLAGS \ - { XLOG_TIC_INITED, "XLOG_TIC_INITED" }, \ { XLOG_TIC_PERM_RESERV, "XLOG_TIC_PERM_RESERV" } /*