From patchwork Thu Jul 15 10:45:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kadashev X-Patchwork-Id: 12379817 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 DFE67C47E4B for ; Thu, 15 Jul 2021 10:45:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CDCDF613BC for ; Thu, 15 Jul 2021 10:45:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241636AbhGOKsv (ORCPT ); Thu, 15 Jul 2021 06:48:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241632AbhGOKsu (ORCPT ); Thu, 15 Jul 2021 06:48:50 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8D1EC06175F; Thu, 15 Jul 2021 03:45:56 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id bu12so8609599ejb.0; Thu, 15 Jul 2021 03:45:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+MzqW1FGpWE2/HiJKOcK3CZTGi1+seN/N4XAEsKSZdc=; b=Ta4DYJlqXq9iplYXdZB3LW+xfWxJxbf+ojWnk4ZVrcXd84ag/Fbu/SPxbzZMYVdq9u m1B/bZSy1URZR/Ax6xErXeTy9AZvRa13Yk3Fe0bLFobm9YUoHdtk+0AGEw4MazaAUEil RDxuiqMdELlWptBeZ/UqpBJKYofq7dFE/fZCYOrnbEoRMcl47ziDGgWw6rBXQMTRym4f 1c+2XINzSaDHLaZCLG8t9nq71gpOBDMiK9S3vRkjVgUEfyEeJcNB1qcOaZFTxYe40XZM G6q58gk5t2qfA0srqQJ3qRT1C/Pd+T80OYFQovpVnBu9FFYl7dnssQApFfbRrAgO9fw0 BZkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+MzqW1FGpWE2/HiJKOcK3CZTGi1+seN/N4XAEsKSZdc=; b=eWsaob43jO6jRDMEHjk1PRBTdvG+rvsWc/MbAzS2C4nnDT5+4yVMbXb0ZMUMQ+a/2u uqlLKgNBZbAmTD+D5QHXMnkSEGm48x8W636jQjJeCb5zIIdxOeEYT/0aXKDBI8HxwDx5 md3gN5qcXzSc56Mu8MkLe1MvD6KdoWiISy1QnXkaHBCPPFsDM980+OMINwqsrgPKVbHr H9poPbjcnTC0o3vvglYc03HLFY/0pX7hXR8dRL3UuEQRzQ+LmL2nHLRzkSL76x5SIsps PZjdePZDsuGJCBKZFddqxAVd/gXN4RLcOtBHM4cG4GcChSdmmpx9iHWO5k/0244x2Zgn DykA== X-Gm-Message-State: AOAM533ZBYBdr5gt+Sl4JkRF8V9wU+zwlgvW8wN4GTXfb5hCdmRW0FXZ /4T+6rjhquBcdTIibEmOFfQ= X-Google-Smtp-Source: ABdhPJwKAto5nuGVQO3oSTP04S00UvJ90twAOWO1Y4Yf99C85d1mqBznvk6XlmbXUvtcF70tSp35Pw== X-Received: by 2002:a17:906:c7d6:: with SMTP id dc22mr4882611ejb.517.1626345955384; Thu, 15 Jul 2021 03:45:55 -0700 (PDT) Received: from carbon.v ([108.61.166.58]) by smtp.googlemail.com with ESMTPSA id d19sm2231498eds.54.2021.07.15.03.45.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 03:45:55 -0700 (PDT) From: Dmitry Kadashev To: Jens Axboe , Alexander Viro , Christian Brauner , Linus Torvalds Cc: linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Dmitry Kadashev Subject: [PATCH v2 05/14] namei: prepare do_mkdirat for refactoring Date: Thu, 15 Jul 2021 17:45:27 +0700 Message-Id: <20210715104536.3598130-6-dkadashev@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210715104536.3598130-1-dkadashev@gmail.com> References: <20210715104536.3598130-1-dkadashev@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This is just a preparation for the move of the main mkdirat logic to a separate function to make the logic easier to follow. This change contains the flow changes so that the actual change to move the main logic to a separate function does no change the flow at all. Just like the similar patches for rmdir and unlink a few commits before, there two changes here: 1. Previously on filename_create() error the function used to exit immediately, and now it will check the return code to see if ESTALE retry is appropriate. The filename_create() does its own retries on ESTALE (at least via filename_parentat() used inside), but this extra check should be completely fine. 2. The retry_estale() check is wrapped in unlikely(). Some other places already have that and overall it seems to make sense Cc: Linus Torvalds Cc: Al Viro Cc: Christian Brauner Suggested-by: Linus Torvalds Link: https://lore.kernel.org/io-uring/CAHk-=wijsw1QSsQHFu_6dEoZEr_zvT7++WJWohcuEkLqqXBGrQ@mail.gmail.com/ Link: https://lore.kernel.org/io-uring/CAHk-=wjFd0qn6asio=zg7zUTRmSty_TpAEhnwym1Qb=wFgCKzA@mail.gmail.com/ Signed-off-by: Dmitry Kadashev --- fs/namei.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 703cce40d597..54dbd1e38298 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3861,7 +3861,7 @@ int do_mkdirat(int dfd, struct filename *name, umode_t mode) dentry = __filename_create(dfd, name, &path, lookup_flags); error = PTR_ERR(dentry); if (IS_ERR(dentry)) - goto out_putname; + goto out; if (!IS_POSIXACL(path.dentry->d_inode)) mode &= ~current_umask(); @@ -3873,11 +3873,11 @@ int do_mkdirat(int dfd, struct filename *name, umode_t mode) mode); } done_path_create(&path, dentry); - if (retry_estale(error, lookup_flags)) { +out: + if (unlikely(retry_estale(error, lookup_flags))) { lookup_flags |= LOOKUP_REVAL; goto retry; } -out_putname: putname(name); return error; }