From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, 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 3BF4AC43219 for ; Tue, 30 Apr 2019 12:07:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 01F562075E for ; Tue, 30 Apr 2019 12:07:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556626071; bh=1v3inFiLJzSCitqpL2LAc8O+IpCjNakfSNz/Xoc3Gdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=pX4IYR7dv9Ooszyu/1vS9tbTyrbtKu6bjviU538e/qEie13/kS53/T4NTlO1n5H6c aoT/ZulU8Ra8OTxlT+5KVeOseN9dx4dGbiotvoVB93PuL7vp5LRDaVGmDJjxhNjVoC 8RM5FDJ9pMtZ6Nk5JSgYuUkeisnYpoRwaDlniRWo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728417AbfD3LkW (ORCPT ); Tue, 30 Apr 2019 07:40:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:46588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728408AbfD3LkV (ORCPT ); Tue, 30 Apr 2019 07:40:21 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B061B2177B; Tue, 30 Apr 2019 11:40:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556624421; bh=1v3inFiLJzSCitqpL2LAc8O+IpCjNakfSNz/Xoc3Gdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ct2IG2aBPHUM+FgmSMZSnbSmAj6skz3yseulXh2fA4yeBEJyKhaVbDGCMHReuv7Dd R4Rgnr7KLLYTJu14Wp2niXY3sUluHLScSEQHjEPl27ru3bo28XP2bP3Kh6FKqoovYG sazh+ySQeLt5UdKb2egbaF2Pblv9i6fQWJoCFCTg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeff Layton , "Yan, Zheng" , Ilya Dryomov Subject: [PATCH 4.9 08/41] ceph: ensure d_name stability in ceph_dentry_hash() Date: Tue, 30 Apr 2019 13:38:19 +0200 Message-Id: <20190430113526.560682600@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190430113524.451237916@linuxfoundation.org> References: <20190430113524.451237916@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jeff Layton commit 76a495d666e5043ffc315695f8241f5e94a98849 upstream. Take the d_lock here to ensure that d_name doesn't change. Cc: stable@vger.kernel.org Signed-off-by: Jeff Layton Reviewed-by: "Yan, Zheng" Signed-off-by: Ilya Dryomov Signed-off-by: Greg Kroah-Hartman --- fs/ceph/dir.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -1471,6 +1471,7 @@ void ceph_dentry_lru_del(struct dentry * unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn) { struct ceph_inode_info *dci = ceph_inode(dir); + unsigned hash; switch (dci->i_dir_layout.dl_dir_hash) { case 0: /* for backward compat */ @@ -1478,8 +1479,11 @@ unsigned ceph_dentry_hash(struct inode * return dn->d_name.hash; default: - return ceph_str_hash(dci->i_dir_layout.dl_dir_hash, + spin_lock(&dn->d_lock); + hash = ceph_str_hash(dci->i_dir_layout.dl_dir_hash, dn->d_name.name, dn->d_name.len); + spin_unlock(&dn->d_lock); + return hash; } }