From patchwork Thu Jan 19 06:36:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13107454 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7EC13C6379F for ; Thu, 19 Jan 2023 06:36:51 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pIOXa-0001Sh-QT; Thu, 19 Jan 2023 06:36:49 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIOXY-0001SS-4a for linux-f2fs-devel@lists.sourceforge.net; Thu, 19 Jan 2023 06:36:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=3Q1xLjahu5r3Hpi8KZaN6erKrrcckUykkiJeIuFGVEE=; b=IlUErF5i3b7jZi3XAcRuZ47I3B 42g12CLaQqhqwHGO8uChh8UOzdiNj82T+OikL3ZHqL/E08eJh74Qqvbl4y2+Lvp9wbTpR4LBbT7Wn PWsnvAkPGH6m8EjEo5Rf6zN2AKfu/Gr/+BMJ4+ISE0cjC2JmZpsLABzn10acGEfACGlQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=3Q1xLjahu5r3Hpi8KZaN6erKrrcckUykkiJeIuFGVEE=; b=OTLiXq4nvPxNTLlP1xV5mAQxqv heIgOB3ruDEjvIMjMVppWStsoUOKrCeTqvetqe2UZkFvzKkVKlqes7vrSOViQ7wNNeYUWoBygFw1F Kehp3P5t3kG+6fOolSZjVTRTQaRCvqN/gXlkErPIBWln+R2AFL/9/8+8T1mcxF9rFStQ=; Received: from bombadil.infradead.org ([198.137.202.133]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pIOXT-0001dS-40 for linux-f2fs-devel@lists.sourceforge.net; Thu, 19 Jan 2023 06:36:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=3Q1xLjahu5r3Hpi8KZaN6erKrrcckUykkiJeIuFGVEE=; b=d3DP1HJYKUhjmxH2khsCX1lzSb nYglgL/Luow7+mlgv4t+ID3WyUjWW9WIam85f66YeL15OSsO+J0ymB+slQIbcyGc/3LmvY/aYRZRd aH33+vPELLR9WQ/fNMYoAzLixuxhgN6DQqTmZb00SOWavugxADcDu/T8zmnBuK/cAF0AbVKJ7js3N gYXpRYnWEcfZh32rhGj4+WiRcQk1W+PcroHK6uclkU+1BzPrhAgLSR0GSpRhG20calAetf2vxQXLe aF1of7K1s+92MjOIKVvRtJ1NSXMqX7Qge+/iUw95vdn/jVnMJJezaR6Bs6dNXfUPNHZCJEiB7MhJf 5tSq7T2g==; Received: from [2001:4bb8:19a:2039:96fe:c1ec:dda2:41a3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIOXH-003kak-D6; Thu, 19 Jan 2023 06:36:32 +0000 From: Christoph Hellwig To: Jaegeuk Kim , Chao Yu Date: Thu, 19 Jan 2023 07:36:18 +0100 Message-Id: <20230119063625.466485-2-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230119063625.466485-1-hch@lst.de> References: <20230119063625.466485-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Headers-End: 1pIOXT-0001dS-40 Subject: [f2fs-dev] [PATCH 1/8] f2fs: remove __add_sum_entry X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This function just assigns a summary entry. This can be done entirely typesafe with an open code struct assignment that relies on array indexing. Signed-off-by: Christoph Hellwig Reviewed-by: Chao Yu --- fs/f2fs/segment.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 311243dda4cefa..ec6880213e8fa9 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2323,19 +2323,6 @@ bool f2fs_is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr) return is_cp; } -/* - * This function should be resided under the curseg_mutex lock - */ -static void __add_sum_entry(struct f2fs_sb_info *sbi, int type, - struct f2fs_summary *sum) -{ - struct curseg_info *curseg = CURSEG_I(sbi, type); - void *addr = curseg->sum_blk; - - addr += curseg->next_blkoff * sizeof(struct f2fs_summary); - memcpy(addr, sum, sizeof(struct f2fs_summary)); -} - /* * Calculate the number of current summary pages for writing */ @@ -3262,13 +3249,7 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, f2fs_wait_discard_bio(sbi, *new_blkaddr); - /* - * __add_sum_entry should be resided under the curseg_mutex - * because, this function updates a summary entry in the - * current summary block. - */ - __add_sum_entry(sbi, type, sum); - + curseg->sum_blk->entries[curseg->next_blkoff] = *sum; __refresh_next_blkoff(sbi, curseg); stat_inc_block_count(sbi, curseg); @@ -3571,7 +3552,7 @@ void f2fs_do_replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, } curseg->next_blkoff = GET_BLKOFF_FROM_SEG0(sbi, new_blkaddr); - __add_sum_entry(sbi, type, sum); + curseg->sum_blk->entries[curseg->next_blkoff] = *sum; if (!recover_curseg || recover_newaddr) { if (!from_gc)