From patchwork Wed Jun 16 16:32:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12325657 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05559C48BE6 for ; Wed, 16 Jun 2021 16:33:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD0D261356 for ; Wed, 16 Jun 2021 16:33:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229931AbhFPQfD (ORCPT ); Wed, 16 Jun 2021 12:35:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbhFPQfB (ORCPT ); Wed, 16 Jun 2021 12:35:01 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7694C061574 for ; Wed, 16 Jun 2021 09:32:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=TiA/jKSIaDaUx28iReaPf9vZd06digMfKfn74wIvAZk=; b=otyLR23P/DjS1SQ+vJpPuMyUw3 x5i1krgUf5oA5dgEppVvIkplF9RUxKZq8k6AVfuySfOdo+2BWDDWVruYFdpexbkrDVcBTOaSzOI3z SxdTWVJEvsvXVcpSAchfFzDmOKGSuSfkE4Jy+62F4ernMiWSuPqKYplnU4Q1EwrA/SjGjz06jAMED ohFZ4v54m9F5N8BQcCRpJfs7Cd1VBfENuowlT0tXCDMHYWvloNRGvXO9OWoRreUNBTL/NoCQsCQc/ p8zrPQMFyDArFHKJUI5K5M5nQ9WWEDZpD8r/z+Ke1ewH6S9qvgqKa4edPd0XgkzLpgWRB/zNnzebZ 226DxA3g==; Received: from [2001:4bb8:19b:fdce:84d:447:81f0:ca60] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltYSs-008G1N-MJ for linux-xfs@vger.kernel.org; Wed, 16 Jun 2021 16:32:39 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 1/8] xfs: change the type of ic_datap Date: Wed, 16 Jun 2021 18:32:05 +0200 Message-Id: <20210616163212.1480297-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210616163212.1480297-1-hch@lst.de> References: <20210616163212.1480297-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Turn ic_datap from a char into a void pointer given that it points to arbitrary data. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Chandan Babu R --- fs/xfs/xfs_log.c | 2 +- fs/xfs/xfs_log_priv.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index e921b554b68367..8999c78f3ac6d9 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -3613,7 +3613,7 @@ xlog_verify_iclog( if (field_offset & 0x1ff) { clientid = ophead->oh_clientid; } else { - idx = BTOBBT((char *)&ophead->oh_clientid - iclog->ic_datap); + idx = BTOBBT((void *)&ophead->oh_clientid - iclog->ic_datap); if (idx >= (XLOG_HEADER_CYCLE_SIZE / BBSIZE)) { j = idx / (XLOG_HEADER_CYCLE_SIZE / BBSIZE); k = idx % (XLOG_HEADER_CYCLE_SIZE / BBSIZE); diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index e4e421a7033558..96dbe713954f7e 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h @@ -185,7 +185,7 @@ typedef struct xlog_in_core { u32 ic_offset; enum xlog_iclog_state ic_state; unsigned int ic_flags; - char *ic_datap; /* pointer to iclog data */ + void *ic_datap; /* pointer to iclog data */ /* Callback structures need their own cacheline */ spinlock_t ic_callback_lock ____cacheline_aligned_in_smp; From patchwork Wed Jun 16 16:32:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12325659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85007C48BE5 for ; Wed, 16 Jun 2021 16:34:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F43461359 for ; Wed, 16 Jun 2021 16:34:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229614AbhFPQgV (ORCPT ); Wed, 16 Jun 2021 12:36:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230137AbhFPQfS (ORCPT ); Wed, 16 Jun 2021 12:35:18 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6CD4C061760 for ; Wed, 16 Jun 2021 09:33:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=TMBZEHOKd/MSVAMcTKo8Tui3DPavBxLZKDAba96SRvk=; b=RpGqkfQysf02RRE6xd0kfFzMfs o/0dYFpvXLrF169fJxzI8l3XNNeLjQELhRW+y2kWrxBJACANoEfXHskCMTah51MLweNYRTI0/wBk7 jnCsLwA0MmHWZ/FDzDs0yJdtBg7OFYPVg05FENBk2rklL/OnyKZ6+uhZR3Ny6QJ6oHkwinZAMiSYn BYCL+KJ+ls4W1TmhPIlUBtRf3N1NvPBoBpVs488D/YX/8jeyMi7c67cLPii5ZIkarQPrVSEwExy79 lZY4UBO5tzHLdWMS5ex66+fmZQ/7Xw0i8ESKR4tiVbU9HCLRSsycsBZKpTFTqnWgfgkx9fpt9nZgI WrYYmQ/A==; Received: from [2001:4bb8:19b:fdce:84d:447:81f0:ca60] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltYTF-008G2E-7T for linux-xfs@vger.kernel.org; Wed, 16 Jun 2021 16:32:58 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 2/8] xfs: list entry elements don't need to be initialized Date: Wed, 16 Jun 2021 18:32:06 +0200 Message-Id: <20210616163212.1480297-3-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210616163212.1480297-1-hch@lst.de> References: <20210616163212.1480297-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org list_add does not require the added element to be initialized. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Chandan Babu R --- fs/xfs/xfs_log.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 8999c78f3ac6d9..32cb0fc459a364 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -851,7 +851,7 @@ xlog_write_unmount_record( .lv_iovecp = ®, }; LIST_HEAD(lv_chain); - INIT_LIST_HEAD(&vec.lv_list); + list_add(&vec.lv_list, &lv_chain); BUILD_BUG_ON((sizeof(struct xlog_op_header) + @@ -1587,7 +1587,7 @@ xlog_commit_record( }; int error; LIST_HEAD(lv_chain); - INIT_LIST_HEAD(&vec.lv_list); + list_add(&vec.lv_list, &lv_chain); if (XLOG_FORCED_SHUTDOWN(log)) From patchwork Wed Jun 16 16:32:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12325661 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A1A2C48BE5 for ; Wed, 16 Jun 2021 16:34:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D989261351 for ; Wed, 16 Jun 2021 16:34:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229652AbhFPQgW (ORCPT ); Wed, 16 Jun 2021 12:36:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbhFPQft (ORCPT ); Wed, 16 Jun 2021 12:35:49 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74B46C061767 for ; Wed, 16 Jun 2021 09:33:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=wCKHjGNk495455IdS8vUcvNie/Cn7eJI8DQ6fVhWTpM=; b=fI6IEykoxD9rE5jJ1PR0t0QvV/ a4odw3LtWNYB67/B/9+lEqN0k4d0zQUaFM6GmLoMYb8tIGKCTsOPPyaZR6lA2BEeaLq6SDYhbnPFf J58/RHHp4+/ZDEinBXgwm01ybJGVD/LwRlAG9unvlPgm4tOfETvPCODi8PGGkHTJlBf9da/onHzkc d2mmgFn2oB67dF8K/BAJFChBsN7TdpyYldnGJQbgVZVCteadWdx8Rgadj/DhrNVoa7nkFZreSSNKT dc9i3PNojC47SExCAyfTioDaAp2wcIWo2c6aMx2eNm1JV1dwbdkvNn7SdwpcMTTFhhtDGO/rB6Lxl L4V0Hwmg==; Received: from [2001:4bb8:19b:fdce:84d:447:81f0:ca60] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltYTX-008G3t-Ls for linux-xfs@vger.kernel.org; Wed, 16 Jun 2021 16:33:17 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 3/8] xfs: factor out a helper to write a log_iovec into the iclog Date: Wed, 16 Jun 2021 18:32:07 +0200 Message-Id: <20210616163212.1480297-4-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210616163212.1480297-1-hch@lst.de> References: <20210616163212.1480297-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Add a new helper to copy the log iovec into the in-core log buffer, and open code the handling continuation opheader as a special case. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Chandan Babu R --- fs/xfs/xfs_log.c | 55 +++++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 32cb0fc459a364..5b431d53287d2c 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2124,6 +2124,26 @@ xlog_print_trans( } } +static inline void +xlog_write_iovec( + struct xlog_in_core *iclog, + uint32_t *log_offset, + void *data, + uint32_t write_len, + int *bytes_left, + uint32_t *record_cnt, + uint32_t *data_cnt) +{ + ASSERT(*log_offset % sizeof(int32_t) == 0); + ASSERT(write_len % sizeof(int32_t) == 0); + + memcpy(iclog->ic_datap + *log_offset, data, write_len); + *log_offset += write_len; + *bytes_left -= write_len; + (*record_cnt)++; + *data_cnt += write_len; +} + /* * Write whole log vectors into a single iclog which is guaranteed to have * either sufficient space for the entire log vector chain to be written or @@ -2145,13 +2165,11 @@ xlog_write_single( uint32_t *data_cnt) { struct xfs_log_vec *lv; - void *ptr; int index; ASSERT(*log_offset + *len <= iclog->ic_size || iclog->ic_state == XLOG_STATE_WANT_SYNC); - ptr = iclog->ic_datap + *log_offset; for (lv = log_vector; !list_entry_is_head(lv, lv_chain, lv_list); lv = list_next_entry(lv, lv_list)) { @@ -2171,16 +2189,13 @@ xlog_write_single( struct xfs_log_iovec *reg = &lv->lv_iovecp[index]; struct xlog_op_header *ophdr = reg->i_addr; - ASSERT(reg->i_len % sizeof(int32_t) == 0); - ASSERT((unsigned long)ptr % sizeof(int32_t) == 0); - ophdr->oh_tid = cpu_to_be32(ticket->t_tid); ophdr->oh_len = cpu_to_be32(reg->i_len - sizeof(struct xlog_op_header)); - memcpy(ptr, reg->i_addr, reg->i_len); - xlog_write_adv_cnt(&ptr, len, log_offset, reg->i_len); - (*record_cnt)++; - *data_cnt += reg->i_len; + + xlog_write_iovec(iclog, log_offset, reg->i_addr, + reg->i_len, len, record_cnt, + data_cnt); } } if (list_entry_is_head(lv, lv_chain, lv_list)) @@ -2249,12 +2264,10 @@ xlog_write_partial( int error; /* walk the logvec, copying until we run out of space in the iclog */ - ptr = iclog->ic_datap + *log_offset; for (index = 0; index < lv->lv_niovecs; index++) { uint32_t reg_offset = 0; reg = &lv->lv_iovecp[index]; - ASSERT(reg->i_len % sizeof(int32_t) == 0); /* * The first region of a continuation must have a non-zero @@ -2274,7 +2287,6 @@ xlog_write_partial( data_cnt); if (error) return ERR_PTR(error); - ptr = iclog->ic_datap + *log_offset; } ophdr = reg->i_addr; @@ -2285,12 +2297,9 @@ xlog_write_partial( if (rlen != reg->i_len) ophdr->oh_flags |= XLOG_CONTINUE_TRANS; - ASSERT((unsigned long)ptr % sizeof(int32_t) == 0); - xlog_verify_dest_ptr(log, ptr); - memcpy(ptr, reg->i_addr, rlen); - xlog_write_adv_cnt(&ptr, len, log_offset, rlen); - (*record_cnt)++; - *data_cnt += rlen; + xlog_verify_dest_ptr(log, iclog->ic_datap + *log_offset); + xlog_write_iovec(iclog, log_offset, reg->i_addr, rlen, len, + record_cnt, data_cnt); /* If we wrote the whole region, move to the next. */ if (rlen == reg->i_len) @@ -2356,12 +2365,10 @@ xlog_write_partial( rlen = min_t(uint32_t, rlen, iclog->ic_size - *log_offset); ophdr->oh_len = cpu_to_be32(rlen); - xlog_verify_dest_ptr(log, ptr); - memcpy(ptr, reg->i_addr + reg_offset, rlen); - xlog_write_adv_cnt(&ptr, len, log_offset, rlen); - (*record_cnt)++; - *data_cnt += rlen; - + xlog_verify_dest_ptr(log, iclog->ic_datap + *log_offset); + xlog_write_iovec(iclog, log_offset, + reg->i_addr + reg_offset, rlen, len, + record_cnt, data_cnt); } while (ophdr->oh_flags & XLOG_CONTINUE_TRANS); } From patchwork Wed Jun 16 16:32:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12325663 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EF6AC48BE5 for ; Wed, 16 Jun 2021 16:34:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0765A61356 for ; Wed, 16 Jun 2021 16:34:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230137AbhFPQgX (ORCPT ); Wed, 16 Jun 2021 12:36:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229616AbhFPQfx (ORCPT ); Wed, 16 Jun 2021 12:35:53 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CB87C061574 for ; Wed, 16 Jun 2021 09:33:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=wf1ZtzWA/fYEmFI1ias1swk53gjv9unRVGn7yXvVZJ0=; b=f3oQ9gWDOeTDonHe49HSJIbkhn qwHwgZlWCr+BL5GRtATzazSbPC5Y4lcoazKApJQGwbc5wYWfibjcKbDSoR3dAmHGNFvVS7yhxOb2v oqNZDomLx3m58OaRvZKq6cgAa0T3bipeD9VZwvfFjKZDfCutKxo0hEMbujLxSq2vhejT71jkMczNx GuJ778kWSgWKoc+pTsHgMAX/X8nspXkCKeilcNzYpjHyAZ6395Ab8qal/ohZZPg/ENb9/sm5XGtEJ oCpkydB/ZJn2Cbrg3qCvCRVwE2OnWgTQCYsXaH/Aqjn9UjqgAN9RV6MfSdjRK5lwWSNFUspYNXU+C yHI2ExGA==; Received: from [2001:4bb8:19b:fdce:84d:447:81f0:ca60] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltYTn-008G4j-UG for linux-xfs@vger.kernel.org; Wed, 16 Jun 2021 16:33:35 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 4/8] xfs: remove xlog_write_adv_cnt and simplify xlog_write_partial Date: Wed, 16 Jun 2021 18:32:08 +0200 Message-Id: <20210616163212.1480297-5-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210616163212.1480297-1-hch@lst.de> References: <20210616163212.1480297-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org xlog_write_adv_cnt is now only used for writing the continuation ophdr. Remove xlog_write_adv_cnt and simplify the caller now that we don't need the ptr iteration variable, and don't need to increment / decrement len for the accounting shengians. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Chandan Babu R --- fs/xfs/xfs_log.c | 12 +++++------- fs/xfs/xfs_log_priv.h | 8 -------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 5b431d53287d2c..1bc32f056a5bcf 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2331,24 +2331,22 @@ xlog_write_partial( * a new iclog. This is necessary so that we reserve * space in the iclog for it. */ - *len += sizeof(struct xlog_op_header); ticket->t_curr_res -= sizeof(struct xlog_op_header); error = xlog_write_get_more_iclog_space(log, ticket, - &iclog, log_offset, *len, record_cnt, - data_cnt); + &iclog, log_offset, + *len + sizeof(struct xlog_op_header), + record_cnt, data_cnt); if (error) return ERR_PTR(error); - ptr = iclog->ic_datap + *log_offset; - ophdr = ptr; + ophdr = iclog->ic_datap + *log_offset; ophdr->oh_tid = cpu_to_be32(ticket->t_tid); ophdr->oh_clientid = XFS_TRANSACTION; ophdr->oh_res2 = 0; ophdr->oh_flags = XLOG_WAS_CONT_TRANS; - xlog_write_adv_cnt(&ptr, len, log_offset, - sizeof(struct xlog_op_header)); + *log_offset += sizeof(struct xlog_op_header); *data_cnt += sizeof(struct xlog_op_header); /* diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index 96dbe713954f7e..1b3b3d2bb8a5d1 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h @@ -467,14 +467,6 @@ extern kmem_zone_t *xfs_log_ticket_zone; struct xlog_ticket *xlog_ticket_alloc(struct xlog *log, int unit_bytes, int count, bool permanent); -static inline void -xlog_write_adv_cnt(void **ptr, int *len, int *off, size_t bytes) -{ - *ptr += bytes; - *len -= bytes; - *off += 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 list_head *lv_chain, From patchwork Wed Jun 16 16:32:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12325667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7618C48BE5 for ; Wed, 16 Jun 2021 16:34:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ACECE61356 for ; Wed, 16 Jun 2021 16:34:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230212AbhFPQgy (ORCPT ); Wed, 16 Jun 2021 12:36:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230268AbhFPQgR (ORCPT ); Wed, 16 Jun 2021 12:36:17 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37078C0617A8 for ; Wed, 16 Jun 2021 09:34:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=H5+lhxA85qvY5IJAoi2MDKWmgsIRgqZiw/Nt/fuAKfA=; b=Tuw9VB7rdr7Ry8/SxqeWd6MHau VTt98F/uK3TaJsM+D4ysiX+sJxu5kg8eV5cKSIkOiNcq/P/mTb+BqxfjzVxsKiUAc3dYytxTICPyZ 7qvjOu+a/vj/V60bFPjOZBogHY2NYuwc8Jv7WeRqqphe6H3NkMbOjzMmXYbi+w3NbQT+jfeaNSt1I xRTwZfaJC46JeNyLUc68kLAKxgmOR7HJFscMwkoR4XN9LIG1sUnvUTLSg8c7VRvAuQ78sT+WygUd5 DnUrDb9t3A9qN2pcb6DaUFT/QQWmS5CP1aszFfmFmdjyrdxeoGlUN6qnKgpfE/thuGlIUroS/0Ly0 Bsvap7WA==; Received: from [2001:4bb8:19b:fdce:84d:447:81f0:ca60] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltYU7-008G6J-2s for linux-xfs@vger.kernel.org; Wed, 16 Jun 2021 16:33:49 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 5/8] xfs: remove xlog_verify_dest_ptr Date: Wed, 16 Jun 2021 18:32:09 +0200 Message-Id: <20210616163212.1480297-6-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210616163212.1480297-1-hch@lst.de> References: <20210616163212.1480297-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Just check that the offset in xlog_write_vec is smaller than the iclog size and remove the expensive cycling through all iclogs. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Chandan Babu R --- fs/xfs/xfs_log.c | 35 +---------------------------------- fs/xfs/xfs_log_priv.h | 4 ---- 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 1bc32f056a5bcf..5d55d4fff63035 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -59,10 +59,6 @@ xlog_sync( struct xlog_ticket *ticket); #if defined(DEBUG) STATIC void -xlog_verify_dest_ptr( - struct xlog *log, - void *ptr); -STATIC void xlog_verify_grant_tail( struct xlog *log); STATIC void @@ -76,7 +72,6 @@ xlog_verify_tail_lsn( struct xlog_in_core *iclog, xfs_lsn_t tail_lsn); #else -#define xlog_verify_dest_ptr(a,b) #define xlog_verify_grant_tail(a) #define xlog_verify_iclog(a,b,c) #define xlog_verify_tail_lsn(a,b,c) @@ -1501,9 +1496,6 @@ xlog_alloc_log( KM_MAYFAIL | KM_ZERO); if (!iclog->ic_data) goto out_free_iclog; -#ifdef DEBUG - log->l_iclog_bak[i] = &iclog->ic_header; -#endif head = &iclog->ic_header; memset(head, 0, sizeof(xlog_rec_header_t)); head->h_magicno = cpu_to_be32(XLOG_HEADER_MAGIC_NUM); @@ -2134,6 +2126,7 @@ xlog_write_iovec( uint32_t *record_cnt, uint32_t *data_cnt) { + ASSERT(*log_offset < iclog->ic_log->l_iclog_size); ASSERT(*log_offset % sizeof(int32_t) == 0); ASSERT(write_len % sizeof(int32_t) == 0); @@ -2258,7 +2251,6 @@ xlog_write_partial( struct xfs_log_vec *lv = log_vector; struct xfs_log_iovec *reg; struct xlog_op_header *ophdr; - void *ptr; int index = 0; uint32_t rlen; int error; @@ -2297,7 +2289,6 @@ xlog_write_partial( if (rlen != reg->i_len) ophdr->oh_flags |= XLOG_CONTINUE_TRANS; - xlog_verify_dest_ptr(log, iclog->ic_datap + *log_offset); xlog_write_iovec(iclog, log_offset, reg->i_addr, rlen, len, record_cnt, data_cnt); @@ -2363,7 +2354,6 @@ xlog_write_partial( rlen = min_t(uint32_t, rlen, iclog->ic_size - *log_offset); ophdr->oh_len = cpu_to_be32(rlen); - xlog_verify_dest_ptr(log, iclog->ic_datap + *log_offset); xlog_write_iovec(iclog, log_offset, reg->i_addr + reg_offset, rlen, len, record_cnt, data_cnt); @@ -3466,29 +3456,6 @@ xlog_ticket_alloc( } #if defined(DEBUG) -/* - * Make sure that the destination ptr is within the valid data region of - * one of the iclogs. This uses backup pointers stored in a different - * part of the log in case we trash the log structure. - */ -STATIC void -xlog_verify_dest_ptr( - struct xlog *log, - void *ptr) -{ - int i; - int good_ptr = 0; - - for (i = 0; i < log->l_iclog_bufs; i++) { - if (ptr >= log->l_iclog_bak[i] && - ptr <= log->l_iclog_bak[i] + log->l_iclog_size) - good_ptr++; - } - - if (!good_ptr) - xfs_emerg(log->l_mp, "%s: invalid ptr", __func__); -} - /* * Check to make sure the grant write head didn't just over lap the tail. If * the cycles are the same, we can't be overlapping. Otherwise, make sure that diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index 1b3b3d2bb8a5d1..b829d8ba5c6a3f 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h @@ -434,10 +434,6 @@ struct xlog { struct xfs_kobj l_kobj; - /* The following field are used for debugging; need to hold icloglock */ -#ifdef DEBUG - void *l_iclog_bak[XLOG_MAX_ICLOGS]; -#endif /* log recovery lsn tracking (for buffer submission */ xfs_lsn_t l_recovery_lsn; From patchwork Wed Jun 16 16:32:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12325665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 034C7C48BE6 for ; Wed, 16 Jun 2021 16:34:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E17B361375 for ; Wed, 16 Jun 2021 16:34:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230225AbhFPQgy (ORCPT ); Wed, 16 Jun 2021 12:36:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229716AbhFPQgh (ORCPT ); Wed, 16 Jun 2021 12:36:37 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E60FC061760 for ; Wed, 16 Jun 2021 09:34:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=KcDSHBFHpogeWb37JH6IsrtjDkPG5LkJQotCBwXS6ho=; b=GPJADTupBus1uGRtIxclglC01p JFUjxWHLHwvuMTr9VPFJ5XesbNYekwDijCCtyJ/kz86vLkoec+Vd/SaKDjl0pUPiAxOoj2hRvKGhU UNsPE8lGGIFMnaVRLdlJHCD8e88VmBrwp3qtfb326AKBVc5IYczJH1z9vf6Jw60QqxElo1Z1TCemV A41yHFWYd4B/nrnzi5rOlyMEkignJBpSACBrjsWKfxWMEN1jog787UptIQKpT8AnEvbf69lfnK+kM wnLKpN49pYtBKq6tNhwEjPeHdW85pGUuT9bzSg40gSd3wGRBPg5CNs9l25HuztSmzXaVgSu0oHbW4 xcA6QE+Q==; Received: from [2001:4bb8:19b:fdce:84d:447:81f0:ca60] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltYUU-008G7y-Mc for linux-xfs@vger.kernel.org; Wed, 16 Jun 2021 16:34:17 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 6/8] xfs: simplify the xlog_write_partial calling conventions Date: Wed, 16 Jun 2021 18:32:10 +0200 Message-Id: <20210616163212.1480297-7-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210616163212.1480297-1-hch@lst.de> References: <20210616163212.1480297-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Lift the iteration to the next log_vec into the callers, and drop the pointless log argument that can be trivially derived. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Chandan Babu R --- fs/xfs/xfs_log.c | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 5d55d4fff63035..4afa8ff1a82076 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2232,14 +2232,11 @@ xlog_write_get_more_iclog_space( /* * Write log vectors into a single iclog which is smaller than the current chain * length. We write until we cannot fit a full record into the remaining space - * and then stop. We return the log vector that is to be written that cannot - * wholly fit in the iclog. + * and then stop. */ -static struct xfs_log_vec * +static int xlog_write_partial( - struct xlog *log, - struct list_head *lv_chain, - struct xfs_log_vec *log_vector, + struct xfs_log_vec *lv, struct xlog_ticket *ticket, struct xlog_in_core **iclogp, uint32_t *log_offset, @@ -2248,8 +2245,7 @@ xlog_write_partial( uint32_t *data_cnt) { struct xlog_in_core *iclog = *iclogp; - struct xfs_log_vec *lv = log_vector; - struct xfs_log_iovec *reg; + struct xlog *log = iclog->ic_log; struct xlog_op_header *ophdr; int index = 0; uint32_t rlen; @@ -2257,9 +2253,8 @@ xlog_write_partial( /* walk the logvec, copying until we run out of space in the iclog */ for (index = 0; index < lv->lv_niovecs; index++) { - uint32_t reg_offset = 0; - - reg = &lv->lv_iovecp[index]; + struct xfs_log_iovec *reg = &lv->lv_iovecp[index]; + uint32_t reg_offset = 0; /* * The first region of a continuation must have a non-zero @@ -2278,7 +2273,7 @@ xlog_write_partial( &iclog, log_offset, *len, record_cnt, data_cnt); if (error) - return ERR_PTR(error); + return error; } ophdr = reg->i_addr; @@ -2329,7 +2324,7 @@ xlog_write_partial( *len + sizeof(struct xlog_op_header), record_cnt, data_cnt); if (error) - return ERR_PTR(error); + return error; ophdr = iclog->ic_datap + *log_offset; ophdr->oh_tid = cpu_to_be32(ticket->t_tid); @@ -2365,10 +2360,7 @@ xlog_write_partial( * the caller so it can go back to fast path copying. */ *iclogp = iclog; - lv = list_next_entry(lv, lv_list); - if (list_entry_is_head(lv, lv_chain, lv_list)) - return NULL; - return lv; + return 0; } /* @@ -2450,13 +2442,13 @@ xlog_write( if (!lv) break; - lv = xlog_write_partial(log, lv_chain, lv, ticket, &iclog, - &log_offset, &len, &record_cnt, - &data_cnt); - if (IS_ERR_OR_NULL(lv)) { - error = PTR_ERR_OR_ZERO(lv); + error = xlog_write_partial(lv, ticket, &iclog, &log_offset, + &len, &record_cnt, &data_cnt); + if (error) + break; + lv = list_next_entry(lv, lv_list); + if (list_entry_is_head(lv, lv_chain, lv_list)) break; - } } ASSERT((len == 0 && !lv) || error); From patchwork Wed Jun 16 16:32:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12325669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DA40C48BE5 for ; Wed, 16 Jun 2021 16:34:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 24CE1613DC for ; Wed, 16 Jun 2021 16:34:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229716AbhFPQg5 (ORCPT ); Wed, 16 Jun 2021 12:36:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230215AbhFPQg4 (ORCPT ); Wed, 16 Jun 2021 12:36:56 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74B70C061574 for ; Wed, 16 Jun 2021 09:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=AWmt/JAQcf5OF2oa8CpgUiKffxILYfQkA/gxmYiZ22o=; b=bPO87/ySMLGBHzEr+08p5Bv87d sMGBd41rDVV8YDfqmXgs/99pIFTGahPe9KPZUYyWOXJLFudUyp0xzfzCVWtvl4QpFMfuiXa+veNV1 bxmvTvgL9IzI5y8YvxEpF7k4PAl9cHoi07XKWcL70C9q+KCTspeb6FlkSVCvaL2A4+lq+ICNuHeK8 y2DGFGu2xooVfY1P6cglwlIkCXq9rvyf7korrfXXA1OpyQ9a61eXhIpRHxUVpiRCcZMXWGfxHo1DK g3W9pUyT1+QT1LmeDVgktlTlARafUkWYUfEC4OcLm3CxLGRv//Vpbk8oWWxl2rnvKeXLRqAuKiSCK YIzN7F+g==; Received: from [2001:4bb8:19b:fdce:84d:447:81f0:ca60] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltYUn-008G9H-L0 for linux-xfs@vger.kernel.org; Wed, 16 Jun 2021 16:34:33 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 7/8] xfs: factor out a xlog_write_full_log_vec helper Date: Wed, 16 Jun 2021 18:32:11 +0200 Message-Id: <20210616163212.1480297-8-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210616163212.1480297-1-hch@lst.de> References: <20210616163212.1480297-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Add a helper to write out an entire log_vec to prepare for additional cleanups. Signed-off-by: Christoph Hellwig --- fs/xfs/xfs_log.c | 61 +++++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 4afa8ff1a82076..f8df09f37c3b84 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2137,6 +2137,44 @@ xlog_write_iovec( *data_cnt += write_len; } +/* + * Write a whole log vector into a single iclog which is guaranteed to have + * either sufficient space for the entire log vector chain to be written or + * exclusive access to the remaining space in the iclog. + * + * Return the number of iovecs and data written into the iclog. + */ +static void +xlog_write_full( + struct xfs_log_vec *lv, + struct xlog_ticket *ticket, + struct xlog_in_core *iclog, + uint32_t *log_offset, + uint32_t *len, + uint32_t *record_cnt, + uint32_t *data_cnt) +{ + int i; + + ASSERT(*log_offset + *len <= iclog->ic_size || + iclog->ic_state == XLOG_STATE_WANT_SYNC); + + /* + * Ordered log vectors have no regions to write so this loop will + * naturally skip them. + */ + for (i = 0; i < lv->lv_niovecs; i++) { + struct xfs_log_iovec *reg = &lv->lv_iovecp[i]; + struct xlog_op_header *ophdr = reg->i_addr; + + ophdr->oh_tid = cpu_to_be32(ticket->t_tid); + ophdr->oh_len = + cpu_to_be32(reg->i_len - sizeof(struct xlog_op_header)); + xlog_write_iovec(iclog, log_offset, reg->i_addr, reg->i_len, + len, record_cnt, data_cnt); + } +} + /* * Write whole log vectors into a single iclog which is guaranteed to have * either sufficient space for the entire log vector chain to be written or @@ -2158,10 +2196,6 @@ xlog_write_single( uint32_t *data_cnt) { struct xfs_log_vec *lv; - int index; - - ASSERT(*log_offset + *len <= iclog->ic_size || - iclog->ic_state == XLOG_STATE_WANT_SYNC); for (lv = log_vector; !list_entry_is_head(lv, lv_chain, lv_list); @@ -2173,23 +2207,8 @@ xlog_write_single( if (lv->lv_niovecs && lv->lv_bytes > iclog->ic_size - *log_offset) break; - - /* - * Ordered log vectors have no regions to write so this - * loop will naturally skip them. - */ - for (index = 0; index < lv->lv_niovecs; index++) { - struct xfs_log_iovec *reg = &lv->lv_iovecp[index]; - struct xlog_op_header *ophdr = reg->i_addr; - - ophdr->oh_tid = cpu_to_be32(ticket->t_tid); - ophdr->oh_len = cpu_to_be32(reg->i_len - - sizeof(struct xlog_op_header)); - - xlog_write_iovec(iclog, log_offset, reg->i_addr, - reg->i_len, len, record_cnt, - data_cnt); - } + xlog_write_full(lv, ticket, iclog, log_offset, len, record_cnt, + data_cnt); } if (list_entry_is_head(lv, lv_chain, lv_list)) lv = NULL; From patchwork Wed Jun 16 16:32:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12325671 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E38BC48BE5 for ; Wed, 16 Jun 2021 16:35:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5900F61356 for ; Wed, 16 Jun 2021 16:35:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229992AbhFPQhP (ORCPT ); Wed, 16 Jun 2021 12:37:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229673AbhFPQhP (ORCPT ); Wed, 16 Jun 2021 12:37:15 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05BE0C061574 for ; Wed, 16 Jun 2021 09:35:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=Nn8TfUVhaH5GRsCmm3ljXHlRGPEJzdb+4yTT3UIPqMI=; b=ir6TXTUHFjxRlYv7kJsXJQSD64 9LHVR3nWGetKsZ/0EExyjMbvNeJ97VTjUzNSavnQ9VHTqWDLV3V4Xak4ZylPZ4hi81QZwVOV9Pzpy peDxlHwv8cDUB+mVgoq4E2WUgfSkrPGV2KQW4eslr29cfUas7Su+WEV0bAdCX5m0xml3IsPu4mZWb gK2JpSRP+LEp5VIvf3Vv0qu+saqNe4COklZgqcPfojaUDOVY/DKat/jeZQ6d180Gyx/uIW3QTFYlW OIhj2mFdAOB+ie6+iw8leeio53PIgWZD0u6PwWaMH+lzVtmpsbkged+8P2bIP+J1a+WTKPGA03Ya2 Dja/qIBg==; Received: from [2001:4bb8:19b:fdce:84d:447:81f0:ca60] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltYV8-008GAx-1r for linux-xfs@vger.kernel.org; Wed, 16 Jun 2021 16:34:55 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 8/8] xfs: simplify the list iteration in xlog_write Date: Wed, 16 Jun 2021 18:32:12 +0200 Message-Id: <20210616163212.1480297-9-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210616163212.1480297-1-hch@lst.de> References: <20210616163212.1480297-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Just use a single list_for_each_entry in xlog_write which then dispatches to the simple or partial cases instead of using nested loops. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster --- fs/xfs/xfs_log.c | 73 +++++++++++------------------------------------- 1 file changed, 17 insertions(+), 56 deletions(-) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index f8df09f37c3b84..365914c25ff0f0 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -2175,47 +2175,6 @@ xlog_write_full( } } -/* - * Write whole log vectors into a single iclog which is guaranteed to have - * either sufficient space for the entire log vector chain to be written or - * exclusive access to the remaining space in the iclog. - * - * Return the number of iovecs and data written into the iclog, as well as - * a pointer to the logvec that doesn't fit in the log (or NULL if we hit the - * end of the chain. - */ -static struct xfs_log_vec * -xlog_write_single( - struct list_head *lv_chain, - struct xfs_log_vec *log_vector, - struct xlog_ticket *ticket, - struct xlog_in_core *iclog, - uint32_t *log_offset, - uint32_t *len, - uint32_t *record_cnt, - uint32_t *data_cnt) -{ - struct xfs_log_vec *lv; - - for (lv = log_vector; - !list_entry_is_head(lv, lv_chain, lv_list); - lv = list_next_entry(lv, lv_list)) { - /* - * If the entire log vec does not fit in the iclog, punt it to - * the partial copy loop which can handle this case. - */ - if (lv->lv_niovecs && - lv->lv_bytes > iclog->ic_size - *log_offset) - break; - xlog_write_full(lv, ticket, iclog, log_offset, len, record_cnt, - data_cnt); - } - if (list_entry_is_head(lv, lv_chain, lv_list)) - lv = NULL; - ASSERT(*len == 0 || lv); - return lv; -} - static int xlog_write_get_more_iclog_space( struct xlog *log, @@ -2454,22 +2413,24 @@ xlog_write( if (start_lsn) *start_lsn = be64_to_cpu(iclog->ic_header.h_lsn); - lv = list_first_entry_or_null(lv_chain, struct xfs_log_vec, lv_list); - while (lv) { - lv = xlog_write_single(lv_chain, lv, ticket, iclog, &log_offset, - &len, &record_cnt, &data_cnt); - if (!lv) - break; - - error = xlog_write_partial(lv, ticket, &iclog, &log_offset, - &len, &record_cnt, &data_cnt); - if (error) - break; - lv = list_next_entry(lv, lv_list); - if (list_entry_is_head(lv, lv_chain, lv_list)) - break; + list_for_each_entry(lv, lv_chain, lv_list) { + /* + * If the entire log vec does not fit in the iclog, punt it to + * the partial copy loop which can handle this case. + */ + if (lv->lv_niovecs && + lv->lv_bytes > iclog->ic_size - log_offset) { + error = xlog_write_partial(lv, ticket, &iclog, + &log_offset, &len, + &record_cnt, &data_cnt); + if (error) + break; + } else { + xlog_write_full(lv, ticket, iclog, &log_offset, &len, + &record_cnt, &data_cnt); + } } - ASSERT((len == 0 && !lv) || error); + ASSERT(len == 0 || error); /* * We've already been guaranteed that the last writes will fit inside