Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp7326455rwl; Thu, 23 Mar 2023 02:47:05 -0700 (PDT) X-Google-Smtp-Source: AK7set9XU2e05LETdrHSugOW+JbKLT6KmDyaiy9iPAM45BLW/R5t2PdGj05GFO0jfPd8k6EGqbHh X-Received: by 2002:aa7:842c:0:b0:624:3061:7dbf with SMTP id q12-20020aa7842c000000b0062430617dbfmr6653040pfn.25.1679564825063; Thu, 23 Mar 2023 02:47:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679564825; cv=none; d=google.com; s=arc-20160816; b=RDQ+Quavy0aSL5ybfRarAz1juTeFEqIOHut0TexT7mOEPghtPchAOsAXm7K6YGBNg3 n9QKVm2dZ8sN13g4A0j9QHnw581vAFRaXZqyVwrTDup7blhvnhHlhtijS/thCbCOu+PI KCZw+APNnBzmfxv0+p9xf4X8Q/gSmUWsrpeVS1/zXz2SJUDtLxYwlX/oeez5H2vNOnm2 jHlmCCStcl5aGbXZk4iD4OOWkq/t6JfCZ0WLFFqniwmyjfMjylZOK/cEjj8375nVWMNY lCkk7i0Hd8QU6/p/6Sq7zp2AQKeDYnozowkUXH0mjQBhDyULLbCXU/mkHNQ5xyWA/Ioo HHAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=Xnj4Y7EBHNaL0eUpvowUJ11WSVF8uF2ZvPTW6OeR87w=; b=BBrPmNpEp6NE0ckJ7J6uZQKaPib9Nj+h3d/pzbvLb81uF0B9niplJcTRYPXs/Ii+Vn gL4JDv0Uqj+gkgTcHVl+kldZdrwPFM6RuDto1UDsS2tRljaL//2YQ7OnH1WWc1hzoIc1 syR1vlc69W+djsPzf2/YGpETe+WyadAEn64yX+p0bRr+8Dz/pzLFWpjvgdrF0ihBKnWk MdWbuSCNzMXyAnnBSYriOYjAD1jciSep+A8Wdlg5kY2ubEm9DY8EqwlAHnaW9JSsrjT4 F5Ay1F1ICk9UMgOEHc+TZYVEKNYBPMHk84HqkFnJLQmPV7r6SF6nU+cbQWM+Be1yXnb/ S04g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z31-20020a630a5f000000b0050b30b20470si17684546pgk.82.2023.03.23.02.46.53; Thu, 23 Mar 2023 02:47:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230050AbjCWJmb (ORCPT + 99 others); Thu, 23 Mar 2023 05:42:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231173AbjCWJm2 (ORCPT ); Thu, 23 Mar 2023 05:42:28 -0400 Received: from smtpbgau2.qq.com (smtpbgau2.qq.com [54.206.34.216]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CB751A952; Thu, 23 Mar 2023 02:42:25 -0700 (PDT) X-QQ-mid: bizesmtp81t1679564275tucju5hh Received: from localhost.localdomain ( [113.200.76.118]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 23 Mar 2023 17:37:54 +0800 (CST) X-QQ-SSF: 01400000002000B0E000B00A0000000 X-QQ-FEAT: oAZ4GxcAC/U4hZiQyDBn8H5sWH7ScPQ86jUr7hjTo2DIrIVN/YIU2iiZ1kRJw +y7k5jY/d+3MuGGGhRuStbii8CIK4GvxIim8ngThprC70S6NaorS/pRTM5wFOfqjEPqlD3H hbvBDEMwjG3OtO53qCnwE+xzU14hpgyTeAOy90CBnbGOgCFBtNPgHmono8DxpsPXhKaRHFA /McrbzMwOgtepFDmmUOlWBqeCBuSFNqCm9xqyRSi17WGJ0BSlClCmKSSFPf2z1NaJiU9Ud/ nP7ag8lJyZqesef1WuxW/pympfs9FZWBwB4uC6QTlF1mu4t78XY6hGlhd+/6iVlU4xKJG5w hRaa4F8ZtAHDNu37OGFreVYn4/wGDoIKLKWfgGKdl22VbAnSfMlKC7ntcNCCw== X-QQ-GoodBg: 2 From: gouhao@uniontech.com To: viro@zeniv.linux.org.uk, brauner@kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] fs/buffer: adjust the order of might_sleep() in __getblk_gfp() Date: Thu, 23 Mar 2023 17:37:52 +0800 Message-Id: <20230323093752.17461-1-gouhao@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybglogicsvr:qybglogicsvr7 X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gou Hao If 'bh' is found in cache, just return directly. might_sleep() is only required on slow paths. Signed-off-by: Gou Hao --- fs/buffer.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 9e1e2add541e..e13eff504fb5 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1371,10 +1371,11 @@ __getblk_gfp(struct block_device *bdev, sector_t block, { struct buffer_head *bh = __find_get_block(bdev, block, size); + if (bh) + return bh; + might_sleep(); - if (bh == NULL) - bh = __getblk_slow(bdev, block, size, gfp); - return bh; + return __getblk_slow(bdev, block, size, gfp); } EXPORT_SYMBOL(__getblk_gfp); -- 2.20.1