+static void smfs_filter_flags(struct filter_obd * filt, struct inode * o_dir)
+{
+ struct dentry * dentry = NULL;
+ int i,j;
+
+ CDEBUG(D_SUPER,"OST OBD post_setup\n");
+ /* enable plugins for all in O */
+ SMFS_SET(I2SMI(o_dir)->smi_flags, SMFS_PLG_ALL);
+ /* enable plugins for all already created d<n> dirs */
+ for (j = 1; j < filt->fo_group_count; j++) {
+ for (i = 0; i < filt->fo_subdir_count; i++) {
+ dentry = (filt->fo_subdirs + j)->dentry[i];
+ SMFS_SET(I2SMI(dentry->d_inode)->smi_flags,
+ SMFS_PLG_ALL);
+ }
+ }
+}
+
+static void smfs_mds_flags(struct mds_obd * mds, struct inode * root)
+{
+ struct inode * pend = mds->mds_pending_dir->d_inode;
+
+ CDEBUG(D_SUPER,"MDS OBD post_setup\n");
+ /* enable plugins for all in ROOT */
+ SMFS_SET(I2SMI(root)->smi_flags, SMFS_PLG_ALL);
+ /* the same for PENDING */
+ SMFS_SET(I2SMI(pend)->smi_flags, SMFS_PLG_ALL);
+}
+
+
+int smfs_post_setup(struct obd_device *obd, struct vfsmount *mnt,
+ struct dentry * root_dentry)
+{
+ struct lvfs_run_ctxt saved, *current_ctxt = NULL;
+ struct smfs_super_info *smb = S2SMI(mnt->mnt_sb);
+ int rc = 0;
+
+ ENTRY;
+
+ OBD_ALLOC(current_ctxt, sizeof(*current_ctxt));
+ if (!current_ctxt)
+ RETURN(-ENOMEM);
+
+ OBD_SET_CTXT_MAGIC(current_ctxt);
+
+ current_ctxt->pwdmnt = mnt;
+ current_ctxt->pwd = mnt->mnt_root;
+ current_ctxt->fs = get_ds();
+ smb->smsi_ctxt = current_ctxt;
+
+ push_ctxt(&saved, smb->smsi_ctxt, NULL);
+
+ rc = smfs_llog_setup(smb);
+ if (!rc) {
+ rc = SMFS_PLG_HELP(mnt->mnt_sb, PLG_START, NULL);
+ }
+
+ pop_ctxt(&saved, smb->smsi_ctxt, NULL);
+
+ /* connect KML ctxt to obd */
+ if (obd && smb->smsi_kml_log) {
+ smb->smsi_kml_log->loc_idx = LLOG_REINT_ORIG_CTXT;
+ smb->smsi_kml_log->loc_obd = obd;
+ obd->obd_llog_ctxt[LLOG_REINT_ORIG_CTXT] = smb->smsi_kml_log;
+ }
+
+ /* enable plugins for directories on MDS or OST */
+ if (obd && obd->obd_type && obd->obd_type->typ_name) {
+ if (!strcmp(obd->obd_type->typ_name, "obdfilter")) {
+ struct filter_obd *filt = &obd->u.filter;
+
+ smfs_filter_flags(filt, root_dentry->d_inode);
+ }
+ else if (!strcmp(obd->obd_type->typ_name, "mds")) {
+ struct mds_obd * mds = &obd->u.mds;
+
+ smfs_mds_flags(mds, root_dentry->d_inode);
+ }
+ else
+ CDEBUG(D_SUPER,"Unknown OBD (%s) post_setup\n",
+ obd->obd_type->typ_name);
+ }
+
+ if (rc)
+ OBD_FREE(current_ctxt, sizeof(*current_ctxt));
+
+ RETURN(rc);
+}
+
+void smfs_post_cleanup(struct super_block *sb)
+{
+ struct smfs_super_info *smb = S2SMI(sb);
+
+ ENTRY;
+
+ smfs_llog_cleanup(smb);
+ SMFS_PLG_HELP(sb, PLG_STOP, NULL);
+
+ if (smb->smsi_ctxt)
+ OBD_FREE(smb->smsi_ctxt, sizeof(struct lvfs_run_ctxt));
+
+ EXIT;
+}
+