Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp91918imm; Thu, 21 Jun 2018 14:31:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI5npimCwcRGq0czKKTcNufmG5QZ4OrSwB3A3dEyxes2WZ0aO2loTdvUtCKuWSjD9eyirQl X-Received: by 2002:a17:902:bd95:: with SMTP id q21-v6mr29963202pls.237.1529616695449; Thu, 21 Jun 2018 14:31:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529616695; cv=none; d=google.com; s=arc-20160816; b=VcKgnLq7iaGtmxwdcc+lUUbf+5zNBjPpibEXpLh9nLHByeuVKtQ7iwF1f749O7E0vv ZogBcYr7K2qjDPBZbt+owPeH1glGZgP4Wir7dNH2t9Kt/fnSeE/hHgZuRlF4ug4LSUU1 c6w7pCsgULurIydScygV1qR+mIve4iqzWAUuE6xvLQBE1HIuzsLun+gr9j/rbSSKZcf4 KuA3uLfqszUShc6sknMuQLz2bKcpOD9lzQxDOEj7PAdwITEb+gq4YpYPXaR/7fA+mT68 UVAwhXSNFKdnEgi8CTcNBqws8EnHxJGdOrAA9CYl41E8l86dUEWwgnrQx/bj9NjLBkvY QH5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=wSZamsI5hfX+Sdt4UILe32NNcomypNMJ+9Y7hrsTfCM=; b=lAUor2NuGNUjXwXjB51dTiW0guYN7LmdP7LyH7fUTZmOVLE5KqqZJRjYB6C8sjtKEQ eDGj8uEur9MTxmj2MkjNY/HXiskOdE6W9yc94OF11cVbrwF7+BntkAQRoeDAZ7Ptivn4 7xqVuXrwTYPxuRKoHiCmdsdc99G+EglyOkUTSG45usFs2UCI/K0JDbEFfCiofd8PqOGR Wm8Gy2VaYil718yuZ8c1sRA4YRTsOZv9wKywkC+yj9IEUw45XX3Ud41xMOMBPb+VI2S8 ERB3258brjrrOJKsmApgWJOhUMXoqBkaM6iOaxdmHrsRPBER+a2lnPiUVKodxhcpV2zf yefg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=mNMQR+8u; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b83-v6si6212477pfk.342.2018.06.21.14.31.21; Thu, 21 Jun 2018 14:31:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=mNMQR+8u; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934005AbeFUV3N (ORCPT + 99 others); Thu, 21 Jun 2018 17:29:13 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:41748 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933933AbeFUV3I (ORCPT ); Thu, 21 Jun 2018 17:29:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=wSZamsI5hfX+Sdt4UILe32NNcomypNMJ+9Y7hrsTfCM=; b=mNMQR+8uF5m73Aw++Vj1iGJK3 Ra2PPK8MfMFAlskGA+EY6IhNdFa9RAqmsXQgg03JWmhLEROM1b9hewK3IilLJq/F28CPAG0VNYyHi b6wdoae/W+EAeHEeVik7YU88adrMwCvBC0khUgD2Sfi5AzXovF5Tnoo9wGuEfdjVm6Rq51Lj2dPTC hCTj0MNpE8T1cVBtgSRM/Rbf03nsnPRhgFW2/o8M6auPbFIiRfYfZoM8XPjrsYmAT87iCfQnPzxpK +phWUhJUF87Uvn4LKeZuLa8Jf1TRPQz+EyM9K6K91lmpT4FwbVps8JpIBNiNaiRll4dE0oOGhRz8L A9QeTLV7g==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fW78d-0001az-U4; Thu, 21 Jun 2018 21:29:07 +0000 From: Matthew Wilcox To: linux-kernel@vger.kernel.org Cc: Matthew Wilcox , Alexander Viro , linux-fsdevel@vger.kernel.org Subject: [PATCH 06/26] fs: Convert namespace IDAs to new API Date: Thu, 21 Jun 2018 14:28:15 -0700 Message-Id: <20180621212835.5636-7-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180621212835.5636-1-willy@infradead.org> References: <20180621212835.5636-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We don't need to keep track of the starting value; the IDA is efficient. Signed-off-by: Matthew Wilcox --- fs/namespace.c | 50 ++++++++++++-------------------------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 8ddd14806799..bfd33eaab5aa 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -61,9 +61,6 @@ __setup("mphash_entries=", set_mphash_entries); static u64 event; static DEFINE_IDA(mnt_id_ida); static DEFINE_IDA(mnt_group_ida); -static DEFINE_SPINLOCK(mnt_id_lock); -static int mnt_id_start = 0; -static int mnt_group_start = 1; static struct hlist_head *mount_hashtable __read_mostly; static struct hlist_head *mountpoint_hashtable __read_mostly; @@ -101,50 +98,30 @@ static inline struct hlist_head *mp_hash(struct dentry *dentry) static int mnt_alloc_id(struct mount *mnt) { - int res; + int res = ida_alloc(&mnt_id_ida, GFP_KERNEL); -retry: - ida_pre_get(&mnt_id_ida, GFP_KERNEL); - spin_lock(&mnt_id_lock); - res = ida_get_new_above(&mnt_id_ida, mnt_id_start, &mnt->mnt_id); - if (!res) - mnt_id_start = mnt->mnt_id + 1; - spin_unlock(&mnt_id_lock); - if (res == -EAGAIN) - goto retry; - - return res; + if (res < 0) + return res; + mnt->mnt_id = res; + return 0; } static void mnt_free_id(struct mount *mnt) { - int id = mnt->mnt_id; - spin_lock(&mnt_id_lock); - ida_remove(&mnt_id_ida, id); - if (mnt_id_start > id) - mnt_id_start = id; - spin_unlock(&mnt_id_lock); + ida_free(&mnt_id_ida, mnt->mnt_id); } /* * Allocate a new peer group ID - * - * mnt_group_ida is protected by namespace_sem */ static int mnt_alloc_group_id(struct mount *mnt) { - int res; + int res = ida_alloc_min(&mnt_group_ida, 1, GFP_KERNEL); - if (!ida_pre_get(&mnt_group_ida, GFP_KERNEL)) - return -ENOMEM; - - res = ida_get_new_above(&mnt_group_ida, - mnt_group_start, - &mnt->mnt_group_id); - if (!res) - mnt_group_start = mnt->mnt_group_id + 1; - - return res; + if (res < 0) + return res; + mnt->mnt_group_id = res; + return 0; } /* @@ -152,10 +129,7 @@ static int mnt_alloc_group_id(struct mount *mnt) */ void mnt_release_group_id(struct mount *mnt) { - int id = mnt->mnt_group_id; - ida_remove(&mnt_group_ida, id); - if (mnt_group_start > id) - mnt_group_start = id; + ida_free(&mnt_group_ida, mnt->mnt_group_id); mnt->mnt_group_id = 0; } -- 2.17.1