summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2014-01-07 15:56:06 -0500
committerSteve Dickson <steved@redhat.com>2014-01-07 15:57:48 -0500
commit35640883cf34a32f893e9fecefbb193782e9bc75 (patch)
treedf22e2007dfca0a84b5ee8cdc25b47a74e1938f7
parent9d404c0bc391c6d0294204cd9c7eba032d517013 (diff)
downloadnfs-utils-1-3-0-rc2.tar.gz
mountd: optimize libblkid usagenfs-utils-1-3-0-rc2nfs-utils-1-2-10-rc2
* 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> Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r--utils/mountd/cache.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
index e04b86e..ca35de2 100644
--- a/utils/mountd/cache.c
+++ b/utils/mountd/cache.c
@@ -266,6 +266,27 @@ static int get_uuid(const char *val, size_t uuidlen, char *u)
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,23 @@ static int uuid_by_path(char *path, int type, size_t uuidlen, char *uuid)
*/
struct statfs64 st;
char fsid_val[17];
- const char *blkid_val;
+ const char *blkid_val = NULL;
const char *val;
+ int rc;
- blkid_val = get_uuid_blkdev(path);
+ rc = statfs64(path, &st);
+
+ if (type == 0 && rc == 0) {
+ const long int *bad;
+ 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]);