From patchwork Thu Aug 1 20:25:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 11071331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB33113A0 for ; Thu, 1 Aug 2019 20:26:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E38E2873B for ; Thu, 1 Aug 2019 20:26:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 927B02877F; Thu, 1 Aug 2019 20:26:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AFDE28779 for ; Thu, 1 Aug 2019 20:26:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726888AbfHAU0J (ORCPT ); Thu, 1 Aug 2019 16:26:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:49502 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726667AbfHAU0J (ORCPT ); Thu, 1 Aug 2019 16:26:09 -0400 Received: from tleilax.poochiereds.net (cpe-71-70-156-158.nc.res.rr.com [71.70.156.158]) (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 DAA502084C; Thu, 1 Aug 2019 20:26:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564691168; bh=T7ShJQd5gV3+K8ARj1JPvIb8bpDsUEpH5CHeVaJ3C4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GlYdY4SiYbv5QTKpf36KVHO7xCO8KkndHyXEqssInwLnzSWtvkGF1FlwKRKwcu3qB lq2MbYkpisHin96Z306M78Bg4ssVT1rTJyivyo6WIyTFf3B2Df7zys4AgLS0anoILc u3rYJAQQCPeI7drboBvUdASOg/duyGd3Cej1qD0I= From: Jeff Layton To: ceph-devel@vger.kernel.org Cc: ukernel@gmail.com, idryomov@gmail.com, sage@redhat.com, pdonnell@redhat.com Subject: [PATCH 1/9] ceph: make several helper accessors take const pointers Date: Thu, 1 Aug 2019 16:25:57 -0400 Message-Id: <20190801202605.18172-2-jlayton@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190801202605.18172-1-jlayton@kernel.org> References: <20190801202605.18172-1-jlayton@kernel.org> MIME-Version: 1.0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP None of these helper functions change anything in memory, so we can declare their arguments as const. Signed-off-by: Jeff Layton --- fs/ceph/super.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 28404b3adcd2..4cd60f58d690 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -406,22 +406,26 @@ struct ceph_inode_info { struct inode vfs_inode; /* at end */ }; -static inline struct ceph_inode_info *ceph_inode(struct inode *inode) +static inline struct ceph_inode_info * +ceph_inode(const struct inode *inode) { return container_of(inode, struct ceph_inode_info, vfs_inode); } -static inline struct ceph_fs_client *ceph_inode_to_client(struct inode *inode) +static inline struct ceph_fs_client * +ceph_inode_to_client(const struct inode *inode) { return (struct ceph_fs_client *)inode->i_sb->s_fs_info; } -static inline struct ceph_fs_client *ceph_sb_to_client(struct super_block *sb) +static inline struct ceph_fs_client * +ceph_sb_to_client(const struct super_block *sb) { return (struct ceph_fs_client *)sb->s_fs_info; } -static inline struct ceph_vino ceph_vino(struct inode *inode) +static inline struct ceph_vino +ceph_vino(const struct inode *inode) { return ceph_inode(inode)->i_vino; } From patchwork Thu Aug 1 20:25:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 11071335 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2B5513A0 for ; Thu, 1 Aug 2019 20:26:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B57E32873B for ; Thu, 1 Aug 2019 20:26:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A93532877F; Thu, 1 Aug 2019 20:26:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A4452873B for ; Thu, 1 Aug 2019 20:26:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727127AbfHAU0K (ORCPT ); Thu, 1 Aug 2019 16:26:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:49504 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726667AbfHAU0J (ORCPT ); Thu, 1 Aug 2019 16:26:09 -0400 Received: from tleilax.poochiereds.net (cpe-71-70-156-158.nc.res.rr.com [71.70.156.158]) (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 B9FF82080C; Thu, 1 Aug 2019 20:26:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564691169; bh=lg2sSncJAePQ1VLP3BBA6UWn/Xj9FgztGxLE5Q2T3ec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P6MS838FvLwxu5IRQSgaIixu38C5gAYb48lXxqmv0seVUiPgI3foktwfwZCpDlZHp IQap2m9GAxDTxkguV6rx9yUF73oZYDLTCBxjPy7fSqmryGGy0BoJBdDKeUV1nXXbQe 9tyraFCoeX62z+Q4MSaHTlEtA4znQdlN5bQLRX8g= From: Jeff Layton To: ceph-devel@vger.kernel.org Cc: ukernel@gmail.com, idryomov@gmail.com, sage@redhat.com, pdonnell@redhat.com Subject: [PATCH 2/9] ceph: hold extra reference to r_parent over life of request Date: Thu, 1 Aug 2019 16:25:58 -0400 Message-Id: <20190801202605.18172-3-jlayton@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190801202605.18172-1-jlayton@kernel.org> References: <20190801202605.18172-1-jlayton@kernel.org> MIME-Version: 1.0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, we just assume that it will stick around by virtue of the submitter's reference, but later patches will allow the syscall to return early and we can't rely on that reference at that point. Take an extra reference to the inode when setting r_parent and release it when releasing the request. Signed-off-by: Jeff Layton --- fs/ceph/mds_client.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index d3c00b417c4e..115f753e05b1 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -707,8 +707,10 @@ void ceph_mdsc_release_request(struct kref *kref) /* avoid calling iput_final() in mds dispatch threads */ ceph_async_iput(req->r_inode); } - if (req->r_parent) + if (req->r_parent) { ceph_put_cap_refs(ceph_inode(req->r_parent), CEPH_CAP_PIN); + ceph_async_iput(req->r_parent); + } ceph_async_iput(req->r_target_inode); if (req->r_dentry) dput(req->r_dentry); @@ -2669,8 +2671,10 @@ int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir, /* take CAP_PIN refs for r_inode, r_parent, r_old_dentry */ if (req->r_inode) ceph_get_cap_refs(ceph_inode(req->r_inode), CEPH_CAP_PIN); - if (req->r_parent) + if (req->r_parent) { ceph_get_cap_refs(ceph_inode(req->r_parent), CEPH_CAP_PIN); + ihold(req->r_parent); + } if (req->r_old_dentry_dir) ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir), CEPH_CAP_PIN); From patchwork Thu Aug 1 20:25:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 11071333 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3EB2F13A0 for ; Thu, 1 Aug 2019 20:26:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 309C62873B for ; Thu, 1 Aug 2019 20:26:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 243672877B; Thu, 1 Aug 2019 20:26:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6A4A2873B for ; Thu, 1 Aug 2019 20:26:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727362AbfHAU0L (ORCPT ); Thu, 1 Aug 2019 16:26:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:49510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726920AbfHAU0K (ORCPT ); Thu, 1 Aug 2019 16:26:10 -0400 Received: from tleilax.poochiereds.net (cpe-71-70-156-158.nc.res.rr.com [71.70.156.158]) (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 956C22084C; Thu, 1 Aug 2019 20:26:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564691170; bh=oPdnWw5iLQqd3ABGNQFABrtBkAYA0vsRRjE/JsBbDDE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FUtk5ag8tyhX7Z8Caw2un3VFlzULkTCzS6nIrYqvyrp/L0tJmUhGHNw0PGTyJXZmI zJKXbiiFeWXtDFnD3YlGFANEU/+cZjUKTq2cD54w0Mx6HdL5JqS0/wTRWt4aQTQ9Sg N67Pu2LK9OU8Plt5rGTfRfHy8MRomvW+R9/lA758= From: Jeff Layton To: ceph-devel@vger.kernel.org Cc: ukernel@gmail.com, idryomov@gmail.com, sage@redhat.com, pdonnell@redhat.com Subject: [PATCH 3/9] ceph: register MDS request with dir inode from the get-go Date: Thu, 1 Aug 2019 16:25:59 -0400 Message-Id: <20190801202605.18172-4-jlayton@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190801202605.18172-1-jlayton@kernel.org> References: <20190801202605.18172-1-jlayton@kernel.org> MIME-Version: 1.0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When the unsafe reply to a request comes in, we put it on the r_unsafe_dir inode's list. In future patches, we're going to need to wait on requests that may not have gotten an unsafe reply yet. Change __register_request to put the entry on the dir inode's list when the pointer is set in the request, and don't check the CEPH_MDS_R_GOT_UNSAFE flag when unregistering it. The only place that uses this list is fsync codepath, and for that we'd want to wait on all operations whether the flag is set or not. Signed-off-by: Jeff Layton --- fs/ceph/mds_client.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 115f753e05b1..89c71db77a33 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -791,8 +791,13 @@ static void __register_request(struct ceph_mds_client *mdsc, mdsc->oldest_tid = req->r_tid; if (dir) { + struct ceph_inode_info *ci = ceph_inode(dir); + ihold(dir); req->r_unsafe_dir = dir; + spin_lock(&ci->i_unsafe_lock); + list_add_tail(&req->r_unsafe_dir_item, &ci->i_unsafe_dirops); + spin_unlock(&ci->i_unsafe_lock); } } @@ -820,8 +825,7 @@ static void __unregister_request(struct ceph_mds_client *mdsc, erase_request(&mdsc->request_tree, req); - if (req->r_unsafe_dir && - test_bit(CEPH_MDS_R_GOT_UNSAFE, &req->r_req_flags)) { + if (req->r_unsafe_dir) { struct ceph_inode_info *ci = ceph_inode(req->r_unsafe_dir); spin_lock(&ci->i_unsafe_lock); list_del_init(&req->r_unsafe_dir_item); @@ -2891,14 +2895,6 @@ static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg) } else { set_bit(CEPH_MDS_R_GOT_UNSAFE, &req->r_req_flags); list_add_tail(&req->r_unsafe_item, &req->r_session->s_unsafe); - if (req->r_unsafe_dir) { - struct ceph_inode_info *ci = - ceph_inode(req->r_unsafe_dir); - spin_lock(&ci->i_unsafe_lock); - list_add_tail(&req->r_unsafe_dir_item, - &ci->i_unsafe_dirops); - spin_unlock(&ci->i_unsafe_lock); - } } dout("handle_reply tid %lld result %d\n", tid, result); From patchwork Thu Aug 1 20:26:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 11071337 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 17D871399 for ; Thu, 1 Aug 2019 20:26:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A89C2873B for ; Thu, 1 Aug 2019 20:26:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2D3C2877B; Thu, 1 Aug 2019 20:26:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9705828779 for ; Thu, 1 Aug 2019 20:26:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727528AbfHAU0N (ORCPT ); Thu, 1 Aug 2019 16:26:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:49520 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726920AbfHAU0M (ORCPT ); Thu, 1 Aug 2019 16:26:12 -0400 Received: from tleilax.poochiereds.net (cpe-71-70-156-158.nc.res.rr.com [71.70.156.158]) (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 733C22080C; Thu, 1 Aug 2019 20:26:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564691171; bh=wYlo91P18uNQg93VeUntHLaTeRzcuNYhpTby8BQNZhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GPJEgqQ8mZmn5Xd+qzaLiNbrUJhBMPRyFgCAoFYFVRhkUqIqoBR3lCmuzDpeUtxYk NK2qk44X7LyBWZfsYLjj58I+NtGJj6T06az9UtLBX4UePz2AoKclhVHRhHuZElq1+T +o31hYSD3phwpJtk0Fay0o0Vh2XPQibXPGITxfKk= From: Jeff Layton To: ceph-devel@vger.kernel.org Cc: ukernel@gmail.com, idryomov@gmail.com, sage@redhat.com, pdonnell@redhat.com Subject: [PATCH 4/9] ceph: add refcounting for Fx caps Date: Thu, 1 Aug 2019 16:26:00 -0400 Message-Id: <20190801202605.18172-5-jlayton@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190801202605.18172-1-jlayton@kernel.org> References: <20190801202605.18172-1-jlayton@kernel.org> MIME-Version: 1.0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Jeff Layton --- fs/ceph/caps.c | 7 +++++++ fs/ceph/inode.c | 1 + fs/ceph/super.h | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index d3b9c9d5c1bd..c8a677ddedd8 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -964,6 +964,8 @@ int __ceph_caps_used(struct ceph_inode_info *ci) used |= CEPH_CAP_FILE_WR; if (ci->i_wb_ref || ci->i_wrbuffer_ref) used |= CEPH_CAP_FILE_BUFFER; + if (ci->i_fx_ref) + used |= CEPH_CAP_FILE_EXCL; return used; } @@ -2503,6 +2505,8 @@ static void __take_cap_refs(struct ceph_inode_info *ci, int got, ci->i_rd_ref++; if (got & CEPH_CAP_FILE_CACHE) ci->i_rdcache_ref++; + if (got & CEPH_CAP_FILE_EXCL) + ci->i_fx_ref++; if (got & CEPH_CAP_FILE_WR) { if (ci->i_wr_ref == 0 && !ci->i_head_snapc) { BUG_ON(!snap_rwsem_locked); @@ -2897,6 +2901,9 @@ void ceph_put_cap_refs(struct ceph_inode_info *ci, int had) if (had & CEPH_CAP_FILE_CACHE) if (--ci->i_rdcache_ref == 0) last++; + if (had & CEPH_CAP_FILE_EXCL) + if (--ci->i_fx_ref == 0) + last++; if (had & CEPH_CAP_FILE_BUFFER) { if (--ci->i_wb_ref == 0) { last++; diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 9f135624ae47..c844bd7f5f37 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -494,6 +494,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb) ci->i_rdcache_ref = 0; ci->i_wr_ref = 0; ci->i_wb_ref = 0; + ci->i_fx_ref = 0; ci->i_wrbuffer_ref = 0; ci->i_wrbuffer_ref_head = 0; atomic_set(&ci->i_filelock_ref, 0); diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 4cd60f58d690..a9aa3e358226 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -373,7 +373,7 @@ struct ceph_inode_info { /* held references to caps */ int i_pin_ref; - int i_rd_ref, i_rdcache_ref, i_wr_ref, i_wb_ref; + int i_rd_ref, i_rdcache_ref, i_wr_ref, i_wb_ref, i_fx_ref; int i_wrbuffer_ref, i_wrbuffer_ref_head; atomic_t i_filelock_ref; atomic_t i_shared_gen; /* increment each time we get FILE_SHARED */ From patchwork Thu Aug 1 20:26:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 11071339 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 00F6F1399 for ; Thu, 1 Aug 2019 20:26:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E64BF2873B for ; Thu, 1 Aug 2019 20:26:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA48A2877B; Thu, 1 Aug 2019 20:26:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 769CF2873B for ; Thu, 1 Aug 2019 20:26:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727720AbfHAU0O (ORCPT ); Thu, 1 Aug 2019 16:26:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:49530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726999AbfHAU0N (ORCPT ); Thu, 1 Aug 2019 16:26:13 -0400 Received: from tleilax.poochiereds.net (cpe-71-70-156-158.nc.res.rr.com [71.70.156.158]) (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 4FC092087E; Thu, 1 Aug 2019 20:26:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564691171; bh=waDiAq9JxHsX1cmD1cirK7VbDedUL4nkAGbMPVeAU2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bKak0YPZB62Daeh1vmU3BYSl7Am8pOuklMZ6HwnXQkrWxorFG9zcuUoC9+sjly1y4 R3clNlJSHR+LMdpUXbbhEq+HMyxPb35rajUSMYcYK4N8kPcerPpkh7LYxCRcoF8Cz1 38cvRFT4HjolC1CcHoj11ukmtbLnvCcPcjwr4YBY= From: Jeff Layton To: ceph-devel@vger.kernel.org Cc: ukernel@gmail.com, idryomov@gmail.com, sage@redhat.com, pdonnell@redhat.com Subject: [PATCH 5/9] ceph: wait for async dir ops to complete before doing synchronous dir ops Date: Thu, 1 Aug 2019 16:26:01 -0400 Message-Id: <20190801202605.18172-6-jlayton@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190801202605.18172-1-jlayton@kernel.org> References: <20190801202605.18172-1-jlayton@kernel.org> MIME-Version: 1.0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Ensure that we wait on replies from any pending directory operations involving children before we allow synchronous operations involving that directory to proceed. Signed-off-by: Jeff Layton --- fs/ceph/dir.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- fs/ceph/file.c | 4 ++++ fs/ceph/super.h | 1 + 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index aab29f48c62d..35797ff895e7 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -1036,6 +1036,38 @@ static int ceph_link(struct dentry *old_dentry, struct inode *dir, return err; } +int ceph_async_dirop_request_wait(struct inode *inode) +{ + struct ceph_inode_info *ci = ceph_inode(inode); + struct ceph_mds_request *cur, *req; + int ret = 0; + + /* Only applicable for directories */ + if (!inode || !S_ISDIR(inode->i_mode)) + return 0; +retry: + spin_lock(&ci->i_unsafe_lock); + req = NULL; + list_for_each_entry(cur, &ci->i_unsafe_dirops, r_unsafe_dir_item) { + if (!test_bit(CEPH_MDS_R_GOT_UNSAFE, &cur->r_req_flags) && + !test_bit(CEPH_MDS_R_GOT_SAFE, &cur->r_req_flags)) { + req = cur; + ceph_mdsc_get_request(req); + break; + } + } + spin_unlock(&ci->i_unsafe_lock); + if (req) { + dout("%s %lx wait on tid %llu\n", __func__, inode->i_ino, + req->r_tid); + ret = wait_for_completion_killable(&req->r_completion); + ceph_mdsc_put_request(req); + if (!ret) + goto retry; + } + return ret; +} + /* * rmdir and unlink are differ only by the metadata op code */ @@ -1059,6 +1091,12 @@ static int ceph_unlink(struct inode *dir, struct dentry *dentry) CEPH_MDS_OP_RMDIR : CEPH_MDS_OP_UNLINK; } else goto out; + + /* Wait for any requests involving children to get a reply */ + err = ceph_async_dirop_request_wait(inode); + if (err) + goto out; + req = ceph_mdsc_create_request(mdsc, op, USE_AUTH_MDS); if (IS_ERR(req)) { err = PTR_ERR(req); @@ -1105,8 +1143,14 @@ static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry, (!ceph_quota_is_same_realm(old_dir, new_dir))) return -EXDEV; - dout("rename dir %p dentry %p to dir %p dentry %p\n", - old_dir, old_dentry, new_dir, new_dentry); + err = ceph_async_dirop_request_wait(d_inode(old_dentry)); + if (err) + return err; + + err = ceph_async_dirop_request_wait(d_inode(new_dentry)); + if (err) + return err; + req = ceph_mdsc_create_request(mdsc, op, USE_AUTH_MDS); if (IS_ERR(req)) return PTR_ERR(req); diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 3c0b5247818f..75bce889305c 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -449,6 +449,10 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry, dir, dentry, dentry, d_unhashed(dentry) ? "unhashed" : "hashed", flags, mode); + err = ceph_async_dirop_request_wait(dir); + if (err) + return err; + if (dentry->d_name.len > NAME_MAX) return -ENAMETOOLONG; diff --git a/fs/ceph/super.h b/fs/ceph/super.h index a9aa3e358226..77ed6c5900be 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -1113,6 +1113,7 @@ extern int ceph_handle_snapdir(struct ceph_mds_request *req, struct dentry *dentry, int err); extern struct dentry *ceph_finish_lookup(struct ceph_mds_request *req, struct dentry *dentry, int err); +extern int ceph_async_dirop_request_wait(struct inode *inode); extern void __ceph_dentry_lease_touch(struct ceph_dentry_info *di); extern void __ceph_dentry_dir_lease_touch(struct ceph_dentry_info *di); From patchwork Thu Aug 1 20:26:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 11071341 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F51713A0 for ; Thu, 1 Aug 2019 20:26:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E9AC2873B for ; Thu, 1 Aug 2019 20:26:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 429852877F; Thu, 1 Aug 2019 20:26:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B233D2873B for ; Thu, 1 Aug 2019 20:26:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727788AbfHAU0O (ORCPT ); Thu, 1 Aug 2019 16:26:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:49538 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727580AbfHAU0O (ORCPT ); Thu, 1 Aug 2019 16:26:14 -0400 Received: from tleilax.poochiereds.net (cpe-71-70-156-158.nc.res.rr.com [71.70.156.158]) (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 2D96F2080C; Thu, 1 Aug 2019 20:26:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564691172; bh=/V6wP1p1s6vCOrVHgVlI1NbK69cZ7hS48gm2Zqi+RYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Js4/mCQYRgWsMyxo1zt6X2+Tf5I7OMYpEdJ2wer0OVrQiEMJQOwY9nNbvz1vf9SkH 69MN6EvcjZ4lDhNMAfc4vY07a9FH5SPiKvQJWD8ak3v2+jbJFAJVINVS2M+8x+6Hfj XzBACSCcY4V8IuakIyyfDOW0SHl/P9ZWp44Fo7A4= From: Jeff Layton To: ceph-devel@vger.kernel.org Cc: ukernel@gmail.com, idryomov@gmail.com, sage@redhat.com, pdonnell@redhat.com Subject: [PATCH 6/9] ceph: check inode type for CEPH_CAP_FILE_{CACHE,RD,REXTEND,LAZYIO} Date: Thu, 1 Aug 2019 16:26:02 -0400 Message-Id: <20190801202605.18172-7-jlayton@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190801202605.18172-1-jlayton@kernel.org> References: <20190801202605.18172-1-jlayton@kernel.org> MIME-Version: 1.0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Yan, Zheng" they will have new meaning for directory inode Signed-off-by: "Yan, Zheng" --- fs/ceph/caps.c | 44 ++++++++++++++++++++++++++++++++------------ fs/ceph/mds_client.c | 3 ++- fs/ceph/super.h | 12 +----------- 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index c8a677ddedd8..a9d0a2d211ac 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -573,7 +573,8 @@ static void __check_cap_issue(struct ceph_inode_info *ci, struct ceph_cap *cap, * Each time we receive FILE_CACHE anew, we increment * i_rdcache_gen. */ - if ((issued & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) && + if (S_ISREG(ci->vfs_inode.i_mode) && + (issued & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) && (had & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) == 0) { ci->i_rdcache_gen++; } @@ -957,7 +958,7 @@ int __ceph_caps_used(struct ceph_inode_info *ci) if (ci->i_rd_ref) used |= CEPH_CAP_FILE_RD; if (ci->i_rdcache_ref || - (!S_ISDIR(ci->vfs_inode.i_mode) && /* ignore readdir cache */ + (S_ISREG(ci->vfs_inode.i_mode) && ci->vfs_inode.i_data.nrpages)) used |= CEPH_CAP_FILE_CACHE; if (ci->i_wr_ref) @@ -984,6 +985,20 @@ int __ceph_caps_file_wanted(struct ceph_inode_info *ci) return ceph_caps_for_mode(bits >> 1); } +/* + * wanted, by virtue of open file modes AND cap refs (buffered/cached data) + */ +int __ceph_caps_wanted(struct ceph_inode_info *ci) +{ + int w = __ceph_caps_file_wanted(ci) | __ceph_caps_used(ci); + if (!S_ISDIR(ci->vfs_inode.i_mode)) { + /* we want EXCL if dirty data */ + if (w & CEPH_CAP_FILE_BUFFER) + w |= CEPH_CAP_FILE_EXCL; + } + return w; +} + /* * Return caps we have registered with the MDS(s) as 'wanted'. */ @@ -1906,7 +1921,7 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags, * If we fail, it's because pages are locked.... try again later. */ if ((!no_delay || mdsc->stopping) && - !S_ISDIR(inode->i_mode) && /* ignore readdir cache */ + S_ISREG(inode->i_mode) && !(ci->i_wb_ref || ci->i_wrbuffer_ref) && /* no dirty pages... */ inode->i_data.nrpages && /* have cached pages */ (revoking & (CEPH_CAP_FILE_CACHE| @@ -2638,7 +2653,8 @@ static int try_get_cap_refs(struct inode *inode, int need, int want, snap_rwsem_locked = true; } *got = need | (have & want); - if ((need & CEPH_CAP_FILE_RD) && + if (S_ISREG(inode->i_mode) && + (need & CEPH_CAP_FILE_RD) && !(*got & CEPH_CAP_FILE_CACHE)) ceph_disable_fscache_readpage(ci); __take_cap_refs(ci, *got, true); @@ -2646,7 +2662,8 @@ static int try_get_cap_refs(struct inode *inode, int need, int want, } } else { int session_readonly = false; - if ((need & CEPH_CAP_FILE_WR) && ci->i_auth_cap) { + if (ci->i_auth_cap && + (need & (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_EXCL))) { struct ceph_mds_session *s = ci->i_auth_cap->session; spin_lock(&s->s_cap_lock); session_readonly = s->s_readonly; @@ -2803,7 +2820,8 @@ int ceph_get_caps(struct file *filp, int need, int want, return ret; } - if (ci->i_inline_version != CEPH_INLINE_NONE && + if (S_ISREG(ci->vfs_inode.i_mode) && + ci->i_inline_version != CEPH_INLINE_NONE && (_got & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) && i_size_read(inode) > 0) { struct page *page = @@ -2836,7 +2854,8 @@ int ceph_get_caps(struct file *filp, int need, int want, break; } - if ((_got & CEPH_CAP_FILE_RD) && (_got & CEPH_CAP_FILE_CACHE)) + if (S_ISREG(ci->vfs_inode.i_mode) && + (_got & CEPH_CAP_FILE_RD) && (_got & CEPH_CAP_FILE_CACHE)) ceph_fscache_revalidate_cookie(ci); *got = _got; @@ -3126,7 +3145,7 @@ static void handle_cap_grant(struct inode *inode, * try to invalidate (once). (If there are dirty buffers, we * will invalidate _after_ writeback.) */ - if (!S_ISDIR(inode->i_mode) && /* don't invalidate readdir cache */ + if (S_ISREG(inode->i_mode) && /* don't invalidate readdir cache */ ((cap->issued & ~newcaps) & CEPH_CAP_FILE_CACHE) && (newcaps & CEPH_CAP_FILE_LAZYIO) == 0 && !(ci->i_wrbuffer_ref || ci->i_wb_ref)) { @@ -3290,11 +3309,12 @@ static void handle_cap_grant(struct inode *inode, ceph_cap_string(cap->issued), ceph_cap_string(newcaps), ceph_cap_string(revoking)); - if (revoking & used & CEPH_CAP_FILE_BUFFER) + if (S_ISREG(inode->i_mode) && + (revoking & used & CEPH_CAP_FILE_BUFFER)) writeback = true; /* initiate writeback; will delay ack */ - else if (revoking == CEPH_CAP_FILE_CACHE && - (newcaps & CEPH_CAP_FILE_LAZYIO) == 0 && - queue_invalidate) + else if (queue_invalidate && + revoking == CEPH_CAP_FILE_CACHE && + (newcaps & CEPH_CAP_FILE_LAZYIO) == 0) ; /* do nothing yet, invalidation will be queued */ else if (cap == ci->i_auth_cap) check_caps = 1; /* check auth cap only */ diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 89c71db77a33..294a6153272d 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -1757,7 +1757,8 @@ static int trim_caps_cb(struct inode *inode, struct ceph_cap *cap, void *arg) } /* The inode has cached pages, but it's no longer used. * we can safely drop it */ - if (wanted == 0 && used == CEPH_CAP_FILE_CACHE && + if (S_ISREG(inode->i_mode) && + wanted == 0 && used == CEPH_CAP_FILE_CACHE && !(oissued & CEPH_CAP_FILE_CACHE)) { used = 0; oissued = 0; diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 77ed6c5900be..292ac0544e33 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -673,17 +673,7 @@ extern int ceph_caps_revoking(struct ceph_inode_info *ci, int mask); extern int __ceph_caps_used(struct ceph_inode_info *ci); extern int __ceph_caps_file_wanted(struct ceph_inode_info *ci); - -/* - * wanted, by virtue of open file modes AND cap refs (buffered/cached data) - */ -static inline int __ceph_caps_wanted(struct ceph_inode_info *ci) -{ - int w = __ceph_caps_file_wanted(ci) | __ceph_caps_used(ci); - if (w & CEPH_CAP_FILE_BUFFER) - w |= CEPH_CAP_FILE_EXCL; /* we want EXCL if dirty data */ - return w; -} +extern int __ceph_caps_wanted(struct ceph_inode_info *ci); /* what the mds thinks we want */ extern int __ceph_caps_mds_wanted(struct ceph_inode_info *ci, bool check); From patchwork Thu Aug 1 20:26:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 11071345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 17EC91399 for ; Thu, 1 Aug 2019 20:26:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08B8F286BC for ; Thu, 1 Aug 2019 20:26:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0CE228779; Thu, 1 Aug 2019 20:26:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42EA4286BC for ; Thu, 1 Aug 2019 20:26:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728255AbfHAU0Q (ORCPT ); Thu, 1 Aug 2019 16:26:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:49546 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727659AbfHAU0P (ORCPT ); Thu, 1 Aug 2019 16:26:15 -0400 Received: from tleilax.poochiereds.net (cpe-71-70-156-158.nc.res.rr.com [71.70.156.158]) (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 0A6262084C; Thu, 1 Aug 2019 20:26:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564691173; bh=Xij1cDAFauv0aRo5uNWz6wMddYgRsuoDrvdZy+qgQcc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qDafvrt6OHm58hF1E3tydhQqjyzPMEUgulJOJF3Wbvy0zqmjzquOBv5ZrrXEny4RD ZZ/APZBikw4gIRUvTPElHiMQ7iaQtDOiu+1/ftIDL/dxVsrJ+mI7fud9nAb8HpN2KN LPkmDukh0VvDa98fTJqICspC94wpbw+ysRuos4MM= From: Jeff Layton To: ceph-devel@vger.kernel.org Cc: ukernel@gmail.com, idryomov@gmail.com, sage@redhat.com, pdonnell@redhat.com Subject: [PATCH 7/9] ceph: perform asynchronous unlink if we have sufficient caps Date: Thu, 1 Aug 2019 16:26:03 -0400 Message-Id: <20190801202605.18172-8-jlayton@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190801202605.18172-1-jlayton@kernel.org> References: <20190801202605.18172-1-jlayton@kernel.org> MIME-Version: 1.0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Yan, Zheng" The MDS is getting a new lock-caching facility that will allow it to cache the necessary locks to allow asynchronous directory operations. Since the CEPH_CAP_FILE_* caps are currently unused on directories, we can repurpose those bits for this purpose. When performing an unlink, if we have Fx on the parent directory, and CEPH_CAP_DIR_UNLINK (aka Fr), and we know that the dentry being removed is the primary link, then then we can fire off an unlink request immediately and don't need to wait on reply before returning. In that situation, just fix up the dcache and link count and return immediately after issuing the call to the MDS. This does mean that we need to hold an extra reference to the inode being unlinked, and extra references to the caps to avoid races. Those references are put and error handling is done in the r_callback routine. If the operation ends up failing, then set a writeback error on the directory inode that can be fetched later by an fsync on the dir. Signed-off-by: "Yan, Zheng" Signed-off-by: Jeff Layton --- fs/ceph/caps.c | 35 ++++++++++++------ fs/ceph/dir.c | 70 +++++++++++++++++++++++++++++++++--- fs/ceph/inode.c | 8 ++++- fs/ceph/super.h | 1 + include/linux/ceph/ceph_fs.h | 9 +++++ 5 files changed, 107 insertions(+), 16 deletions(-) diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index a9d0a2d211ac..9344e742397e 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -991,7 +991,11 @@ int __ceph_caps_file_wanted(struct ceph_inode_info *ci) int __ceph_caps_wanted(struct ceph_inode_info *ci) { int w = __ceph_caps_file_wanted(ci) | __ceph_caps_used(ci); - if (!S_ISDIR(ci->vfs_inode.i_mode)) { + if (S_ISDIR(ci->vfs_inode.i_mode)) { + /* we want EXCL if holding caps of dir ops */ + if (w & CEPH_CAP_ANY_DIR_OPS) + w |= CEPH_CAP_FILE_EXCL; + } else { /* we want EXCL if dirty data */ if (w & CEPH_CAP_FILE_BUFFER) w |= CEPH_CAP_FILE_EXCL; @@ -1886,10 +1890,13 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags, * revoking the shared cap on every create/unlink * operation. */ - if (IS_RDONLY(inode)) + if (IS_RDONLY(inode)) { want = CEPH_CAP_ANY_SHARED; - else - want = CEPH_CAP_ANY_SHARED | CEPH_CAP_FILE_EXCL; + } else { + want = CEPH_CAP_ANY_SHARED | + CEPH_CAP_FILE_EXCL | + CEPH_CAP_ANY_DIR_OPS; + } retain |= want; } else { @@ -2652,7 +2659,10 @@ static int try_get_cap_refs(struct inode *inode, int need, int want, } snap_rwsem_locked = true; } - *got = need | (have & want); + if ((have & want) == want) + *got = need | want; + else + *got = need; if (S_ISREG(inode->i_mode) && (need & CEPH_CAP_FILE_RD) && !(*got & CEPH_CAP_FILE_CACHE)) @@ -2742,13 +2752,16 @@ int ceph_try_get_caps(struct inode *inode, int need, int want, int ret; BUG_ON(need & ~CEPH_CAP_FILE_RD); - BUG_ON(want & ~(CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO|CEPH_CAP_FILE_SHARED)); - ret = ceph_pool_perm_check(inode, need); - if (ret < 0) - return ret; + if (need) { + ret = ceph_pool_perm_check(inode, need); + if (ret < 0) + return ret; + } - ret = try_get_cap_refs(inode, need, want, 0, - (nonblock ? NON_BLOCKING : 0), got); + BUG_ON(want & ~(CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO | + CEPH_CAP_FILE_SHARED | CEPH_CAP_FILE_EXCL | + CEPH_CAP_ANY_DIR_OPS)); + ret = try_get_cap_refs(inode, need, want, 0, nonblock, got); return ret == -EAGAIN ? 0 : ret; } diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 35797ff895e7..2bd3e073249e 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -1068,6 +1068,47 @@ int ceph_async_dirop_request_wait(struct inode *inode) return ret; } +static void ceph_async_unlink_cb(struct ceph_mds_client *mdsc, + struct ceph_mds_request *req) +{ + /* If op failed, set error on parent directory */ + mapping_set_error(req->r_parent->i_mapping, req->r_err); + if (req->r_err) + printk("%s: req->r_err = %d\n", __func__, req->r_err); + ceph_put_cap_refs(ceph_inode(req->r_parent), + CEPH_CAP_FILE_EXCL | CEPH_CAP_DIR_UNLINK); + iput(req->r_old_inode); +} + +static bool get_caps_for_async_unlink(struct inode *dir, struct dentry *dentry) +{ + struct ceph_inode_info *ci = ceph_inode(dir); + struct ceph_dentry_info *di; + int ret, want, got; + + want = CEPH_CAP_FILE_EXCL | CEPH_CAP_DIR_UNLINK; + ret = ceph_try_get_caps(dir, 0, want, true, &got); + dout("Fx on %p ret=%d got=%d\n", dir, ret, got); + if (ret != 1 || got != want) + return false; + + spin_lock(&dentry->d_lock); + di = ceph_dentry(dentry); + /* - We are holding CEPH_CAP_FILE_EXCL, which implies + * CEPH_CAP_FILE_SHARED. + * - Only support async unlink for primary linkage */ + if (atomic_read(&ci->i_shared_gen) != di->lease_shared_gen || + !(di->flags & CEPH_DENTRY_PRIMARY_LINK)) + ret = 0; + spin_unlock(&dentry->d_lock); + + if (!ret) { + ceph_put_cap_refs(ci, got); + return false; + } + return true; +} + /* * rmdir and unlink are differ only by the metadata op code */ @@ -1105,13 +1146,33 @@ static int ceph_unlink(struct inode *dir, struct dentry *dentry) req->r_dentry = dget(dentry); req->r_num_caps = 2; req->r_parent = dir; - set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); req->r_dentry_drop = CEPH_CAP_FILE_SHARED; req->r_dentry_unless = CEPH_CAP_FILE_EXCL; req->r_inode_drop = ceph_drop_caps_for_unlink(inode); - err = ceph_mdsc_do_request(mdsc, dir, req); - if (!err && !req->r_reply_info.head->is_dentry) - d_delete(dentry); + + if (op == CEPH_MDS_OP_UNLINK && + get_caps_for_async_unlink(dir, dentry)) { + dout("ceph: Async unlink on %lu/%.*s", dir->i_ino, + dentry->d_name.len, dentry->d_name.name); + req->r_callback = ceph_async_unlink_cb; + req->r_old_inode = d_inode(dentry); + ihold(req->r_old_inode); + err = ceph_mdsc_submit_request(mdsc, dir, req); + if (!err) { + /* + * We have enough caps, so we assume that the unlink + * will succeed. Fix up the target inode and dcache. + */ + drop_nlink(inode); + d_delete(dentry); + } + } else { + set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); + err = ceph_mdsc_do_request(mdsc, dir, req); + if (!err && !req->r_reply_info.head->is_dentry) + d_delete(dentry); + } + ceph_mdsc_put_request(req); out: return err; @@ -1455,6 +1516,7 @@ void ceph_invalidate_dentry_lease(struct dentry *dentry) spin_lock(&dentry->d_lock); di->time = jiffies; di->lease_shared_gen = 0; + di->flags &= ~CEPH_DENTRY_PRIMARY_LINK; __dentry_lease_unlist(di); spin_unlock(&dentry->d_lock); } diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index c844bd7f5f37..d71d97540b72 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -1047,6 +1047,7 @@ static void __update_dentry_lease(struct inode *dir, struct dentry *dentry, struct ceph_mds_session **old_lease_session) { struct ceph_dentry_info *di = ceph_dentry(dentry); + unsigned mask = le16_to_cpu(lease->mask); long unsigned duration = le32_to_cpu(lease->duration_ms); long unsigned ttl = from_time + (duration * HZ) / 1000; long unsigned half_ttl = from_time + (duration * HZ / 2) / 1000; @@ -1058,8 +1059,13 @@ static void __update_dentry_lease(struct inode *dir, struct dentry *dentry, if (ceph_snap(dir) != CEPH_NOSNAP) return; + if (mask & CEPH_LEASE_PRIMARY_LINK) + di->flags |= CEPH_DENTRY_PRIMARY_LINK; + else + di->flags &= ~CEPH_DENTRY_PRIMARY_LINK; + di->lease_shared_gen = atomic_read(&ceph_inode(dir)->i_shared_gen); - if (duration == 0) { + if (!(mask & CEPH_LEASE_VALID)) { __ceph_dentry_dir_lease_touch(di); return; } diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 292ac0544e33..537db863010b 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -282,6 +282,7 @@ struct ceph_dentry_info { #define CEPH_DENTRY_REFERENCED 1 #define CEPH_DENTRY_LEASE_LIST 2 #define CEPH_DENTRY_SHRINK_LIST 4 +#define CEPH_DENTRY_PRIMARY_LINK 8 struct ceph_inode_xattrs_info { /* diff --git a/include/linux/ceph/ceph_fs.h b/include/linux/ceph/ceph_fs.h index cb21c5cf12c3..a099f60feb7b 100644 --- a/include/linux/ceph/ceph_fs.h +++ b/include/linux/ceph/ceph_fs.h @@ -530,6 +530,9 @@ struct ceph_mds_reply_lease { __le32 seq; } __attribute__ ((packed)); +#define CEPH_LEASE_VALID (1 | 2) /* old and new bit values */ +#define CEPH_LEASE_PRIMARY_LINK 4 /* primary linkage */ + struct ceph_mds_reply_dirfrag { __le32 frag; /* fragment */ __le32 auth; /* auth mds, if this is a delegation point */ @@ -659,6 +662,12 @@ int ceph_flags_to_mode(int flags); #define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \ CEPH_LOCK_IXATTR) +/* cap masks async dir operations */ +#define CEPH_CAP_DIR_CREATE CEPH_CAP_FILE_CACHE +#define CEPH_CAP_DIR_UNLINK CEPH_CAP_FILE_RD +#define CEPH_CAP_ANY_DIR_OPS (CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_RD | \ + CEPH_CAP_FILE_WREXTEND | CEPH_CAP_FILE_LAZYIO) + int ceph_caps_for_mode(int mode); enum { From patchwork Thu Aug 1 20:26:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 11071343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0FAD413A0 for ; Thu, 1 Aug 2019 20:26:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01C10286BC for ; Thu, 1 Aug 2019 20:26:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA34D28779; Thu, 1 Aug 2019 20:26:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5575028780 for ; Thu, 1 Aug 2019 20:26:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727993AbfHAU0P (ORCPT ); Thu, 1 Aug 2019 16:26:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:49538 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726999AbfHAU0O (ORCPT ); Thu, 1 Aug 2019 16:26:14 -0400 Received: from tleilax.poochiereds.net (cpe-71-70-156-158.nc.res.rr.com [71.70.156.158]) (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 DC5A92087E; Thu, 1 Aug 2019 20:26:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564691174; bh=nZQgPJKv5fwJ8ut+b7rCh8xkm2nY5C7BWMl6iIexTP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DbweZTEca2y2rjgMrm+LHR4wGSK1jUwTm5LV+zXoMoNvgOXXukpcmQmw/BVP+if81 wa6PfAy5n/vTX3xsKt3gq+RCbD1zhcgqKWoiVZ6rOdrWyEufpVbwIjn96a0Lk9ikuz awk6R/G2sEdru3+ZzbNkyd7LVAB4bWg8GT1YKnl8= From: Jeff Layton To: ceph-devel@vger.kernel.org Cc: ukernel@gmail.com, idryomov@gmail.com, sage@redhat.com, pdonnell@redhat.com Subject: [PATCH 8/9] ceph: new tracepoints when adding and removing caps Date: Thu, 1 Aug 2019 16:26:04 -0400 Message-Id: <20190801202605.18172-9-jlayton@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190801202605.18172-1-jlayton@kernel.org> References: <20190801202605.18172-1-jlayton@kernel.org> MIME-Version: 1.0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for two new tracepoints surrounding the adding/updating and removing of caps from the cache. To support this, we also add new functions for printing cap strings a'la ceph_cap_string(). Signed-off-by: Jeff Layton --- fs/ceph/Makefile | 3 +- fs/ceph/caps.c | 4 ++ fs/ceph/trace.c | 76 +++++++++++++++++++++++++++++++++ fs/ceph/trace.h | 55 ++++++++++++++++++++++++ include/linux/ceph/ceph_debug.h | 1 + 5 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 fs/ceph/trace.c create mode 100644 fs/ceph/trace.h diff --git a/fs/ceph/Makefile b/fs/ceph/Makefile index a699e320393f..5148284f74a9 100644 --- a/fs/ceph/Makefile +++ b/fs/ceph/Makefile @@ -3,12 +3,13 @@ # Makefile for CEPH filesystem. # +ccflags-y += -I$(src) # needed for trace events obj-$(CONFIG_CEPH_FS) += ceph.o ceph-y := super.o inode.o dir.o file.o locks.o addr.o ioctl.o \ export.o caps.o snap.o xattr.o quota.o \ mds_client.o mdsmap.o strings.o ceph_frag.o \ - debugfs.o + debugfs.o trace.o ceph-$(CONFIG_CEPH_FSCACHE) += cache.o ceph-$(CONFIG_CEPH_FS_POSIX_ACL) += acl.o diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 9344e742397e..236d9c205e3d 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -13,6 +13,7 @@ #include "super.h" #include "mds_client.h" #include "cache.h" +#include "trace.h" #include #include @@ -754,6 +755,8 @@ void ceph_add_cap(struct inode *inode, cap->mseq = mseq; cap->cap_gen = gen; + trace_ceph_add_cap(cap); + if (fmode >= 0) __ceph_get_fmode(ci, fmode); } @@ -1078,6 +1081,7 @@ void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release) int removed = 0; dout("__ceph_remove_cap %p from %p\n", cap, &ci->vfs_inode); + trace_ceph_remove_cap(cap); /* remove from session list */ spin_lock(&session->s_cap_lock); diff --git a/fs/ceph/trace.c b/fs/ceph/trace.c new file mode 100644 index 000000000000..e082d4eb973f --- /dev/null +++ b/fs/ceph/trace.c @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: GPL-2.0 +#define CREATE_TRACE_POINTS +#include "trace.h" + +#define CEPH_CAP_BASE_MASK (CEPH_CAP_GSHARED|CEPH_CAP_GEXCL) +#define CEPH_CAP_FILE_MASK (CEPH_CAP_GSHARED | \ + CEPH_CAP_GEXCL | \ + CEPH_CAP_GCACHE | \ + CEPH_CAP_GRD | \ + CEPH_CAP_GWR | \ + CEPH_CAP_GBUFFER | \ + CEPH_CAP_GWREXTEND | \ + CEPH_CAP_GLAZYIO) + +static void +trace_gcap_string(struct trace_seq *p, int c) +{ + if (c & CEPH_CAP_GSHARED) + trace_seq_putc(p, 's'); + if (c & CEPH_CAP_GEXCL) + trace_seq_putc(p, 'x'); + if (c & CEPH_CAP_GCACHE) + trace_seq_putc(p, 'c'); + if (c & CEPH_CAP_GRD) + trace_seq_putc(p, 'r'); + if (c & CEPH_CAP_GWR) + trace_seq_putc(p, 'w'); + if (c & CEPH_CAP_GBUFFER) + trace_seq_putc(p, 'b'); + if (c & CEPH_CAP_GWREXTEND) + trace_seq_putc(p, 'a'); + if (c & CEPH_CAP_GLAZYIO) + trace_seq_putc(p, 'l'); +} + +const char * +trace_ceph_cap_string(struct trace_seq *p, int caps) +{ + int c; + const char *ret = trace_seq_buffer_ptr(p); + + if (caps == 0) { + trace_seq_putc(p, '-'); + goto out; + } + + if (caps & CEPH_CAP_PIN) + trace_seq_putc(p, 'p'); + + c = (caps >> CEPH_CAP_SAUTH) & CEPH_CAP_BASE_MASK; + if (c) { + trace_seq_putc(p, 'A'); + trace_gcap_string(p, c); + } + + c = (caps >> CEPH_CAP_SLINK) & CEPH_CAP_BASE_MASK; + if (c) { + trace_seq_putc(p, 'L'); + trace_gcap_string(p, c); + } + + c = (caps >> CEPH_CAP_SXATTR) & CEPH_CAP_BASE_MASK; + if (c) { + trace_seq_putc(p, 'X'); + trace_gcap_string(p, c); + } + + c = (caps >> CEPH_CAP_SFILE) & CEPH_CAP_FILE_MASK; + if (c) { + trace_seq_putc(p, 'F'); + trace_gcap_string(p, c); + } +out: + trace_seq_putc(p, '\0'); + return ret; +} diff --git a/fs/ceph/trace.h b/fs/ceph/trace.h new file mode 100644 index 000000000000..d1cf4bb8a21d --- /dev/null +++ b/fs/ceph/trace.h @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM ceph + +#if !defined(_CEPH_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) +#define _CEPH_TRACE_H + +#include +#include +#include "super.h" + +const char *trace_ceph_cap_string(struct trace_seq *p, int caps); +#define show_caps(caps) ({ trace_ceph_cap_string(p, caps); }) + +#define show_snapid(snap) \ + __print_symbolic_u64(snap, {CEPH_NOSNAP, "NOSNAP" }) + +DECLARE_EVENT_CLASS(ceph_cap_class, + TP_PROTO(struct ceph_cap *cap), + TP_ARGS(cap), + TP_STRUCT__entry( + __field(u64, ino) + __field(u64, snap) + __field(int, issued) + __field(int, implemented) + __field(int, mds) + __field(int, mds_wanted) + ), + TP_fast_assign( + __entry->ino = cap->ci->i_vino.ino; + __entry->snap = cap->ci->i_vino.snap; + __entry->issued = cap->issued; + __entry->implemented = cap->implemented; + __entry->mds = cap->mds; + __entry->mds_wanted = cap->mds_wanted; + ), + TP_printk("ino=0x%llx snap=%s mds=%d issued=%s implemented=%s mds_wanted=%s", + __entry->ino, show_snapid(__entry->snap), __entry->mds, + show_caps(__entry->issued), show_caps(__entry->implemented), + show_caps(__entry->mds_wanted)) +) + +#define DEFINE_CEPH_CAP_EVENT(name) \ +DEFINE_EVENT(ceph_cap_class, ceph_##name, \ + TP_PROTO(struct ceph_cap *cap), \ + TP_ARGS(cap)) + +DEFINE_CEPH_CAP_EVENT(add_cap); +DEFINE_CEPH_CAP_EVENT(remove_cap); + +#endif /* _CEPH_TRACE_H */ + +#define TRACE_INCLUDE_PATH . +#define TRACE_INCLUDE_FILE trace +#include diff --git a/include/linux/ceph/ceph_debug.h b/include/linux/ceph/ceph_debug.h index d5a5da838caf..fa4a84e0e018 100644 --- a/include/linux/ceph/ceph_debug.h +++ b/include/linux/ceph/ceph_debug.h @@ -2,6 +2,7 @@ #ifndef _FS_CEPH_DEBUG_H #define _FS_CEPH_DEBUG_H +#undef pr_fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include From patchwork Thu Aug 1 20:26:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 11071347 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8327013A0 for ; Thu, 1 Aug 2019 20:26:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 747E7286BC for ; Thu, 1 Aug 2019 20:26:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 688D52873B; Thu, 1 Aug 2019 20:26:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 127482877B for ; Thu, 1 Aug 2019 20:26:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728272AbfHAU0R (ORCPT ); Thu, 1 Aug 2019 16:26:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:49556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727856AbfHAU0Q (ORCPT ); Thu, 1 Aug 2019 16:26:16 -0400 Received: from tleilax.poochiereds.net (cpe-71-70-156-158.nc.res.rr.com [71.70.156.158]) (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 C06052080C; Thu, 1 Aug 2019 20:26:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564691175; bh=p4CsUWSRZyq/rpts6dnbyJgEaqymmpri5IWTEPl/om8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cwkEWFZVNx+7tfL8a4JIR3cahuoUcEmr9O8NHkMYinPETRHi1PWMJMBelQc5ZqYHh J9Kj69TCjbTYaUc8eX0H/a6POKNOqnAEiMFGGeKtrUaSuzDLdDHGnzTjnuZuYnXOir M6SonPOiWXCMw8oC40mi3lxsd8N1LllPwOyVmhTc= From: Jeff Layton To: ceph-devel@vger.kernel.org Cc: ukernel@gmail.com, idryomov@gmail.com, sage@redhat.com, pdonnell@redhat.com Subject: [PATCH 9/9] ceph: add tracepoints for async and sync unlink Date: Thu, 1 Aug 2019 16:26:05 -0400 Message-Id: <20190801202605.18172-10-jlayton@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190801202605.18172-1-jlayton@kernel.org> References: <20190801202605.18172-1-jlayton@kernel.org> MIME-Version: 1.0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For now, they just show the parent inode info and dentry name. Signed-off-by: Jeff Layton --- fs/ceph/dir.c | 3 +++ fs/ceph/trace.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 2bd3e073249e..b318be1ff057 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -9,6 +9,7 @@ #include "super.h" #include "mds_client.h" +#include "trace.h" /* * Directory operations: readdir, lookup, create, link, unlink, @@ -1154,6 +1155,7 @@ static int ceph_unlink(struct inode *dir, struct dentry *dentry) get_caps_for_async_unlink(dir, dentry)) { dout("ceph: Async unlink on %lu/%.*s", dir->i_ino, dentry->d_name.len, dentry->d_name.name); + trace_ceph_async_unlink(dir, dentry); req->r_callback = ceph_async_unlink_cb; req->r_old_inode = d_inode(dentry); ihold(req->r_old_inode); @@ -1167,6 +1169,7 @@ static int ceph_unlink(struct inode *dir, struct dentry *dentry) d_delete(dentry); } } else { + trace_ceph_sync_unlink(dir, dentry); set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); err = ceph_mdsc_do_request(mdsc, dir, req); if (!err && !req->r_reply_info.head->is_dentry) diff --git a/fs/ceph/trace.h b/fs/ceph/trace.h index d1cf4bb8a21d..48e65075e4e3 100644 --- a/fs/ceph/trace.h +++ b/fs/ceph/trace.h @@ -48,6 +48,37 @@ DEFINE_EVENT(ceph_cap_class, ceph_##name, \ DEFINE_CEPH_CAP_EVENT(add_cap); DEFINE_CEPH_CAP_EVENT(remove_cap); +DECLARE_EVENT_CLASS(ceph_directory_class, + TP_PROTO( + const struct inode *dir, + const struct dentry *dentry + ), + TP_ARGS(dir, dentry), + TP_STRUCT__entry( + __field(u64, ino) + __field(u64, snap) + __string(name, dentry->d_name.name) + ), + TP_fast_assign( + __entry->ino = ceph_inode(dir)->i_vino.ino; + __entry->snap = ceph_inode(dir)->i_vino.snap; + __assign_str(name, dentry->d_name.name); + ), + TP_printk( + "name=%s:0x%llx/%s", + show_snapid(__entry->snap), __entry->ino, + __get_str(name) + ) +); + +#define DEFINE_CEPH_DIRECTORY_EVENT(name) \ +DEFINE_EVENT(ceph_directory_class, ceph_##name, \ + TP_PROTO(const struct inode *dir, const struct dentry *dentry), \ + TP_ARGS(dir, dentry)) + +DEFINE_CEPH_DIRECTORY_EVENT(async_unlink); +DEFINE_CEPH_DIRECTORY_EVENT(sync_unlink); + #endif /* _CEPH_TRACE_H */ #define TRACE_INCLUDE_PATH .