From: Fan Yong Date: Fri, 11 Nov 2011 02:18:39 +0000 (+0800) Subject: ORNL-3 mntopt: consider low-layer options for MDT ACL flags X-Git-Tag: 2.1.52~1 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=fde3d36fb2650298c2bd2ea12e92adf232e0e786 ORNL-3 mntopt: consider low-layer options for MDT ACL flags Currently, MDT layer enables ACL support by default without checking whether low-layer (ldiskfs) enables ACL support or not, then causes unnecessary data traffic on network and through MDS stack for ACL. So MDT should communicate with low-layer before setting ACL flags. Signed-off-by: Fan Yong Change-Id: I804f10bf486745ddd3b23b89e959dfd585589ac0 Reviewed-on: http://review.whamcloud.com/1211 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/darwin/lustre_lib.h b/lustre/include/darwin/lustre_lib.h index 1b76661..337de76 100644 --- a/lustre/include/darwin/lustre_lib.h +++ b/lustre/include/darwin/lustre_lib.h @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * * GPL HEADER START @@ -22,8 +23,6 @@ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. - * - * GPL HEADER END */ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. diff --git a/lustre/include/dt_object.h b/lustre/include/dt_object.h index e6c6103..d02d664 100644 --- a/lustre/include/dt_object.h +++ b/lustre/include/dt_object.h @@ -30,6 +30,9 @@ * Use is subject to license terms. */ /* + * Copyright (c) 2011 Whamcloud, Inc. + */ +/* * This file is part of Lustre, http://www.lustre.org/ * Lustre is a trademark of Sun Microsystems, Inc. */ @@ -68,10 +71,16 @@ struct dt_object; struct dt_index_features; struct dt_quota_ctxt; +typedef enum { + MNTOPT_USERXATTR = 0x00000001, + MNTOPT_ACL = 0x00000002, +} mntopt_t; + struct dt_device_param { unsigned ddp_max_name_len; unsigned ddp_max_nlink; unsigned ddp_block_shift; + mntopt_t ddp_mntopts; }; /** diff --git a/lustre/include/lustre_lib.h b/lustre/include/lustre_lib.h index 6283648..be0d684 100644 --- a/lustre/include/lustre_lib.h +++ b/lustre/include/lustre_lib.h @@ -537,6 +537,8 @@ static inline void obd_ioctl_freedata(char *buf, int len) #define OBD_IOC_GET_OBJ_VERSION _IOR('f', 210, OBD_IOC_DATA_TYPE) +#define OBD_IOC_GET_MNTOPT _IOW('f', 220, mntopt_t) + /* XXX _IOWR('f', 250, long) has been defined in * libcfs/include/libcfs/libcfs_private.h for debug, don't use it */ diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c index 0dbfbd4..5f3a492 100644 --- a/lustre/mdd/mdd_device.c +++ b/lustre/mdd/mdd_device.c @@ -30,6 +30,9 @@ * Use is subject to license terms. */ /* + * Copyright (c) 2011 Whamcloud, Inc. + */ +/* * This file is part of Lustre, http://www.lustre.org/ * Lustre is a trademark of Sun Microsystems, Inc. * @@ -1492,11 +1495,18 @@ static int mdd_iocontrol(const struct lu_env *env, struct md_device *m, mdd = lu2mdd_dev(&m->md_lu_dev); /* Doesn't use obd_ioctl_data */ - if (cmd == OBD_IOC_CHANGELOG_CLEAR) { + switch (cmd) { + case OBD_IOC_CHANGELOG_CLEAR: { struct changelog_setinfo *cs = karg; rc = mdd_changelog_user_purge(mdd, cs->cs_id, cs->cs_recno); RETURN(rc); } + case OBD_IOC_GET_MNTOPT: { + mntopt_t *mntopts = (mntopt_t *)karg; + *mntopts = mdd->mdd_dt_conf.ddp_mntopts; + RETURN(0); + } + } /* Below ioctls use obd_ioctl_data */ if (len != sizeof(*data)) { @@ -1518,7 +1528,7 @@ static int mdd_iocontrol(const struct lu_env *env, struct md_device *m, MCUD_UNREGISTER); break; default: - rc = -EOPNOTSUPP; + rc = -ENOTTY; } RETURN (rc); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index d4de547..e45abae 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -4395,52 +4395,6 @@ static int mdt_adapt_sptlrpc_conf(struct obd_device *obd, int initial) return 0; } -static void fsoptions_to_mdt_flags(struct mdt_device *m, char *options) -{ - char *p = options; - - m->mdt_opts.mo_mds_capa = 1; - m->mdt_opts.mo_oss_capa = 1; -#ifdef CONFIG_FS_POSIX_ACL - /* ACLs should be enabled by default (b=13829) */ - m->mdt_opts.mo_acl = 1; - LCONSOLE_INFO("Enabling ACL\n"); -#else - m->mdt_opts.mo_acl = 0; - LCONSOLE_INFO("Disabling ACL\n"); -#endif - - if (!options) - return; - - while (*options) { - int len; - - while (*p && *p != ',') - p++; - - len = p - options; - if ((len == sizeof("user_xattr") - 1) && - (memcmp(options, "user_xattr", len) == 0)) { - m->mdt_opts.mo_user_xattr = 1; - LCONSOLE_INFO("Enabling user_xattr\n"); - } else if ((len == sizeof("nouser_xattr") - 1) && - (memcmp(options, "nouser_xattr", len) == 0)) { - m->mdt_opts.mo_user_xattr = 0; - LCONSOLE_INFO("Disabling user_xattr\n"); - } else if ((len == sizeof("noacl") - 1) && - (memcmp(options, "noacl", len) == 0)) { - m->mdt_opts.mo_acl = 0; - LCONSOLE_INFO("Disabling ACL\n"); - } - - if (!*p) - break; - - options = ++p; - } -} - int mdt_postrecov(const struct lu_env *, struct mdt_device *); static int mdt_init0(const struct lu_env *env, struct mdt_device *m, @@ -4456,11 +4410,10 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m, struct lu_site *s; struct md_site *mite; const char *identity_upcall = "NONE"; -#ifdef HAVE_QUOTA_SUPPORT struct md_device *next; -#endif int rc; int node_id; + mntopt_t mntopts; ENTRY; md_device_init(&m->mdt_md_dev, ldt); @@ -4486,8 +4439,6 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m, m->mdt_max_cookiesize = sizeof(struct llog_cookie); m->mdt_som_conf = 0; - m->mdt_opts.mo_user_xattr = 0; - m->mdt_opts.mo_acl = 0; m->mdt_opts.mo_cos = MDT_COS_DEFAULT; lmi = server_get_mount_2(dev); if (lmi == NULL) { @@ -4495,7 +4446,6 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m, RETURN(-EFAULT); } else { lsi = s2lsi(lmi->lmi_sb); - fsoptions_to_mdt_flags(m, lsi->lsi_lmd->lmd_opts); /* CMD is supported only in IAM mode */ ldd = lsi->lsi_ldd; LASSERT(num); @@ -4513,6 +4463,8 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m, cfs_spin_lock_init(&m->mdt_ioepoch_lock); m->mdt_opts.mo_compat_resname = 0; + m->mdt_opts.mo_mds_capa = 1; + m->mdt_opts.mo_oss_capa = 1; m->mdt_capa_timeout = CAPA_TIMEOUT; m->mdt_capa_alg = CAPA_HMAC_ALG_SHA1; m->mdt_ck_timeout = CAPA_KEY_TIMEOUT; @@ -4597,19 +4549,6 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m, /* set obd_namespace for compatibility with old code */ obd->obd_namespace = m->mdt_namespace; - /* XXX: to support suppgid for ACL, we enable identity_upcall - * by default, otherwise, maybe got unexpected -EACCESS. */ - if (m->mdt_opts.mo_acl) - identity_upcall = MDT_IDENTITY_UPCALL_PATH; - - m->mdt_identity_cache = upcall_cache_init(obd->obd_name, identity_upcall, - &mdt_identity_upcall_cache_ops); - if (IS_ERR(m->mdt_identity_cache)) { - rc = PTR_ERR(m->mdt_identity_cache); - m->mdt_identity_cache = NULL; - GOTO(err_free_ns, rc); - } - cfs_timer_init(&m->mdt_ck_timer, mdt_ck_timer_callback, m); rc = mdt_ck_thread_start(m); @@ -4630,8 +4569,8 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m, mdt_adapt_sptlrpc_conf(obd, 1); -#ifdef HAVE_QUOTA_SUPPORT next = m->mdt_child; +#ifdef HAVE_QUOTA_SUPPORT rc = next->md_ops->mdo_quota.mqo_setup(env, next, lmi->lmi_mnt); if (rc) GOTO(err_llog_cleanup, rc); @@ -4640,6 +4579,34 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m, server_put_mount_2(dev, lmi->lmi_mnt); lmi = NULL; + rc = next->md_ops->mdo_iocontrol(env, next, OBD_IOC_GET_MNTOPT, 0, + &mntopts); + if (rc) + GOTO(err_quota, rc); + + if (mntopts & MNTOPT_USERXATTR) + m->mdt_opts.mo_user_xattr = 1; + else + m->mdt_opts.mo_user_xattr = 0; + + if (mntopts & MNTOPT_ACL) + m->mdt_opts.mo_acl = 1; + else + m->mdt_opts.mo_acl = 0; + + /* XXX: to support suppgid for ACL, we enable identity_upcall + * by default, otherwise, maybe got unexpected -EACCESS. */ + if (m->mdt_opts.mo_acl) + identity_upcall = MDT_IDENTITY_UPCALL_PATH; + + m->mdt_identity_cache = upcall_cache_init(obd->obd_name,identity_upcall, + &mdt_identity_upcall_cache_ops); + if (IS_ERR(m->mdt_identity_cache)) { + rc = PTR_ERR(m->mdt_identity_cache); + m->mdt_identity_cache = NULL; + GOTO(err_quota, rc); + } + target_recovery_init(&m->mdt_lut, mdt_recovery_handle); rc = mdt_start_ptlrpc_service(m); @@ -4670,6 +4637,9 @@ err_stop_service: mdt_stop_ptlrpc_service(m); err_recovery: target_recovery_fini(obd); + upcall_cache_cleanup(m->mdt_identity_cache); + m->mdt_identity_cache = NULL; +err_quota: #ifdef HAVE_QUOTA_SUPPORT next->md_ops->mdo_quota.mqo_cleanup(env, next); #endif @@ -4682,8 +4652,6 @@ err_capa: cfs_timer_disarm(&m->mdt_ck_timer); mdt_ck_thread_stop(m); err_free_ns: - upcall_cache_cleanup(m->mdt_identity_cache); - m->mdt_identity_cache = NULL; ldlm_namespace_free(m->mdt_namespace, NULL, 0); obd->obd_namespace = m->mdt_namespace = NULL; err_fini_seq: diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 29764c9..9bdf41c 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -882,12 +882,19 @@ static void osd_conf_get(const struct lu_env *env, const struct dt_device *dev, struct dt_device_param *param) { + struct super_block *sb = osd_sb(osd_dt_dev(dev)); + /* * XXX should be taken from not-yet-existing fs abstraction layer. */ - param->ddp_max_name_len = LDISKFS_NAME_LEN; - param->ddp_max_nlink = LDISKFS_LINK_MAX; - param->ddp_block_shift = osd_sb(osd_dt_dev(dev))->s_blocksize_bits; + param->ddp_max_name_len = LDISKFS_NAME_LEN; + param->ddp_max_nlink = LDISKFS_LINK_MAX; + param->ddp_block_shift = osd_sb(osd_dt_dev(dev))->s_blocksize_bits; + param->ddp_mntopts = 0; + if (test_opt(sb, XATTR_USER)) + param->ddp_mntopts |= MNTOPT_USERXATTR; + if (test_opt(sb, POSIX_ACL)) + param->ddp_mntopts |= MNTOPT_ACL; } /**