cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [gfs2 patch] gfs2: Dump nrpages for inodes and their glocks
       [not found] <1859993006.36585610.1543346736694.JavaMail.zimbra@redhat.com>
@ 2018-11-27 19:26 ` Bob Peterson
  2018-11-29 19:36   ` Andreas Gruenbacher
  0 siblings, 1 reply; 4+ messages in thread
From: Bob Peterson @ 2018-11-27 19:26 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

This patch is based on an idea from Steve Whitehouse. The idea is
to dump the number of pages (both inode and its glock's address
space) in the glock dumps. To avoid adding any new locks, I
switch from calling i_size_read to using its constituant pieces,
namely, calling preempt_disable before gathering the values of
i_size and the new nrpages values, then I preempt_enable.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
---
 fs/gfs2/glops.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index f79ef9525e33..f60411707e88 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -470,14 +470,28 @@ static int inode_go_lock(struct gfs2_holder *gh)
 static void inode_go_dump(struct seq_file *seq, const struct gfs2_glock *gl)
 {
 	const struct gfs2_inode *ip = gl->gl_object;
+	const struct inode *inode;
+	const struct address_space *mapping = (const struct address_space *)
+		(gl + 1); /* Can't use gfs2_glock2aspace due to const */
+	unsigned long nrpages1, nrpages2;
+	loff_t i_size;
+
 	if (ip == NULL)
 		return;
-	gfs2_print_dbg(seq, " I: n:%llu/%llu t:%u f:0x%02lx d:0x%08x s:%llu\n",
+
+	inode = &ip->i_inode;
+	preempt_disable();
+	i_size = inode->i_size;
+	nrpages1 = inode->i_data.nrpages;
+	nrpages2 = mapping->nrpages;
+	preempt_enable();
+
+	gfs2_print_dbg(seq, " I: n:%llu/%llu t:%u f:0x%02lx d:0x%08x s:%llu p:%lu/%lu\n",
 		  (unsigned long long)ip->i_no_formal_ino,
 		  (unsigned long long)ip->i_no_addr,
 		  IF2DT(ip->i_inode.i_mode), ip->i_flags,
 		  (unsigned int)ip->i_diskflags,
-		  (unsigned long long)i_size_read(&ip->i_inode));
+		  (unsigned long long)i_size, nrpages1, nrpages2);
 }
 
 /**



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Cluster-devel] [gfs2 patch] gfs2: Dump nrpages for inodes and their glocks
  2018-11-27 19:26 ` [Cluster-devel] [gfs2 patch] gfs2: Dump nrpages for inodes and their glocks Bob Peterson
@ 2018-11-29 19:36   ` Andreas Gruenbacher
  2018-12-07 19:51     ` [Cluster-devel] [gfs2 patch v2] " Bob Peterson
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Gruenbacher @ 2018-11-29 19:36 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

On Tue, 27 Nov 2018 at 20:26, Bob Peterson <rpeterso@redhat.com> wrote:
> Hi,
>
> This patch is based on an idea from Steve Whitehouse. The idea is
> to dump the number of pages (both inode and its glock's address
> space) in the glock dumps. To avoid adding any new locks, I
> switch from calling i_size_read to using its constituant pieces,
> namely, calling preempt_disable before gathering the values of
> i_size and the new nrpages values, then I preempt_enable.
>
> Signed-off-by: Bob Peterson <rpeterso@redhat.com>
> ---
>  fs/gfs2/glops.c | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
> index f79ef9525e33..f60411707e88 100644
> --- a/fs/gfs2/glops.c
> +++ b/fs/gfs2/glops.c
> @@ -470,14 +470,28 @@ static int inode_go_lock(struct gfs2_holder *gh)
>  static void inode_go_dump(struct seq_file *seq, const struct gfs2_glock *gl)
>  {
>         const struct gfs2_inode *ip = gl->gl_object;
> +       const struct inode *inode;

The inode pointer can be directly initialized to &ip->i_inode even
when inode is NULL.

> +       const struct address_space *mapping = (const struct address_space *)
> +               (gl + 1); /* Can't use gfs2_glock2aspace due to const */

