Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp697890pxb; Thu, 23 Sep 2021 08:51:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCSR0WLzv+TtAFhm4OtmmqHzO5OlGb+WrGMhvPfl6GIgp+goCsiQcA8n+xTPC9mMTCM8pg X-Received: by 2002:a50:e108:: with SMTP id h8mr6195145edl.42.1632412280135; Thu, 23 Sep 2021 08:51:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632412280; cv=none; d=google.com; s=arc-20160816; b=SxD3tDbgj2Xl6U7Ie7mCutlIzEKqrvXmjrS+poR2CM6fkAoF7nTluR6pt1OiL+D8M5 3WfRXpHiUQqZG7JRve4Lir8MgkU0aXhQlBok0g4/HlzsxUZ6xHS7EriEhjjcmDTa39cD 2JgTLEA6N1zgz1zQ+tTDmhYyPXsC3p/8JK1EVC2GKQlS83dGJNDB0zelofoEHZdzMXyJ Hze5HxTC32PEzcH7cXBCDAxLdG4nMtscFQRbE71UD9Gru41hjRGCna/rj0ukRbqVfatG Fs0Ya76mlJvUOLC5jY6mwU1FhgDmatg20x4yFqNelJDzeyGkso0g1RCjBvItr1mUv785 4nMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:cc :references:to:from:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=1Rg2zXZ/vgixRrUZ0go+XppCVTwHrFXwMt2I9sXaE38=; b=a9t807K3+qdrNPEjJRbYzYD67p4ZFEdF6EEOUyOVKMavuC4//ShYxtd/x0iAEZPS70 cb6X7iW/DvYhzbTGBWzPDGy+WQaWl7K2Ta8GPfnVqarSW9TFHcelgF6OEoYGiMmYOjS2 VERrTHK33GhOLfCsi/rKldV2t/R8a3hS+DGH/QKyXoJqPgxTOA+C5zVMJczvWb0ggh5u nrxni9283CsW1E+iz8WJUQrGlK6RYifNQmbdbRsT1H1u/CFcP/90cnF99eFsLFwjmqhl 4f80rC+Ikt0OhEM+GVMzSdQpmipSNy2X1ODvJHLxr8FpUCnp7Mo3BBtJDHK1NeW9SQc7 gHpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=H7Y1VQG4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m27si6590154ejn.5.2021.09.23.08.50.50; Thu, 23 Sep 2021 08:51:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=H7Y1VQG4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242155AbhIWPuk (ORCPT + 99 others); Thu, 23 Sep 2021 11:50:40 -0400 Received: from relaydlg-01.paragon-software.com ([81.5.88.159]:40508 "EHLO relaydlg-01.paragon-software.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242016AbhIWPsU (ORCPT ); Thu, 23 Sep 2021 11:48:20 -0400 Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relaydlg-01.paragon-software.com (Postfix) with ESMTPS id A7DFA82255; Thu, 23 Sep 2021 18:45:44 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1632411944; bh=1Rg2zXZ/vgixRrUZ0go+XppCVTwHrFXwMt2I9sXaE38=; h=Date:Subject:From:To:References:CC:In-Reply-To; b=H7Y1VQG4nfpOb2qXJVQVZXs/x7vb9PI2NnD363MYSKG/mxYaylCn4lpFS0m/lqcXc FhVOtOZRN4hv7INYOOJfSu5nF3pMn7lhoi5gwzvCx9UnuigzCVOA7gNakFsq1xARSy 69bhEfKSbLPWBXCoGcjULONIiW9VRBjK9WZkerag= Received: from [192.168.211.73] (192.168.211.73) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 23 Sep 2021 18:45:44 +0300 Message-ID: <894082b3-16c2-d9bd-13c3-476c0a80308a@paragon-software.com> Date: Thu, 23 Sep 2021 18:45:43 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.1 Subject: [PATCH v2 6/6] fs/ntfs3: Refactoring lock in ntfs_init_acl Content-Language: en-US From: Konstantin Komarov To: References: CC: , In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.211.73] X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is possible because of moving lock into ntfs_create_inode. Reviewed-by: Kari Argillander Signed-off-by: Konstantin Komarov --- fs/ntfs3/xattr.c | 55 ++++++++++++------------------------------------ 1 file changed, 14 insertions(+), 41 deletions(-) diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index 59ec5e61a239..83bbee277e12 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -693,54 +693,27 @@ int ntfs_init_acl(struct user_namespace *mnt_userns, struct inode *inode, struct posix_acl *default_acl, *acl; int err; - /* - * TODO: Refactoring lock. - * ni_lock(dir) ... -> posix_acl_create(dir,...) -> ntfs_get_acl -> ni_lock(dir) - */ - inode->i_default_acl = NULL; - - default_acl = ntfs_get_acl_ex(mnt_userns, dir, ACL_TYPE_DEFAULT, 1); - - if (!default_acl || default_acl == ERR_PTR(-EOPNOTSUPP)) { - inode->i_mode &= ~current_umask(); - err = 0; - goto out; - } - - if (IS_ERR(default_acl)) { - err = PTR_ERR(default_acl); - goto out; - } - - acl = default_acl; - err = __posix_acl_create(&acl, GFP_NOFS, &inode->i_mode); - if (err < 0) - goto out1; - if (!err) { - posix_acl_release(acl); - acl = NULL; - } - - if (!S_ISDIR(inode->i_mode)) { - posix_acl_release(default_acl); - default_acl = NULL; - } + err = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl); + if (err) + return err; - if (default_acl) + if (default_acl) { err = ntfs_set_acl_ex(mnt_userns, inode, default_acl, ACL_TYPE_DEFAULT, 1); + posix_acl_release(default_acl); + } else { + inode->i_default_acl = NULL; + } if (!acl) inode->i_acl = NULL; - else if (!err) - err = ntfs_set_acl_ex(mnt_userns, inode, acl, ACL_TYPE_ACCESS, - 1); - - posix_acl_release(acl); -out1: - posix_acl_release(default_acl); + else { + if (!err) + err = ntfs_set_acl_ex(mnt_userns, inode, acl, + ACL_TYPE_ACCESS, 1); + posix_acl_release(acl); + } -out: return err; } #endif -- 2.33.0