From patchwork Thu Mar 15 07:12:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10283949 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7ED1C602C2 for ; Thu, 15 Mar 2018 07:13:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F4BA237F1 for ; Thu, 15 Mar 2018 07:13:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53BD4288C3; Thu, 15 Mar 2018 07:13:11 +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=-6.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, 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 C0AF8237F1 for ; Thu, 15 Mar 2018 07:13:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751405AbeCOHNG (ORCPT ); Thu, 15 Mar 2018 03:13:06 -0400 Received: from mout.gmx.net ([212.227.17.21]:46823 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751095AbeCOHNF (ORCPT ); Thu, 15 Mar 2018 03:13:05 -0400 Received: from juanniu018037.ss.mogujie.org ([122.225.81.134]) by mail.gmx.com (mrgmx101 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MSZ6u-1f6Mvu2u6W-00RcsA; Thu, 15 Mar 2018 08:12:59 +0100 From: Chengguang Xu To: zyan@redhat.com Cc: idryomov@gmail.com, ceph-devel@vger.kernel.org, Chengguang Xu Subject: [PATCH] ceph: surround debugfs related code with CONFIG_DEBUG_FS Date: Thu, 15 Mar 2018 15:12:50 +0800 Message-Id: <1521097970-181351-1-git-send-email-cgxu519@gmx.com> X-Mailer: git-send-email 1.8.3.1 X-Provags-ID: V03:K0:OCqQePVix5pscEJScarNqxPDirQkcn/lA2/vWL0jw9Cz8EvNnso gfiWTcQjPL4Q6+3UXaZNU/oGbw8sIgU0yD/bCcrWDL2tGXaJbAz2AudkPsMaj8m1AKq4YZ2 yR1AQ+DtJMki7HdZusRMCbgb45ESH3+FjttNSHaZfLC70ppXlNHwN34abCqg5hwQF4gjQWd uw4VCRHZFIxrH/qP+692g== X-UI-Out-Filterresults: notjunk:1; V01:K0:MHkLogqY/DQ=:PEFIcWfTcp1M5kibgS1Nx+ EycXJjldtyIVRm9s6bRtF4/6lKOXy5b7GsRsLtSr0zjYRCPl1dBu5FJggRyYYUYlLSV0zrNqG vssTZfxMHuPJ6KD/h6pQqm+JFhGtNewPjUawRbsb33gbElOTVjiLdffXhw6tUt/nQsFROCTT1 BR+O9lrcPlyZoK/mRHdk3hD+EkOPzbFvYPcbFGEc2eMLgrSWKVABDfSxYzuukDDav4SmUQ1sj GfKSyO3KflLw+fWnItDXYp6rqyKQBNsWpRO35iCFHbTargdfON9fYIw5O5wFV5G+n4BexFIPW N/zEAzJKgtRtBE0a3Gxay5JUBFZMv73dmppLv5Kun+z70SdgBQvfSQ/zH8ChsWz9ZVuA3A0py zTFOHcBh/hfoPBJG1EbRADuH5RP+byT3mpZ6Z5hIr+SZWBKO1jdSMyjOPpOBcUVTMJ9R3QM9T 9rP7Ekn5djlzq85zPmveXp7hW8MY2SLLcPtIfe0QnTYS+hHXT7orZLKPvOmvc1gUFk0hyzjd5 gmwkYfz2j8Vi6Fvlbnj5xxLiLoql3/CV03CcAKYwXhsDzrGEbao7FrL0lxnshJy4aIpHVqaDz lDL2DJjzX9w7IXiyp/UIaPA8srpNZLRgAkdpKEvaxVuArl897QfT3iHkfNDudMou63Y8/K7g2 pcdIxD79+KBJtzoJ/T8qPnY0OURkYUu9rTiHYbliR0uibHetCG8V631/UppbQTCm8tF6a6wRX uAt3z66H8LJmsGPGgs8sn3Co1iSJuVCRE3bASBeMJPEq54t9eKf2IS2V4lyAD+IDfS/wOIhLK gLdE0cLFqAMlnus10rnCN0/VVjpyw== 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 ceph_dentry_info lru is only for debug purpose now, so surround related functions with CONFIG_DEBUG_FS and move to begin of the file for deleting extern statement in header file. Signed-off-by: Chengguang Xu --- fs/ceph/dir.c | 105 ++++++++++++++++++++++++++++++++------------------------ fs/ceph/super.h | 2 -- 2 files changed, 61 insertions(+), 46 deletions(-) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 5c5ae93..867d6dc 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -30,6 +30,67 @@ const struct dentry_operations ceph_dentry_ops; +#ifdef CONFIG_DEBUG_FS +/* + * We maintain a private dentry LRU. + * + * FIXME: this needs to be changed to a per-mds lru to be useful. + */ +static void ceph_dentry_lru_add(struct dentry *dn) +{ + struct ceph_dentry_info *di = ceph_dentry(dn); + struct ceph_mds_client *mdsc; + + dout("dentry_lru_add %p %p '%pd'\n", di, dn, dn); + mdsc = ceph_sb_to_client(dn->d_sb)->mdsc; + spin_lock(&mdsc->dentry_lru_lock); + list_add_tail(&di->lru, &mdsc->dentry_lru); + mdsc->num_dentry++; + spin_unlock(&mdsc->dentry_lru_lock); +} + +void ceph_dentry_lru_touch(struct dentry *dn) +{ + struct ceph_dentry_info *di = ceph_dentry(dn); + struct ceph_mds_client *mdsc; + + dout("dentry_lru_touch %p %p '%pd' (offset %lld)\n", di, dn, dn, + di->offset); + mdsc = ceph_sb_to_client(dn->d_sb)->mdsc; + spin_lock(&mdsc->dentry_lru_lock); + list_move_tail(&di->lru, &mdsc->dentry_lru); + spin_unlock(&mdsc->dentry_lru_lock); +} + +static void ceph_dentry_lru_del(struct dentry *dn) +{ + struct ceph_dentry_info *di = ceph_dentry(dn); + struct ceph_mds_client *mdsc; + + dout("dentry_lru_del %p %p '%pd'\n", di, dn, dn); + mdsc = ceph_sb_to_client(dn->d_sb)->mdsc; + spin_lock(&mdsc->dentry_lru_lock); + list_del_init(&di->lru); + mdsc->num_dentry--; + spin_unlock(&mdsc->dentry_lru_lock); +} + +#else + +static void ceph_dentry_lru_add(struct dentry *dn) +{ +} + +void ceph_dentry_lru_touch(struct dentry *dn) +{ +} + +static void ceph_dentry_lru_del(struct dentry *dn) +{ +} + +#endif /* CONFIG_DEBUG_FS */ + /* * Initialize ceph dentry state. */ @@ -1418,50 +1479,6 @@ static ssize_t ceph_read_dir(struct file *file, char __user *buf, size_t size, } /* - * We maintain a private dentry LRU. - * - * FIXME: this needs to be changed to a per-mds lru to be useful. - */ -void ceph_dentry_lru_add(struct dentry *dn) -{ - struct ceph_dentry_info *di = ceph_dentry(dn); - struct ceph_mds_client *mdsc; - - dout("dentry_lru_add %p %p '%pd'\n", di, dn, dn); - mdsc = ceph_sb_to_client(dn->d_sb)->mdsc; - spin_lock(&mdsc->dentry_lru_lock); - list_add_tail(&di->lru, &mdsc->dentry_lru); - mdsc->num_dentry++; - spin_unlock(&mdsc->dentry_lru_lock); -} - -void ceph_dentry_lru_touch(struct dentry *dn) -{ - struct ceph_dentry_info *di = ceph_dentry(dn); - struct ceph_mds_client *mdsc; - - dout("dentry_lru_touch %p %p '%pd' (offset %lld)\n", di, dn, dn, - di->offset); - mdsc = ceph_sb_to_client(dn->d_sb)->mdsc; - spin_lock(&mdsc->dentry_lru_lock); - list_move_tail(&di->lru, &mdsc->dentry_lru); - spin_unlock(&mdsc->dentry_lru_lock); -} - -void ceph_dentry_lru_del(struct dentry *dn) -{ - struct ceph_dentry_info *di = ceph_dentry(dn); - struct ceph_mds_client *mdsc; - - dout("dentry_lru_del %p %p '%pd'\n", di, dn, dn); - mdsc = ceph_sb_to_client(dn->d_sb)->mdsc; - spin_lock(&mdsc->dentry_lru_lock); - list_del_init(&di->lru); - mdsc->num_dentry--; - spin_unlock(&mdsc->dentry_lru_lock); -} - -/* * Return name hash for a given dentry. This is dependent on * the parent directory's hash function. */ diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 04198ae..7557dde 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -1058,9 +1058,7 @@ extern int ceph_handle_snapdir(struct ceph_mds_request *req, extern struct dentry *ceph_finish_lookup(struct ceph_mds_request *req, struct dentry *dentry, int err); -extern void ceph_dentry_lru_add(struct dentry *dn); extern void ceph_dentry_lru_touch(struct dentry *dn); -extern void ceph_dentry_lru_del(struct dentry *dn); extern void ceph_invalidate_dentry_lease(struct dentry *dentry); extern unsigned int ceph_dentry_hash(struct inode *dir, struct dentry *dn); extern void ceph_readdir_cache_release(struct ceph_readdir_cache_control *ctl);