Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1459563ybm; Thu, 23 May 2019 01:09:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTYVT7x/StrzATHyWXuwHAVuLLYrmgSnPA9wjt+ES/e5TFGJI3YZcP2jgOXGO7Djlyf8pi X-Received: by 2002:a63:c94f:: with SMTP id y15mr32200107pgg.159.1558598947493; Thu, 23 May 2019 01:09:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558598947; cv=none; d=google.com; s=arc-20160816; b=suiLYRerSZ1iKiARWQ1FLVNIz1jr/bCXEg9y0tWEEkS4fx8yS6cr5nJJGm2Ce0Xe1R LnN8wyzcLU8JoGE0YCP7EqBHUd3fxPlz6k+TYMQ4w+j8HgaPzEdIPh2N8diNjvx657NM lc5yc5s4736izpAoIOmdu1+qa5XBa39KT2nHeOSoQc6r5rbDzpc8hqK2g7/mODB8M2pV Z/zLT+X1dmxQqgWd1fexlWDtNXh0jTVZ6udI44dNex/6kZDP2X0541HMvIod+ok8Q+Mk 2YRQlvPUptlohzo3WnA6ELZNE4gESumj9nWCTIagAWteCPdWU6+SqjUISCNrr1T2Kgzq yx5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=h4NeuRvkL7UL6LScf3plYLA+ODTp/El/ZpUPMn8+eNc=; b=FY7tZiopYakWcsZZ1plU9d+/ekn2xx4hzfKQ0WvPU0eUW6GKjtD/EkdXdV4oXF82BG 7Vm/wwQS679bN+SXQDtJjqxQUI1Hw8dWN8qc797bVlcXjayOfxJLkteN5oqHyrBJe4gk yXv7CUmN+d/8oqg9td/7kT5rly99h4wvm/88EGaMq+2MxhBd+/v4BsTzAk448IqnjPj4 flJhwVoe5yR4+0uE08wg1uvrKXWZgTPJjfbrQzRyoT5k7Vz8DT4om5wz1m1IYrgYJPiM aoO5EwiSojpqJRjuCYXLA5EtmXmJ2MMkFS/yozQmxAh592LbK/W3UGFM5iPIoyEM5PXE Fehg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9si30813156pgu.189.2019.05.23.01.08.51; Thu, 23 May 2019 01:09:07 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730150AbfEWIHJ (ORCPT + 99 others); Thu, 23 May 2019 04:07:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40328 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726222AbfEWIHI (ORCPT ); Thu, 23 May 2019 04:07:08 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 853AF3DBC5 for ; Thu, 23 May 2019 08:07:07 +0000 (UTC) Received: from zhyan-laptop.redhat.com (ovpn-12-163.pek2.redhat.com [10.72.12.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id 870D017D34; Thu, 23 May 2019 08:07:05 +0000 (UTC) From: "Yan, Zheng" To: linux-kernel@vger.kernel.org Cc: idryomov@redhat.com, jlayton@redhat.com Subject: [PATCH 7/8] ceph: ensure d_name/d_parent stability in ceph_mdsc_lease_send_msg() Date: Thu, 23 May 2019 16:06:45 +0800 Message-Id: <20190523080646.19632-7-zyan@redhat.com> In-Reply-To: <20190523080646.19632-1-zyan@redhat.com> References: <20190523080646.19632-1-zyan@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 23 May 2019 08:07:07 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: "Yan, Zheng" --- fs/ceph/dir.c | 7 +++---- fs/ceph/mds_client.c | 24 +++++++++++++----------- fs/ceph/mds_client.h | 1 - 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 1271024a3797..72efad28857c 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -1433,8 +1433,7 @@ static bool __dentry_lease_is_valid(struct ceph_dentry_info *di) return false; } -static int dentry_lease_is_valid(struct dentry *dentry, unsigned int flags, - struct inode *dir) +static int dentry_lease_is_valid(struct dentry *dentry, unsigned int flags) { struct ceph_dentry_info *di; struct ceph_mds_session *session = NULL; @@ -1466,7 +1465,7 @@ static int dentry_lease_is_valid(struct dentry *dentry, unsigned int flags, spin_unlock(&dentry->d_lock); if (session) { - ceph_mdsc_lease_send_msg(session, dir, dentry, + ceph_mdsc_lease_send_msg(session, dentry, CEPH_MDS_LEASE_RENEW, seq); ceph_put_mds_session(session); } @@ -1566,7 +1565,7 @@ static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags) ceph_snap(d_inode(dentry)) == CEPH_SNAPDIR) { valid = 1; } else { - valid = dentry_lease_is_valid(dentry, flags, dir); + valid = dentry_lease_is_valid(dentry, flags); if (valid == -ECHILD) return valid; if (valid || dir_lease_is_valid(dir, dentry)) { diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 870754e9d572..98c500dbec3f 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -3941,31 +3941,33 @@ static void handle_lease(struct ceph_mds_client *mdsc, } void ceph_mdsc_lease_send_msg(struct ceph_mds_session *session, - struct inode *inode, struct dentry *dentry, char action, u32 seq) { struct ceph_msg *msg; struct ceph_mds_lease *lease; - int len = sizeof(*lease) + sizeof(u32); - int dnamelen = 0; + struct inode *dir; + int len = sizeof(*lease) + sizeof(u32) + NAME_MAX; - dout("lease_send_msg inode %p dentry %p %s to mds%d\n", - inode, dentry, ceph_lease_op_name(action), session->s_mds); - dnamelen = dentry->d_name.len; - len += dnamelen; + dout("lease_send_msg identry %p %s to mds%d\n", + dentry, ceph_lease_op_name(action), session->s_mds); msg = ceph_msg_new(CEPH_MSG_CLIENT_LEASE, len, GFP_NOFS, false); if (!msg) return; lease = msg->front.iov_base; lease->action = action; - lease->ino = cpu_to_le64(ceph_vino(inode).ino); - lease->first = lease->last = cpu_to_le64(ceph_vino(inode).snap); lease->seq = cpu_to_le32(seq); - put_unaligned_le32(dnamelen, lease + 1); - memcpy((void *)(lease + 1) + 4, dentry->d_name.name, dnamelen); + spin_lock(&dentry->d_lock); + dir = d_inode(dentry->d_parent); + lease->ino = cpu_to_le64(ceph_inode(dir)->i_vino.ino); + lease->first = lease->last = cpu_to_le64(ceph_inode(dir)->i_vino.snap); + + put_unaligned_le32(dentry->d_name.len, lease + 1); + memcpy((void *)(lease + 1) + 4, + dentry->d_name.name, dentry->d_name.len); + spin_unlock(&dentry->d_lock); /* * if this is a preemptive lease RELEASE, no need to * flush request stream, since the actual request will diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index 9c28b86abcf4..330769ecb601 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h @@ -505,7 +505,6 @@ extern char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *base, extern void __ceph_mdsc_drop_dentry_lease(struct dentry *dentry); extern void ceph_mdsc_lease_send_msg(struct ceph_mds_session *session, - struct inode *inode, struct dentry *dentry, char action, u32 seq); -- 2.17.2