From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 847F8C43334 for ; Sat, 18 Jun 2022 08:38:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229876AbiFRIij (ORCPT ); Sat, 18 Jun 2022 04:38:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbiFRIiY (ORCPT ); Sat, 18 Jun 2022 04:38:24 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C367D1F2C9; Sat, 18 Jun 2022 01:38:21 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LQ8Q922J8zhXYF; Sat, 18 Jun 2022 16:36:17 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 18 Jun 2022 16:38:19 +0800 From: Miaohe Lin To: , CC: , , , Subject: [PATCH] filemap: obey mapping->invalidate_lock lock/unlock order Date: Sat, 18 Jun 2022 16:38:20 +0800 Message-ID: <20220618083820.35626-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The invalidate_locks of two mappings should be unlocked in reverse order relative to the locking order in filemap_invalidate_lock_two(). Modifying the code to obey it. Signed-off-by: Miaohe Lin --- mm/filemap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index 8ef861297ffb..9948b26e6400 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1009,6 +1009,8 @@ EXPORT_SYMBOL(filemap_invalidate_lock_two); void filemap_invalidate_unlock_two(struct address_space *mapping1, struct address_space *mapping2) { + if (mapping1 < mapping2) + swap(mapping1, mapping2); if (mapping1) up_write(&mapping1->invalidate_lock); if (mapping2 && mapping1 != mapping2) -- 2.23.0