From patchwork Tue Apr 9 19:42:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 10892207 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 87F4F13B5 for ; Tue, 9 Apr 2019 19:42:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7729128950 for ; Tue, 9 Apr 2019 19:42:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6BA5528980; Tue, 9 Apr 2019 19:42:43 +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 1A37A28969 for ; Tue, 9 Apr 2019 19:42:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726712AbfDITml (ORCPT ); Tue, 9 Apr 2019 15:42:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:57818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726615AbfDITmg (ORCPT ); Tue, 9 Apr 2019 15:42:36 -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 8A3492077C for ; Tue, 9 Apr 2019 19:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554838955; bh=YJOpTLsPZfqz0GBaN8f/e9Xy90XOCpjZXiXwkpONkHk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nznqVKQIcUdls7ae0G+SC0cwSRn7wDVNSZf41Wm5sQTjzBji6hnFSNHWnNhzl8Re8 2zM8wOBRGUhtdW202ca8ISjsvfogKwia8TGAzkpZDRD5padb9qAUwfnG71v4CqqHBn bYf14WgrwZTN8aaBdO2afc9Vmony1HpUyZmMFPkk= From: Jeff Layton To: ceph-devel@vger.kernel.org Subject: [RFC PATCH 09/11] ceph: add refcounting for Lx caps Date: Tue, 9 Apr 2019 15:42:27 -0400 Message-Id: <20190409194229.8247-10-jlayton@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190409194229.8247-1-jlayton@kernel.org> References: <20190409194229.8247-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 6dc96844fdee..d022e15c8378 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -989,6 +989,8 @@ int __ceph_caps_used(struct ceph_inode_info *ci) used |= CEPH_CAP_FILE_BUFFER; if (ci->i_fx_ref) used |= CEPH_CAP_FILE_EXCL; + if (ci->i_lx_ref) + used |= CEPH_CAP_LINK_EXCL; return used; } @@ -2506,6 +2508,8 @@ static void __take_cap_refs(struct ceph_inode_info *ci, int got, ci->i_rdcache_ref++; if (got & CEPH_CAP_FILE_EXCL) ci->i_fx_ref++; + if (got & CEPH_CAP_LINK_EXCL) + ci->i_lx_ref++; if (got & CEPH_CAP_FILE_WR) { if (ci->i_wr_ref == 0 && !ci->i_head_snapc) { BUG_ON(!snap_rwsem_locked); @@ -2872,6 +2876,9 @@ void ceph_put_cap_refs(struct ceph_inode_info *ci, int had) if (had & CEPH_CAP_FILE_EXCL) if (--ci->i_fx_ref == 0) last++; + if (had & CEPH_CAP_LINK_EXCL) + if (--ci->i_lx_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 2a5b22985699..a7385ce4500b 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -495,6 +495,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb) ci->i_wr_ref = 0; ci->i_wb_ref = 0; ci->i_fx_ref = 0; + ci->i_lx_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 03cbb80faab1..3c5608f2108a 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -368,7 +368,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, i_fx_ref; + int i_rd_ref, i_rdcache_ref, i_wr_ref, i_wb_ref, i_fx_ref, i_lx_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 */