Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp628067pxb; Wed, 22 Sep 2021 09:25:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxR3AcmycbbMsCgtvx2GiYhlallX4BhhDUbSrm3EuFwAS0w0uhZltfVL0rC+YNvbri++ZAt X-Received: by 2002:a17:907:20cb:: with SMTP id qq11mr460310ejb.488.1632327935126; Wed, 22 Sep 2021 09:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632327935; cv=none; d=google.com; s=arc-20160816; b=b6ipvoZ0myUC0vpJd8gaEcNe/NgUhwNwTCxpbHilwovEqGWZ2qTt1Z08fkg+SptLjY H9cjZ1f4gVDG5Jb4F5F9WLD3OGDXU+0nSu1SDBCPLIg0sKodWsntUBEo6y+oC8ciGfye s/EntRQ2a4A7/JlxQgut2GxQQoS8hYMLk9VS02pGUH6UhfO/RibrHbSYl52XPdL5wrdz FCd165DkK+kD/UOAbFelApQcTWNQ2cfa5xZ4Nh4XVyhioM5OmMdhomxOkEpW3uCIakEw tWgR8toexcBNF/3/c4H0MNf/WfJUZ8k0QsM/Vic/usrQuxH56mLDYest4/VbkDD39E6D Im2A== 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=nzKgLZFLmGFZYS2r/7vIgqQggi3AOg3FFmnvTlnlJhc=; b=GpZgLSmb1D2vZNqL0QcC7nj1mynaKUQ//W99XlPL1HagImX0QUl2ODG9wpUO8k4YgY 8WES7tL6ZPUhbY+PKZls6YgxUDNboHog0lINtljfP3dLsAak7fEZ3oGsz3uOdVX3DOXb KAzj4+oIDPfln/8nlg+60sAbC+lv4xsip8JsfBP8ouubsKVGjn/gIPBGbzYKeLPhHfTU wiStzcg+OvTdHiKNzLCvX7UUidVFjzTskluuAWvuZzU8HQ3MtEhx1f8a4esShYw5bcvL imGnLASJYAA7WO4v75hCsq0T45mHC/LFi4v4zPUUmVrGy9WT/Lgu6VxpsCpyvaatP7nj RVsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=onjZzTDy; 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 m15si3132759edp.413.2021.09.22.09.25.06; Wed, 22 Sep 2021 09:25:35 -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=onjZzTDy; 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 S236565AbhIVQW1 (ORCPT + 99 others); Wed, 22 Sep 2021 12:22:27 -0400 Received: from relayfre-01.paragon-software.com ([176.12.100.13]:44232 "EHLO relayfre-01.paragon-software.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232357AbhIVQWV (ORCPT ); Wed, 22 Sep 2021 12:22:21 -0400 Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 1DFEA1D1D; Wed, 22 Sep 2021 19:20:50 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1632327650; bh=nzKgLZFLmGFZYS2r/7vIgqQggi3AOg3FFmnvTlnlJhc=; h=Date:Subject:From:To:References:CC:In-Reply-To; b=onjZzTDyL0/JYnwFmb6j5Igko0laCFI2LEcWix9BakDuq+PKLclBFcDszct9/ToUr /5zltobvGc83nC/HBaLvz7qvAK5SDU562CchPRnkWratl0eFLad/thLgf6yE6Q+aW1 L/6CztogpUS7qTwQ03UdOvQF7zEghz0Y0bwLnXXM= Received: from [192.168.211.195] (192.168.211.195) 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; Wed, 22 Sep 2021 19:20:49 +0300 Message-ID: Date: Wed, 22 Sep 2021 19:20:49 +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 5/5] fs/ntfs3: Refactoring lock in ntfs_init_acl Content-Language: en-US From: Konstantin Komarov To: References: <2771ff62-e612-a8ed-4b93-5534c26aef9e@paragon-software.com> CC: , In-Reply-To: <2771ff62-e612-a8ed-4b93-5534c26aef9e@paragon-software.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.211.195] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) 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. 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