#include <linux/lustre_ha.h>
#include <linux/lustre_dlm.h>
#include <linux/lprocfs_status.h>
+#include <linux/lustre_snap.h>
#include "llite_internal.h"
kmem_cache_t *ll_file_data_slab;
sbi->ll_max_read_ahead_pages = SBI_DEFAULT_RA_MAX;
INIT_LIST_HEAD(&sbi->ll_conn_chain);
INIT_HLIST_HEAD(&sbi->ll_orphan_dentry_list);
+ INIT_LIST_HEAD(&sbi->ll_mnt_list);
+ sema_init(&sbi->ll_gns_sem, 1);
+ init_completion(&sbi->ll_gns_completion);
+ sbi->ll_gns_state = LL_GNS_STATE_IDLE;
+ sbi->ll_gns_timer.data = (unsigned long)sbi;
+ sbi->ll_gns_timer.function = ll_gns_timer_callback;
+ init_timer(&sbi->ll_gns_timer);
+ INIT_LIST_HEAD(&sbi->ll_gns_sbi_head);
+
ll_set_sbi(sb, sbi);
generate_random_uuid(uuid);
struct ll_sb_info *sbi = ll_s2sbi(sb);
ENTRY;
- if (sbi != NULL)
+ if (sbi != NULL) {
+ list_del(&sbi->ll_gns_sbi_head);
+ del_timer(&sbi->ll_gns_timer);
OBD_FREE(sbi, sizeof(*sbi));
+ }
ll_set_sbi(sb, NULL);
EXIT;
}
valsize = sizeof(desc);
rc = obd_get_info(sbi->ll_osc_exp, strlen("lovdesc") + 1, "lovdesc",
&valsize, &desc);
- if (rc == 0) {
- obd_init_ea_size(sbi->ll_mdc_exp,
- obd_size_diskmd(sbi->ll_osc_exp, NULL),
- desc.ld_tgt_count*sizeof(struct llog_cookie));
-
- /* declare ourself as real client. not connection
- * from another MDS
- * FIXME: remove fake valsize, mdsize --bzzz */
- rc = obd_set_info(sbi->ll_mdc_exp, strlen("client"),
- "client", valsize, &desc);
- }
+ if (rc)
+ RETURN(rc);
+ obd_init_ea_size(sbi->ll_mdc_exp, obd_size_diskmd(sbi->ll_osc_exp, NULL),
+ desc.ld_tgt_count*sizeof(struct llog_cookie));
+
RETURN(rc);
}
CERROR("could not register mount in /proc/lustre");
}
- err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid);
+ err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid, 0);
if (err == -EBUSY) {
CERROR("An MDS (mdc %s) is performing recovery, of which this"
" client is not a part. Please wait for recovery to "
GOTO(out_mdc, err);
}
- err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid);
+ err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid, 0);
if (err == -EBUSY) {
CERROR("An OST (osc %s) is performing recovery, of which this"
" client is not a part. Please wait for recovery to "
GOTO(out_root, err);
}
+ ll_gns_add_timer(sbi);
+
/* making vm readahead 0 for 2.4.x. In the case of 2.6.x,
backing dev info assigned to inode mapping is used for
determining maximal readahead. */
#endif
sb->s_root = d_alloc_root(root);
+
+#ifdef S_PDIROPS
+ CWARN("Enabling PDIROPS\n");
+ sb->s_flags |= S_PDIROPS;
+#endif
+
RETURN(err);
out_root:
struct hlist_node *tmp, *next;
ENTRY;
+ ll_gns_del_timer(sbi);
+
ll_close_thread_shutdown(sbi->ll_lcq);
list_del(&sbi->ll_conn_chain);
RETURN(fl);
}
-void ll_options(char *options, char **ost, char **mdc, int *flags)
+void ll_options(char *options, char **ost, char **mdc, int *flags,
+ char **clone_opts)
{
char *this_char;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
continue;
if (!*mdc && (*mdc = ll_read_opt("mdc", this_char)))
continue;
+ if (!*clone_opts && (*clone_opts = ll_read_opt("clone",
+ this_char)))
+ continue;
if (!(*flags & LL_SBI_NOLCK) &&
((*flags) = (*flags) |
ll_set_opt("nolock", this_char,
LL_SBI_NOLCK)))
continue;
}
+
EXIT;
}
lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
spin_lock_init(&lli->lli_lock);
INIT_LIST_HEAD(&lli->lli_pending_write_llaps);
+ lli->lli_inode_magic = LLI_INODE_MAGIC;
}
int ll_fill_super(struct super_block *sb, void *data, int silent)
struct ll_sb_info *sbi;
char *osc = NULL;
char *mdc = NULL;
+ char *clone_opts = NULL;
int err;
ENTRY;
RETURN(-ENOMEM);
sbi->ll_flags |= LL_SBI_READAHEAD;
- ll_options(data, &osc, &mdc, &sbi->ll_flags);
+ ll_options(data, &osc, &mdc, &sbi->ll_flags, &clone_opts);
if (!osc) {
CERROR("no osc\n");
OBD_FREE(mdc, strlen(mdc) + 1);
if (osc)
OBD_FREE(osc, strlen(osc) + 1);
+ if (clone_opts)
+ OBD_FREE(clone_opts, strlen(clone_opts) + 1);
RETURN(err);
} /* ll_read_super */
-int lustre_process_log(struct lustre_mount_data *lmd, char * profile,
- struct config_llog_instance *cfg, int allow_recov)
+static int lustre_process_log(struct lustre_mount_data *lmd, char *profile,
+ struct config_llog_instance *cfg, int allow_recov)
{
struct lustre_cfg lcfg;
struct portals_cfg pcfg;
if (err)
GOTO(out_cleanup, err);
- err = obd_connect(&mdc_conn, obd, &mdc_uuid);
+ err = obd_connect(&mdc_conn, obd, &mdc_uuid, 0);
if (err) {
CERROR("cannot connect to %s: rc = %d\n", lmd->lmd_mds, err);
GOTO(out_cleanup, err);
exp = class_conn2export(&mdc_conn);
- ctxt = llog_get_context(&exp->exp_obd->obd_llogs, LLOG_CONFIG_REPL_CTXT);
-#if 1
- rc = class_config_parse_llog(ctxt, profile, cfg);
-#else
- /*
- * For debugging, it's useful to just dump the log
- */
- rc = class_config_dump_llog(ctxt, profile, cfg);
-#endif
- if (rc) {
- CERROR("class_config_parse_llog failed: rc = %d\n", rc);
- }
+ ctxt = llog_get_context(&exp->exp_obd->obd_llogs,LLOG_CONFIG_REPL_CTXT);
+ rc = class_config_process_llog(ctxt, profile, cfg);
+ if (rc)
+ CERROR("class_config_process_llog failed: rc = %d\n", rc);
err = obd_disconnect(exp, 0);
err = lustre_process_log(lmd, lmd->lmd_profile, &cfg, 0);
if (err < 0) {
CERROR("Unable to process log: %s\n", lmd->lmd_profile);
-
GOTO(out_free, err);
}
if (err)
GOTO(out_free, err);
-
+
out_dev:
if (mdc)
OBD_FREE(mdc, strlen(mdc) + 1);
int err;
if (sbi->ll_instance != NULL) {
+ struct lustre_mount_data *lmd = sbi->ll_lmd;
char * cln_prof;
struct config_llog_instance cfg;
cfg.cfg_uuid = sbi->ll_sb_uuid;
OBD_ALLOC(cln_prof, len);
- sprintf(cln_prof, "%s-clean", sbi->ll_lmd->lmd_profile);
+ sprintf(cln_prof, "%s-clean", lmd->lmd_profile);
- err = lustre_process_log(sbi->ll_lmd, cln_prof, &cfg,
- 0);
+ err = lustre_process_log(lmd, cln_prof, &cfg, 0);
if (err < 0)
CERROR("Unable to process log: %s\n", cln_prof);
OBD_FREE(cln_prof, len);
obd = NULL;
lustre_common_put_super(sb);
-
if (sbi->ll_lmd != NULL) {
char * cln_prof;
int len = strlen(sbi->ll_lmd->lmd_profile) + sizeof("-clean")+1;
EXIT;
} /* lustre_put_super */
+int ll_process_config_update(struct ll_sb_info *sbi, int clean)
+{
+ struct obd_export *mdc_exp = sbi->ll_mdc_exp;
+ struct lustre_mount_data *lmd = sbi->ll_lmd;
+ struct llog_ctxt *ctxt;
+ struct config_llog_instance cfg;
+ char *profile = lmd->lmd_profile, *name = NULL;
+ int rc, namelen = 0, version;
+ ENTRY;
+
+ if (profile == NULL)
+ RETURN(0);
+ if (lmd == NULL) {
+ CERROR("Client not mounted with zero-conf; cannot process "
+ "update log.\n");
+ RETURN(0);
+ }
+
+ rc = ldlm_cli_cancel_unused(mdc_exp->exp_obd->obd_namespace, NULL,
+ LDLM_FL_CONFIG_CHANGE, NULL);
+ if (rc != 0)
+ CWARN("ldlm_cli_cancel_unused(mdc): %d\n", rc);
+
+ rc = obd_cancel_unused(sbi->ll_osc_exp, NULL, LDLM_FL_CONFIG_CHANGE,
+ NULL);
+ if (rc != 0)
+ CWARN("obd_cancel_unused(lov): %d\n", rc);
+
+ cfg.cfg_instance = sbi->ll_instance;
+ cfg.cfg_uuid = sbi->ll_sb_uuid;
+ cfg.cfg_local_nid = lmd->lmd_local_nid;
+
+ namelen = strlen(profile) + 20; /* -clean-######### */
+ OBD_ALLOC(name, namelen);
+ if (name == NULL)
+ RETURN(-ENOMEM);
+
+ if (clean) {
+ version = sbi->ll_config_version - 1;
+ sprintf(name, "%s-clean-%d", profile, version);
+ } else {
+ version = sbi->ll_config_version + 1;
+ sprintf(name, "%s-%d", profile, version);
+ }
+
+ CWARN("Applying configuration log %s\n", name);
+
+ ctxt = llog_get_context(&mdc_exp->exp_obd->obd_llogs,
+ LLOG_CONFIG_REPL_CTXT);
+ rc = class_config_process_llog(ctxt, name, &cfg);
+ if (rc == 0)
+ sbi->ll_config_version = version;
+ CWARN("Finished applying configuration log %s: %d\n", name, rc);
+
+ if (rc == 0 && clean == 0) {
+ struct lov_desc desc;
+ int rc, valsize;
+ valsize = sizeof(desc);
+ rc = obd_get_info(sbi->ll_osc_exp, strlen("lovdesc") + 1,
+ "lovdesc", &valsize, &desc);
+
+ rc = obd_init_ea_size(mdc_exp,
+ obd_size_diskmd(sbi->ll_osc_exp, NULL),
+ (desc.ld_tgt_count *
+ sizeof(struct llog_cookie)));
+ }
+ OBD_FREE(name, namelen);
+ RETURN(rc);
+}
struct inode *ll_inode_from_lock(struct ldlm_lock *lock)
{
- struct inode *inode;
+ struct inode *inode = NULL;
l_lock(&lock->l_resource->lr_namespace->ns_lock);
- if (lock->l_ast_data)
- inode = igrab(lock->l_ast_data);
- else
- inode = NULL;
+ if (lock->l_ast_data) {
+ struct ll_inode_info *lli = ll_i2info(lock->l_ast_data);
+ if (lli->lli_inode_magic == LLI_INODE_MAGIC) {
+ inode = igrab(lock->l_ast_data);
+ } else {
+ CERROR("DEBUG: l_ast_data %p is bogus: magic %x\n",
+ lock->l_ast_data, lli->lli_inode_magic);
+ }
+ }
l_unlock(&lock->l_resource->lr_namespace->ns_lock);
return inode;
}
int null_if_equal(struct ldlm_lock *lock, void *data)
{
- if (data == lock->l_ast_data)
+ if (data == lock->l_ast_data) {
lock->l_ast_data = NULL;
- if (lock->l_req_mode != lock->l_granted_mode)
- return LDLM_ITER_STOP;
+ if (lock->l_req_mode != lock->l_granted_mode)
+ LDLM_ERROR(lock,"clearing inode with ungranted lock\n");
+ }
return LDLM_ITER_CONTINUE;
}
CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
inode->i_generation, inode);
+ lli->lli_inode_magic = LLI_INODE_DEAD;
ll_inode2fid(&fid, inode);
clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(ll_i2info(inode)->lli_flags));
md_change_cbdata(sbi->ll_mdc_exp, &fid, null_if_equal, inode);
return 0;
}
-void dump_lsm(int level, struct lov_stripe_md *lsm)
-{
- CDEBUG(level, "objid "LPX64", maxbytes "LPX64", magic 0x%08X, "
- "stripe_size %u, stripe_count %u\n",
- lsm->lsm_object_id, lsm->lsm_maxbytes, lsm->lsm_magic,
- lsm->lsm_stripe_size, lsm->lsm_stripe_count);
-}
-
void ll_update_inode(struct inode *inode, struct lustre_md *md)
{
struct ll_inode_info *lli = ll_i2info(inode);
if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
} else {
+ int i;
if (memcmp(lli->lli_smd, lsm, sizeof(*lsm))) {
CERROR("lsm mismatch for inode %ld\n",
inode->i_ino);
dump_lsm(D_ERROR, lsm);
LBUG();
}
+ /* XXX FIXME -- We should decide on a safer (atomic) and
+ * more elegant way to update the lsm */
+ for (i = 0; i < lsm->lsm_stripe_count; i++) {
+ lli->lli_smd->lsm_oinfo[i].loi_id =
+ lsm->lsm_oinfo[i].loi_id;
+ lli->lli_smd->lsm_oinfo[i].loi_gr =
+ lsm->lsm_oinfo[i].loi_gr;
+ lli->lli_smd->lsm_oinfo[i].loi_ost_idx =
+ lsm->lsm_oinfo[i].loi_ost_idx;
+ lli->lli_smd->lsm_oinfo[i].loi_ost_gen =
+ lsm->lsm_oinfo[i].loi_ost_gen;
+ }
}
/* bug 2844 - limit i_blksize for broken user-space apps */
LASSERTF(lsm->lsm_xfersize != 0, "%lu\n", lsm->lsm_xfersize);
}
}
+void ll_delete_inode(struct inode *inode)
+{
+ int rc;
+ struct ll_fid fid;
+ struct ll_sb_info *sbi = ll_i2sbi(inode);
+ ENTRY;
+
+ ll_inode2fid(&fid, inode);
+
+ rc = md_delete_object(sbi->ll_mdc_exp, &fid);
+ if (rc) {
+ CERROR("md_delete_object() failed, error %d.\n",
+ rc);
+ }
+
+ clear_inode(inode);
+ EXIT;
+}
+
int ll_iocontrol(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{