linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Sander Klein <roedie@roedie.nl>
Cc: Karel Zak <kzak@redhat.com>,
	linux-nfs@vger.kernel.org, linux-nfs-owner@vger.kernel.org,
	steved@redhat.com
Subject: Re: rpc.mountd high cpu usage
Date: Tue, 7 Jan 2014 15:49:20 -0500	[thread overview]
Message-ID: <20140107204920.GB15922@fieldses.org> (raw)
In-Reply-To: <0a94c641959a8084a56c688dd2242c04@roedie.nl>

On Tue, Jan 07, 2014 at 08:55:12PM +0100, Sander Klein wrote:
> Hi,
> 
> Thank you very much for this patch. I've added the ZFS magic and
> tested it on my nfs-utils-1.2.8 package and it looks like it fixes
> my issue.
> 
> Is there any chance this patch will be accepted upstream with the
> ZFS_SUPER_MAGIC as shown below?

OK by me; cc'ing steved.

--b.

> 
> Greets,
> 
> Sander
> 
> From e4f5b38c87ef8d713c6d0a3169afaf1acc7e22c6 Mon Sep 17 00:00:00 2001
> From: Karel Zak <kzak@redhat.com>
> Date: Mon, 6 Jan 2014 12:03:01 +0100
> Subject: [PATCH] mountd: optimize libblkid usage
> 
>  * use get_uuid_blkdev() only first time for the path (it means
>    that uuid_by_path() is called with type==0)
> 
>  * don't use libblkid for btrfs, network or pseudo filesystems
> 
> Note that the patch defines the fs type ID rather than include
> <linux/magic.h> as this file seems incomplete and libc specific).
> 
> Signed-off-by: Karel Zak <kzak@redhat.com>
> ---
>  utils/mountd/cache.c | 38 +++++++++++++++++++++++++++++++++++---
>  1 file changed, 35 insertions(+), 3 deletions(-)
> 
> Index: nfs-utils-1.2.8/utils/mountd/cache.c
> ===================================================================
> --- nfs-utils-1.2.8.orig/utils/mountd/cache.c	2013-05-02
> 14:21:12.000000000 +0200
> +++ nfs-utils-1.2.8/utils/mountd/cache.c	2014-01-07
> 20:46:55.799904557 +0100
> @@ -266,6 +266,27 @@
>  	return 1;
>  }
> 
> +
> +/*
> + * Don't ask libblkid for these filesystems. Note that BTRF is
> ignored, because
> + * we generate the identifier from statfs->f_fsid. The rest are
> network or
> + * pseudo filesystems. (See <linux/magic.h> for the basic IDs.)
> + */
> +static const long int nonblkid_filesystems[] = {
> +	0x2fc12fc1,	/* ZFS_SUPER_MAGIC */
> +	0x9123683E,	/* BTRFS_SUPER_MAGIC */
> +	0xFF534D42,	/* CIFS_MAGIC_NUMBER */
> +	0x1373,		/* DEVFS_SUPER_MAGIC */
> +	0x73757245,	/* CODA_SUPER_MAGIC */
> +	0x564C,		/* NCP_SUPER_MAGIC */
> +	0x6969,		/* NFS_SUPER_MAGIC */
> +	0x9FA0,		/* PROC_SUPER_MAGIC */
> +	0x62656572,	/* SYSFS_MAGIC */
> +	0x517B,		/* SMB_SUPER_MAGIC */
> +	0x01021994,	/* TMPFS_SUPER_MAGIC */
> +	0		/* last */
> +};
> +
>  static int uuid_by_path(char *path, int type, size_t uuidlen, char
> *uuid)
>  {
>  	/* get a uuid for the filesystem found at 'path'.
> @@ -297,12 +318,24 @@
>  	 */
>  	struct statfs64 st;
>  	char fsid_val[17];
> -	const char *blkid_val;
> +	const char *blkid_val = NULL;
>  	const char *val;
> +	int rc;
> +
> +	rc = statfs64(path, &st);
> +
> +	if (type == 0 && rc == 0) {
> +		const long int *bad;
> 
> -	blkid_val = get_uuid_blkdev(path);
> +		for (bad = nonblkid_filesystems; *bad; bad++) {
> +			if (*bad == st.f_type)
> +				break;
> +		}
> +		if (*bad == 0)
> +			blkid_val = get_uuid_blkdev(path);
> +	}
> 
> -	if (statfs64(path, &st) == 0 &&
> +	if (rc == 0 &&
>  	    (st.f_fsid.__val[0] || st.f_fsid.__val[1]))
>  		snprintf(fsid_val, 17, "%08x%08x",
>  			 st.f_fsid.__val[0], st.f_fsid.__val[1]);
> 

  reply	other threads:[~2014-01-07 20:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-12 10:13 rpc.mountd high cpu usage Sander Klein
2013-12-12 15:46 ` J. Bruce Fields
2013-12-12 16:42   ` Sander Klein
2013-12-12 21:22     ` J. Bruce Fields
2013-12-13 19:32       ` Sander Klein
2013-12-19 17:09         ` J. Bruce Fields
2013-12-23 11:01           ` Sander Klein
2014-01-06 11:18   ` Karel Zak
2014-01-06 16:20     ` Sander Klein
2014-01-06 16:31       ` Karel Zak
2014-01-06 21:25     ` J. Bruce Fields
2014-01-07 19:55       ` Sander Klein
2014-01-07 20:49         ` J. Bruce Fields [this message]
2014-01-07 21:01         ` Steve Dickson
2014-01-08  9:09           ` Sander Klein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140107204920.GB15922@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=kzak@redhat.com \
    --cc=linux-nfs-owner@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=roedie@roedie.nl \
    --cc=steved@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).