diff mbox

ceph: surround debugfs related code with CONFIG_DEBUG_FS

Message ID 1521097970-181351-1-git-send-email-cgxu519@gmx.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chengguang Xu March 15, 2018, 7:12 a.m. UTC
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 <cgxu519@gmx.com>
---
 fs/ceph/dir.c   | 105 ++++++++++++++++++++++++++++++++------------------------
 fs/ceph/super.h |   2 --
 2 files changed, 61 insertions(+), 46 deletions(-)

Comments

Ilya Dryomov March 15, 2018, 8:25 a.m. UTC | #1
On Thu, Mar 15, 2018 at 8:12 AM, Chengguang Xu <cgxu519@gmx.com> wrote:
> 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 <cgxu519@gmx.com>
> ---
>  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);

Hi Chengguang,

AFAICT it has always been used exclusively for debugging.

We don't want to get in the way of people wanting to build their
kernels without debugfs, so some !CONFIG_DEBUG_FS stubs are necessary,
but as long as it compiles without debugfs, let's not add new ones.

Thanks,

                Ilya
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chengguang Xu March 15, 2018, 8:48 a.m. UTC | #2
> Sent: Thursday, March 15, 2018 at 4:25 PM
> From: "Ilya Dryomov" <idryomov@gmail.com>
> To: "Chengguang Xu" <cgxu519@gmx.com>
> Cc: "Yan, Zheng" <zyan@redhat.com>, "Ceph Development" <ceph-devel@vger.kernel.org>
> Subject: Re: [PATCH] ceph: surround debugfs related code with CONFIG_DEBUG_FS
>
> On Thu, Mar 15, 2018 at 8:12 AM, Chengguang Xu <cgxu519@gmx.com> wrote:
> > 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 <cgxu519@gmx.com>
> > ---
> >  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);
> 
> Hi Chengguang,
> 
> AFAICT it has always been used exclusively for debugging.
> 
> We don't want to get in the way of people wanting to build their
> kernels without debugfs, so some !CONFIG_DEBUG_FS stubs are necessary,
> but as long as it compiles without debugfs, let's not add new ones.

Hi Ilya,

Got it, Thanks.

Chengguang.
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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);