This introduces code duplication, which seems worse than casting away
const here.

> +       unsigned long nrpages1, nrpages2;
> +       loff_t i_size;
> +
>         if (ip == NULL)
>                 return;
> -       gfs2_print_dbg(seq, " I: n:%llu/%llu t:%u f:0x%02lx d:0x%08x s:%llu\n",
> +
> +       inode = &ip->i_inode;
> +       preempt_disable();
> +       i_size = inode->i_size;
> +       nrpages1 = inode->i_data.nrpages;
> +       nrpages2 = mapping->nrpages;
> +       preempt_enable();

Please don't open-code i_size_read: it's a simple memory read on the
architectures we really care about, and cheap enough on the others.

The nrpages values are protected by xa_lock(&mapping->i_pages). If we
really want to make sure we're always reporting correct values on
32-bit architectures, we'd probably have to read nrpages under lock.
On 64-bit architectures, I believe we can directly read the nrpages. I
agree that nrpages for the data address space can be interesting. Not
sure if nrpages for the metadata address space is important enough to
bother reporting it though.

> +
> +       gfs2_print_dbg(seq, " I: n:%llu/%llu t:%u f:0x%02lx d:0x%08x s:%llu p:%lu/%lu\n",
>                   (unsigned long long)ip->i_no_formal_ino,
>                   (unsigned long long)ip->i_no_addr,
>                   IF2DT(ip->i_inode.i_mode), ip->i_flags,
>                   (unsigned int)ip->i_diskflags,
> -                 (unsigned long long)i_size_read(&ip->i_inode));
> +                 (unsigned long long)i_size, nrpages1, nrpages2);
>  }
>
>  /**
>

Thanks,
Andreas



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Cluster-devel] [gfs2 patch v2] gfs2: Dump nrpages for inodes and their glocks
  2018-11-29 19:36   ` Andreas Gruenbacher
@ 2018-12-07 19:51     ` Bob Peterson
  2018-12-10 21:51       ` Andreas Gruenbacher
  0 siblings, 1 reply; 4+ messages in thread
From: Bob Peterson @ 2018-12-07 19:51 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

This is my latest version of this patch, revised with Andreas's
suggestions:
(1) I got dropped const from the go_dump functions to allow for
    additional locking without going through hoops.
(2) I got rid of the nrpages for the metadata.
(3) I reverted to previous i_size_read behavior.
(4) I added locking for just the nrpages value.

Regards,

Bob Peterson
Red Hat File Systems
---
This patch is based on an idea from Steve Whitehouse. The idea is
to dump the number of pages for inodes in the glock dumps.
The additional locking required me to drop const from quite a few
places.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
---
 fs/gfs2/glock.c  |  2 +-
 fs/gfs2/glock.h  |  2 +-
 fs/gfs2/glops.c  | 16 ++++++++++++----
 fs/gfs2/incore.h |  2 +-
 fs/gfs2/rgrp.c   |  2 +-
 fs/gfs2/rgrp.h   |  2 +-
 6 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 05431324b262..b92740edc416 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -1777,7 +1777,7 @@ static const char *gflags2str(char *buf, const struct gfs2_glock *gl)
  *
  */
 
