From patchwork Tue Oct 19 06:49:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "yebin (H)" X-Patchwork-Id: 1543019 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee2:21ea]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HYPDq596Rz9sNH for ; Tue, 19 Oct 2021 17:37:31 +1100 (AEDT) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee2:21ea]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4HYPDq4Qtpz4xbc for ; Tue, 19 Oct 2021 17:37:31 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4HYPDq4NzQz4xd8; Tue, 19 Oct 2021 17:37:31 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4HYPDq4LVlz4xbc for ; Tue, 19 Oct 2021 17:37:31 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233786AbhJSGjm (ORCPT ); Tue, 19 Oct 2021 02:39:42 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:29908 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229755AbhJSGjk (ORCPT ); Tue, 19 Oct 2021 02:39:40 -0400 Received: from dggeme754-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HYP7T3NXzzbnLs; Tue, 19 Oct 2021 14:32:53 +0800 (CST) Received: from huawei.com (10.175.127.227) by dggeme754-chm.china.huawei.com (10.3.19.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.15; Tue, 19 Oct 2021 14:37:25 +0800 From: Ye Bin To: , , CC: , , Ye Bin Subject: [PATCH -next v3 1/5] ext4: init 'seq' with the value which set in 'ext4_multi_mount_protect' Date: Tue, 19 Oct 2021 14:49:55 +0800 Message-ID: <20211019064959.625557-2-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211019064959.625557-1-yebin10@huawei.com> References: <20211019064959.625557-1-yebin10@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggeme754-chm.china.huawei.com (10.3.19.100) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org If two host have the same nodename, and seq start from 0, May cause the detection mechanism to fail. So init 'seq' with the value which set in 'ext4_multi_mount_protect' to accelerate conflict detection. Signed-off-by: Ye Bin --- fs/ext4/mmp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c index cebea4270817..11627ff002d3 100644 --- a/fs/ext4/mmp.c +++ b/fs/ext4/mmp.c @@ -132,7 +132,7 @@ static int kmmpd(void *data) struct buffer_head *bh = EXT4_SB(sb)->s_mmp_bh; struct mmp_struct *mmp; ext4_fsblk_t mmp_block; - u32 seq = 0; + u32 seq; unsigned long failed_writes = 0; int mmp_update_interval = le16_to_cpu(es->s_mmp_update_interval); unsigned mmp_check_interval; @@ -143,6 +143,7 @@ static int kmmpd(void *data) mmp_block = le64_to_cpu(es->s_mmp_block); mmp = (struct mmp_struct *)(bh->b_data); mmp->mmp_time = cpu_to_le64(ktime_get_real_seconds()); + seq = le32_to_cpu(mmp->mmp_seq); /* * Start with the higher mmp_check_interval and reduce it if * the MMP block is being updated on time. From patchwork Tue Oct 19 06:49:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "yebin (H)" X-Patchwork-Id: 1543018 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee2:21ea]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HYPDp5jLKz9sNH for ; Tue, 19 Oct 2021 17:37:30 +1100 (AEDT) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4HYPDp4yCgz4xbc for ; Tue, 19 Oct 2021 17:37:30 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4HYPDp4wM5z4xd8; Tue, 19 Oct 2021 17:37:30 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4HYPDp4skrz4xbc for ; Tue, 19 Oct 2021 17:37:30 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234234AbhJSGjl (ORCPT ); Tue, 19 Oct 2021 02:39:41 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:13953 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233540AbhJSGjk (ORCPT ); Tue, 19 Oct 2021 02:39:40 -0400 Received: from dggeme754-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HYPBj2hzxzZcR6; Tue, 19 Oct 2021 14:35:41 +0800 (CST) Received: from huawei.com (10.175.127.227) by dggeme754-chm.china.huawei.com (10.3.19.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.15; Tue, 19 Oct 2021 14:37:26 +0800 From: Ye Bin To: , , CC: , , Ye Bin Subject: [PATCH -next v3 2/5] ext4: compare to local seq and nodename when check conflict Date: Tue, 19 Oct 2021 14:49:56 +0800 Message-ID: <20211019064959.625557-3-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211019064959.625557-1-yebin10@huawei.com> References: <20211019064959.625557-1-yebin10@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggeme754-chm.china.huawei.com (10.3.19.100) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org As mmp and check_mmp is point to the same data, so there will never detect conflict. To solve this issue just compare to local data. Signed-off-by: Ye Bin Reviewed-by: Jan Kara --- fs/ext4/ext4.h | 5 ++++- fs/ext4/mmp.c | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 404dd50856e5..9a487a558787 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2601,6 +2601,8 @@ struct ext4_features { #define EXT4_MMP_SEQ_FSCK 0xE24D4D50U /* mmp_seq value when being fscked */ #define EXT4_MMP_SEQ_MAX 0xE24D4D4FU /* maximum valid mmp_seq value */ +#define EXT4_MMP_NODENAME_LEN 64 /* mmp_nodename length */ + struct mmp_struct { __le32 mmp_magic; /* Magic number for MMP */ __le32 mmp_seq; /* Sequence no. updated periodically */ @@ -2610,7 +2612,8 @@ struct mmp_struct { * purposes and do not affect the correctness of the algorithm */ __le64 mmp_time; /* Time last updated */ - char mmp_nodename[64]; /* Node which last updated MMP block */ + /* Node which last updated MMP block */ + char mmp_nodename[EXT4_MMP_NODENAME_LEN]; char mmp_bdevname[32]; /* Bdev which last updated MMP block */ /* diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c index 11627ff002d3..4af8b99ade84 100644 --- a/fs/ext4/mmp.c +++ b/fs/ext4/mmp.c @@ -138,6 +138,7 @@ static int kmmpd(void *data) unsigned mmp_check_interval; unsigned long last_update_time; unsigned long diff; + char nodename[EXT4_MMP_NODENAME_LEN]; int retval = 0; mmp_block = le64_to_cpu(es->s_mmp_block); @@ -154,8 +155,8 @@ static int kmmpd(void *data) BUILD_BUG_ON(sizeof(mmp->mmp_bdevname) < BDEVNAME_SIZE); bdevname(bh->b_bdev, mmp->mmp_bdevname); - memcpy(mmp->mmp_nodename, init_utsname()->nodename, - sizeof(mmp->mmp_nodename)); + memcpy(nodename, init_utsname()->nodename, sizeof(nodename)); + memcpy(mmp->mmp_nodename, nodename, sizeof(mmp->mmp_nodename)); while (!kthread_should_stop() && !sb_rdonly(sb)) { if (!ext4_has_feature_mmp(sb)) { @@ -207,8 +208,8 @@ static int kmmpd(void *data) } mmp_check = (struct mmp_struct *)(bh_check->b_data); - if (mmp->mmp_seq != mmp_check->mmp_seq || - memcmp(mmp->mmp_nodename, mmp_check->mmp_nodename, + if (seq != mmp_check->mmp_seq || + memcmp(nodename, mmp_check->mmp_nodename, sizeof(mmp->mmp_nodename))) { dump_mmp_msg(sb, mmp_check, "Error while updating MMP info. " From patchwork Tue Oct 19 06:49:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "yebin (H)" X-Patchwork-Id: 1543022 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee2:21ea]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HYPDw57t2z9sNH for ; Tue, 19 Oct 2021 17:37:36 +1100 (AEDT) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee2:21ea]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4HYPDw4SmMz4xbc for ; Tue, 19 Oct 2021 17:37:36 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4HYPDw4Qb2z4xd8; Tue, 19 Oct 2021 17:37:36 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4HYPDw4N8zz4xbc for ; Tue, 19 Oct 2021 17:37:36 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234308AbhJSGjr (ORCPT ); Tue, 19 Oct 2021 02:39:47 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:25232 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233888AbhJSGjl (ORCPT ); Tue, 19 Oct 2021 02:39:41 -0400 Received: from dggeme754-chm.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4HYPCK6Gb4z8thv; Tue, 19 Oct 2021 14:36:13 +0800 (CST) Received: from huawei.com (10.175.127.227) by dggeme754-chm.china.huawei.com (10.3.19.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.15; Tue, 19 Oct 2021 14:37:26 +0800 From: Ye Bin To: , , CC: , , Ye Bin Subject: [PATCH -next v3 3/5] ext4: get buffer head before read_mmp_block Date: Tue, 19 Oct 2021 14:49:57 +0800 Message-ID: <20211019064959.625557-4-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211019064959.625557-1-yebin10@huawei.com> References: <20211019064959.625557-1-yebin10@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggeme754-chm.china.huawei.com (10.3.19.100) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org There is only pass NULL 'bh' in ext4_multi_mount_protect, So just call sb_getblk get buffer head fisrt, and we will simplify read_mmp_block function. Signed-off-by: Ye Bin Reviewed-by: Jan Kara --- fs/ext4/mmp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c index 4af8b99ade84..6ac6aacd8fa5 100644 --- a/fs/ext4/mmp.c +++ b/fs/ext4/mmp.c @@ -295,6 +295,10 @@ int ext4_multi_mount_protect(struct super_block *sb, goto failed; } + bh = sb_getblk(sb, mmp_block); + if (bh) + goto failed; + retval = read_mmp_block(sb, &bh, mmp_block); if (retval) goto failed; From patchwork Tue Oct 19 06:49:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "yebin (H)" X-Patchwork-Id: 1543021 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HYPDv4pslz9sNH for ; Tue, 19 Oct 2021 17:37:35 +1100 (AEDT) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee2:21ea]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4HYPDv42gyz4xd8 for ; Tue, 19 Oct 2021 17:37:35 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4HYPDv41Bwz4xd9; Tue, 19 Oct 2021 17:37:35 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4HYPDv3xN3z4xd8 for ; Tue, 19 Oct 2021 17:37:35 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234268AbhJSGjn (ORCPT ); Tue, 19 Oct 2021 02:39:43 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:25233 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233986AbhJSGjl (ORCPT ); Tue, 19 Oct 2021 02:39:41 -0400 Received: from dggeme754-chm.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4HYPCL2QN0z8tm8; Tue, 19 Oct 2021 14:36:14 +0800 (CST) Received: from huawei.com (10.175.127.227) by dggeme754-chm.china.huawei.com (10.3.19.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.15; Tue, 19 Oct 2021 14:37:26 +0800 From: Ye Bin To: , , CC: , , Ye Bin Subject: [PATCH -next v3 4/5] ext4: simplify read_mmp_block fucntion Date: Tue, 19 Oct 2021 14:49:58 +0800 Message-ID: <20211019064959.625557-5-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211019064959.625557-1-yebin10@huawei.com> References: <20211019064959.625557-1-yebin10@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggeme754-chm.china.huawei.com (10.3.19.100) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org This patch is according to Jan Kara's suggestion: I guess I would just get rid of sb_getblk() in read_mmp_block() and always expect valid bh passed. The only place that passes NULL bh after this patch is one case in ext4_multi_mount_protect() and that can call sb_getblk() on its own. That way we can also simplify read_mmp_block() prototype to: static int read_mmp_block(struct super_block *sb, struct buffer_head *bh); Signed-off-by: Ye Bin Reported-by: kernel test robot --- fs/ext4/mmp.c | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c index 6ac6aacd8fa5..61c765c249b9 100644 --- a/fs/ext4/mmp.c +++ b/fs/ext4/mmp.c @@ -64,33 +64,26 @@ static int write_mmp_block(struct super_block *sb, struct buffer_head *bh) /* * Read the MMP block. It _must_ be read from disk and hence we clear the * uptodate flag on the buffer. + * Caller must ensure pass valid 'bh'. */ -static int read_mmp_block(struct super_block *sb, struct buffer_head **bh, - ext4_fsblk_t mmp_block) +static int read_mmp_block(struct super_block *sb, struct buffer_head *bh) { struct mmp_struct *mmp; int ret; - if (*bh) - clear_buffer_uptodate(*bh); - - /* This would be sb_bread(sb, mmp_block), except we need to be sure - * that the MD RAID device cache has been bypassed, and that the read - * is not blocked in the elevator. */ - if (!*bh) { - *bh = sb_getblk(sb, mmp_block); - if (!*bh) { - ret = -ENOMEM; - goto warn_exit; - } + if (!bh) { + ret = -EINVAL; + goto warn_exit; } - lock_buffer(*bh); - ret = ext4_read_bh(*bh, REQ_META | REQ_PRIO, NULL); + clear_buffer_uptodate(bh); + + lock_buffer(bh); + ret = ext4_read_bh(bh, REQ_META | REQ_PRIO, NULL); if (ret) goto warn_exit; - mmp = (struct mmp_struct *)((*bh)->b_data); + mmp = (struct mmp_struct *)((bh)->b_data); if (le32_to_cpu(mmp->mmp_magic) != EXT4_MMP_MAGIC) { ret = -EFSCORRUPTED; goto warn_exit; @@ -101,10 +94,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh, } return 0; warn_exit: - brelse(*bh); - *bh = NULL; - ext4_warning(sb, "Error %d while reading MMP block %llu", - ret, mmp_block); + ext4_warning(sb, "Error %d while reading MMP block", ret); return ret; } @@ -199,7 +189,7 @@ static int kmmpd(void *data) struct buffer_head *bh_check = NULL; struct mmp_struct *mmp_check; - retval = read_mmp_block(sb, &bh_check, mmp_block); + retval = read_mmp_block(sb, bh_check); if (retval) { ext4_error_err(sb, -retval, "error reading MMP data: %d", @@ -299,7 +289,7 @@ int ext4_multi_mount_protect(struct super_block *sb, if (bh) goto failed; - retval = read_mmp_block(sb, &bh, mmp_block); + retval = read_mmp_block(sb, bh); if (retval) goto failed; @@ -337,7 +327,7 @@ int ext4_multi_mount_protect(struct super_block *sb, goto failed; } - retval = read_mmp_block(sb, &bh, mmp_block); + retval = read_mmp_block(sb, bh); if (retval) goto failed; mmp = (struct mmp_struct *)(bh->b_data); @@ -366,7 +356,7 @@ int ext4_multi_mount_protect(struct super_block *sb, goto failed; } - retval = read_mmp_block(sb, &bh, mmp_block); + retval = read_mmp_block(sb, bh); if (retval) goto failed; mmp = (struct mmp_struct *)(bh->b_data); From patchwork Tue Oct 19 06:49:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "yebin (H)" X-Patchwork-Id: 1543023 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee2:21ea]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HYPDy2NYCz9sNH for ; Tue, 19 Oct 2021 17:37:38 +1100 (AEDT) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee2:21ea]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4HYPDy1DYHz4xbc for ; Tue, 19 Oct 2021 17:37:38 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4HYPDy1BrKz4xd8; Tue, 19 Oct 2021 17:37:38 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4HYPDy17JLz4xbc for ; Tue, 19 Oct 2021 17:37:38 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234310AbhJSGjs (ORCPT ); Tue, 19 Oct 2021 02:39:48 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:13954 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234178AbhJSGjl (ORCPT ); Tue, 19 Oct 2021 02:39:41 -0400 Received: from dggeme754-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HYPBk4ZH1zZcNP; Tue, 19 Oct 2021 14:35:42 +0800 (CST) Received: from huawei.com (10.175.127.227) by dggeme754-chm.china.huawei.com (10.3.19.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.15; Tue, 19 Oct 2021 14:37:27 +0800 From: Ye Bin To: , , CC: , , Ye Bin Subject: [PATCH -next v3 5/5] ext4: avoid to re-read mmp check data get from page cache Date: Tue, 19 Oct 2021 14:49:59 +0800 Message-ID: <20211019064959.625557-6-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211019064959.625557-1-yebin10@huawei.com> References: <20211019064959.625557-1-yebin10@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggeme754-chm.china.huawei.com (10.3.19.100) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org As call read_mmp_block pass bh_check which value is NULL, then call sb_getblk to get buffer_head. But mmp_block's buffer_head is already exist which also is uptodate. Lead to compare the same data. Signed-off-by: Ye Bin Reviewed-by: Jan Kara --- fs/ext4/mmp.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c index 61c765c249b9..8018f6fb6ac2 100644 --- a/fs/ext4/mmp.c +++ b/fs/ext4/mmp.c @@ -186,10 +186,7 @@ static int kmmpd(void *data) */ diff = jiffies - last_update_time; if (diff > mmp_check_interval * HZ) { - struct buffer_head *bh_check = NULL; - struct mmp_struct *mmp_check; - - retval = read_mmp_block(sb, bh_check); + retval = read_mmp_block(sb, bh); if (retval) { ext4_error_err(sb, -retval, "error reading MMP data: %d", @@ -197,20 +194,18 @@ static int kmmpd(void *data) goto wait_to_exit; } - mmp_check = (struct mmp_struct *)(bh_check->b_data); - if (seq != mmp_check->mmp_seq || - memcmp(nodename, mmp_check->mmp_nodename, - sizeof(mmp->mmp_nodename))) { - dump_mmp_msg(sb, mmp_check, + mmp = (struct mmp_struct *)(bh->b_data); + if (seq != le32_to_cpu(mmp->mmp_seq) || + memcmp(nodename, mmp->mmp_nodename, + sizeof(nodename))) { + dump_mmp_msg(sb, mmp, "Error while updating MMP info. " "The filesystem seems to have been" " multiply mounted."); ext4_error_err(sb, EBUSY, "abort"); - put_bh(bh_check); retval = -EBUSY; goto wait_to_exit; } - put_bh(bh_check); } /*