X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fmount_utils.c;h=b8e97c40859965f3d3a909507f1fff502913000b;hb=49c61548c35d67f34120fd64916a55fd20a6ab68;hp=839c7f60f9d158ca533a73ded757ed134fa557e7;hpb=cfef7958178b4e2981a44b1977da6577cc152ce4;p=fs%2Flustre-release.git diff --git a/lustre/utils/mount_utils.c b/lustre/utils/mount_utils.c index 839c7f6..b8e97c4 100644 --- a/lustre/utils/mount_utils.c +++ b/lustre/utils/mount_utils.c @@ -26,7 +26,7 @@ /* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. - * Copyright (c) 2012 Whamcloud, Inc. + * Copyright (c) 2011, 2012, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -37,6 +37,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include "mount_utils.h" #include #include #include @@ -45,7 +46,6 @@ #include #include #include -#include "mount_utils.h" extern char *progname; extern int verbose; @@ -180,6 +180,20 @@ int check_mtab_entry(char *spec1, char *spec2, char *mtpt, char *type) return 0; } +#define PROC_DIR "/proc/" +static int mtab_is_proc(const char *mtab) +{ + char path[16]; + + if (readlink(mtab, path, sizeof(path)) < 0) + return 0; + + if (strncmp(path, PROC_DIR, strlen(PROC_DIR))) + return 0; + + return 1; +} + int update_mtab_entry(char *spec, char *mtpt, char *type, char *opts, int flags, int freq, int pass) { @@ -187,6 +201,10 @@ int update_mtab_entry(char *spec, char *mtpt, char *type, char *opts, struct mntent mnt; int rc = 0; + /* Don't update mtab if it is linked to any file in /proc direcotry.*/ + if (mtab_is_proc(MOUNTED)) + return 0; + mnt.mnt_fsname = spec; mnt.mnt_dir = mtpt; mnt.mnt_type = type; @@ -383,10 +401,12 @@ int osd_write_ldd(struct mkfs_opts *mop) int ret; switch (ldd->ldd_mount_type) { +#ifdef HAVE_LDISKFS_OSD case LDD_MT_LDISKFS: case LDD_MT_LDISKFS2: ret = ldiskfs_write_ldd(mop); break; +#endif /* HAVE_LDISKFS_OSD */ #ifdef HAVE_ZFS_OSD case LDD_MT_ZFS: ret = zfs_write_ldd(mop); @@ -409,10 +429,12 @@ int osd_read_ldd(char *dev, struct lustre_disk_data *ldd) int ret; switch (ldd->ldd_mount_type) { +#ifdef HAVE_LDISKFS_OSD case LDD_MT_LDISKFS: case LDD_MT_LDISKFS2: ret = ldiskfs_read_ldd(dev, ldd); break; +#endif /* HAVE_LDISKFS_OSD */ #ifdef HAVE_ZFS_OSD case LDD_MT_ZFS: ret = zfs_read_ldd(dev, ldd); @@ -434,10 +456,12 @@ int osd_is_lustre(char *dev, unsigned *mount_type) { vprint("checking for existing Lustre data: "); +#ifdef HAVE_LDISKFS_OSD if (ldiskfs_is_lustre(dev, mount_type)) { vprint("found\n"); return 1; } +#endif /* HAVE_LDISKFS_OSD */ #ifdef HAVE_ZFS_OSD if (zfs_is_lustre(dev, mount_type)) { vprint("found\n"); @@ -456,10 +480,12 @@ int osd_make_lustre(struct mkfs_opts *mop) int ret; switch (ldd->ldd_mount_type) { +#ifdef HAVE_LDISKFS_OSD case LDD_MT_LDISKFS: case LDD_MT_LDISKFS2: ret = ldiskfs_make_lustre(mop); break; +#endif /* HAVE_LDISKFS_OSD */ #ifdef HAVE_ZFS_OSD case LDD_MT_ZFS: ret = zfs_make_lustre(mop); @@ -484,12 +510,14 @@ int osd_prepare_lustre(struct mkfs_opts *mop, int ret; switch (ldd->ldd_mount_type) { +#ifdef HAVE_LDISKFS_OSD case LDD_MT_LDISKFS: case LDD_MT_LDISKFS2: ret = ldiskfs_prepare_lustre(mop, default_mountopts, default_len, always_mountopts, always_len); break; +#endif /* HAVE_LDISKFS_OSD */ #ifdef HAVE_ZFS_OSD case LDD_MT_ZFS: ret = zfs_prepare_lustre(mop, @@ -514,10 +542,12 @@ int osd_tune_lustre(char *dev, struct mount_opts *mop) int ret; switch (ldd->ldd_mount_type) { +#ifdef HAVE_LDISKFS_OSD case LDD_MT_LDISKFS: case LDD_MT_LDISKFS2: ret = ldiskfs_tune_lustre(dev, mop); break; +#endif /* HAVE_LDISKFS_OSD */ #ifdef HAVE_ZFS_OSD case LDD_MT_ZFS: ret = zfs_tune_lustre(dev, mop); @@ -540,10 +570,12 @@ int osd_label_lustre(struct mount_opts *mop) int ret; switch (ldd->ldd_mount_type) { +#ifdef HAVE_LDISKFS_OSD case LDD_MT_LDISKFS: case LDD_MT_LDISKFS2: ret = ldiskfs_label_lustre(mop); break; +#endif /* HAVE_LDISKFS_OSD */ #ifdef HAVE_ZFS_OSD case LDD_MT_ZFS: ret = zfs_label_lustre(mop); @@ -560,13 +592,46 @@ int osd_label_lustre(struct mount_opts *mop) return ret; } +/* Enable quota accounting */ +int osd_enable_quota(struct mkfs_opts *mop) +{ + struct lustre_disk_data *ldd = &mop->mo_ldd; + int ret; + + switch (ldd->ldd_mount_type) { +#ifdef HAVE_LDISKFS_OSD + case LDD_MT_EXT3: + case LDD_MT_LDISKFS: + case LDD_MT_LDISKFS2: + ret = ldiskfs_enable_quota(mop); + break; +#endif /* HAVE_LDISKFS_OSD */ +#ifdef HAVE_ZFS_OSD + case LDD_MT_ZFS: + fprintf(stderr, "this option is only valid for ldiskfs\n"); + ret = EINVAL; + break; +#endif /* HAVE_ZFS_OSD */ + default: + fatal(); + fprintf(stderr, "unknown fs type %d '%s'\n", + ldd->ldd_mount_type, MT_STR(ldd)); + ret = EINVAL; + break; + } + + return ret; +} + int osd_init(void) { int ret = 0; +#ifdef HAVE_LDISKFS_OSD ret = ldiskfs_init(); if (ret) return ret; +#endif /* HAVE_LDISKFS_OSD */ #ifdef HAVE_ZFS_OSD ret = zfs_init(); /* we want to be able to set up a ldiskfs-based filesystem w/o @@ -580,7 +645,9 @@ int osd_init(void) void osd_fini(void) { +#ifdef HAVE_LDISKFS_OSD ldiskfs_fini(); +#endif /* HAVE_LDISKFS_OSD */ #ifdef HAVE_ZFS_OSD zfs_fini(); #endif /* HAVE_ZFS_OSD */