-void gfs2_dump_glock(struct seq_file *seq, const struct gfs2_glock *gl)
+void gfs2_dump_glock(struct seq_file *seq, struct gfs2_glock *gl)
 {
 	const struct gfs2_glock_operations *glops = gl->gl_ops;
 	unsigned long long dtime;
diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h
index 5e12220cc0c2..8949bf28b249 100644
--- a/fs/gfs2/glock.h
+++ b/fs/gfs2/glock.h
@@ -202,7 +202,7 @@ extern int gfs2_glock_nq_num(struct gfs2_sbd *sdp, u64 number,
 			     struct gfs2_holder *gh);
 extern int gfs2_glock_nq_m(unsigned int num_gh, struct gfs2_holder *ghs);
 extern void gfs2_glock_dq_m(unsigned int num_gh, struct gfs2_holder *ghs);
-extern void gfs2_dump_glock(struct seq_file *seq, const struct gfs2_glock *gl);
+extern void gfs2_dump_glock(struct seq_file *seq, struct gfs2_glock *gl);
 #define GLOCK_BUG_ON(gl,x) do { if (unlikely(x)) { gfs2_dump_glock(NULL, gl); BUG(); } } while(0)
 extern __printf(2, 3)
 void gfs2_print_dbg(struct seq_file *seq, const char *fmt, ...);
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index f79ef9525e33..f15b4c57c4bd 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -467,17 +467,25 @@ static int inode_go_lock(struct gfs2_holder *gh)
  *
  */
 
-static void inode_go_dump(struct seq_file *seq, const struct gfs2_glock *gl)
+static void inode_go_dump(struct seq_file *seq, struct gfs2_glock *gl)
 {
-	const struct gfs2_inode *ip = gl->gl_object;
+	struct gfs2_inode *ip = gl->gl_object;
+	struct inode *inode = &ip->i_inode;
+	unsigned long nrpages;
+
 	if (ip == NULL)
 		return;
-	gfs2_print_dbg(seq, " I: n:%llu/%llu t:%u f:0x%02lx d:0x%08x s:%llu\n",
+
+	xa_lock_irq(&inode->i_data.i_pages);
+	nrpages = inode->i_data.nrpages;
+	xa_unlock_irq(&inode->i_data.i_pages);
+
+	gfs2_print_dbg(seq, " I: n:%llu/%llu t:%u f:0x%02lx d:0x%08x s:%llu p:%lu\n",
 		  (unsigned long long)ip->i_no_formal_ino,
 		  (unsigned long long)ip->i_no_addr,
 		  IF2DT(ip->i_inode.i_mode), ip->i_flags,
 		  (unsigned int)ip->i_diskflags,
-		  (unsigned long long)i_size_read(&ip->i_inode));
+		  (unsigned long long)i_size_read(inode), nrpages);
 }
 
 /**
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 663759abe60d..e10e0b0a7cd5 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -243,7 +243,7 @@ struct gfs2_glock_operations {
 	int (*go_demote_ok) (const struct gfs2_glock *gl);
 	int (*go_lock) (struct gfs2_holder *gh);
 	void (*go_unlock) (struct gfs2_holder *gh);
-	void (*go_dump)(struct seq_file *seq, const struct gfs2_glock *gl);
+	void (*go_dump)(struct seq_file *seq, struct gfs2_glock *gl);
 	void (*go_callback)(struct gfs2_glock *gl, bool remote);
 	const int go_type;
 	const unsigned long go_flags;
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index b08a530433ad..17a8d3b43990 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -2256,7 +2256,7 @@ static void rgblk_free(struct gfs2_sbd *sdp, struct gfs2_rgrpd *rgd,
  *
  */
 
-void gfs2_rgrp_dump(struct seq_file *seq, const struct gfs2_glock *gl)
+void gfs2_rgrp_dump(struct seq_file *seq, struct gfs2_glock *gl)
 {
 	struct gfs2_rgrpd *rgd = gl->gl_object;
 	struct gfs2_blkreserv *trs;
diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h
index b596c3d17988..499079a9dbbe 100644
--- a/fs/gfs2/rgrp.h
+++ b/fs/gfs2/rgrp.h
@@ -72,7 +72,7 @@ extern void gfs2_rlist_add(struct gfs2_inode *ip, struct gfs2_rgrp_list *rlist,
 extern void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist);
 extern void gfs2_rlist_free(struct gfs2_rgrp_list *rlist);
 extern u64 gfs2_ri_total(struct gfs2_sbd *sdp);
-extern void gfs2_rgrp_dump(struct seq_file *seq, const struct gfs2_glock *gl);
+extern void gfs2_rgrp_dump(struct seq_file *seq, struct gfs2_glock *gl);
 extern int gfs2_rgrp_send_discards(struct gfs2_sbd *sdp, u64 offset,
 				   struct buffer_head *bh,
 				   const struct gfs2_bitmap *bi, unsigned minlen, u64 *ptrimmed);



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Cluster-devel] [gfs2 patch v2] gfs2: Dump nrpages for inodes and their glocks
  2018-12-07 19:51     ` [Cluster-devel] [gfs2 patch v2] " Bob Peterson
@ 2018-12-10 21:51       ` Andreas Gruenbacher
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Gruenbacher @ 2018-12-10 21:51 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Fri, 7 Dec 2018 at 20:51, Bob Peterson <rpeterso@redhat.com> wrote:
>
> Hi,
>
> This is my latest version of this patch, revised with Andreas's
> suggestions:
> (1) I got dropped const from the go_dump functions to allow for
>     additional locking without going through hoops.
> (2) I got rid of the nrpages for the metadata.
> (3) I reverted to previous i_size_read behavior.
> (4) I added locking for just the nrpages value.
>
> Regards,
>
> Bob Peterson
> Red Hat File Systems
> ---
> This patch is based on an idea from Steve Whitehouse. The idea is
> to dump the number of pages for inodes in the glock dumps.
> The additional locking required me to drop const from quite a few
> places.
>
> Signed-off-by: Bob Peterson <rpeterso@redhat.com>
> ---
>  fs/gfs2/glock.c  |  2 +-
>  fs/gfs2/glock.h  |  2 +-
>  fs/gfs2/glops.c  | 16 ++++++++++++----
>  fs/gfs2/incore.h |  2 +-
>  fs/gfs2/rgrp.c   |  2 +-
>  fs/gfs2/rgrp.h   |  2 +-
>  6 files changed, 17 insertions(+), 9 deletions(-)
>
> diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
> index 05431324b262..b92740edc416 100644
> --- a/fs/gfs2/glock.c
> +++ b/fs/gfs2/glock.c
> @@ -1777,7 +1777,7 @@ static const char *gflags2str(char *buf, const struct gfs2_glock *gl)
>   *
>   */
>
> -void gfs2_dump_glock(struct seq_file *seq, const struct gfs2_glock *gl)
> +void gfs2_dump_glock(struct seq_file *seq, struct gfs2_glock *gl)
>  {
>         const struct gfs2_glock_operations *glops = gl->gl_ops;
>         unsigned long long dtime;
> diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h
> index 5e12220cc0c2..8949bf28b249 100644
> --- a/fs/gfs2/glock.h
> +++ b/fs/gfs2/glock.h
> @@ -202,7 +202,7 @@ extern int gfs2_glock_nq_num(struct gfs2_sbd *sdp, u64 number,
>                              struct gfs2_holder *gh);
>  extern int gfs2_glock_nq_m(unsigned int num_gh, struct gfs2_holder *ghs);
>  extern void gfs2_glock_dq_m(unsigned int num_gh, struct gfs2_holder *ghs);
> -extern void gfs2_dump_glock(struct seq_file *seq, const struct gfs2_glock *gl);
> +extern void gfs2_dump_glock(struct seq_file *seq, struct gfs2_glock *gl);
>  #define GLOCK_BUG_ON(gl,x) do { if (unlikely(x)) { gfs2_dump_glock(NULL, gl); BUG(); } } while(0)
>  extern __printf(2, 3)
>  void gfs2_print_dbg(struct seq_file *seq, const char *fmt, ...);
> diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
> index f79ef9525e33..f15b4c57c4bd 100644
> --- a/fs/gfs2/glops.c
> +++ b/fs/gfs2/glops.c
> @@ -467,17 +467,25 @@ static int inode_go_lock(struct gfs2_holder *gh)
>   *
>   */
>
> -static void inode_go_dump(struct seq_file *seq, const struct gfs2_glock *gl)
> +static void inode_go_dump(struct seq_file *seq, struct gfs2_glock *gl)
>  {
> -       const struct gfs2_inode *ip = gl->gl_object;
> +       struct gfs2_inode *ip = gl->gl_object;
> +       struct inode *inode = &ip->i_inode;
> +       unsigned long nrpages;
> +
>         if (ip == NULL)
>                 return;
> -       gfs2_print_dbg(seq, " I: n:%llu/%llu t:%u f:0x%02lx d:0x%08x s:%llu\n",
> +
> +       xa_lock_irq(&inode->i_data.i_pages);
> +       nrpages = inode->i_data.nrpages;
> +       xa_unlock_irq(&inode->i_data.i_pages);
> +
> +       gfs2_print_dbg(seq, " I: n:%llu/%llu t:%u f:0x%02lx d:0x%08x s:%llu p:%lu\n",
>                   (unsigned long long)ip->i_no_formal_ino,
>                   (unsigned long long)ip->i_no_addr,
>                   IF2DT(ip->i_inode.i_mode), ip->i_flags,
>                   (unsigned int)ip->i_diskflags,
> -                 (unsigned long long)i_size_read(&ip->i_inode));
> +                 (unsigned long long)i_size_read(inode), nrpages);
>  }
>
>  /**
> diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
> index 663759abe60d..e10e0b0a7cd5 100644
> --- a/fs/gfs2/incore.h
> +++ b/fs/gfs2/incore.h
> @@ -243,7 +243,7 @@ struct gfs2_glock_operations {
>         int (*go_demote_ok) (const struct gfs2_glock *gl);
>         int (*go_lock) (struct gfs2_holder *gh);
>         void (*go_unlock) (struct gfs2_holder *gh);
> -       void (*go_dump)(struct seq_file *seq, const struct gfs2_glock *gl);
> +       void (*go_dump)(struct seq_file *seq, struct gfs2_glock *gl);
>         void (*go_callback)(struct gfs2_glock *gl, bool remote);
>         const int go_type;
>         const unsigned long go_flags;
> diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
> index b08a530433ad..17a8d3b43990 100644
> --- a/fs/gfs2/rgrp.c
> +++ b/fs/gfs2/rgrp.c
> @@ -2256,7 +2256,7 @@ static void rgblk_free(struct gfs2_sbd *sdp, struct gfs2_rgrpd *rgd,
>   *
>   */
>
> -void gfs2_rgrp_dump(struct seq_file *seq, const struct gfs2_glock *gl)
> +void gfs2_rgrp_dump(struct seq_file *seq, struct gfs2_glock *gl)
>  {
>         struct gfs2_rgrpd *rgd = gl->gl_object;
>         struct gfs2_blkreserv *trs;
> diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h
> index b596c3d17988..499079a9dbbe 100644
> --- a/fs/gfs2/rgrp.h
> +++ b/fs/gfs2/rgrp.h
> @@ -72,7 +72,7 @@ extern void gfs2_rlist_add(struct gfs2_inode *ip, struct gfs2_rgrp_list *rlist,
>  extern void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist);
>  extern void gfs2_rlist_free(struct gfs2_rgrp_list *rlist);
>  extern u64 gfs2_ri_total(struct gfs2_sbd *sdp);
> -extern void gfs2_rgrp_dump(struct seq_file *seq, const struct gfs2_glock *gl);
> +extern void gfs2_rgrp_dump(struct seq_file *seq, struct gfs2_glock *gl);
>  extern int gfs2_rgrp_send_discards(struct gfs2_sbd *sdp, u64 offset,
>                                    struct buffer_head *bh,
>                                    const struct gfs2_bitmap *bi, unsigned minlen, u64 *ptrimmed);

This looks okay as far as I can see.

Thanks,
Andreas



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-10 21:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1859993006.36585610.1543346736694.JavaMail.zimbra@redhat.com>
2018-11-27 19:26 ` [Cluster-devel] [gfs2 patch] gfs2: Dump nrpages for inodes and their glocks Bob Peterson
2018-11-29 19:36   ` Andreas Gruenbacher
2018-12-07 19:51     ` [Cluster-devel] [gfs2 patch v2] " Bob Peterson
2018-12-10 21:51       ` Andreas Gruenbacher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).